@stencil/core
Version:
A Compiler for Web Components and Progressive Web Apps
1,414 lines (1,377 loc) • 116 kB
JavaScript
/*
Stencil Client Platform v4.22.2 | 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/client/client-build.ts
import { BUILD } from "@stencil/core/internal/app-data";
var Build = {
isDev: BUILD.isDev ? true : false,
isBrowser: true,
isServer: false,
isTesting: BUILD.isTesting ? true : false
};
// src/client/client-host-ref.ts
import { BUILD as BUILD2 } from "@stencil/core/internal/app-data";
var hostRefs = BUILD2.hotModuleReplacement ? window.__STENCIL_HOSTREFS__ || (window.__STENCIL_HOSTREFS__ = /* @__PURE__ */ new WeakMap()) : /* @__PURE__ */ new WeakMap();
var getHostRef = (ref) => hostRefs.get(ref);
var registerInstance = (lazyInstance, hostRef) => hostRefs.set(hostRef.$lazyInstance$ = lazyInstance, hostRef);
var registerHost = (hostElement, cmpMeta) => {
const hostRef = {
$flags$: 0,
$hostElement$: hostElement,
$cmpMeta$: cmpMeta,
$instanceValues$: /* @__PURE__ */ new Map()
};
if (BUILD2.isDev) {
hostRef.$renderCount$ = 0;
}
if (BUILD2.method && BUILD2.lazyLoad) {
hostRef.$onInstancePromise$ = new Promise((r) => hostRef.$onInstanceResolve$ = r);
}
if (BUILD2.asyncLoading) {
hostRef.$onReadyPromise$ = new Promise((r) => hostRef.$onReadyResolve$ = r);
hostElement["s-p"] = [];
hostElement["s-rc"] = [];
}
return hostRefs.set(hostElement, hostRef);
};
var isMemberInElement = (elm, memberName) => memberName in elm;
// src/client/client-load-module.ts
import { BUILD as BUILD4 } from "@stencil/core/internal/app-data";
// src/client/client-log.ts
import { BUILD as BUILD3 } from "@stencil/core/internal/app-data";
var customError;
var consoleError = (e, el) => (customError || console.error)(e, el);
var STENCIL_DEV_MODE = BUILD3.isTesting ? ["STENCIL:"] : [
"%cstencil",
"color: white;background:#4c47ff;font-weight: bold; font-size:10px; padding:2px 6px; border-radius: 5px"
];
var consoleDevError = (...m) => console.error(...STENCIL_DEV_MODE, ...m);
var consoleDevWarn = (...m) => console.warn(...STENCIL_DEV_MODE, ...m);
var consoleDevInfo = (...m) => console.info(...STENCIL_DEV_MODE, ...m);
var setErrorHandler = (handler) => customError = handler;
// src/client/client-load-module.ts
var cmpModules = /* @__PURE__ */ new Map();
var MODULE_IMPORT_PREFIX = "./";
var loadModule = (cmpMeta, hostRef, hmrVersionId) => {
const exportName = cmpMeta.$tagName$.replace(/-/g, "_");
const bundleId = cmpMeta.$lazyBundleId$;
if (BUILD4.isDev && typeof bundleId !== "string") {
consoleDevError(
`Trying to lazily load component <${cmpMeta.$tagName$}> with style mode "${hostRef.$modeName$}", but it does not exist.`
);
return void 0;
} else if (!bundleId) {
return void 0;
}
const module = !BUILD4.hotModuleReplacement ? cmpModules.get(bundleId) : false;
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${BUILD4.hotModuleReplacement && hmrVersionId ? "?s-hmr=" + hmrVersionId : ""}`
).then((importedModule) => {
if (!BUILD4.hotModuleReplacement) {
cmpModules.set(bundleId, importedModule);
}
return importedModule[exportName];
}, consoleError);
};
// src/client/client-style.ts
var styles = /* @__PURE__ */ new Map();
var modeResolutionChain = [];
// src/client/client-task-queue.ts
import { BUILD as BUILD6 } from "@stencil/core/internal/app-data";
// src/runtime/runtime-constants.ts
var CONTENT_REF_ID = "r";
var ORG_LOCATION_ID = "o";
var SLOT_NODE_ID = "s";
var TEXT_NODE_ID = "t";
var HYDRATE_ID = "s-id";
var HYDRATED_STYLE_ID = "sty-id";
var HYDRATE_CHILD_ID = "c-id";
var HYDRATED_CSS = "{visibility:hidden}.hydrated{visibility:inherit}";
var STENCIL_DOC_DATA = "_stencilDocData";
var DEFAULT_DOC_DATA = {
hostIds: 0,
rootLevelIds: 0,
staticComponents: /* @__PURE__ */ new Set()
};
var SLOT_FB_CSS = "slot-fb{display:contents}slot-fb[hidden]{display:none}";
var XLINK_NS = "http://www.w3.org/1999/xlink";
var FORM_ASSOCIATED_CUSTOM_ELEMENT_CALLBACKS = [
"formAssociatedCallback",
"formResetCallback",
"formDisabledCallback",
"formStateRestoreCallback"
];
// src/client/client-window.ts
import { BUILD as BUILD5 } from "@stencil/core/internal/app-data";
var win = typeof window !== "undefined" ? window : {};
var doc = win.document || { head: {} };
var H = win.HTMLElement || class {
};
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 setPlatformHelpers = (helpers) => {
Object.assign(plt, helpers);
};
var supportsShadow = BUILD5.shadowDom;
var supportsListenerOptions = /* @__PURE__ */ (() => {
let supportsListenerOptions2 = false;
try {
doc.addEventListener(
"e",
null,
Object.defineProperty({}, "passive", {
get() {
supportsListenerOptions2 = true;
}
})
);
} catch (e) {
}
return supportsListenerOptions2;
})();
var promiseResolve = (v) => Promise.resolve(v);
var supportsConstructableStylesheets = BUILD5.constructableCSS ? /* @__PURE__ */ (() => {
try {
new CSSStyleSheet();
return typeof new CSSStyleSheet().replaceSync === "function";
} catch (e) {
}
return false;
})() : false;
// src/client/client-task-queue.ts
var queueCongestion = 0;
var queuePending = false;
var queueDomReads = [];
var queueDomWrites = [];
var queueDomWritesLow = [];
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 consumeTimeout = (queue, timeout) => {
let i2 = 0;
let ts = 0;
while (i2 < queue.length && (ts = performance.now()) < timeout) {
try {
queue[i2++](ts);
} catch (e) {
consoleError(e);
}
}
if (i2 === queue.length) {
queue.length = 0;
} else if (i2 !== 0) {
queue.splice(0, i2);
}
};
var flush = () => {
if (BUILD6.asyncQueue) {
queueCongestion++;
}
consume(queueDomReads);
if (BUILD6.asyncQueue) {
const timeout = (plt.$flags$ & 6 /* queueMask */) === 2 /* appLoaded */ ? performance.now() + 14 * Math.ceil(queueCongestion * (1 / 10)) : Infinity;
consumeTimeout(queueDomWrites, timeout);
consumeTimeout(queueDomWritesLow, timeout);
if (queueDomWrites.length > 0) {
queueDomWritesLow.push(...queueDomWrites);
queueDomWrites.length = 0;
}
if (queuePending = queueDomReads.length + queueDomWrites.length + queueDomWritesLow.length > 0) {
plt.raf(flush);
} else {
queueCongestion = 0;
}
} else {
consume(queueDomWrites);
if (queuePending = queueDomReads.length > 0) {
plt.raf(flush);
}
}
};
var nextTick = (cb) => promiseResolve().then(cb);
var readTask = /* @__PURE__ */ queueTask(queueDomReads, false);
var writeTask = /* @__PURE__ */ queueTask(queueDomWrites, true);
// src/client/index.ts
import { BUILD as BUILD27, Env, NAMESPACE as NAMESPACE2 } from "@stencil/core/internal/app-data";
// src/runtime/asset-path.ts
var getAssetPath = (path) => {
const assetUrl = new URL(path, plt.$resourcesUrl$);
return assetUrl.origin !== win.location.origin ? assetUrl.href : assetUrl.pathname;
};
var setAssetPath = (path) => plt.$resourcesUrl$ = path;
// src/runtime/bootstrap-custom-element.ts
import { BUILD as BUILD24 } from "@stencil/core/internal/app-data";
// src/utils/constants.ts
var EMPTY_OBJ = {};
var SVG_NS = "http://www.w3.org/2000/svg";
var HTML_NS = "http://www.w3.org/1999/xhtml";
// src/utils/helpers.ts
var isDef = (v) => v != null;
var isComplexType = (o) => {
o = typeof o;
return o === "object" || o === "function";
};
// src/utils/query-nonce-meta-tag-content.ts
function queryNonceMetaTagContent(doc2) {
var _a, _b, _c;
return (_c = (_b = (_a = doc2.head) == null ? void 0 : _a.querySelector('meta[name="csp-nonce"]')) == null ? void 0 : _b.getAttribute("content")) != null ? _c : void 0;
}
// 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/runtime/connected-callback.ts
import { BUILD as BUILD21 } from "@stencil/core/internal/app-data";
// src/runtime/client-hydrate.ts
import { BUILD as BUILD9 } from "@stencil/core/internal/app-data";
// src/runtime/profile.ts
import { BUILD as BUILD7 } from "@stencil/core/internal/app-data";
var i = 0;
var createTime = (fnName, tagName = "") => {
if (BUILD7.profile && performance.mark) {
const key = `st:${fnName}:${tagName}:${i++}`;
performance.mark(key);
return () => performance.measure(`[Stencil] ${fnName}() <${tagName}>`, key);
} else {
return () => {
return;
};
}
};
var uniqueTime = (key, measureText) => {
if (BUILD7.profile && performance.mark) {
if (performance.getEntriesByName(key, "mark").length === 0) {
performance.mark(key);
}
return () => {
if (performance.getEntriesByName(measureText, "measure").length === 0) {
performance.measure(measureText, key);
}
};
} else {
return () => {
return;
};
}
};
var inspect = (ref) => {
const hostRef = getHostRef(ref);
if (!hostRef) {
return void 0;
}
const flags = hostRef.$flags$;
const hostElement = hostRef.$hostElement$;
return {
renderCount: hostRef.$renderCount$,
flags: {
hasRendered: !!(flags & 2 /* hasRendered */),
hasConnected: !!(flags & 1 /* hasConnected */),
isWaitingForChildren: !!(flags & 4 /* isWaitingForChildren */),
isConstructingInstance: !!(flags & 8 /* isConstructingInstance */),
isQueuedForUpdate: !!(flags & 16 /* isQueuedForUpdate */),
hasInitializedComponent: !!(flags & 32 /* hasInitializedComponent */),
hasLoadedComponent: !!(flags & 64 /* hasLoadedComponent */),
isWatchReady: !!(flags & 128 /* isWatchReady */),
isListenReady: !!(flags & 256 /* isListenReady */),
needsRerender: !!(flags & 512 /* needsRerender */)
},
instanceValues: hostRef.$instanceValues$,
ancestorComponent: hostRef.$ancestorComponent$,
hostElement,
lazyInstance: hostRef.$lazyInstance$,
vnode: hostRef.$vnode$,
modeName: hostRef.$modeName$,
onReadyPromise: hostRef.$onReadyPromise$,
onReadyResolve: hostRef.$onReadyResolve$,
onInstancePromise: hostRef.$onInstancePromise$,
onInstanceResolve: hostRef.$onInstanceResolve$,
onRenderResolve: hostRef.$onRenderResolve$,
queuedListeners: hostRef.$queuedListeners$,
rmListeners: hostRef.$rmListeners$,
["s-id"]: hostElement["s-id"],
["s-cr"]: hostElement["s-cr"],
["s-lr"]: hostElement["s-lr"],
["s-p"]: hostElement["s-p"],
["s-rc"]: hostElement["s-rc"],
["s-sc"]: hostElement["s-sc"]
};
};
var installDevTools = () => {
if (BUILD7.devTools) {
const stencil = win.stencil = win.stencil || {};
const originalInspect = stencil.inspect;
stencil.inspect = (ref) => {
let result = inspect(ref);
if (!result && typeof originalInspect === "function") {
result = originalInspect(ref);
}
return result;
};
}
};
// src/runtime/vdom/h.ts
import { BUILD as BUILD8 } from "@stencil/core/internal/app-data";
var h = (nodeName, vnodeData, ...children) => {
let child = null;
let key = null;
let slotName = null;
let simple = false;
let lastSimple = false;
const vNodeChildren = [];
const walk = (c) => {
for (let i2 = 0; i2 < c.length; i2++) {
child = c[i2];
if (Array.isArray(child)) {
walk(child);
} else if (child != null && typeof child !== "boolean") {
if (simple = typeof nodeName !== "function" && !isComplexType(child)) {
child = String(child);
} else if (BUILD8.isDev && typeof nodeName !== "function" && child.$flags$ === void 0) {
consoleDevError(`vNode passed as children has unexpected type.
Make sure it's using the correct h() function.
Empty objects can also be the cause, look for JSX comments that became objects.`);
}
if (simple && lastSimple) {
vNodeChildren[vNodeChildren.length - 1].$text$ += child;
} else {
vNodeChildren.push(simple ? newVNode(null, child) : child);
}
lastSimple = simple;
}
}
};
walk(children);
if (vnodeData) {
if (BUILD8.isDev && nodeName === "input") {
validateInputProperties(vnodeData);
}
if (BUILD8.vdomKey && vnodeData.key) {
key = vnodeData.key;
}
if (BUILD8.slotRelocation && vnodeData.name) {
slotName = vnodeData.name;
}
if (BUILD8.vdomClass) {
const classData = vnodeData.className || vnodeData.class;
if (classData) {
vnodeData.class = typeof classData !== "object" ? classData : Object.keys(classData).filter((k) => classData[k]).join(" ");
}
}
}
if (BUILD8.isDev && vNodeChildren.some(isHost)) {
consoleDevError(`The <Host> must be the single root component. Make sure:
- You are NOT using hostData() and <Host> in the same component.
- <Host> is used once, and it's the single root component of the render() function.`);
}
if (BUILD8.vdomFunctional && typeof nodeName === "function") {
return nodeName(
vnodeData === null ? {} : vnodeData,
vNodeChildren,
vdomFnUtils
);
}
const vnode = newVNode(nodeName, null);
vnode.$attrs$ = vnodeData;
if (vNodeChildren.length > 0) {
vnode.$children$ = vNodeChildren;
}
if (BUILD8.vdomKey) {
vnode.$key$ = key;
}
if (BUILD8.slotRelocation) {
vnode.$name$ = slotName;
}
return vnode;
};
var newVNode = (tag, text) => {
const vnode = {
$flags$: 0,
$tag$: tag,
$text$: text,
$elm$: null,
$children$: null
};
if (BUILD8.vdomAttribute) {
vnode.$attrs$ = null;
}
if (BUILD8.vdomKey) {
vnode.$key$ = null;
}
if (BUILD8.slotRelocation) {
vnode.$name$ = null;
}
return vnode;
};
var Host = {};
var isHost = (node) => node && node.$tag$ === Host;
var vdomFnUtils = {
forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate)
};
var convertToPublic = (node) => ({
vattrs: node.$attrs$,
vchildren: node.$children$,
vkey: node.$key$,
vname: node.$name$,
vtag: node.$tag$,
vtext: node.$text$
});
var convertToPrivate = (node) => {
if (typeof node.vtag === "function") {
const vnodeData = { ...node.vattrs };
if (node.vkey) {
vnodeData.key = node.vkey;
}
if (node.vname) {
vnodeData.name = node.vname;
}
return h(node.vtag, vnodeData, ...node.vchildren || []);
}
const vnode = newVNode(node.vtag, node.vtext);
vnode.$attrs$ = node.vattrs;
vnode.$children$ = node.vchildren;
vnode.$key$ = node.vkey;
vnode.$name$ = node.vname;
return vnode;
};
var validateInputProperties = (inputElm) => {
const props = Object.keys(inputElm);
const value = props.indexOf("value");
if (value === -1) {
return;
}
const typeIndex = props.indexOf("type");
const minIndex = props.indexOf("min");
const maxIndex = props.indexOf("max");
const stepIndex = props.indexOf("step");
if (value < typeIndex || value < minIndex || value < maxIndex || value < stepIndex) {
consoleDevWarn(`The "value" prop of <input> should be set after "min", "max", "type" and "step"`);
}
};
// src/runtime/client-hydrate.ts
var initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
const endHydrate = createTime("hydrateClient", tagName);
const shadowRoot = hostElm.shadowRoot;
const childRenderNodes = [];
const slotNodes = [];
const shadowRootNodes = BUILD9.shadowDom && shadowRoot ? [] : null;
const vnode = hostRef.$vnode$ = newVNode(tagName, null);
if (!plt.$orgLocNodes$) {
initializeDocumentHydrate(doc.body, plt.$orgLocNodes$ = /* @__PURE__ */ new Map());
}
hostElm[HYDRATE_ID] = hostId;
hostElm.removeAttribute(HYDRATE_ID);
clientHydrate(vnode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, hostElm, hostId);
childRenderNodes.map((c) => {
const orgLocationId = c.$hostId$ + "." + c.$nodeId$;
const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
const node = c.$elm$;
if (orgLocationNode && supportsShadow && orgLocationNode["s-en"] === "") {
orgLocationNode.parentNode.insertBefore(node, orgLocationNode.nextSibling);
}
if (!shadowRoot) {
node["s-hn"] = tagName;
if (orgLocationNode) {
node["s-ol"] = orgLocationNode;
node["s-ol"]["s-nr"] = node;
}
}
plt.$orgLocNodes$.delete(orgLocationId);
});
if (BUILD9.shadowDom && shadowRoot) {
shadowRootNodes.map((shadowRootNode) => {
if (shadowRootNode) {
shadowRoot.appendChild(shadowRootNode);
}
});
}
endHydrate();
};
var clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node, hostId) => {
let childNodeType;
let childIdSplt;
let childVNode;
let i2;
if (node.nodeType === 1 /* ElementNode */) {
childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
if (childNodeType) {
childIdSplt = childNodeType.split(".");
if (childIdSplt[0] === hostId || childIdSplt[0] === "0") {
childVNode = {
$flags$: 0,
$hostId$: childIdSplt[0],
$nodeId$: childIdSplt[1],
$depth$: childIdSplt[2],
$index$: childIdSplt[3],
$tag$: node.tagName.toLowerCase(),
$elm$: node,
$attrs$: null,
$children$: null,
$key$: null,
$name$: null,
$text$: null
};
childRenderNodes.push(childVNode);
node.removeAttribute(HYDRATE_CHILD_ID);
if (!parentVNode.$children$) {
parentVNode.$children$ = [];
}
parentVNode.$children$[childVNode.$index$] = childVNode;
parentVNode = childVNode;
if (shadowRootNodes && childVNode.$depth$ === "0") {
shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
}
}
}
if (node.shadowRoot) {
for (i2 = node.shadowRoot.childNodes.length - 1; i2 >= 0; i2--) {
clientHydrate(
parentVNode,
childRenderNodes,
slotNodes,
shadowRootNodes,
hostElm,
node.shadowRoot.childNodes[i2],
hostId
);
}
}
for (i2 = node.childNodes.length - 1; i2 >= 0; i2--) {
clientHydrate(
parentVNode,
childRenderNodes,
slotNodes,
shadowRootNodes,
hostElm,
node.childNodes[i2],
hostId
);
}
} else if (node.nodeType === 8 /* CommentNode */) {
childIdSplt = node.nodeValue.split(".");
if (childIdSplt[1] === hostId || childIdSplt[1] === "0") {
childNodeType = childIdSplt[0];
childVNode = {
$flags$: 0,
$hostId$: childIdSplt[1],
$nodeId$: childIdSplt[2],
$depth$: childIdSplt[3],
$index$: childIdSplt[4],
$elm$: node,
$attrs$: null,
$children$: null,
$key$: null,
$name$: null,
$tag$: null,
$text$: null
};
if (childNodeType === TEXT_NODE_ID) {
childVNode.$elm$ = node.nextSibling;
if (childVNode.$elm$ && childVNode.$elm$.nodeType === 3 /* TextNode */) {
childVNode.$text$ = childVNode.$elm$.textContent;
childRenderNodes.push(childVNode);
node.remove();
if (!parentVNode.$children$) {
parentVNode.$children$ = [];
}
parentVNode.$children$[childVNode.$index$] = childVNode;
if (shadowRootNodes && childVNode.$depth$ === "0") {
shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
}
}
} else if (childVNode.$hostId$ === hostId) {
if (childNodeType === SLOT_NODE_ID) {
childVNode.$tag$ = "slot";
if (childIdSplt[5]) {
node["s-sn"] = childVNode.$name$ = childIdSplt[5];
} else {
node["s-sn"] = "";
}
node["s-sr"] = true;
if (BUILD9.shadowDom && shadowRootNodes) {
childVNode.$elm$ = doc.createElement(childVNode.$tag$);
if (childVNode.$name$) {
childVNode.$elm$.setAttribute("name", childVNode.$name$);
}
node.parentNode.insertBefore(childVNode.$elm$, node);
node.remove();
if (childVNode.$depth$ === "0") {
shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
}
}
slotNodes.push(childVNode);
if (!parentVNode.$children$) {
parentVNode.$children$ = [];
}
parentVNode.$children$[childVNode.$index$] = childVNode;
} else if (childNodeType === CONTENT_REF_ID) {
if (BUILD9.shadowDom && shadowRootNodes) {
node.remove();
} else if (BUILD9.slotRelocation) {
hostElm["s-cr"] = node;
node["s-cn"] = true;
}
}
}
}
} else if (parentVNode && parentVNode.$tag$ === "style") {
const vnode = newVNode(null, node.textContent);
vnode.$elm$ = node;
vnode.$index$ = "0";
parentVNode.$children$ = [vnode];
}
};
var initializeDocumentHydrate = (node, orgLocNodes) => {
if (node.nodeType === 1 /* ElementNode */) {
let i2 = 0;
if (node.shadowRoot) {
for (; i2 < node.shadowRoot.childNodes.length; i2++) {
initializeDocumentHydrate(node.shadowRoot.childNodes[i2], orgLocNodes);
}
}
for (i2 = 0; i2 < node.childNodes.length; i2++) {
initializeDocumentHydrate(node.childNodes[i2], orgLocNodes);
}
} else if (node.nodeType === 8 /* CommentNode */) {
const childIdSplt = node.nodeValue.split(".");
if (childIdSplt[0] === ORG_LOCATION_ID) {
orgLocNodes.set(childIdSplt[1] + "." + childIdSplt[2], node);
node.nodeValue = "";
node["s-en"] = childIdSplt[3];
}
}
};
// src/runtime/initialize-component.ts
import { BUILD as BUILD20 } from "@stencil/core/internal/app-data";
// src/runtime/mode.ts
var computeMode = (elm) => modeResolutionChain.map((h2) => h2(elm)).find((m) => !!m);
var setMode = (handler) => modeResolutionChain.push(handler);
var getMode = (ref) => getHostRef(ref).$modeName$;
// src/runtime/proxy-component.ts
import { BUILD as BUILD19 } from "@stencil/core/internal/app-data";
// src/runtime/set-value.ts
import { BUILD as BUILD18 } from "@stencil/core/internal/app-data";
// src/runtime/parse-property-value.ts
import { BUILD as BUILD10 } from "@stencil/core/internal/app-data";
var parsePropertyValue = (propValue, propType) => {
if (propValue != null && !isComplexType(propValue)) {
if (BUILD10.propBoolean && propType & 4 /* Boolean */) {
return propValue === "false" ? false : propValue === "" || !!propValue;
}
if (BUILD10.propNumber && propType & 2 /* Number */) {
return parseFloat(propValue);
}
if (BUILD10.propString && propType & 1 /* String */) {
return String(propValue);
}
return propValue;
}
return propValue;
};
// src/runtime/update-component.ts
import { BUILD as BUILD17, NAMESPACE } from "@stencil/core/internal/app-data";
// src/runtime/event-emitter.ts
import { BUILD as BUILD12 } from "@stencil/core/internal/app-data";
// src/runtime/element.ts
import { BUILD as BUILD11 } from "@stencil/core/internal/app-data";
var getElement = (ref) => BUILD11.lazyLoad ? getHostRef(ref).$hostElement$ : ref;
// src/runtime/event-emitter.ts
var createEvent = (ref, name, flags) => {
const elm = getElement(ref);
return {
emit: (detail) => {
if (BUILD12.isDev && !elm.isConnected) {
consoleDevWarn(`The "${name}" event was emitted, but the dispatcher node is no longer connected to the dom.`);
}
return emitEvent(elm, name, {
bubbles: !!(flags & 4 /* Bubbles */),
composed: !!(flags & 2 /* Composed */),
cancelable: !!(flags & 1 /* Cancellable */),
detail
});
}
};
};
var emitEvent = (elm, name, opts) => {
const ev = plt.ce(name, opts);
elm.dispatchEvent(ev);
return ev;
};
// src/runtime/styles.ts
import { BUILD as BUILD13 } from "@stencil/core/internal/app-data";
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, mode);
const style = styles.get(scopeId2);
if (!BUILD13.attachStyles) {
return scopeId2;
}
styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
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)) {
if (BUILD13.hydrateClientSide && styleContainerNode.host && (styleElm = styleContainerNode.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId2}"]`))) {
styleElm.innerHTML = style;
} else {
styleElm = doc.createElement("style");
styleElm.innerHTML = style;
const nonce = (_a = plt.$nonce$) != null ? _a : queryNonceMetaTagContent(doc);
if (nonce != null) {
styleElm.setAttribute("nonce", nonce);
}
if ((BUILD13.hydrateServerSide || BUILD13.hotModuleReplacement) && cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
styleElm.setAttribute(HYDRATED_STYLE_ID, scopeId2);
}
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);
} else if ("host" in styleContainerNode) {
if (supportsConstructableStylesheets) {
const stylesheet = new CSSStyleSheet();
stylesheet.replaceSync(style);
styleContainerNode.adoptedStyleSheets = [stylesheet, ...styleContainerNode.adoptedStyleSheets];
} 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.nodeName !== "HEAD") {
styleContainerNode.insertBefore(styleElm, null);
}
}
if (cmpMeta.$flags$ & 4 /* hasSlotRelocation */) {
styleElm.innerHTML += SLOT_FB_CSS;
}
if (appliedStyles) {
appliedStyles.add(scopeId2);
}
}
} else if (BUILD13.constructableCSS && !styleContainerNode.adoptedStyleSheets.includes(style)) {
styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, 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(
BUILD13.shadowDom && supportsShadow && elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(),
cmpMeta,
hostRef.$modeName$
);
if ((BUILD13.shadowDom || BUILD13.scoped) && BUILD13.cssAnnotations && flags & 10 /* needsScopedEncapsulation */ && flags & 2 /* scopedCssEncapsulation */) {
elm["s-sc"] = scopeId2;
elm.classList.add(scopeId2 + "-h");
if (BUILD13.scoped && flags & 2 /* scopedCssEncapsulation */) {
elm.classList.add(scopeId2 + "-s");
}
}
endAttachStyles();
};
var getScopeId = (cmp, mode) => "sc-" + (BUILD13.mode && mode && cmp.$flags$ & 32 /* hasMode */ ? cmp.$tagName$ + "-" + mode : cmp.$tagName$);
// src/runtime/vdom/vdom-render.ts
import { BUILD as BUILD16 } from "@stencil/core/internal/app-data";
// src/runtime/vdom/update-element.ts
import { BUILD as BUILD15 } from "@stencil/core/internal/app-data";
// src/runtime/vdom/set-accessor.ts
import { BUILD as BUILD14 } from "@stencil/core/internal/app-data";
var setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
if (oldValue !== newValue) {
let isProp = isMemberInElement(elm, memberName);
let ln = memberName.toLowerCase();
if (BUILD14.vdomClass && memberName === "class") {
const classList = elm.classList;
const oldClasses = parseClassList(oldValue);
const newClasses = parseClassList(newValue);
classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
} else if (BUILD14.vdomStyle && memberName === "style") {
if (BUILD14.updatable) {
for (const prop in oldValue) {
if (!newValue || newValue[prop] == null) {
if (!BUILD14.hydrateServerSide && prop.includes("-")) {
elm.style.removeProperty(prop);
} else {
elm.style[prop] = "";
}
}
}
}
for (const prop in newValue) {
if (!oldValue || newValue[prop] !== oldValue[prop]) {
if (!BUILD14.hydrateServerSide && prop.includes("-")) {
elm.style.setProperty(prop, newValue[prop]);
} else {
elm.style[prop] = newValue[prop];
}
}
}
} else if (BUILD14.vdomKey && memberName === "key") {
} else if (BUILD14.vdomRef && memberName === "ref") {
if (newValue) {
newValue(elm);
}
} else if (BUILD14.vdomListener && (BUILD14.lazyLoad ? !isProp : !elm.__lookupSetter__(memberName)) && memberName[0] === "o" && memberName[1] === "n") {
if (memberName[2] === "-") {
memberName = memberName.slice(3);
} else if (isMemberInElement(win, ln)) {
memberName = ln.slice(2);
} else {
memberName = ln[2] + memberName.slice(3);
}
if (oldValue || newValue) {
const capture = memberName.endsWith(CAPTURE_EVENT_SUFFIX);
memberName = memberName.replace(CAPTURE_EVENT_REGEX, "");
if (oldValue) {
plt.rel(elm, memberName, oldValue, capture);
}
if (newValue) {
plt.ael(elm, memberName, newValue, capture);
}
}
} else if (BUILD14.vdomPropOrAttr) {
const isComplex = isComplexType(newValue);
if ((isProp || isComplex && newValue !== null) && !isSvg) {
try {
if (!elm.tagName.includes("-")) {
const n = newValue == null ? "" : newValue;
if (memberName === "list") {
isProp = false;
} else if (oldValue == null || elm[memberName] != n) {
if (typeof elm.__lookupSetter__(memberName) === "function") {
elm[memberName] = n;
} else {
elm.setAttribute(memberName, n);
}
}
} else {
elm[memberName] = newValue;
}
} catch (e) {
}
}
let xlink = false;
if (BUILD14.vdomXlink) {
if (ln !== (ln = ln.replace(/^xlink\:?/, ""))) {
memberName = ln;
xlink = true;
}
}
if (newValue == null || newValue === false) {
if (newValue !== false || elm.getAttribute(memberName) === "") {
if (BUILD14.vdomXlink && xlink) {
elm.removeAttributeNS(XLINK_NS, memberName);
} else {
elm.removeAttribute(memberName);
}
}
} else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
newValue = newValue === true ? "" : newValue;
if (BUILD14.vdomXlink && xlink) {
elm.setAttributeNS(XLINK_NS, memberName, newValue);
} else {
elm.setAttribute(memberName, newValue);
}
}
}
}
};
var parseClassListRegex = /\s/;
var parseClassList = (value) => !value ? [] : value.split(parseClassListRegex);
var CAPTURE_EVENT_SUFFIX = "Capture";
var CAPTURE_EVENT_REGEX = new RegExp(CAPTURE_EVENT_SUFFIX + "$");
// src/runtime/vdom/update-element.ts
var updateElement = (oldVnode, newVnode, isSvgMode2) => {
const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host ? newVnode.$elm$.host : newVnode.$elm$;
const oldVnodeAttrs = oldVnode && oldVnode.$attrs$ || EMPTY_OBJ;
const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
if (BUILD15.updatable) {
for (const memberName of sortedAttrNames(Object.keys(oldVnodeAttrs))) {
if (!(memberName in newVnodeAttrs)) {
setAccessor(elm, memberName, oldVnodeAttrs[memberName], void 0, isSvgMode2, newVnode.$flags$);
}
}
}
for (const memberName of sortedAttrNames(Object.keys(newVnodeAttrs))) {
setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode2, newVnode.$flags$);
}
};
function sortedAttrNames(attrNames) {
return attrNames.includes("ref") ? (
// we need to sort these to ensure that `'ref'` is the last attr
[...attrNames.filter((attr) => attr !== "ref"), "ref"]
) : (
// no need to sort, return the original array
attrNames
);
}
// src/runtime/vdom/vdom-render.ts
var scopeId;
var contentRef;
var hostTagName;
var useNativeShadowDom = false;
var checkSlotFallbackVisibility = false;
var checkSlotRelocate = false;
var isSvgMode = false;
var createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
var _a;
const newVNode2 = newParentVNode.$children$[childIndex];
let i2 = 0;
let elm;
let childNode;
let oldVNode;
if (BUILD16.slotRelocation && !useNativeShadowDom) {
checkSlotRelocate = true;
if (newVNode2.$tag$ === "slot") {
if (scopeId) {
parentElm.classList.add(scopeId + "-s");
}
newVNode2.$flags$ |= newVNode2.$children$ ? (
// slot element has fallback content
// still create an element that "mocks" the slot element
2 /* isSlotFallback */
) : (
// slot element does not have fallback content
// create an html comment we'll use to always reference
// where actual slot content should sit next to
1 /* isSlotReference */
);
}
}
if (BUILD16.isDev && newVNode2.$elm$) {
consoleDevError(
`The JSX ${newVNode2.$text$ !== null ? `"${newVNode2.$text$}" text` : `"${newVNode2.$tag$}" element`} node should not be shared within the same renderer. The renderer caches element lookups in order to improve performance. However, a side effect from this is that the exact same JSX node should not be reused. For more information please see https://stenciljs.com/docs/templating-jsx#avoid-shared-jsx-nodes`
);
}
if (BUILD16.vdomText && newVNode2.$text$ !== null) {
elm = newVNode2.$elm$ = doc.createTextNode(newVNode2.$text$);
} else if (BUILD16.slotRelocation && newVNode2.$flags$ & 1 /* isSlotReference */) {
elm = newVNode2.$elm$ = BUILD16.isDebug || BUILD16.hydrateServerSide ? slotReferenceDebugNode(newVNode2) : doc.createTextNode("");
} else {
if (BUILD16.svg && !isSvgMode) {
isSvgMode = newVNode2.$tag$ === "svg";
}
elm = newVNode2.$elm$ = BUILD16.svg ? doc.createElementNS(
isSvgMode ? SVG_NS : HTML_NS,
!useNativeShadowDom && BUILD16.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
) : doc.createElement(
!useNativeShadowDom && BUILD16.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
);
if (BUILD16.svg && isSvgMode && newVNode2.$tag$ === "foreignObject") {
isSvgMode = false;
}
if (BUILD16.vdomAttribute) {
updateElement(null, newVNode2, isSvgMode);
}
const rootNode = elm.getRootNode();
const isElementWithinShadowRoot = !rootNode.querySelector("body");
if (!isElementWithinShadowRoot && BUILD16.scoped && isDef(scopeId) && elm["s-si"] !== scopeId) {
elm.classList.add(elm["s-si"] = scopeId);
}
if (BUILD16.scoped) {
updateElementScopeIds(elm, parentElm);
}
if (newVNode2.$children$) {
for (i2 = 0; i2 < newVNode2.$children$.length; ++i2) {
childNode = createElm(oldParentVNode, newVNode2, i2, elm);
if (childNode) {
elm.appendChild(childNode);
}
}
}
if (BUILD16.svg) {
if (newVNode2.$tag$ === "svg") {
isSvgMode = false;
} else if (elm.tagName === "foreignObject") {
isSvgMode = true;
}
}
}
elm["s-hn"] = hostTagName;
if (BUILD16.slotRelocation) {
if (newVNode2.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
elm["s-sr"] = true;
elm["s-cr"] = contentRef;
elm["s-sn"] = newVNode2.$name$ || "";
elm["s-rf"] = (_a = newVNode2.$attrs$) == null ? void 0 : _a.ref;
oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
if (oldVNode && oldVNode.$tag$ === newVNode2.$tag$ && oldParentVNode.$elm$) {
if (BUILD16.experimentalSlotFixes) {
relocateToHostRoot(oldParentVNode.$elm$);
} else {
putBackInOriginalLocation(oldParentVNode.$elm$, false);
}
}
}
}
return elm;
};
var relocateToHostRoot = (parentElm) => {
plt.$flags$ |= 1 /* isTmpDisconnected */;
const host = parentElm.closest(hostTagName.toLowerCase());
if (host != null) {
const contentRefNode = Array.from(host.childNodes).find((ref) => ref["s-cr"]);
const childNodeArray = Array.from(parentElm.childNodes);
for (const childNode of contentRefNode ? childNodeArray.reverse() : childNodeArray) {
if (childNode["s-sh"] != null) {
insertBefore(host, childNode, contentRefNode != null ? contentRefNode : null);
childNode["s-sh"] = void 0;
checkSlotRelocate = true;
}
}
}
plt.$flags$ &= ~1 /* isTmpDisconnected */;
};
var putBackInOriginalLocation = (parentElm, recursive) => {
plt.$flags$ |= 1 /* isTmpDisconnected */;
const oldSlotChildNodes = Array.from(parentElm.childNodes);
if (parentElm["s-sr"] && BUILD16.experimentalSlotFixes) {
let node = parentElm;
while (node = node.nextSibling) {
if (node && node["s-sn"] === parentElm["s-sn"] && node["s-sh"] === hostTagName) {
oldSlotChildNodes.push(node);
}
}
}
for (let i2 = oldSlotChildNodes.length - 1; i2 >= 0; i2--) {
const childNode = oldSlotChildNodes[i2];
if (childNode["s-hn"] !== hostTagName && childNode["s-ol"]) {
insertBefore(parentReferenceNode(childNode), childNode, referenceNode(childNode));
childNode["s-ol"].remove();
childNode["s-ol"] = void 0;
childNode["s-sh"] = void 0;
checkSlotRelocate = true;
}
if (recursive) {
putBackInOriginalLocation(childNode, recursive);
}
}
plt.$flags$ &= ~1 /* isTmpDisconnected */;
};
var addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
let containerElm = BUILD16.slotRelocation && parentElm["s-cr"] && parentElm["s-cr"].parentNode || parentElm;
let childNode;
if (BUILD16.shadowDom && containerElm.shadowRoot && containerElm.tagName === hostTagName) {
containerElm = containerElm.shadowRoot;
}
for (; startIdx <= endIdx; ++startIdx) {
if (vnodes[startIdx]) {
childNode = createElm(null, parentVNode, startIdx, parentElm);
if (childNode) {
vnodes[startIdx].$elm$ = childNode;
insertBefore(containerElm, childNode, BUILD16.slotRelocation ? referenceNode(before) : before);
}
}
}
};
var removeVnodes = (vnodes, startIdx, endIdx) => {
for (let index = startIdx; index <= endIdx; ++index) {
const vnode = vnodes[index];
if (vnode) {
const elm = vnode.$elm$;
nullifyVNodeRefs(vnode);
if (elm) {
if (BUILD16.slotRelocation) {
checkSlotFallbackVisibility = true;
if (elm["s-ol"]) {
elm["s-ol"].remove();
} else {
putBackInOriginalLocation(elm, true);
}
}
elm.remove();
}
}
}
};
var updateChildren = (parentElm, oldCh, newVNode2, newCh, isInitialRender = false) => {
let oldStartIdx = 0;
let newStartIdx = 0;
let idxInOld = 0;
let i2 = 0;
let oldEndIdx = oldCh.length - 1;
let oldStartVnode = oldCh[0];
let oldEndVnode = oldCh[oldEndIdx];
let newEndIdx = newCh.length - 1;
let newStartVnode = newCh[0];
let newEndVnode = newCh[newEndIdx];
let node;
let elmToMove;
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
if (oldStartVnode == null) {
oldStartVnode = oldCh[++oldStartIdx];
} else if (oldEndVnode == null) {
oldEndVnode = oldCh[--oldEndIdx];
} else if (newStartVnode == null) {
newStartVnode = newCh[++newStartIdx];
} else if (newEndVnode == null) {
newEndVnode = newCh[--newEndIdx];
} else if (isSameVnode(oldStartVnode, newStartVnode, isInitialRender)) {
patch(oldStartVnode, newStartVnode, isInitialRender);
oldStartVnode = oldCh[++oldStartIdx];
newStartVnode = newCh[++newStartIdx];
} else if (isSameVnode(oldEndVnode, newEndVnode, isInitialRender)) {
patch(oldEndVnode, newEndVnode, isInitialRender);
oldEndVnode = oldCh[--oldEndIdx];
newEndVnode = newCh[--newEndIdx];
} else if (isSameVnode(oldStartVnode, newEndVnode, isInitialRender)) {
if (BUILD16.slotRelocation && (oldStartVnode.$tag$ === "slot" || newEndVnode.$tag$ === "slot")) {
putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
}
patch(oldStartVnode, newEndVnode, isInitialRender);
insertBefore(parentElm, oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
oldStartVnode = oldCh[++oldStartIdx];
newEndVnode = newCh[--newEndIdx];
} else if (isSameVnode(oldEndVnode, newStartVnode, isInitialRender)) {
if (BUILD16.slotRelocation && (oldStartVnode.$tag$ === "slot" || newEndVnode.$tag$ === "slot")) {
putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
}
patch(oldEndVnode, newStartVnode, isInitialRender);
insertBefore(parentElm, oldEndVnode.$elm$, oldStartVnode.$elm$);
oldEndVnode = oldCh[--oldEndIdx];
newStartVnode = newCh[++newStartIdx];
} else {
idxInOld = -1;
if (BUILD16.vdomKey) {
for (i2 = oldStartIdx; i2 <= oldEndIdx; ++i2) {
if (oldCh[i2] && oldCh[i2].$key$ !== null && oldCh[i2].$key$ === newStartVnode.$key$) {
idxInOld = i2;
break;
}
}
}
if (BUILD16.vdomKey && idxInOld >= 0) {
elmToMove = oldCh[idxInOld];
if (elmToMove.$tag$ !== newStartVnode.$tag$) {
node = createElm(oldCh && oldCh[newStartIdx], newVNode2, idxInOld, parentElm);
} else {
patch(elmToMove, newStartVnode, isInitialRender);
oldCh[idxInOld] = void 0;
node = elmToMove.$elm$;
}
newStartVnode = newCh[++newStartIdx];
} else {
node = createElm(oldCh && oldCh[newStartIdx], newVNode2, newStartIdx, parentElm);
newStartVnode = newCh[++newStartIdx];
}
if (node) {
if (BUILD16.slotRelocation) {
insertBefore(parentReferenceNode(oldStartVnode.$elm$), node, referenceNode(oldStartVnode.$elm$));
} else {
insertBefore(oldStartVnode.$elm$.parentNode, node, oldStartVnode.$elm$);
}
}
}
}
if (oldStartIdx > oldEndIdx) {
addVnodes(
parentElm,
newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$,
newVNode2,
newCh,
newStartIdx,
newEndIdx
);
} else if (BUILD16.updatable && newStartIdx > newEndIdx) {
removeVnodes(oldCh, oldStartIdx, oldEndIdx);
}
};
var isSameVnode = (leftVNode, rightVNode, isInitialRender = false) => {
if (leftVNode.$tag$ === rightVNode.$tag$) {
if (BUILD16.slotRelocation && leftVNode.$tag$ === "slot") {
if (
// The component gets hydrated and no VDOM has been initialized.
// Here the comparison can't happen as $name$ property is not set for `leftNode`.
"$nodeId$" in leftVNode && isInitialRender && // `leftNode` is not from type HTMLComment which would cause many
// hydration comments to be removed
leftVNode.$elm$.nodeType !== 8
) {
return false;
}
return leftVNode.$name$ === rightVNode.$name$;
}
if (BUILD16.vdomKey && !isInitialRender) {
return leftVNode.$key$ === rightVNode.$key$;
}
return true;
}
return false;
};
var referenceNode = (node) => {
return node && node["s-ol"] || node;
};
var parentReferenceNode = (node) => (node["s-ol"] ? node["s-ol"] : node).parentNode;
var patch = (oldVNode, newVNode2, isInitialRender = false) => {
const elm = newVNode2.$elm$ = oldVNode.$elm$;
const oldChildren = oldVNode.$children$;
const newChildren = newVNode2.$children$;
const tag = newVNode2.$tag$;
const text = newVNode2.$text$;
let defaultHolder;
if (!BUILD16.vdomText || text === null) {
if (BUILD16.svg) {
isSvgMode = tag === "svg" ? true : tag === "foreignObject" ? false : isSvgMode;
}
if (BUILD16.vdomAttribute || BUILD16.reflect) {
if (BUILD16.slot && tag === "slot" && !useNativeShadowDom) {
if (BUILD16.experimentalSlotFixes && oldVNode.$name$ !== newVNode2.$name$) {
newVNode2.$elm$["s-sn"] = newVNode2.$name$ || "";
relocateToHostRoot(newVNode2.$elm$.parentElement);
}
} else {
updateElement(oldVNode, newVNode2, isSvgMode);
}
}
if (BUILD16.updatable && oldChildren !== null && newChildren !== null) {
updateChildren(elm, oldChildren, newVNode2, newChildren, isInitialRender);
} else if (newChildren !== null) {
if (BUILD16.updatable && BUILD16.vdomText && oldVNode.$text$ !== null) {
elm.textContent = "";
}
addVnodes(elm, null, newVNode2, newChildren, 0, newChildren.length - 1);
} else if (
// don't do this on initial render as it can cause non-hydrated content to be removed
!isInitialRender && BUILD16.updatable && oldChildren !== null
) {
removeVnodes(oldChildren, 0, oldChildren.length - 1);
}
if (BUILD16.svg && isSvgMode && tag === "svg") {
isSvgMode = false;
}
} else if (BUILD16.vdomText && BUILD16.slotRelocation && (defaultHolder = elm["s-cr"])) {
defaultHolder.parentNode.textContent = text;
} else if (BUILD16.vdomText && oldVNode.$text$ !== text) {
elm.data = text;
}
};
var updateFallbackSlotVisibility = (elm) => {
const childNodes = elm.childNodes;
for (const childNode of childNodes) {
if (childNode.nodeType === 1 /* ElementNode */) {
if (childNode["s-sr"]) {
const slotName = childNode["s-sn"];
childNode.hidden = false;
for (const siblingNode of childNodes) {
if (siblingNode !== childNode) {
if (siblingNode["s-hn"] !== childNode["s-hn"] || slotName !== "") {
if (siblingNode.nodeType === 1 /* ElementNode */ && (slotName === siblingNode.getAttribute("slot") || slotName === siblingNode["s-sn"]) || siblingNode.nodeType === 3 /* TextNode */ && slotName === siblingNode["s-sn"]) {
childNode.hidden = true;
break;
}
} else {
if (siblingNode.nodeType === 1 /* ElementNode */ || siblingNode.nodeType === 3 /* TextNode */ && siblingNode.