@maggioli-design-system/mds-input-tip-item 1.0.0

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 (192) hide show
  1. package/dist/cjs/index-8ba1476a.js +1640 -0
  2. package/dist/cjs/index.cjs.js +2 -0
  3. package/dist/cjs/loader.cjs.js +13 -0
  4. package/dist/cjs/mds-input-tip-item.cjs.entry.js +75 -0
  5. package/dist/cjs/mds-input-tip-item.cjs.js +23 -0
  6. package/dist/collection/collection-manifest.json +12 -0
  7. package/dist/collection/common/aria.js +29 -0
  8. package/dist/collection/common/file.js +48 -0
  9. package/dist/collection/common/icon.js +15 -0
  10. package/dist/collection/common/keyboard-manager.js +45 -0
  11. package/dist/collection/common/locale.js +20 -0
  12. package/dist/collection/common/unit.js +22 -0
  13. package/dist/collection/common/yugop/core.js +16 -0
  14. package/dist/collection/common/yugop/index.js +3 -0
  15. package/dist/collection/common/yugop/random-text.js +59 -0
  16. package/dist/collection/common/yugop/utils/math.js +11 -0
  17. package/dist/collection/common/yugop/utils/noop.js +1 -0
  18. package/dist/collection/common/yugop/utils/prng.js +21 -0
  19. package/dist/collection/common/yugop/utils/string.js +2 -0
  20. package/dist/collection/components/mds-input-tip-item/mds-input-tip-item.css +306 -0
  21. package/dist/collection/components/mds-input-tip-item/mds-input-tip-item.js +85 -0
  22. package/dist/collection/components/mds-input-tip-item/meta/types.js +1 -0
  23. package/dist/collection/components/mds-input-tip-item/test/mds-input-tip-item.e2e.js +9 -0
  24. package/dist/collection/dictionary/autocomplete.js +59 -0
  25. package/dist/collection/dictionary/button.js +30 -0
  26. package/dist/collection/dictionary/color.js +19 -0
  27. package/dist/collection/dictionary/file-extensions.js +64 -0
  28. package/dist/collection/dictionary/floating-ui.js +19 -0
  29. package/dist/collection/dictionary/icon.js +10 -0
  30. package/dist/collection/dictionary/input.js +37 -0
  31. package/dist/collection/dictionary/loading.js +5 -0
  32. package/dist/collection/dictionary/text.js +6 -0
  33. package/dist/collection/dictionary/typography.js +67 -0
  34. package/dist/collection/dictionary/variant.js +90 -0
  35. package/dist/collection/fixtures/cities.js +110 -0
  36. package/dist/collection/fixtures/filenames.js +57 -0
  37. package/dist/collection/interface/input-value.js +1 -0
  38. package/dist/collection/type/autocomplete.js +1 -0
  39. package/dist/collection/type/button.js +1 -0
  40. package/dist/collection/type/file-types.js +1 -0
  41. package/dist/collection/type/floating-ui.js +1 -0
  42. package/dist/collection/type/form-rel.js +1 -0
  43. package/dist/collection/type/input.js +1 -0
  44. package/dist/collection/type/loading.js +1 -0
  45. package/dist/collection/type/text.js +1 -0
  46. package/dist/collection/type/typography.js +1 -0
  47. package/dist/collection/type/variant-file-format.js +120 -0
  48. package/dist/collection/type/variant.js +1 -0
  49. package/dist/components/index.d.ts +33 -0
  50. package/dist/components/index.js +1 -0
  51. package/dist/components/mds-input-tip-item.d.ts +11 -0
  52. package/dist/components/mds-input-tip-item.js +92 -0
  53. package/dist/documentation.d.ts +401 -0
  54. package/dist/documentation.json +109 -0
  55. package/dist/esm/index-9bfcacb5.js +1612 -0
  56. package/dist/esm/index.js +1 -0
  57. package/dist/esm/loader.js +9 -0
  58. package/dist/esm/mds-input-tip-item.entry.js +71 -0
  59. package/dist/esm/mds-input-tip-item.js +18 -0
  60. package/dist/esm/polyfills/core-js.js +11 -0
  61. package/dist/esm/polyfills/dom.js +79 -0
  62. package/dist/esm/polyfills/es5-html-element.js +1 -0
  63. package/dist/esm/polyfills/index.js +34 -0
  64. package/dist/esm/polyfills/system.js +6 -0
  65. package/dist/esm-es5/index-9bfcacb5.js +1 -0
  66. package/dist/esm-es5/index.js +0 -0
  67. package/dist/esm-es5/loader.js +1 -0
  68. package/dist/esm-es5/mds-input-tip-item.entry.js +1 -0
  69. package/dist/esm-es5/mds-input-tip-item.js +1 -0
  70. package/dist/index.cjs.js +1 -0
  71. package/dist/index.js +1 -0
  72. package/dist/mds-input-tip-item/index.esm.js +0 -0
  73. package/dist/mds-input-tip-item/mds-input-tip-item.esm.js +1 -0
  74. package/dist/mds-input-tip-item/mds-input-tip-item.js +127 -0
  75. package/dist/mds-input-tip-item/p-50ea2036.system.js +1 -0
  76. package/dist/mds-input-tip-item/p-96fd552b.entry.js +1 -0
  77. package/dist/mds-input-tip-item/p-9d931dda.js +2 -0
  78. package/dist/mds-input-tip-item/p-bc4a4db2.system.js +2 -0
  79. package/dist/mds-input-tip-item/p-e8f8ccd0.system.entry.js +1 -0
  80. package/dist/mds-input-tip-item/p-eb883bae.system.js +1 -0
  81. package/dist/stats.json +515 -0
  82. package/dist/types/common/aria.d.ts +5 -0
  83. package/dist/types/common/file.d.ts +12 -0
  84. package/dist/types/common/icon.d.ts +5 -0
  85. package/dist/types/common/keyboard-manager.d.ts +12 -0
  86. package/dist/types/common/locale.d.ts +14 -0
  87. package/dist/types/common/unit.d.ts +3 -0
  88. package/dist/types/common/yugop/core.d.ts +10 -0
  89. package/dist/types/common/yugop/index.d.ts +1 -0
  90. package/dist/types/common/yugop/random-text.d.ts +31 -0
  91. package/dist/types/common/yugop/utils/math.d.ts +3 -0
  92. package/dist/types/common/yugop/utils/noop.d.ts +1 -0
  93. package/dist/types/common/yugop/utils/prng.d.ts +8 -0
  94. package/dist/types/common/yugop/utils/string.d.ts +1 -0
  95. package/dist/types/components/mds-input-tip-item/mds-input-tip-item.d.ts +15 -0
  96. package/dist/types/components/mds-input-tip-item/meta/types.d.ts +1 -0
  97. package/dist/types/components.d.ts +55 -0
  98. package/dist/types/dictionary/autocomplete.d.ts +2 -0
  99. package/dist/types/dictionary/button.d.ts +6 -0
  100. package/dist/types/dictionary/color.d.ts +3 -0
  101. package/dist/types/dictionary/file-extensions.d.ts +11 -0
  102. package/dist/types/dictionary/floating-ui.d.ts +3 -0
  103. package/dist/types/dictionary/icon.d.ts +4 -0
  104. package/dist/types/dictionary/input.d.ts +5 -0
  105. package/dist/types/dictionary/loading.d.ts +2 -0
  106. package/dist/types/dictionary/text.d.ts +2 -0
  107. package/dist/types/dictionary/typography.d.ts +11 -0
  108. package/dist/types/dictionary/variant.d.ts +11 -0
  109. package/dist/types/fixtures/cities.d.ts +2 -0
  110. package/dist/types/fixtures/filenames.d.ts +2 -0
  111. package/dist/types/interface/input-value.d.ts +4 -0
  112. package/dist/types/stencil-public-runtime.d.ts +1681 -0
  113. package/dist/types/type/autocomplete.d.ts +2 -0
  114. package/dist/types/type/button.d.ts +5 -0
  115. package/dist/types/type/file-types.d.ts +1 -0
  116. package/dist/types/type/floating-ui.d.ts +2 -0
  117. package/dist/types/type/form-rel.d.ts +1 -0
  118. package/dist/types/type/input.d.ts +4 -0
  119. package/dist/types/type/loading.d.ts +1 -0
  120. package/dist/types/type/text.d.ts +1 -0
  121. package/dist/types/type/typography.d.ts +10 -0
  122. package/dist/types/type/variant-file-format.d.ts +11 -0
  123. package/dist/types/type/variant.d.ts +12 -0
  124. package/documentation.json +585 -0
  125. package/loader/cdn.js +3 -0
  126. package/loader/index.cjs.js +3 -0
  127. package/loader/index.d.ts +21 -0
  128. package/loader/index.es2017.js +3 -0
  129. package/loader/index.js +4 -0
  130. package/loader/package.json +11 -0
  131. package/package.json +59 -0
  132. package/readme.md +38 -0
  133. package/src/common/aria.ts +39 -0
  134. package/src/common/file.ts +63 -0
  135. package/src/common/icon.ts +25 -0
  136. package/src/common/keyboard-manager.ts +50 -0
  137. package/src/common/locale.ts +31 -0
  138. package/src/common/unit.ts +33 -0
  139. package/src/common/yugop/core.ts +47 -0
  140. package/src/common/yugop/index.ts +4 -0
  141. package/src/common/yugop/random-text.ts +95 -0
  142. package/src/common/yugop/utils/math.ts +21 -0
  143. package/src/common/yugop/utils/noop.ts +1 -0
  144. package/src/common/yugop/utils/prng.ts +35 -0
  145. package/src/common/yugop/utils/string.ts +4 -0
  146. package/src/components/mds-input-tip-item/.gitlab-ci.yml +25 -0
  147. package/src/components/mds-input-tip-item/mds-input-tip-item.css +96 -0
  148. package/src/components/mds-input-tip-item/mds-input-tip-item.tsx +66 -0
  149. package/src/components/mds-input-tip-item/meta/locale.en.json +5 -0
  150. package/src/components/mds-input-tip-item/meta/locale.it.json +5 -0
  151. package/src/components/mds-input-tip-item/meta/types.ts +6 -0
  152. package/src/components/mds-input-tip-item/readme.md +18 -0
  153. package/src/components/mds-input-tip-item/test/mds-input-tip-item.e2e.ts +11 -0
  154. package/src/components.d.ts +55 -0
  155. package/src/dictionary/autocomplete.ts +62 -0
  156. package/src/dictionary/button.ts +41 -0
  157. package/src/dictionary/color.ts +24 -0
  158. package/src/dictionary/file-extensions.ts +81 -0
  159. package/src/dictionary/floating-ui.ts +25 -0
  160. package/src/dictionary/icon.ts +15 -0
  161. package/src/dictionary/input.ts +48 -0
  162. package/src/dictionary/loading.ts +9 -0
  163. package/src/dictionary/text.ts +9 -0
  164. package/src/dictionary/typography.ts +88 -0
  165. package/src/dictionary/variant.ts +111 -0
  166. package/src/fixtures/cities.ts +116 -0
  167. package/src/fixtures/filenames.ts +60 -0
  168. package/src/fixtures/icons.json +344 -0
  169. package/src/fixtures/iconsauce.json +257 -0
  170. package/src/interface/input-value.ts +5 -0
  171. package/src/tailwind/components.css +15 -0
  172. package/src/type/autocomplete.ts +69 -0
  173. package/src/type/button.ts +28 -0
  174. package/src/type/file-types.ts +55 -0
  175. package/src/type/floating-ui.ts +17 -0
  176. package/src/type/form-rel.ts +11 -0
  177. package/src/type/input.ts +25 -0
  178. package/src/type/loading.ts +3 -0
  179. package/src/type/text.ts +4 -0
  180. package/src/type/typography.ts +65 -0
  181. package/src/type/variant-file-format.ts +137 -0
  182. package/src/type/variant.ts +99 -0
  183. package/www/build/index.esm.js +0 -0
  184. package/www/build/mds-input-tip-item.esm.js +1 -0
  185. package/www/build/mds-input-tip-item.js +127 -0
  186. package/www/build/p-50ea2036.system.js +1 -0
  187. package/www/build/p-96fd552b.entry.js +1 -0
  188. package/www/build/p-9d931dda.js +2 -0
  189. package/www/build/p-bc4a4db2.system.js +2 -0
  190. package/www/build/p-e8f8ccd0.system.entry.js +1 -0
  191. package/www/build/p-eb883bae.system.js +1 -0
  192. package/www/host.config.json +15 -0
