@verdocs/web-sdk 1.0.15 → 1.0.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/dist/cjs/{Content-986f7a13.js → Content-1d98b2f3.js} +297 -17
  2. package/dist/cjs/app-globals-3a1e7e63.js +5 -0
  3. package/dist/cjs/css-shim-88cc6900.js +6 -0
  4. package/dist/cjs/document-status-indicator.cjs.entry.js +1 -1
  5. package/dist/cjs/dom-95afd968.js +75 -0
  6. package/dist/cjs/dropdown-menu.cjs.entry.js +191 -4
  7. package/dist/cjs/index-0b9c3c7d.js +3064 -0
  8. package/dist/cjs/loader.cjs.js +19 -3
  9. package/dist/cjs/org-popup.cjs.entry.js +1 -1
  10. package/dist/cjs/pdf-viewer.cjs.entry.js +87 -6
  11. package/dist/cjs/search-box.cjs.entry.js +19 -7
  12. package/dist/cjs/search-embed.cjs.entry.js +1 -1
  13. package/dist/cjs/search-quick-functions.cjs.entry.js +1 -1
  14. package/dist/cjs/search-recent.cjs.entry.js +2 -2
  15. package/dist/cjs/search-saved.cjs.entry.js +2 -2
  16. package/dist/cjs/search-starred.cjs.entry.js +1 -1
  17. package/dist/cjs/search-tabs.cjs.entry.js +1 -1
  18. package/dist/cjs/shadow-css-71d0f821.js +391 -0
  19. package/dist/cjs/tags-indicator.cjs.entry.js +1 -1
  20. package/dist/cjs/template-card.cjs.entry.js +1 -1
  21. package/dist/cjs/toggle-icon-buttons.cjs.entry.js +1 -1
  22. package/dist/cjs/verdocs-web-sdk.cjs.js +113 -5
  23. package/dist/collection/collection-manifest.json +2 -2
  24. package/dist/collection/components/elements/search-box/search-box.css +4 -0
  25. package/dist/collection/components/elements/search-box/search-box.js +73 -14
  26. package/dist/collection/components/elements/search-box/search-box.stories.js +3 -1
  27. package/dist/custom-elements/index.js +597 -34
  28. package/dist/docs.json +40 -5
  29. package/dist/esm/{Content-386637c8.js → Content-0d614ff3.js} +297 -17
  30. package/dist/esm/app-globals-0f993ce5.js +3 -0
  31. package/dist/esm/css-shim-c64026cd.js +4 -0
  32. package/dist/esm/document-status-indicator.entry.js +1 -1
  33. package/dist/esm/dom-a712b575.js +73 -0
  34. package/dist/esm/dropdown-menu.entry.js +191 -4
  35. package/dist/esm/index-81ec66c1.js +3027 -0
  36. package/dist/esm/loader.js +19 -3
  37. package/dist/esm/org-popup.entry.js +1 -1
  38. package/dist/esm/pdf-viewer.entry.js +87 -6
  39. package/dist/esm/search-box.entry.js +19 -7
  40. package/dist/esm/search-embed.entry.js +1 -1
  41. package/dist/esm/search-quick-functions.entry.js +1 -1
  42. package/dist/esm/search-recent.entry.js +2 -2
  43. package/dist/esm/search-saved.entry.js +2 -2
  44. package/dist/esm/search-starred.entry.js +1 -1
  45. package/dist/esm/search-tabs.entry.js +1 -1
  46. package/dist/esm/shadow-css-1e16431b.js +389 -0
  47. package/dist/esm/tags-indicator.entry.js +1 -1
  48. package/dist/esm/template-card.entry.js +1 -1
  49. package/dist/esm/toggle-icon-buttons.entry.js +1 -1
  50. package/dist/esm/verdocs-web-sdk.js +113 -5
  51. package/dist/esm-es5/Content-0d614ff3.js +1 -0
  52. package/dist/esm-es5/app-globals-0f993ce5.js +1 -0
  53. package/dist/esm-es5/css-shim-c64026cd.js +1 -0
  54. package/dist/esm-es5/document-status-indicator.entry.js +1 -1
  55. package/dist/esm-es5/dom-a712b575.js +21 -0
  56. package/dist/esm-es5/dropdown-menu.entry.js +1 -1
  57. package/dist/esm-es5/index-81ec66c1.js +1 -0
  58. package/dist/esm-es5/loader.js +1 -1
  59. package/dist/esm-es5/org-popup.entry.js +1 -1
  60. package/dist/esm-es5/pdf-viewer.entry.js +2 -2
  61. package/dist/esm-es5/search-box.entry.js +1 -1
  62. package/dist/esm-es5/search-embed.entry.js +1 -1
  63. package/dist/esm-es5/search-quick-functions.entry.js +1 -1
  64. package/dist/esm-es5/search-recent.entry.js +1 -1
  65. package/dist/esm-es5/search-saved.entry.js +1 -1
  66. package/dist/esm-es5/search-starred.entry.js +1 -1
  67. package/dist/esm-es5/search-tabs.entry.js +1 -1
  68. package/dist/esm-es5/shadow-css-1e16431b.js +12 -0
  69. package/dist/esm-es5/tags-indicator.entry.js +1 -1
  70. package/dist/esm-es5/template-card.entry.js +1 -1
  71. package/dist/esm-es5/toggle-icon-buttons.entry.js +1 -1
  72. package/dist/esm-es5/verdocs-web-sdk.js +1 -1
  73. package/dist/types/components/elements/search-box/search-box.d.ts +20 -5
  74. package/dist/types/components/elements/search-box/search-box.stories.d.ts +3 -1
  75. package/dist/types/components.d.ts +23 -1
  76. package/dist/verdocs-web-sdk/Content-0d614ff3.js +2175 -0
  77. package/dist/verdocs-web-sdk/Content-42ddf5ec.system.js +1 -0
  78. package/dist/verdocs-web-sdk/app-globals-0f993ce5.js +3 -0
  79. package/dist/verdocs-web-sdk/app-globals-497eb362.system.js +1 -0
  80. package/dist/verdocs-web-sdk/css-shim-0e9af51a.system.js +1 -0
  81. package/dist/verdocs-web-sdk/css-shim-c64026cd.js +4 -0
  82. package/dist/verdocs-web-sdk/document-status-indicator.entry.js +55 -0
  83. package/dist/verdocs-web-sdk/document-status-indicator.system.entry.js +1 -0
  84. package/dist/verdocs-web-sdk/dom-a712b575.js +73 -0
  85. package/dist/verdocs-web-sdk/dom-f6327147.system.js +21 -0
  86. package/dist/verdocs-web-sdk/dropdown-menu.entry.js +1990 -0
  87. package/dist/verdocs-web-sdk/dropdown-menu.system.entry.js +1 -0
  88. package/dist/verdocs-web-sdk/index-46cb292b.system.js +1 -0
  89. package/dist/verdocs-web-sdk/index-81ec66c1.js +3027 -0
  90. package/dist/verdocs-web-sdk/index.esm.js +1 -0
  91. package/dist/verdocs-web-sdk/{p-50ea2036.system.js → index.system.js} +0 -0
  92. package/dist/verdocs-web-sdk/org-popup.entry.js +21 -0
  93. package/dist/verdocs-web-sdk/org-popup.system.entry.js +1 -0
  94. package/dist/verdocs-web-sdk/pdf-viewer.entry.js +13754 -0
  95. package/dist/verdocs-web-sdk/pdf-viewer.system.entry.js +23 -0
  96. package/dist/verdocs-web-sdk/search-box.entry.js +46 -0
  97. package/dist/verdocs-web-sdk/search-box.system.entry.js +1 -0
  98. package/dist/verdocs-web-sdk/search-embed.entry.js +15 -0
  99. package/dist/verdocs-web-sdk/search-embed.system.entry.js +1 -0
  100. package/dist/verdocs-web-sdk/search-quick-functions.entry.js +27 -0
  101. package/dist/verdocs-web-sdk/search-quick-functions.system.entry.js +1 -0
  102. package/dist/verdocs-web-sdk/search-recent.entry.js +35 -0
  103. package/dist/verdocs-web-sdk/search-recent.system.entry.js +1 -0
  104. package/dist/verdocs-web-sdk/search-saved.entry.js +35 -0
  105. package/dist/verdocs-web-sdk/search-saved.system.entry.js +1 -0
  106. package/dist/verdocs-web-sdk/search-starred.entry.js +42 -0
  107. package/dist/verdocs-web-sdk/search-starred.system.entry.js +1 -0
  108. package/dist/verdocs-web-sdk/search-tabs.entry.js +16 -0
  109. package/dist/verdocs-web-sdk/search-tabs.system.entry.js +1 -0
  110. package/dist/verdocs-web-sdk/shadow-css-1e16431b.js +389 -0
  111. package/dist/verdocs-web-sdk/shadow-css-ef154fe4.system.js +13 -0
  112. package/dist/verdocs-web-sdk/tags-indicator.entry.js +16 -0
  113. package/dist/verdocs-web-sdk/tags-indicator.system.entry.js +1 -0
  114. package/dist/verdocs-web-sdk/template-card.entry.js +24 -0
  115. package/dist/verdocs-web-sdk/template-card.system.entry.js +1 -0
  116. package/dist/verdocs-web-sdk/toggle-icon-buttons.entry.js +28 -0
  117. package/dist/verdocs-web-sdk/toggle-icon-buttons.system.entry.js +1 -0
  118. package/dist/verdocs-web-sdk/verdocs-web-sdk.css +12 -1
  119. package/dist/verdocs-web-sdk/verdocs-web-sdk.esm.js +125 -1
  120. package/dist/verdocs-web-sdk/verdocs-web-sdk.js +1 -1
  121. package/dist/verdocs-web-sdk/verdocs-web-sdk.system.js +1 -0
  122. package/package.json +5 -5
  123. package/dist/cjs/index-e2fb537e.js +0 -1631
  124. package/dist/custom-elements.json +0 -266
  125. package/dist/esm/index-183a8995.js +0 -1602
  126. package/dist/esm-es5/Content-386637c8.js +0 -1
  127. package/dist/esm-es5/index-183a8995.js +0 -1
  128. package/dist/verdocs-web-sdk/p-153879ad.entry.js +0 -1
  129. package/dist/verdocs-web-sdk/p-1d1bc463.system.entry.js +0 -1
  130. package/dist/verdocs-web-sdk/p-29cb7cbc.entry.js +0 -1
  131. package/dist/verdocs-web-sdk/p-2cec77cf.entry.js +0 -1
  132. package/dist/verdocs-web-sdk/p-32a5788a.entry.js +0 -1
  133. package/dist/verdocs-web-sdk/p-33f73371.system.js +0 -1
  134. package/dist/verdocs-web-sdk/p-349248f0.system.entry.js +0 -1
  135. package/dist/verdocs-web-sdk/p-36082c90.entry.js +0 -1
  136. package/dist/verdocs-web-sdk/p-3a032151.entry.js +0 -1
  137. package/dist/verdocs-web-sdk/p-3cc8281f.system.entry.js +0 -1
  138. package/dist/verdocs-web-sdk/p-440d8a73.system.entry.js +0 -1
  139. package/dist/verdocs-web-sdk/p-4d4e090f.system.entry.js +0 -1
  140. package/dist/verdocs-web-sdk/p-55660c24.entry.js +0 -1
  141. package/dist/verdocs-web-sdk/p-63107dd5.system.entry.js +0 -1
  142. package/dist/verdocs-web-sdk/p-6b569aa1.system.entry.js +0 -1
  143. package/dist/verdocs-web-sdk/p-6e033b90.system.entry.js +0 -1
  144. package/dist/verdocs-web-sdk/p-6ee008ff.entry.js +0 -1
  145. package/dist/verdocs-web-sdk/p-7ab216be.system.entry.js +0 -1
  146. package/dist/verdocs-web-sdk/p-7d10b067.system.entry.js +0 -23
  147. package/dist/verdocs-web-sdk/p-89be87e5.js +0 -1
  148. package/dist/verdocs-web-sdk/p-92e7863c.system.entry.js +0 -1
  149. package/dist/verdocs-web-sdk/p-99ebfee7.system.entry.js +0 -1
  150. package/dist/verdocs-web-sdk/p-9af63b8a.system.js +0 -1
  151. package/dist/verdocs-web-sdk/p-9da35744.entry.js +0 -1
  152. package/dist/verdocs-web-sdk/p-b3d5601a.entry.js +0 -1
  153. package/dist/verdocs-web-sdk/p-b466e003.entry.js +0 -1
  154. package/dist/verdocs-web-sdk/p-bb99a203.entry.js +0 -1
  155. package/dist/verdocs-web-sdk/p-cbc784a6.system.js +0 -1
  156. package/dist/verdocs-web-sdk/p-cf030985.js +0 -1
  157. package/dist/verdocs-web-sdk/p-d73f486f.entry.js +0 -23
  158. package/dist/verdocs-web-sdk/p-dea09611.entry.js +0 -1
  159. package/dist/verdocs-web-sdk/p-e34538bd.system.entry.js +0 -1
  160. package/dist/verdocs-web-sdk/p-e59eda0c.system.entry.js +0 -1
