index.js 119 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394
  1. /*
  2. Stencil Hydrate Platform v4.20.0 | MIT Licensed | https://stenciljs.com
  3. */
  4. var __defProp = Object.defineProperty;
  5. var __export = (target, all) => {
  6. for (var name in all)
  7. __defProp(target, name, { get: all[name], enumerable: true });
  8. };
  9. // src/hydrate/platform/index.ts
  10. import { BUILD as BUILD22 } from "@stencil/core/internal/app-data";
  11. // src/runtime/asset-path.ts
  12. var getAssetPath = (path) => {
  13. const assetUrl = new URL(path, plt.$resourcesUrl$);
  14. return assetUrl.origin !== win.location.origin ? assetUrl.href : assetUrl.pathname;
  15. };
  16. var setAssetPath = (path) => plt.$resourcesUrl$ = path;
  17. // src/runtime/bootstrap-custom-element.ts
  18. import { BUILD as BUILD18 } from "@stencil/core/internal/app-data";
  19. // src/utils/constants.ts
  20. var EMPTY_OBJ = {};
  21. var SVG_NS = "http://www.w3.org/2000/svg";
  22. var HTML_NS = "http://www.w3.org/1999/xhtml";
  23. // src/utils/helpers.ts
  24. var isDef = (v) => v != null;
  25. var isComplexType = (o) => {
  26. o = typeof o;
  27. return o === "object" || o === "function";
  28. };
  29. // src/utils/query-nonce-meta-tag-content.ts
  30. function queryNonceMetaTagContent(doc2) {
  31. var _a, _b, _c;
  32. 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;
  33. }
  34. // src/utils/result.ts
  35. var result_exports = {};
  36. __export(result_exports, {
  37. err: () => err,
  38. map: () => map,
  39. ok: () => ok,
  40. unwrap: () => unwrap,
  41. unwrapErr: () => unwrapErr
  42. });
  43. var ok = (value) => ({
  44. isOk: true,
  45. isErr: false,
  46. value
  47. });
  48. var err = (value) => ({
  49. isOk: false,
  50. isErr: true,
  51. value
  52. });
  53. function map(result, fn) {
  54. if (result.isOk) {
  55. const val = fn(result.value);
  56. if (val instanceof Promise) {
  57. return val.then((newVal) => ok(newVal));
  58. } else {
  59. return ok(val);
  60. }
  61. }
  62. if (result.isErr) {
  63. const value = result.value;
  64. return err(value);
  65. }
  66. throw "should never get here";
  67. }
  68. var unwrap = (result) => {
  69. if (result.isOk) {
  70. return result.value;
  71. } else {
  72. throw result.value;
  73. }
  74. };
  75. var unwrapErr = (result) => {
  76. if (result.isErr) {
  77. return result.value;
  78. } else {
  79. throw result.value;
  80. }
  81. };
  82. // src/runtime/connected-callback.ts
  83. import { BUILD as BUILD15 } from "@stencil/core/internal/app-data";
  84. // src/runtime/client-hydrate.ts
  85. import { BUILD as BUILD3 } from "@stencil/core/internal/app-data";
  86. // src/runtime/profile.ts
  87. import { BUILD } from "@stencil/core/internal/app-data";
  88. var i = 0;
  89. var createTime = (fnName, tagName = "") => {
  90. if (BUILD.profile && performance.mark) {
  91. const key = `st:${fnName}:${tagName}:${i++}`;
  92. performance.mark(key);
  93. return () => performance.measure(`[Stencil] ${fnName}() <${tagName}>`, key);
  94. } else {
  95. return () => {
  96. return;
  97. };
  98. }
  99. };
  100. var uniqueTime = (key, measureText) => {
  101. if (BUILD.profile && performance.mark) {
  102. if (performance.getEntriesByName(key, "mark").length === 0) {
  103. performance.mark(key);
  104. }
  105. return () => {
  106. if (performance.getEntriesByName(measureText, "measure").length === 0) {
  107. performance.measure(measureText, key);
  108. }
  109. };
  110. } else {
  111. return () => {
  112. return;
  113. };
  114. }
  115. };
  116. var inspect = (ref) => {
  117. const hostRef = getHostRef(ref);
  118. if (!hostRef) {
  119. return void 0;
  120. }
  121. const flags = hostRef.$flags$;
  122. const hostElement = hostRef.$hostElement$;
  123. return {
  124. renderCount: hostRef.$renderCount$,
  125. flags: {
  126. hasRendered: !!(flags & 2 /* hasRendered */),
  127. hasConnected: !!(flags & 1 /* hasConnected */),
  128. isWaitingForChildren: !!(flags & 4 /* isWaitingForChildren */),
  129. isConstructingInstance: !!(flags & 8 /* isConstructingInstance */),
  130. isQueuedForUpdate: !!(flags & 16 /* isQueuedForUpdate */),
  131. hasInitializedComponent: !!(flags & 32 /* hasInitializedComponent */),
  132. hasLoadedComponent: !!(flags & 64 /* hasLoadedComponent */),
  133. isWatchReady: !!(flags & 128 /* isWatchReady */),
  134. isListenReady: !!(flags & 256 /* isListenReady */),
  135. needsRerender: !!(flags & 512 /* needsRerender */)
  136. },
  137. instanceValues: hostRef.$instanceValues$,
  138. ancestorComponent: hostRef.$ancestorComponent$,
  139. hostElement,
  140. lazyInstance: hostRef.$lazyInstance$,
  141. vnode: hostRef.$vnode$,
  142. modeName: hostRef.$modeName$,
  143. onReadyPromise: hostRef.$onReadyPromise$,
  144. onReadyResolve: hostRef.$onReadyResolve$,
  145. onInstancePromise: hostRef.$onInstancePromise$,
  146. onInstanceResolve: hostRef.$onInstanceResolve$,
  147. onRenderResolve: hostRef.$onRenderResolve$,
  148. queuedListeners: hostRef.$queuedListeners$,
  149. rmListeners: hostRef.$rmListeners$,
  150. ["s-id"]: hostElement["s-id"],
  151. ["s-cr"]: hostElement["s-cr"],
  152. ["s-lr"]: hostElement["s-lr"],
  153. ["s-p"]: hostElement["s-p"],
  154. ["s-rc"]: hostElement["s-rc"],
  155. ["s-sc"]: hostElement["s-sc"]
  156. };
  157. };
  158. var installDevTools = () => {
  159. if (BUILD.devTools) {
  160. const stencil = win.stencil = win.stencil || {};
  161. const originalInspect = stencil.inspect;
  162. stencil.inspect = (ref) => {
  163. let result = inspect(ref);
  164. if (!result && typeof originalInspect === "function") {
  165. result = originalInspect(ref);
  166. }
  167. return result;
  168. };
  169. }
  170. };
  171. // src/runtime/runtime-constants.ts
  172. var CONTENT_REF_ID = "r";
  173. var ORG_LOCATION_ID = "o";
  174. var SLOT_NODE_ID = "s";
  175. var TEXT_NODE_ID = "t";
  176. var HYDRATE_ID = "s-id";
  177. var HYDRATED_STYLE_ID = "sty-id";
  178. var HYDRATE_CHILD_ID = "c-id";
  179. var HYDRATED_CSS = "{visibility:hidden}.hydrated{visibility:inherit}";
  180. var SLOT_FB_CSS = "slot-fb{display:contents}slot-fb[hidden]{display:none}";
  181. var XLINK_NS = "http://www.w3.org/1999/xlink";
  182. var FORM_ASSOCIATED_CUSTOM_ELEMENT_CALLBACKS = [
  183. "formAssociatedCallback",
  184. "formResetCallback",
  185. "formDisabledCallback",
  186. "formStateRestoreCallback"
  187. ];
  188. // src/runtime/vdom/h.ts
  189. import { BUILD as BUILD2 } from "@stencil/core/internal/app-data";
  190. var h = (nodeName, vnodeData, ...children) => {
  191. let child = null;
  192. let key = null;
  193. let slotName = null;
  194. let simple = false;
  195. let lastSimple = false;
  196. const vNodeChildren = [];
  197. const walk = (c) => {
  198. for (let i2 = 0; i2 < c.length; i2++) {
  199. child = c[i2];
  200. if (Array.isArray(child)) {
  201. walk(child);
  202. } else if (child != null && typeof child !== "boolean") {
  203. if (simple = typeof nodeName !== "function" && !isComplexType(child)) {
  204. child = String(child);
  205. } else if (BUILD2.isDev && typeof nodeName !== "function" && child.$flags$ === void 0) {
  206. consoleDevError(`vNode passed as children has unexpected type.
  207. Make sure it's using the correct h() function.
  208. Empty objects can also be the cause, look for JSX comments that became objects.`);
  209. }
  210. if (simple && lastSimple) {
  211. vNodeChildren[vNodeChildren.length - 1].$text$ += child;
  212. } else {
  213. vNodeChildren.push(simple ? newVNode(null, child) : child);
  214. }
  215. lastSimple = simple;
  216. }
  217. }
  218. };
  219. walk(children);
  220. if (vnodeData) {
  221. if (BUILD2.isDev && nodeName === "input") {
  222. validateInputProperties(vnodeData);
  223. }
  224. if (BUILD2.vdomKey && vnodeData.key) {
  225. key = vnodeData.key;
  226. }
  227. if (BUILD2.slotRelocation && vnodeData.name) {
  228. slotName = vnodeData.name;
  229. }
  230. if (BUILD2.vdomClass) {
  231. const classData = vnodeData.className || vnodeData.class;
  232. if (classData) {
  233. vnodeData.class = typeof classData !== "object" ? classData : Object.keys(classData).filter((k) => classData[k]).join(" ");
  234. }
  235. }
  236. }
  237. if (BUILD2.isDev && vNodeChildren.some(isHost)) {
  238. consoleDevError(`The <Host> must be the single root component. Make sure:
  239. - You are NOT using hostData() and <Host> in the same component.
  240. - <Host> is used once, and it's the single root component of the render() function.`);
  241. }
  242. if (BUILD2.vdomFunctional && typeof nodeName === "function") {
  243. return nodeName(
  244. vnodeData === null ? {} : vnodeData,
  245. vNodeChildren,
  246. vdomFnUtils
  247. );
  248. }
  249. const vnode = newVNode(nodeName, null);
  250. vnode.$attrs$ = vnodeData;
  251. if (vNodeChildren.length > 0) {
  252. vnode.$children$ = vNodeChildren;
  253. }
  254. if (BUILD2.vdomKey) {
  255. vnode.$key$ = key;
  256. }
  257. if (BUILD2.slotRelocation) {
  258. vnode.$name$ = slotName;
  259. }
  260. return vnode;
  261. };
  262. var newVNode = (tag, text) => {
  263. const vnode = {
  264. $flags$: 0,
  265. $tag$: tag,
  266. $text$: text,
  267. $elm$: null,
  268. $children$: null
  269. };
  270. if (BUILD2.vdomAttribute) {
  271. vnode.$attrs$ = null;
  272. }
  273. if (BUILD2.vdomKey) {
  274. vnode.$key$ = null;
  275. }
  276. if (BUILD2.slotRelocation) {
  277. vnode.$name$ = null;
  278. }
  279. return vnode;
  280. };
  281. var Host = {};
  282. var isHost = (node) => node && node.$tag$ === Host;
  283. var vdomFnUtils = {
  284. forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
  285. map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate)
  286. };
  287. var convertToPublic = (node) => ({
  288. vattrs: node.$attrs$,
  289. vchildren: node.$children$,
  290. vkey: node.$key$,
  291. vname: node.$name$,
  292. vtag: node.$tag$,
  293. vtext: node.$text$
  294. });
  295. var convertToPrivate = (node) => {
  296. if (typeof node.vtag === "function") {
  297. const vnodeData = { ...node.vattrs };
  298. if (node.vkey) {
  299. vnodeData.key = node.vkey;
  300. }
  301. if (node.vname) {
  302. vnodeData.name = node.vname;
  303. }
  304. return h(node.vtag, vnodeData, ...node.vchildren || []);
  305. }
  306. const vnode = newVNode(node.vtag, node.vtext);
  307. vnode.$attrs$ = node.vattrs;
  308. vnode.$children$ = node.vchildren;
  309. vnode.$key$ = node.vkey;
  310. vnode.$name$ = node.vname;
  311. return vnode;
  312. };
  313. var validateInputProperties = (inputElm) => {
  314. const props = Object.keys(inputElm);
  315. const value = props.indexOf("value");
  316. if (value === -1) {
  317. return;
  318. }
  319. const typeIndex = props.indexOf("type");
  320. const minIndex = props.indexOf("min");
  321. const maxIndex = props.indexOf("max");
  322. const stepIndex = props.indexOf("step");
  323. if (value < typeIndex || value < minIndex || value < maxIndex || value < stepIndex) {
  324. consoleDevWarn(`The "value" prop of <input> should be set after "min", "max", "type" and "step"`);
  325. }
  326. };
  327. // src/runtime/client-hydrate.ts
  328. var initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
  329. const endHydrate = createTime("hydrateClient", tagName);
  330. const shadowRoot = hostElm.shadowRoot;
  331. const childRenderNodes = [];
  332. const slotNodes = [];
  333. const shadowRootNodes = BUILD3.shadowDom && shadowRoot ? [] : null;
  334. const vnode = hostRef.$vnode$ = newVNode(tagName, null);
  335. if (!plt.$orgLocNodes$) {
  336. initializeDocumentHydrate(doc.body, plt.$orgLocNodes$ = /* @__PURE__ */ new Map());
  337. }
  338. hostElm[HYDRATE_ID] = hostId;
  339. hostElm.removeAttribute(HYDRATE_ID);
  340. clientHydrate(vnode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, hostElm, hostId);
  341. childRenderNodes.map((c) => {
  342. const orgLocationId = c.$hostId$ + "." + c.$nodeId$;
  343. const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
  344. const node = c.$elm$;
  345. if (orgLocationNode && supportsShadow && orgLocationNode["s-en"] === "") {
  346. orgLocationNode.parentNode.insertBefore(node, orgLocationNode.nextSibling);
  347. }
  348. if (!shadowRoot) {
  349. node["s-hn"] = tagName;
  350. if (orgLocationNode) {
  351. node["s-ol"] = orgLocationNode;
  352. node["s-ol"]["s-nr"] = node;
  353. }
  354. }
  355. plt.$orgLocNodes$.delete(orgLocationId);
  356. });
  357. if (BUILD3.shadowDom && shadowRoot) {
  358. shadowRootNodes.map((shadowRootNode) => {
  359. if (shadowRootNode) {
  360. shadowRoot.appendChild(shadowRootNode);
  361. }
  362. });
  363. }
  364. endHydrate();
  365. };
  366. var clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node, hostId) => {
  367. let childNodeType;
  368. let childIdSplt;
  369. let childVNode;
  370. let i2;
  371. if (node.nodeType === 1 /* ElementNode */) {
  372. childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
  373. if (childNodeType) {
  374. childIdSplt = childNodeType.split(".");
  375. if (childIdSplt[0] === hostId || childIdSplt[0] === "0") {
  376. childVNode = {
  377. $flags$: 0,
  378. $hostId$: childIdSplt[0],
  379. $nodeId$: childIdSplt[1],
  380. $depth$: childIdSplt[2],
  381. $index$: childIdSplt[3],
  382. $tag$: node.tagName.toLowerCase(),
  383. $elm$: node,
  384. $attrs$: null,
  385. $children$: null,
  386. $key$: null,
  387. $name$: null,
  388. $text$: null
  389. };
  390. childRenderNodes.push(childVNode);
  391. node.removeAttribute(HYDRATE_CHILD_ID);
  392. if (!parentVNode.$children$) {
  393. parentVNode.$children$ = [];
  394. }
  395. parentVNode.$children$[childVNode.$index$] = childVNode;
  396. parentVNode = childVNode;
  397. if (shadowRootNodes && childVNode.$depth$ === "0") {
  398. shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
  399. }
  400. }
  401. }
  402. if (node.shadowRoot) {
  403. for (i2 = node.shadowRoot.childNodes.length - 1; i2 >= 0; i2--) {
  404. clientHydrate(
  405. parentVNode,
  406. childRenderNodes,
  407. slotNodes,
  408. shadowRootNodes,
  409. hostElm,
  410. node.shadowRoot.childNodes[i2],
  411. hostId
  412. );
  413. }
  414. }
  415. for (i2 = node.childNodes.length - 1; i2 >= 0; i2--) {
  416. clientHydrate(
  417. parentVNode,
  418. childRenderNodes,
  419. slotNodes,
  420. shadowRootNodes,
  421. hostElm,
  422. node.childNodes[i2],
  423. hostId
  424. );
  425. }
  426. } else if (node.nodeType === 8 /* CommentNode */) {
  427. childIdSplt = node.nodeValue.split(".");
  428. if (childIdSplt[1] === hostId || childIdSplt[1] === "0") {
  429. childNodeType = childIdSplt[0];
  430. childVNode = {
  431. $flags$: 0,
  432. $hostId$: childIdSplt[1],
  433. $nodeId$: childIdSplt[2],
  434. $depth$: childIdSplt[3],
  435. $index$: childIdSplt[4],
  436. $elm$: node,
  437. $attrs$: null,
  438. $children$: null,
  439. $key$: null,
  440. $name$: null,
  441. $tag$: null,
  442. $text$: null
  443. };
  444. if (childNodeType === TEXT_NODE_ID) {
  445. childVNode.$elm$ = node.nextSibling;
  446. if (childVNode.$elm$ && childVNode.$elm$.nodeType === 3 /* TextNode */) {
  447. childVNode.$text$ = childVNode.$elm$.textContent;
  448. childRenderNodes.push(childVNode);
  449. node.remove();
  450. if (!parentVNode.$children$) {
  451. parentVNode.$children$ = [];
  452. }
  453. parentVNode.$children$[childVNode.$index$] = childVNode;
  454. if (shadowRootNodes && childVNode.$depth$ === "0") {
  455. shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
  456. }
  457. }
  458. } else if (childVNode.$hostId$ === hostId) {
  459. if (childNodeType === SLOT_NODE_ID) {
  460. childVNode.$tag$ = "slot";
  461. if (childIdSplt[5]) {
  462. node["s-sn"] = childVNode.$name$ = childIdSplt[5];
  463. } else {
  464. node["s-sn"] = "";
  465. }
  466. node["s-sr"] = true;
  467. if (BUILD3.shadowDom && shadowRootNodes) {
  468. childVNode.$elm$ = doc.createElement(childVNode.$tag$);
  469. if (childVNode.$name$) {
  470. childVNode.$elm$.setAttribute("name", childVNode.$name$);
  471. }
  472. node.parentNode.insertBefore(childVNode.$elm$, node);
  473. node.remove();
  474. if (childVNode.$depth$ === "0") {
  475. shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
  476. }
  477. }
  478. slotNodes.push(childVNode);
  479. if (!parentVNode.$children$) {
  480. parentVNode.$children$ = [];
  481. }
  482. parentVNode.$children$[childVNode.$index$] = childVNode;
  483. } else if (childNodeType === CONTENT_REF_ID) {
  484. if (BUILD3.shadowDom && shadowRootNodes) {
  485. node.remove();
  486. } else if (BUILD3.slotRelocation) {
  487. hostElm["s-cr"] = node;
  488. node["s-cn"] = true;
  489. }
  490. }
  491. }
  492. }
  493. } else if (parentVNode && parentVNode.$tag$ === "style") {
  494. const vnode = newVNode(null, node.textContent);
  495. vnode.$elm$ = node;
  496. vnode.$index$ = "0";
  497. parentVNode.$children$ = [vnode];
  498. }
  499. };
  500. var initializeDocumentHydrate = (node, orgLocNodes) => {
  501. if (node.nodeType === 1 /* ElementNode */) {
  502. let i2 = 0;
  503. if (node.shadowRoot) {
  504. for (; i2 < node.shadowRoot.childNodes.length; i2++) {
  505. initializeDocumentHydrate(node.shadowRoot.childNodes[i2], orgLocNodes);
  506. }
  507. }
  508. for (i2 = 0; i2 < node.childNodes.length; i2++) {
  509. initializeDocumentHydrate(node.childNodes[i2], orgLocNodes);
  510. }
  511. } else if (node.nodeType === 8 /* CommentNode */) {
  512. const childIdSplt = node.nodeValue.split(".");
  513. if (childIdSplt[0] === ORG_LOCATION_ID) {
  514. orgLocNodes.set(childIdSplt[1] + "." + childIdSplt[2], node);
  515. node.nodeValue = "";
  516. node["s-en"] = childIdSplt[3];
  517. }
  518. }
  519. };
  520. // src/runtime/initialize-component.ts
  521. import { BUILD as BUILD14 } from "@stencil/core/internal/app-data";
  522. // src/runtime/mode.ts
  523. var computeMode = (elm) => modeResolutionChain.map((h2) => h2(elm)).find((m) => !!m);
  524. var setMode = (handler) => modeResolutionChain.push(handler);
  525. var getMode = (ref) => getHostRef(ref).$modeName$;
  526. // src/runtime/proxy-component.ts
  527. import { BUILD as BUILD13 } from "@stencil/core/internal/app-data";
  528. // src/runtime/set-value.ts
  529. import { BUILD as BUILD12 } from "@stencil/core/internal/app-data";
  530. // src/runtime/parse-property-value.ts
  531. import { BUILD as BUILD4 } from "@stencil/core/internal/app-data";
  532. var parsePropertyValue = (propValue, propType) => {
  533. if (propValue != null && !isComplexType(propValue)) {
  534. if (BUILD4.propBoolean && propType & 4 /* Boolean */) {
  535. return propValue === "false" ? false : propValue === "" || !!propValue;
  536. }
  537. if (BUILD4.propNumber && propType & 2 /* Number */) {
  538. return parseFloat(propValue);
  539. }
  540. if (BUILD4.propString && propType & 1 /* String */) {
  541. return String(propValue);
  542. }
  543. return propValue;
  544. }
  545. return propValue;
  546. };
  547. // src/runtime/update-component.ts
  548. import { BUILD as BUILD11, NAMESPACE } from "@stencil/core/internal/app-data";
  549. // src/runtime/event-emitter.ts
  550. import { BUILD as BUILD6 } from "@stencil/core/internal/app-data";
  551. // src/runtime/element.ts
  552. import { BUILD as BUILD5 } from "@stencil/core/internal/app-data";
  553. var getElement = (ref) => BUILD5.lazyLoad ? getHostRef(ref).$hostElement$ : ref;
  554. // src/runtime/event-emitter.ts
  555. var createEvent = (ref, name, flags) => {
  556. const elm = getElement(ref);
  557. return {
  558. emit: (detail) => {
  559. if (BUILD6.isDev && !elm.isConnected) {
  560. consoleDevWarn(`The "${name}" event was emitted, but the dispatcher node is no longer connected to the dom.`);
  561. }
  562. return emitEvent(elm, name, {
  563. bubbles: !!(flags & 4 /* Bubbles */),
  564. composed: !!(flags & 2 /* Composed */),
  565. cancelable: !!(flags & 1 /* Cancellable */),
  566. detail
  567. });
  568. }
  569. };
  570. };
  571. var emitEvent = (elm, name, opts) => {
  572. const ev = plt.ce(name, opts);
  573. elm.dispatchEvent(ev);
  574. return ev;
  575. };
  576. // src/runtime/styles.ts
  577. import { BUILD as BUILD7 } from "@stencil/core/internal/app-data";
  578. var rootAppliedStyles = /* @__PURE__ */ new WeakMap();
  579. var registerStyle = (scopeId2, cssText, allowCS) => {
  580. let style = styles.get(scopeId2);
  581. if (supportsConstructableStylesheets && allowCS) {
  582. style = style || new CSSStyleSheet();
  583. if (typeof style === "string") {
  584. style = cssText;
  585. } else {
  586. style.replaceSync(cssText);
  587. }
  588. } else {
  589. style = cssText;
  590. }
  591. styles.set(scopeId2, style);
  592. };
  593. var addStyle = (styleContainerNode, cmpMeta, mode) => {
  594. var _a;
  595. const scopeId2 = getScopeId(cmpMeta, mode);
  596. const style = styles.get(scopeId2);
  597. if (!BUILD7.attachStyles) {
  598. return scopeId2;
  599. }
  600. styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
  601. if (style) {
  602. if (typeof style === "string") {
  603. styleContainerNode = styleContainerNode.head || styleContainerNode;
  604. let appliedStyles = rootAppliedStyles.get(styleContainerNode);
  605. let styleElm;
  606. if (!appliedStyles) {
  607. rootAppliedStyles.set(styleContainerNode, appliedStyles = /* @__PURE__ */ new Set());
  608. }
  609. if (!appliedStyles.has(scopeId2)) {
  610. if (BUILD7.hydrateClientSide && styleContainerNode.host && (styleElm = styleContainerNode.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId2}"]`))) {
  611. styleElm.innerHTML = style;
  612. } else {
  613. styleElm = doc.createElement("style");
  614. styleElm.innerHTML = style;
  615. const nonce = (_a = plt.$nonce$) != null ? _a : queryNonceMetaTagContent(doc);
  616. if (nonce != null) {
  617. styleElm.setAttribute("nonce", nonce);
  618. }
  619. if ((BUILD7.hydrateServerSide || BUILD7.hotModuleReplacement) && cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
  620. styleElm.setAttribute(HYDRATED_STYLE_ID, scopeId2);
  621. }
  622. const injectStyle = (
  623. /**
  624. * we render a scoped component
  625. */
  626. !(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) || /**
  627. * we are using shadow dom and render the style tag within the shadowRoot
  628. */
  629. cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */ && styleContainerNode.nodeName !== "HEAD"
  630. );
  631. if (injectStyle) {
  632. styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector("link"));
  633. }
  634. }
  635. if (cmpMeta.$flags$ & 4 /* hasSlotRelocation */) {
  636. styleElm.innerHTML += SLOT_FB_CSS;
  637. }
  638. if (appliedStyles) {
  639. appliedStyles.add(scopeId2);
  640. }
  641. }
  642. } else if (BUILD7.constructableCSS && !styleContainerNode.adoptedStyleSheets.includes(style)) {
  643. styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
  644. }
  645. }
  646. return scopeId2;
  647. };
  648. var attachStyles = (hostRef) => {
  649. const cmpMeta = hostRef.$cmpMeta$;
  650. const elm = hostRef.$hostElement$;
  651. const flags = cmpMeta.$flags$;
  652. const endAttachStyles = createTime("attachStyles", cmpMeta.$tagName$);
  653. const scopeId2 = addStyle(
  654. BUILD7.shadowDom && supportsShadow && elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(),
  655. cmpMeta,
  656. hostRef.$modeName$
  657. );
  658. if ((BUILD7.shadowDom || BUILD7.scoped) && BUILD7.cssAnnotations && flags & 10 /* needsScopedEncapsulation */ && flags & 2 /* scopedCssEncapsulation */) {
  659. elm["s-sc"] = scopeId2;
  660. elm.classList.add(scopeId2 + "-h");
  661. if (BUILD7.scoped && flags & 2 /* scopedCssEncapsulation */) {
  662. elm.classList.add(scopeId2 + "-s");
  663. }
  664. }
  665. endAttachStyles();
  666. };
  667. var getScopeId = (cmp, mode) => "sc-" + (BUILD7.mode && mode && cmp.$flags$ & 32 /* hasMode */ ? cmp.$tagName$ + "-" + mode : cmp.$tagName$);
  668. // src/runtime/vdom/vdom-render.ts
  669. import { BUILD as BUILD10 } from "@stencil/core/internal/app-data";
  670. // src/runtime/vdom/update-element.ts
  671. import { BUILD as BUILD9 } from "@stencil/core/internal/app-data";
  672. // src/runtime/vdom/set-accessor.ts
  673. import { BUILD as BUILD8 } from "@stencil/core/internal/app-data";
  674. var setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
  675. if (oldValue !== newValue) {
  676. let isProp = isMemberInElement(elm, memberName);
  677. let ln = memberName.toLowerCase();
  678. if (BUILD8.vdomClass && memberName === "class") {
  679. const classList = elm.classList;
  680. const oldClasses = parseClassList(oldValue);
  681. const newClasses = parseClassList(newValue);
  682. classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
  683. classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
  684. } else if (BUILD8.vdomStyle && memberName === "style") {
  685. if (BUILD8.updatable) {
  686. for (const prop in oldValue) {
  687. if (!newValue || newValue[prop] == null) {
  688. if (!BUILD8.hydrateServerSide && prop.includes("-")) {
  689. elm.style.removeProperty(prop);
  690. } else {
  691. elm.style[prop] = "";
  692. }
  693. }
  694. }
  695. }
  696. for (const prop in newValue) {
  697. if (!oldValue || newValue[prop] !== oldValue[prop]) {
  698. if (!BUILD8.hydrateServerSide && prop.includes("-")) {
  699. elm.style.setProperty(prop, newValue[prop]);
  700. } else {
  701. elm.style[prop] = newValue[prop];
  702. }
  703. }
  704. }
  705. } else if (BUILD8.vdomKey && memberName === "key") {
  706. } else if (BUILD8.vdomRef && memberName === "ref") {
  707. if (newValue) {
  708. newValue(elm);
  709. }
  710. } else if (BUILD8.vdomListener && (BUILD8.lazyLoad ? !isProp : !elm.__lookupSetter__(memberName)) && memberName[0] === "o" && memberName[1] === "n") {
  711. if (memberName[2] === "-") {
  712. memberName = memberName.slice(3);
  713. } else if (isMemberInElement(win, ln)) {
  714. memberName = ln.slice(2);
  715. } else {
  716. memberName = ln[2] + memberName.slice(3);
  717. }
  718. if (oldValue || newValue) {
  719. const capture = memberName.endsWith(CAPTURE_EVENT_SUFFIX);
  720. memberName = memberName.replace(CAPTURE_EVENT_REGEX, "");
  721. if (oldValue) {
  722. plt.rel(elm, memberName, oldValue, capture);
  723. }
  724. if (newValue) {
  725. plt.ael(elm, memberName, newValue, capture);
  726. }
  727. }
  728. } else if (BUILD8.vdomPropOrAttr) {
  729. const isComplex = isComplexType(newValue);
  730. if ((isProp || isComplex && newValue !== null) && !isSvg) {
  731. try {
  732. if (!elm.tagName.includes("-")) {
  733. const n = newValue == null ? "" : newValue;
  734. if (memberName === "list") {
  735. isProp = false;
  736. } else if (oldValue == null || elm[memberName] != n) {
  737. elm[memberName] = n;
  738. }
  739. } else {
  740. elm[memberName] = newValue;
  741. }
  742. } catch (e) {
  743. }
  744. }
  745. let xlink = false;
  746. if (BUILD8.vdomXlink) {
  747. if (ln !== (ln = ln.replace(/^xlink\:?/, ""))) {
  748. memberName = ln;
  749. xlink = true;
  750. }
  751. }
  752. if (newValue == null || newValue === false) {
  753. if (newValue !== false || elm.getAttribute(memberName) === "") {
  754. if (BUILD8.vdomXlink && xlink) {
  755. elm.removeAttributeNS(XLINK_NS, memberName);
  756. } else {
  757. elm.removeAttribute(memberName);
  758. }
  759. }
  760. } else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
  761. newValue = newValue === true ? "" : newValue;
  762. if (BUILD8.vdomXlink && xlink) {
  763. elm.setAttributeNS(XLINK_NS, memberName, newValue);
  764. } else {
  765. elm.setAttribute(memberName, newValue);
  766. }
  767. }
  768. }
  769. }
  770. };
  771. var parseClassListRegex = /\s/;
  772. var parseClassList = (value) => !value ? [] : value.split(parseClassListRegex);
  773. var CAPTURE_EVENT_SUFFIX = "Capture";
  774. var CAPTURE_EVENT_REGEX = new RegExp(CAPTURE_EVENT_SUFFIX + "$");
  775. // src/runtime/vdom/update-element.ts
  776. var updateElement = (oldVnode, newVnode, isSvgMode2) => {
  777. const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host ? newVnode.$elm$.host : newVnode.$elm$;
  778. const oldVnodeAttrs = oldVnode && oldVnode.$attrs$ || EMPTY_OBJ;
  779. const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
  780. if (BUILD9.updatable) {
  781. for (const memberName of sortedAttrNames(Object.keys(oldVnodeAttrs))) {
  782. if (!(memberName in newVnodeAttrs)) {
  783. setAccessor(elm, memberName, oldVnodeAttrs[memberName], void 0, isSvgMode2, newVnode.$flags$);
  784. }
  785. }
  786. }
  787. for (const memberName of sortedAttrNames(Object.keys(newVnodeAttrs))) {
  788. setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode2, newVnode.$flags$);
  789. }
  790. };
  791. function sortedAttrNames(attrNames) {
  792. return attrNames.includes("ref") ? (
  793. // we need to sort these to ensure that `'ref'` is the last attr
  794. [...attrNames.filter((attr) => attr !== "ref"), "ref"]
  795. ) : (
  796. // no need to sort, return the original array
  797. attrNames
  798. );
  799. }
  800. // src/runtime/vdom/vdom-render.ts
  801. var scopeId;
  802. var contentRef;
  803. var hostTagName;
  804. var useNativeShadowDom = false;
  805. var checkSlotFallbackVisibility = false;
  806. var checkSlotRelocate = false;
  807. var isSvgMode = false;
  808. var createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
  809. var _a;
  810. const newVNode2 = newParentVNode.$children$[childIndex];
  811. let i2 = 0;
  812. let elm;
  813. let childNode;
  814. let oldVNode;
  815. if (BUILD10.slotRelocation && !useNativeShadowDom) {
  816. checkSlotRelocate = true;
  817. if (newVNode2.$tag$ === "slot") {
  818. if (scopeId) {
  819. parentElm.classList.add(scopeId + "-s");
  820. }
  821. newVNode2.$flags$ |= newVNode2.$children$ ? (
  822. // slot element has fallback content
  823. // still create an element that "mocks" the slot element
  824. 2 /* isSlotFallback */
  825. ) : (
  826. // slot element does not have fallback content
  827. // create an html comment we'll use to always reference
  828. // where actual slot content should sit next to
  829. 1 /* isSlotReference */
  830. );
  831. }
  832. }
  833. if (BUILD10.isDev && newVNode2.$elm$) {
  834. consoleDevError(
  835. `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`
  836. );
  837. }
  838. if (BUILD10.vdomText && newVNode2.$text$ !== null) {
  839. elm = newVNode2.$elm$ = doc.createTextNode(newVNode2.$text$);
  840. } else if (BUILD10.slotRelocation && newVNode2.$flags$ & 1 /* isSlotReference */) {
  841. elm = newVNode2.$elm$ = BUILD10.isDebug || BUILD10.hydrateServerSide ? slotReferenceDebugNode(newVNode2) : doc.createTextNode("");
  842. } else {
  843. if (BUILD10.svg && !isSvgMode) {
  844. isSvgMode = newVNode2.$tag$ === "svg";
  845. }
  846. elm = newVNode2.$elm$ = BUILD10.svg ? doc.createElementNS(
  847. isSvgMode ? SVG_NS : HTML_NS,
  848. !useNativeShadowDom && BUILD10.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
  849. ) : doc.createElement(
  850. !useNativeShadowDom && BUILD10.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
  851. );
  852. if (BUILD10.svg && isSvgMode && newVNode2.$tag$ === "foreignObject") {
  853. isSvgMode = false;
  854. }
  855. if (BUILD10.vdomAttribute) {
  856. updateElement(null, newVNode2, isSvgMode);
  857. }
  858. const rootNode = elm.getRootNode();
  859. const isElementWithinShadowRoot = !rootNode.querySelector("body");
  860. if (!isElementWithinShadowRoot && BUILD10.scoped && isDef(scopeId) && elm["s-si"] !== scopeId) {
  861. elm.classList.add(elm["s-si"] = scopeId);
  862. }
  863. if (BUILD10.scoped) {
  864. updateElementScopeIds(elm, parentElm);
  865. }
  866. if (newVNode2.$children$) {
  867. for (i2 = 0; i2 < newVNode2.$children$.length; ++i2) {
  868. childNode = createElm(oldParentVNode, newVNode2, i2, elm);
  869. if (childNode) {
  870. elm.appendChild(childNode);
  871. }
  872. }
  873. }
  874. if (BUILD10.svg) {
  875. if (newVNode2.$tag$ === "svg") {
  876. isSvgMode = false;
  877. } else if (elm.tagName === "foreignObject") {
  878. isSvgMode = true;
  879. }
  880. }
  881. }
  882. elm["s-hn"] = hostTagName;
  883. if (BUILD10.slotRelocation) {
  884. if (newVNode2.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
  885. elm["s-sr"] = true;
  886. elm["s-cr"] = contentRef;
  887. elm["s-sn"] = newVNode2.$name$ || "";
  888. elm["s-rf"] = (_a = newVNode2.$attrs$) == null ? void 0 : _a.ref;
  889. oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
  890. if (oldVNode && oldVNode.$tag$ === newVNode2.$tag$ && oldParentVNode.$elm$) {
  891. if (BUILD10.experimentalSlotFixes) {
  892. relocateToHostRoot(oldParentVNode.$elm$);
  893. } else {
  894. putBackInOriginalLocation(oldParentVNode.$elm$, false);
  895. }
  896. }
  897. }
  898. }
  899. return elm;
  900. };
  901. var relocateToHostRoot = (parentElm) => {
  902. plt.$flags$ |= 1 /* isTmpDisconnected */;
  903. const host = parentElm.closest(hostTagName.toLowerCase());
  904. if (host != null) {
  905. const contentRefNode = Array.from(host.childNodes).find((ref) => ref["s-cr"]);
  906. const childNodeArray = Array.from(parentElm.childNodes);
  907. for (const childNode of contentRefNode ? childNodeArray.reverse() : childNodeArray) {
  908. if (childNode["s-sh"] != null) {
  909. insertBefore(host, childNode, contentRefNode != null ? contentRefNode : null);
  910. childNode["s-sh"] = void 0;
  911. checkSlotRelocate = true;
  912. }
  913. }
  914. }
  915. plt.$flags$ &= ~1 /* isTmpDisconnected */;
  916. };
  917. var putBackInOriginalLocation = (parentElm, recursive) => {
  918. plt.$flags$ |= 1 /* isTmpDisconnected */;
  919. const oldSlotChildNodes = Array.from(parentElm.childNodes);
  920. if (parentElm["s-sr"] && BUILD10.experimentalSlotFixes) {
  921. let node = parentElm;
  922. while (node = node.nextSibling) {
  923. if (node && node["s-sn"] === parentElm["s-sn"] && node["s-sh"] === hostTagName) {
  924. oldSlotChildNodes.push(node);
  925. }
  926. }
  927. }
  928. for (let i2 = oldSlotChildNodes.length - 1; i2 >= 0; i2--) {
  929. const childNode = oldSlotChildNodes[i2];
  930. if (childNode["s-hn"] !== hostTagName && childNode["s-ol"]) {
  931. insertBefore(parentReferenceNode(childNode), childNode, referenceNode(childNode));
  932. childNode["s-ol"].remove();
  933. childNode["s-ol"] = void 0;
  934. childNode["s-sh"] = void 0;
  935. checkSlotRelocate = true;
  936. }
  937. if (recursive) {
  938. putBackInOriginalLocation(childNode, recursive);
  939. }
  940. }
  941. plt.$flags$ &= ~1 /* isTmpDisconnected */;
  942. };
  943. var addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
  944. let containerElm = BUILD10.slotRelocation && parentElm["s-cr"] && parentElm["s-cr"].parentNode || parentElm;
  945. let childNode;
  946. if (BUILD10.shadowDom && containerElm.shadowRoot && containerElm.tagName === hostTagName) {
  947. containerElm = containerElm.shadowRoot;
  948. }
  949. for (; startIdx <= endIdx; ++startIdx) {
  950. if (vnodes[startIdx]) {
  951. childNode = createElm(null, parentVNode, startIdx, parentElm);
  952. if (childNode) {
  953. vnodes[startIdx].$elm$ = childNode;
  954. insertBefore(containerElm, childNode, BUILD10.slotRelocation ? referenceNode(before) : before);
  955. }
  956. }
  957. }
  958. };
  959. var removeVnodes = (vnodes, startIdx, endIdx) => {
  960. for (let index = startIdx; index <= endIdx; ++index) {
  961. const vnode = vnodes[index];
  962. if (vnode) {
  963. const elm = vnode.$elm$;
  964. nullifyVNodeRefs(vnode);
  965. if (elm) {
  966. if (BUILD10.slotRelocation) {
  967. checkSlotFallbackVisibility = true;
  968. if (elm["s-ol"]) {
  969. elm["s-ol"].remove();
  970. } else {
  971. putBackInOriginalLocation(elm, true);
  972. }
  973. }
  974. elm.remove();
  975. }
  976. }
  977. }
  978. };
  979. var updateChildren = (parentElm, oldCh, newVNode2, newCh, isInitialRender = false) => {
  980. let oldStartIdx = 0;
  981. let newStartIdx = 0;
  982. let idxInOld = 0;
  983. let i2 = 0;
  984. let oldEndIdx = oldCh.length - 1;
  985. let oldStartVnode = oldCh[0];
  986. let oldEndVnode = oldCh[oldEndIdx];
  987. let newEndIdx = newCh.length - 1;
  988. let newStartVnode = newCh[0];
  989. let newEndVnode = newCh[newEndIdx];
  990. let node;
  991. let elmToMove;
  992. while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
  993. if (oldStartVnode == null) {
  994. oldStartVnode = oldCh[++oldStartIdx];
  995. } else if (oldEndVnode == null) {
  996. oldEndVnode = oldCh[--oldEndIdx];
  997. } else if (newStartVnode == null) {
  998. newStartVnode = newCh[++newStartIdx];
  999. } else if (newEndVnode == null) {
  1000. newEndVnode = newCh[--newEndIdx];
  1001. } else if (isSameVnode(oldStartVnode, newStartVnode, isInitialRender)) {
  1002. patch(oldStartVnode, newStartVnode, isInitialRender);
  1003. oldStartVnode = oldCh[++oldStartIdx];
  1004. newStartVnode = newCh[++newStartIdx];
  1005. } else if (isSameVnode(oldEndVnode, newEndVnode, isInitialRender)) {
  1006. patch(oldEndVnode, newEndVnode, isInitialRender);
  1007. oldEndVnode = oldCh[--oldEndIdx];
  1008. newEndVnode = newCh[--newEndIdx];
  1009. } else if (isSameVnode(oldStartVnode, newEndVnode, isInitialRender)) {
  1010. if (BUILD10.slotRelocation && (oldStartVnode.$tag$ === "slot" || newEndVnode.$tag$ === "slot")) {
  1011. putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
  1012. }
  1013. patch(oldStartVnode, newEndVnode, isInitialRender);
  1014. insertBefore(parentElm, oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
  1015. oldStartVnode = oldCh[++oldStartIdx];
  1016. newEndVnode = newCh[--newEndIdx];
  1017. } else if (isSameVnode(oldEndVnode, newStartVnode, isInitialRender)) {
  1018. if (BUILD10.slotRelocation && (oldStartVnode.$tag$ === "slot" || newEndVnode.$tag$ === "slot")) {
  1019. putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
  1020. }
  1021. patch(oldEndVnode, newStartVnode, isInitialRender);
  1022. insertBefore(parentElm, oldEndVnode.$elm$, oldStartVnode.$elm$);
  1023. oldEndVnode = oldCh[--oldEndIdx];
  1024. newStartVnode = newCh[++newStartIdx];
  1025. } else {
  1026. idxInOld = -1;
  1027. if (BUILD10.vdomKey) {
  1028. for (i2 = oldStartIdx; i2 <= oldEndIdx; ++i2) {
  1029. if (oldCh[i2] && oldCh[i2].$key$ !== null && oldCh[i2].$key$ === newStartVnode.$key$) {
  1030. idxInOld = i2;
  1031. break;
  1032. }
  1033. }
  1034. }
  1035. if (BUILD10.vdomKey && idxInOld >= 0) {
  1036. elmToMove = oldCh[idxInOld];
  1037. if (elmToMove.$tag$ !== newStartVnode.$tag$) {
  1038. node = createElm(oldCh && oldCh[newStartIdx], newVNode2, idxInOld, parentElm);
  1039. } else {
  1040. patch(elmToMove, newStartVnode, isInitialRender);
  1041. oldCh[idxInOld] = void 0;
  1042. node = elmToMove.$elm$;
  1043. }
  1044. newStartVnode = newCh[++newStartIdx];
  1045. } else {
  1046. node = createElm(oldCh && oldCh[newStartIdx], newVNode2, newStartIdx, parentElm);
  1047. newStartVnode = newCh[++newStartIdx];
  1048. }
  1049. if (node) {
  1050. if (BUILD10.slotRelocation) {
  1051. insertBefore(parentReferenceNode(oldStartVnode.$elm$), node, referenceNode(oldStartVnode.$elm$));
  1052. } else {
  1053. insertBefore(oldStartVnode.$elm$.parentNode, node, oldStartVnode.$elm$);
  1054. }
  1055. }
  1056. }
  1057. }
  1058. if (oldStartIdx > oldEndIdx) {
  1059. addVnodes(
  1060. parentElm,
  1061. newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$,
  1062. newVNode2,
  1063. newCh,
  1064. newStartIdx,
  1065. newEndIdx
  1066. );
  1067. } else if (BUILD10.updatable && newStartIdx > newEndIdx) {
  1068. removeVnodes(oldCh, oldStartIdx, oldEndIdx);
  1069. }
  1070. };
  1071. var isSameVnode = (leftVNode, rightVNode, isInitialRender = false) => {
  1072. if (leftVNode.$tag$ === rightVNode.$tag$) {
  1073. if (BUILD10.slotRelocation && leftVNode.$tag$ === "slot") {
  1074. if (
  1075. // The component gets hydrated and no VDOM has been initialized.
  1076. // Here the comparison can't happen as $name$ property is not set for `leftNode`.
  1077. "$nodeId$" in leftVNode && isInitialRender && // `leftNode` is not from type HTMLComment which would cause many
  1078. // hydration comments to be removed
  1079. leftVNode.$elm$.nodeType !== 8
  1080. ) {
  1081. return false;
  1082. }
  1083. return leftVNode.$name$ === rightVNode.$name$;
  1084. }
  1085. if (BUILD10.vdomKey && !isInitialRender) {
  1086. return leftVNode.$key$ === rightVNode.$key$;
  1087. }
  1088. return true;
  1089. }
  1090. return false;
  1091. };
  1092. var referenceNode = (node) => {
  1093. return node && node["s-ol"] || node;
  1094. };
  1095. var parentReferenceNode = (node) => (node["s-ol"] ? node["s-ol"] : node).parentNode;
  1096. var patch = (oldVNode, newVNode2, isInitialRender = false) => {
  1097. const elm = newVNode2.$elm$ = oldVNode.$elm$;
  1098. const oldChildren = oldVNode.$children$;
  1099. const newChildren = newVNode2.$children$;
  1100. const tag = newVNode2.$tag$;
  1101. const text = newVNode2.$text$;
  1102. let defaultHolder;
  1103. if (!BUILD10.vdomText || text === null) {
  1104. if (BUILD10.svg) {
  1105. isSvgMode = tag === "svg" ? true : tag === "foreignObject" ? false : isSvgMode;
  1106. }
  1107. if (BUILD10.vdomAttribute || BUILD10.reflect) {
  1108. if (BUILD10.slot && tag === "slot" && !useNativeShadowDom) {
  1109. if (BUILD10.experimentalSlotFixes && oldVNode.$name$ !== newVNode2.$name$) {
  1110. newVNode2.$elm$["s-sn"] = newVNode2.$name$ || "";
  1111. relocateToHostRoot(newVNode2.$elm$.parentElement);
  1112. }
  1113. } else {
  1114. updateElement(oldVNode, newVNode2, isSvgMode);
  1115. }
  1116. }
  1117. if (BUILD10.updatable && oldChildren !== null && newChildren !== null) {
  1118. updateChildren(elm, oldChildren, newVNode2, newChildren, isInitialRender);
  1119. } else if (newChildren !== null) {
  1120. if (BUILD10.updatable && BUILD10.vdomText && oldVNode.$text$ !== null) {
  1121. elm.textContent = "";
  1122. }
  1123. addVnodes(elm, null, newVNode2, newChildren, 0, newChildren.length - 1);
  1124. } else if (
  1125. // don't do this on initial render as it can cause non-hydrated content to be removed
  1126. !isInitialRender && BUILD10.updatable && oldChildren !== null
  1127. ) {
  1128. removeVnodes(oldChildren, 0, oldChildren.length - 1);
  1129. }
  1130. if (BUILD10.svg && isSvgMode && tag === "svg") {
  1131. isSvgMode = false;
  1132. }
  1133. } else if (BUILD10.vdomText && BUILD10.slotRelocation && (defaultHolder = elm["s-cr"])) {
  1134. defaultHolder.parentNode.textContent = text;
  1135. } else if (BUILD10.vdomText && oldVNode.$text$ !== text) {
  1136. elm.data = text;
  1137. }
  1138. };
  1139. var updateFallbackSlotVisibility = (elm) => {
  1140. const childNodes = elm.childNodes;
  1141. for (const childNode of childNodes) {
  1142. if (childNode.nodeType === 1 /* ElementNode */) {
  1143. if (childNode["s-sr"]) {
  1144. const slotName = childNode["s-sn"];
  1145. childNode.hidden = false;
  1146. for (const siblingNode of childNodes) {
  1147. if (siblingNode !== childNode) {
  1148. if (siblingNode["s-hn"] !== childNode["s-hn"] || slotName !== "") {
  1149. if (siblingNode.nodeType === 1 /* ElementNode */ && (slotName === siblingNode.getAttribute("slot") || slotName === siblingNode["s-sn"]) || siblingNode.nodeType === 3 /* TextNode */ && slotName === siblingNode["s-sn"]) {
  1150. childNode.hidden = true;
  1151. break;
  1152. }
  1153. } else {
  1154. if (siblingNode.nodeType === 1 /* ElementNode */ || siblingNode.nodeType === 3 /* TextNode */ && siblingNode.textContent.trim() !== "") {
  1155. childNode.hidden = true;
  1156. break;
  1157. }
  1158. }
  1159. }
  1160. }
  1161. }
  1162. updateFallbackSlotVisibility(childNode);
  1163. }
  1164. }
  1165. };
  1166. var relocateNodes = [];
  1167. var markSlotContentForRelocation = (elm) => {
  1168. let node;
  1169. let hostContentNodes;
  1170. let j;
  1171. for (const childNode of elm.childNodes) {
  1172. if (childNode["s-sr"] && (node = childNode["s-cr"]) && node.parentNode) {
  1173. hostContentNodes = node.parentNode.childNodes;
  1174. const slotName = childNode["s-sn"];
  1175. for (j = hostContentNodes.length - 1; j >= 0; j--) {
  1176. node = hostContentNodes[j];
  1177. if (!node["s-cn"] && !node["s-nr"] && node["s-hn"] !== childNode["s-hn"] && (!BUILD10.experimentalSlotFixes || !node["s-sh"] || node["s-sh"] !== childNode["s-hn"])) {
  1178. if (isNodeLocatedInSlot(node, slotName)) {
  1179. let relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
  1180. checkSlotFallbackVisibility = true;
  1181. node["s-sn"] = node["s-sn"] || slotName;
  1182. if (relocateNodeData) {
  1183. relocateNodeData.$nodeToRelocate$["s-sh"] = childNode["s-hn"];
  1184. relocateNodeData.$slotRefNode$ = childNode;
  1185. } else {
  1186. node["s-sh"] = childNode["s-hn"];
  1187. relocateNodes.push({
  1188. $slotRefNode$: childNode,
  1189. $nodeToRelocate$: node
  1190. });
  1191. }
  1192. if (node["s-sr"]) {
  1193. relocateNodes.map((relocateNode) => {
  1194. if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node["s-sn"])) {
  1195. relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
  1196. if (relocateNodeData && !relocateNode.$slotRefNode$) {
  1197. relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
  1198. }
  1199. }
  1200. });
  1201. }
  1202. } else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
  1203. relocateNodes.push({
  1204. $nodeToRelocate$: node
  1205. });
  1206. }
  1207. }
  1208. }
  1209. }
  1210. if (childNode.nodeType === 1 /* ElementNode */) {
  1211. markSlotContentForRelocation(childNode);
  1212. }
  1213. }
  1214. };
  1215. var isNodeLocatedInSlot = (nodeToRelocate, slotName) => {
  1216. if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
  1217. if (nodeToRelocate.getAttribute("slot") === null && slotName === "") {
  1218. return true;
  1219. }
  1220. if (nodeToRelocate.getAttribute("slot") === slotName) {
  1221. return true;
  1222. }
  1223. return false;
  1224. }
  1225. if (nodeToRelocate["s-sn"] === slotName) {
  1226. return true;
  1227. }
  1228. return slotName === "";
  1229. };
  1230. var nullifyVNodeRefs = (vNode) => {
  1231. if (BUILD10.vdomRef) {
  1232. vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
  1233. vNode.$children$ && vNode.$children$.map(nullifyVNodeRefs);
  1234. }
  1235. };
  1236. var insertBefore = (parent, newNode, reference) => {
  1237. const inserted = parent == null ? void 0 : parent.insertBefore(newNode, reference);
  1238. if (BUILD10.scoped) {
  1239. updateElementScopeIds(newNode, parent);
  1240. }
  1241. return inserted;
  1242. };
  1243. var findScopeIds = (element) => {
  1244. const scopeIds = [];
  1245. if (element) {
  1246. scopeIds.push(
  1247. ...element["s-scs"] || [],
  1248. element["s-si"],
  1249. element["s-sc"],
  1250. ...findScopeIds(element.parentElement)
  1251. );
  1252. }
  1253. return scopeIds;
  1254. };
  1255. var updateElementScopeIds = (element, parent, iterateChildNodes = false) => {
  1256. var _a;
  1257. if (element && parent && element.nodeType === 1 /* ElementNode */) {
  1258. const scopeIds = new Set(findScopeIds(parent).filter(Boolean));
  1259. if (scopeIds.size) {
  1260. (_a = element.classList) == null ? void 0 : _a.add(...element["s-scs"] = [...scopeIds]);
  1261. if (element["s-ol"] || iterateChildNodes) {
  1262. for (const childNode of Array.from(element.childNodes)) {
  1263. updateElementScopeIds(childNode, element, true);
  1264. }
  1265. }
  1266. }
  1267. }
  1268. };
  1269. var renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
  1270. var _a, _b, _c, _d, _e;
  1271. const hostElm = hostRef.$hostElement$;
  1272. const cmpMeta = hostRef.$cmpMeta$;
  1273. const oldVNode = hostRef.$vnode$ || newVNode(null, null);
  1274. const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
  1275. hostTagName = hostElm.tagName;
  1276. if (BUILD10.isDev && Array.isArray(renderFnResults) && renderFnResults.some(isHost)) {
  1277. throw new Error(`The <Host> must be the single root component.
  1278. Looks like the render() function of "${hostTagName.toLowerCase()}" is returning an array that contains the <Host>.
  1279. The render() function should look like this instead:
  1280. render() {
  1281. // Do not return an array
  1282. return (
  1283. <Host>{content}</Host>
  1284. );
  1285. }
  1286. `);
  1287. }
  1288. if (BUILD10.reflect && cmpMeta.$attrsToReflect$) {
  1289. rootVnode.$attrs$ = rootVnode.$attrs$ || {};
  1290. cmpMeta.$attrsToReflect$.map(
  1291. ([propName, attribute]) => rootVnode.$attrs$[attribute] = hostElm[propName]
  1292. );
  1293. }
  1294. if (isInitialLoad && rootVnode.$attrs$) {
  1295. for (const key of Object.keys(rootVnode.$attrs$)) {
  1296. if (hostElm.hasAttribute(key) && !["key", "ref", "style", "class"].includes(key)) {
  1297. rootVnode.$attrs$[key] = hostElm[key];
  1298. }
  1299. }
  1300. }
  1301. rootVnode.$tag$ = null;
  1302. rootVnode.$flags$ |= 4 /* isHost */;
  1303. hostRef.$vnode$ = rootVnode;
  1304. rootVnode.$elm$ = oldVNode.$elm$ = BUILD10.shadowDom ? hostElm.shadowRoot || hostElm : hostElm;
  1305. if (BUILD10.scoped || BUILD10.shadowDom) {
  1306. scopeId = hostElm["s-sc"];
  1307. }
  1308. useNativeShadowDom = supportsShadow && (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) !== 0;
  1309. if (BUILD10.slotRelocation) {
  1310. contentRef = hostElm["s-cr"];
  1311. checkSlotFallbackVisibility = false;
  1312. }
  1313. patch(oldVNode, rootVnode, isInitialLoad);
  1314. if (BUILD10.slotRelocation) {
  1315. plt.$flags$ |= 1 /* isTmpDisconnected */;
  1316. if (checkSlotRelocate) {
  1317. markSlotContentForRelocation(rootVnode.$elm$);
  1318. for (const relocateData of relocateNodes) {
  1319. const nodeToRelocate = relocateData.$nodeToRelocate$;
  1320. if (!nodeToRelocate["s-ol"]) {
  1321. const orgLocationNode = BUILD10.isDebug || BUILD10.hydrateServerSide ? originalLocationDebugNode(nodeToRelocate) : doc.createTextNode("");
  1322. orgLocationNode["s-nr"] = nodeToRelocate;
  1323. insertBefore(nodeToRelocate.parentNode, nodeToRelocate["s-ol"] = orgLocationNode, nodeToRelocate);
  1324. }
  1325. }
  1326. for (const relocateData of relocateNodes) {
  1327. const nodeToRelocate = relocateData.$nodeToRelocate$;
  1328. const slotRefNode = relocateData.$slotRefNode$;
  1329. if (slotRefNode) {
  1330. const parentNodeRef = slotRefNode.parentNode;
  1331. let insertBeforeNode = slotRefNode.nextSibling;
  1332. if (!BUILD10.experimentalSlotFixes || insertBeforeNode && insertBeforeNode.nodeType === 1 /* ElementNode */) {
  1333. let orgLocationNode = (_a = nodeToRelocate["s-ol"]) == null ? void 0 : _a.previousSibling;
  1334. while (orgLocationNode) {
  1335. let refNode = (_b = orgLocationNode["s-nr"]) != null ? _b : null;
  1336. if (refNode && refNode["s-sn"] === nodeToRelocate["s-sn"] && parentNodeRef === refNode.parentNode) {
  1337. refNode = refNode.nextSibling;
  1338. while (refNode === nodeToRelocate || (refNode == null ? void 0 : refNode["s-sr"])) {
  1339. refNode = refNode == null ? void 0 : refNode.nextSibling;
  1340. }
  1341. if (!refNode || !refNode["s-nr"]) {
  1342. insertBeforeNode = refNode;
  1343. break;
  1344. }
  1345. }
  1346. orgLocationNode = orgLocationNode.previousSibling;
  1347. }
  1348. }
  1349. if (!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode || nodeToRelocate.nextSibling !== insertBeforeNode) {
  1350. if (nodeToRelocate !== insertBeforeNode) {
  1351. if (!BUILD10.experimentalSlotFixes && !nodeToRelocate["s-hn"] && nodeToRelocate["s-ol"]) {
  1352. nodeToRelocate["s-hn"] = nodeToRelocate["s-ol"].parentNode.nodeName;
  1353. }
  1354. insertBefore(parentNodeRef, nodeToRelocate, insertBeforeNode);
  1355. if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
  1356. nodeToRelocate.hidden = (_c = nodeToRelocate["s-ih"]) != null ? _c : false;
  1357. }
  1358. }
  1359. }
  1360. nodeToRelocate && typeof slotRefNode["s-rf"] === "function" && slotRefNode["s-rf"](nodeToRelocate);
  1361. } else {
  1362. if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
  1363. if (isInitialLoad) {
  1364. nodeToRelocate["s-ih"] = (_d = nodeToRelocate.hidden) != null ? _d : false;
  1365. }
  1366. nodeToRelocate.hidden = true;
  1367. }
  1368. }
  1369. }
  1370. }
  1371. if (checkSlotFallbackVisibility) {
  1372. updateFallbackSlotVisibility(rootVnode.$elm$);
  1373. }
  1374. plt.$flags$ &= ~1 /* isTmpDisconnected */;
  1375. relocateNodes.length = 0;
  1376. }
  1377. if (BUILD10.experimentalScopedSlotChanges && cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
  1378. for (const childNode of rootVnode.$elm$.childNodes) {
  1379. if (childNode["s-hn"] !== hostTagName && !childNode["s-sh"]) {
  1380. if (isInitialLoad && childNode["s-ih"] == null) {
  1381. childNode["s-ih"] = (_e = childNode.hidden) != null ? _e : false;
  1382. }
  1383. childNode.hidden = true;
  1384. }
  1385. }
  1386. }
  1387. contentRef = void 0;
  1388. };
  1389. var slotReferenceDebugNode = (slotVNode) => doc.createComment(
  1390. `<slot${slotVNode.$name$ ? ' name="' + slotVNode.$name$ + '"' : ""}> (host=${hostTagName.toLowerCase()})`
  1391. );
  1392. var originalLocationDebugNode = (nodeToRelocate) => doc.createComment(
  1393. `org-location for ` + (nodeToRelocate.localName ? `<${nodeToRelocate.localName}> (host=${nodeToRelocate["s-hn"]})` : `[${nodeToRelocate.textContent}]`)
  1394. );
  1395. // src/runtime/update-component.ts
  1396. var attachToAncestor = (hostRef, ancestorComponent) => {
  1397. if (BUILD11.asyncLoading && ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent["s-p"]) {
  1398. ancestorComponent["s-p"].push(new Promise((r) => hostRef.$onRenderResolve$ = r));
  1399. }
  1400. };
  1401. var scheduleUpdate = (hostRef, isInitialLoad) => {
  1402. if (BUILD11.taskQueue && BUILD11.updatable) {
  1403. hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
  1404. }
  1405. if (BUILD11.asyncLoading && hostRef.$flags$ & 4 /* isWaitingForChildren */) {
  1406. hostRef.$flags$ |= 512 /* needsRerender */;
  1407. return;
  1408. }
  1409. attachToAncestor(hostRef, hostRef.$ancestorComponent$);
  1410. const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
  1411. return BUILD11.taskQueue ? writeTask(dispatch) : dispatch();
  1412. };
  1413. var dispatchHooks = (hostRef, isInitialLoad) => {
  1414. const elm = hostRef.$hostElement$;
  1415. const endSchedule = createTime("scheduleUpdate", hostRef.$cmpMeta$.$tagName$);
  1416. const instance = BUILD11.lazyLoad ? hostRef.$lazyInstance$ : elm;
  1417. if (!instance) {
  1418. throw new Error(
  1419. `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`
  1420. );
  1421. }
  1422. let maybePromise;
  1423. if (isInitialLoad) {
  1424. if (BUILD11.lazyLoad && BUILD11.hostListener) {
  1425. hostRef.$flags$ |= 256 /* isListenReady */;
  1426. if (hostRef.$queuedListeners$) {
  1427. hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
  1428. hostRef.$queuedListeners$ = void 0;
  1429. }
  1430. }
  1431. emitLifecycleEvent(elm, "componentWillLoad");
  1432. if (BUILD11.cmpWillLoad) {
  1433. maybePromise = safeCall(instance, "componentWillLoad");
  1434. }
  1435. } else {
  1436. emitLifecycleEvent(elm, "componentWillUpdate");
  1437. if (BUILD11.cmpWillUpdate) {
  1438. maybePromise = safeCall(instance, "componentWillUpdate");
  1439. }
  1440. }
  1441. emitLifecycleEvent(elm, "componentWillRender");
  1442. if (BUILD11.cmpWillRender) {
  1443. maybePromise = enqueue(maybePromise, () => safeCall(instance, "componentWillRender"));
  1444. }
  1445. endSchedule();
  1446. return enqueue(maybePromise, () => updateComponent(hostRef, instance, isInitialLoad));
  1447. };
  1448. var enqueue = (maybePromise, fn) => isPromisey(maybePromise) ? maybePromise.then(fn).catch((err2) => {
  1449. console.error(err2);
  1450. fn();
  1451. }) : fn();
  1452. var isPromisey = (maybePromise) => maybePromise instanceof Promise || maybePromise && maybePromise.then && typeof maybePromise.then === "function";
  1453. var updateComponent = async (hostRef, instance, isInitialLoad) => {
  1454. var _a;
  1455. const elm = hostRef.$hostElement$;
  1456. const endUpdate = createTime("update", hostRef.$cmpMeta$.$tagName$);
  1457. const rc = elm["s-rc"];
  1458. if (BUILD11.style && isInitialLoad) {
  1459. attachStyles(hostRef);
  1460. }
  1461. const endRender = createTime("render", hostRef.$cmpMeta$.$tagName$);
  1462. if (BUILD11.isDev) {
  1463. hostRef.$flags$ |= 1024 /* devOnRender */;
  1464. }
  1465. if (BUILD11.hydrateServerSide) {
  1466. await callRender(hostRef, instance, elm, isInitialLoad);
  1467. } else {
  1468. callRender(hostRef, instance, elm, isInitialLoad);
  1469. }
  1470. if (BUILD11.isDev) {
  1471. hostRef.$renderCount$ = hostRef.$renderCount$ === void 0 ? 1 : hostRef.$renderCount$ + 1;
  1472. hostRef.$flags$ &= ~1024 /* devOnRender */;
  1473. }
  1474. if (BUILD11.hydrateServerSide) {
  1475. try {
  1476. serverSideConnected(elm);
  1477. if (isInitialLoad) {
  1478. if (hostRef.$cmpMeta$.$flags$ & 1 /* shadowDomEncapsulation */) {
  1479. elm["s-en"] = "";
  1480. } else if (hostRef.$cmpMeta$.$flags$ & 2 /* scopedCssEncapsulation */) {
  1481. elm["s-en"] = "c";
  1482. }
  1483. }
  1484. } catch (e) {
  1485. consoleError(e, elm);
  1486. }
  1487. }
  1488. if (BUILD11.asyncLoading && rc) {
  1489. rc.map((cb) => cb());
  1490. elm["s-rc"] = void 0;
  1491. }
  1492. endRender();
  1493. endUpdate();
  1494. if (BUILD11.asyncLoading) {
  1495. const childrenPromises = (_a = elm["s-p"]) != null ? _a : [];
  1496. const postUpdate = () => postUpdateComponent(hostRef);
  1497. if (childrenPromises.length === 0) {
  1498. postUpdate();
  1499. } else {
  1500. Promise.all(childrenPromises).then(postUpdate);
  1501. hostRef.$flags$ |= 4 /* isWaitingForChildren */;
  1502. childrenPromises.length = 0;
  1503. }
  1504. } else {
  1505. postUpdateComponent(hostRef);
  1506. }
  1507. };
  1508. var renderingRef = null;
  1509. var callRender = (hostRef, instance, elm, isInitialLoad) => {
  1510. const allRenderFn = BUILD11.allRenderFn ? true : false;
  1511. const lazyLoad = BUILD11.lazyLoad ? true : false;
  1512. const taskQueue = BUILD11.taskQueue ? true : false;
  1513. const updatable = BUILD11.updatable ? true : false;
  1514. try {
  1515. renderingRef = instance;
  1516. instance = allRenderFn ? instance.render() : instance.render && instance.render();
  1517. if (updatable && taskQueue) {
  1518. hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
  1519. }
  1520. if (updatable || lazyLoad) {
  1521. hostRef.$flags$ |= 2 /* hasRendered */;
  1522. }
  1523. if (BUILD11.hasRenderFn || BUILD11.reflect) {
  1524. if (BUILD11.vdomRender || BUILD11.reflect) {
  1525. if (BUILD11.hydrateServerSide) {
  1526. return Promise.resolve(instance).then((value) => renderVdom(hostRef, value, isInitialLoad));
  1527. } else {
  1528. renderVdom(hostRef, instance, isInitialLoad);
  1529. }
  1530. } else {
  1531. const shadowRoot = elm.shadowRoot;
  1532. if (hostRef.$cmpMeta$.$flags$ & 1 /* shadowDomEncapsulation */) {
  1533. shadowRoot.textContent = instance;
  1534. } else {
  1535. elm.textContent = instance;
  1536. }
  1537. }
  1538. }
  1539. } catch (e) {
  1540. consoleError(e, hostRef.$hostElement$);
  1541. }
  1542. renderingRef = null;
  1543. return null;
  1544. };
  1545. var getRenderingRef = () => renderingRef;
  1546. var postUpdateComponent = (hostRef) => {
  1547. const tagName = hostRef.$cmpMeta$.$tagName$;
  1548. const elm = hostRef.$hostElement$;
  1549. const endPostUpdate = createTime("postUpdate", tagName);
  1550. const instance = BUILD11.lazyLoad ? hostRef.$lazyInstance$ : elm;
  1551. const ancestorComponent = hostRef.$ancestorComponent$;
  1552. if (BUILD11.cmpDidRender) {
  1553. if (BUILD11.isDev) {
  1554. hostRef.$flags$ |= 1024 /* devOnRender */;
  1555. }
  1556. safeCall(instance, "componentDidRender");
  1557. if (BUILD11.isDev) {
  1558. hostRef.$flags$ &= ~1024 /* devOnRender */;
  1559. }
  1560. }
  1561. emitLifecycleEvent(elm, "componentDidRender");
  1562. if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
  1563. hostRef.$flags$ |= 64 /* hasLoadedComponent */;
  1564. if (BUILD11.asyncLoading && BUILD11.cssAnnotations) {
  1565. addHydratedFlag(elm);
  1566. }
  1567. if (BUILD11.cmpDidLoad) {
  1568. if (BUILD11.isDev) {
  1569. hostRef.$flags$ |= 2048 /* devOnDidLoad */;
  1570. }
  1571. safeCall(instance, "componentDidLoad");
  1572. if (BUILD11.isDev) {
  1573. hostRef.$flags$ &= ~2048 /* devOnDidLoad */;
  1574. }
  1575. }
  1576. emitLifecycleEvent(elm, "componentDidLoad");
  1577. endPostUpdate();
  1578. if (BUILD11.asyncLoading) {
  1579. hostRef.$onReadyResolve$(elm);
  1580. if (!ancestorComponent) {
  1581. appDidLoad(tagName);
  1582. }
  1583. }
  1584. } else {
  1585. if (BUILD11.cmpDidUpdate) {
  1586. if (BUILD11.isDev) {
  1587. hostRef.$flags$ |= 1024 /* devOnRender */;
  1588. }
  1589. safeCall(instance, "componentDidUpdate");
  1590. if (BUILD11.isDev) {
  1591. hostRef.$flags$ &= ~1024 /* devOnRender */;
  1592. }
  1593. }
  1594. emitLifecycleEvent(elm, "componentDidUpdate");
  1595. endPostUpdate();
  1596. }
  1597. if (BUILD11.method && BUILD11.lazyLoad) {
  1598. hostRef.$onInstanceResolve$(elm);
  1599. }
  1600. if (BUILD11.asyncLoading) {
  1601. if (hostRef.$onRenderResolve$) {
  1602. hostRef.$onRenderResolve$();
  1603. hostRef.$onRenderResolve$ = void 0;
  1604. }
  1605. if (hostRef.$flags$ & 512 /* needsRerender */) {
  1606. nextTick(() => scheduleUpdate(hostRef, false));
  1607. }
  1608. hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
  1609. }
  1610. };
  1611. var forceUpdate = (ref) => {
  1612. if (BUILD11.updatable && (Build.isBrowser || Build.isTesting)) {
  1613. const hostRef = getHostRef(ref);
  1614. const isConnected = hostRef.$hostElement$.isConnected;
  1615. if (isConnected && (hostRef.$flags$ & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
  1616. scheduleUpdate(hostRef, false);
  1617. }
  1618. return isConnected;
  1619. }
  1620. return false;
  1621. };
  1622. var appDidLoad = (who) => {
  1623. if (BUILD11.cssAnnotations) {
  1624. addHydratedFlag(doc.documentElement);
  1625. }
  1626. if (BUILD11.asyncQueue) {
  1627. plt.$flags$ |= 2 /* appLoaded */;
  1628. }
  1629. nextTick(() => emitEvent(win, "appload", { detail: { namespace: NAMESPACE } }));
  1630. if (BUILD11.profile && performance.measure) {
  1631. performance.measure(`[Stencil] ${NAMESPACE} initial load (by ${who})`, "st:app:start");
  1632. }
  1633. };
  1634. var safeCall = (instance, method, arg) => {
  1635. if (instance && instance[method]) {
  1636. try {
  1637. return instance[method](arg);
  1638. } catch (e) {
  1639. consoleError(e);
  1640. }
  1641. }
  1642. return void 0;
  1643. };
  1644. var emitLifecycleEvent = (elm, lifecycleName) => {
  1645. if (BUILD11.lifecycleDOMEvents) {
  1646. emitEvent(elm, "stencil_" + lifecycleName, {
  1647. bubbles: true,
  1648. composed: true,
  1649. detail: {
  1650. namespace: NAMESPACE
  1651. }
  1652. });
  1653. }
  1654. };
  1655. var addHydratedFlag = (elm) => {
  1656. var _a, _b;
  1657. return BUILD11.hydratedClass ? elm.classList.add((_a = BUILD11.hydratedSelectorName) != null ? _a : "hydrated") : BUILD11.hydratedAttribute ? elm.setAttribute((_b = BUILD11.hydratedSelectorName) != null ? _b : "hydrated", "") : void 0;
  1658. };
  1659. var serverSideConnected = (elm) => {
  1660. const children = elm.children;
  1661. if (children != null) {
  1662. for (let i2 = 0, ii = children.length; i2 < ii; i2++) {
  1663. const childElm = children[i2];
  1664. if (typeof childElm.connectedCallback === "function") {
  1665. childElm.connectedCallback();
  1666. }
  1667. serverSideConnected(childElm);
  1668. }
  1669. }
  1670. };
  1671. // src/runtime/set-value.ts
  1672. var getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
  1673. var setValue = (ref, propName, newVal, cmpMeta) => {
  1674. const hostRef = getHostRef(ref);
  1675. if (BUILD12.lazyLoad && !hostRef) {
  1676. throw new Error(
  1677. `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).`
  1678. );
  1679. }
  1680. const elm = BUILD12.lazyLoad ? hostRef.$hostElement$ : ref;
  1681. const oldVal = hostRef.$instanceValues$.get(propName);
  1682. const flags = hostRef.$flags$;
  1683. const instance = BUILD12.lazyLoad ? hostRef.$lazyInstance$ : elm;
  1684. newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
  1685. const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
  1686. const didValueChange = newVal !== oldVal && !areBothNaN;
  1687. if ((!BUILD12.lazyLoad || !(flags & 8 /* isConstructingInstance */) || oldVal === void 0) && didValueChange) {
  1688. hostRef.$instanceValues$.set(propName, newVal);
  1689. if (BUILD12.isDev) {
  1690. if (hostRef.$flags$ & 1024 /* devOnRender */) {
  1691. consoleDevWarn(
  1692. `The state/prop "${propName}" changed during rendering. This can potentially lead to infinite-loops and other bugs.`,
  1693. "\nElement",
  1694. elm,
  1695. "\nNew value",
  1696. newVal,
  1697. "\nOld value",
  1698. oldVal
  1699. );
  1700. } else if (hostRef.$flags$ & 2048 /* devOnDidLoad */) {
  1701. consoleDevWarn(
  1702. `The state/prop "${propName}" changed during "componentDidLoad()", this triggers extra re-renders, try to setup on "componentWillLoad()"`,
  1703. "\nElement",
  1704. elm,
  1705. "\nNew value",
  1706. newVal,
  1707. "\nOld value",
  1708. oldVal
  1709. );
  1710. }
  1711. }
  1712. if (!BUILD12.lazyLoad || instance) {
  1713. if (BUILD12.watchCallback && cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
  1714. const watchMethods = cmpMeta.$watchers$[propName];
  1715. if (watchMethods) {
  1716. watchMethods.map((watchMethodName) => {
  1717. try {
  1718. instance[watchMethodName](newVal, oldVal, propName);
  1719. } catch (e) {
  1720. consoleError(e, elm);
  1721. }
  1722. });
  1723. }
  1724. }
  1725. if (BUILD12.updatable && (flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
  1726. if (BUILD12.cmpShouldUpdate && instance.componentShouldUpdate) {
  1727. if (instance.componentShouldUpdate(newVal, oldVal, propName) === false) {
  1728. return;
  1729. }
  1730. }
  1731. scheduleUpdate(hostRef, false);
  1732. }
  1733. }
  1734. }
  1735. };
  1736. // src/runtime/proxy-component.ts
  1737. var proxyComponent = (Cstr, cmpMeta, flags) => {
  1738. var _a, _b;
  1739. const prototype = Cstr.prototype;
  1740. if (BUILD13.formAssociated && cmpMeta.$flags$ & 64 /* formAssociated */ && flags & 1 /* isElementConstructor */) {
  1741. FORM_ASSOCIATED_CUSTOM_ELEMENT_CALLBACKS.forEach(
  1742. (cbName) => Object.defineProperty(prototype, cbName, {
  1743. value(...args) {
  1744. const hostRef = getHostRef(this);
  1745. const elm = BUILD13.lazyLoad ? hostRef.$hostElement$ : this;
  1746. const instance = BUILD13.lazyLoad ? hostRef.$lazyInstance$ : elm;
  1747. if (!instance) {
  1748. hostRef.$onReadyPromise$.then((instance2) => {
  1749. const cb = instance2[cbName];
  1750. typeof cb === "function" && cb.call(instance2, ...args);
  1751. });
  1752. } else {
  1753. const cb = instance[cbName];
  1754. typeof cb === "function" && cb.call(instance, ...args);
  1755. }
  1756. }
  1757. })
  1758. );
  1759. }
  1760. if (BUILD13.member && cmpMeta.$members$ || BUILD13.watchCallback && (cmpMeta.$watchers$ || Cstr.watchers)) {
  1761. if (BUILD13.watchCallback && Cstr.watchers && !cmpMeta.$watchers$) {
  1762. cmpMeta.$watchers$ = Cstr.watchers;
  1763. }
  1764. const members = Object.entries((_a = cmpMeta.$members$) != null ? _a : {});
  1765. members.map(([memberName, [memberFlags]]) => {
  1766. if ((BUILD13.prop || BUILD13.state) && (memberFlags & 31 /* Prop */ || (!BUILD13.lazyLoad || flags & 2 /* proxyState */) && memberFlags & 32 /* State */)) {
  1767. Object.defineProperty(prototype, memberName, {
  1768. get() {
  1769. return getValue(this, memberName);
  1770. },
  1771. set(newValue) {
  1772. if (BUILD13.isDev) {
  1773. const ref = getHostRef(this);
  1774. if (
  1775. // we are proxying the instance (not element)
  1776. (flags & 1 /* isElementConstructor */) === 0 && // the element is not constructing
  1777. (ref && ref.$flags$ & 8 /* isConstructingInstance */) === 0 && // the member is a prop
  1778. (memberFlags & 31 /* Prop */) !== 0 && // the member is not mutable
  1779. (memberFlags & 1024 /* Mutable */) === 0
  1780. ) {
  1781. consoleDevWarn(
  1782. `@Prop() "${memberName}" on <${cmpMeta.$tagName$}> is immutable but was modified from within the component.
  1783. More information: https://stenciljs.com/docs/properties#prop-mutability`
  1784. );
  1785. }
  1786. }
  1787. setValue(this, memberName, newValue, cmpMeta);
  1788. },
  1789. configurable: true,
  1790. enumerable: true
  1791. });
  1792. } else if (BUILD13.lazyLoad && BUILD13.method && flags & 1 /* isElementConstructor */ && memberFlags & 64 /* Method */) {
  1793. Object.defineProperty(prototype, memberName, {
  1794. value(...args) {
  1795. var _a2;
  1796. const ref = getHostRef(this);
  1797. return (_a2 = ref == null ? void 0 : ref.$onInstancePromise$) == null ? void 0 : _a2.then(() => {
  1798. var _a3;
  1799. return (_a3 = ref.$lazyInstance$) == null ? void 0 : _a3[memberName](...args);
  1800. });
  1801. }
  1802. });
  1803. }
  1804. });
  1805. if (BUILD13.observeAttribute && (!BUILD13.lazyLoad || flags & 1 /* isElementConstructor */)) {
  1806. const attrNameToPropName = /* @__PURE__ */ new Map();
  1807. prototype.attributeChangedCallback = function(attrName, oldValue, newValue) {
  1808. plt.jmp(() => {
  1809. var _a2;
  1810. const propName = attrNameToPropName.get(attrName);
  1811. if (this.hasOwnProperty(propName)) {
  1812. newValue = this[propName];
  1813. delete this[propName];
  1814. } else if (prototype.hasOwnProperty(propName) && typeof this[propName] === "number" && // cast type to number to avoid TS compiler issues
  1815. this[propName] == newValue) {
  1816. return;
  1817. } else if (propName == null) {
  1818. const hostRef = getHostRef(this);
  1819. const flags2 = hostRef == null ? void 0 : hostRef.$flags$;
  1820. if (flags2 && !(flags2 & 8 /* isConstructingInstance */) && flags2 & 128 /* isWatchReady */ && newValue !== oldValue) {
  1821. const elm = BUILD13.lazyLoad ? hostRef.$hostElement$ : this;
  1822. const instance = BUILD13.lazyLoad ? hostRef.$lazyInstance$ : elm;
  1823. const entry = (_a2 = cmpMeta.$watchers$) == null ? void 0 : _a2[attrName];
  1824. entry == null ? void 0 : entry.forEach((callbackName) => {
  1825. if (instance[callbackName] != null) {
  1826. instance[callbackName].call(instance, newValue, oldValue, attrName);
  1827. }
  1828. });
  1829. }
  1830. return;
  1831. }
  1832. this[propName] = newValue === null && typeof this[propName] === "boolean" ? false : newValue;
  1833. });
  1834. };
  1835. Cstr.observedAttributes = Array.from(
  1836. /* @__PURE__ */ new Set([
  1837. ...Object.keys((_b = cmpMeta.$watchers$) != null ? _b : {}),
  1838. ...members.filter(([_, m]) => m[0] & 15 /* HasAttribute */).map(([propName, m]) => {
  1839. var _a2;
  1840. const attrName = m[1] || propName;
  1841. attrNameToPropName.set(attrName, propName);
  1842. if (BUILD13.reflect && m[0] & 512 /* ReflectAttr */) {
  1843. (_a2 = cmpMeta.$attrsToReflect$) == null ? void 0 : _a2.push([propName, attrName]);
  1844. }
  1845. return attrName;
  1846. })
  1847. ])
  1848. );
  1849. }
  1850. }
  1851. return Cstr;
  1852. };
  1853. // src/runtime/initialize-component.ts
  1854. var initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
  1855. let Cstr;
  1856. if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
  1857. hostRef.$flags$ |= 32 /* hasInitializedComponent */;
  1858. const bundleId = cmpMeta.$lazyBundleId$;
  1859. if ((BUILD14.lazyLoad || BUILD14.hydrateClientSide) && bundleId) {
  1860. const CstrImport = loadModule(cmpMeta, hostRef, hmrVersionId);
  1861. if (CstrImport && "then" in CstrImport) {
  1862. const endLoad = uniqueTime(
  1863. `st:load:${cmpMeta.$tagName$}:${hostRef.$modeName$}`,
  1864. `[Stencil] Load module for <${cmpMeta.$tagName$}>`
  1865. );
  1866. Cstr = await CstrImport;
  1867. endLoad();
  1868. } else {
  1869. Cstr = CstrImport;
  1870. }
  1871. if (!Cstr) {
  1872. throw new Error(`Constructor for "${cmpMeta.$tagName$}#${hostRef.$modeName$}" was not found`);
  1873. }
  1874. if (BUILD14.member && !Cstr.isProxied) {
  1875. if (BUILD14.watchCallback) {
  1876. cmpMeta.$watchers$ = Cstr.watchers;
  1877. }
  1878. proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
  1879. Cstr.isProxied = true;
  1880. }
  1881. const endNewInstance = createTime("createInstance", cmpMeta.$tagName$);
  1882. if (BUILD14.member) {
  1883. hostRef.$flags$ |= 8 /* isConstructingInstance */;
  1884. }
  1885. try {
  1886. new Cstr(hostRef);
  1887. } catch (e) {
  1888. consoleError(e);
  1889. }
  1890. if (BUILD14.member) {
  1891. hostRef.$flags$ &= ~8 /* isConstructingInstance */;
  1892. }
  1893. if (BUILD14.watchCallback) {
  1894. hostRef.$flags$ |= 128 /* isWatchReady */;
  1895. }
  1896. endNewInstance();
  1897. fireConnectedCallback(hostRef.$lazyInstance$);
  1898. } else {
  1899. Cstr = elm.constructor;
  1900. const cmpTag = elm.localName;
  1901. customElements.whenDefined(cmpTag).then(() => hostRef.$flags$ |= 128 /* isWatchReady */);
  1902. }
  1903. if (BUILD14.style && Cstr && Cstr.style) {
  1904. let style;
  1905. if (typeof Cstr.style === "string") {
  1906. style = Cstr.style;
  1907. } else if (BUILD14.mode && typeof Cstr.style !== "string") {
  1908. hostRef.$modeName$ = computeMode(elm);
  1909. if (hostRef.$modeName$) {
  1910. style = Cstr.style[hostRef.$modeName$];
  1911. }
  1912. if (BUILD14.hydrateServerSide && hostRef.$modeName$) {
  1913. elm.setAttribute("s-mode", hostRef.$modeName$);
  1914. }
  1915. }
  1916. const scopeId2 = getScopeId(cmpMeta, hostRef.$modeName$);
  1917. if (!styles.has(scopeId2)) {
  1918. const endRegisterStyles = createTime("registerStyles", cmpMeta.$tagName$);
  1919. if (!BUILD14.hydrateServerSide && BUILD14.shadowDom && // TODO(STENCIL-854): Remove code related to legacy shadowDomShim field
  1920. BUILD14.shadowDomShim && cmpMeta.$flags$ & 8 /* needsShadowDomShim */) {
  1921. style = await import("../client/shadow-css.js").then((m) => m.scopeCss(style, scopeId2));
  1922. }
  1923. registerStyle(scopeId2, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
  1924. endRegisterStyles();
  1925. }
  1926. }
  1927. }
  1928. const ancestorComponent = hostRef.$ancestorComponent$;
  1929. const schedule = () => scheduleUpdate(hostRef, true);
  1930. if (BUILD14.asyncLoading && ancestorComponent && ancestorComponent["s-rc"]) {
  1931. ancestorComponent["s-rc"].push(schedule);
  1932. } else {
  1933. schedule();
  1934. }
  1935. };
  1936. var fireConnectedCallback = (instance) => {
  1937. if (BUILD14.lazyLoad && BUILD14.connectedCallback) {
  1938. safeCall(instance, "connectedCallback");
  1939. }
  1940. };
  1941. // src/runtime/connected-callback.ts
  1942. var connectedCallback = (elm) => {
  1943. if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
  1944. const hostRef = getHostRef(elm);
  1945. const cmpMeta = hostRef.$cmpMeta$;
  1946. const endConnected = createTime("connectedCallback", cmpMeta.$tagName$);
  1947. if (BUILD15.hostListenerTargetParent) {
  1948. addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, true);
  1949. }
  1950. if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
  1951. hostRef.$flags$ |= 1 /* hasConnected */;
  1952. let hostId;
  1953. if (BUILD15.hydrateClientSide) {
  1954. hostId = elm.getAttribute(HYDRATE_ID);
  1955. if (hostId) {
  1956. if (BUILD15.shadowDom && supportsShadow && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
  1957. const scopeId2 = BUILD15.mode ? addStyle(elm.shadowRoot, cmpMeta, elm.getAttribute("s-mode")) : addStyle(elm.shadowRoot, cmpMeta);
  1958. elm.classList.remove(scopeId2 + "-h", scopeId2 + "-s");
  1959. }
  1960. initializeClientHydrate(elm, cmpMeta.$tagName$, hostId, hostRef);
  1961. }
  1962. }
  1963. if (BUILD15.slotRelocation && !hostId) {
  1964. if (BUILD15.hydrateServerSide || (BUILD15.slot || BUILD15.shadowDom) && // TODO(STENCIL-854): Remove code related to legacy shadowDomShim field
  1965. cmpMeta.$flags$ & (4 /* hasSlotRelocation */ | 8 /* needsShadowDomShim */)) {
  1966. setContentReference(elm);
  1967. }
  1968. }
  1969. if (BUILD15.asyncLoading) {
  1970. let ancestorComponent = elm;
  1971. while (ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host) {
  1972. if (BUILD15.hydrateClientSide && ancestorComponent.nodeType === 1 /* ElementNode */ && ancestorComponent.hasAttribute("s-id") && ancestorComponent["s-p"] || ancestorComponent["s-p"]) {
  1973. attachToAncestor(hostRef, hostRef.$ancestorComponent$ = ancestorComponent);
  1974. break;
  1975. }
  1976. }
  1977. }
  1978. if (BUILD15.prop && !BUILD15.hydrateServerSide && cmpMeta.$members$) {
  1979. Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
  1980. if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
  1981. const value = elm[memberName];
  1982. delete elm[memberName];
  1983. elm[memberName] = value;
  1984. }
  1985. });
  1986. }
  1987. if (BUILD15.initializeNextTick) {
  1988. nextTick(() => initializeComponent(elm, hostRef, cmpMeta));
  1989. } else {
  1990. initializeComponent(elm, hostRef, cmpMeta);
  1991. }
  1992. } else {
  1993. addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, false);
  1994. if (hostRef == null ? void 0 : hostRef.$lazyInstance$) {
  1995. fireConnectedCallback(hostRef.$lazyInstance$);
  1996. } else if (hostRef == null ? void 0 : hostRef.$onReadyPromise$) {
  1997. hostRef.$onReadyPromise$.then(() => fireConnectedCallback(hostRef.$lazyInstance$));
  1998. }
  1999. }
  2000. endConnected();
  2001. }
  2002. };
  2003. var setContentReference = (elm) => {
  2004. const contentRefElm = elm["s-cr"] = doc.createComment(
  2005. BUILD15.isDebug ? `content-ref (host=${elm.localName})` : ""
  2006. );
  2007. contentRefElm["s-cn"] = true;
  2008. insertBefore(elm, contentRefElm, elm.firstChild);
  2009. };
  2010. // src/runtime/disconnected-callback.ts
  2011. import { BUILD as BUILD16 } from "@stencil/core/internal/app-data";
  2012. var disconnectInstance = (instance) => {
  2013. if (BUILD16.lazyLoad && BUILD16.disconnectedCallback) {
  2014. safeCall(instance, "disconnectedCallback");
  2015. }
  2016. if (BUILD16.cmpDidUnload) {
  2017. safeCall(instance, "componentDidUnload");
  2018. }
  2019. };
  2020. var disconnectedCallback = async (elm) => {
  2021. if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
  2022. const hostRef = getHostRef(elm);
  2023. if (BUILD16.hostListener) {
  2024. if (hostRef.$rmListeners$) {
  2025. hostRef.$rmListeners$.map((rmListener) => rmListener());
  2026. hostRef.$rmListeners$ = void 0;
  2027. }
  2028. }
  2029. if (!BUILD16.lazyLoad) {
  2030. disconnectInstance(elm);
  2031. } else if (hostRef == null ? void 0 : hostRef.$lazyInstance$) {
  2032. disconnectInstance(hostRef.$lazyInstance$);
  2033. } else if (hostRef == null ? void 0 : hostRef.$onReadyPromise$) {
  2034. hostRef.$onReadyPromise$.then(() => disconnectInstance(hostRef.$lazyInstance$));
  2035. }
  2036. }
  2037. };
  2038. // src/runtime/dom-extras.ts
  2039. import { BUILD as BUILD17 } from "@stencil/core/internal/app-data";
  2040. var patchPseudoShadowDom = (hostElementPrototype, descriptorPrototype) => {
  2041. patchCloneNode(hostElementPrototype);
  2042. patchSlotAppendChild(hostElementPrototype);
  2043. patchSlotAppend(hostElementPrototype);
  2044. patchSlotPrepend(hostElementPrototype);
  2045. patchSlotInsertAdjacentElement(hostElementPrototype);
  2046. patchSlotInsertAdjacentHTML(hostElementPrototype);
  2047. patchSlotInsertAdjacentText(hostElementPrototype);
  2048. patchTextContent(hostElementPrototype);
  2049. patchChildSlotNodes(hostElementPrototype, descriptorPrototype);
  2050. patchSlotRemoveChild(hostElementPrototype);
  2051. };
  2052. var patchCloneNode = (HostElementPrototype) => {
  2053. const orgCloneNode = HostElementPrototype.cloneNode;
  2054. HostElementPrototype.cloneNode = function(deep) {
  2055. const srcNode = this;
  2056. const isShadowDom = BUILD17.shadowDom ? srcNode.shadowRoot && supportsShadow : false;
  2057. const clonedNode = orgCloneNode.call(srcNode, isShadowDom ? deep : false);
  2058. if (BUILD17.slot && !isShadowDom && deep) {
  2059. let i2 = 0;
  2060. let slotted, nonStencilNode;
  2061. const stencilPrivates = [
  2062. "s-id",
  2063. "s-cr",
  2064. "s-lr",
  2065. "s-rc",
  2066. "s-sc",
  2067. "s-p",
  2068. "s-cn",
  2069. "s-sr",
  2070. "s-sn",
  2071. "s-hn",
  2072. "s-ol",
  2073. "s-nr",
  2074. "s-si",
  2075. "s-rf",
  2076. "s-scs"
  2077. ];
  2078. for (; i2 < srcNode.childNodes.length; i2++) {
  2079. slotted = srcNode.childNodes[i2]["s-nr"];
  2080. nonStencilNode = stencilPrivates.every((privateField) => !srcNode.childNodes[i2][privateField]);
  2081. if (slotted) {
  2082. if (BUILD17.appendChildSlotFix && clonedNode.__appendChild) {
  2083. clonedNode.__appendChild(slotted.cloneNode(true));
  2084. } else {
  2085. clonedNode.appendChild(slotted.cloneNode(true));
  2086. }
  2087. }
  2088. if (nonStencilNode) {
  2089. clonedNode.appendChild(srcNode.childNodes[i2].cloneNode(true));
  2090. }
  2091. }
  2092. }
  2093. return clonedNode;
  2094. };
  2095. };
  2096. var patchSlotAppendChild = (HostElementPrototype) => {
  2097. HostElementPrototype.__appendChild = HostElementPrototype.appendChild;
  2098. HostElementPrototype.appendChild = function(newChild) {
  2099. const slotName = newChild["s-sn"] = getSlotName(newChild);
  2100. const slotNode = getHostSlotNode(this.childNodes, slotName, this.tagName);
  2101. if (slotNode) {
  2102. const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
  2103. const appendAfter = slotChildNodes[slotChildNodes.length - 1];
  2104. const insertedNode = insertBefore(appendAfter.parentNode, newChild, appendAfter.nextSibling);
  2105. updateFallbackSlotVisibility(this);
  2106. return insertedNode;
  2107. }
  2108. return this.__appendChild(newChild);
  2109. };
  2110. };
  2111. var patchSlotRemoveChild = (ElementPrototype) => {
  2112. ElementPrototype.__removeChild = ElementPrototype.removeChild;
  2113. ElementPrototype.removeChild = function(toRemove) {
  2114. if (toRemove && typeof toRemove["s-sn"] !== "undefined") {
  2115. const slotNode = getHostSlotNode(this.childNodes, toRemove["s-sn"], this.tagName);
  2116. if (slotNode) {
  2117. const slotChildNodes = getHostSlotChildNodes(slotNode, toRemove["s-sn"]);
  2118. const existingNode = slotChildNodes.find((n) => n === toRemove);
  2119. if (existingNode) {
  2120. existingNode.remove();
  2121. updateFallbackSlotVisibility(this);
  2122. return;
  2123. }
  2124. }
  2125. }
  2126. return this.__removeChild(toRemove);
  2127. };
  2128. };
  2129. var patchSlotPrepend = (HostElementPrototype) => {
  2130. const originalPrepend = HostElementPrototype.prepend;
  2131. HostElementPrototype.prepend = function(...newChildren) {
  2132. newChildren.forEach((newChild) => {
  2133. if (typeof newChild === "string") {
  2134. newChild = this.ownerDocument.createTextNode(newChild);
  2135. }
  2136. const slotName = newChild["s-sn"] = getSlotName(newChild);
  2137. const slotNode = getHostSlotNode(this.childNodes, slotName, this.tagName);
  2138. if (slotNode) {
  2139. const slotPlaceholder = document.createTextNode("");
  2140. slotPlaceholder["s-nr"] = newChild;
  2141. slotNode["s-cr"].parentNode.__appendChild(slotPlaceholder);
  2142. newChild["s-ol"] = slotPlaceholder;
  2143. const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
  2144. const appendAfter = slotChildNodes[0];
  2145. return insertBefore(appendAfter.parentNode, newChild, appendAfter.nextSibling);
  2146. }
  2147. if (newChild.nodeType === 1 && !!newChild.getAttribute("slot")) {
  2148. newChild.hidden = true;
  2149. }
  2150. return originalPrepend.call(this, newChild);
  2151. });
  2152. };
  2153. };
  2154. var patchSlotAppend = (HostElementPrototype) => {
  2155. HostElementPrototype.append = function(...newChildren) {
  2156. newChildren.forEach((newChild) => {
  2157. if (typeof newChild === "string") {
  2158. newChild = this.ownerDocument.createTextNode(newChild);
  2159. }
  2160. this.appendChild(newChild);
  2161. });
  2162. };
  2163. };
  2164. var patchSlotInsertAdjacentHTML = (HostElementPrototype) => {
  2165. const originalInsertAdjacentHtml = HostElementPrototype.insertAdjacentHTML;
  2166. HostElementPrototype.insertAdjacentHTML = function(position, text) {
  2167. if (position !== "afterbegin" && position !== "beforeend") {
  2168. return originalInsertAdjacentHtml.call(this, position, text);
  2169. }
  2170. const container = this.ownerDocument.createElement("_");
  2171. let node;
  2172. container.innerHTML = text;
  2173. if (position === "afterbegin") {
  2174. while (node = container.firstChild) {
  2175. this.prepend(node);
  2176. }
  2177. } else if (position === "beforeend") {
  2178. while (node = container.firstChild) {
  2179. this.append(node);
  2180. }
  2181. }
  2182. };
  2183. };
  2184. var patchSlotInsertAdjacentText = (HostElementPrototype) => {
  2185. HostElementPrototype.insertAdjacentText = function(position, text) {
  2186. this.insertAdjacentHTML(position, text);
  2187. };
  2188. };
  2189. var patchSlotInsertAdjacentElement = (HostElementPrototype) => {
  2190. const originalInsertAdjacentElement = HostElementPrototype.insertAdjacentElement;
  2191. HostElementPrototype.insertAdjacentElement = function(position, element) {
  2192. if (position !== "afterbegin" && position !== "beforeend") {
  2193. return originalInsertAdjacentElement.call(this, position, element);
  2194. }
  2195. if (position === "afterbegin") {
  2196. this.prepend(element);
  2197. return element;
  2198. } else if (position === "beforeend") {
  2199. this.append(element);
  2200. return element;
  2201. }
  2202. return element;
  2203. };
  2204. };
  2205. var patchTextContent = (hostElementPrototype) => {
  2206. const descriptor = Object.getOwnPropertyDescriptor(Node.prototype, "textContent");
  2207. Object.defineProperty(hostElementPrototype, "__textContent", descriptor);
  2208. if (BUILD17.experimentalScopedSlotChanges) {
  2209. Object.defineProperty(hostElementPrototype, "textContent", {
  2210. // To mimic shadow root behavior, we need to return the text content of all
  2211. // nodes in a slot reference node
  2212. get() {
  2213. const slotRefNodes = getAllChildSlotNodes(this.childNodes);
  2214. const textContent = slotRefNodes.map((node) => {
  2215. var _a, _b;
  2216. const text = [];
  2217. let slotContent = node.nextSibling;
  2218. while (slotContent && slotContent["s-sn"] === node["s-sn"]) {
  2219. if (slotContent.nodeType === 3 /* TEXT_NODE */ || slotContent.nodeType === 1 /* ELEMENT_NODE */) {
  2220. text.push((_b = (_a = slotContent.textContent) == null ? void 0 : _a.trim()) != null ? _b : "");
  2221. }
  2222. slotContent = slotContent.nextSibling;
  2223. }
  2224. return text.filter((ref) => ref !== "").join(" ");
  2225. }).filter((text) => text !== "").join(" ");
  2226. return " " + textContent + " ";
  2227. },
  2228. // To mimic shadow root behavior, we need to overwrite all nodes in a slot
  2229. // reference node. If a default slot reference node exists, the text content will be
  2230. // placed there. Otherwise, the new text node will be hidden
  2231. set(value) {
  2232. const slotRefNodes = getAllChildSlotNodes(this.childNodes);
  2233. slotRefNodes.forEach((node) => {
  2234. let slotContent = node.nextSibling;
  2235. while (slotContent && slotContent["s-sn"] === node["s-sn"]) {
  2236. const tmp = slotContent;
  2237. slotContent = slotContent.nextSibling;
  2238. tmp.remove();
  2239. }
  2240. if (node["s-sn"] === "") {
  2241. const textNode = this.ownerDocument.createTextNode(value);
  2242. textNode["s-sn"] = "";
  2243. insertBefore(node.parentElement, textNode, node.nextSibling);
  2244. } else {
  2245. node.remove();
  2246. }
  2247. });
  2248. }
  2249. });
  2250. } else {
  2251. Object.defineProperty(hostElementPrototype, "textContent", {
  2252. get() {
  2253. var _a;
  2254. const slotNode = getHostSlotNode(this.childNodes, "", this.tagName);
  2255. if (((_a = slotNode == null ? void 0 : slotNode.nextSibling) == null ? void 0 : _a.nodeType) === 3 /* TEXT_NODE */) {
  2256. return slotNode.nextSibling.textContent;
  2257. } else if (slotNode) {
  2258. return slotNode.textContent;
  2259. } else {
  2260. return this.__textContent;
  2261. }
  2262. },
  2263. set(value) {
  2264. var _a;
  2265. const slotNode = getHostSlotNode(this.childNodes, "", this.tagName);
  2266. if (((_a = slotNode == null ? void 0 : slotNode.nextSibling) == null ? void 0 : _a.nodeType) === 3 /* TEXT_NODE */) {
  2267. slotNode.nextSibling.textContent = value;
  2268. } else if (slotNode) {
  2269. slotNode.textContent = value;
  2270. } else {
  2271. this.__textContent = value;
  2272. const contentRefElm = this["s-cr"];
  2273. if (contentRefElm) {
  2274. insertBefore(this, contentRefElm, this.firstChild);
  2275. }
  2276. }
  2277. }
  2278. });
  2279. }
  2280. };
  2281. var patchChildSlotNodes = (elm, cmpMeta) => {
  2282. class FakeNodeList extends Array {
  2283. item(n) {
  2284. return this[n];
  2285. }
  2286. }
  2287. if (cmpMeta.$flags$ & 8 /* needsShadowDomShim */) {
  2288. const childNodesFn = elm.__lookupGetter__("childNodes");
  2289. Object.defineProperty(elm, "children", {
  2290. get() {
  2291. return this.childNodes.map((n) => n.nodeType === 1);
  2292. }
  2293. });
  2294. Object.defineProperty(elm, "childElementCount", {
  2295. get() {
  2296. return elm.children.length;
  2297. }
  2298. });
  2299. Object.defineProperty(elm, "childNodes", {
  2300. get() {
  2301. const childNodes = childNodesFn.call(this);
  2302. if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0 && getHostRef(this).$flags$ & 2 /* hasRendered */) {
  2303. const result = new FakeNodeList();
  2304. for (let i2 = 0; i2 < childNodes.length; i2++) {
  2305. const slot = childNodes[i2]["s-nr"];
  2306. if (slot) {
  2307. result.push(slot);
  2308. }
  2309. }
  2310. return result;
  2311. }
  2312. return FakeNodeList.from(childNodes);
  2313. }
  2314. });
  2315. }
  2316. };
  2317. var getAllChildSlotNodes = (childNodes) => {
  2318. const slotRefNodes = [];
  2319. for (const childNode of Array.from(childNodes)) {
  2320. if (childNode["s-sr"]) {
  2321. slotRefNodes.push(childNode);
  2322. }
  2323. slotRefNodes.push(...getAllChildSlotNodes(childNode.childNodes));
  2324. }
  2325. return slotRefNodes;
  2326. };
  2327. var getSlotName = (node) => node["s-sn"] || node.nodeType === 1 && node.getAttribute("slot") || "";
  2328. var getHostSlotNode = (childNodes, slotName, hostName) => {
  2329. let i2 = 0;
  2330. let childNode;
  2331. for (; i2 < childNodes.length; i2++) {
  2332. childNode = childNodes[i2];
  2333. if (childNode["s-sr"] && childNode["s-sn"] === slotName && childNode["s-hn"] === hostName) {
  2334. return childNode;
  2335. }
  2336. childNode = getHostSlotNode(childNode.childNodes, slotName, hostName);
  2337. if (childNode) {
  2338. return childNode;
  2339. }
  2340. }
  2341. return null;
  2342. };
  2343. var getHostSlotChildNodes = (n, slotName) => {
  2344. const childNodes = [n];
  2345. while ((n = n.nextSibling) && n["s-sn"] === slotName) {
  2346. childNodes.push(n);
  2347. }
  2348. return childNodes;
  2349. };
  2350. // src/runtime/bootstrap-custom-element.ts
  2351. var defineCustomElement = (Cstr, compactMeta) => {
  2352. customElements.define(compactMeta[1], proxyCustomElement(Cstr, compactMeta));
  2353. };
  2354. var proxyCustomElement = (Cstr, compactMeta) => {
  2355. const cmpMeta = {
  2356. $flags$: compactMeta[0],
  2357. $tagName$: compactMeta[1]
  2358. };
  2359. if (BUILD18.member) {
  2360. cmpMeta.$members$ = compactMeta[2];
  2361. }
  2362. if (BUILD18.hostListener) {
  2363. cmpMeta.$listeners$ = compactMeta[3];
  2364. }
  2365. if (BUILD18.watchCallback) {
  2366. cmpMeta.$watchers$ = Cstr.$watchers$;
  2367. }
  2368. if (BUILD18.reflect) {
  2369. cmpMeta.$attrsToReflect$ = [];
  2370. }
  2371. if (BUILD18.shadowDom && !supportsShadow && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
  2372. cmpMeta.$flags$ |= 8 /* needsShadowDomShim */;
  2373. }
  2374. if (BUILD18.experimentalSlotFixes) {
  2375. if (BUILD18.scoped && cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
  2376. patchPseudoShadowDom(Cstr.prototype, cmpMeta);
  2377. }
  2378. } else {
  2379. if (BUILD18.slotChildNodesFix) {
  2380. patchChildSlotNodes(Cstr.prototype, cmpMeta);
  2381. }
  2382. if (BUILD18.cloneNodeFix) {
  2383. patchCloneNode(Cstr.prototype);
  2384. }
  2385. if (BUILD18.appendChildSlotFix) {
  2386. patchSlotAppendChild(Cstr.prototype);
  2387. }
  2388. if (BUILD18.scopedSlotTextContentFix && cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
  2389. patchTextContent(Cstr.prototype);
  2390. }
  2391. }
  2392. const originalConnectedCallback = Cstr.prototype.connectedCallback;
  2393. const originalDisconnectedCallback = Cstr.prototype.disconnectedCallback;
  2394. Object.assign(Cstr.prototype, {
  2395. __registerHost() {
  2396. registerHost(this, cmpMeta);
  2397. },
  2398. connectedCallback() {
  2399. const hostRef = getHostRef(this);
  2400. addHostEventListeners(this, hostRef, cmpMeta.$listeners$, false);
  2401. connectedCallback(this);
  2402. if (BUILD18.connectedCallback && originalConnectedCallback) {
  2403. originalConnectedCallback.call(this);
  2404. }
  2405. },
  2406. disconnectedCallback() {
  2407. disconnectedCallback(this);
  2408. if (BUILD18.disconnectedCallback && originalDisconnectedCallback) {
  2409. originalDisconnectedCallback.call(this);
  2410. }
  2411. },
  2412. __attachShadow() {
  2413. if (supportsShadow) {
  2414. if (!this.shadowRoot) {
  2415. if (BUILD18.shadowDelegatesFocus) {
  2416. this.attachShadow({
  2417. mode: "open",
  2418. delegatesFocus: !!(cmpMeta.$flags$ & 16 /* shadowDelegatesFocus */)
  2419. });
  2420. } else {
  2421. this.attachShadow({ mode: "open" });
  2422. }
  2423. } else {
  2424. if (this.shadowRoot.mode !== "open") {
  2425. throw new Error(
  2426. `Unable to re-use existing shadow root for ${cmpMeta.$tagName$}! Mode is set to ${this.shadowRoot.mode} but Stencil only supports open shadow roots.`
  2427. );
  2428. }
  2429. }
  2430. } else {
  2431. this.shadowRoot = this;
  2432. }
  2433. }
  2434. });
  2435. Cstr.is = cmpMeta.$tagName$;
  2436. return proxyComponent(Cstr, cmpMeta, 1 /* isElementConstructor */ | 2 /* proxyState */);
  2437. };
  2438. var forceModeUpdate = (elm) => {
  2439. if (BUILD18.style && BUILD18.mode && !BUILD18.lazyLoad) {
  2440. const mode = computeMode(elm);
  2441. const hostRef = getHostRef(elm);
  2442. if (hostRef.$modeName$ !== mode) {
  2443. const cmpMeta = hostRef.$cmpMeta$;
  2444. const oldScopeId = elm["s-sc"];
  2445. const scopeId2 = getScopeId(cmpMeta, mode);
  2446. const style = elm.constructor.style[mode];
  2447. const flags = cmpMeta.$flags$;
  2448. if (style) {
  2449. if (!styles.has(scopeId2)) {
  2450. registerStyle(scopeId2, style, !!(flags & 1 /* shadowDomEncapsulation */));
  2451. }
  2452. hostRef.$modeName$ = mode;
  2453. elm.classList.remove(oldScopeId + "-h", oldScopeId + "-s");
  2454. attachStyles(hostRef);
  2455. forceUpdate(elm);
  2456. }
  2457. }
  2458. }
  2459. };
  2460. // src/runtime/bootstrap-lazy.ts
  2461. import { BUILD as BUILD19 } from "@stencil/core/internal/app-data";
  2462. // src/runtime/hmr-component.ts
  2463. var hmrStart = (hostElement, cmpMeta, hmrVersionId) => {
  2464. const hostRef = getHostRef(hostElement);
  2465. hostRef.$flags$ = 1 /* hasConnected */;
  2466. initializeComponent(hostElement, hostRef, cmpMeta, hmrVersionId);
  2467. };
  2468. // src/runtime/bootstrap-lazy.ts
  2469. var bootstrapLazy = (lazyBundles, options = {}) => {
  2470. var _a;
  2471. if (BUILD19.profile && performance.mark) {
  2472. performance.mark("st:app:start");
  2473. }
  2474. installDevTools();
  2475. const endBootstrap = createTime("bootstrapLazy");
  2476. const cmpTags = [];
  2477. const exclude = options.exclude || [];
  2478. const customElements2 = win.customElements;
  2479. const head = doc.head;
  2480. const metaCharset = /* @__PURE__ */ head.querySelector("meta[charset]");
  2481. const dataStyles = /* @__PURE__ */ doc.createElement("style");
  2482. const deferredConnectedCallbacks = [];
  2483. let appLoadFallback;
  2484. let isBootstrapping = true;
  2485. Object.assign(plt, options);
  2486. plt.$resourcesUrl$ = new URL(options.resourcesUrl || "./", doc.baseURI).href;
  2487. if (BUILD19.asyncQueue) {
  2488. if (options.syncQueue) {
  2489. plt.$flags$ |= 4 /* queueSync */;
  2490. }
  2491. }
  2492. if (BUILD19.hydrateClientSide) {
  2493. plt.$flags$ |= 2 /* appLoaded */;
  2494. }
  2495. let hasSlotRelocation = false;
  2496. lazyBundles.map((lazyBundle) => {
  2497. lazyBundle[1].map((compactMeta) => {
  2498. var _a2;
  2499. const cmpMeta = {
  2500. $flags$: compactMeta[0],
  2501. $tagName$: compactMeta[1],
  2502. $members$: compactMeta[2],
  2503. $listeners$: compactMeta[3]
  2504. };
  2505. if (cmpMeta.$flags$ & 4 /* hasSlotRelocation */) {
  2506. hasSlotRelocation = true;
  2507. }
  2508. if (BUILD19.member) {
  2509. cmpMeta.$members$ = compactMeta[2];
  2510. }
  2511. if (BUILD19.hostListener) {
  2512. cmpMeta.$listeners$ = compactMeta[3];
  2513. }
  2514. if (BUILD19.reflect) {
  2515. cmpMeta.$attrsToReflect$ = [];
  2516. }
  2517. if (BUILD19.watchCallback) {
  2518. cmpMeta.$watchers$ = (_a2 = compactMeta[4]) != null ? _a2 : {};
  2519. }
  2520. if (BUILD19.shadowDom && !supportsShadow && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
  2521. cmpMeta.$flags$ |= 8 /* needsShadowDomShim */;
  2522. }
  2523. const tagName = BUILD19.transformTagName && options.transformTagName ? options.transformTagName(cmpMeta.$tagName$) : cmpMeta.$tagName$;
  2524. const HostElement = class extends HTMLElement {
  2525. // StencilLazyHost
  2526. constructor(self) {
  2527. super(self);
  2528. this.hasRegisteredEventListeners = false;
  2529. self = this;
  2530. registerHost(self, cmpMeta);
  2531. if (BUILD19.shadowDom && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
  2532. if (supportsShadow) {
  2533. if (!self.shadowRoot) {
  2534. if (BUILD19.shadowDelegatesFocus) {
  2535. self.attachShadow({
  2536. mode: "open",
  2537. delegatesFocus: !!(cmpMeta.$flags$ & 16 /* shadowDelegatesFocus */)
  2538. });
  2539. } else {
  2540. self.attachShadow({ mode: "open" });
  2541. }
  2542. } else {
  2543. if (self.shadowRoot.mode !== "open") {
  2544. throw new Error(
  2545. `Unable to re-use existing shadow root for ${cmpMeta.$tagName$}! Mode is set to ${self.shadowRoot.mode} but Stencil only supports open shadow roots.`
  2546. );
  2547. }
  2548. }
  2549. } else if (!BUILD19.hydrateServerSide && !("shadowRoot" in self)) {
  2550. self.shadowRoot = self;
  2551. }
  2552. }
  2553. }
  2554. connectedCallback() {
  2555. const hostRef = getHostRef(this);
  2556. if (!this.hasRegisteredEventListeners) {
  2557. this.hasRegisteredEventListeners = true;
  2558. addHostEventListeners(this, hostRef, cmpMeta.$listeners$, false);
  2559. }
  2560. if (appLoadFallback) {
  2561. clearTimeout(appLoadFallback);
  2562. appLoadFallback = null;
  2563. }
  2564. if (isBootstrapping) {
  2565. deferredConnectedCallbacks.push(this);
  2566. } else {
  2567. plt.jmp(() => connectedCallback(this));
  2568. }
  2569. }
  2570. disconnectedCallback() {
  2571. plt.jmp(() => disconnectedCallback(this));
  2572. }
  2573. componentOnReady() {
  2574. return getHostRef(this).$onReadyPromise$;
  2575. }
  2576. };
  2577. if (BUILD19.experimentalSlotFixes) {
  2578. if (BUILD19.scoped && cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
  2579. patchPseudoShadowDom(HostElement.prototype, cmpMeta);
  2580. }
  2581. } else {
  2582. if (BUILD19.slotChildNodesFix) {
  2583. patchChildSlotNodes(HostElement.prototype, cmpMeta);
  2584. }
  2585. if (BUILD19.cloneNodeFix) {
  2586. patchCloneNode(HostElement.prototype);
  2587. }
  2588. if (BUILD19.appendChildSlotFix) {
  2589. patchSlotAppendChild(HostElement.prototype);
  2590. }
  2591. if (BUILD19.scopedSlotTextContentFix && cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
  2592. patchTextContent(HostElement.prototype);
  2593. }
  2594. }
  2595. if (BUILD19.formAssociated && cmpMeta.$flags$ & 64 /* formAssociated */) {
  2596. HostElement.formAssociated = true;
  2597. }
  2598. if (BUILD19.hotModuleReplacement) {
  2599. HostElement.prototype["s-hmr"] = function(hmrVersionId) {
  2600. hmrStart(this, cmpMeta, hmrVersionId);
  2601. };
  2602. }
  2603. cmpMeta.$lazyBundleId$ = lazyBundle[0];
  2604. if (!exclude.includes(tagName) && !customElements2.get(tagName)) {
  2605. cmpTags.push(tagName);
  2606. customElements2.define(
  2607. tagName,
  2608. proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */)
  2609. );
  2610. }
  2611. });
  2612. });
  2613. if (cmpTags.length > 0) {
  2614. if (hasSlotRelocation) {
  2615. dataStyles.textContent += SLOT_FB_CSS;
  2616. }
  2617. if (BUILD19.invisiblePrehydration && (BUILD19.hydratedClass || BUILD19.hydratedAttribute)) {
  2618. dataStyles.textContent += cmpTags.sort() + HYDRATED_CSS;
  2619. }
  2620. if (dataStyles.innerHTML.length) {
  2621. dataStyles.setAttribute("data-styles", "");
  2622. const nonce = (_a = plt.$nonce$) != null ? _a : queryNonceMetaTagContent(doc);
  2623. if (nonce != null) {
  2624. dataStyles.setAttribute("nonce", nonce);
  2625. }
  2626. head.insertBefore(dataStyles, metaCharset ? metaCharset.nextSibling : head.firstChild);
  2627. }
  2628. }
  2629. isBootstrapping = false;
  2630. if (deferredConnectedCallbacks.length) {
  2631. deferredConnectedCallbacks.map((host) => host.connectedCallback());
  2632. } else {
  2633. if (BUILD19.profile) {
  2634. plt.jmp(() => appLoadFallback = setTimeout(appDidLoad, 30, "timeout"));
  2635. } else {
  2636. plt.jmp(() => appLoadFallback = setTimeout(appDidLoad, 30));
  2637. }
  2638. }
  2639. endBootstrap();
  2640. };
  2641. // src/runtime/fragment.ts
  2642. var Fragment = (_, children) => children;
  2643. // src/runtime/host-listener.ts
  2644. import { BUILD as BUILD20 } from "@stencil/core/internal/app-data";
  2645. var addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
  2646. if (BUILD20.hostListener && listeners) {
  2647. if (BUILD20.hostListenerTargetParent) {
  2648. if (attachParentListeners) {
  2649. listeners = listeners.filter(([flags]) => flags & 32 /* TargetParent */);
  2650. } else {
  2651. listeners = listeners.filter(([flags]) => !(flags & 32 /* TargetParent */));
  2652. }
  2653. }
  2654. listeners.map(([flags, name, method]) => {
  2655. const target = BUILD20.hostListenerTarget ? getHostListenerTarget(elm, flags) : elm;
  2656. const handler = hostListenerProxy(hostRef, method);
  2657. const opts = hostListenerOpts(flags);
  2658. plt.ael(target, name, handler, opts);
  2659. (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
  2660. });
  2661. }
  2662. };
  2663. var hostListenerProxy = (hostRef, methodName) => (ev) => {
  2664. var _a;
  2665. try {
  2666. if (BUILD20.lazyLoad) {
  2667. if (hostRef.$flags$ & 256 /* isListenReady */) {
  2668. (_a = hostRef.$lazyInstance$) == null ? void 0 : _a[methodName](ev);
  2669. } else {
  2670. (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
  2671. }
  2672. } else {
  2673. hostRef.$hostElement$[methodName](ev);
  2674. }
  2675. } catch (e) {
  2676. consoleError(e);
  2677. }
  2678. };
  2679. var getHostListenerTarget = (elm, flags) => {
  2680. if (BUILD20.hostListenerTargetDocument && flags & 4 /* TargetDocument */) return doc;
  2681. if (BUILD20.hostListenerTargetWindow && flags & 8 /* TargetWindow */) return win;
  2682. if (BUILD20.hostListenerTargetBody && flags & 16 /* TargetBody */) return doc.body;
  2683. if (BUILD20.hostListenerTargetParent && flags & 32 /* TargetParent */ && elm.parentElement)
  2684. return elm.parentElement;
  2685. return elm;
  2686. };
  2687. var hostListenerOpts = (flags) => supportsListenerOptions ? {
  2688. passive: (flags & 1 /* Passive */) !== 0,
  2689. capture: (flags & 2 /* Capture */) !== 0
  2690. } : (flags & 2 /* Capture */) !== 0;
  2691. // src/runtime/nonce.ts
  2692. var setNonce = (nonce) => plt.$nonce$ = nonce;
  2693. // src/runtime/vdom/vdom-annotations.ts
  2694. var insertVdomAnnotations = (doc2, staticComponents) => {
  2695. if (doc2 != null) {
  2696. const docData = {
  2697. hostIds: 0,
  2698. rootLevelIds: 0,
  2699. staticComponents: new Set(staticComponents)
  2700. };
  2701. const orgLocationNodes = [];
  2702. parseVNodeAnnotations(doc2, doc2.body, docData, orgLocationNodes);
  2703. orgLocationNodes.forEach((orgLocationNode) => {
  2704. var _a;
  2705. if (orgLocationNode != null && orgLocationNode["s-nr"]) {
  2706. const nodeRef = orgLocationNode["s-nr"];
  2707. let hostId = nodeRef["s-host-id"];
  2708. let nodeId = nodeRef["s-node-id"];
  2709. let childId = `${hostId}.${nodeId}`;
  2710. if (hostId == null) {
  2711. hostId = 0;
  2712. docData.rootLevelIds++;
  2713. nodeId = docData.rootLevelIds;
  2714. childId = `${hostId}.${nodeId}`;
  2715. if (nodeRef.nodeType === 1 /* ElementNode */) {
  2716. nodeRef.setAttribute(HYDRATE_CHILD_ID, childId);
  2717. } else if (nodeRef.nodeType === 3 /* TextNode */) {
  2718. if (hostId === 0) {
  2719. const textContent = (_a = nodeRef.nodeValue) == null ? void 0 : _a.trim();
  2720. if (textContent === "") {
  2721. orgLocationNode.remove();
  2722. return;
  2723. }
  2724. }
  2725. const commentBeforeTextNode = doc2.createComment(childId);
  2726. commentBeforeTextNode.nodeValue = `${TEXT_NODE_ID}.${childId}`;
  2727. insertBefore(nodeRef.parentNode, commentBeforeTextNode, nodeRef);
  2728. }
  2729. }
  2730. let orgLocationNodeId = `${ORG_LOCATION_ID}.${childId}`;
  2731. const orgLocationParentNode = orgLocationNode.parentElement;
  2732. if (orgLocationParentNode) {
  2733. if (orgLocationParentNode["s-en"] === "") {
  2734. orgLocationNodeId += `.`;
  2735. } else if (orgLocationParentNode["s-en"] === "c") {
  2736. orgLocationNodeId += `.c`;
  2737. }
  2738. }
  2739. orgLocationNode.nodeValue = orgLocationNodeId;
  2740. }
  2741. });
  2742. }
  2743. };
  2744. var parseVNodeAnnotations = (doc2, node, docData, orgLocationNodes) => {
  2745. var _a;
  2746. if (node == null) {
  2747. return;
  2748. }
  2749. if (node["s-nr"] != null) {
  2750. orgLocationNodes.push(node);
  2751. }
  2752. if (node.nodeType === 1 /* ElementNode */) {
  2753. const childNodes = [...Array.from(node.childNodes), ...Array.from(((_a = node.shadowRoot) == null ? void 0 : _a.childNodes) || [])];
  2754. childNodes.forEach((childNode) => {
  2755. const hostRef = getHostRef(childNode);
  2756. if (hostRef != null && !docData.staticComponents.has(childNode.nodeName.toLowerCase())) {
  2757. const cmpData = {
  2758. nodeIds: 0
  2759. };
  2760. insertVNodeAnnotations(doc2, childNode, hostRef.$vnode$, docData, cmpData);
  2761. }
  2762. parseVNodeAnnotations(doc2, childNode, docData, orgLocationNodes);
  2763. });
  2764. }
  2765. };
  2766. var insertVNodeAnnotations = (doc2, hostElm, vnode, docData, cmpData) => {
  2767. if (vnode != null) {
  2768. const hostId = ++docData.hostIds;
  2769. hostElm.setAttribute(HYDRATE_ID, hostId);
  2770. if (hostElm["s-cr"] != null) {
  2771. hostElm["s-cr"].nodeValue = `${CONTENT_REF_ID}.${hostId}`;
  2772. }
  2773. if (vnode.$children$ != null) {
  2774. const depth = 0;
  2775. vnode.$children$.forEach((vnodeChild, index) => {
  2776. insertChildVNodeAnnotations(doc2, vnodeChild, cmpData, hostId, depth, index);
  2777. });
  2778. }
  2779. if (hostElm && vnode && vnode.$elm$ && !hostElm.hasAttribute(HYDRATE_CHILD_ID)) {
  2780. const parent = hostElm.parentElement;
  2781. if (parent && parent.childNodes) {
  2782. const parentChildNodes = Array.from(parent.childNodes);
  2783. const comment = parentChildNodes.find(
  2784. (node) => node.nodeType === 8 /* CommentNode */ && node["s-sr"]
  2785. );
  2786. if (comment) {
  2787. const index = parentChildNodes.indexOf(hostElm) - 1;
  2788. vnode.$elm$.setAttribute(
  2789. HYDRATE_CHILD_ID,
  2790. `${comment["s-host-id"]}.${comment["s-node-id"]}.0.${index}`
  2791. );
  2792. }
  2793. }
  2794. }
  2795. }
  2796. };
  2797. var insertChildVNodeAnnotations = (doc2, vnodeChild, cmpData, hostId, depth, index) => {
  2798. const childElm = vnodeChild.$elm$;
  2799. if (childElm == null) {
  2800. return;
  2801. }
  2802. const nodeId = cmpData.nodeIds++;
  2803. const childId = `${hostId}.${nodeId}.${depth}.${index}`;
  2804. childElm["s-host-id"] = hostId;
  2805. childElm["s-node-id"] = nodeId;
  2806. if (childElm.nodeType === 1 /* ElementNode */) {
  2807. childElm.setAttribute(HYDRATE_CHILD_ID, childId);
  2808. } else if (childElm.nodeType === 3 /* TextNode */) {
  2809. const parentNode = childElm.parentNode;
  2810. const nodeName = parentNode == null ? void 0 : parentNode.nodeName;
  2811. if (nodeName !== "STYLE" && nodeName !== "SCRIPT") {
  2812. const textNodeId = `${TEXT_NODE_ID}.${childId}`;
  2813. const commentBeforeTextNode = doc2.createComment(textNodeId);
  2814. insertBefore(parentNode, commentBeforeTextNode, childElm);
  2815. }
  2816. } else if (childElm.nodeType === 8 /* CommentNode */) {
  2817. if (childElm["s-sr"]) {
  2818. const slotName = childElm["s-sn"] || "";
  2819. const slotNodeId = `${SLOT_NODE_ID}.${childId}.${slotName}`;
  2820. childElm.nodeValue = slotNodeId;
  2821. }
  2822. }
  2823. if (vnodeChild.$children$ != null) {
  2824. const childDepth = depth + 1;
  2825. vnodeChild.$children$.forEach((vnode, index2) => {
  2826. insertChildVNodeAnnotations(doc2, vnode, cmpData, hostId, childDepth, index2);
  2827. });
  2828. }
  2829. };
  2830. // src/hydrate/platform/h-async.ts
  2831. var hAsync = (nodeName, vnodeData, ...children) => {
  2832. if (Array.isArray(children) && children.length > 0) {
  2833. const flatChildren = children.flat(Infinity);
  2834. if (flatChildren.some((child) => child instanceof Promise)) {
  2835. return Promise.all(flatChildren).then((resolvedChildren) => {
  2836. return h(nodeName, vnodeData, ...resolvedChildren);
  2837. }).catch((err2) => {
  2838. consoleDevError(err2);
  2839. return h(nodeName, vnodeData);
  2840. });
  2841. }
  2842. return h(nodeName, vnodeData, ...flatChildren);
  2843. }
  2844. return h(nodeName, vnodeData);
  2845. };
  2846. // src/app-globals/index.ts
  2847. var globalScripts = (
  2848. /* default */
  2849. () => {
  2850. }
  2851. );
  2852. // src/hydrate/platform/proxy-host-element.ts
  2853. import { BUILD as BUILD21 } from "@stencil/core/internal/app-data";
  2854. function proxyHostElement(elm, cmpMeta) {
  2855. if (typeof elm.componentOnReady !== "function") {
  2856. elm.componentOnReady = componentOnReady;
  2857. }
  2858. if (typeof elm.forceUpdate !== "function") {
  2859. elm.forceUpdate = forceUpdate2;
  2860. }
  2861. if (!elm.shadowRoot && !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */)) {
  2862. if (BUILD21.shadowDelegatesFocus) {
  2863. elm.attachShadow({
  2864. mode: "open",
  2865. delegatesFocus: !!(cmpMeta.$flags$ & 16 /* shadowDelegatesFocus */)
  2866. });
  2867. } else {
  2868. elm.attachShadow({ mode: "open" });
  2869. }
  2870. }
  2871. if (cmpMeta.$members$ != null) {
  2872. const hostRef = getHostRef(elm);
  2873. const members = Object.entries(cmpMeta.$members$);
  2874. members.forEach(([memberName, m]) => {
  2875. var _a, _b;
  2876. const memberFlags = m[0];
  2877. if (memberFlags & 31 /* Prop */) {
  2878. const attributeName = m[1] || memberName;
  2879. let attrValue = elm.getAttribute(attributeName);
  2880. if ((attrValue == null ? void 0 : attrValue.startsWith("{")) && attrValue.endsWith("}") || (attrValue == null ? void 0 : attrValue.startsWith("[")) && attrValue.endsWith("]")) {
  2881. try {
  2882. attrValue = JSON.parse(attrValue);
  2883. } catch (e) {
  2884. }
  2885. }
  2886. if (attrValue != null) {
  2887. const parsedAttrValue = parsePropertyValue(attrValue, memberFlags);
  2888. (_a = hostRef == null ? void 0 : hostRef.$instanceValues$) == null ? void 0 : _a.set(memberName, parsedAttrValue);
  2889. }
  2890. const ownValue = elm[memberName];
  2891. if (ownValue !== void 0) {
  2892. (_b = hostRef == null ? void 0 : hostRef.$instanceValues$) == null ? void 0 : _b.set(memberName, ownValue);
  2893. delete elm[memberName];
  2894. }
  2895. Object.defineProperty(elm, memberName, {
  2896. get() {
  2897. return getValue(this, memberName);
  2898. },
  2899. set(newValue) {
  2900. setValue(this, memberName, newValue, cmpMeta);
  2901. },
  2902. configurable: true,
  2903. enumerable: true
  2904. });
  2905. } else if (memberFlags & 64 /* Method */) {
  2906. Object.defineProperty(elm, memberName, {
  2907. value(...args) {
  2908. var _a2;
  2909. const ref = getHostRef(this);
  2910. return (_a2 = ref == null ? void 0 : ref.$onInstancePromise$) == null ? void 0 : _a2.then(() => {
  2911. var _a3;
  2912. return (_a3 = ref == null ? void 0 : ref.$lazyInstance$) == null ? void 0 : _a3[memberName](...args);
  2913. }).catch(consoleError);
  2914. }
  2915. });
  2916. }
  2917. });
  2918. }
  2919. }
  2920. function componentOnReady() {
  2921. var _a;
  2922. return (_a = getHostRef(this)) == null ? void 0 : _a.$onReadyPromise$;
  2923. }
  2924. function forceUpdate2() {
  2925. }
  2926. // src/hydrate/platform/hydrate-app.ts
  2927. function hydrateApp(win2, opts, results, afterHydrate, resolve) {
  2928. const connectedElements = /* @__PURE__ */ new Set();
  2929. const createdElements = /* @__PURE__ */ new Set();
  2930. const waitingElements = /* @__PURE__ */ new Set();
  2931. const orgDocumentCreateElement = win2.document.createElement;
  2932. const orgDocumentCreateElementNS = win2.document.createElementNS;
  2933. const resolved2 = Promise.resolve();
  2934. let tmrId;
  2935. let ranCompleted = false;
  2936. function hydratedComplete() {
  2937. globalThis.clearTimeout(tmrId);
  2938. createdElements.clear();
  2939. connectedElements.clear();
  2940. if (!ranCompleted) {
  2941. ranCompleted = true;
  2942. try {
  2943. if (opts.clientHydrateAnnotations) {
  2944. insertVdomAnnotations(win2.document, opts.staticComponents);
  2945. }
  2946. win2.dispatchEvent(new win2.Event("DOMContentLoaded"));
  2947. win2.document.createElement = orgDocumentCreateElement;
  2948. win2.document.createElementNS = orgDocumentCreateElementNS;
  2949. } catch (e) {
  2950. renderCatchError(opts, results, e);
  2951. }
  2952. }
  2953. afterHydrate(win2, opts, results, resolve);
  2954. }
  2955. function hydratedError(err2) {
  2956. renderCatchError(opts, results, err2);
  2957. hydratedComplete();
  2958. }
  2959. function timeoutExceeded() {
  2960. hydratedError(`Hydrate exceeded timeout${waitingOnElementsMsg(waitingElements)}`);
  2961. }
  2962. try {
  2963. let patchedConnectedCallback2 = function() {
  2964. return connectElement2(this);
  2965. }, patchElement2 = function(elm) {
  2966. if (isValidComponent(elm, opts)) {
  2967. const hostRef = getHostRef(elm);
  2968. if (!hostRef) {
  2969. const Cstr = loadModule(
  2970. {
  2971. $tagName$: elm.nodeName.toLowerCase(),
  2972. $flags$: null
  2973. },
  2974. null
  2975. );
  2976. if (Cstr != null && Cstr.cmpMeta != null) {
  2977. createdElements.add(elm);
  2978. elm.connectedCallback = patchedConnectedCallback2;
  2979. registerHost(elm, Cstr.cmpMeta);
  2980. proxyHostElement(elm, Cstr.cmpMeta);
  2981. }
  2982. }
  2983. }
  2984. }, patchChild2 = function(elm) {
  2985. if (elm != null && elm.nodeType === 1) {
  2986. patchElement2(elm);
  2987. const children = elm.children;
  2988. for (let i2 = 0, ii = children.length; i2 < ii; i2++) {
  2989. patchChild2(children[i2]);
  2990. }
  2991. }
  2992. }, connectElement2 = function(elm) {
  2993. createdElements.delete(elm);
  2994. if (isValidComponent(elm, opts) && results.hydratedCount < opts.maxHydrateCount) {
  2995. if (!connectedElements.has(elm) && shouldHydrate(elm)) {
  2996. connectedElements.add(elm);
  2997. return hydrateComponent.call(elm, win2, results, elm.nodeName, elm, waitingElements);
  2998. }
  2999. }
  3000. return resolved2;
  3001. }, waitLoop2 = function() {
  3002. const toConnect = Array.from(createdElements).filter((elm) => elm.parentElement);
  3003. if (toConnect.length > 0) {
  3004. return Promise.all(toConnect.map(connectElement2)).then(waitLoop2);
  3005. }
  3006. return resolved2;
  3007. };
  3008. var patchedConnectedCallback = patchedConnectedCallback2, patchElement = patchElement2, patchChild = patchChild2, connectElement = connectElement2, waitLoop = waitLoop2;
  3009. win2.document.createElement = function patchedCreateElement(tagName) {
  3010. const elm = orgDocumentCreateElement.call(win2.document, tagName);
  3011. patchElement2(elm);
  3012. return elm;
  3013. };
  3014. win2.document.createElementNS = function patchedCreateElement(namespaceURI, tagName) {
  3015. const elm = orgDocumentCreateElementNS.call(win2.document, namespaceURI, tagName);
  3016. patchElement2(elm);
  3017. return elm;
  3018. };
  3019. tmrId = globalThis.setTimeout(timeoutExceeded, opts.timeout);
  3020. plt.$resourcesUrl$ = new URL(opts.resourcesUrl || "./", doc.baseURI).href;
  3021. globalScripts();
  3022. patchChild2(win2.document.body);
  3023. waitLoop2().then(hydratedComplete).catch(hydratedError);
  3024. } catch (e) {
  3025. hydratedError(e);
  3026. }
  3027. }
  3028. async function hydrateComponent(win2, results, tagName, elm, waitingElements) {
  3029. tagName = tagName.toLowerCase();
  3030. const Cstr = loadModule(
  3031. {
  3032. $tagName$: tagName,
  3033. $flags$: null
  3034. },
  3035. null
  3036. );
  3037. if (Cstr != null) {
  3038. const cmpMeta = Cstr.cmpMeta;
  3039. if (cmpMeta != null) {
  3040. waitingElements.add(elm);
  3041. const hostRef = getHostRef(this);
  3042. addHostEventListeners(this, hostRef, cmpMeta.$listeners$, false);
  3043. try {
  3044. connectedCallback(elm);
  3045. await elm.componentOnReady();
  3046. results.hydratedCount++;
  3047. const ref = getHostRef(elm);
  3048. const modeName = !ref.$modeName$ ? "$" : ref.$modeName$;
  3049. if (!results.components.some((c) => c.tag === tagName && c.mode === modeName)) {
  3050. results.components.push({
  3051. tag: tagName,
  3052. mode: modeName,
  3053. count: 0,
  3054. depth: -1
  3055. });
  3056. }
  3057. } catch (e) {
  3058. win2.console.error(e);
  3059. }
  3060. waitingElements.delete(elm);
  3061. }
  3062. }
  3063. }
  3064. function isValidComponent(elm, opts) {
  3065. if (elm != null && elm.nodeType === 1) {
  3066. const tagName = elm.nodeName;
  3067. if (typeof tagName === "string" && tagName.includes("-")) {
  3068. if (opts.excludeComponents.includes(tagName.toLowerCase())) {
  3069. return false;
  3070. }
  3071. return true;
  3072. }
  3073. }
  3074. return false;
  3075. }
  3076. function shouldHydrate(elm) {
  3077. if (elm.nodeType === 9) {
  3078. return true;
  3079. }
  3080. if (NO_HYDRATE_TAGS.has(elm.nodeName)) {
  3081. return false;
  3082. }
  3083. if (elm.hasAttribute("no-prerender")) {
  3084. return false;
  3085. }
  3086. const parentNode = elm.parentNode;
  3087. if (parentNode == null) {
  3088. return true;
  3089. }
  3090. return shouldHydrate(parentNode);
  3091. }
  3092. var NO_HYDRATE_TAGS = /* @__PURE__ */ new Set([
  3093. "CODE",
  3094. "HEAD",
  3095. "IFRAME",
  3096. "INPUT",
  3097. "OBJECT",
  3098. "OUTPUT",
  3099. "NOSCRIPT",
  3100. "PRE",
  3101. "SCRIPT",
  3102. "SELECT",
  3103. "STYLE",
  3104. "TEMPLATE",
  3105. "TEXTAREA"
  3106. ]);
  3107. function renderCatchError(opts, results, err2) {
  3108. const diagnostic = {
  3109. level: "error",
  3110. type: "build",
  3111. header: "Hydrate Error",
  3112. messageText: "",
  3113. relFilePath: void 0,
  3114. absFilePath: void 0,
  3115. lines: []
  3116. };
  3117. if (opts.url) {
  3118. try {
  3119. const u = new URL(opts.url);
  3120. if (u.pathname !== "/") {
  3121. diagnostic.header += ": " + u.pathname;
  3122. }
  3123. } catch (e) {
  3124. }
  3125. }
  3126. if (err2 != null) {
  3127. if (err2.stack != null) {
  3128. diagnostic.messageText = err2.stack.toString();
  3129. } else if (err2.message != null) {
  3130. diagnostic.messageText = err2.message.toString();
  3131. } else {
  3132. diagnostic.messageText = err2.toString();
  3133. }
  3134. }
  3135. results.diagnostics.push(diagnostic);
  3136. }
  3137. function printTag(elm) {
  3138. let tag = `<${elm.nodeName.toLowerCase()}`;
  3139. if (Array.isArray(elm.attributes)) {
  3140. for (let i2 = 0; i2 < elm.attributes.length; i2++) {
  3141. const attr = elm.attributes[i2];
  3142. tag += ` ${attr.name}`;
  3143. if (attr.value !== "") {
  3144. tag += `="${attr.value}"`;
  3145. }
  3146. }
  3147. }
  3148. tag += `>`;
  3149. return tag;
  3150. }
  3151. function waitingOnElementMsg(waitingElement) {
  3152. let msg = "";
  3153. if (waitingElement) {
  3154. const lines = [];
  3155. msg = " - waiting on:";
  3156. let elm = waitingElement;
  3157. while (elm && elm.nodeType !== 9 && elm.nodeName !== "BODY") {
  3158. lines.unshift(printTag(elm));
  3159. elm = elm.parentElement;
  3160. }
  3161. let indent = "";
  3162. for (const ln of lines) {
  3163. indent += " ";
  3164. msg += `
  3165. ${indent}${ln}`;
  3166. }
  3167. }
  3168. return msg;
  3169. }
  3170. function waitingOnElementsMsg(waitingElements) {
  3171. return Array.from(waitingElements).map(waitingOnElementMsg);
  3172. }
  3173. // src/hydrate/platform/index.ts
  3174. import { BUILD as BUILD23, Env, NAMESPACE as NAMESPACE2 } from "@stencil/core/internal/app-data";
  3175. var customError;
  3176. var cmpModules = /* @__PURE__ */ new Map();
  3177. var getModule = (tagName) => {
  3178. if (typeof tagName === "string") {
  3179. tagName = tagName.toLowerCase();
  3180. const cmpModule = cmpModules.get(tagName);
  3181. if (cmpModule != null) {
  3182. return cmpModule[tagName];
  3183. }
  3184. }
  3185. return null;
  3186. };
  3187. var loadModule = (cmpMeta, _hostRef, _hmrVersionId) => {
  3188. return getModule(cmpMeta.$tagName$);
  3189. };
  3190. var isMemberInElement = (elm, memberName) => {
  3191. if (elm != null) {
  3192. if (memberName in elm) {
  3193. return true;
  3194. }
  3195. const cstr = getModule(elm.nodeName);
  3196. if (cstr != null) {
  3197. const hostRef = cstr;
  3198. if (hostRef != null && hostRef.cmpMeta != null && hostRef.cmpMeta.$members$ != null) {
  3199. return memberName in hostRef.cmpMeta.$members$;
  3200. }
  3201. }
  3202. }
  3203. return false;
  3204. };
  3205. var registerComponents = (Cstrs) => {
  3206. for (const Cstr of Cstrs) {
  3207. const exportName = Cstr.cmpMeta.$tagName$;
  3208. cmpModules.set(exportName, {
  3209. [exportName]: Cstr
  3210. });
  3211. }
  3212. };
  3213. var win = window;
  3214. var doc = win.document;
  3215. var readTask = (cb) => {
  3216. nextTick(() => {
  3217. try {
  3218. cb();
  3219. } catch (e) {
  3220. consoleError(e);
  3221. }
  3222. });
  3223. };
  3224. var writeTask = (cb) => {
  3225. nextTick(() => {
  3226. try {
  3227. cb();
  3228. } catch (e) {
  3229. consoleError(e);
  3230. }
  3231. });
  3232. };
  3233. var resolved = /* @__PURE__ */ Promise.resolve();
  3234. var nextTick = (cb) => resolved.then(cb);
  3235. var defaultConsoleError = (e) => {
  3236. if (e != null) {
  3237. console.error(e.stack || e.message || e);
  3238. }
  3239. };
  3240. var consoleError = (e, el) => (customError || defaultConsoleError)(e, el);
  3241. var consoleDevError = (..._) => {
  3242. };
  3243. var consoleDevWarn = (..._) => {
  3244. };
  3245. var consoleDevInfo = (..._) => {
  3246. };
  3247. var setErrorHandler = (handler) => customError = handler;
  3248. var plt = {
  3249. $flags$: 0,
  3250. $resourcesUrl$: "",
  3251. jmp: (h2) => h2(),
  3252. raf: (h2) => requestAnimationFrame(h2),
  3253. ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
  3254. rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
  3255. ce: (eventName, opts) => new win.CustomEvent(eventName, opts)
  3256. };
  3257. var setPlatformHelpers = (helpers) => {
  3258. Object.assign(plt, helpers);
  3259. };
  3260. var supportsShadow = BUILD22.shadowDom;
  3261. var supportsListenerOptions = false;
  3262. var supportsConstructableStylesheets = false;
  3263. var hostRefs = /* @__PURE__ */ new WeakMap();
  3264. var getHostRef = (ref) => hostRefs.get(ref);
  3265. var registerInstance = (lazyInstance, hostRef) => hostRefs.set(hostRef.$lazyInstance$ = lazyInstance, hostRef);
  3266. var registerHost = (elm, cmpMeta) => {
  3267. const hostRef = {
  3268. $flags$: 0,
  3269. $cmpMeta$: cmpMeta,
  3270. $hostElement$: elm,
  3271. $instanceValues$: /* @__PURE__ */ new Map(),
  3272. $renderCount$: 0
  3273. };
  3274. hostRef.$onInstancePromise$ = new Promise((r) => hostRef.$onInstanceResolve$ = r);
  3275. hostRef.$onReadyPromise$ = new Promise((r) => hostRef.$onReadyResolve$ = r);
  3276. elm["s-p"] = [];
  3277. elm["s-rc"] = [];
  3278. return hostRefs.set(elm, hostRef);
  3279. };
  3280. var Build = {
  3281. isDev: false,
  3282. isBrowser: false,
  3283. isServer: true,
  3284. isTesting: false
  3285. };
  3286. var styles = /* @__PURE__ */ new Map();
  3287. var modeResolutionChain = [];
  3288. export {
  3289. BUILD23 as BUILD,
  3290. Build,
  3291. Env,
  3292. Fragment,
  3293. Host,
  3294. NAMESPACE2 as NAMESPACE,
  3295. addHostEventListeners,
  3296. bootstrapLazy,
  3297. cmpModules,
  3298. connectedCallback,
  3299. consoleDevError,
  3300. consoleDevInfo,
  3301. consoleDevWarn,
  3302. consoleError,
  3303. createEvent,
  3304. defineCustomElement,
  3305. disconnectedCallback,
  3306. doc,
  3307. forceModeUpdate,
  3308. forceUpdate,
  3309. getAssetPath,
  3310. getElement,
  3311. getHostRef,
  3312. getMode,
  3313. getRenderingRef,
  3314. getValue,
  3315. hAsync as h,
  3316. hydrateApp,
  3317. insertVdomAnnotations,
  3318. isMemberInElement,
  3319. loadModule,
  3320. modeResolutionChain,
  3321. nextTick,
  3322. parsePropertyValue,
  3323. plt,
  3324. postUpdateComponent,
  3325. proxyComponent,
  3326. proxyCustomElement,
  3327. readTask,
  3328. registerComponents,
  3329. registerHost,
  3330. registerInstance,
  3331. renderVdom,
  3332. setAssetPath,
  3333. setErrorHandler,
  3334. setMode,
  3335. setNonce,
  3336. setPlatformHelpers,
  3337. setValue,
  3338. styles,
  3339. supportsConstructableStylesheets,
  3340. supportsListenerOptions,
  3341. supportsShadow,
  3342. win,
  3343. writeTask
  3344. };