@@ -0,0 +1,1640 @@
1
+ 'use strict';
2
+
3
+ function _interopNamespace(e) {
4
+ if (e && e.__esModule) return e;
5
+ var n = Object.create(null);
6
+ if (e) {
7
+ Object.keys(e).forEach(function (k) {
8
+ if (k !== 'default') {
9
+ var d = Object.getOwnPropertyDescriptor(e, k);
10
+ Object.defineProperty(n, k, d.get ? d : {
11
+ enumerable: true,
12
+ get: function () {
13
+ return e[k];
14
+ }
15
+ });
16
+ }
17
+ });
18
+ }
19
+ n['default'] = e;
20
+ return Object.freeze(n);
21
+ }
22
+
23
+ const NAMESPACE = 'mds-input-tip-item';
24
+
25
+ /**
26
+ * Virtual DOM patching algorithm based on Snabbdom by
27
+ * Simon Friis Vindum (@paldepind)
28
+ * Licensed under the MIT License
29
+ * https://github.com/snabbdom/snabbdom/blob/master/LICENSE
30
+ *
31
+ * Modified for Stencil's renderer and slot projection
32
+ */
33
+ let scopeId;
34
+ let hostTagName;
35
+ let isSvgMode = false;
36
+ let queuePending = false;
37
+ const createTime = (fnName, tagName = '') => {
38
+ {
39
+ return () => {
40
+ return;
41
+ };
42
+ }
43
+ };
44
+ const uniqueTime = (key, measureText) => {
45
+ {
46
+ return () => {
47
+ return;
48
+ };
49
+ }
50
+ };
51
+ const HYDRATED_CSS = '{visibility:hidden}[hydrated]{visibility:inherit}';
52
+ /**
53
+ * Constant for styles to be globally applied to `slot-fb` elements for pseudo-slot behavior.
54
+ *
55
+ * Two cascading rules must be used instead of a `:not()` selector due to Stencil browser
56
+ * support as of Stencil v4.
57
+ */
58
+ const SLOT_FB_CSS = 'slot-fb{display:contents}slot-fb[hidden]{display:none}';
59
+ /**
60
+ * Default style mode id
61
+ */
62
+ /**
63
+ * Reusable empty obj/array
64
+ * Don't add values to these!!
65
+ */
66
+ const EMPTY_OBJ = {};
67
+ const isDef = (v) => v != null;
68
+ /**
69
+ * Check whether a value is a 'complex type', defined here as an object or a
70
+ * function.
71
+ *
72
+ * @param o the value to check
73
+ * @returns whether it's a complex type or not
74
+ */
75
+ const isComplexType = (o) => {
76
+ // https://jsperf.com/typeof-fn-object/5
77
+ o = typeof o;
78
+ return o === 'object' || o === 'function';
79
+ };
80
+ /**
81
+ * Helper method for querying a `meta` tag that contains a nonce value
82
+ * out of a DOM's head.
83
+ *
84
+ * @param doc The DOM containing the `head` to query against
85
+ * @returns The content of the meta tag representing the nonce value, or `undefined` if no tag
86
+ * exists or the tag has no content.
87
+ */
88
+ function queryNonceMetaTagContent(doc) {
89
+ var _a, _b, _c;
90
+ return (_c = (_b = (_a = doc.head) === null || _a === void 0 ? void 0 : _a.querySelector('meta[name="csp-nonce"]')) === null || _b === void 0 ? void 0 : _b.getAttribute('content')) !== null && _c !== void 0 ? _c : undefined;
91
+ }
92
+ /**
93
+ * Production h() function based on Preact by
94
+ * Jason Miller (@developit)
95
+ * Licensed under the MIT License
96
+ * https://github.com/developit/preact/blob/master/LICENSE
97
+ *
98
+ * Modified for Stencil's compiler and vdom
99
+ */
100
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
101
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
102
+ const h = (nodeName, vnodeData, ...children) => {
103
+ let child = null;
104
+ let simple = false;
105
+ let lastSimple = false;
106
+ const vNodeChildren = [];
107
+ const walk = (c) => {
108
+ for (let i = 0; i < c.length; i++) {
109
+ child = c[i];
110
+ if (Array.isArray(child)) {
111
+ walk(child);
112
+ }
113
+ else if (child != null && typeof child !== 'boolean') {
114
+ if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
115
+ child = String(child);
116
+ }
117
+ if (simple && lastSimple) {
118
+ // If the previous child was simple (string), we merge both
119
+ vNodeChildren[vNodeChildren.length - 1].$text$ += child;
120
+ }
121
+ else {
122
+ // Append a new vNode, if it's text, we create a text vNode
123
+ vNodeChildren.push(simple ? newVNode(null, child) : child);
124
+ }
125
+ lastSimple = simple;
126
+ }
127
+ }
128
+ };
129
+ walk(children);
130
+ if (vnodeData) {
131
+ // normalize class / className attributes
132
+ {
133
+ const classData = vnodeData.className || vnodeData.class;
134
+ if (classData) {
135
+ vnodeData.class =
136
+ typeof classData !== 'object'
137
+ ? classData
138
+ : Object.keys(classData)
139
+ .filter((k) => classData[k])
140
+ .join(' ');
141
+ }
142
+ }
143
+ }
144
+ const vnode = newVNode(nodeName, null);
145
+ vnode.$attrs$ = vnodeData;
146
+ if (vNodeChildren.length > 0) {
147
+ vnode.$children$ = vNodeChildren;
148
+ }
149
+ return vnode;
150
+ };
151
+ /**
152
+ * A utility function for creating a virtual DOM node from a tag and some
153
+ * possible text content.
154
+ *
155
+ * @param tag the tag for this element
156
+ * @param text possible text content for the node
157
+ * @returns a newly-minted virtual DOM node
158
+ */
159
+ const newVNode = (tag, text) => {
160
+ const vnode = {
161
+ $flags$: 0,
162
+ $tag$: tag,
163
+ $text$: text,
164
+ $elm$: null,
165
+ $children$: null,
166
+ };
167
+ {
168
+ vnode.$attrs$ = null;
169
+ }
170
+ return vnode;
171
+ };
172
+ const Host = {};
173
+ /**
174
+ * Check whether a given node is a Host node or not
175
+ *
176
+ * @param node the virtual DOM node to check
177
+ * @returns whether it's a Host node or not
178
+ */
179
+ const isHost = (node) => node && node.$tag$ === Host;
180
+ /**
181
+ * Parse a new property value for a given property type.
182
+ *
183
+ * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
184
+ * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
185
+ * 1. `any`, the type given to `propValue` in the function signature
186
+ * 2. the type stored from `propType`.
187
+ *
188
+ * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
189
+ *
190
+ * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
191
+ * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
192
+ * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
193
+ * ```tsx
194
+ * <my-cmp prop-val={0}></my-cmp>
195
+ * ```
196
+ *
197
+ * HTML prop values on the other hand, will always a string
198
+ *
199
+ * @param propValue the new value to coerce to some type
200
+ * @param propType the type of the prop, expressed as a binary number
201
+ * @returns the parsed/coerced value
202
+ */
203
+ const parsePropertyValue = (propValue, propType) => {
204
+ // ensure this value is of the correct prop type
205
+ if (propValue != null && !isComplexType(propValue)) {
206
+ if (propType & 4 /* MEMBER_FLAGS.Boolean */) {
207
+ // per the HTML spec, any string value means it is a boolean true value
208
+ // but we'll cheat here and say that the string "false" is the boolean false
209
+ return propValue === 'false' ? false : propValue === '' || !!propValue;
210
+ }
211
+ if (propType & 1 /* MEMBER_FLAGS.String */) {
212
+ // could have been passed as a number or boolean
213
+ // but we still want it as a string
214
+ return String(propValue);
215
+ }
216
+ // redundant return here for better minification
217
+ return propValue;
218
+ }
219
+ // not sure exactly what type we want
220
+ // so no need to change to a different type
221
+ return propValue;
222
+ };
223
+ const getElement = (ref) => (getHostRef(ref).$hostElement$ );
224
+ /**
225
+ * Helper function to create & dispatch a custom Event on a provided target
226
+ * @param elm the target of the Event
227
+ * @param name the name to give the custom Event
228
+ * @param opts options for configuring a custom Event
229
+ * @returns the custom Event
230
+ */
231
+ const emitEvent = (elm, name, opts) => {
232
+ const ev = plt.ce(name, opts);
233
+ elm.dispatchEvent(ev);
234
+ return ev;
235
+ };
236
+ const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
237
+ const registerStyle = (scopeId, cssText, allowCS) => {
238
+ let style = styles.get(scopeId);
239
+ if (supportsConstructableStylesheets && allowCS) {
240
+ style = (style || new CSSStyleSheet());
241
+ if (typeof style === 'string') {
242
+ style = cssText;
243
+ }
244
+ else {
245
+ style.replaceSync(cssText);
246
+ }
247
+ }
248
+ else {
249
+ style = cssText;
250
+ }
251
+ styles.set(scopeId, style);
252
+ };
253
+ const addStyle = (styleContainerNode, cmpMeta, mode) => {
254
+ var _a;
255
+ const scopeId = getScopeId(cmpMeta);
256
+ const style = styles.get(scopeId);
257
+ // if an element is NOT connected then getRootNode() will return the wrong root node
258
+ // so the fallback is to always use the document for the root node in those cases
259
+ styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
260
+ if (style) {
261
+ if (typeof style === 'string') {
262
+ styleContainerNode = styleContainerNode.head || styleContainerNode;
263
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
264
+ let styleElm;
265
+ if (!appliedStyles) {
266
+ rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
267
+ }
268
+ if (!appliedStyles.has(scopeId)) {
269
+ {
270
+ styleElm = doc.createElement('style');
271
+ styleElm.innerHTML = style;
272
+ // Apply CSP nonce to the style tag if it exists
273
+ const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
274
+ if (nonce != null) {
275
+ styleElm.setAttribute('nonce', nonce);
276
+ }
277
+ styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
278
+ }
279
+ // Add styles for `slot-fb` elements if we're using slots outside the Shadow DOM
280
+ if (cmpMeta.$flags$ & 4 /* CMP_FLAGS.hasSlotRelocation */) {
281
+ styleElm.innerHTML += SLOT_FB_CSS;
282
+ }
283
+ if (appliedStyles) {
284
+ appliedStyles.add(scopeId);
285
+ }
286
+ }
287
+ }
288
+ else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
289
+ styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
290
+ }
291
+ }
292
+ return scopeId;
293
+ };
294
+ const attachStyles = (hostRef) => {
295
+ const cmpMeta = hostRef.$cmpMeta$;
296
+ const elm = hostRef.$hostElement$;
297
+ const flags = cmpMeta.$flags$;
298
+ const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
299
+ const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
300
+ if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
301
+ // only required when we're NOT using native shadow dom (slot)
302
+ // or this browser doesn't support native shadow dom
303
+ // and this host element was NOT created with SSR
304
+ // let's pick out the inner content for slot projection
305
+ // create a node to represent where the original
306
+ // content was first placed, which is useful later on
307
+ // DOM WRITE!!
308
+ elm['s-sc'] = scopeId;
309
+ elm.classList.add(scopeId + '-h');
310
+ }
311
+ endAttachStyles();
312
+ };
313
+ const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
314
+ /**
315
+ * Production setAccessor() function based on Preact by
316
+ * Jason Miller (@developit)
317
+ * Licensed under the MIT License
318
+ * https://github.com/developit/preact/blob/master/LICENSE
319
+ *
320
+ * Modified for Stencil's compiler and vdom
321
+ */
322
+ /**
323
+ * When running a VDom render set properties present on a VDom node onto the
324
+ * corresponding HTML element.
325
+ *
326
+ * Note that this function has special functionality for the `class`,
327
+ * `style`, `key`, and `ref` attributes, as well as event handlers (like
328
+ * `onClick`, etc). All others are just passed through as-is.
329
+ *
330
+ * @param elm the HTMLElement onto which attributes should be set
331
+ * @param memberName the name of the attribute to set
332
+ * @param oldValue the old value for the attribute
333
+ * @param newValue the new value for the attribute
334
+ * @param isSvg whether we're in an svg context or not
335
+ * @param flags bitflags for Vdom variables
336
+ */
337
+ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
338
+ if (oldValue !== newValue) {
339
+ let isProp = isMemberInElement(elm, memberName);
340
+ memberName.toLowerCase();
341
+ if (memberName === 'class') {
342
+ const classList = elm.classList;
343
+ const oldClasses = parseClassList(oldValue);
344
+ const newClasses = parseClassList(newValue);
345
+ classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
346
+ classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
347
+ }
348
+ else {
349
+ // Set property if it exists and it's not a SVG
350
+ const isComplex = isComplexType(newValue);
351
+ if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
352
+ try {
353
+ if (!elm.tagName.includes('-')) {
354
+ const n = newValue == null ? '' : newValue;
355
+ // Workaround for Safari, moving the <input> caret when re-assigning the same valued
356
+ if (memberName === 'list') {
357
+ isProp = false;
358
+ }
359
+ else if (oldValue == null || elm[memberName] != n) {
360
+ elm[memberName] = n;
361
+ }
362
+ }
363
+ else {
364
+ elm[memberName] = newValue;
365
+ }
366
+ }
367
+ catch (e) {
368
+ /**
369
+ * in case someone tries to set a read-only property, e.g. "namespaceURI", we just ignore it
370
+ */
371
+ }
372
+ }
373
+ if (newValue == null || newValue === false) {
374
+ if (newValue !== false || elm.getAttribute(memberName) === '') {
375
+ {
376
+ elm.removeAttribute(memberName);
377
+ }
378
+ }
379
+ }
380
+ else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
381
+ newValue = newValue === true ? '' : newValue;
382
+ {
383
+ elm.setAttribute(memberName, newValue);
384
+ }
385
+ }
386
+ }
387
+ }
388
+ };
389
+ const parseClassListRegex = /\s/;
390
+ /**
391
+ * Parsed a string of classnames into an array
392
+ * @param value className string, e.g. "foo bar baz"
393
+ * @returns list of classes, e.g. ["foo", "bar", "baz"]
394
+ */
395
+ const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
396
+ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
397
+ // if the element passed in is a shadow root, which is a document fragment
398
+ // then we want to be adding attrs/props to the shadow root's "host" element
399
+ // if it's not a shadow root, then we add attrs/props to the same element
400
+ const elm = newVnode.$elm$.nodeType === 11 /* NODE_TYPE.DocumentFragment */ && newVnode.$elm$.host
401
+ ? newVnode.$elm$.host
402
+ : newVnode.$elm$;
403
+ const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
404
+ const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
405
+ {
406
+ // remove attributes no longer present on the vnode by setting them to undefined
407
+ for (memberName in oldVnodeAttrs) {
408
+ if (!(memberName in newVnodeAttrs)) {
409
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
410
+ }
411
+ }
412
+ }
413
+ // add new & update changed attributes
414
+ for (memberName in newVnodeAttrs) {
415
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
416
+ }
417
+ };
418
+ /**
419
+ * Create a DOM Node corresponding to one of the children of a given VNode.
420
+ *
421
+ * @param oldParentVNode the parent VNode from the previous render
422
+ * @param newParentVNode the parent VNode from the current render
423
+ * @param childIndex the index of the VNode, in the _new_ parent node's
424
+ * children, for which we will create a new DOM node
425
+ * @param parentElm the parent DOM node which our new node will be a child of
426
+ * @returns the newly created node
427
+ */
428
+ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
429
+ // tslint:disable-next-line: prefer-const
430
+ const newVNode = newParentVNode.$children$[childIndex];
431
+ let i = 0;
432
+ let elm;
433
+ let childNode;
434
+ if (newVNode.$text$ !== null) {
435
+ // create text node
436
+ elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
437
+ }
438
+ else {
439
+ // create element
440
+ elm = newVNode.$elm$ = (doc.createElement(newVNode.$tag$));
441
+ // add css classes, attrs, props, listeners, etc.
442
+ {
443
+ updateElement(null, newVNode, isSvgMode);
444
+ }
445
+ if (isDef(scopeId) && elm['s-si'] !== scopeId) {
446
+ // if there is a scopeId and this is the initial render
447
+ // then let's add the scopeId as a css class
448
+ elm.classList.add((elm['s-si'] = scopeId));
449
+ }
450
+ if (newVNode.$children$) {
451
+ for (i = 0; i < newVNode.$children$.length; ++i) {
452
+ // create the node
453
+ childNode = createElm(oldParentVNode, newVNode, i);
454
+ // return node could have been null
455
+ if (childNode) {
456
+ // append our new node
457
+ elm.appendChild(childNode);
458
+ }
459
+ }
460
+ }
461
+ }
462
+ // This needs to always happen so we can hide nodes that are projected
463
+ // to another component but don't end up in a slot
464
+ elm['s-hn'] = hostTagName;
465
+ return elm;
466
+ };
467
+ /**
468
+ * Create DOM nodes corresponding to a list of {@link d.Vnode} objects and
469
+ * add them to the DOM in the appropriate place.
470
+ *
471
+ * @param parentElm the DOM node which should be used as a parent for the new
472
+ * DOM nodes
473
+ * @param before a child of the `parentElm` which the new children should be
474
+ * inserted before (optional)
475
+ * @param parentVNode the parent virtual DOM node
476
+ * @param vnodes the new child virtual DOM nodes to produce DOM nodes for
477
+ * @param startIdx the index in the child virtual DOM nodes at which to start
478
+ * creating DOM nodes (inclusive)
479
+ * @param endIdx the index in the child virtual DOM nodes at which to stop
480
+ * creating DOM nodes (inclusive)
481
+ */
482
+ const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
483
+ let containerElm = (parentElm);
484
+ let childNode;
485
+ if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
486
+ containerElm = containerElm.shadowRoot;
487
+ }
488
+ for (; startIdx <= endIdx; ++startIdx) {
489
+ if (vnodes[startIdx]) {
490
+ childNode = createElm(null, parentVNode, startIdx);
491
+ if (childNode) {
492
+ vnodes[startIdx].$elm$ = childNode;
493
+ containerElm.insertBefore(childNode, before);
494
+ }
495
+ }
496
+ }
497
+ };
498
+ /**
499
+ * Remove the DOM elements corresponding to a list of {@link d.VNode} objects.
500
+ * This can be used to, for instance, clean up after a list of children which
501
+ * should no longer be shown.
502
+ *
503
+ * This function also handles some of Stencil's slot relocation logic.
504
+ *
505
+ * @param vnodes a list of virtual DOM nodes to remove
506
+ * @param startIdx the index at which to start removing nodes (inclusive)
507
+ * @param endIdx the index at which to stop removing nodes (inclusive)
508
+ */
509
+ const removeVnodes = (vnodes, startIdx, endIdx) => {
510
+ for (let index = startIdx; index <= endIdx; ++index) {
511
+ const vnode = vnodes[index];
512
+ if (vnode) {
513
+ const elm = vnode.$elm$;
514
+ if (elm) {
515
+ // remove the vnode's element from the dom
516
+ elm.remove();
517
+ }
518
+ }
519
+ }
520
+ };
521
+ /**
522
+ * Reconcile the children of a new VNode with the children of an old VNode by
523
+ * traversing the two collections of children, identifying nodes that are
524
+ * conserved or changed, calling out to `patch` to make any necessary
525
+ * updates to the DOM, and rearranging DOM nodes as needed.
526
+ *
527
+ * The algorithm for reconciling children works by analyzing two 'windows' onto
528
+ * the two arrays of children (`oldCh` and `newCh`). We keep track of the
529
+ * 'windows' by storing start and end indices and references to the
530
+ * corresponding array entries. Initially the two 'windows' are basically equal
531
+ * to the entire array, but we progressively narrow the windows until there are
532
+ * no children left to update by doing the following:
533
+ *
534
+ * 1. Skip any `null` entries at the beginning or end of the two arrays, so
535
+ * that if we have an initial array like the following we'll end up dealing
536
+ * only with a window bounded by the highlighted elements:
537
+ *
538
+ * [null, null, VNode1 , ... , VNode2, null, null]
539
+ * ^^^^^^ ^^^^^^
540
+ *
541
+ * 2. Check to see if the elements at the head and tail positions are equal
542
+ * across the windows. This will basically detect elements which haven't
543
+ * been added, removed, or changed position, i.e. if you had the following
544
+ * VNode elements (represented as HTML):
545
+ *
546
+ * oldVNode: `<div><p><span>HEY</span></p></div>`
547
+ * newVNode: `<div><p><span>THERE</span></p></div>`
548
+ *
549
+ * Then when comparing the children of the `<div>` tag we check the equality
550
+ * of the VNodes corresponding to the `<p>` tags and, since they are the
551
+ * same tag in the same position, we'd be able to avoid completely
552
+ * re-rendering the subtree under them with a new DOM element and would just
553
+ * call out to `patch` to handle reconciling their children and so on.
554
+ *
555
+ * 3. Check, for both windows, to see if the element at the beginning of the
556
+ * window corresponds to the element at the end of the other window. This is
557
+ * a heuristic which will let us identify _some_ situations in which
558
+ * elements have changed position, for instance it _should_ detect that the
559
+ * children nodes themselves have not changed but merely moved in the
560
+ * following example:
561
+ *
562
+ * oldVNode: `<div><element-one /><element-two /></div>`
563
+ * newVNode: `<div><element-two /><element-one /></div>`
564
+ *
565
+ * If we find cases like this then we also need to move the concrete DOM
566
+ * elements corresponding to the moved children to write the re-order to the
567
+ * DOM.
568
+ *
569
+ * 4. Finally, if VNodes have the `key` attribute set on them we check for any
570
+ * nodes in the old children which have the same key as the first element in
571
+ * our window on the new children. If we find such a node we handle calling
572
+ * out to `patch`, moving relevant DOM nodes, and so on, in accordance with
573
+ * what we find.
574
+ *
575
+ * Finally, once we've narrowed our 'windows' to the point that either of them
576
+ * collapse (i.e. they have length 0) we then handle any remaining VNode
577
+ * insertion or deletion that needs to happen to get a DOM state that correctly
578
+ * reflects the new child VNodes. If, for instance, after our window on the old
579
+ * children has collapsed we still have more nodes on the new children that
580
+ * we haven't dealt with yet then we need to add them, or if the new children
581
+ * collapse but we still have unhandled _old_ children then we need to make
582
+ * sure the corresponding DOM nodes are removed.
583
+ *
584
+ * @param parentElm the node into which the parent VNode is rendered
585
+ * @param oldCh the old children of the parent node
586
+ * @param newVNode the new VNode which will replace the parent
587
+ * @param newCh the new children of the parent node
588
+ * @param isInitialRender whether or not this is the first render of the vdom
589
+ */
590
+ const updateChildren = (parentElm, oldCh, newVNode, newCh, isInitialRender = false) => {
591
+ let oldStartIdx = 0;
592
+ let newStartIdx = 0;
593
+ let oldEndIdx = oldCh.length - 1;
594
+ let oldStartVnode = oldCh[0];
595
+ let oldEndVnode = oldCh[oldEndIdx];
596
+ let newEndIdx = newCh.length - 1;
597
+ let newStartVnode = newCh[0];
598
+ let newEndVnode = newCh[newEndIdx];
599
+ let node;
600
+ while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
601
+ if (oldStartVnode == null) {
602
+ // VNode might have been moved left
603
+ oldStartVnode = oldCh[++oldStartIdx];
604
+ }
605
+ else if (oldEndVnode == null) {
606
+ oldEndVnode = oldCh[--oldEndIdx];
607
+ }
608
+ else if (newStartVnode == null) {
609
+ newStartVnode = newCh[++newStartIdx];
610
+ }
611
+ else if (newEndVnode == null) {
612
+ newEndVnode = newCh[--newEndIdx];
613
+ }
614
+ else if (isSameVnode(oldStartVnode, newStartVnode, isInitialRender)) {
615
+ // if the start nodes are the same then we should patch the new VNode
616
+ // onto the old one, and increment our `newStartIdx` and `oldStartIdx`
617
+ // indices to reflect that. We don't need to move any DOM Nodes around
618
+ // since things are matched up in order.
619
+ patch(oldStartVnode, newStartVnode, isInitialRender);
620
+ oldStartVnode = oldCh[++oldStartIdx];
621
+ newStartVnode = newCh[++newStartIdx];
622
+ }
623
+ else if (isSameVnode(oldEndVnode, newEndVnode, isInitialRender)) {
624
+ // likewise, if the end nodes are the same we patch new onto old and
625
+ // decrement our end indices, and also likewise in this case we don't
626
+ // need to move any DOM Nodes.
627
+ patch(oldEndVnode, newEndVnode, isInitialRender);
628
+ oldEndVnode = oldCh[--oldEndIdx];
629
+ newEndVnode = newCh[--newEndIdx];
630
+ }
631
+ else if (isSameVnode(oldStartVnode, newEndVnode, isInitialRender)) {
632
+ patch(oldStartVnode, newEndVnode, isInitialRender);
633
+ // We need to move the element for `oldStartVnode` into a position which
634
+ // will be appropriate for `newEndVnode`. For this we can use
635
+ // `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
636
+ // sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
637
+ // `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
638
+ //
639
+ // <old-start-node />
640
+ // <some-intervening-node />
641
+ // <old-end-node />
642
+ // <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
643
+ // <next-sibling />
644
+ //
645
+ // If instead `oldEndVnode.$elm$` has no sibling then we just want to put
646
+ // the node for `oldStartVnode` at the end of the children of
647
+ // `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
648
+ // aren't any siblings, and passing `null` to `Node.insertBefore` will
649
+ // append it to the children of the parent element.
650
+ parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
651
+ oldStartVnode = oldCh[++oldStartIdx];
652
+ newEndVnode = newCh[--newEndIdx];
653
+ }
654
+ else if (isSameVnode(oldEndVnode, newStartVnode, isInitialRender)) {
655
+ patch(oldEndVnode, newStartVnode, isInitialRender);
656
+ // We've already checked above if `oldStartVnode` and `newStartVnode` are
657
+ // the same node, so since we're here we know that they are not. Thus we
658
+ // can move the element for `oldEndVnode` _before_ the element for
659
+ // `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
660
+ // future.
661
+ parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
662
+ oldEndVnode = oldCh[--oldEndIdx];
663
+ newStartVnode = newCh[++newStartIdx];
664
+ }
665
+ else {
666
+ {
667
+ // We either didn't find an element in the old children that matches
668
+ // the key of the first new child OR the build is not using `key`
669
+ // attributes at all. In either case we need to create a new element
670
+ // for the new node.
671
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
672
+ newStartVnode = newCh[++newStartIdx];
673
+ }
674
+ if (node) {
675
+ // if we created a new node then handle inserting it to the DOM
676
+ {
677
+ oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
678
+ }
679
+ }
680
+ }
681
+ }
682
+ if (oldStartIdx > oldEndIdx) {
683
+ // we have some more new nodes to add which don't match up with old nodes
684
+ addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
685
+ }
686
+ else if (newStartIdx > newEndIdx) {
687
+ // there are nodes in the `oldCh` array which no longer correspond to nodes
688
+ // in the new array, so lets remove them (which entails cleaning up the
689
+ // relevant DOM nodes)
690
+ removeVnodes(oldCh, oldStartIdx, oldEndIdx);
691
+ }
692
+ };
693
+ /**
694
+ * Compare two VNodes to determine if they are the same
695
+ *
696
+ * **NB**: This function is an equality _heuristic_ based on the available
697
+ * information set on the two VNodes and can be misleading under certain
698
+ * circumstances. In particular, if the two nodes do not have `key` attrs
699
+ * (available under `$key$` on VNodes) then the function falls back on merely
700
+ * checking that they have the same tag.
701
+ *
702
+ * So, in other words, if `key` attrs are not set on VNodes which may be
703
+ * changing order within a `children` array or something along those lines then
704
+ * we could obtain a false negative and then have to do needless re-rendering
705
+ * (i.e. we'd say two VNodes aren't equal when in fact they should be).
706
+ *
707
+ * @param leftVNode the first VNode to check
708
+ * @param rightVNode the second VNode to check
709
+ * @param isInitialRender whether or not this is the first render of the vdom
710
+ * @returns whether they're equal or not
711
+ */
712
+ const isSameVnode = (leftVNode, rightVNode, isInitialRender = false) => {
713
+ // compare if two vnode to see if they're "technically" the same
714
+ // need to have the same element tag, and same key to be the same
715
+ if (leftVNode.$tag$ === rightVNode.$tag$) {
716
+ return true;
717
+ }
718
+ return false;
719
+ };
720
+ /**
721
+ * Handle reconciling an outdated VNode with a new one which corresponds to
722
+ * it. This function handles flushing updates to the DOM and reconciling the
723
+ * children of the two nodes (if any).
724
+ *
725
+ * @param oldVNode an old VNode whose DOM element and children we want to update
726
+ * @param newVNode a new VNode representing an updated version of the old one
727
+ * @param isInitialRender whether or not this is the first render of the vdom
728
+ */
729
+ const patch = (oldVNode, newVNode, isInitialRender = false) => {
730
+ const elm = (newVNode.$elm$ = oldVNode.$elm$);
731
+ const oldChildren = oldVNode.$children$;
732
+ const newChildren = newVNode.$children$;
733
+ const tag = newVNode.$tag$;
734
+ const text = newVNode.$text$;
735
+ if (text === null) {
736
+ {
737
+ if (tag === 'slot')
738
+ ;
739
+ else {
740
+ // either this is the first render of an element OR it's an update
741
+ // AND we already know it's possible it could have changed
742
+ // this updates the element's css classes, attrs, props, listeners, etc.
743
+ updateElement(oldVNode, newVNode, isSvgMode);
744
+ }
745
+ }
746
+ if (oldChildren !== null && newChildren !== null) {
747
+ // looks like there's child vnodes for both the old and new vnodes
748
+ // so we need to call `updateChildren` to reconcile them
749
+ updateChildren(elm, oldChildren, newVNode, newChildren, isInitialRender);
750
+ }
751
+ else if (newChildren !== null) {
752
+ // no old child vnodes, but there are new child vnodes to add
753
+ if (oldVNode.$text$ !== null) {
754
+ // the old vnode was text, so be sure to clear it out
755
+ elm.textContent = '';
756
+ }
757
+ // add the new vnode children
758
+ addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
759
+ }
760
+ else if (oldChildren !== null) {
761
+ // no new child vnodes, but there are old child vnodes to remove
762
+ removeVnodes(oldChildren, 0, oldChildren.length - 1);
763
+ }
764
+ }
765
+ else if (oldVNode.$text$ !== text) {
766
+ // update the text content for the text only vnode
767
+ // and also only if the text is different than before
768
+ elm.data = text;
769
+ }
770
+ };
771
+ /**
772
+ * The main entry point for Stencil's virtual DOM-based rendering engine
773
+ *
774
+ * Given a {@link d.HostRef} container and some virtual DOM nodes, this
775
+ * function will handle creating a virtual DOM tree with a single root, patching
776
+ * the current virtual DOM tree onto an old one (if any), dealing with slot
777
+ * relocation, and reflecting attributes.
778
+ *
779
+ * @param hostRef data needed to root and render the virtual DOM tree, such as
780
+ * the DOM node into which it should be rendered.
781
+ * @param renderFnResults the virtual DOM nodes to be rendered
782
+ * @param isInitialLoad whether or not this is the first call after page load
783
+ */
784
+ const renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
785
+ const hostElm = hostRef.$hostElement$;
786
+ const cmpMeta = hostRef.$cmpMeta$;
787
+ const oldVNode = hostRef.$vnode$ || newVNode(null, null);
788
+ // if `renderFnResults` is a Host node then we can use it directly. If not,
789
+ // we need to call `h` again to wrap the children of our component in a
790
+ // 'dummy' Host node (well, an empty vnode) since `renderVdom` assumes
791
+ // implicitly that the top-level vdom node is 1) an only child and 2)
792
+ // contains attrs that need to be set on the host element.
793
+ const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
794
+ hostTagName = hostElm.tagName;
795
+ if (cmpMeta.$attrsToReflect$) {
796
+ rootVnode.$attrs$ = rootVnode.$attrs$ || {};
797
+ cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
798
+ }
799
+ // On the first render and *only* on the first render we want to check for
800
+ // any attributes set on the host element which are also set on the vdom
801
+ // node. If we find them, we override the value on the VDom node attrs with
802
+ // the value from the host element, which allows developers building apps
803
+ // with Stencil components to override e.g. the `role` attribute on a
804
+ // component even if it's already set on the `Host`.
805
+ if (isInitialLoad && rootVnode.$attrs$) {
806
+ for (const key of Object.keys(rootVnode.$attrs$)) {
807
+ // We have a special implementation in `setAccessor` for `style` and
808
+ // `class` which reconciles values coming from the VDom with values
809
+ // already present on the DOM element, so we don't want to override those
810
+ // attributes on the VDom tree with values from the host element if they
811
+ // are present.
812
+ //
813
+ // Likewise, `ref` and `key` are special internal values for the Stencil
814
+ // runtime and we don't want to override those either.
815
+ if (hostElm.hasAttribute(key) && !['key', 'ref', 'style', 'class'].includes(key)) {
816
+ rootVnode.$attrs$[key] = hostElm[key];
817
+ }
818
+ }
819
+ }
820
+ rootVnode.$tag$ = null;
821
+ rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
822
+ hostRef.$vnode$ = rootVnode;
823
+ rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
824
+ {
825
+ scopeId = hostElm['s-sc'];
826
+ }
827
+ // synchronous patch
828
+ patch(oldVNode, rootVnode, isInitialLoad);
829
+ };
830
+ const attachToAncestor = (hostRef, ancestorComponent) => {
831
+ if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
832
+ ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
833
+ }
834
+ };
835
+ const scheduleUpdate = (hostRef, isInitialLoad) => {
836
+ {
837
+ hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
838
+ }
839
+ if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
840
+ hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
841
+ return;
842
+ }
843
+ attachToAncestor(hostRef, hostRef.$ancestorComponent$);
844
+ // there is no ancestor component or the ancestor component
845
+ // has already fired off its lifecycle update then
846
+ // fire off the initial update
847
+ const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
848
+ return writeTask(dispatch) ;
849
+ };
850
+ /**
851
+ * Dispatch initial-render and update lifecycle hooks, enqueuing calls to
852
+ * component lifecycle methods like `componentWillLoad` as well as
853
+ * {@link updateComponent}, which will kick off the virtual DOM re-render.
854
+ *
855
+ * @param hostRef a reference to a host DOM node
856
+ * @param isInitialLoad whether we're on the initial load or not
857
+ * @returns an empty Promise which is used to enqueue a series of operations for
858
+ * the component
859
+ */
860
+ const dispatchHooks = (hostRef, isInitialLoad) => {
861
+ const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
862
+ const instance = hostRef.$lazyInstance$ ;
863
+ // We're going to use this variable together with `enqueue` to implement a
864
+ // little promise-based queue. We start out with it `undefined`. When we add
865
+ // the first function to the queue we'll set this variable to be that
866
+ // function's return value. When we attempt to add subsequent values to the
867
+ // queue we'll check that value and, if it was a `Promise`, we'll then chain
868
+ // the new function off of that `Promise` using `.then()`. This will give our
869
+ // queue two nice properties:
870
+ //
871
+ // 1. If all functions added to the queue are synchronous they'll be called
872
+ // synchronously right away.
873
+ // 2. If all functions added to the queue are asynchronous they'll all be
874
+ // called in order after `dispatchHooks` exits.
875
+ let maybePromise;
876
+ {
877
+ maybePromise = enqueue(maybePromise, () => safeCall(instance, 'componentWillRender'));
878
+ }
879
+ endSchedule();
880
+ return enqueue(maybePromise, () => updateComponent(hostRef, instance, isInitialLoad));
881
+ };
882
+ /**
883
+ * This function uses a Promise to implement a simple first-in, first-out queue
884
+ * of functions to be called.
885
+ *
886
+ * The queue is ordered on the basis of the first argument. If it's
887
+ * `undefined`, then nothing is on the queue yet, so the provided function can
888
+ * be called synchronously (although note that this function may return a
889
+ * `Promise`). The idea is that then the return value of that enqueueing
890
+ * operation is kept around, so that if it was a `Promise` then subsequent
891
+ * functions can be enqueued by calling this function again with that `Promise`
892
+ * as the first argument.
893
+ *
894
+ * @param maybePromise either a `Promise` which should resolve before the next function is called or an 'empty' sentinel
895
+ * @param fn a function to enqueue
896
+ * @returns either a `Promise` or the return value of the provided function
897
+ */
898
+ const enqueue = (maybePromise, fn) => isPromisey(maybePromise) ? maybePromise.then(fn) : fn();
899
+ /**
900
+ * Check that a value is a `Promise`. To check, we first see if the value is an
901
+ * instance of the `Promise` global. In a few circumstances, in particular if
902
+ * the global has been overwritten, this is could be misleading, so we also do
903
+ * a little 'duck typing' check to see if the `.then` property of the value is
904
+ * defined and a function.
905
+ *
906
+ * @param maybePromise it might be a promise!
907
+ * @returns whether it is or not
908
+ */
909
+ const isPromisey = (maybePromise) => maybePromise instanceof Promise ||
910
+ (maybePromise && maybePromise.then && typeof maybePromise.then === 'function');
911
+ /**
912
+ * Update a component given reference to its host elements and so on.
913
+ *
914
+ * @param hostRef an object containing references to the element's host node,
915
+ * VDom nodes, and other metadata
916
+ * @param instance a reference to the underlying host element where it will be
917
+ * rendered
918
+ * @param isInitialLoad whether or not this function is being called as part of
919
+ * the first render cycle
920
+ */
921
+ const updateComponent = async (hostRef, instance, isInitialLoad) => {
922
+ var _a;
923
+ const elm = hostRef.$hostElement$;
924
+ const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
925
+ const rc = elm['s-rc'];
926
+ if (isInitialLoad) {
927
+ // DOM WRITE!
928
+ attachStyles(hostRef);
929
+ }
930
+ const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
931
+ {
932
+ callRender(hostRef, instance, elm, isInitialLoad);
933
+ }
934
+ if (rc) {
935
+ // ok, so turns out there are some child host elements
936
+ // waiting on this parent element to load
937
+ // let's fire off all update callbacks waiting
938
+ rc.map((cb) => cb());
939
+ elm['s-rc'] = undefined;
940
+ }
941
+ endRender();
942
+ endUpdate();
943
+ {
944
+ const childrenPromises = (_a = elm['s-p']) !== null && _a !== void 0 ? _a : [];
945
+ const postUpdate = () => postUpdateComponent(hostRef);
946
+ if (childrenPromises.length === 0) {
947
+ postUpdate();
948
+ }
949
+ else {
950
+ Promise.all(childrenPromises).then(postUpdate);
951
+ hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
952
+ childrenPromises.length = 0;
953
+ }
954
+ }
955
+ };
956
+ /**
957
+ * Handle making the call to the VDom renderer with the proper context given
958
+ * various build variables
959
+ *
960
+ * @param hostRef an object containing references to the element's host node,
961
+ * VDom nodes, and other metadata
962
+ * @param instance a reference to the underlying host element where it will be
963
+ * rendered
964
+ * @param elm the Host element for the component
965
+ * @param isInitialLoad whether or not this function is being called as part of
966
+ * @returns an empty promise
967
+ */
968
+ const callRender = (hostRef, instance, elm, isInitialLoad) => {
969
+ try {
970
+ /**
971
+ * minification optimization: `allRenderFn` is `true` if all components have a `render`
972
+ * method, so we can call the method immediately. If not, check before calling it.
973
+ */
974
+ instance = instance.render() ;
975
+ {
976
+ hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
977
+ }
978
+ {
979
+ hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
980
+ }
981
+ {
982
+ {
983
+ // looks like we've got child nodes to render into this host element
984
+ // or we need to update the css class/attrs on the host element
985
+ // DOM WRITE!
986
+ {
987
+ renderVdom(hostRef, instance, isInitialLoad);
988
+ }
989
+ }
990
+ }
991
+ }
992
+ catch (e) {
993
+ consoleError(e, hostRef.$hostElement$);
994
+ }
995
+ return null;
996
+ };
997
+ const postUpdateComponent = (hostRef) => {
998
+ const tagName = hostRef.$cmpMeta$.$tagName$;
999
+ const elm = hostRef.$hostElement$;
1000
+ const endPostUpdate = createTime('postUpdate', tagName);
1001
+ const ancestorComponent = hostRef.$ancestorComponent$;
1002
+ if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
1003
+ hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
1004
+ {
1005
+ // DOM WRITE!
1006
+ addHydratedFlag(elm);
1007
+ }
1008
+ endPostUpdate();
1009
+ {
1010
+ hostRef.$onReadyResolve$(elm);
1011
+ if (!ancestorComponent) {
1012
+ appDidLoad();
1013
+ }
1014
+ }
1015
+ }
1016
+ else {
1017
+ endPostUpdate();
1018
+ }
1019
+ // load events fire from bottom to top
1020
+ // the deepest elements load first then bubbles up
1021
+ {
1022
+ if (hostRef.$onRenderResolve$) {
1023
+ hostRef.$onRenderResolve$();
1024
+ hostRef.$onRenderResolve$ = undefined;
1025
+ }
1026
+ if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
1027
+ nextTick(() => scheduleUpdate(hostRef, false));
1028
+ }
1029
+ hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
1030
+ }
1031
+ // ( •_•)
1032
+ // ( •_•)>⌐■-■
1033
+ // (⌐■_■)
1034
+ };
1035
+ const appDidLoad = (who) => {
1036
+ // on appload
1037
+ // we have finish the first big initial render
1038
+ {
1039
+ addHydratedFlag(doc.documentElement);
1040
+ }
1041
+ nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
1042
+ };
1043
+ /**
1044
+ * Allows to safely call a method, e.g. `componentDidLoad`, on an instance,
1045
+ * e.g. custom element node. If a build figures out that e.g. no component
1046
+ * has a `componentDidLoad` method, the instance method gets removed from the
1047
+ * output bundle and this function returns `undefined`.
1048
+ * @param instance any object that may or may not contain methods
1049
+ * @param method method name
1050
+ * @param arg single arbitrary argument
1051
+ * @returns result of method call if it exists, otherwise `undefined`
1052
+ */
1053
+ const safeCall = (instance, method, arg) => {
1054
+ if (instance && instance[method]) {
1055
+ try {
1056
+ return instance[method](arg);
1057
+ }
1058
+ catch (e) {
1059
+ consoleError(e);
1060
+ }
1061
+ }
1062
+ return undefined;
1063
+ };
1064
+ const addHydratedFlag = (elm) => elm.setAttribute('hydrated', '')
1065
+ ;
1066
+ const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
1067
+ const setValue = (ref, propName, newVal, cmpMeta) => {
1068
+ // check our new property value against our internal value
1069
+ const hostRef = getHostRef(ref);
1070
+ const oldVal = hostRef.$instanceValues$.get(propName);
1071
+ const flags = hostRef.$flags$;
1072
+ const instance = hostRef.$lazyInstance$ ;
1073
+ newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
1074
+ // explicitly check for NaN on both sides, as `NaN === NaN` is always false
1075
+ const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
1076
+ const didValueChange = newVal !== oldVal && !areBothNaN;
1077
+ if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
1078
+ // gadzooks! the property's value has changed!!
1079
+ // set our new value!
1080
+ hostRef.$instanceValues$.set(propName, newVal);
1081
+ if (instance) {
1082
+ if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
1083
+ // looks like this value actually changed, so we've got work to do!
1084
+ // but only if we've already rendered, otherwise just chill out
1085
+ // queue that we need to do an update, but don't worry about queuing
1086
+ // up millions cuz this function ensures it only runs once
1087
+ scheduleUpdate(hostRef, false);
1088
+ }
1089
+ }
1090
+ }
1091
+ };
1092
+ /**
1093
+ * Attach a series of runtime constructs to a compiled Stencil component
1094
+ * constructor, including getters and setters for the `@Prop` and `@State`
1095
+ * decorators, callbacks for when attributes change, and so on.
1096
+ *
1097
+ * @param Cstr the constructor for a component that we need to process
1098
+ * @param cmpMeta metadata collected previously about the component
1099
+ * @param flags a number used to store a series of bit flags
1100
+ * @returns a reference to the same constructor passed in (but now mutated)
1101
+ */
1102
+ const proxyComponent = (Cstr, cmpMeta, flags) => {
1103
+ var _a;
1104
+ const prototype = Cstr.prototype;
1105
+ if (cmpMeta.$members$) {
1106
+ // It's better to have a const than two Object.entries()
1107
+ const members = Object.entries(cmpMeta.$members$);
1108
+ members.map(([memberName, [memberFlags]]) => {
1109
+ if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
1110
+ ((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
1111
+ // proxyComponent - prop
1112
+ Object.defineProperty(prototype, memberName, {
1113
+ get() {
1114
+ // proxyComponent, get value
1115
+ return getValue(this, memberName);
1116
+ },
1117
+ set(newValue) {
1118
+ // proxyComponent, set value
1119
+ setValue(this, memberName, newValue, cmpMeta);
1120
+ },
1121
+ configurable: true,
1122
+ enumerable: true,
1123
+ });
1124
+ }
1125
+ });
1126
+ if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
1127
+ const attrNameToPropName = new Map();
1128
+ prototype.attributeChangedCallback = function (attrName, oldValue, newValue) {
1129
+ plt.jmp(() => {
1130
+ var _a;
1131
+ const propName = attrNameToPropName.get(attrName);
1132
+ // In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
1133
+ // in the case where an attribute was set inline.
1134
+ // ```html
1135
+ // <my-component some-attribute="some-value"></my-component>
1136
+ // ```
1137
+ //
1138
+ // There is an edge case where a developer sets the attribute inline on a custom element and then
1139
+ // programmatically changes it before it has been upgraded as shown below:
1140
+ //
1141
+ // ```html
1142
+ // <!-- this component has _not_ been upgraded yet -->
1143
+ // <my-component id="test" some-attribute="some-value"></my-component>
1144
+ // <script>
1145
+ // // grab non-upgraded component
1146
+ // el = document.querySelector("#test");
1147
+ // el.someAttribute = "another-value";
1148
+ // // upgrade component
1149
+ // customElements.define('my-component', MyComponent);
1150
+ // </script>
1151
+ // ```
1152
+ // In this case if we do not un-shadow here and use the value of the shadowing property, attributeChangedCallback
1153
+ // will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
1154
+ // to the value that was set inline i.e. "some-value" from above example. When
1155
+ // the connectedCallback attempts to un-shadow it will use "some-value" as the initial value rather than "another-value"
1156
+ //
1157
+ // The case where the attribute was NOT set inline but was not set programmatically shall be handled/un-shadowed
1158
+ // by connectedCallback as this attributeChangedCallback will not fire.
1159
+ //
1160
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1161
+ //
1162
+ // TODO(STENCIL-16) we should think about whether or not we actually want to be reflecting the attributes to
1163
+ // properties here given that this goes against best practices outlined here
1164
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy
1165
+ if (this.hasOwnProperty(propName)) {
1166
+ newValue = this[propName];
1167
+ delete this[propName];
1168
+ }
1169
+ else if (prototype.hasOwnProperty(propName) &&
1170
+ typeof this[propName] === 'number' &&
1171
+ this[propName] == newValue) {
1172
+ // if the propName exists on the prototype of `Cstr`, this update may be a result of Stencil using native
1173
+ // APIs to reflect props as attributes. Calls to `setAttribute(someElement, propName)` will result in
1174
+ // `propName` to be converted to a `DOMString`, which may not be what we want for other primitive props.
1175
+ return;
1176
+ }
1177
+ else if (propName == null) {
1178
+ // At this point we should know this is not a "member", so we can treat it like watching an attribute
1179
+ // on a vanilla web component
1180
+ const hostRef = getHostRef(this);
1181
+ const flags = hostRef === null || hostRef === void 0 ? void 0 : hostRef.$flags$;
1182
+ // We only want to trigger the callback(s) if:
1183
+ // 1. The instance is ready
1184
+ // 2. The watchers are ready
1185
+ // 3. The value has changed
1186
+ if (flags &&
1187
+ !(flags & 8 /* HOST_FLAGS.isConstructingInstance */) &&
1188
+ flags & 128 /* HOST_FLAGS.isWatchReady */ &&
1189
+ newValue !== oldValue) {
1190
+ const instance = hostRef.$lazyInstance$ ;
1191
+ const entry = (_a = cmpMeta.$watchers$) === null || _a === void 0 ? void 0 : _a[attrName];
1192
+ entry === null || entry === void 0 ? void 0 : entry.forEach((callbackName) => {
1193
+ if (instance[callbackName] != null) {
1194
+ instance[callbackName].call(instance, newValue, oldValue, attrName);
1195
+ }
1196
+ });
1197
+ }
1198
+ return;
1199
+ }
1200
+ this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
1201
+ });
1202
+ };
1203
+ // Create an array of attributes to observe
1204
+ // This list in comprised of all strings used within a `@Watch()` decorator
1205
+ // on a component as well as any Stencil-specific "members" (`@Prop()`s and `@State()`s).
1206
+ // As such, there is no way to guarantee type-safety here that a user hasn't entered
1207
+ // an invalid attribute.
1208
+ Cstr.observedAttributes = Array.from(new Set([
1209
+ ...Object.keys((_a = cmpMeta.$watchers$) !== null && _a !== void 0 ? _a : {}),
1210
+ ...members
1211
+ .filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */)
1212
+ .map(([propName, m]) => {
1213
+ var _a;
1214
+ const attrName = m[1] || propName;
1215
+ attrNameToPropName.set(attrName, propName);
1216
+ if (m[0] & 512 /* MEMBER_FLAGS.ReflectAttr */) {
1217
+ (_a = cmpMeta.$attrsToReflect$) === null || _a === void 0 ? void 0 : _a.push([propName, attrName]);
1218
+ }
1219
+ return attrName;
1220
+ }),
1221
+ ]));
1222
+ }
1223
+ }
1224
+ return Cstr;
1225
+ };
1226
+ /**
1227
+ * Initialize a Stencil component given a reference to its host element, its
1228
+ * runtime bookkeeping data structure, runtime metadata about the component,
1229
+ * and (optionally) an HMR version ID.
1230
+ *
1231
+ * @param elm a host element
1232
+ * @param hostRef the element's runtime bookkeeping object
1233
+ * @param cmpMeta runtime metadata for the Stencil component
1234
+ * @param hmrVersionId an (optional) HMR version ID
1235
+ */
1236
+ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
1237
+ let Cstr;
1238
+ // initializeComponent
1239
+ if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
1240
+ // Let the runtime know that the component has been initialized
1241
+ hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
1242
+ {
1243
+ // lazy loaded components
1244
+ // request the component's implementation to be
1245
+ // wired up with the host element
1246
+ Cstr = loadModule(cmpMeta);
1247
+ if (Cstr.then) {
1248
+ // Await creates a micro-task avoid if possible
1249
+ const endLoad = uniqueTime();
1250
+ Cstr = await Cstr;
1251
+ endLoad();
1252
+ }
1253
+ if (!Cstr.isProxied) {
1254
+ proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
1255
+ Cstr.isProxied = true;
1256
+ }
1257
+ const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
1258
+ // ok, time to construct the instance
1259
+ // but let's keep track of when we start and stop
1260
+ // so that the getters/setters don't incorrectly step on data
1261
+ {
1262
+ hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
1263
+ }
1264
+ // construct the lazy-loaded component implementation
1265
+ // passing the hostRef is very important during
1266
+ // construction in order to directly wire together the
1267
+ // host element and the lazy-loaded instance
1268
+ try {
1269
+ new Cstr(hostRef);
1270
+ }
1271
+ catch (e) {
1272
+ consoleError(e);
1273
+ }
1274
+ {
1275
+ hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
1276
+ }
1277
+ endNewInstance();
1278
+ }
1279
+ if (Cstr.style) {
1280
+ // this component has styles but we haven't registered them yet
1281
+ let style = Cstr.style;
1282
+ const scopeId = getScopeId(cmpMeta);
1283
+ if (!styles.has(scopeId)) {
1284
+ const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
1285
+ registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
1286
+ endRegisterStyles();
1287
+ }
1288
+ }
1289
+ }
1290
+ // we've successfully created a lazy instance
1291
+ const ancestorComponent = hostRef.$ancestorComponent$;
1292
+ const schedule = () => scheduleUpdate(hostRef, true);
1293
+ if (ancestorComponent && ancestorComponent['s-rc']) {
1294
+ // this is the initial load and this component it has an ancestor component
1295
+ // but the ancestor component has NOT fired its will update lifecycle yet
1296
+ // so let's just cool our jets and wait for the ancestor to continue first
1297
+ // this will get fired off when the ancestor component
1298
+ // finally gets around to rendering its lazy self
1299
+ // fire off the initial update
1300
+ ancestorComponent['s-rc'].push(schedule);
1301
+ }
1302
+ else {
1303
+ schedule();
1304
+ }
1305
+ };
1306
+ const fireConnectedCallback = (instance) => {
1307
+ };
1308
+ const connectedCallback = (elm) => {
1309
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
1310
+ const hostRef = getHostRef(elm);
1311
+ const cmpMeta = hostRef.$cmpMeta$;
1312
+ const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
1313
+ if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
1314
+ // first time this component has connected
1315
+ hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
1316
+ {
1317
+ // find the first ancestor component (if there is one) and register
1318
+ // this component as one of the actively loading child components for its ancestor
1319
+ let ancestorComponent = elm;
1320
+ while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
1321
+ // climb up the ancestors looking for the first
1322
+ // component that hasn't finished its lifecycle update yet
1323
+ if (ancestorComponent['s-p']) {
1324
+ // we found this components first ancestor component
1325
+ // keep a reference to this component's ancestor component
1326
+ attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
1327
+ break;
1328
+ }
1329
+ }
1330
+ }
1331
+ // Lazy properties
1332
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1333
+ if (cmpMeta.$members$) {
1334
+ Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
1335
+ if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
1336
+ const value = elm[memberName];
1337
+ delete elm[memberName];
1338
+ elm[memberName] = value;
1339
+ }
1340
+ });
1341
+ }
1342
+ {
1343
+ initializeComponent(elm, hostRef, cmpMeta);
1344
+ }
1345
+ }
1346
+ else {
1347
+ // fire off connectedCallback() on component instance
1348
+ if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$lazyInstance$) ;
1349
+ else if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$onReadyPromise$) {
1350
+ hostRef.$onReadyPromise$.then(() => fireConnectedCallback());
1351
+ }
1352
+ }
1353
+ endConnected();
1354
+ }
1355
+ };
1356
+ const disconnectInstance = (instance) => {
1357
+ };
1358
+ const disconnectedCallback = async (elm) => {
1359
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
1360
+ const hostRef = getHostRef(elm);
1361
+ if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$lazyInstance$) ;
1362
+ else if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$onReadyPromise$) {
1363
+ hostRef.$onReadyPromise$.then(() => disconnectInstance());
1364
+ }
1365
+ }
1366
+ };
1367
+ const bootstrapLazy = (lazyBundles, options = {}) => {
1368
+ var _a;
1369
+ const endBootstrap = createTime();
1370
+ const cmpTags = [];
1371
+ const exclude = options.exclude || [];
1372
+ const customElements = win.customElements;
1373
+ const head = doc.head;
1374
+ const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
1375
+ const dataStyles = /*@__PURE__*/ doc.createElement('style');
1376
+ const deferredConnectedCallbacks = [];
1377
+ let appLoadFallback;
1378
+ let isBootstrapping = true;
1379
+ Object.assign(plt, options);
1380
+ plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
1381
+ let hasSlotRelocation = false;
1382
+ lazyBundles.map((lazyBundle) => {
1383
+ lazyBundle[1].map((compactMeta) => {
1384
+ const cmpMeta = {
1385
+ $flags$: compactMeta[0],
1386
+ $tagName$: compactMeta[1],
1387
+ $members$: compactMeta[2],
1388
+ $listeners$: compactMeta[3],
1389
+ };
1390
+ // Check if we are using slots outside the shadow DOM in this component.
1391
+ // We'll use this information later to add styles for `slot-fb` elements
1392
+ if (cmpMeta.$flags$ & 4 /* CMP_FLAGS.hasSlotRelocation */) {
1393
+ hasSlotRelocation = true;
1394
+ }
1395
+ {
1396
+ cmpMeta.$members$ = compactMeta[2];
1397
+ }
1398
+ {
1399
+ cmpMeta.$attrsToReflect$ = [];
1400
+ }
1401
+ const tagName = cmpMeta.$tagName$;
1402
+ const HostElement = class extends HTMLElement {
1403
+ // StencilLazyHost
1404
+ constructor(self) {
1405
+ // @ts-ignore
1406
+ super(self);
1407
+ self = this;
1408
+ registerHost(self, cmpMeta);
1409
+ if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
1410
+ // this component is using shadow dom
1411
+ // and this browser supports shadow dom
1412
+ // add the read-only property "shadowRoot" to the host element
1413
+ // adding the shadow root build conditionals to minimize runtime
1414
+ {
1415
+ {
1416
+ self.attachShadow({ mode: 'open' });
1417
+ }
1418
+ }
1419
+ }
1420
+ }
1421
+ connectedCallback() {
1422
+ if (appLoadFallback) {
1423
+ clearTimeout(appLoadFallback);
1424
+ appLoadFallback = null;
1425
+ }
1426
+ if (isBootstrapping) {
1427
+ // connectedCallback will be processed once all components have been registered
1428
+ deferredConnectedCallbacks.push(this);
1429
+ }
1430
+ else {
1431
+ plt.jmp(() => connectedCallback(this));
1432
+ }
1433
+ }
1434
+ disconnectedCallback() {
1435
+ plt.jmp(() => disconnectedCallback(this));
1436
+ }
1437
+ componentOnReady() {
1438
+ return getHostRef(this).$onReadyPromise$;
1439
+ }
1440
+ };
1441
+ cmpMeta.$lazyBundleId$ = lazyBundle[0];
1442
+ if (!exclude.includes(tagName) && !customElements.get(tagName)) {
1443
+ cmpTags.push(tagName);
1444
+ customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
1445
+ }
1446
+ });
1447
+ });
1448
+ // Add styles for `slot-fb` elements if any of our components are using slots outside the Shadow DOM
1449
+ if (hasSlotRelocation) {
1450
+ dataStyles.innerHTML += SLOT_FB_CSS;
1451
+ }
1452
+ // Add hydration styles
1453
+ {
1454
+ dataStyles.innerHTML += cmpTags + HYDRATED_CSS;
1455
+ }
1456
+ // If we have styles, add them to the DOM
1457
+ if (dataStyles.innerHTML.length) {
1458
+ dataStyles.setAttribute('data-styles', '');
1459
+ // Apply CSP nonce to the style tag if it exists
1460
+ const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
1461
+ if (nonce != null) {
1462
+ dataStyles.setAttribute('nonce', nonce);
1463
+ }
1464
+ // Insert the styles into the document head
1465
+ // NOTE: this _needs_ to happen last so we can ensure the nonce (and other attributes) are applied
1466
+ head.insertBefore(dataStyles, metaCharset ? metaCharset.nextSibling : head.firstChild);
1467
+ }
1468
+ // Process deferred connectedCallbacks now all components have been registered
1469
+ isBootstrapping = false;
1470
+ if (deferredConnectedCallbacks.length) {
1471
+ deferredConnectedCallbacks.map((host) => host.connectedCallback());
1472
+ }
1473
+ else {
1474
+ {
1475
+ plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
1476
+ }
1477
+ }
1478
+ // Fallback appLoad event
1479
+ endBootstrap();
1480
+ };
1481
+ /**
1482
+ * Assigns the given value to the nonce property on the runtime platform object.
1483
+ * During runtime, this value is used to set the nonce attribute on all dynamically created script and style tags.
1484
+ * @param nonce The value to be assigned to the platform nonce property.
1485
+ * @returns void
1486
+ */
1487
+ const setNonce = (nonce) => (plt.$nonce$ = nonce);
1488
+ /**
1489
+ * A WeakMap mapping runtime component references to their corresponding host reference
1490
+ * instances.
1491
+ */
1492
+ const hostRefs = /*@__PURE__*/ new WeakMap();
1493
+ /**
1494
+ * Given a {@link d.RuntimeRef} retrieve the corresponding {@link d.HostRef}
1495
+ *
1496
+ * @param ref the runtime ref of interest
1497
+ * @returns the Host reference (if found) or undefined
1498
+ */
1499
+ const getHostRef = (ref) => hostRefs.get(ref);
1500
+ /**
1501
+ * Register a lazy instance with the {@link hostRefs} object so it's
1502
+ * corresponding {@link d.HostRef} can be retrieved later.
1503
+ *
1504
+ * @param lazyInstance the lazy instance of interest
1505
+ * @param hostRef that instances `HostRef` object
1506
+ * @returns a reference to the host ref WeakMap
1507
+ */
1508
+ const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
1509
+ /**
1510
+ * Register a host element for a Stencil component, setting up various metadata
1511
+ * and callbacks based on {@link BUILD} flags as well as the component's runtime
1512
+ * metadata.
1513
+ *
1514
+ * @param hostElement the host element to register
1515
+ * @param cmpMeta runtime metadata for that component
1516
+ * @returns a reference to the host ref WeakMap
1517
+ */
1518
+ const registerHost = (hostElement, cmpMeta) => {
1519
+ const hostRef = {
1520
+ $flags$: 0,
1521
+ $hostElement$: hostElement,
1522
+ $cmpMeta$: cmpMeta,
1523
+ $instanceValues$: new Map(),
1524
+ };
1525
+ {
1526
+ hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
1527
+ hostElement['s-p'] = [];
1528
+ hostElement['s-rc'] = [];
1529
+ }
1530
+ return hostRefs.set(hostElement, hostRef);
1531
+ };
1532
+ const isMemberInElement = (elm, memberName) => memberName in elm;
1533
+ const consoleError = (e, el) => (0, console.error)(e, el);
1534
+ const cmpModules = /*@__PURE__*/ new Map();
1535
+ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1536
+ // loadModuleImport
1537
+ const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
1538
+ const bundleId = cmpMeta.$lazyBundleId$;
1539
+ const module = cmpModules.get(bundleId) ;
1540
+ if (module) {
1541
+ return module[exportName];
1542
+ }
1543
+
1544
+ if (!hmrVersionId || !BUILD.hotModuleReplacement) {
1545
+ const processMod = importedModule => {
1546
+ cmpModules.set(bundleId, importedModule);
1547
+ return importedModule[exportName];
1548
+ }
1549
+ switch(bundleId) {
1550
+
1551
+ case 'mds-input-tip-item.cjs':
1552
+ return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
1553
+ /* webpackMode: "lazy" */
1554
+ './mds-input-tip-item.cjs.entry.js')); }).then(processMod, consoleError);
1555
+ }
1556
+ }
1557
+ return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
1558
+ /* @vite-ignore */
1559
+ /* webpackInclude: /\.entry\.js$/ */
1560
+ /* webpackExclude: /\.system\.entry\.js$/ */
1561
+ /* webpackMode: "lazy" */
1562
+ `./${bundleId}.entry.js${''}`)); }).then((importedModule) => {
1563
+ {
1564
+ cmpModules.set(bundleId, importedModule);
1565
+ }
1566
+ return importedModule[exportName];
1567
+ }, consoleError);
1568
+ };
1569
+ const styles = /*@__PURE__*/ new Map();
1570
+ const win = typeof window !== 'undefined' ? window : {};
1571
+ const doc = win.document || { head: {} };
1572
+ const plt = {
1573
+ $flags$: 0,
1574
+ $resourcesUrl$: '',
1575
+ jmp: (h) => h(),
1576
+ raf: (h) => requestAnimationFrame(h),
1577
+ ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
1578
+ rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
1579
+ ce: (eventName, opts) => new CustomEvent(eventName, opts),
1580
+ };
1581
+ const promiseResolve = (v) => Promise.resolve(v);
1582
+ const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
1583
+ try {
1584
+ new CSSStyleSheet();
1585
+ return typeof new CSSStyleSheet().replaceSync === 'function';
1586
+ }
1587
+ catch (e) { }
1588
+ return false;
1589
+ })()
1590
+ ;
1591
+ const queueDomReads = [];
1592
+ const queueDomWrites = [];
1593
+ const queueTask = (queue, write) => (cb) => {
1594
+ queue.push(cb);
1595
+ if (!queuePending) {
1596
+ queuePending = true;
1597
+ if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
1598
+ nextTick(flush);
1599
+ }
1600
+ else {
1601
+ plt.raf(flush);
1602
+ }
1603
+ }
1604
+ };
1605
+ const consume = (queue) => {
1606
+ for (let i = 0; i < queue.length; i++) {
1607
+ try {
1608
+ queue[i](performance.now());
1609
+ }
1610
+ catch (e) {
1611
+ consoleError(e);
1612
+ }
1613
+ }
1614
+ queue.length = 0;
1615
+ };
1616
+ const flush = () => {
1617
+ // always force a bunch of medium callbacks to run, but still have
1618
+ // a throttle on how many can run in a certain time
1619
+ // DOM READS!!!
1620
+ consume(queueDomReads);
1621
+ // DOM WRITES!!!
1622
+ {
1623
+ consume(queueDomWrites);
1624
+ if ((queuePending = queueDomReads.length > 0)) {
1625
+ // still more to do yet, but we've run out of time
1626
+ // let's let this thing cool off and try again in the next tick
1627
+ plt.raf(flush);
1628
+ }
1629
+ }
1630
+ };
1631
+ const nextTick = (cb) => promiseResolve().then(cb);
1632
+ const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
1633
+
1634
+ exports.Host = Host;
1635
+ exports.bootstrapLazy = bootstrapLazy;
1636
+ exports.getElement = getElement;
1637
+ exports.h = h;
1638
+ exports.promiseResolve = promiseResolve;
1639
+ exports.registerInstance = registerInstance;
1640
+ exports.setNonce = setNonce;