123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322 |
- /*!
- * (C) Ionic http://ionicframework.com - MIT License
- */
- 'use strict';
- function _interopNamespace(e) {
- if (e && e.__esModule) return e;
- var n = Object.create(null);
- if (e) {
- Object.keys(e).forEach(function (k) {
- if (k !== 'default') {
- var d = Object.getOwnPropertyDescriptor(e, k);
- Object.defineProperty(n, k, d.get ? d : {
- enumerable: true,
- get: function () {
- return e[k];
- }
- });
- }
- });
- }
- n['default'] = e;
- return Object.freeze(n);
- }
- const NAMESPACE = 'ionic';
- const BUILD = /* ionic */ { allRenderFn: false, appendChildSlotFix: true, asyncLoading: true, asyncQueue: false, attachStyles: true, cloneNodeFix: true, cmpDidLoad: true, cmpDidRender: true, cmpDidUnload: false, cmpDidUpdate: true, cmpShouldUpdate: false, cmpWillLoad: true, cmpWillRender: true, cmpWillUpdate: false, connectedCallback: true, constructableCSS: true, cssAnnotations: true, devTools: false, disconnectedCallback: true, element: false, event: true, experimentalScopedSlotChanges: true, experimentalSlotFixes: true, formAssociated: false, hasRenderFn: true, hostListener: true, hostListenerTarget: true, hostListenerTargetBody: true, hostListenerTargetDocument: true, hostListenerTargetParent: false, hostListenerTargetWindow: true, hotModuleReplacement: false, hydrateClientSide: true, hydrateServerSide: false, hydratedAttribute: false, hydratedClass: true, hydratedSelectorName: "hydrated", initializeNextTick: false, invisiblePrehydration: true, isDebug: false, isDev: false, isTesting: false, lazyLoad: true, lifecycle: true, lifecycleDOMEvents: false, member: true, method: true, mode: true, observeAttribute: true, profile: false, prop: true, propBoolean: true, propMutable: true, propNumber: true, propString: true, reflect: true, scoped: true, scopedSlotTextContentFix: true, scriptDataOpts: false, shadowDelegatesFocus: true, shadowDom: true, slot: true, slotChildNodesFix: true, slotRelocation: true, state: true, style: true, svg: true, taskQueue: true, transformTagName: false, updatable: true, vdomAttribute: true, vdomClass: true, vdomFunctional: true, vdomKey: true, vdomListener: true, vdomPropOrAttr: true, vdomRef: true, vdomRender: true, vdomStyle: true, vdomText: true, vdomXlink: true, watchCallback: true };
- /*
- Stencil Client Platform v4.20.0 | 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 });
- };
- var Build = {
- isDev: false,
- isBrowser: true,
- isServer: false,
- isTesting: false
- };
- var hostRefs = /* @__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()
- };
- {
- hostRef.$onInstancePromise$ = new Promise((r) => hostRef.$onInstanceResolve$ = r);
- }
- {
- 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;
- 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 Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
- /* @vite-ignore */
- /* webpackInclude: /\.entry\.js$/ */
- /* webpackExclude: /\.system\.entry\.js$/ */
- /* webpackMode: "lazy" */
- `./${bundleId}.entry.js${""}`
- )); }).then((importedModule) => {
- {
- cmpModules.set(bundleId, importedModule);
- }
- return importedModule[exportName];
- }, consoleError);
- };
- // src/client/client-style.ts
- var styles = /* @__PURE__ */ new Map();
- var modeResolutionChain = [];
- // 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 SLOT_FB_CSS = "slot-fb{display:contents}slot-fb[hidden]{display:none}";
- var XLINK_NS = "http://www.w3.org/1999/xlink";
- 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 supportsShadow = BUILD.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 = /* @__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 readTask = /* @__PURE__ */ queueTask(queueDomReads, false);
- var writeTask = /* @__PURE__ */ queueTask(queueDomWrites, true);
- // 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;
- };
- // 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;
- }
- };
- var createTime = (fnName, tagName = "") => {
- {
- return () => {
- return;
- };
- }
- };
- var uniqueTime = (key, measureText) => {
- {
- return () => {
- return;
- };
- }
- };
- 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);
- }
- if (simple && lastSimple) {
- vNodeChildren[vNodeChildren.length - 1].$text$ += child;
- } else {
- vNodeChildren.push(simple ? newVNode(null, child) : child);
- }
- lastSimple = simple;
- }
- }
- };
- walk(children);
- if (vnodeData) {
- if (vnodeData.key) {
- key = vnodeData.key;
- }
- if (vnodeData.name) {
- slotName = vnodeData.name;
- }
- {
- const classData = vnodeData.className || vnodeData.class;
- if (classData) {
- vnodeData.class = typeof classData !== "object" ? classData : Object.keys(classData).filter((k) => classData[k]).join(" ");
- }
- }
- }
- if (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;
- }
- {
- vnode.$key$ = key;
- }
- {
- vnode.$name$ = slotName;
- }
- return vnode;
- };
- var newVNode = (tag, text) => {
- const vnode = {
- $flags$: 0,
- $tag$: tag,
- $text$: text,
- $elm$: null,
- $children$: null
- };
- {
- vnode.$attrs$ = null;
- }
- {
- vnode.$key$ = null;
- }
- {
- 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;
- };
- // 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 = 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 (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 (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 (shadowRootNodes) {
- node.remove();
- } else {
- 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/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$;
- var parsePropertyValue = (propValue, propType) => {
- if (propValue != null && !isComplexType(propValue)) {
- if (propType & 4 /* Boolean */) {
- return propValue === "false" ? false : propValue === "" || !!propValue;
- }
- if (propType & 2 /* Number */) {
- return parseFloat(propValue);
- }
- if (propType & 1 /* String */) {
- return String(propValue);
- }
- return propValue;
- }
- return propValue;
- };
- var getElement = (ref) => getHostRef(ref).$hostElement$ ;
- // src/runtime/event-emitter.ts
- var createEvent = (ref, name, flags) => {
- const elm = getElement(ref);
- return {
- emit: (detail) => {
- 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;
- };
- 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);
- 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 (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);
- }
- const injectStyle = (
- /**
- * we render a scoped component
- */
- !(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) || /**
- * we are using shadow dom and render the style tag within the shadowRoot
- */
- cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */ && styleContainerNode.nodeName !== "HEAD"
- );
- if (injectStyle) {
- styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector("link"));
- }
- }
- if (cmpMeta.$flags$ & 4 /* hasSlotRelocation */) {
- styleElm.innerHTML += SLOT_FB_CSS;
- }
- if (appliedStyles) {
- appliedStyles.add(scopeId2);
- }
- }
- } else if (!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(
- elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(),
- cmpMeta,
- hostRef.$modeName$
- );
- if (flags & 10 /* needsScopedEncapsulation */ && flags & 2 /* scopedCssEncapsulation */) {
- elm["s-sc"] = scopeId2;
- elm.classList.add(scopeId2 + "-h");
- if (flags & 2 /* scopedCssEncapsulation */) {
- elm.classList.add(scopeId2 + "-s");
- }
- }
- endAttachStyles();
- };
- var getScopeId = (cmp, mode) => "sc-" + (mode && cmp.$flags$ & 32 /* hasMode */ ? cmp.$tagName$ + "-" + mode : cmp.$tagName$);
- var setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
- if (oldValue !== newValue) {
- let isProp = isMemberInElement(elm, memberName);
- let ln = memberName.toLowerCase();
- if (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 (memberName === "style") {
- {
- for (const prop in oldValue) {
- if (!newValue || newValue[prop] == null) {
- if (prop.includes("-")) {
- elm.style.removeProperty(prop);
- } else {
- elm.style[prop] = "";
- }
- }
- }
- }
- for (const prop in newValue) {
- if (!oldValue || newValue[prop] !== oldValue[prop]) {
- if (prop.includes("-")) {
- elm.style.setProperty(prop, newValue[prop]);
- } else {
- elm.style[prop] = newValue[prop];
- }
- }
- }
- } else if (memberName === "key") ; else if (memberName === "ref") {
- if (newValue) {
- newValue(elm);
- }
- } else if ((!isProp ) && 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 {
- 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) {
- elm[memberName] = n;
- }
- } else {
- elm[memberName] = newValue;
- }
- } catch (e) {
- }
- }
- let xlink = false;
- {
- if (ln !== (ln = ln.replace(/^xlink\:?/, ""))) {
- memberName = ln;
- xlink = true;
- }
- }
- if (newValue == null || newValue === false) {
- if (newValue !== false || elm.getAttribute(memberName) === "") {
- if (xlink) {
- elm.removeAttributeNS(XLINK_NS, memberName);
- } else {
- elm.removeAttribute(memberName);
- }
- }
- } else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
- newValue = newValue === true ? "" : newValue;
- if (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;
- {
- 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 (!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 (newVNode2.$text$ !== null) {
- elm = newVNode2.$elm$ = doc.createTextNode(newVNode2.$text$);
- } else if (newVNode2.$flags$ & 1 /* isSlotReference */) {
- elm = newVNode2.$elm$ = doc.createTextNode("");
- } else {
- if (!isSvgMode) {
- isSvgMode = newVNode2.$tag$ === "svg";
- }
- elm = newVNode2.$elm$ = doc.createElementNS(
- isSvgMode ? SVG_NS : HTML_NS,
- !useNativeShadowDom && BUILD.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
- ) ;
- if (isSvgMode && newVNode2.$tag$ === "foreignObject") {
- isSvgMode = false;
- }
- {
- updateElement(null, newVNode2, isSvgMode);
- }
- const rootNode = elm.getRootNode();
- const isElementWithinShadowRoot = !rootNode.querySelector("body");
- if (!isElementWithinShadowRoot && BUILD.scoped && isDef(scopeId) && elm["s-si"] !== scopeId) {
- elm.classList.add(elm["s-si"] = scopeId);
- }
- {
- 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 (newVNode2.$tag$ === "svg") {
- isSvgMode = false;
- } else if (elm.tagName === "foreignObject") {
- isSvgMode = true;
- }
- }
- }
- elm["s-hn"] = hostTagName;
- {
- 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$) {
- {
- relocateToHostRoot(oldParentVNode.$elm$);
- }
- }
- }
- }
- 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"] && BUILD.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 = parentElm["s-cr"] && parentElm["s-cr"].parentNode || parentElm;
- let childNode;
- if (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, referenceNode(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) {
- {
- 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 ((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 ((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;
- {
- for (i2 = oldStartIdx; i2 <= oldEndIdx; ++i2) {
- if (oldCh[i2] && oldCh[i2].$key$ !== null && oldCh[i2].$key$ === newStartVnode.$key$) {
- idxInOld = i2;
- break;
- }
- }
- }
- if (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) {
- {
- insertBefore(parentReferenceNode(oldStartVnode.$elm$), node, referenceNode(oldStartVnode.$elm$));
- }
- }
- }
- }
- if (oldStartIdx > oldEndIdx) {
- addVnodes(
- parentElm,
- newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$,
- newVNode2,
- newCh,
- newStartIdx,
- newEndIdx
- );
- } else if (newStartIdx > newEndIdx) {
- removeVnodes(oldCh, oldStartIdx, oldEndIdx);
- }
- };
- var isSameVnode = (leftVNode, rightVNode, isInitialRender = false) => {
- if (leftVNode.$tag$ === rightVNode.$tag$) {
- if (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 (!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 (text === null) {
- {
- isSvgMode = tag === "svg" ? true : tag === "foreignObject" ? false : isSvgMode;
- }
- {
- if (tag === "slot" && !useNativeShadowDom) {
- if (oldVNode.$name$ !== newVNode2.$name$) {
- newVNode2.$elm$["s-sn"] = newVNode2.$name$ || "";
- relocateToHostRoot(newVNode2.$elm$.parentElement);
- }
- } else {
- updateElement(oldVNode, newVNode2, isSvgMode);
- }
- }
- if (oldChildren !== null && newChildren !== null) {
- updateChildren(elm, oldChildren, newVNode2, newChildren, isInitialRender);
- } else if (newChildren !== null) {
- if (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 && BUILD.updatable && oldChildren !== null
- ) {
- removeVnodes(oldChildren, 0, oldChildren.length - 1);
- }
- if (isSvgMode && tag === "svg") {
- isSvgMode = false;
- }
- } else if ((defaultHolder = elm["s-cr"])) {
- defaultHolder.parentNode.textContent = text;
- } else if (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.textContent.trim() !== "") {
- childNode.hidden = true;
- break;
- }
- }
- }
- }
- }
- updateFallbackSlotVisibility(childNode);
- }
- }
- };
- var relocateNodes = [];
- var markSlotContentForRelocation = (elm) => {
- let node;
- let hostContentNodes;
- let j;
- for (const childNode of elm.childNodes) {
- if (childNode["s-sr"] && (node = childNode["s-cr"]) && node.parentNode) {
- hostContentNodes = node.parentNode.childNodes;
- const slotName = childNode["s-sn"];
- for (j = hostContentNodes.length - 1; j >= 0; j--) {
- node = hostContentNodes[j];
- if (!node["s-cn"] && !node["s-nr"] && node["s-hn"] !== childNode["s-hn"] && (!node["s-sh"] || node["s-sh"] !== childNode["s-hn"])) {
- if (isNodeLocatedInSlot(node, slotName)) {
- let relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
- checkSlotFallbackVisibility = true;
- node["s-sn"] = node["s-sn"] || slotName;
- if (relocateNodeData) {
- relocateNodeData.$nodeToRelocate$["s-sh"] = childNode["s-hn"];
- relocateNodeData.$slotRefNode$ = childNode;
- } else {
- node["s-sh"] = childNode["s-hn"];
- relocateNodes.push({
- $slotRefNode$: childNode,
- $nodeToRelocate$: node
- });
- }
- if (node["s-sr"]) {
- relocateNodes.map((relocateNode) => {
- if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node["s-sn"])) {
- relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
- if (relocateNodeData && !relocateNode.$slotRefNode$) {
- relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
- }
- }
- });
- }
- } else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
- relocateNodes.push({
- $nodeToRelocate$: node
- });
- }
- }
- }
- }
- if (childNode.nodeType === 1 /* ElementNode */) {
- markSlotContentForRelocation(childNode);
- }
- }
- };
- var isNodeLocatedInSlot = (nodeToRelocate, slotName) => {
- if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
- if (nodeToRelocate.getAttribute("slot") === null && slotName === "") {
- return true;
- }
- if (nodeToRelocate.getAttribute("slot") === slotName) {
- return true;
- }
- return false;
- }
- if (nodeToRelocate["s-sn"] === slotName) {
- return true;
- }
- return slotName === "";
- };
- var nullifyVNodeRefs = (vNode) => {
- {
- vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
- vNode.$children$ && vNode.$children$.map(nullifyVNodeRefs);
- }
- };
- var insertBefore = (parent, newNode, reference) => {
- const inserted = parent == null ? void 0 : parent.insertBefore(newNode, reference);
- {
- updateElementScopeIds(newNode, parent);
- }
- return inserted;
- };
- var findScopeIds = (element) => {
- const scopeIds = [];
- if (element) {
- scopeIds.push(
- ...element["s-scs"] || [],
- element["s-si"],
- element["s-sc"],
- ...findScopeIds(element.parentElement)
- );
- }
- return scopeIds;
- };
- var updateElementScopeIds = (element, parent, iterateChildNodes = false) => {
- var _a;
- if (element && parent && element.nodeType === 1 /* ElementNode */) {
- const scopeIds = new Set(findScopeIds(parent).filter(Boolean));
- if (scopeIds.size) {
- (_a = element.classList) == null ? void 0 : _a.add(...element["s-scs"] = [...scopeIds]);
- if (element["s-ol"] || iterateChildNodes) {
- for (const childNode of Array.from(element.childNodes)) {
- updateElementScopeIds(childNode, element, true);
- }
- }
- }
- }
- };
- var renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
- var _a, _b, _c, _d, _e;
- const hostElm = hostRef.$hostElement$;
- const cmpMeta = hostRef.$cmpMeta$;
- const oldVNode = hostRef.$vnode$ || newVNode(null, null);
- const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
- hostTagName = hostElm.tagName;
- if (cmpMeta.$attrsToReflect$) {
- rootVnode.$attrs$ = rootVnode.$attrs$ || {};
- cmpMeta.$attrsToReflect$.map(
- ([propName, attribute]) => rootVnode.$attrs$[attribute] = hostElm[propName]
- );
- }
- if (isInitialLoad && rootVnode.$attrs$) {
- for (const key of Object.keys(rootVnode.$attrs$)) {
- if (hostElm.hasAttribute(key) && !["key", "ref", "style", "class"].includes(key)) {
- rootVnode.$attrs$[key] = hostElm[key];
- }
- }
- }
- rootVnode.$tag$ = null;
- rootVnode.$flags$ |= 4 /* isHost */;
- hostRef.$vnode$ = rootVnode;
- rootVnode.$elm$ = oldVNode.$elm$ = hostElm.shadowRoot || hostElm ;
- {
- scopeId = hostElm["s-sc"];
- }
- useNativeShadowDom = (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) !== 0;
- {
- contentRef = hostElm["s-cr"];
- checkSlotFallbackVisibility = false;
- }
- patch(oldVNode, rootVnode, isInitialLoad);
- {
- plt.$flags$ |= 1 /* isTmpDisconnected */;
- if (checkSlotRelocate) {
- markSlotContentForRelocation(rootVnode.$elm$);
- for (const relocateData of relocateNodes) {
- const nodeToRelocate = relocateData.$nodeToRelocate$;
- if (!nodeToRelocate["s-ol"]) {
- const orgLocationNode = doc.createTextNode("");
- orgLocationNode["s-nr"] = nodeToRelocate;
- insertBefore(nodeToRelocate.parentNode, nodeToRelocate["s-ol"] = orgLocationNode, nodeToRelocate);
- }
- }
- for (const relocateData of relocateNodes) {
- const nodeToRelocate = relocateData.$nodeToRelocate$;
- const slotRefNode = relocateData.$slotRefNode$;
- if (slotRefNode) {
- const parentNodeRef = slotRefNode.parentNode;
- let insertBeforeNode = slotRefNode.nextSibling;
- if (insertBeforeNode && insertBeforeNode.nodeType === 1 /* ElementNode */) {
- let orgLocationNode = (_a = nodeToRelocate["s-ol"]) == null ? void 0 : _a.previousSibling;
- while (orgLocationNode) {
- let refNode = (_b = orgLocationNode["s-nr"]) != null ? _b : null;
- if (refNode && refNode["s-sn"] === nodeToRelocate["s-sn"] && parentNodeRef === refNode.parentNode) {
- refNode = refNode.nextSibling;
- while (refNode === nodeToRelocate || (refNode == null ? void 0 : refNode["s-sr"])) {
- refNode = refNode == null ? void 0 : refNode.nextSibling;
- }
- if (!refNode || !refNode["s-nr"]) {
- insertBeforeNode = refNode;
- break;
- }
- }
- orgLocationNode = orgLocationNode.previousSibling;
- }
- }
- if (!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode || nodeToRelocate.nextSibling !== insertBeforeNode) {
- if (nodeToRelocate !== insertBeforeNode) {
- insertBefore(parentNodeRef, nodeToRelocate, insertBeforeNode);
- if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
- nodeToRelocate.hidden = (_c = nodeToRelocate["s-ih"]) != null ? _c : false;
- }
- }
- }
- nodeToRelocate && typeof slotRefNode["s-rf"] === "function" && slotRefNode["s-rf"](nodeToRelocate);
- } else {
- if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
- if (isInitialLoad) {
- nodeToRelocate["s-ih"] = (_d = nodeToRelocate.hidden) != null ? _d : false;
- }
- nodeToRelocate.hidden = true;
- }
- }
- }
- }
- if (checkSlotFallbackVisibility) {
- updateFallbackSlotVisibility(rootVnode.$elm$);
- }
- plt.$flags$ &= ~1 /* isTmpDisconnected */;
- relocateNodes.length = 0;
- }
- if (cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
- for (const childNode of rootVnode.$elm$.childNodes) {
- if (childNode["s-hn"] !== hostTagName && !childNode["s-sh"]) {
- if (isInitialLoad && childNode["s-ih"] == null) {
- childNode["s-ih"] = (_e = childNode.hidden) != null ? _e : false;
- }
- childNode.hidden = true;
- }
- }
- }
- contentRef = void 0;
- };
- // src/runtime/update-component.ts
- var attachToAncestor = (hostRef, ancestorComponent) => {
- if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent["s-p"]) {
- ancestorComponent["s-p"].push(new Promise((r) => hostRef.$onRenderResolve$ = 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) {
- {
- hostRef.$flags$ |= 256 /* isListenReady */;
- if (hostRef.$queuedListeners$) {
- hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
- hostRef.$queuedListeners$ = void 0;
- }
- }
- {
- maybePromise = safeCall(instance, "componentWillLoad");
- }
- }
- {
- maybePromise = enqueue(maybePromise, () => safeCall(instance, "componentWillRender"));
- }
- 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, isInitialLoad);
- }
- 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 && instance.render();
- {
- hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
- }
- {
- hostRef.$flags$ |= 2 /* hasRendered */;
- }
- {
- {
- {
- renderVdom(hostRef, instance, isInitialLoad);
- }
- }
- }
- } 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");
- }
- if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
- hostRef.$flags$ |= 64 /* hasLoadedComponent */;
- {
- addHydratedFlag(elm);
- }
- {
- safeCall(instance, "componentDidLoad");
- }
- endPostUpdate();
- {
- hostRef.$onReadyResolve$(elm);
- if (!ancestorComponent) {
- appDidLoad();
- }
- }
- } else {
- {
- safeCall(instance, "componentDidUpdate");
- }
- endPostUpdate();
- }
- {
- hostRef.$onInstanceResolve$(elm);
- }
- {
- if (hostRef.$onRenderResolve$) {
- hostRef.$onRenderResolve$();
- hostRef.$onRenderResolve$ = void 0;
- }
- if (hostRef.$flags$ & 512 /* needsRerender */) {
- nextTick(() => scheduleUpdate(hostRef, false));
- }
- hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
- }
- };
- var forceUpdate = (ref) => {
- {
- const hostRef = getHostRef(ref);
- const isConnected = hostRef.$hostElement$.isConnected;
- if (isConnected && (hostRef.$flags$ & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
- scheduleUpdate(hostRef, false);
- }
- return isConnected;
- }
- };
- var appDidLoad = (who) => {
- {
- addHydratedFlag(doc.documentElement);
- }
- nextTick(() => emitEvent(win, "appload", { detail: { namespace: NAMESPACE } }));
- };
- var safeCall = (instance, method, arg) => {
- if (instance && instance[method]) {
- try {
- return instance[method](arg);
- } catch (e) {
- consoleError(e);
- }
- }
- 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/ionic-team/stencil/issues/5457).`
- );
- }
- const elm = hostRef.$hostElement$ ;
- 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 (cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
- const watchMethods = cmpMeta.$watchers$[propName];
- if (watchMethods) {
- watchMethods.map((watchMethodName) => {
- try {
- instance[watchMethodName](newVal, oldVal, propName);
- } catch (e) {
- consoleError(e, elm);
- }
- });
- }
- }
- if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
- scheduleUpdate(hostRef, false);
- }
- }
- }
- };
- // src/runtime/proxy-component.ts
- var proxyComponent = (Cstr, cmpMeta, flags) => {
- var _a, _b;
- const prototype = Cstr.prototype;
- if (cmpMeta.$members$ || (cmpMeta.$watchers$ || Cstr.watchers)) {
- if (Cstr.watchers && !cmpMeta.$watchers$) {
- cmpMeta.$watchers$ = Cstr.watchers;
- }
- const members = Object.entries((_a = cmpMeta.$members$) != null ? _a : {});
- members.map(([memberName, [memberFlags]]) => {
- if ((memberFlags & 31 /* Prop */ || (flags & 2 /* proxyState */) && memberFlags & 32 /* State */)) {
- Object.defineProperty(prototype, memberName, {
- get() {
- return getValue(this, memberName);
- },
- set(newValue) {
- setValue(this, memberName, newValue, cmpMeta);
- },
- configurable: true,
- enumerable: true
- });
- } else if (flags & 1 /* isElementConstructor */ && memberFlags & 64 /* Method */) {
- Object.defineProperty(prototype, memberName, {
- value(...args) {
- var _a2;
- const ref = getHostRef(this);
- return (_a2 = ref == null ? void 0 : ref.$onInstancePromise$) == null ? void 0 : _a2.then(() => {
- var _a3;
- return (_a3 = ref.$lazyInstance$) == null ? void 0 : _a3[memberName](...args);
- });
- }
- });
- }
- });
- 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)) {
- 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;
- }
- this[propName] = newValue === null && typeof this[propName] === "boolean" ? false : 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]) => {
- var _a2;
- const attrName = m[1] || propName;
- attrNameToPropName.set(attrName, propName);
- if (m[0] & 512 /* ReflectAttr */) {
- (_a2 = cmpMeta.$attrsToReflect$) == null ? void 0 : _a2.push([propName, attrName]);
- }
- 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);
- 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) {
- {
- cmpMeta.$watchers$ = Cstr.watchers;
- }
- 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);
- }
- {
- hostRef.$flags$ &= ~8 /* isConstructingInstance */;
- }
- {
- hostRef.$flags$ |= 128 /* isWatchReady */;
- }
- endNewInstance();
- fireConnectedCallback(hostRef.$lazyInstance$);
- } 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;
- } else if (typeof Cstr.style !== "string") {
- hostRef.$modeName$ = computeMode(elm);
- if (hostRef.$modeName$) {
- style = Cstr.style[hostRef.$modeName$];
- }
- }
- const scopeId2 = getScopeId(cmpMeta, hostRef.$modeName$);
- 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) => {
- {
- safeCall(instance, "connectedCallback");
- }
- };
- // 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 hostId;
- {
- hostId = elm.getAttribute(HYDRATE_ID);
- if (hostId) {
- if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
- const scopeId2 = addStyle(elm.shadowRoot, cmpMeta, elm.getAttribute("s-mode")) ;
- elm.classList.remove(scopeId2 + "-h", scopeId2 + "-s");
- }
- initializeClientHydrate(elm, cmpMeta.$tagName$, hostId, hostRef);
- }
- }
- if (!hostId) {
- if (// TODO(STENCIL-854): Remove code related to legacy shadowDomShim field
- cmpMeta.$flags$ & (4 /* hasSlotRelocation */ | 8 /* needsShadowDomShim */)) {
- setContentReference(elm);
- }
- }
- {
- let ancestorComponent = elm;
- while (ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host) {
- if (ancestorComponent.nodeType === 1 /* ElementNode */ && ancestorComponent.hasAttribute("s-id") && ancestorComponent["s-p"] || 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 {
- addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
- if (hostRef == null ? void 0 : hostRef.$lazyInstance$) {
- fireConnectedCallback(hostRef.$lazyInstance$);
- } else if (hostRef == null ? void 0 : hostRef.$onReadyPromise$) {
- hostRef.$onReadyPromise$.then(() => fireConnectedCallback(hostRef.$lazyInstance$));
- }
- }
- endConnected();
- }
- };
- var setContentReference = (elm) => {
- const contentRefElm = elm["s-cr"] = doc.createComment(
- ""
- );
- contentRefElm["s-cn"] = true;
- insertBefore(elm, contentRefElm, elm.firstChild);
- };
- var disconnectInstance = (instance) => {
- {
- safeCall(instance, "disconnectedCallback");
- }
- };
- var disconnectedCallback = async (elm) => {
- if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
- const hostRef = getHostRef(elm);
- {
- if (hostRef.$rmListeners$) {
- hostRef.$rmListeners$.map((rmListener) => rmListener());
- hostRef.$rmListeners$ = void 0;
- }
- }
- if (hostRef == null ? void 0 : hostRef.$lazyInstance$) {
- disconnectInstance(hostRef.$lazyInstance$);
- } else if (hostRef == null ? void 0 : hostRef.$onReadyPromise$) {
- hostRef.$onReadyPromise$.then(() => disconnectInstance(hostRef.$lazyInstance$));
- }
- }
- };
- var patchPseudoShadowDom = (hostElementPrototype, descriptorPrototype) => {
- patchCloneNode(hostElementPrototype);
- patchSlotAppendChild(hostElementPrototype);
- patchSlotAppend(hostElementPrototype);
- patchSlotPrepend(hostElementPrototype);
- patchSlotInsertAdjacentElement(hostElementPrototype);
- patchSlotInsertAdjacentHTML(hostElementPrototype);
- patchSlotInsertAdjacentText(hostElementPrototype);
- patchTextContent(hostElementPrototype);
- patchChildSlotNodes(hostElementPrototype, descriptorPrototype);
- patchSlotRemoveChild(hostElementPrototype);
- };
- var patchCloneNode = (HostElementPrototype) => {
- const orgCloneNode = HostElementPrototype.cloneNode;
- HostElementPrototype.cloneNode = function(deep) {
- const srcNode = this;
- const isShadowDom = srcNode.shadowRoot && supportsShadow ;
- const clonedNode = orgCloneNode.call(srcNode, isShadowDom ? deep : false);
- if (!isShadowDom && deep) {
- let i2 = 0;
- let slotted, nonStencilNode;
- const stencilPrivates = [
- "s-id",
- "s-cr",
- "s-lr",
- "s-rc",
- "s-sc",
- "s-p",
- "s-cn",
- "s-sr",
- "s-sn",
- "s-hn",
- "s-ol",
- "s-nr",
- "s-si",
- "s-rf",
- "s-scs"
- ];
- for (; i2 < srcNode.childNodes.length; i2++) {
- slotted = srcNode.childNodes[i2]["s-nr"];
- nonStencilNode = stencilPrivates.every((privateField) => !srcNode.childNodes[i2][privateField]);
- if (slotted) {
- if (clonedNode.__appendChild) {
- clonedNode.__appendChild(slotted.cloneNode(true));
- } else {
- clonedNode.appendChild(slotted.cloneNode(true));
- }
- }
- if (nonStencilNode) {
- clonedNode.appendChild(srcNode.childNodes[i2].cloneNode(true));
- }
- }
- }
- return clonedNode;
- };
- };
- var patchSlotAppendChild = (HostElementPrototype) => {
- HostElementPrototype.__appendChild = HostElementPrototype.appendChild;
- HostElementPrototype.appendChild = function(newChild) {
- const slotName = newChild["s-sn"] = getSlotName(newChild);
- const slotNode = getHostSlotNode(this.childNodes, slotName, this.tagName);
- if (slotNode) {
- const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
- const appendAfter = slotChildNodes[slotChildNodes.length - 1];
- const insertedNode = insertBefore(appendAfter.parentNode, newChild, appendAfter.nextSibling);
- updateFallbackSlotVisibility(this);
- return insertedNode;
- }
- return this.__appendChild(newChild);
- };
- };
- var patchSlotRemoveChild = (ElementPrototype) => {
- ElementPrototype.__removeChild = ElementPrototype.removeChild;
- ElementPrototype.removeChild = function(toRemove) {
- if (toRemove && typeof toRemove["s-sn"] !== "undefined") {
- const slotNode = getHostSlotNode(this.childNodes, toRemove["s-sn"], this.tagName);
- if (slotNode) {
- const slotChildNodes = getHostSlotChildNodes(slotNode, toRemove["s-sn"]);
- const existingNode = slotChildNodes.find((n) => n === toRemove);
- if (existingNode) {
- existingNode.remove();
- updateFallbackSlotVisibility(this);
- return;
- }
- }
- }
- return this.__removeChild(toRemove);
- };
- };
- var patchSlotPrepend = (HostElementPrototype) => {
- const originalPrepend = HostElementPrototype.prepend;
- HostElementPrototype.prepend = function(...newChildren) {
- newChildren.forEach((newChild) => {
- if (typeof newChild === "string") {
- newChild = this.ownerDocument.createTextNode(newChild);
- }
- const slotName = newChild["s-sn"] = getSlotName(newChild);
- const slotNode = getHostSlotNode(this.childNodes, slotName, this.tagName);
- if (slotNode) {
- const slotPlaceholder = document.createTextNode("");
- slotPlaceholder["s-nr"] = newChild;
- slotNode["s-cr"].parentNode.__appendChild(slotPlaceholder);
- newChild["s-ol"] = slotPlaceholder;
- const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
- const appendAfter = slotChildNodes[0];
- return insertBefore(appendAfter.parentNode, newChild, appendAfter.nextSibling);
- }
- if (newChild.nodeType === 1 && !!newChild.getAttribute("slot")) {
- newChild.hidden = true;
- }
- return originalPrepend.call(this, newChild);
- });
- };
- };
- var patchSlotAppend = (HostElementPrototype) => {
- HostElementPrototype.append = function(...newChildren) {
- newChildren.forEach((newChild) => {
- if (typeof newChild === "string") {
- newChild = this.ownerDocument.createTextNode(newChild);
- }
- this.appendChild(newChild);
- });
- };
- };
- var patchSlotInsertAdjacentHTML = (HostElementPrototype) => {
- const originalInsertAdjacentHtml = HostElementPrototype.insertAdjacentHTML;
- HostElementPrototype.insertAdjacentHTML = function(position, text) {
- if (position !== "afterbegin" && position !== "beforeend") {
- return originalInsertAdjacentHtml.call(this, position, text);
- }
- const container = this.ownerDocument.createElement("_");
- let node;
- container.innerHTML = text;
- if (position === "afterbegin") {
- while (node = container.firstChild) {
- this.prepend(node);
- }
- } else if (position === "beforeend") {
- while (node = container.firstChild) {
- this.append(node);
- }
- }
- };
- };
- var patchSlotInsertAdjacentText = (HostElementPrototype) => {
- HostElementPrototype.insertAdjacentText = function(position, text) {
- this.insertAdjacentHTML(position, text);
- };
- };
- var patchSlotInsertAdjacentElement = (HostElementPrototype) => {
- const originalInsertAdjacentElement = HostElementPrototype.insertAdjacentElement;
- HostElementPrototype.insertAdjacentElement = function(position, element) {
- if (position !== "afterbegin" && position !== "beforeend") {
- return originalInsertAdjacentElement.call(this, position, element);
- }
- if (position === "afterbegin") {
- this.prepend(element);
- return element;
- } else if (position === "beforeend") {
- this.append(element);
- return element;
- }
- return element;
- };
- };
- var patchTextContent = (hostElementPrototype) => {
- const descriptor = Object.getOwnPropertyDescriptor(Node.prototype, "textContent");
- Object.defineProperty(hostElementPrototype, "__textContent", descriptor);
- {
- Object.defineProperty(hostElementPrototype, "textContent", {
- // To mimic shadow root behavior, we need to return the text content of all
- // nodes in a slot reference node
- get() {
- const slotRefNodes = getAllChildSlotNodes(this.childNodes);
- const textContent = slotRefNodes.map((node) => {
- var _a, _b;
- const text = [];
- let slotContent = node.nextSibling;
- while (slotContent && slotContent["s-sn"] === node["s-sn"]) {
- if (slotContent.nodeType === 3 /* TEXT_NODE */ || slotContent.nodeType === 1 /* ELEMENT_NODE */) {
- text.push((_b = (_a = slotContent.textContent) == null ? void 0 : _a.trim()) != null ? _b : "");
- }
- slotContent = slotContent.nextSibling;
- }
- return text.filter((ref) => ref !== "").join(" ");
- }).filter((text) => text !== "").join(" ");
- return " " + textContent + " ";
- },
- // To mimic shadow root behavior, we need to overwrite all nodes in a slot
- // reference node. If a default slot reference node exists, the text content will be
- // placed there. Otherwise, the new text node will be hidden
- set(value) {
- const slotRefNodes = getAllChildSlotNodes(this.childNodes);
- slotRefNodes.forEach((node) => {
- let slotContent = node.nextSibling;
- while (slotContent && slotContent["s-sn"] === node["s-sn"]) {
- const tmp = slotContent;
- slotContent = slotContent.nextSibling;
- tmp.remove();
- }
- if (node["s-sn"] === "") {
- const textNode = this.ownerDocument.createTextNode(value);
- textNode["s-sn"] = "";
- insertBefore(node.parentElement, textNode, node.nextSibling);
- } else {
- node.remove();
- }
- });
- }
- });
- }
- };
- var patchChildSlotNodes = (elm, cmpMeta) => {
- class FakeNodeList extends Array {
- item(n) {
- return this[n];
- }
- }
- if (cmpMeta.$flags$ & 8 /* needsShadowDomShim */) {
- const childNodesFn = elm.__lookupGetter__("childNodes");
- Object.defineProperty(elm, "children", {
- get() {
- return this.childNodes.map((n) => n.nodeType === 1);
- }
- });
- Object.defineProperty(elm, "childElementCount", {
- get() {
- return elm.children.length;
- }
- });
- Object.defineProperty(elm, "childNodes", {
- get() {
- const childNodes = childNodesFn.call(this);
- if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0 && getHostRef(this).$flags$ & 2 /* hasRendered */) {
- const result = new FakeNodeList();
- for (let i2 = 0; i2 < childNodes.length; i2++) {
- const slot = childNodes[i2]["s-nr"];
- if (slot) {
- result.push(slot);
- }
- }
- return result;
- }
- return FakeNodeList.from(childNodes);
- }
- });
- }
- };
- var getAllChildSlotNodes = (childNodes) => {
- const slotRefNodes = [];
- for (const childNode of Array.from(childNodes)) {
- if (childNode["s-sr"]) {
- slotRefNodes.push(childNode);
- }
- slotRefNodes.push(...getAllChildSlotNodes(childNode.childNodes));
- }
- return slotRefNodes;
- };
- var getSlotName = (node) => node["s-sn"] || node.nodeType === 1 && node.getAttribute("slot") || "";
- var getHostSlotNode = (childNodes, slotName, hostName) => {
- let i2 = 0;
- let childNode;
- for (; i2 < childNodes.length; i2++) {
- childNode = childNodes[i2];
- if (childNode["s-sr"] && childNode["s-sn"] === slotName && childNode["s-hn"] === hostName) {
- return childNode;
- }
- childNode = getHostSlotNode(childNode.childNodes, slotName, hostName);
- if (childNode) {
- return childNode;
- }
- }
- return null;
- };
- var getHostSlotChildNodes = (n, slotName) => {
- const childNodes = [n];
- while ((n = n.nextSibling) && n["s-sn"] === slotName) {
- childNodes.push(n);
- }
- return childNodes;
- };
- // src/runtime/bootstrap-lazy.ts
- var bootstrapLazy = (lazyBundles, options = {}) => {
- var _a;
- const endBootstrap = createTime();
- const cmpTags = [];
- const exclude = options.exclude || [];
- const customElements2 = win.customElements;
- const head = doc.head;
- const metaCharset = /* @__PURE__ */ head.querySelector("meta[charset]");
- const dataStyles = /* @__PURE__ */ doc.createElement("style");
- const deferredConnectedCallbacks = [];
- let appLoadFallback;
- let isBootstrapping = true;
- Object.assign(plt, options);
- plt.$resourcesUrl$ = new URL(options.resourcesUrl || "./", doc.baseURI).href;
- {
- plt.$flags$ |= 2 /* appLoaded */;
- }
- let hasSlotRelocation = false;
- lazyBundles.map((lazyBundle) => {
- lazyBundle[1].map((compactMeta) => {
- var _a2;
- 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];
- }
- {
- cmpMeta.$listeners$ = compactMeta[3];
- }
- {
- cmpMeta.$attrsToReflect$ = [];
- }
- {
- cmpMeta.$watchers$ = (_a2 = compactMeta[4]) != null ? _a2 : {};
- }
- 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) {
- {
- self.attachShadow({
- mode: "open",
- delegatesFocus: !!(cmpMeta.$flags$ & 16 /* shadowDelegatesFocus */)
- });
- }
- } 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() {
- const hostRef = getHostRef(this);
- if (!this.hasRegisteredEventListeners) {
- this.hasRegisteredEventListeners = true;
- addHostEventListeners(this, hostRef, cmpMeta.$listeners$);
- }
- if (appLoadFallback) {
- clearTimeout(appLoadFallback);
- appLoadFallback = null;
- }
- if (isBootstrapping) {
- deferredConnectedCallbacks.push(this);
- } else {
- plt.jmp(() => connectedCallback(this));
- }
- }
- disconnectedCallback() {
- plt.jmp(() => disconnectedCallback(this));
- }
- componentOnReady() {
- return getHostRef(this).$onReadyPromise$;
- }
- };
- {
- if (cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
- patchPseudoShadowDom(HostElement.prototype, cmpMeta);
- }
- }
- 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(doc);
- 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();
- };
- var addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
- if (listeners) {
- listeners.map(([flags, name, method]) => {
- const target = getHostListenerTarget(elm, flags) ;
- const handler = hostListenerProxy(hostRef, method);
- const opts = hostListenerOpts(flags);
- plt.ael(target, name, handler, opts);
- (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
- });
- }
- };
- var hostListenerProxy = (hostRef, methodName) => (ev) => {
- var _a;
- try {
- {
- if (hostRef.$flags$ & 256 /* isListenReady */) {
- (_a = hostRef.$lazyInstance$) == null ? void 0 : _a[methodName](ev);
- } else {
- (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
- }
- }
- } catch (e) {
- consoleError(e);
- }
- };
- var getHostListenerTarget = (elm, flags) => {
- if (flags & 4 /* TargetDocument */) return doc;
- if (flags & 8 /* TargetWindow */) return win;
- if (flags & 16 /* TargetBody */) return doc.body;
- return elm;
- };
- var hostListenerOpts = (flags) => supportsListenerOptions ? {
- passive: (flags & 1 /* Passive */) !== 0,
- capture: (flags & 2 /* Capture */) !== 0
- } : (flags & 2 /* Capture */) !== 0;
- // src/runtime/nonce.ts
- var setNonce = (nonce) => plt.$nonce$ = nonce;
- exports.Build = Build;
- exports.H = H;
- exports.Host = Host;
- exports.bootstrapLazy = bootstrapLazy;
- exports.createEvent = createEvent;
- exports.forceUpdate = forceUpdate;
- exports.getAssetPath = getAssetPath;
- exports.getElement = getElement;
- exports.getMode = getMode;
- exports.h = h;
- exports.promiseResolve = promiseResolve;
- exports.readTask = readTask;
- exports.registerInstance = registerInstance;
- exports.setMode = setMode;
- exports.setNonce = setNonce;
- exports.writeTask = writeTask;
|