@@ -0,0 +1,3027 @@
1
+ const NAMESPACE = 'verdocs-web-sdk';
2
+ const BUILD = /* verdocs-web-sdk */ { allRenderFn: true, appendChildSlotFix: false, asyncLoading: true, asyncQueue: false, attachStyles: true, cloneNodeFix: false, cmpDidLoad: true, cmpDidRender: false, cmpDidUnload: false, cmpDidUpdate: false, cmpShouldUpdate: false, cmpWillLoad: true, cmpWillRender: false, cmpWillUpdate: false, connectedCallback: false, constructableCSS: false, cssAnnotations: true, cssVarShim: false, devTools: true, disconnectedCallback: false, dynamicImportShim: false, element: false, event: true, hasRenderFn: true, hostListener: true, hostListenerTarget: true, hostListenerTargetBody: false, hostListenerTargetDocument: true, hostListenerTargetParent: false, hostListenerTargetWindow: false, hotModuleReplacement: true, hydrateClientSide: false, hydrateServerSide: false, hydratedAttribute: false, hydratedClass: true, initializeNextTick: false, invisiblePrehydration: true, isDebug: false, isDev: true, isTesting: false, lazyLoad: true, lifecycle: true, lifecycleDOMEvents: false, member: true, method: false, mode: false, observeAttribute: true, profile: true, prop: true, propBoolean: true, propMutable: false, propNumber: true, propString: true, reflect: false, safari10: false, scoped: false, scopedSlotTextContentFix: false, scriptDataOpts: false, shadowDelegatesFocus: false, shadowDom: true, shadowDomShim: false, slot: true, slotChildNodesFix: false, slotRelocation: true, state: true, style: true, svg: false, taskQueue: true, transformTagName: false, updatable: true, vdomAttribute: true, vdomClass: true, vdomFunctional: false, vdomKey: true, vdomListener: true, vdomPropOrAttr: true, vdomRef: true, vdomRender: true, vdomStyle: false, vdomText: true, vdomXlink: false, watchCallback: true };
3
+ const Env = /* verdocs-web-sdk */ {};
4
+
5
+ let scopeId;
6
+ let contentRef;
7
+ let hostTagName;
8
+ let customError;
9
+ let i = 0;
10
+ let useNativeShadowDom = false;
11
+ let checkSlotFallbackVisibility = false;
12
+ let checkSlotRelocate = false;
13
+ let isSvgMode = false;
14
+ let renderingRef = null;
15
+ let queueCongestion = 0;
16
+ let queuePending = false;
17
+ const win = typeof window !== 'undefined' ? window : {};
18
+ const CSS = BUILD.cssVarShim ? win.CSS : null;
19
+ const doc = win.document || { head: {} };
20
+ const H = (win.HTMLElement || class {
21
+ });
22
+ const plt = {
23
+ $flags$: 0,
24
+ $resourcesUrl$: '',
25
+ jmp: (h) => h(),
26
+ raf: (h) => requestAnimationFrame(h),
27
+ ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
28
+ rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
29
+ ce: (eventName, opts) => new CustomEvent(eventName, opts),
30
+ };
31
+ const setPlatformHelpers = (helpers) => {
32
+ Object.assign(plt, helpers);
33
+ };
34
+ const supportsShadow = BUILD.shadowDomShim && BUILD.shadowDom
35
+ ? /*@__PURE__*/ (() => (doc.head.attachShadow + '').indexOf('[native') > -1)()
36
+ : true;
37
+ const supportsListenerOptions = /*@__PURE__*/ (() => {
38
+ let supportsListenerOptions = false;
39
+ try {
40
+ doc.addEventListener('e', null, Object.defineProperty({}, 'passive', {
41
+ get() {
42
+ supportsListenerOptions = true;
43
+ },
44
+ }));
45
+ }
46
+ catch (e) { }
47
+ return supportsListenerOptions;
48
+ })();
49
+ const promiseResolve = (v) => Promise.resolve(v);
50
+ const supportsConstructibleStylesheets = BUILD.constructableCSS
51
+ ? /*@__PURE__*/ (() => {
52
+ try {
53
+ new CSSStyleSheet();
54
+ return typeof new CSSStyleSheet().replace === 'function';
55
+ }
56
+ catch (e) { }
57
+ return false;
58
+ })()
59
+ : false;
60
+ const Context = {};
61
+ const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
62
+ if (BUILD.hostListener && listeners) {
63
+ // this is called immediately within the element's constructor
64
+ // initialize our event listeners on the host element
65
+ // we do this now so that we can listen to events that may
66
+ // have fired even before the instance is ready
67
+ if (BUILD.hostListenerTargetParent) {
68
+ // this component may have event listeners that should be attached to the parent
69
+ if (attachParentListeners) {
70
+ // this is being ran from within the connectedCallback
71
+ // which is important so that we know the host element actually has a parent element
72
+ // filter out the listeners to only have the ones that ARE being attached to the parent
73
+ listeners = listeners.filter(([flags]) => flags & 32 /* TargetParent */);
74
+ }
75
+ else {
76
+ // this is being ran from within the component constructor
77
+ // everything BUT the parent element listeners should be attached at this time
78
+ // filter out the listeners that are NOT being attached to the parent
79
+ listeners = listeners.filter(([flags]) => !(flags & 32 /* TargetParent */));
80
+ }
81
+ }
82
+ listeners.map(([flags, name, method]) => {
83
+ const target = BUILD.hostListenerTarget ? getHostListenerTarget(elm, flags) : elm;
84
+ const handler = hostListenerProxy(hostRef, method);
85
+ const opts = hostListenerOpts(flags);
86
+ plt.ael(target, name, handler, opts);
87
+ (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
88
+ });
89
+ }
90
+ };
91
+ const hostListenerProxy = (hostRef, methodName) => (ev) => {
92
+ try {
93
+ if (BUILD.lazyLoad) {
94
+ if (hostRef.$flags$ & 256 /* isListenReady */) {
95
+ // instance is ready, let's call it's member method for this event
96
+ hostRef.$lazyInstance$[methodName](ev);
97
+ }
98
+ else {
99
+ (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
100
+ }
101
+ }
102
+ else {
103
+ hostRef.$hostElement$[methodName](ev);
104
+ }
105
+ }
106
+ catch (e) {
107
+ consoleError(e);
108
+ }
109
+ };
110
+ const getHostListenerTarget = (elm, flags) => {
111
+ if (BUILD.hostListenerTargetDocument && flags & 4 /* TargetDocument */)
112
+ return doc;
113
+ if (BUILD.hostListenerTargetWindow && flags & 8 /* TargetWindow */)
114
+ return win;
115
+ if (BUILD.hostListenerTargetBody && flags & 16 /* TargetBody */)
116
+ return doc.body;
117
+ if (BUILD.hostListenerTargetParent && flags & 32 /* TargetParent */)
118
+ return elm.parentElement;
119
+ return elm;
120
+ };
121
+ // prettier-ignore
122
+ const hostListenerOpts = (flags) => supportsListenerOptions
123
+ ? ({
124
+ passive: (flags & 1 /* Passive */) !== 0,
125
+ capture: (flags & 2 /* Capture */) !== 0,
126
+ })
127
+ : (flags & 2 /* Capture */) !== 0;
128
+ const CONTENT_REF_ID = 'r';
129
+ const ORG_LOCATION_ID = 'o';
130
+ const SLOT_NODE_ID = 's';
131
+ const TEXT_NODE_ID = 't';
132
+ const HYDRATE_ID = 's-id';
133
+ const HYDRATED_STYLE_ID = 'sty-id';
134
+ const HYDRATE_CHILD_ID = 'c-id';
135
+ const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
136
+ const XLINK_NS = 'http://www.w3.org/1999/xlink';
137
+ const createTime = (fnName, tagName = '') => {
138
+ if (BUILD.profile && performance.mark) {
139
+ const key = `st:${fnName}:${tagName}:${i++}`;
140
+ // Start
141
+ performance.mark(key);
142
+ // End
143
+ return () => performance.measure(`[Stencil] ${fnName}() <${tagName}>`, key);
144
+ }
145
+ else {
146
+ return () => {
147
+ return;
148
+ };
149
+ }
150
+ };
151
+ const uniqueTime = (key, measureText) => {
152
+ if (BUILD.profile && performance.mark) {
153
+ if (performance.getEntriesByName(key).length === 0) {
154
+ performance.mark(key);
155
+ }
156
+ return () => {
157
+ if (performance.getEntriesByName(measureText).length === 0) {
158
+ performance.measure(measureText, key);
159
+ }
160
+ };
161
+ }
162
+ else {
163
+ return () => {
164
+ return;
165
+ };
166
+ }
167
+ };
168
+ const inspect = (ref) => {
169
+ const hostRef = getHostRef(ref);
170
+ if (!hostRef) {
171
+ return undefined;
172
+ }
173
+ const flags = hostRef.$flags$;
174
+ const hostElement = hostRef.$hostElement$;
175
+ return {
176
+ renderCount: hostRef.$renderCount$,
177
+ flags: {
178
+ hasRendered: !!(flags & 2 /* hasRendered */),
179
+ hasConnected: !!(flags & 1 /* hasConnected */),
180
+ isWaitingForChildren: !!(flags & 4 /* isWaitingForChildren */),
181
+ isConstructingInstance: !!(flags & 8 /* isConstructingInstance */),
182
+ isQueuedForUpdate: !!(flags & 16 /* isQueuedForUpdate */),
183
+ hasInitializedComponent: !!(flags & 32 /* hasInitializedComponent */),
184
+ hasLoadedComponent: !!(flags & 64 /* hasLoadedComponent */),
185
+ isWatchReady: !!(flags & 128 /* isWatchReady */),
186
+ isListenReady: !!(flags & 256 /* isListenReady */),
187
+ needsRerender: !!(flags & 512 /* needsRerender */),
188
+ },
189
+ instanceValues: hostRef.$instanceValues$,
190
+ ancestorComponent: hostRef.$ancestorComponent$,
191
+ hostElement,
192
+ lazyInstance: hostRef.$lazyInstance$,
193
+ vnode: hostRef.$vnode$,
194
+ modeName: hostRef.$modeName$,
195
+ onReadyPromise: hostRef.$onReadyPromise$,
196
+ onReadyResolve: hostRef.$onReadyResolve$,
197
+ onInstancePromise: hostRef.$onInstancePromise$,
198
+ onInstanceResolve: hostRef.$onInstanceResolve$,
199
+ onRenderResolve: hostRef.$onRenderResolve$,
200
+ queuedListeners: hostRef.$queuedListeners$,
201
+ rmListeners: hostRef.$rmListeners$,
202
+ ['s-id']: hostElement['s-id'],
203
+ ['s-cr']: hostElement['s-cr'],
204
+ ['s-lr']: hostElement['s-lr'],
205
+ ['s-p']: hostElement['s-p'],
206
+ ['s-rc']: hostElement['s-rc'],
207
+ ['s-sc']: hostElement['s-sc'],
208
+ };
209
+ };
210
+ const installDevTools = () => {
211
+ if (BUILD.devTools) {
212
+ const stencil = (win.stencil = win.stencil || {});
213
+ const originalInspect = stencil.inspect;
214
+ stencil.inspect = (ref) => {
215
+ let result = inspect(ref);
216
+ if (!result && typeof originalInspect === 'function') {
217
+ result = originalInspect(ref);
218
+ }
219
+ return result;
220
+ };
221
+ }
222
+ };
223
+ const rootAppliedStyles = new WeakMap();
224
+ const registerStyle = (scopeId, cssText, allowCS) => {
225
+ let style = styles.get(scopeId);
226
+ if (supportsConstructibleStylesheets && allowCS) {
227
+ style = (style || new CSSStyleSheet());
228
+ style.replace(cssText);
229
+ }
230
+ else {
231
+ style = cssText;
232
+ }
233
+ styles.set(scopeId, style);
234
+ };
235
+ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
236
+ let scopeId = getScopeId(cmpMeta, mode);
237
+ let style = styles.get(scopeId);
238
+ if (!BUILD.attachStyles) {
239
+ return scopeId;
240
+ }
241
+ // if an element is NOT connected then getRootNode() will return the wrong root node
242
+ // so the fallback is to always use the document for the root node in those cases
243
+ styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
244
+ if (style) {
245
+ if (typeof style === 'string') {
246
+ styleContainerNode = styleContainerNode.head || styleContainerNode;
247
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
248
+ let styleElm;
249
+ if (!appliedStyles) {
250
+ rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
251
+ }
252
+ if (!appliedStyles.has(scopeId)) {
253
+ if (BUILD.hydrateClientSide &&
254
+ styleContainerNode.host &&
255
+ (styleElm = styleContainerNode.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId}"]`))) {
256
+ // This is only happening on native shadow-dom, do not needs CSS var shim
257
+ styleElm.innerHTML = style;
258
+ }
259
+ else {
260
+ if (BUILD.cssVarShim && plt.$cssShim$) {
261
+ styleElm = plt.$cssShim$.createHostStyle(hostElm, scopeId, style, !!(cmpMeta.$flags$ & 10 /* needsScopedEncapsulation */));
262
+ const newScopeId = styleElm['s-sc'];
263
+ if (newScopeId) {
264
+ scopeId = newScopeId;
265
+ // we don't want to add this styleID to the appliedStyles Set
266
+ // since the cssVarShim might need to apply several different
267
+ // stylesheets for the same component
268
+ appliedStyles = null;
269
+ }
270
+ }
271
+ else {
272
+ styleElm = doc.createElement('style');
273
+ styleElm.innerHTML = style;
274
+ }
275
+ if (BUILD.hydrateServerSide || BUILD.hotModuleReplacement) {
276
+ styleElm.setAttribute(HYDRATED_STYLE_ID, scopeId);
277
+ }
278
+ styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
279
+ }
280
+ if (appliedStyles) {
281
+ appliedStyles.add(scopeId);
282
+ }
283
+ }
284
+ }
285
+ else if (BUILD.constructableCSS && !styleContainerNode.adoptedStyleSheets.includes(style)) {
286
+ styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
287
+ }
288
+ }
289
+ return scopeId;
290
+ };
291
+ const attachStyles = (hostRef) => {
292
+ const cmpMeta = hostRef.$cmpMeta$;
293
+ const elm = hostRef.$hostElement$;
294
+ const flags = cmpMeta.$flags$;
295
+ const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
296
+ const scopeId = addStyle(BUILD.shadowDom && supportsShadow && elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta, hostRef.$modeName$, elm);
297
+ if ((BUILD.shadowDom || BUILD.scoped) && BUILD.cssAnnotations && flags & 10 /* needsScopedEncapsulation */) {
298
+ // only required when we're NOT using native shadow dom (slot)
299
+ // or this browser doesn't support native shadow dom
300
+ // and this host element was NOT created with SSR
301
+ // let's pick out the inner content for slot projection
302
+ // create a node to represent where the original
303
+ // content was first placed, which is useful later on
304
+ // DOM WRITE!!
305
+ elm['s-sc'] = scopeId;
306
+ elm.classList.add(scopeId + '-h');
307
+ if (BUILD.scoped && flags & 2 /* scopedCssEncapsulation */) {
308
+ elm.classList.add(scopeId + '-s');
309
+ }
310
+ }
311
+ endAttachStyles();
312
+ };
313
+ const getScopeId = (cmp, mode) => 'sc-' + (BUILD.mode && mode && cmp.$flags$ & 32 /* hasMode */ ? cmp.$tagName$ + '-' + mode : cmp.$tagName$);
314
+ const convertScopedToShadow = (css) => css.replace(/\/\*!@([^\/]+)\*\/[^\{]+\{/g, '$1{');
315
+ // Private
316
+ const computeMode = (elm) => modeResolutionChain.map((h) => h(elm)).find((m) => !!m);
317
+ // Public
318
+ const setMode = (handler) => modeResolutionChain.push(handler);
319
+ const getMode = (ref) => getHostRef(ref).$modeName$;
320
+ /**
321
+ * Default style mode id
322
+ */
323
+ /**
324
+ * Reusable empty obj/array
325
+ * Don't add values to these!!
326
+ */
327
+ const EMPTY_OBJ = {};
328
+ /**
329
+ * Namespaces
330
+ */
331
+ const SVG_NS = 'http://www.w3.org/2000/svg';
332
+ const HTML_NS = 'http://www.w3.org/1999/xhtml';
333
+ const isDef = (v) => v != null;
334
+ const isComplexType = (o) => {
335
+ // https://jsperf.com/typeof-fn-object/5
336
+ o = typeof o;
337
+ return o === 'object' || o === 'function';
338
+ };
339
+ /**
340
+ * Production h() function based on Preact by
341
+ * Jason Miller (@developit)
342
+ * Licensed under the MIT License
343
+ * https://github.com/developit/preact/blob/master/LICENSE
344
+ *
345
+ * Modified for Stencil's compiler and vdom
346
+ */
347
+ // const stack: any[] = [];
348
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
349
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
350
+ const h = (nodeName, vnodeData, ...children) => {
351
+ let child = null;
352
+ let key = null;
353
+ let slotName = null;
354
+ let simple = false;
355
+ let lastSimple = false;
356
+ let vNodeChildren = [];
357
+ const walk = (c) => {
358
+ for (let i = 0; i < c.length; i++) {
359
+ child = c[i];
360
+ if (Array.isArray(child)) {
361
+ walk(child);
362
+ }
363
+ else if (child != null && typeof child !== 'boolean') {
364
+ if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
365
+ child = String(child);
366
+ }
367
+ else if (BUILD.isDev && typeof nodeName !== 'function' && child.$flags$ === undefined) {
368
+ consoleDevError(`vNode passed as children has unexpected type.
369
+ Make sure it's using the correct h() function.
370
+ Empty objects can also be the cause, look for JSX comments that became objects.`);
371
+ }
372
+ if (simple && lastSimple) {
373
+ // If the previous child was simple (string), we merge both
374
+ vNodeChildren[vNodeChildren.length - 1].$text$ += child;
375
+ }
376
+ else {
377
+ // Append a new vNode, if it's text, we create a text vNode
378
+ vNodeChildren.push(simple ? newVNode(null, child) : child);
379
+ }
380
+ lastSimple = simple;
381
+ }
382
+ }
383
+ };
384
+ walk(children);
385
+ if (vnodeData) {
386
+ if (BUILD.isDev && nodeName === 'input') {
387
+ validateInputProperties(vnodeData);
388
+ }
389
+ // normalize class / classname attributes
390
+ if (BUILD.vdomKey && vnodeData.key) {
391
+ key = vnodeData.key;
392
+ }
393
+ if (BUILD.slotRelocation && vnodeData.name) {
394
+ slotName = vnodeData.name;
395
+ }
396
+ if (BUILD.vdomClass) {
397
+ const classData = vnodeData.className || vnodeData.class;
398
+ if (classData) {
399
+ vnodeData.class =
400
+ typeof classData !== 'object'
401
+ ? classData
402
+ : Object.keys(classData)
403
+ .filter((k) => classData[k])
404
+ .join(' ');
405
+ }
406
+ }
407
+ }
408
+ if (BUILD.isDev && vNodeChildren.some(isHost)) {
409
+ consoleDevError(`The <Host> must be the single root component. Make sure:
410
+ - You are NOT using hostData() and <Host> in the same component.
411
+ - <Host> is used once, and it's the single root component of the render() function.`);
412
+ }
413
+ if (BUILD.vdomFunctional && typeof nodeName === 'function') {
414
+ // nodeName is a functional component
415
+ return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
416
+ }
417
+ const vnode = newVNode(nodeName, null);
418
+ vnode.$attrs$ = vnodeData;
419
+ if (vNodeChildren.length > 0) {
420
+ vnode.$children$ = vNodeChildren;
421
+ }
422
+ if (BUILD.vdomKey) {
423
+ vnode.$key$ = key;
424
+ }
425
+ if (BUILD.slotRelocation) {
426
+ vnode.$name$ = slotName;
427
+ }
428
+ return vnode;
429
+ };
430
+ const newVNode = (tag, text) => {
431
+ const vnode = {
432
+ $flags$: 0,
433
+ $tag$: tag,
434
+ $text$: text,
435
+ $elm$: null,
436
+ $children$: null,
437
+ };
438
+ if (BUILD.vdomAttribute) {
439
+ vnode.$attrs$ = null;
440
+ }
441
+ if (BUILD.vdomKey) {
442
+ vnode.$key$ = null;
443
+ }
444
+ if (BUILD.slotRelocation) {
445
+ vnode.$name$ = null;
446
+ }
447
+ return vnode;
448
+ };
449
+ const Host = {};
450
+ const isHost = (node) => node && node.$tag$ === Host;
451
+ const vdomFnUtils = {
452
+ forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
453
+ map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate),
454
+ };
455
+ const convertToPublic = (node) => ({
456
+ vattrs: node.$attrs$,
457
+ vchildren: node.$children$,
458
+ vkey: node.$key$,
459
+ vname: node.$name$,
460
+ vtag: node.$tag$,
461
+ vtext: node.$text$,
462
+ });
463
+ const convertToPrivate = (node) => {
464
+ if (typeof node.vtag === 'function') {
465
+ const vnodeData = Object.assign({}, node.vattrs);
466
+ if (node.vkey) {
467
+ vnodeData.key = node.vkey;
468
+ }
469
+ if (node.vname) {
470
+ vnodeData.name = node.vname;
471
+ }
472
+ return h(node.vtag, vnodeData, ...(node.vchildren || []));
473
+ }
474
+ const vnode = newVNode(node.vtag, node.vtext);
475
+ vnode.$attrs$ = node.vattrs;
476
+ vnode.$children$ = node.vchildren;
477
+ vnode.$key$ = node.vkey;
478
+ vnode.$name$ = node.vname;
479
+ return vnode;
480
+ };
481
+ const validateInputProperties = (vnodeData) => {
482
+ const props = Object.keys(vnodeData);
483
+ const typeIndex = props.indexOf('type');
484
+ const minIndex = props.indexOf('min');
485
+ const maxIndex = props.indexOf('max');
486
+ const stepIndex = props.indexOf('min');
487
+ const value = props.indexOf('value');
488
+ if (value === -1) {
489
+ return;
490
+ }
491
+ if (value < typeIndex || value < minIndex || value < maxIndex || value < stepIndex) {
492
+ consoleDevWarn(`The "value" prop of <input> should be set after "min", "max", "type" and "step"`);
493
+ }
494
+ };
495
+ /**
496
+ * Production setAccessor() function based on Preact by
497
+ * Jason Miller (@developit)
498
+ * Licensed under the MIT License
499
+ * https://github.com/developit/preact/blob/master/LICENSE
500
+ *
501
+ * Modified for Stencil's compiler and vdom
502
+ */
503
+ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
504
+ if (oldValue !== newValue) {
505
+ let isProp = isMemberInElement(elm, memberName);
506
+ let ln = memberName.toLowerCase();
507
+ if (BUILD.vdomClass && memberName === 'class') {
508
+ const classList = elm.classList;
509
+ const oldClasses = parseClassList(oldValue);
510
+ const newClasses = parseClassList(newValue);
511
+ classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
512
+ classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
513
+ }
514
+ else if (BUILD.vdomStyle && memberName === 'style') {
515
+ // update style attribute, css properties and values
516
+ if (BUILD.updatable) {
517
+ for (const prop in oldValue) {
518
+ if (!newValue || newValue[prop] == null) {
519
+ if (!BUILD.hydrateServerSide && prop.includes('-')) {
520
+ elm.style.removeProperty(prop);
521
+ }
522
+ else {
523
+ elm.style[prop] = '';
524
+ }
525
+ }
526
+ }
527
+ }
528
+ for (const prop in newValue) {
529
+ if (!oldValue || newValue[prop] !== oldValue[prop]) {
530
+ if (!BUILD.hydrateServerSide && prop.includes('-')) {
531
+ elm.style.setProperty(prop, newValue[prop]);
532
+ }
533
+ else {
534
+ elm.style[prop] = newValue[prop];
535
+ }
536
+ }
537
+ }
538
+ }
539
+ else if (BUILD.vdomKey && memberName === 'key')
540
+ ;
541
+ else if (BUILD.vdomRef && memberName === 'ref') {
542
+ // minifier will clean this up
543
+ if (newValue) {
544
+ newValue(elm);
545
+ }
546
+ }
547
+ else if (BUILD.vdomListener &&
548
+ (BUILD.lazyLoad ? !isProp : !elm.__lookupSetter__(memberName)) &&
549
+ memberName[0] === 'o' &&
550
+ memberName[1] === 'n') {
551
+ // Event Handlers
552
+ // so if the member name starts with "on" and the 3rd characters is
553
+ // a capital letter, and it's not already a member on the element,
554
+ // then we're assuming it's an event listener
555
+ if (memberName[2] === '-') {
556
+ // on- prefixed events
557
+ // allows to be explicit about the dom event to listen without any magic
558
+ // under the hood:
559
+ // <my-cmp on-click> // listens for "click"
560
+ // <my-cmp on-Click> // listens for "Click"
561
+ // <my-cmp on-ionChange> // listens for "ionChange"
562
+ // <my-cmp on-EVENTS> // listens for "EVENTS"
563
+ memberName = memberName.slice(3);
564
+ }
565
+ else if (isMemberInElement(win, ln)) {
566
+ // standard event
567
+ // the JSX attribute could have been "onMouseOver" and the
568
+ // member name "onmouseover" is on the window's prototype
569
+ // so let's add the listener "mouseover", which is all lowercased
570
+ memberName = ln.slice(2);
571
+ }
572
+ else {
573
+ // custom event
574
+ // the JSX attribute could have been "onMyCustomEvent"
575
+ // so let's trim off the "on" prefix and lowercase the first character
576
+ // and add the listener "myCustomEvent"
577
+ // except for the first character, we keep the event name case
578
+ memberName = ln[2] + memberName.slice(3);
579
+ }
580
+ if (oldValue) {
581
+ plt.rel(elm, memberName, oldValue, false);
582
+ }
583
+ if (newValue) {
584
+ plt.ael(elm, memberName, newValue, false);
585
+ }
586
+ }
587
+ else if (BUILD.vdomPropOrAttr) {
588
+ // Set property if it exists and it's not a SVG
589
+ const isComplex = isComplexType(newValue);
590
+ if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
591
+ try {
592
+ if (!elm.tagName.includes('-')) {
593
+ let n = newValue == null ? '' : newValue;
594
+ // Workaround for Safari, moving the <input> caret when re-assigning the same valued
595
+ if (memberName === 'list') {
596
+ isProp = false;
597
+ }
598
+ else if (oldValue == null || elm[memberName] != n) {
599
+ elm[memberName] = n;
600
+ }
601
+ }
602
+ else {
603
+ elm[memberName] = newValue;
604
+ }
605
+ }
606
+ catch (e) { }
607
+ }
608
+ /**
609
+ * Need to manually update attribute if:
610
+ * - memberName is not an attribute
611
+ * - if we are rendering the host element in order to reflect attribute
612
+ * - if it's a SVG, since properties might not work in <svg>
613
+ * - if the newValue is null/undefined or 'false'.
614
+ */
615
+ let xlink = false;
616
+ if (BUILD.vdomXlink) {
617
+ if (ln !== (ln = ln.replace(/^xlink\:?/, ''))) {
618
+ memberName = ln;
619
+ xlink = true;
620
+ }
621
+ }
622
+ if (newValue == null || newValue === false) {
623
+ if (newValue !== false || elm.getAttribute(memberName) === '') {
624
+ if (BUILD.vdomXlink && xlink) {
625
+ elm.removeAttributeNS(XLINK_NS, memberName);
626
+ }
627
+ else {
628
+ elm.removeAttribute(memberName);
629
+ }
630
+ }
631
+ }
632
+ else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
633
+ newValue = newValue === true ? '' : newValue;
634
+ if (BUILD.vdomXlink && xlink) {
635
+ elm.setAttributeNS(XLINK_NS, memberName, newValue);
636
+ }
637
+ else {
638
+ elm.setAttribute(memberName, newValue);
639
+ }
640
+ }
641
+ }
642
+ }
643
+ };
644
+ const parseClassListRegex = /\s/;
645
+ const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
646
+ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
647
+ // if the element passed in is a shadow root, which is a document fragment
648
+ // then we want to be adding attrs/props to the shadow root's "host" element
649
+ // if it's not a shadow root, then we add attrs/props to the same element
650
+ const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host
651
+ ? newVnode.$elm$.host
652
+ : newVnode.$elm$;
653
+ const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
654
+ const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
655
+ if (BUILD.updatable) {
656
+ // remove attributes no longer present on the vnode by setting them to undefined
657
+ for (memberName in oldVnodeAttrs) {
658
+ if (!(memberName in newVnodeAttrs)) {
659
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
660
+ }
661
+ }
662
+ }
663
+ // add new & update changed attributes
664
+ for (memberName in newVnodeAttrs) {
665
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
666
+ }
667
+ };
668
+ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
669
+ // tslint:disable-next-line: prefer-const
670
+ let newVNode = newParentVNode.$children$[childIndex];
671
+ let i = 0;
672
+ let elm;
673
+ let childNode;
674
+ let oldVNode;
675
+ if (BUILD.slotRelocation && !useNativeShadowDom) {
676
+ // remember for later we need to check to relocate nodes
677
+ checkSlotRelocate = true;
678
+ if (newVNode.$tag$ === 'slot') {
679
+ if (scopeId) {
680
+ // scoped css needs to add its scoped id to the parent element
681
+ parentElm.classList.add(scopeId + '-s');
682
+ }
683
+ newVNode.$flags$ |= newVNode.$children$
684
+ ? // slot element has fallback content
685
+ 2 /* isSlotFallback */
686
+ : // slot element does not have fallback content
687
+ 1 /* isSlotReference */;
688
+ }
689
+ }
690
+ if (BUILD.isDev && newVNode.$elm$) {
691
+ consoleDevError(`The JSX ${newVNode.$text$ !== null ? `"${newVNode.$text$}" text` : `"${newVNode.$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`);
692
+ }
693
+ if (BUILD.vdomText && newVNode.$text$ !== null) {
694
+ // create text node
695
+ elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
696
+ }
697
+ else if (BUILD.slotRelocation && newVNode.$flags$ & 1 /* isSlotReference */) {
698
+ // create a slot reference node
699
+ elm = newVNode.$elm$ =
700
+ BUILD.isDebug || BUILD.hydrateServerSide ? slotReferenceDebugNode(newVNode) : doc.createTextNode('');
701
+ }
702
+ else {
703
+ if (BUILD.svg && !isSvgMode) {
704
+ isSvgMode = newVNode.$tag$ === 'svg';
705
+ }
706
+ // create element
707
+ elm = newVNode.$elm$ = (BUILD.svg
708
+ ? doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, BUILD.slotRelocation && newVNode.$flags$ & 2 /* isSlotFallback */
709
+ ? 'slot-fb'
710
+ : newVNode.$tag$)
711
+ : doc.createElement(BUILD.slotRelocation && newVNode.$flags$ & 2 /* isSlotFallback */
712
+ ? 'slot-fb'
713
+ : newVNode.$tag$));
714
+ if (BUILD.svg && isSvgMode && newVNode.$tag$ === 'foreignObject') {
715
+ isSvgMode = false;
716
+ }
717
+ // add css classes, attrs, props, listeners, etc.
718
+ if (BUILD.vdomAttribute) {
719
+ updateElement(null, newVNode, isSvgMode);
720
+ }
721
+ if ((BUILD.shadowDom || BUILD.scoped) && isDef(scopeId) && elm['s-si'] !== scopeId) {
722
+ // if there is a scopeId and this is the initial render
723
+ // then let's add the scopeId as a css class
724
+ elm.classList.add((elm['s-si'] = scopeId));
725
+ }
726
+ if (newVNode.$children$) {
727
+ for (i = 0; i < newVNode.$children$.length; ++i) {
728
+ // create the node
729
+ childNode = createElm(oldParentVNode, newVNode, i, elm);
730
+ // return node could have been null
731
+ if (childNode) {
732
+ // append our new node
733
+ elm.appendChild(childNode);
734
+ }
735
+ }
736
+ }
737
+ if (BUILD.svg) {
738
+ if (newVNode.$tag$ === 'svg') {
739
+ // Only reset the SVG context when we're exiting <svg> element
740
+ isSvgMode = false;
741
+ }
742
+ else if (elm.tagName === 'foreignObject') {
743
+ // Reenter SVG context when we're exiting <foreignObject> element
744
+ isSvgMode = true;
745
+ }
746
+ }
747
+ }
748
+ if (BUILD.slotRelocation) {
749
+ elm['s-hn'] = hostTagName;
750
+ if (newVNode.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
751
+ // remember the content reference comment
752
+ elm['s-sr'] = true;
753
+ // remember the content reference comment
754
+ elm['s-cr'] = contentRef;
755
+ // remember the slot name, or empty string for default slot
756
+ elm['s-sn'] = newVNode.$name$ || '';
757
+ // check if we've got an old vnode for this slot
758
+ oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
759
+ if (oldVNode && oldVNode.$tag$ === newVNode.$tag$ && oldParentVNode.$elm$) {
760
+ // we've got an old slot vnode and the wrapper is being replaced
761
+ // so let's move the old slot content back to it's original location
762
+ putBackInOriginalLocation(oldParentVNode.$elm$, false);
763
+ }
764
+ }
765
+ }
766
+ return elm;
767
+ };
768
+ const putBackInOriginalLocation = (parentElm, recursive) => {
769
+ plt.$flags$ |= 1 /* isTmpDisconnected */;
770
+ const oldSlotChildNodes = parentElm.childNodes;
771
+ for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
772
+ const childNode = oldSlotChildNodes[i];
773
+ if (childNode['s-hn'] !== hostTagName && childNode['s-ol']) {
774
+ // // this child node in the old element is from another component
775
+ // // remove this node from the old slot's parent
776
+ // childNode.remove();
777
+ // and relocate it back to it's original location
778
+ parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
779
+ // remove the old original location comment entirely
780
+ // later on the patch function will know what to do
781
+ // and move this to the correct spot in need be
782
+ childNode['s-ol'].remove();
783
+ childNode['s-ol'] = undefined;
784
+ checkSlotRelocate = true;
785
+ }
786
+ if (recursive) {
787
+ putBackInOriginalLocation(childNode, recursive);
788
+ }
789
+ }
790
+ plt.$flags$ &= ~1 /* isTmpDisconnected */;
791
+ };
792
+ const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
793
+ let containerElm = ((BUILD.slotRelocation && parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
794
+ let childNode;
795
+ if (BUILD.shadowDom && containerElm.shadowRoot && containerElm.tagName === hostTagName) {
796
+ containerElm = containerElm.shadowRoot;
797
+ }
798
+ for (; startIdx <= endIdx; ++startIdx) {
799
+ if (vnodes[startIdx]) {
800
+ childNode = createElm(null, parentVNode, startIdx, parentElm);
801
+ if (childNode) {
802
+ vnodes[startIdx].$elm$ = childNode;
803
+ containerElm.insertBefore(childNode, BUILD.slotRelocation ? referenceNode(before) : before);
804
+ }
805
+ }
806
+ }
807
+ };
808
+ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
809
+ for (; startIdx <= endIdx; ++startIdx) {
810
+ if ((vnode = vnodes[startIdx])) {
811
+ elm = vnode.$elm$;
812
+ callNodeRefs(vnode);
813
+ if (BUILD.slotRelocation) {
814
+ // we're removing this element
815
+ // so it's possible we need to show slot fallback content now
816
+ checkSlotFallbackVisibility = true;
817
+ if (elm['s-ol']) {
818
+ // remove the original location comment
819
+ elm['s-ol'].remove();
820
+ }
821
+ else {
822
+ // it's possible that child nodes of the node
823
+ // that's being removed are slot nodes
824
+ putBackInOriginalLocation(elm, true);
825
+ }
826
+ }
827
+ // remove the vnode's element from the dom
828
+ elm.remove();
829
+ }
830
+ }
831
+ };
832
+ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
833
+ let oldStartIdx = 0;
834
+ let newStartIdx = 0;
835
+ let idxInOld = 0;
836
+ let i = 0;
837
+ let oldEndIdx = oldCh.length - 1;
838
+ let oldStartVnode = oldCh[0];
839
+ let oldEndVnode = oldCh[oldEndIdx];
840
+ let newEndIdx = newCh.length - 1;
841
+ let newStartVnode = newCh[0];
842
+ let newEndVnode = newCh[newEndIdx];
843
+ let node;
844
+ let elmToMove;
845
+ while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
846
+ if (oldStartVnode == null) {
847
+ // Vnode might have been moved left
848
+ oldStartVnode = oldCh[++oldStartIdx];
849
+ }
850
+ else if (oldEndVnode == null) {
851
+ oldEndVnode = oldCh[--oldEndIdx];
852
+ }
853
+ else if (newStartVnode == null) {
854
+ newStartVnode = newCh[++newStartIdx];
855
+ }
856
+ else if (newEndVnode == null) {
857
+ newEndVnode = newCh[--newEndIdx];
858
+ }
859
+ else if (isSameVnode(oldStartVnode, newStartVnode)) {
860
+ patch(oldStartVnode, newStartVnode);
861
+ oldStartVnode = oldCh[++oldStartIdx];
862
+ newStartVnode = newCh[++newStartIdx];
863
+ }
864
+ else if (isSameVnode(oldEndVnode, newEndVnode)) {
865
+ patch(oldEndVnode, newEndVnode);
866
+ oldEndVnode = oldCh[--oldEndIdx];
867
+ newEndVnode = newCh[--newEndIdx];
868
+ }
869
+ else if (isSameVnode(oldStartVnode, newEndVnode)) {
870
+ // Vnode moved right
871
+ if (BUILD.slotRelocation && (oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
872
+ putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
873
+ }
874
+ patch(oldStartVnode, newEndVnode);
875
+ parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
876
+ oldStartVnode = oldCh[++oldStartIdx];
877
+ newEndVnode = newCh[--newEndIdx];
878
+ }
879
+ else if (isSameVnode(oldEndVnode, newStartVnode)) {
880
+ // Vnode moved left
881
+ if (BUILD.slotRelocation && (oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
882
+ putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
883
+ }
884
+ patch(oldEndVnode, newStartVnode);
885
+ parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
886
+ oldEndVnode = oldCh[--oldEndIdx];
887
+ newStartVnode = newCh[++newStartIdx];
888
+ }
889
+ else {
890
+ // createKeyToOldIdx
891
+ idxInOld = -1;
892
+ if (BUILD.vdomKey) {
893
+ for (i = oldStartIdx; i <= oldEndIdx; ++i) {
894
+ if (oldCh[i] && oldCh[i].$key$ !== null && oldCh[i].$key$ === newStartVnode.$key$) {
895
+ idxInOld = i;
896
+ break;
897
+ }
898
+ }
899
+ }
900
+ if (BUILD.vdomKey && idxInOld >= 0) {
901
+ elmToMove = oldCh[idxInOld];
902
+ if (elmToMove.$tag$ !== newStartVnode.$tag$) {
903
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld, parentElm);
904
+ }
905
+ else {
906
+ patch(elmToMove, newStartVnode);
907
+ oldCh[idxInOld] = undefined;
908
+ node = elmToMove.$elm$;
909
+ }
910
+ newStartVnode = newCh[++newStartIdx];
911
+ }
912
+ else {
913
+ // new element
914
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx, parentElm);
915
+ newStartVnode = newCh[++newStartIdx];
916
+ }
917
+ if (node) {
918
+ if (BUILD.slotRelocation) {
919
+ parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
920
+ }
921
+ else {
922
+ oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
923
+ }
924
+ }
925
+ }
926
+ }
927
+ if (oldStartIdx > oldEndIdx) {
928
+ addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
929
+ }
930
+ else if (BUILD.updatable && newStartIdx > newEndIdx) {
931
+ removeVnodes(oldCh, oldStartIdx, oldEndIdx);
932
+ }
933
+ };
934
+ const isSameVnode = (vnode1, vnode2) => {
935
+ // compare if two vnode to see if they're "technically" the same
936
+ // need to have the same element tag, and same key to be the same
937
+ if (vnode1.$tag$ === vnode2.$tag$) {
938
+ if (BUILD.slotRelocation && vnode1.$tag$ === 'slot') {
939
+ return vnode1.$name$ === vnode2.$name$;
940
+ }
941
+ if (BUILD.vdomKey) {
942
+ return vnode1.$key$ === vnode2.$key$;
943
+ }
944
+ return true;
945
+ }
946
+ return false;
947
+ };
948
+ const referenceNode = (node) => {
949
+ // this node was relocated to a new location in the dom
950
+ // because of some other component's slot
951
+ // but we still have an html comment in place of where
952
+ // it's original location was according to it's original vdom
953
+ return (node && node['s-ol']) || node;
954
+ };
955
+ const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
956
+ const patch = (oldVNode, newVNode) => {
957
+ const elm = (newVNode.$elm$ = oldVNode.$elm$);
958
+ const oldChildren = oldVNode.$children$;
959
+ const newChildren = newVNode.$children$;
960
+ const tag = newVNode.$tag$;
961
+ const text = newVNode.$text$;
962
+ let defaultHolder;
963
+ if (!BUILD.vdomText || text === null) {
964
+ if (BUILD.svg) {
965
+ // test if we're rendering an svg element, or still rendering nodes inside of one
966
+ // only add this to the when the compiler sees we're using an svg somewhere
967
+ isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
968
+ }
969
+ // element node
970
+ if (BUILD.vdomAttribute || BUILD.reflect) {
971
+ if (BUILD.slot && tag === 'slot')
972
+ ;
973
+ else {
974
+ // either this is the first render of an element OR it's an update
975
+ // AND we already know it's possible it could have changed
976
+ // this updates the element's css classes, attrs, props, listeners, etc.
977
+ updateElement(oldVNode, newVNode, isSvgMode);
978
+ }
979
+ }
980
+ if (BUILD.updatable && oldChildren !== null && newChildren !== null) {
981
+ // looks like there's child vnodes for both the old and new vnodes
982
+ updateChildren(elm, oldChildren, newVNode, newChildren);
983
+ }
984
+ else if (newChildren !== null) {
985
+ // no old child vnodes, but there are new child vnodes to add
986
+ if (BUILD.updatable && BUILD.vdomText && oldVNode.$text$ !== null) {
987
+ // the old vnode was text, so be sure to clear it out
988
+ elm.textContent = '';
989
+ }
990
+ // add the new vnode children
991
+ addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
992
+ }
993
+ else if (BUILD.updatable && oldChildren !== null) {
994
+ // no new child vnodes, but there are old child vnodes to remove
995
+ removeVnodes(oldChildren, 0, oldChildren.length - 1);
996
+ }
997
+ if (BUILD.svg && isSvgMode && tag === 'svg') {
998
+ isSvgMode = false;
999
+ }
1000
+ }
1001
+ else if (BUILD.vdomText && BUILD.slotRelocation && (defaultHolder = elm['s-cr'])) {
1002
+ // this element has slotted content
1003
+ defaultHolder.parentNode.textContent = text;
1004
+ }
1005
+ else if (BUILD.vdomText && oldVNode.$text$ !== text) {
1006
+ // update the text content for the text only vnode
1007
+ // and also only if the text is different than before
1008
+ elm.data = text;
1009
+ }
1010
+ };
1011
+ const updateFallbackSlotVisibility = (elm) => {
1012
+ // tslint:disable-next-line: prefer-const
1013
+ let childNodes = elm.childNodes;
1014
+ let childNode;
1015
+ let i;
1016
+ let ilen;
1017
+ let j;
1018
+ let slotNameAttr;
1019
+ let nodeType;
1020
+ for (i = 0, ilen = childNodes.length; i < ilen; i++) {
1021
+ childNode = childNodes[i];
1022
+ if (childNode.nodeType === 1 /* ElementNode */) {
1023
+ if (childNode['s-sr']) {
1024
+ // this is a slot fallback node
1025
+ // get the slot name for this slot reference node
1026
+ slotNameAttr = childNode['s-sn'];
1027
+ // by default always show a fallback slot node
1028
+ // then hide it if there are other slots in the light dom
1029
+ childNode.hidden = false;
1030
+ for (j = 0; j < ilen; j++) {
1031
+ nodeType = childNodes[j].nodeType;
1032
+ if (childNodes[j]['s-hn'] !== childNode['s-hn'] || slotNameAttr !== '') {
1033
+ // this sibling node is from a different component OR is a named fallback slot node
1034
+ if (nodeType === 1 /* ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
1035
+ childNode.hidden = true;
1036
+ break;
1037
+ }
1038
+ }
1039
+ else {
1040
+ // this is a default fallback slot node
1041
+ // any element or text node (with content)
1042
+ // should hide the default fallback slot node
1043
+ if (nodeType === 1 /* ElementNode */ ||
1044
+ (nodeType === 3 /* TextNode */ && childNodes[j].textContent.trim() !== '')) {
1045
+ childNode.hidden = true;
1046
+ break;
1047
+ }
1048
+ }
1049
+ }
1050
+ }
1051
+ // keep drilling down
1052
+ updateFallbackSlotVisibility(childNode);
1053
+ }
1054
+ }
1055
+ };
1056
+ const relocateNodes = [];
1057
+ const relocateSlotContent = (elm) => {
1058
+ // tslint:disable-next-line: prefer-const
1059
+ let childNode;
1060
+ let node;
1061
+ let hostContentNodes;
1062
+ let slotNameAttr;
1063
+ let relocateNodeData;
1064
+ let j;
1065
+ let i = 0;
1066
+ let childNodes = elm.childNodes;
1067
+ let ilen = childNodes.length;
1068
+ for (; i < ilen; i++) {
1069
+ childNode = childNodes[i];
1070
+ if (childNode['s-sr'] && (node = childNode['s-cr']) && node.parentNode) {
1071
+ // first got the content reference comment node
1072
+ // then we got it's parent, which is where all the host content is in now
1073
+ hostContentNodes = node.parentNode.childNodes;
1074
+ slotNameAttr = childNode['s-sn'];
1075
+ for (j = hostContentNodes.length - 1; j >= 0; j--) {
1076
+ node = hostContentNodes[j];
1077
+ if (!node['s-cn'] && !node['s-nr'] && node['s-hn'] !== childNode['s-hn']) {
1078
+ // let's do some relocating to its new home
1079
+ // but never relocate a content reference node
1080
+ // that is suppose to always represent the original content location
1081
+ if (isNodeLocatedInSlot(node, slotNameAttr)) {
1082
+ // it's possible we've already decided to relocate this node
1083
+ relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
1084
+ // made some changes to slots
1085
+ // let's make sure we also double check
1086
+ // fallbacks are correctly hidden or shown
1087
+ checkSlotFallbackVisibility = true;
1088
+ node['s-sn'] = node['s-sn'] || slotNameAttr;
1089
+ if (relocateNodeData) {
1090
+ // previously we never found a slot home for this node
1091
+ // but turns out we did, so let's remember it now
1092
+ relocateNodeData.$slotRefNode$ = childNode;
1093
+ }
1094
+ else {
1095
+ // add to our list of nodes to relocate
1096
+ relocateNodes.push({
1097
+ $slotRefNode$: childNode,
1098
+ $nodeToRelocate$: node,
1099
+ });
1100
+ }
1101
+ if (node['s-sr']) {
1102
+ relocateNodes.map((relocateNode) => {
1103
+ if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node['s-sn'])) {
1104
+ relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
1105
+ if (relocateNodeData && !relocateNode.$slotRefNode$) {
1106
+ relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
1107
+ }
1108
+ }
1109
+ });
1110
+ }
1111
+ }
1112
+ else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
1113
+ // so far this element does not have a slot home, not setting slotRefNode on purpose
1114
+ // if we never find a home for this element then we'll need to hide it
1115
+ relocateNodes.push({
1116
+ $nodeToRelocate$: node,
1117
+ });
1118
+ }
1119
+ }
1120
+ }
1121
+ }
1122
+ if (childNode.nodeType === 1 /* ElementNode */) {
1123
+ relocateSlotContent(childNode);
1124
+ }
1125
+ }
1126
+ };
1127
+ const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
1128
+ if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
1129
+ if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
1130
+ return true;
1131
+ }
1132
+ if (nodeToRelocate.getAttribute('slot') === slotNameAttr) {
1133
+ return true;
1134
+ }
1135
+ return false;
1136
+ }
1137
+ if (nodeToRelocate['s-sn'] === slotNameAttr) {
1138
+ return true;
1139
+ }
1140
+ return slotNameAttr === '';
1141
+ };
1142
+ const callNodeRefs = (vNode) => {
1143
+ if (BUILD.vdomRef) {
1144
+ vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
1145
+ vNode.$children$ && vNode.$children$.map(callNodeRefs);
1146
+ }
1147
+ };
1148
+ const renderVdom = (hostRef, renderFnResults) => {
1149
+ const hostElm = hostRef.$hostElement$;
1150
+ const cmpMeta = hostRef.$cmpMeta$;
1151
+ const oldVNode = hostRef.$vnode$ || newVNode(null, null);
1152
+ const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
1153
+ hostTagName = hostElm.tagName;
1154
+ // <Host> runtime check
1155
+ if (BUILD.isDev && Array.isArray(renderFnResults) && renderFnResults.some(isHost)) {
1156
+ throw new Error(`The <Host> must be the single root component.
1157
+ Looks like the render() function of "${hostTagName.toLowerCase()}" is returning an array that contains the <Host>.
1158
+
1159
+ The render() function should look like this instead:
1160
+
1161
+ render() {
1162
+ // Do not return an array
1163
+ return (
1164
+ <Host>{content}</Host>
1165
+ );
1166
+ }
1167
+ `);
1168
+ }
1169
+ if (BUILD.reflect && cmpMeta.$attrsToReflect$) {
1170
+ rootVnode.$attrs$ = rootVnode.$attrs$ || {};
1171
+ cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
1172
+ }
1173
+ rootVnode.$tag$ = null;
1174
+ rootVnode.$flags$ |= 4 /* isHost */;
1175
+ hostRef.$vnode$ = rootVnode;
1176
+ rootVnode.$elm$ = oldVNode.$elm$ = (BUILD.shadowDom ? hostElm.shadowRoot || hostElm : hostElm);
1177
+ if (BUILD.scoped || BUILD.shadowDom) {
1178
+ scopeId = hostElm['s-sc'];
1179
+ }
1180
+ if (BUILD.slotRelocation) {
1181
+ contentRef = hostElm['s-cr'];
1182
+ useNativeShadowDom = supportsShadow && (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) !== 0;
1183
+ // always reset
1184
+ checkSlotFallbackVisibility = false;
1185
+ }
1186
+ // synchronous patch
1187
+ patch(oldVNode, rootVnode);
1188
+ if (BUILD.slotRelocation) {
1189
+ // while we're moving nodes around existing nodes, temporarily disable
1190
+ // the disconnectCallback from working
1191
+ plt.$flags$ |= 1 /* isTmpDisconnected */;
1192
+ if (checkSlotRelocate) {
1193
+ relocateSlotContent(rootVnode.$elm$);
1194
+ let relocateData;
1195
+ let nodeToRelocate;
1196
+ let orgLocationNode;
1197
+ let parentNodeRef;
1198
+ let insertBeforeNode;
1199
+ let refNode;
1200
+ let i = 0;
1201
+ for (; i < relocateNodes.length; i++) {
1202
+ relocateData = relocateNodes[i];
1203
+ nodeToRelocate = relocateData.$nodeToRelocate$;
1204
+ if (!nodeToRelocate['s-ol']) {
1205
+ // add a reference node marking this node's original location
1206
+ // keep a reference to this node for later lookups
1207
+ orgLocationNode =
1208
+ BUILD.isDebug || BUILD.hydrateServerSide
1209
+ ? originalLocationDebugNode(nodeToRelocate)
1210
+ : doc.createTextNode('');
1211
+ orgLocationNode['s-nr'] = nodeToRelocate;
1212
+ nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
1213
+ }
1214
+ }
1215
+ for (i = 0; i < relocateNodes.length; i++) {
1216
+ relocateData = relocateNodes[i];
1217
+ nodeToRelocate = relocateData.$nodeToRelocate$;
1218
+ if (relocateData.$slotRefNode$) {
1219
+ // by default we're just going to insert it directly
1220
+ // after the slot reference node
1221
+ parentNodeRef = relocateData.$slotRefNode$.parentNode;
1222
+ insertBeforeNode = relocateData.$slotRefNode$.nextSibling;
1223
+ orgLocationNode = nodeToRelocate['s-ol'];
1224
+ while ((orgLocationNode = orgLocationNode.previousSibling)) {
1225
+ refNode = orgLocationNode['s-nr'];
1226
+ if (refNode && refNode['s-sn'] === nodeToRelocate['s-sn'] && parentNodeRef === refNode.parentNode) {
1227
+ refNode = refNode.nextSibling;
1228
+ if (!refNode || !refNode['s-nr']) {
1229
+ insertBeforeNode = refNode;
1230
+ break;
1231
+ }
1232
+ }
1233
+ }
1234
+ if ((!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode) ||
1235
+ nodeToRelocate.nextSibling !== insertBeforeNode) {
1236
+ // we've checked that it's worth while to relocate
1237
+ // since that the node to relocate
1238
+ // has a different next sibling or parent relocated
1239
+ if (nodeToRelocate !== insertBeforeNode) {
1240
+ if (!nodeToRelocate['s-hn'] && nodeToRelocate['s-ol']) {
1241
+ // probably a component in the index.html that doesn't have it's hostname set
1242
+ nodeToRelocate['s-hn'] = nodeToRelocate['s-ol'].parentNode.nodeName;
1243
+ }
1244
+ // add it back to the dom but in its new home
1245
+ parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode);
1246
+ }
1247
+ }
1248
+ }
1249
+ else {
1250
+ // this node doesn't have a slot home to go to, so let's hide it
1251
+ if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
1252
+ nodeToRelocate.hidden = true;
1253
+ }
1254
+ }
1255
+ }
1256
+ }
1257
+ if (checkSlotFallbackVisibility) {
1258
+ updateFallbackSlotVisibility(rootVnode.$elm$);
1259
+ }
1260
+ // done moving nodes around
1261
+ // allow the disconnect callback to work again
1262
+ plt.$flags$ &= ~1 /* isTmpDisconnected */;
1263
+ // always reset
1264
+ relocateNodes.length = 0;
1265
+ }
1266
+ };
1267
+ // slot comment debug nodes only created with the `--debug` flag
1268
+ // otherwise these nodes are text nodes w/out content
1269
+ const slotReferenceDebugNode = (slotVNode) => doc.createComment(`<slot${slotVNode.$name$ ? ' name="' + slotVNode.$name$ + '"' : ''}> (host=${hostTagName.toLowerCase()})`);
1270
+ const originalLocationDebugNode = (nodeToRelocate) => doc.createComment(`org-location for ` +
1271
+ (nodeToRelocate.localName
1272
+ ? `<${nodeToRelocate.localName}> (host=${nodeToRelocate['s-hn']})`
1273
+ : `[${nodeToRelocate.textContent}]`));
1274
+ const getElement = (ref) => (BUILD.lazyLoad ? getHostRef(ref).$hostElement$ : ref);
1275
+ const createEvent = (ref, name, flags) => {
1276
+ const elm = getElement(ref);
1277
+ return {
1278
+ emit: (detail) => {
1279
+ if (BUILD.isDev && !elm.isConnected) {
1280
+ consoleDevWarn(`The "${name}" event was emitted, but the dispatcher node is no longer connected to the dom.`);
1281
+ }
1282
+ return emitEvent(elm, name, {
1283
+ bubbles: !!(flags & 4 /* Bubbles */),
1284
+ composed: !!(flags & 2 /* Composed */),
1285
+ cancelable: !!(flags & 1 /* Cancellable */),
1286
+ detail,
1287
+ });
1288
+ },
1289
+ };
1290
+ };
1291
+ /**
1292
+ * Helper function to create & dispatch a custom Event on a provided target
1293
+ * @param elm the target of the Event
1294
+ * @param name the name to give the custom Event
1295
+ * @param opts options for configuring a custom Event
1296
+ * @returns the custom Event
1297
+ */
1298
+ const emitEvent = (elm, name, opts) => {
1299
+ const ev = plt.ce(name, opts);
1300
+ elm.dispatchEvent(ev);
1301
+ return ev;
1302
+ };
1303
+ const attachToAncestor = (hostRef, ancestorComponent) => {
1304
+ if (BUILD.asyncLoading && ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
1305
+ ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
1306
+ }
1307
+ };
1308
+ const scheduleUpdate = (hostRef, isInitialLoad) => {
1309
+ if (BUILD.taskQueue && BUILD.updatable) {
1310
+ hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
1311
+ }
1312
+ if (BUILD.asyncLoading && hostRef.$flags$ & 4 /* isWaitingForChildren */) {
1313
+ hostRef.$flags$ |= 512 /* needsRerender */;
1314
+ return;
1315
+ }
1316
+ attachToAncestor(hostRef, hostRef.$ancestorComponent$);
1317
+ // there is no ancestor component or the ancestor component
1318
+ // has already fired off its lifecycle update then
1319
+ // fire off the initial update
1320
+ const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
1321
+ return BUILD.taskQueue ? writeTask(dispatch) : dispatch();
1322
+ };
1323
+ const dispatchHooks = (hostRef, isInitialLoad) => {
1324
+ const elm = hostRef.$hostElement$;
1325
+ const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
1326
+ const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
1327
+ let promise;
1328
+ if (isInitialLoad) {
1329
+ if (BUILD.lazyLoad && BUILD.hostListener) {
1330
+ hostRef.$flags$ |= 256 /* isListenReady */;
1331
+ if (hostRef.$queuedListeners$) {
1332
+ hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
1333
+ hostRef.$queuedListeners$ = null;
1334
+ }
1335
+ }
1336
+ emitLifecycleEvent(elm, 'componentWillLoad');
1337
+ if (BUILD.cmpWillLoad) {
1338
+ promise = safeCall(instance, 'componentWillLoad');
1339
+ }
1340
+ }
1341
+ else {
1342
+ emitLifecycleEvent(elm, 'componentWillUpdate');
1343
+ if (BUILD.cmpWillUpdate) {
1344
+ promise = safeCall(instance, 'componentWillUpdate');
1345
+ }
1346
+ }
1347
+ emitLifecycleEvent(elm, 'componentWillRender');
1348
+ if (BUILD.cmpWillRender) {
1349
+ promise = then(promise, () => safeCall(instance, 'componentWillRender'));
1350
+ }
1351
+ endSchedule();
1352
+ return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
1353
+ };
1354
+ const updateComponent = async (hostRef, instance, isInitialLoad) => {
1355
+ // updateComponent
1356
+ const elm = hostRef.$hostElement$;
1357
+ const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
1358
+ const rc = elm['s-rc'];
1359
+ if (BUILD.style && isInitialLoad) {
1360
+ // DOM WRITE!
1361
+ attachStyles(hostRef);
1362
+ }
1363
+ const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
1364
+ if (BUILD.isDev) {
1365
+ hostRef.$flags$ |= 1024 /* devOnRender */;
1366
+ }
1367
+ if (BUILD.hydrateServerSide) {
1368
+ await callRender(hostRef, instance, elm);
1369
+ }
1370
+ else {
1371
+ callRender(hostRef, instance, elm);
1372
+ }
1373
+ if (BUILD.cssVarShim && plt.$cssShim$) {
1374
+ plt.$cssShim$.updateHost(elm);
1375
+ }
1376
+ if (BUILD.isDev) {
1377
+ hostRef.$renderCount$++;
1378
+ hostRef.$flags$ &= ~1024 /* devOnRender */;
1379
+ }
1380
+ if (BUILD.hydrateServerSide) {
1381
+ try {
1382
+ // manually connected child components during server-side hydrate
1383
+ serverSideConnected(elm);
1384
+ if (isInitialLoad) {
1385
+ // using only during server-side hydrate
1386
+ if (hostRef.$cmpMeta$.$flags$ & 1 /* shadowDomEncapsulation */) {
1387
+ elm['s-en'] = '';
1388
+ }
1389
+ else if (hostRef.$cmpMeta$.$flags$ & 2 /* scopedCssEncapsulation */) {
1390
+ elm['s-en'] = 'c';
1391
+ }
1392
+ }
1393
+ }
1394
+ catch (e) {
1395
+ consoleError(e, elm);
1396
+ }
1397
+ }
1398
+ if (BUILD.asyncLoading && rc) {
1399
+ // ok, so turns out there are some child host elements
1400
+ // waiting on this parent element to load
1401
+ // let's fire off all update callbacks waiting
1402
+ rc.map((cb) => cb());
1403
+ elm['s-rc'] = undefined;
1404
+ }
1405
+ endRender();
1406
+ endUpdate();
1407
+ if (BUILD.asyncLoading) {
1408
+ const childrenPromises = elm['s-p'];
1409
+ const postUpdate = () => postUpdateComponent(hostRef);
1410
+ if (childrenPromises.length === 0) {
1411
+ postUpdate();
1412
+ }
1413
+ else {
1414
+ Promise.all(childrenPromises).then(postUpdate);
1415
+ hostRef.$flags$ |= 4 /* isWaitingForChildren */;
1416
+ childrenPromises.length = 0;
1417
+ }
1418
+ }
1419
+ else {
1420
+ postUpdateComponent(hostRef);
1421
+ }
1422
+ };
1423
+ const callRender = (hostRef, instance, elm) => {
1424
+ // in order for bundlers to correctly treeshake the BUILD object
1425
+ // we need to ensure BUILD is not deoptimized within a try/catch
1426
+ // https://rollupjs.org/guide/en/#treeshake tryCatchDeoptimization
1427
+ const allRenderFn = BUILD.allRenderFn ? true : false;
1428
+ const lazyLoad = BUILD.lazyLoad ? true : false;
1429
+ const taskQueue = BUILD.taskQueue ? true : false;
1430
+ const updatable = BUILD.updatable ? true : false;
1431
+ try {
1432
+ renderingRef = instance;
1433
+ instance = allRenderFn ? instance.render() : instance.render && instance.render();
1434
+ if (updatable && taskQueue) {
1435
+ hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
1436
+ }
1437
+ if (updatable || lazyLoad) {
1438
+ hostRef.$flags$ |= 2 /* hasRendered */;
1439
+ }
1440
+ if (BUILD.hasRenderFn || BUILD.reflect) {
1441
+ if (BUILD.vdomRender || BUILD.reflect) {
1442
+ // looks like we've got child nodes to render into this host element
1443
+ // or we need to update the css class/attrs on the host element
1444
+ // DOM WRITE!
1445
+ if (BUILD.hydrateServerSide) {
1446
+ return Promise.resolve(instance).then((value) => renderVdom(hostRef, value));
1447
+ }
1448
+ else {
1449
+ renderVdom(hostRef, instance);
1450
+ }
1451
+ }
1452
+ else {
1453
+ elm.textContent = instance;
1454
+ }
1455
+ }
1456
+ }
1457
+ catch (e) {
1458
+ consoleError(e, hostRef.$hostElement$);
1459
+ }
1460
+ renderingRef = null;
1461
+ return null;
1462
+ };
1463
+ const getRenderingRef = () => renderingRef;
1464
+ const postUpdateComponent = (hostRef) => {
1465
+ const tagName = hostRef.$cmpMeta$.$tagName$;
1466
+ const elm = hostRef.$hostElement$;
1467
+ const endPostUpdate = createTime('postUpdate', tagName);
1468
+ const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
1469
+ const ancestorComponent = hostRef.$ancestorComponent$;
1470
+ if (BUILD.cmpDidRender) {
1471
+ if (BUILD.isDev) {
1472
+ hostRef.$flags$ |= 1024 /* devOnRender */;
1473
+ }
1474
+ safeCall(instance, 'componentDidRender');
1475
+ if (BUILD.isDev) {
1476
+ hostRef.$flags$ &= ~1024 /* devOnRender */;
1477
+ }
1478
+ }
1479
+ emitLifecycleEvent(elm, 'componentDidRender');
1480
+ if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
1481
+ hostRef.$flags$ |= 64 /* hasLoadedComponent */;
1482
+ if (BUILD.asyncLoading && BUILD.cssAnnotations) {
1483
+ // DOM WRITE!
1484
+ addHydratedFlag(elm);
1485
+ }
1486
+ if (BUILD.cmpDidLoad) {
1487
+ if (BUILD.isDev) {
1488
+ hostRef.$flags$ |= 2048 /* devOnDidLoad */;
1489
+ }
1490
+ safeCall(instance, 'componentDidLoad');
1491
+ if (BUILD.isDev) {
1492
+ hostRef.$flags$ &= ~2048 /* devOnDidLoad */;
1493
+ }
1494
+ }
1495
+ emitLifecycleEvent(elm, 'componentDidLoad');
1496
+ endPostUpdate();
1497
+ if (BUILD.asyncLoading) {
1498
+ hostRef.$onReadyResolve$(elm);
1499
+ if (!ancestorComponent) {
1500
+ appDidLoad(tagName);
1501
+ }
1502
+ }
1503
+ }
1504
+ else {
1505
+ if (BUILD.cmpDidUpdate) {
1506
+ // we've already loaded this component
1507
+ // fire off the user's componentDidUpdate method (if one was provided)
1508
+ // componentDidUpdate runs AFTER render() has been called
1509
+ // and all child components have finished updating
1510
+ if (BUILD.isDev) {
1511
+ hostRef.$flags$ |= 1024 /* devOnRender */;
1512
+ }
1513
+ safeCall(instance, 'componentDidUpdate');
1514
+ if (BUILD.isDev) {
1515
+ hostRef.$flags$ &= ~1024 /* devOnRender */;
1516
+ }
1517
+ }
1518
+ emitLifecycleEvent(elm, 'componentDidUpdate');
1519
+ endPostUpdate();
1520
+ }
1521
+ if (BUILD.hotModuleReplacement) {
1522
+ elm['s-hmr-load'] && elm['s-hmr-load']();
1523
+ }
1524
+ if (BUILD.method && BUILD.lazyLoad) {
1525
+ hostRef.$onInstanceResolve$(elm);
1526
+ }
1527
+ // load events fire from bottom to top
1528
+ // the deepest elements load first then bubbles up
1529
+ if (BUILD.asyncLoading) {
1530
+ if (hostRef.$onRenderResolve$) {
1531
+ hostRef.$onRenderResolve$();
1532
+ hostRef.$onRenderResolve$ = undefined;
1533
+ }
1534
+ if (hostRef.$flags$ & 512 /* needsRerender */) {
1535
+ nextTick(() => scheduleUpdate(hostRef, false));
1536
+ }
1537
+ hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
1538
+ }
1539
+ // ( •_•)
1540
+ // ( •_•)>⌐■-■
1541
+ // (⌐■_■)
1542
+ };
1543
+ const forceUpdate = (ref) => {
1544
+ if (BUILD.updatable) {
1545
+ const hostRef = getHostRef(ref);
1546
+ const isConnected = hostRef.$hostElement$.isConnected;
1547
+ if (isConnected &&
1548
+ (hostRef.$flags$ & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
1549
+ scheduleUpdate(hostRef, false);
1550
+ }
1551
+ // Returns "true" when the forced update was successfully scheduled
1552
+ return isConnected;
1553
+ }
1554
+ return false;
1555
+ };
1556
+ const appDidLoad = (who) => {
1557
+ // on appload
1558
+ // we have finish the first big initial render
1559
+ if (BUILD.cssAnnotations) {
1560
+ addHydratedFlag(doc.documentElement);
1561
+ }
1562
+ if (BUILD.asyncQueue) {
1563
+ plt.$flags$ |= 2 /* appLoaded */;
1564
+ }
1565
+ nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
1566
+ if (BUILD.profile && performance.measure) {
1567
+ performance.measure(`[Stencil] ${NAMESPACE} initial load (by ${who})`, 'st:app:start');
1568
+ }
1569
+ };
1570
+ const safeCall = (instance, method, arg) => {
1571
+ if (instance && instance[method]) {
1572
+ try {
1573
+ return instance[method](arg);
1574
+ }
1575
+ catch (e) {
1576
+ consoleError(e);
1577
+ }
1578
+ }
1579
+ return undefined;
1580
+ };
1581
+ const then = (promise, thenFn) => {
1582
+ return promise && promise.then ? promise.then(thenFn) : thenFn();
1583
+ };
1584
+ const emitLifecycleEvent = (elm, lifecycleName) => {
1585
+ if (BUILD.lifecycleDOMEvents) {
1586
+ emitEvent(elm, 'stencil_' + lifecycleName, {
1587
+ bubbles: true,
1588
+ composed: true,
1589
+ detail: {
1590
+ namespace: NAMESPACE,
1591
+ },
1592
+ });
1593
+ }
1594
+ };
1595
+ const addHydratedFlag = (elm) => BUILD.hydratedClass
1596
+ ? elm.classList.add('hydrated')
1597
+ : BUILD.hydratedAttribute
1598
+ ? elm.setAttribute('hydrated', '')
1599
+ : undefined;
1600
+ const serverSideConnected = (elm) => {
1601
+ const children = elm.children;
1602
+ if (children != null) {
1603
+ for (let i = 0, ii = children.length; i < ii; i++) {
1604
+ const childElm = children[i];
1605
+ if (typeof childElm.connectedCallback === 'function') {
1606
+ childElm.connectedCallback();
1607
+ }
1608
+ serverSideConnected(childElm);
1609
+ }
1610
+ }
1611
+ };
1612
+ const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
1613
+ const endHydrate = createTime('hydrateClient', tagName);
1614
+ const shadowRoot = hostElm.shadowRoot;
1615
+ const childRenderNodes = [];
1616
+ const slotNodes = [];
1617
+ const shadowRootNodes = BUILD.shadowDom && shadowRoot ? [] : null;
1618
+ const vnode = (hostRef.$vnode$ = newVNode(tagName, null));
1619
+ if (!plt.$orgLocNodes$) {
1620
+ initializeDocumentHydrate(doc.body, (plt.$orgLocNodes$ = new Map()));
1621
+ }
1622
+ hostElm[HYDRATE_ID] = hostId;
1623
+ hostElm.removeAttribute(HYDRATE_ID);
1624
+ clientHydrate(vnode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, hostElm, hostId);
1625
+ childRenderNodes.map((c) => {
1626
+ const orgLocationId = c.$hostId$ + '.' + c.$nodeId$;
1627
+ const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
1628
+ const node = c.$elm$;
1629
+ if (orgLocationNode && supportsShadow && orgLocationNode['s-en'] === '') {
1630
+ orgLocationNode.parentNode.insertBefore(node, orgLocationNode.nextSibling);
1631
+ }
1632
+ if (!shadowRoot) {
1633
+ node['s-hn'] = tagName;
1634
+ if (orgLocationNode) {
1635
+ node['s-ol'] = orgLocationNode;
1636
+ node['s-ol']['s-nr'] = node;
1637
+ }
1638
+ }
1639
+ plt.$orgLocNodes$.delete(orgLocationId);
1640
+ });
1641
+ if (BUILD.shadowDom && shadowRoot) {
1642
+ shadowRootNodes.map((shadowRootNode) => {
1643
+ if (shadowRootNode) {
1644
+ shadowRoot.appendChild(shadowRootNode);
1645
+ }
1646
+ });
1647
+ }
1648
+ endHydrate();
1649
+ };
1650
+ const clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node, hostId) => {
1651
+ let childNodeType;
1652
+ let childIdSplt;
1653
+ let childVNode;
1654
+ let i;
1655
+ if (node.nodeType === 1 /* ElementNode */) {
1656
+ childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
1657
+ if (childNodeType) {
1658
+ // got the node data from the element's attribute
1659
+ // `${hostId}.${nodeId}.${depth}.${index}`
1660
+ childIdSplt = childNodeType.split('.');
1661
+ if (childIdSplt[0] === hostId || childIdSplt[0] === '0') {
1662
+ childVNode = {
1663
+ $flags$: 0,
1664
+ $hostId$: childIdSplt[0],
1665
+ $nodeId$: childIdSplt[1],
1666
+ $depth$: childIdSplt[2],
1667
+ $index$: childIdSplt[3],
1668
+ $tag$: node.tagName.toLowerCase(),
1669
+ $elm$: node,
1670
+ $attrs$: null,
1671
+ $children$: null,
1672
+ $key$: null,
1673
+ $name$: null,
1674
+ $text$: null,
1675
+ };
1676
+ childRenderNodes.push(childVNode);
1677
+ node.removeAttribute(HYDRATE_CHILD_ID);
1678
+ // this is a new child vnode
1679
+ // so ensure its parent vnode has the vchildren array
1680
+ if (!parentVNode.$children$) {
1681
+ parentVNode.$children$ = [];
1682
+ }
1683
+ // add our child vnode to a specific index of the vnode's children
1684
+ parentVNode.$children$[childVNode.$index$] = childVNode;
1685
+ // this is now the new parent vnode for all the next child checks
1686
+ parentVNode = childVNode;
1687
+ if (shadowRootNodes && childVNode.$depth$ === '0') {
1688
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
1689
+ }
1690
+ }
1691
+ }
1692
+ // recursively drill down, end to start so we can remove nodes
1693
+ for (i = node.childNodes.length - 1; i >= 0; i--) {
1694
+ clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.childNodes[i], hostId);
1695
+ }
1696
+ if (node.shadowRoot) {
1697
+ // keep drilling down through the shadow root nodes
1698
+ for (i = node.shadowRoot.childNodes.length - 1; i >= 0; i--) {
1699
+ clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.shadowRoot.childNodes[i], hostId);
1700
+ }
1701
+ }
1702
+ }
1703
+ else if (node.nodeType === 8 /* CommentNode */) {
1704
+ // `${COMMENT_TYPE}.${hostId}.${nodeId}.${depth}.${index}`
1705
+ childIdSplt = node.nodeValue.split('.');
1706
+ if (childIdSplt[1] === hostId || childIdSplt[1] === '0') {
1707
+ // comment node for either the host id or a 0 host id
1708
+ childNodeType = childIdSplt[0];
1709
+ childVNode = {
1710
+ $flags$: 0,
1711
+ $hostId$: childIdSplt[1],
1712
+ $nodeId$: childIdSplt[2],
1713
+ $depth$: childIdSplt[3],
1714
+ $index$: childIdSplt[4],
1715
+ $elm$: node,
1716
+ $attrs$: null,
1717
+ $children$: null,
1718
+ $key$: null,
1719
+ $name$: null,
1720
+ $tag$: null,
1721
+ $text$: null,
1722
+ };
1723
+ if (childNodeType === TEXT_NODE_ID) {
1724
+ childVNode.$elm$ = node.nextSibling;
1725
+ if (childVNode.$elm$ && childVNode.$elm$.nodeType === 3 /* TextNode */) {
1726
+ childVNode.$text$ = childVNode.$elm$.textContent;
1727
+ childRenderNodes.push(childVNode);
1728
+ // remove the text comment since it's no longer needed
1729
+ node.remove();
1730
+ if (!parentVNode.$children$) {
1731
+ parentVNode.$children$ = [];
1732
+ }
1733
+ parentVNode.$children$[childVNode.$index$] = childVNode;
1734
+ if (shadowRootNodes && childVNode.$depth$ === '0') {
1735
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
1736
+ }
1737
+ }
1738
+ }
1739
+ else if (childVNode.$hostId$ === hostId) {
1740
+ // this comment node is specifcally for this host id
1741
+ if (childNodeType === SLOT_NODE_ID) {
1742
+ // `${SLOT_NODE_ID}.${hostId}.${nodeId}.${depth}.${index}.${slotName}`;
1743
+ childVNode.$tag$ = 'slot';
1744
+ if (childIdSplt[5]) {
1745
+ node['s-sn'] = childVNode.$name$ = childIdSplt[5];
1746
+ }
1747
+ else {
1748
+ node['s-sn'] = '';
1749
+ }
1750
+ node['s-sr'] = true;
1751
+ if (BUILD.shadowDom && shadowRootNodes) {
1752
+ // browser support shadowRoot and this is a shadow dom component
1753
+ // create an actual slot element
1754
+ childVNode.$elm$ = doc.createElement(childVNode.$tag$);
1755
+ if (childVNode.$name$) {
1756
+ // add the slot name attribute
1757
+ childVNode.$elm$.setAttribute('name', childVNode.$name$);
1758
+ }
1759
+ // insert the new slot element before the slot comment
1760
+ node.parentNode.insertBefore(childVNode.$elm$, node);
1761
+ // remove the slot comment since it's not needed for shadow
1762
+ node.remove();
1763
+ if (childVNode.$depth$ === '0') {
1764
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
1765
+ }
1766
+ }
1767
+ slotNodes.push(childVNode);
1768
+ if (!parentVNode.$children$) {
1769
+ parentVNode.$children$ = [];
1770
+ }
1771
+ parentVNode.$children$[childVNode.$index$] = childVNode;
1772
+ }
1773
+ else if (childNodeType === CONTENT_REF_ID) {
1774
+ // `${CONTENT_REF_ID}.${hostId}`;
1775
+ if (BUILD.shadowDom && shadowRootNodes) {
1776
+ // remove the content ref comment since it's not needed for shadow
1777
+ node.remove();
1778
+ }
1779
+ else if (BUILD.slotRelocation) {
1780
+ hostElm['s-cr'] = node;
1781
+ node['s-cn'] = true;
1782
+ }
1783
+ }
1784
+ }
1785
+ }
1786
+ }
1787
+ else if (parentVNode && parentVNode.$tag$ === 'style') {
1788
+ const vnode = newVNode(null, node.textContent);
1789
+ vnode.$elm$ = node;
1790
+ vnode.$index$ = '0';
1791
+ parentVNode.$children$ = [vnode];
1792
+ }
1793
+ };
1794
+ const initializeDocumentHydrate = (node, orgLocNodes) => {
1795
+ if (node.nodeType === 1 /* ElementNode */) {
1796
+ let i = 0;
1797
+ for (; i < node.childNodes.length; i++) {
1798
+ initializeDocumentHydrate(node.childNodes[i], orgLocNodes);
1799
+ }
1800
+ if (node.shadowRoot) {
1801
+ for (i = 0; i < node.shadowRoot.childNodes.length; i++) {
1802
+ initializeDocumentHydrate(node.shadowRoot.childNodes[i], orgLocNodes);
1803
+ }
1804
+ }
1805
+ }
1806
+ else if (node.nodeType === 8 /* CommentNode */) {
1807
+ const childIdSplt = node.nodeValue.split('.');
1808
+ if (childIdSplt[0] === ORG_LOCATION_ID) {
1809
+ orgLocNodes.set(childIdSplt[1] + '.' + childIdSplt[2], node);
1810
+ node.nodeValue = '';
1811
+ // useful to know if the original location is
1812
+ // the root light-dom of a shadow dom component
1813
+ node['s-en'] = childIdSplt[3];
1814
+ }
1815
+ }
1816
+ };
1817
+ const parsePropertyValue = (propValue, propType) => {
1818
+ // ensure this value is of the correct prop type
1819
+ if (propValue != null && !isComplexType(propValue)) {
1820
+ if (BUILD.propBoolean && propType & 4 /* Boolean */) {
1821
+ // per the HTML spec, any string value means it is a boolean true value
1822
+ // but we'll cheat here and say that the string "false" is the boolean false
1823
+ return propValue === 'false' ? false : propValue === '' || !!propValue;
1824
+ }
1825
+ if (BUILD.propNumber && propType & 2 /* Number */) {
1826
+ // force it to be a number
1827
+ return parseFloat(propValue);
1828
+ }
1829
+ if (BUILD.propString && propType & 1 /* String */) {
1830
+ // could have been passed as a number or boolean
1831
+ // but we still want it as a string
1832
+ return String(propValue);
1833
+ }
1834
+ // redundant return here for better minification
1835
+ return propValue;
1836
+ }
1837
+ // not sure exactly what type we want
1838
+ // so no need to change to a different type
1839
+ return propValue;
1840
+ };
1841
+ const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
1842
+ const setValue = (ref, propName, newVal, cmpMeta) => {
1843
+ // check our new property value against our internal value
1844
+ const hostRef = getHostRef(ref);
1845
+ const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : ref;
1846
+ const oldVal = hostRef.$instanceValues$.get(propName);
1847
+ const flags = hostRef.$flags$;
1848
+ const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
1849
+ newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
1850
+ if ((!BUILD.lazyLoad || !(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && newVal !== oldVal) {
1851
+ // gadzooks! the property's value has changed!!
1852
+ // set our new value!
1853
+ hostRef.$instanceValues$.set(propName, newVal);
1854
+ if (BUILD.isDev) {
1855
+ if (hostRef.$flags$ & 1024 /* devOnRender */) {
1856
+ consoleDevWarn(`The state/prop "${propName}" changed during rendering. This can potentially lead to infinite-loops and other bugs.`, '\nElement', elm, '\nNew value', newVal, '\nOld value', oldVal);
1857
+ }
1858
+ else if (hostRef.$flags$ & 2048 /* devOnDidLoad */) {
1859
+ consoleDevWarn(`The state/prop "${propName}" changed during "componentDidLoad()", this triggers extra re-renders, try to setup on "componentWillLoad()"`, '\nElement', elm, '\nNew value', newVal, '\nOld value', oldVal);
1860
+ }
1861
+ }
1862
+ if (!BUILD.lazyLoad || instance) {
1863
+ // get an array of method names of watch functions to call
1864
+ if (BUILD.watchCallback && cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
1865
+ const watchMethods = cmpMeta.$watchers$[propName];
1866
+ if (watchMethods) {
1867
+ // this instance is watching for when this property changed
1868
+ watchMethods.map((watchMethodName) => {
1869
+ try {
1870
+ // fire off each of the watch methods that are watching this property
1871
+ instance[watchMethodName](newVal, oldVal, propName);
1872
+ }
1873
+ catch (e) {
1874
+ consoleError(e, elm);
1875
+ }
1876
+ });
1877
+ }
1878
+ }
1879
+ if (BUILD.updatable &&
1880
+ (flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
1881
+ if (BUILD.cmpShouldUpdate && instance.componentShouldUpdate) {
1882
+ if (instance.componentShouldUpdate(newVal, oldVal, propName) === false) {
1883
+ return;
1884
+ }
1885
+ }
1886
+ // looks like this value actually changed, so we've got work to do!
1887
+ // but only if we've already rendered, otherwise just chill out
1888
+ // queue that we need to do an update, but don't worry about queuing
1889
+ // up millions cuz this function ensures it only runs once
1890
+ scheduleUpdate(hostRef, false);
1891
+ }
1892
+ }
1893
+ }
1894
+ };
1895
+ const proxyComponent = (Cstr, cmpMeta, flags) => {
1896
+ if (BUILD.member && cmpMeta.$members$) {
1897
+ if (BUILD.watchCallback && Cstr.watchers) {
1898
+ cmpMeta.$watchers$ = Cstr.watchers;
1899
+ }
1900
+ // It's better to have a const than two Object.entries()
1901
+ const members = Object.entries(cmpMeta.$members$);
1902
+ const prototype = Cstr.prototype;
1903
+ members.map(([memberName, [memberFlags]]) => {
1904
+ if ((BUILD.prop || BUILD.state) &&
1905
+ (memberFlags & 31 /* Prop */ ||
1906
+ ((!BUILD.lazyLoad || flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
1907
+ // proxyComponent - prop
1908
+ Object.defineProperty(prototype, memberName, {
1909
+ get() {
1910
+ // proxyComponent, get value
1911
+ return getValue(this, memberName);
1912
+ },
1913
+ set(newValue) {
1914
+ // only during dev time
1915
+ if (BUILD.isDev) {
1916
+ const ref = getHostRef(this);
1917
+ if (
1918
+ // we are proxying the instance (not element)
1919
+ (flags & 1 /* isElementConstructor */) === 0 &&
1920
+ // the element is not constructing
1921
+ (ref.$flags$ & 8 /* isConstructingInstance */) === 0 &&
1922
+ // the member is a prop
1923
+ (memberFlags & 31 /* Prop */) !== 0 &&
1924
+ // the member is not mutable
1925
+ (memberFlags & 1024 /* Mutable */) === 0) {
1926
+ consoleDevWarn(`@Prop() "${memberName}" on <${cmpMeta.$tagName$}> is immutable but was modified from within the component.\nMore information: https://stenciljs.com/docs/properties#prop-mutability`);
1927
+ }
1928
+ }
1929
+ // proxyComponent, set value
1930
+ setValue(this, memberName, newValue, cmpMeta);
1931
+ },
1932
+ configurable: true,
1933
+ enumerable: true,
1934
+ });
1935
+ }
1936
+ else if (BUILD.lazyLoad &&
1937
+ BUILD.method &&
1938
+ flags & 1 /* isElementConstructor */ &&
1939
+ memberFlags & 64 /* Method */) {
1940
+ // proxyComponent - method
1941
+ Object.defineProperty(prototype, memberName, {
1942
+ value(...args) {
1943
+ const ref = getHostRef(this);
1944
+ return ref.$onInstancePromise$.then(() => ref.$lazyInstance$[memberName](...args));
1945
+ },
1946
+ });
1947
+ }
1948
+ });
1949
+ if (BUILD.observeAttribute && (!BUILD.lazyLoad || flags & 1 /* isElementConstructor */)) {
1950
+ const attrNameToPropName = new Map();
1951
+ prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
1952
+ plt.jmp(() => {
1953
+ const propName = attrNameToPropName.get(attrName);
1954
+ // In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
1955
+ // in the case where an attribute was set inline.
1956
+ // ```html
1957
+ // <my-component some-attribute="some-value"></my-component>
1958
+ // ```
1959
+ //
1960
+ // There is an edge case where a developer sets the attribute inline on a custom element and then
1961
+ // programmatically changes it before it has been upgraded as shown below:
1962
+ //
1963
+ // ```html
1964
+ // <!-- this component has _not_ been upgraded yet -->
1965
+ // <my-component id="test" some-attribute="some-value"></my-component>
1966
+ // <script>
1967
+ // // grab non-upgraded component
1968
+ // el = document.querySelector("#test");
1969
+ // el.someAttribute = "another-value";
1970
+ // // upgrade component
1971
+ // customElements.define('my-component', MyComponent);
1972
+ // </script>
1973
+ // ```
1974
+ // In this case if we do not unshadow here and use the value of the shadowing property, attributeChangedCallback
1975
+ // will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
1976
+ // to the value that was set inline i.e. "some-value" from above example. When
1977
+ // the connectedCallback attempts to unshadow it will use "some-value" as the initial value rather than "another-value"
1978
+ //
1979
+ // The case where the attribute was NOT set inline but was not set programmatically shall be handled/unshadowed
1980
+ // by connectedCallback as this attributeChangedCallback will not fire.
1981
+ //
1982
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1983
+ //
1984
+ // TODO(STENCIL-16) we should think about whether or not we actually want to be reflecting the attributes to
1985
+ // properties here given that this goes against best practices outlined here
1986
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy
1987
+ if (this.hasOwnProperty(propName)) {
1988
+ newValue = this[propName];
1989
+ delete this[propName];
1990
+ }
1991
+ else if (prototype.hasOwnProperty(propName) &&
1992
+ typeof this[propName] === 'number' &&
1993
+ this[propName] == newValue) {
1994
+ // if the propName exists on the prototype of `Cstr`, this update may be a result of Stencil using native
1995
+ // APIs to reflect props as attributes. Calls to `setAttribute(someElement, propName)` will result in
1996
+ // `propName` to be converted to a `DOMString`, which may not be what we want for other primitive props.
1997
+ return;
1998
+ }
1999
+ this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
2000
+ });
2001
+ };
2002
+ // create an array of attributes to observe
2003
+ // and also create a map of html attribute name to js property name
2004
+ Cstr.observedAttributes = members
2005
+ .filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
2006
+ .map(([propName, m]) => {
2007
+ const attrName = m[1] || propName;
2008
+ attrNameToPropName.set(attrName, propName);
2009
+ if (BUILD.reflect && m[0] & 512 /* ReflectAttr */) {
2010
+ cmpMeta.$attrsToReflect$.push([propName, attrName]);
2011
+ }
2012
+ return attrName;
2013
+ });
2014
+ }
2015
+ }
2016
+ return Cstr;
2017
+ };
2018
+ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
2019
+ // initializeComponent
2020
+ if ((BUILD.lazyLoad || BUILD.hydrateServerSide || BUILD.style) &&
2021
+ (hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
2022
+ if (BUILD.lazyLoad || BUILD.hydrateClientSide) {
2023
+ // we haven't initialized this element yet
2024
+ hostRef.$flags$ |= 32 /* hasInitializedComponent */;
2025
+ // lazy loaded components
2026
+ // request the component's implementation to be
2027
+ // wired up with the host element
2028
+ Cstr = loadModule(cmpMeta, hostRef, hmrVersionId);
2029
+ if (Cstr.then) {
2030
+ // Await creates a micro-task avoid if possible
2031
+ const endLoad = uniqueTime(`st:load:${cmpMeta.$tagName$}:${hostRef.$modeName$}`, `[Stencil] Load module for <${cmpMeta.$tagName$}>`);
2032
+ Cstr = await Cstr;
2033
+ endLoad();
2034
+ }
2035
+ if ((BUILD.isDev || BUILD.isDebug) && !Cstr) {
2036
+ throw new Error(`Constructor for "${cmpMeta.$tagName$}#${hostRef.$modeName$}" was not found`);
2037
+ }
2038
+ if (BUILD.member && !Cstr.isProxied) {
2039
+ // we've never proxied this Constructor before
2040
+ // let's add the getters/setters to its prototype before
2041
+ // the first time we create an instance of the implementation
2042
+ if (BUILD.watchCallback) {
2043
+ cmpMeta.$watchers$ = Cstr.watchers;
2044
+ }
2045
+ proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
2046
+ Cstr.isProxied = true;
2047
+ }
2048
+ const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
2049
+ // ok, time to construct the instance
2050
+ // but let's keep track of when we start and stop
2051
+ // so that the getters/setters don't incorrectly step on data
2052
+ if (BUILD.member) {
2053
+ hostRef.$flags$ |= 8 /* isConstructingInstance */;
2054
+ }
2055
+ // construct the lazy-loaded component implementation
2056
+ // passing the hostRef is very important during
2057
+ // construction in order to directly wire together the
2058
+ // host element and the lazy-loaded instance
2059
+ try {
2060
+ new Cstr(hostRef);
2061
+ }
2062
+ catch (e) {
2063
+ consoleError(e);
2064
+ }
2065
+ if (BUILD.member) {
2066
+ hostRef.$flags$ &= ~8 /* isConstructingInstance */;
2067
+ }
2068
+ if (BUILD.watchCallback) {
2069
+ hostRef.$flags$ |= 128 /* isWatchReady */;
2070
+ }
2071
+ endNewInstance();
2072
+ fireConnectedCallback(hostRef.$lazyInstance$);
2073
+ }
2074
+ else {
2075
+ // sync constructor component
2076
+ Cstr = elm.constructor;
2077
+ hostRef.$flags$ |= 32 /* hasInitializedComponent */;
2078
+ // wait for the CustomElementRegistry to mark the component as ready before setting `isWatchReady`. Otherwise,
2079
+ // watchers may fire prematurely if `customElements.get()`/`customElements.whenDefined()` resolves _before_
2080
+ // Stencil has completed instantiating the component.
2081
+ customElements.whenDefined(cmpMeta.$tagName$).then(() => (hostRef.$flags$ |= 128 /* isWatchReady */));
2082
+ }
2083
+ if (BUILD.style && Cstr.style) {
2084
+ // this component has styles but we haven't registered them yet
2085
+ let style = Cstr.style;
2086
+ if (BUILD.mode && typeof style !== 'string') {
2087
+ style = style[(hostRef.$modeName$ = computeMode(elm))];
2088
+ if (BUILD.hydrateServerSide && hostRef.$modeName$) {
2089
+ elm.setAttribute('s-mode', hostRef.$modeName$);
2090
+ }
2091
+ }
2092
+ const scopeId = getScopeId(cmpMeta, hostRef.$modeName$);
2093
+ if (!styles.has(scopeId)) {
2094
+ const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
2095
+ if (!BUILD.hydrateServerSide &&
2096
+ BUILD.shadowDom &&
2097
+ BUILD.shadowDomShim &&
2098
+ cmpMeta.$flags$ & 8 /* needsShadowDomShim */) {
2099
+ style = await import('./shadow-css-1e16431b.js').then((m) => m.scopeCss(style, scopeId, false));
2100
+ }
2101
+ registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
2102
+ endRegisterStyles();
2103
+ }
2104
+ }
2105
+ }
2106
+ // we've successfully created a lazy instance
2107
+ const ancestorComponent = hostRef.$ancestorComponent$;
2108
+ const schedule = () => scheduleUpdate(hostRef, true);
2109
+ if (BUILD.asyncLoading && ancestorComponent && ancestorComponent['s-rc']) {
2110
+ // this is the initial load and this component it has an ancestor component
2111
+ // but the ancestor component has NOT fired its will update lifecycle yet
2112
+ // so let's just cool our jets and wait for the ancestor to continue first
2113
+ // this will get fired off when the ancestor component
2114
+ // finally gets around to rendering its lazy self
2115
+ // fire off the initial update
2116
+ ancestorComponent['s-rc'].push(schedule);
2117
+ }
2118
+ else {
2119
+ schedule();
2120
+ }
2121
+ };
2122
+ const fireConnectedCallback = (instance) => {
2123
+ if (BUILD.lazyLoad && BUILD.connectedCallback) {
2124
+ safeCall(instance, 'connectedCallback');
2125
+ }
2126
+ };
2127
+ const connectedCallback = (elm) => {
2128
+ if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
2129
+ const hostRef = getHostRef(elm);
2130
+ const cmpMeta = hostRef.$cmpMeta$;
2131
+ const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
2132
+ if (BUILD.hostListenerTargetParent) {
2133
+ // only run if we have listeners being attached to a parent
2134
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, true);
2135
+ }
2136
+ if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
2137
+ // first time this component has connected
2138
+ hostRef.$flags$ |= 1 /* hasConnected */;
2139
+ let hostId;
2140
+ if (BUILD.hydrateClientSide) {
2141
+ hostId = elm.getAttribute(HYDRATE_ID);
2142
+ if (hostId) {
2143
+ if (BUILD.shadowDom && supportsShadow && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
2144
+ const scopeId = BUILD.mode
2145
+ ? addStyle(elm.shadowRoot, cmpMeta, elm.getAttribute('s-mode'))
2146
+ : addStyle(elm.shadowRoot, cmpMeta);
2147
+ elm.classList.remove(scopeId + '-h', scopeId + '-s');
2148
+ }
2149
+ initializeClientHydrate(elm, cmpMeta.$tagName$, hostId, hostRef);
2150
+ }
2151
+ }
2152
+ if (BUILD.slotRelocation && !hostId) {
2153
+ // initUpdate
2154
+ // if the slot polyfill is required we'll need to put some nodes
2155
+ // in here to act as original content anchors as we move nodes around
2156
+ // host element has been connected to the DOM
2157
+ if (BUILD.hydrateServerSide ||
2158
+ ((BUILD.slot || BUILD.shadowDom) &&
2159
+ cmpMeta.$flags$ & (4 /* hasSlotRelocation */ | 8 /* needsShadowDomShim */))) {
2160
+ setContentReference(elm);
2161
+ }
2162
+ }
2163
+ if (BUILD.asyncLoading) {
2164
+ // find the first ancestor component (if there is one) and register
2165
+ // this component as one of the actively loading child components for its ancestor
2166
+ let ancestorComponent = elm;
2167
+ while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
2168
+ // climb up the ancestors looking for the first
2169
+ // component that hasn't finished its lifecycle update yet
2170
+ if ((BUILD.hydrateClientSide &&
2171
+ ancestorComponent.nodeType === 1 /* ElementNode */ &&
2172
+ ancestorComponent.hasAttribute('s-id') &&
2173
+ ancestorComponent['s-p']) ||
2174
+ ancestorComponent['s-p']) {
2175
+ // we found this components first ancestor component
2176
+ // keep a reference to this component's ancestor component
2177
+ attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
2178
+ break;
2179
+ }
2180
+ }
2181
+ }
2182
+ // Lazy properties
2183
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
2184
+ if (BUILD.prop && !BUILD.hydrateServerSide && cmpMeta.$members$) {
2185
+ Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
2186
+ if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
2187
+ const value = elm[memberName];
2188
+ delete elm[memberName];
2189
+ elm[memberName] = value;
2190
+ }
2191
+ });
2192
+ }
2193
+ if (BUILD.initializeNextTick) {
2194
+ // connectedCallback, taskQueue, initialLoad
2195
+ // angular sets attribute AFTER connectCallback
2196
+ // https://github.com/angular/angular/issues/18909
2197
+ // https://github.com/angular/angular/issues/19940
2198
+ nextTick(() => initializeComponent(elm, hostRef, cmpMeta));
2199
+ }
2200
+ else {
2201
+ initializeComponent(elm, hostRef, cmpMeta);
2202
+ }
2203
+ }
2204
+ else {
2205
+ // not the first time this has connected
2206
+ // reattach any event listeners to the host
2207
+ // since they would have been removed when disconnected
2208
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, false);
2209
+ // fire off connectedCallback() on component instance
2210
+ fireConnectedCallback(hostRef.$lazyInstance$);
2211
+ }
2212
+ endConnected();
2213
+ }
2214
+ };
2215
+ const setContentReference = (elm) => {
2216
+ // only required when we're NOT using native shadow dom (slot)
2217
+ // or this browser doesn't support native shadow dom
2218
+ // and this host element was NOT created with SSR
2219
+ // let's pick out the inner content for slot projection
2220
+ // create a node to represent where the original
2221
+ // content was first placed, which is useful later on
2222
+ const contentRefElm = (elm['s-cr'] = doc.createComment(BUILD.isDebug ? `content-ref (host=${elm.localName})` : ''));
2223
+ contentRefElm['s-cn'] = true;
2224
+ elm.insertBefore(contentRefElm, elm.firstChild);
2225
+ };
2226
+ const disconnectedCallback = (elm) => {
2227
+ if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
2228
+ const hostRef = getHostRef(elm);
2229
+ const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
2230
+ if (BUILD.hostListener) {
2231
+ if (hostRef.$rmListeners$) {
2232
+ hostRef.$rmListeners$.map((rmListener) => rmListener());
2233
+ hostRef.$rmListeners$ = undefined;
2234
+ }
2235
+ }
2236
+ // clear CSS var-shim tracking
2237
+ if (BUILD.cssVarShim && plt.$cssShim$) {
2238
+ plt.$cssShim$.removeHost(elm);
2239
+ }
2240
+ if (BUILD.lazyLoad && BUILD.disconnectedCallback) {
2241
+ safeCall(instance, 'disconnectedCallback');
2242
+ }
2243
+ if (BUILD.cmpDidUnload) {
2244
+ safeCall(instance, 'componentDidUnload');
2245
+ }
2246
+ }
2247
+ };
2248
+ const defineCustomElement = (Cstr, compactMeta) => {
2249
+ customElements.define(compactMeta[1], proxyCustomElement(Cstr, compactMeta));
2250
+ };
2251
+ const proxyCustomElement = (Cstr, compactMeta) => {
2252
+ const cmpMeta = {
2253
+ $flags$: compactMeta[0],
2254
+ $tagName$: compactMeta[1],
2255
+ };
2256
+ if (BUILD.member) {
2257
+ cmpMeta.$members$ = compactMeta[2];
2258
+ }
2259
+ if (BUILD.hostListener) {
2260
+ cmpMeta.$listeners$ = compactMeta[3];
2261
+ }
2262
+ if (BUILD.watchCallback) {
2263
+ cmpMeta.$watchers$ = Cstr.$watchers$;
2264
+ }
2265
+ if (BUILD.reflect) {
2266
+ cmpMeta.$attrsToReflect$ = [];
2267
+ }
2268
+ if (BUILD.shadowDom && !supportsShadow && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
2269
+ cmpMeta.$flags$ |= 8 /* needsShadowDomShim */;
2270
+ }
2271
+ const originalConnectedCallback = Cstr.prototype.connectedCallback;
2272
+ const originalDisconnectedCallback = Cstr.prototype.disconnectedCallback;
2273
+ Object.assign(Cstr.prototype, {
2274
+ __registerHost() {
2275
+ registerHost(this, cmpMeta);
2276
+ },
2277
+ connectedCallback() {
2278
+ connectedCallback(this);
2279
+ if (BUILD.connectedCallback && originalConnectedCallback) {
2280
+ originalConnectedCallback.call(this);
2281
+ }
2282
+ },
2283
+ disconnectedCallback() {
2284
+ disconnectedCallback(this);
2285
+ if (BUILD.disconnectedCallback && originalDisconnectedCallback) {
2286
+ originalDisconnectedCallback.call(this);
2287
+ }
2288
+ },
2289
+ __attachShadow() {
2290
+ if (supportsShadow) {
2291
+ if (BUILD.shadowDelegatesFocus) {
2292
+ this.attachShadow({
2293
+ mode: 'open',
2294
+ delegatesFocus: !!(cmpMeta.$flags$ & 16 /* shadowDelegatesFocus */),
2295
+ });
2296
+ }
2297
+ else {
2298
+ this.attachShadow({ mode: 'open' });
2299
+ }
2300
+ }
2301
+ else {
2302
+ this.shadowRoot = this;
2303
+ }
2304
+ },
2305
+ });
2306
+ Cstr.is = cmpMeta.$tagName$;
2307
+ return proxyComponent(Cstr, cmpMeta, 1 /* isElementConstructor */ | 2 /* proxyState */);
2308
+ };
2309
+ const forceModeUpdate = (elm) => {
2310
+ if (BUILD.style && BUILD.mode && !BUILD.lazyLoad) {
2311
+ const mode = computeMode(elm);
2312
+ const hostRef = getHostRef(elm);
2313
+ if (hostRef.$modeName$ !== mode) {
2314
+ const cmpMeta = hostRef.$cmpMeta$;
2315
+ const oldScopeId = elm['s-sc'];
2316
+ const scopeId = getScopeId(cmpMeta, mode);
2317
+ const style = elm.constructor.style[mode];
2318
+ const flags = cmpMeta.$flags$;
2319
+ if (style) {
2320
+ if (!styles.has(scopeId)) {
2321
+ registerStyle(scopeId, style, !!(flags & 1 /* shadowDomEncapsulation */));
2322
+ }
2323
+ hostRef.$modeName$ = mode;
2324
+ elm.classList.remove(oldScopeId + '-h', oldScopeId + '-s');
2325
+ attachStyles(hostRef);
2326
+ forceUpdate(elm);
2327
+ }
2328
+ }
2329
+ }
2330
+ };
2331
+ const hmrStart = (elm, cmpMeta, hmrVersionId) => {
2332
+ // ¯\_(ツ)_/¯
2333
+ const hostRef = getHostRef(elm);
2334
+ // reset state flags to only have been connected
2335
+ hostRef.$flags$ = 1 /* hasConnected */;
2336
+ // TODO
2337
+ // detatch any event listeners that may have been added
2338
+ // because we're not passing an exact event name it'll
2339
+ // remove all of this element's event, which is good
2340
+ // create a callback for when this component finishes hmr
2341
+ elm['s-hmr-load'] = () => {
2342
+ // finished hmr for this element
2343
+ delete elm['s-hmr-load'];
2344
+ };
2345
+ // re-initialize the component
2346
+ initializeComponent(elm, hostRef, cmpMeta, hmrVersionId);
2347
+ };
2348
+ const patchCloneNode = (HostElementPrototype) => {
2349
+ const orgCloneNode = HostElementPrototype.cloneNode;
2350
+ HostElementPrototype.cloneNode = function (deep) {
2351
+ const srcNode = this;
2352
+ const isShadowDom = BUILD.shadowDom ? srcNode.shadowRoot && supportsShadow : false;
2353
+ const clonedNode = orgCloneNode.call(srcNode, isShadowDom ? deep : false);
2354
+ if (BUILD.slot && !isShadowDom && deep) {
2355
+ let i = 0;
2356
+ let slotted, nonStencilNode;
2357
+ let stencilPrivates = [
2358
+ 's-id',
2359
+ 's-cr',
2360
+ 's-lr',
2361
+ 's-rc',
2362
+ 's-sc',
2363
+ 's-p',
2364
+ 's-cn',
2365
+ 's-sr',
2366
+ 's-sn',
2367
+ 's-hn',
2368
+ 's-ol',
2369
+ 's-nr',
2370
+ 's-si',
2371
+ ];
2372
+ for (; i < srcNode.childNodes.length; i++) {
2373
+ slotted = srcNode.childNodes[i]['s-nr'];
2374
+ nonStencilNode = stencilPrivates.every((privateField) => !srcNode.childNodes[i][privateField]);
2375
+ if (slotted) {
2376
+ if (BUILD.appendChildSlotFix && clonedNode.__appendChild) {
2377
+ clonedNode.__appendChild(slotted.cloneNode(true));
2378
+ }
2379
+ else {
2380
+ clonedNode.appendChild(slotted.cloneNode(true));
2381
+ }
2382
+ }
2383
+ if (nonStencilNode) {
2384
+ clonedNode.appendChild(srcNode.childNodes[i].cloneNode(true));
2385
+ }
2386
+ }
2387
+ }
2388
+ return clonedNode;
2389
+ };
2390
+ };
2391
+ const patchSlotAppendChild = (HostElementPrototype) => {
2392
+ HostElementPrototype.__appendChild = HostElementPrototype.appendChild;
2393
+ HostElementPrototype.appendChild = function (newChild) {
2394
+ const slotName = (newChild['s-sn'] = getSlotName(newChild));
2395
+ const slotNode = getHostSlotNode(this.childNodes, slotName);
2396
+ if (slotNode) {
2397
+ const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
2398
+ const appendAfter = slotChildNodes[slotChildNodes.length - 1];
2399
+ return appendAfter.parentNode.insertBefore(newChild, appendAfter.nextSibling);
2400
+ }
2401
+ return this.__appendChild(newChild);
2402
+ };
2403
+ };
2404
+ /**
2405
+ * Patches the text content of an unnamed slotted node inside a scoped component
2406
+ * @param hostElementPrototype the `Element` to be patched
2407
+ * @param cmpMeta component runtime metadata used to determine if the component should be patched or not
2408
+ */
2409
+ const patchTextContent = (hostElementPrototype, cmpMeta) => {
2410
+ if (BUILD.scoped && cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
2411
+ const descriptor = Object.getOwnPropertyDescriptor(Node.prototype, 'textContent');
2412
+ Object.defineProperty(hostElementPrototype, '__textContent', descriptor);
2413
+ Object.defineProperty(hostElementPrototype, 'textContent', {
2414
+ get() {
2415
+ var _a;
2416
+ // get the 'default slot', which would be the first slot in a shadow tree (if we were using one), whose name is
2417
+ // the empty string
2418
+ const slotNode = getHostSlotNode(this.childNodes, '');
2419
+ // when a slot node is found, the textContent _may_ be found in the next sibling (text) node, depending on how
2420
+ // nodes were reordered during the vdom render. first try to get the text content from the sibling.
2421
+ if (((_a = slotNode === null || slotNode === void 0 ? void 0 : slotNode.nextSibling) === null || _a === void 0 ? void 0 : _a.nodeType) === 3 /* TEXT_NODE */) {
2422
+ return slotNode.nextSibling.textContent;
2423
+ }
2424
+ else if (slotNode) {
2425
+ return slotNode.textContent;
2426
+ }
2427
+ else {
2428
+ // fallback to the original implementation
2429
+ return this.__textContent;
2430
+ }
2431
+ },
2432
+ set(value) {
2433
+ var _a;
2434
+ // get the 'default slot', which would be the first slot in a shadow tree (if we were using one), whose name is
2435
+ // the empty string
2436
+ const slotNode = getHostSlotNode(this.childNodes, '');
2437
+ // when a slot node is found, the textContent _may_ need to be placed in the next sibling (text) node,
2438
+ // depending on how nodes were reordered during the vdom render. first try to set the text content on the
2439
+ // sibling.
2440
+ if (((_a = slotNode === null || slotNode === void 0 ? void 0 : slotNode.nextSibling) === null || _a === void 0 ? void 0 : _a.nodeType) === 3 /* TEXT_NODE */) {
2441
+ slotNode.nextSibling.textContent = value;
2442
+ }
2443
+ else if (slotNode) {
2444
+ slotNode.textContent = value;
2445
+ }
2446
+ else {
2447
+ // we couldn't find a slot, but that doesn't mean that there isn't one. if this check ran before the DOM
2448
+ // loaded, we could have missed it. check for a content reference element on the scoped component and insert
2449
+ // it there
2450
+ this.__textContent = value;
2451
+ const contentRefElm = this['s-cr'];
2452
+ if (contentRefElm) {
2453
+ this.insertBefore(contentRefElm, this.firstChild);
2454
+ }
2455
+ }
2456
+ },
2457
+ });
2458
+ }
2459
+ };
2460
+ const patchChildSlotNodes = (elm, cmpMeta) => {
2461
+ class FakeNodeList extends Array {
2462
+ item(n) {
2463
+ return this[n];
2464
+ }
2465
+ }
2466
+ if (cmpMeta.$flags$ & 8 /* needsShadowDomShim */) {
2467
+ const childNodesFn = elm.__lookupGetter__('childNodes');
2468
+ Object.defineProperty(elm, 'children', {
2469
+ get() {
2470
+ return this.childNodes.map((n) => n.nodeType === 1);
2471
+ },
2472
+ });
2473
+ Object.defineProperty(elm, 'childElementCount', {
2474
+ get() {
2475
+ return elm.children.length;
2476
+ },
2477
+ });
2478
+ Object.defineProperty(elm, 'childNodes', {
2479
+ get() {
2480
+ const childNodes = childNodesFn.call(this);
2481
+ if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0 &&
2482
+ getHostRef(this).$flags$ & 2 /* hasRendered */) {
2483
+ const result = new FakeNodeList();
2484
+ for (let i = 0; i < childNodes.length; i++) {
2485
+ const slot = childNodes[i]['s-nr'];
2486
+ if (slot) {
2487
+ result.push(slot);
2488
+ }
2489
+ }
2490
+ return result;
2491
+ }
2492
+ return FakeNodeList.from(childNodes);
2493
+ },
2494
+ });
2495
+ }
2496
+ };
2497
+ const getSlotName = (node) => node['s-sn'] || (node.nodeType === 1 && node.getAttribute('slot')) || '';
2498
+ /**
2499
+ * Recursively searches a series of child nodes for a slot with the provided name.
2500
+ * @param childNodes the nodes to search for a slot with a specific name.
2501
+ * @param slotName the name of the slot to match on.
2502
+ * @returns a reference to the slot node that matches the provided name, `null` otherwise
2503
+ */
2504
+ const getHostSlotNode = (childNodes, slotName) => {
2505
+ let i = 0;
2506
+ let childNode;
2507
+ for (; i < childNodes.length; i++) {
2508
+ childNode = childNodes[i];
2509
+ if (childNode['s-sr'] && childNode['s-sn'] === slotName) {
2510
+ return childNode;
2511
+ }
2512
+ childNode = getHostSlotNode(childNode.childNodes, slotName);
2513
+ if (childNode) {
2514
+ return childNode;
2515
+ }
2516
+ }
2517
+ return null;
2518
+ };
2519
+ const getHostSlotChildNodes = (n, slotName) => {
2520
+ const childNodes = [n];
2521
+ while ((n = n.nextSibling) && n['s-sn'] === slotName) {
2522
+ childNodes.push(n);
2523
+ }
2524
+ return childNodes;
2525
+ };
2526
+ const bootstrapLazy = (lazyBundles, options = {}) => {
2527
+ if (BUILD.profile && performance.mark) {
2528
+ performance.mark('st:app:start');
2529
+ }
2530
+ installDevTools();
2531
+ const endBootstrap = createTime('bootstrapLazy');
2532
+ const cmpTags = [];
2533
+ const exclude = options.exclude || [];
2534
+ const customElements = win.customElements;
2535
+ const head = doc.head;
2536
+ const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
2537
+ const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
2538
+ const deferredConnectedCallbacks = [];
2539
+ const styles = /*@__PURE__*/ doc.querySelectorAll(`[${HYDRATED_STYLE_ID}]`);
2540
+ let appLoadFallback;
2541
+ let isBootstrapping = true;
2542
+ let i = 0;
2543
+ Object.assign(plt, options);
2544
+ plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
2545
+ if (BUILD.asyncQueue) {
2546
+ if (options.syncQueue) {
2547
+ plt.$flags$ |= 4 /* queueSync */;
2548
+ }
2549
+ }
2550
+ if (BUILD.hydrateClientSide) {
2551
+ // If the app is already hydrated there is not point to disable the
2552
+ // async queue. This will improve the first input delay
2553
+ plt.$flags$ |= 2 /* appLoaded */;
2554
+ }
2555
+ if (BUILD.hydrateClientSide && BUILD.shadowDom) {
2556
+ for (; i < styles.length; i++) {
2557
+ registerStyle(styles[i].getAttribute(HYDRATED_STYLE_ID), convertScopedToShadow(styles[i].innerHTML), true);
2558
+ }
2559
+ }
2560
+ lazyBundles.map((lazyBundle) => {
2561
+ lazyBundle[1].map((compactMeta) => {
2562
+ const cmpMeta = {
2563
+ $flags$: compactMeta[0],
2564
+ $tagName$: compactMeta[1],
2565
+ $members$: compactMeta[2],
2566
+ $listeners$: compactMeta[3],
2567
+ };
2568
+ if (BUILD.member) {
2569
+ cmpMeta.$members$ = compactMeta[2];
2570
+ }
2571
+ if (BUILD.hostListener) {
2572
+ cmpMeta.$listeners$ = compactMeta[3];
2573
+ }
2574
+ if (BUILD.reflect) {
2575
+ cmpMeta.$attrsToReflect$ = [];
2576
+ }
2577
+ if (BUILD.watchCallback) {
2578
+ cmpMeta.$watchers$ = {};
2579
+ }
2580
+ if (BUILD.shadowDom && !supportsShadow && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
2581
+ cmpMeta.$flags$ |= 8 /* needsShadowDomShim */;
2582
+ }
2583
+ const tagName = BUILD.transformTagName && options.transformTagName
2584
+ ? options.transformTagName(cmpMeta.$tagName$)
2585
+ : cmpMeta.$tagName$;
2586
+ const HostElement = class extends HTMLElement {
2587
+ // StencilLazyHost
2588
+ constructor(self) {
2589
+ // @ts-ignore
2590
+ super(self);
2591
+ self = this;
2592
+ registerHost(self, cmpMeta);
2593
+ if (BUILD.shadowDom && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
2594
+ // this component is using shadow dom
2595
+ // and this browser supports shadow dom
2596
+ // add the read-only property "shadowRoot" to the host element
2597
+ // adding the shadow root build conditionals to minimize runtime
2598
+ if (supportsShadow) {
2599
+ if (BUILD.shadowDelegatesFocus) {
2600
+ self.attachShadow({
2601
+ mode: 'open',
2602
+ delegatesFocus: !!(cmpMeta.$flags$ & 16 /* shadowDelegatesFocus */),
2603
+ });
2604
+ }
2605
+ else {
2606
+ self.attachShadow({ mode: 'open' });
2607
+ }
2608
+ }
2609
+ else if (!BUILD.hydrateServerSide && !('shadowRoot' in self)) {
2610
+ self.shadowRoot = self;
2611
+ }
2612
+ }
2613
+ if (BUILD.slotChildNodesFix) {
2614
+ patchChildSlotNodes(self, cmpMeta);
2615
+ }
2616
+ }
2617
+ connectedCallback() {
2618
+ if (appLoadFallback) {
2619
+ clearTimeout(appLoadFallback);
2620
+ appLoadFallback = null;
2621
+ }
2622
+ if (isBootstrapping) {
2623
+ // connectedCallback will be processed once all components have been registered
2624
+ deferredConnectedCallbacks.push(this);
2625
+ }
2626
+ else {
2627
+ plt.jmp(() => connectedCallback(this));
2628
+ }
2629
+ }
2630
+ disconnectedCallback() {
2631
+ plt.jmp(() => disconnectedCallback(this));
2632
+ }
2633
+ componentOnReady() {
2634
+ return getHostRef(this).$onReadyPromise$;
2635
+ }
2636
+ };
2637
+ if (BUILD.cloneNodeFix) {
2638
+ patchCloneNode(HostElement.prototype);
2639
+ }
2640
+ if (BUILD.appendChildSlotFix) {
2641
+ patchSlotAppendChild(HostElement.prototype);
2642
+ }
2643
+ if (BUILD.hotModuleReplacement) {
2644
+ HostElement.prototype['s-hmr'] = function (hmrVersionId) {
2645
+ hmrStart(this, cmpMeta, hmrVersionId);
2646
+ };
2647
+ }
2648
+ if (BUILD.scopedSlotTextContentFix) {
2649
+ patchTextContent(HostElement.prototype, cmpMeta);
2650
+ }
2651
+ cmpMeta.$lazyBundleId$ = lazyBundle[0];
2652
+ if (!exclude.includes(tagName) && !customElements.get(tagName)) {
2653
+ cmpTags.push(tagName);
2654
+ customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
2655
+ }
2656
+ });
2657
+ });
2658
+ if (BUILD.invisiblePrehydration && (BUILD.hydratedClass || BUILD.hydratedAttribute)) {
2659
+ visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
2660
+ visibilityStyle.setAttribute('data-styles', '');
2661
+ head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
2662
+ }
2663
+ // Process deferred connectedCallbacks now all components have been registered
2664
+ isBootstrapping = false;
2665
+ if (deferredConnectedCallbacks.length) {
2666
+ deferredConnectedCallbacks.map((host) => host.connectedCallback());
2667
+ }
2668
+ else {
2669
+ if (BUILD.profile) {
2670
+ plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30, 'timeout')));
2671
+ }
2672
+ else {
2673
+ plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
2674
+ }
2675
+ }
2676
+ // Fallback appLoad event
2677
+ endBootstrap();
2678
+ };
2679
+ const getAssetPath = (path) => {
2680
+ const assetUrl = new URL(path, plt.$resourcesUrl$);
2681
+ return assetUrl.origin !== win.location.origin ? assetUrl.href : assetUrl.pathname;
2682
+ };
2683
+ const setAssetPath = (path) => (plt.$resourcesUrl$ = path);
2684
+ const getConnect = (_ref, tagName) => {
2685
+ const componentOnReady = () => {
2686
+ let elm = doc.querySelector(tagName);
2687
+ if (!elm) {
2688
+ elm = doc.createElement(tagName);
2689
+ doc.body.appendChild(elm);
2690
+ }
2691
+ return typeof elm.componentOnReady === 'function' ? elm.componentOnReady() : Promise.resolve(elm);
2692
+ };
2693
+ const create = (...args) => {
2694
+ return componentOnReady().then((el) => el.create(...args));
2695
+ };
2696
+ return {
2697
+ create,
2698
+ componentOnReady,
2699
+ };
2700
+ };
2701
+ const getContext = (_elm, context) => {
2702
+ if (context in Context) {
2703
+ return Context[context];
2704
+ }
2705
+ else if (context === 'window') {
2706
+ return win;
2707
+ }
2708
+ else if (context === 'document') {
2709
+ return doc;
2710
+ }
2711
+ else if (context === 'isServer' || context === 'isPrerender') {
2712
+ return BUILD.hydrateServerSide ? true : false;
2713
+ }
2714
+ else if (context === 'isClient') {
2715
+ return BUILD.hydrateServerSide ? false : true;
2716
+ }
2717
+ else if (context === 'resourcesUrl' || context === 'publicPath') {
2718
+ return getAssetPath('.');
2719
+ }
2720
+ else if (context === 'queue') {
2721
+ return {
2722
+ write: writeTask,
2723
+ read: readTask,
2724
+ tick: {
2725
+ then(cb) {
2726
+ return nextTick(cb);
2727
+ },
2728
+ },
2729
+ };
2730
+ }
2731
+ return undefined;
2732
+ };
2733
+ const insertVdomAnnotations = (doc, staticComponents) => {
2734
+ if (doc != null) {
2735
+ const docData = {
2736
+ hostIds: 0,
2737
+ rootLevelIds: 0,
2738
+ staticComponents: new Set(staticComponents),
2739
+ };
2740
+ const orgLocationNodes = [];
2741
+ parseVNodeAnnotations(doc, doc.body, docData, orgLocationNodes);
2742
+ orgLocationNodes.forEach((orgLocationNode) => {
2743
+ if (orgLocationNode != null) {
2744
+ const nodeRef = orgLocationNode['s-nr'];
2745
+ let hostId = nodeRef['s-host-id'];
2746
+ let nodeId = nodeRef['s-node-id'];
2747
+ let childId = `${hostId}.${nodeId}`;
2748
+ if (hostId == null) {
2749
+ hostId = 0;
2750
+ docData.rootLevelIds++;
2751
+ nodeId = docData.rootLevelIds;
2752
+ childId = `${hostId}.${nodeId}`;
2753
+ if (nodeRef.nodeType === 1 /* ElementNode */) {
2754
+ nodeRef.setAttribute(HYDRATE_CHILD_ID, childId);
2755
+ }
2756
+ else if (nodeRef.nodeType === 3 /* TextNode */) {
2757
+ if (hostId === 0) {
2758
+ const textContent = nodeRef.nodeValue.trim();
2759
+ if (textContent === '') {
2760
+ // useless whitespace node at the document root
2761
+ orgLocationNode.remove();
2762
+ return;
2763
+ }
2764
+ }
2765
+ const commentBeforeTextNode = doc.createComment(childId);
2766
+ commentBeforeTextNode.nodeValue = `${TEXT_NODE_ID}.${childId}`;
2767
+ nodeRef.parentNode.insertBefore(commentBeforeTextNode, nodeRef);
2768
+ }
2769
+ }
2770
+ let orgLocationNodeId = `${ORG_LOCATION_ID}.${childId}`;
2771
+ const orgLocationParentNode = orgLocationNode.parentElement;
2772
+ if (orgLocationParentNode) {
2773
+ if (orgLocationParentNode['s-en'] === '') {
2774
+ // ending with a "." means that the parent element
2775
+ // of this node's original location is a SHADOW dom element
2776
+ // and this node is apart of the root level light dom
2777
+ orgLocationNodeId += `.`;
2778
+ }
2779
+ else if (orgLocationParentNode['s-en'] === 'c') {
2780
+ // ending with a ".c" means that the parent element
2781
+ // of this node's original location is a SCOPED element
2782
+ // and this node is apart of the root level light dom
2783
+ orgLocationNodeId += `.c`;
2784
+ }
2785
+ }
2786
+ orgLocationNode.nodeValue = orgLocationNodeId;
2787
+ }
2788
+ });
2789
+ }
2790
+ };
2791
+ const parseVNodeAnnotations = (doc, node, docData, orgLocationNodes) => {
2792
+ if (node == null) {
2793
+ return;
2794
+ }
2795
+ if (node['s-nr'] != null) {
2796
+ orgLocationNodes.push(node);
2797
+ }
2798
+ if (node.nodeType === 1 /* ElementNode */) {
2799
+ node.childNodes.forEach((childNode) => {
2800
+ const hostRef = getHostRef(childNode);
2801
+ if (hostRef != null && !docData.staticComponents.has(childNode.nodeName.toLowerCase())) {
2802
+ const cmpData = {
2803
+ nodeIds: 0,
2804
+ };
2805
+ insertVNodeAnnotations(doc, childNode, hostRef.$vnode$, docData, cmpData);
2806
+ }
2807
+ parseVNodeAnnotations(doc, childNode, docData, orgLocationNodes);
2808
+ });
2809
+ }
2810
+ };
2811
+ const insertVNodeAnnotations = (doc, hostElm, vnode, docData, cmpData) => {
2812
+ if (vnode != null) {
2813
+ const hostId = ++docData.hostIds;
2814
+ hostElm.setAttribute(HYDRATE_ID, hostId);
2815
+ if (hostElm['s-cr'] != null) {
2816
+ hostElm['s-cr'].nodeValue = `${CONTENT_REF_ID}.${hostId}`;
2817
+ }
2818
+ if (vnode.$children$ != null) {
2819
+ const depth = 0;
2820
+ vnode.$children$.forEach((vnodeChild, index) => {
2821
+ insertChildVNodeAnnotations(doc, vnodeChild, cmpData, hostId, depth, index);
2822
+ });
2823
+ }
2824
+ if (hostElm && vnode && vnode.$elm$ && !hostElm.hasAttribute('c-id')) {
2825
+ const parent = hostElm.parentElement;
2826
+ if (parent && parent.childNodes) {
2827
+ const parentChildNodes = Array.from(parent.childNodes);
2828
+ const comment = parentChildNodes.find((node) => node.nodeType === 8 /* CommentNode */ && node['s-sr']);
2829
+ if (comment) {
2830
+ const index = parentChildNodes.indexOf(hostElm) - 1;
2831
+ vnode.$elm$.setAttribute(HYDRATE_CHILD_ID, `${comment['s-host-id']}.${comment['s-node-id']}.0.${index}`);
2832
+ }
2833
+ }
2834
+ }
2835
+ }
2836
+ };
2837
+ const insertChildVNodeAnnotations = (doc, vnodeChild, cmpData, hostId, depth, index) => {
2838
+ const childElm = vnodeChild.$elm$;
2839
+ if (childElm == null) {
2840
+ return;
2841
+ }
2842
+ const nodeId = cmpData.nodeIds++;
2843
+ const childId = `${hostId}.${nodeId}.${depth}.${index}`;
2844
+ childElm['s-host-id'] = hostId;
2845
+ childElm['s-node-id'] = nodeId;
2846
+ if (childElm.nodeType === 1 /* ElementNode */) {
2847
+ childElm.setAttribute(HYDRATE_CHILD_ID, childId);
2848
+ }
2849
+ else if (childElm.nodeType === 3 /* TextNode */) {
2850
+ const parentNode = childElm.parentNode;
2851
+ const nodeName = parentNode.nodeName;
2852
+ if (nodeName !== 'STYLE' && nodeName !== 'SCRIPT') {
2853
+ const textNodeId = `${TEXT_NODE_ID}.${childId}`;
2854
+ const commentBeforeTextNode = doc.createComment(textNodeId);
2855
+ parentNode.insertBefore(commentBeforeTextNode, childElm);
2856
+ }
2857
+ }
2858
+ else if (childElm.nodeType === 8 /* CommentNode */) {
2859
+ if (childElm['s-sr']) {
2860
+ const slotName = childElm['s-sn'] || '';
2861
+ const slotNodeId = `${SLOT_NODE_ID}.${childId}.${slotName}`;
2862
+ childElm.nodeValue = slotNodeId;
2863
+ }
2864
+ }
2865
+ if (vnodeChild.$children$ != null) {
2866
+ const childDepth = depth + 1;
2867
+ vnodeChild.$children$.forEach((vnode, index) => {
2868
+ insertChildVNodeAnnotations(doc, vnode, cmpData, hostId, childDepth, index);
2869
+ });
2870
+ }
2871
+ };
2872
+ const setPlatformOptions = (opts) => Object.assign(plt, opts);
2873
+ const Fragment = (_, children) => children;
2874
+ const hostRefs = new WeakMap();
2875
+ const getHostRef = (ref) => hostRefs.get(ref);
2876
+ const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
2877
+ const registerHost = (elm, cmpMeta) => {
2878
+ const hostRef = {
2879
+ $flags$: 0,
2880
+ $hostElement$: elm,
2881
+ $cmpMeta$: cmpMeta,
2882
+ $instanceValues$: new Map(),
2883
+ };
2884
+ if (BUILD.isDev) {
2885
+ hostRef.$renderCount$ = 0;
2886
+ }
2887
+ if (BUILD.method && BUILD.lazyLoad) {
2888
+ hostRef.$onInstancePromise$ = new Promise((r) => (hostRef.$onInstanceResolve$ = r));
2889
+ }
2890
+ if (BUILD.asyncLoading) {
2891
+ hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
2892
+ elm['s-p'] = [];
2893
+ elm['s-rc'] = [];
2894
+ }
2895
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, false);
2896
+ return hostRefs.set(elm, hostRef);
2897
+ };
2898
+ const isMemberInElement = (elm, memberName) => memberName in elm;
2899
+ const consoleError = (e, el) => (customError || console.error)(e, el);
2900
+ const STENCIL_DEV_MODE = BUILD.isTesting
2901
+ ? ['STENCIL:'] // E2E testing
2902
+ : [
2903
+ '%cstencil',
2904
+ 'color: white;background:#4c47ff;font-weight: bold; font-size:10px; padding:2px 6px; border-radius: 5px',
2905
+ ];
2906
+ const consoleDevError = (...m) => console.error(...STENCIL_DEV_MODE, ...m);
2907
+ const consoleDevWarn = (...m) => console.warn(...STENCIL_DEV_MODE, ...m);
2908
+ const consoleDevInfo = (...m) => console.info(...STENCIL_DEV_MODE, ...m);
2909
+ const setErrorHandler = (handler) => (customError = handler);
2910
+ const cmpModules = /*@__PURE__*/ new Map();
2911
+ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
2912
+ // loadModuleImport
2913
+ const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
2914
+ const bundleId = cmpMeta.$lazyBundleId$;
2915
+ if (BUILD.isDev && typeof bundleId !== 'string') {
2916
+ consoleDevError(`Trying to lazily load component <${cmpMeta.$tagName$}> with style mode "${hostRef.$modeName$}", but it does not exist.`);
2917
+ return undefined;
2918
+ }
2919
+ const module = !BUILD.hotModuleReplacement ? cmpModules.get(bundleId) : false;
2920
+ if (module) {
2921
+ return module[exportName];
2922
+ }
2923
+ return import(
2924
+ /* webpackInclude: /\.entry\.js$/ */
2925
+ /* webpackExclude: /\.system\.entry\.js$/ */
2926
+ /* webpackMode: "lazy" */
2927
+ `./${bundleId}.entry.js${BUILD.hotModuleReplacement && hmrVersionId ? '?s-hmr=' + hmrVersionId : ''}`).then((importedModule) => {
2928
+ if (!BUILD.hotModuleReplacement) {
2929
+ cmpModules.set(bundleId, importedModule);
2930
+ }
2931
+ return importedModule[exportName];
2932
+ }, consoleError);
2933
+ };
2934
+ const styles = new Map();
2935
+ const modeResolutionChain = [];
2936
+ const queueDomReads = [];
2937
+ const queueDomWrites = [];
2938
+ const queueDomWritesLow = [];
2939
+ const queueTask = (queue, write) => (cb) => {
2940
+ queue.push(cb);
2941
+ if (!queuePending) {
2942
+ queuePending = true;
2943
+ if (write && plt.$flags$ & 4 /* queueSync */) {
2944
+ nextTick(flush);
2945
+ }
2946
+ else {
2947
+ plt.raf(flush);
2948
+ }
2949
+ }
2950
+ };
2951
+ const consume = (queue) => {
2952
+ for (let i = 0; i < queue.length; i++) {
2953
+ try {
2954
+ queue[i](performance.now());
2955
+ }
2956
+ catch (e) {
2957
+ consoleError(e);
2958
+ }
2959
+ }
2960
+ queue.length = 0;
2961
+ };
2962
+ const consumeTimeout = (queue, timeout) => {
2963
+ let i = 0;
2964
+ let ts = 0;
2965
+ while (i < queue.length && (ts = performance.now()) < timeout) {
2966
+ try {
2967
+ queue[i++](ts);
2968
+ }
2969
+ catch (e) {
2970
+ consoleError(e);
2971
+ }
2972
+ }
2973
+ if (i === queue.length) {
2974
+ queue.length = 0;
2975
+ }
2976
+ else if (i !== 0) {
2977
+ queue.splice(0, i);
2978
+ }
2979
+ };
2980
+ const flush = () => {
2981
+ if (BUILD.asyncQueue) {
2982
+ queueCongestion++;
2983
+ }
2984
+ // always force a bunch of medium callbacks to run, but still have
2985
+ // a throttle on how many can run in a certain time
2986
+ // DOM READS!!!
2987
+ consume(queueDomReads);
2988
+ // DOM WRITES!!!
2989
+ if (BUILD.asyncQueue) {
2990
+ const timeout = (plt.$flags$ & 6 /* queueMask */) === 2 /* appLoaded */
2991
+ ? performance.now() + 14 * Math.ceil(queueCongestion * (1.0 / 10.0))
2992
+ : Infinity;
2993
+ consumeTimeout(queueDomWrites, timeout);
2994
+ consumeTimeout(queueDomWritesLow, timeout);
2995
+ if (queueDomWrites.length > 0) {
2996
+ queueDomWritesLow.push(...queueDomWrites);
2997
+ queueDomWrites.length = 0;
2998
+ }
2999
+ if ((queuePending = queueDomReads.length + queueDomWrites.length + queueDomWritesLow.length > 0)) {
3000
+ // still more to do yet, but we've run out of time
3001
+ // let's let this thing cool off and try again in the next tick
3002
+ plt.raf(flush);
3003
+ }
3004
+ else {
3005
+ queueCongestion = 0;
3006
+ }
3007
+ }
3008
+ else {
3009
+ consume(queueDomWrites);
3010
+ if ((queuePending = queueDomReads.length > 0)) {
3011
+ // still more to do yet, but we've run out of time
3012
+ // let's let this thing cool off and try again in the next tick
3013
+ plt.raf(flush);
3014
+ }
3015
+ }
3016
+ };
3017
+ const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
3018
+ const readTask = /*@__PURE__*/ queueTask(queueDomReads, false);
3019
+ const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
3020
+ const Build = {
3021
+ isDev: BUILD.isDev ? true : false,
3022
+ isBrowser: true,
3023
+ isServer: false,
3024
+ isTesting: BUILD.isTesting ? true : false,
3025
+ };
3026
+
3027
+ export { BUILD as B, CSS as C, H, NAMESPACE as N, promiseResolve as a, bootstrapLazy as b, consoleDevInfo as c, doc as d, createEvent as e, Host as f, getElement as g, h, getAssetPath as i, plt as p, registerInstance as r, win as w };