@basic-ui-components-stc/basic-ui-components 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 (278) hide show
  1. package/LICENSE +21 -0
  2. package/dist/assets/fonts/symbol-defs.svg +939 -0
  3. package/dist/assets/images/404.svg +104 -0
  4. package/dist/assets/images/no-cards.svg +5 -0
  5. package/dist/assets/images/no-connection.svg +56 -0
  6. package/dist/assets/images/no-data.svg +38 -0
  7. package/dist/assets/images/no-lists.svg +10 -0
  8. package/dist/assets/images/not-authorized.svg +6 -0
  9. package/dist/assets/images/user.svg +4 -0
  10. package/dist/assets/js/svgxuse.min.js +12 -0
  11. package/dist/assets/scss/_bootstrap.scss +16 -0
  12. package/dist/assets/scss/_colors.scss +5 -0
  13. package/dist/assets/scss/_fonts.scss +278 -0
  14. package/dist/assets/scss/_general.scss +401 -0
  15. package/dist/assets/scss/_reset.scss +67 -0
  16. package/dist/assets/scss/_variables.scss +18 -0
  17. package/dist/assets/scss/angular-material/_accordion.scss +131 -0
  18. package/dist/assets/scss/angular-material/_checkbox.scss +59 -0
  19. package/dist/assets/scss/angular-material/_chip-list.scss +33 -0
  20. package/dist/assets/scss/angular-material/_chips.scss +46 -0
  21. package/dist/assets/scss/angular-material/_datepicker.scss +192 -0
  22. package/dist/assets/scss/angular-material/_form-field.scss +383 -0
  23. package/dist/assets/scss/angular-material/_popover.scss +384 -0
  24. package/dist/assets/scss/angular-material/_popups.scss +127 -0
  25. package/dist/assets/scss/angular-material/_radiobox.scss +67 -0
  26. package/dist/assets/scss/angular-material/_sidenav.scss +46 -0
  27. package/dist/assets/scss/angular-material/_slider.scss +131 -0
  28. package/dist/assets/scss/angular-material/_stepper.scss +162 -0
  29. package/dist/assets/scss/angular-material/_tab.scss +87 -0
  30. package/dist/assets/scss/angular-material/_table.scss +108 -0
  31. package/dist/assets/scss/angular-material/_toggle-slide.scss +108 -0
  32. package/dist/assets/scss/angular-material/_toggle.scss +112 -0
  33. package/dist/assets/scss/angular-material/_tooltip.scss +74 -0
  34. package/dist/assets/scss/angular-material/material.scss +16 -0
  35. package/dist/assets/scss/base.scss +66 -0
  36. package/dist/assets/scss/components/_breadcrumb.scss +63 -0
  37. package/dist/assets/scss/components/_card.scss +24 -0
  38. package/dist/assets/scss/components/_charts.scss +190 -0
  39. package/dist/assets/scss/components/_components.scss +19 -0
  40. package/dist/assets/scss/components/_full-calendar.scss +391 -0
  41. package/dist/assets/scss/components/_helper.scss +444 -0
  42. package/dist/assets/scss/components/_images.scss +67 -0
  43. package/dist/assets/scss/components/_info-section.scss +112 -0
  44. package/dist/assets/scss/components/_introJs.scss +109 -0
  45. package/dist/assets/scss/components/_lists.scss +171 -0
  46. package/dist/assets/scss/components/_loading.scss +38 -0
  47. package/dist/assets/scss/components/_ngx-pagination.scss +66 -0
  48. package/dist/assets/scss/components/_page-title.scss +18 -0
  49. package/dist/assets/scss/components/_progress.scss +70 -0
  50. package/dist/assets/scss/components/_repeated-list.scss +38 -0
  51. package/dist/assets/scss/components/_scrollbar.scss +32 -0
  52. package/dist/assets/scss/components/_status.scss +119 -0
  53. package/dist/assets/scss/components/_stc-icons.scss +1051 -0
  54. package/dist/assets/scss/components/_toaster.scss +109 -0
  55. package/dist/assets/scss/components/_user-list.scss +40 -0
  56. package/dist/assets/scss/hub/_hub.scss +756 -0
  57. package/dist/assets/scss/hub/_new-hub.scss +115 -0
  58. package/dist/assets/scss/mixins/_button-mixin.scss +98 -0
  59. package/dist/assets/scss/mixins/_colors-mixin.scss +58 -0
  60. package/dist/assets/scss/mixins/_fonts-mixin.scss +39 -0
  61. package/dist/assets/scss/mixins/_radius-mixin.scss +12 -0
  62. package/dist/assets/scss/mixins/mixins.scss +4 -0
  63. package/dist/assets/scss/web-components/_alert.scss +32 -0
  64. package/dist/assets/scss/web-components/_buttons.scss +94 -0
  65. package/dist/assets/scss/web-components/_status.scss +66 -0
  66. package/dist/assets/scss/web-components/web-components.scss +3 -0
  67. package/dist/assets/scss-old/_bootstrap.scss +16 -0
  68. package/dist/assets/scss-old/_colors.scss +5 -0
  69. package/dist/assets/scss-old/_fonts.scss +273 -0
  70. package/dist/assets/scss-old/_general.scss +401 -0
  71. package/dist/assets/scss-old/_reset.scss +60 -0
  72. package/dist/assets/scss-old/_variables.scss +18 -0
  73. package/dist/assets/scss-old/angular-material/_accordion.scss +130 -0
  74. package/dist/assets/scss-old/angular-material/_checkbox.scss +48 -0
  75. package/dist/assets/scss-old/angular-material/_chip-list.scss +32 -0
  76. package/dist/assets/scss-old/angular-material/_chips.scss +42 -0
  77. package/dist/assets/scss-old/angular-material/_datepicker.scss +191 -0
  78. package/dist/assets/scss-old/angular-material/_form-field.scss +665 -0
  79. package/dist/assets/scss-old/angular-material/_popover.scss +352 -0
  80. package/dist/assets/scss-old/angular-material/_popups.scss +125 -0
  81. package/dist/assets/scss-old/angular-material/_radiobox.scss +40 -0
  82. package/dist/assets/scss-old/angular-material/_sidenav.scss +46 -0
  83. package/dist/assets/scss-old/angular-material/_slider.scss +94 -0
  84. package/dist/assets/scss-old/angular-material/_stepper.scss +162 -0
  85. package/dist/assets/scss-old/angular-material/_tab.scss +68 -0
  86. package/dist/assets/scss-old/angular-material/_table.scss +101 -0
  87. package/dist/assets/scss-old/angular-material/_toggle-slide.scss +59 -0
  88. package/dist/assets/scss-old/angular-material/_toggle.scss +115 -0
  89. package/dist/assets/scss-old/angular-material/_tooltip.scss +46 -0
  90. package/dist/assets/scss-old/angular-material/material.scss +16 -0
  91. package/dist/assets/scss-old/base.scss +63 -0
  92. package/dist/assets/scss-old/components/_breadcrumb.scss +63 -0
  93. package/dist/assets/scss-old/components/_card.scss +24 -0
  94. package/dist/assets/scss-old/components/_components.scss +16 -0
  95. package/dist/assets/scss-old/components/_full-calendar.scss +391 -0
  96. package/dist/assets/scss-old/components/_helper.scss +427 -0
  97. package/dist/assets/scss-old/components/_images.scss +67 -0
  98. package/dist/assets/scss-old/components/_info-section.scss +112 -0
  99. package/dist/assets/scss-old/components/_introJs.scss +109 -0
  100. package/dist/assets/scss-old/components/_lists.scss +105 -0
  101. package/dist/assets/scss-old/components/_loading.scss +38 -0
  102. package/dist/assets/scss-old/components/_ngx-pagination.scss +66 -0
  103. package/dist/assets/scss-old/components/_page-title.scss +18 -0
  104. package/dist/assets/scss-old/components/_progress.scss +70 -0
  105. package/dist/assets/scss-old/components/_scrollbar.scss +32 -0
  106. package/dist/assets/scss-old/components/_status.scss +119 -0
  107. package/dist/assets/scss-old/components/_stc-icons.scss +955 -0
  108. package/dist/assets/scss-old/components/_toaster.scss +125 -0
  109. package/dist/assets/scss-old/hub/_hub.scss +756 -0
  110. package/dist/assets/scss-old/hub/_new-hub.scss +115 -0
  111. package/dist/assets/scss-old/mixins/_button-mixin.scss +98 -0
  112. package/dist/assets/scss-old/mixins/_colors-mixin.scss +56 -0
  113. package/dist/assets/scss-old/mixins/_fonts-mixin.scss +38 -0
  114. package/dist/assets/scss-old/mixins/_radius-mixin.scss +11 -0
  115. package/dist/assets/scss-old/mixins/mixins.scss +4 -0
  116. package/dist/assets/scss-old/web-components/_alert.scss +32 -0
  117. package/dist/assets/scss-old/web-components/_buttons.scss +92 -0
  118. package/dist/assets/scss-old/web-components/_status.scss +66 -0
  119. package/dist/assets/scss-old/web-components/web-components.scss +3 -0
  120. package/dist/cjs/ds-activity-log_16.cjs.entry.js +767 -0
  121. package/dist/cjs/ds-components.cjs.js +23 -0
  122. package/dist/cjs/ds-loading-page.cjs.entry.js +19 -0
  123. package/dist/cjs/ds-splash.cjs.entry.js +20 -0
  124. package/dist/cjs/index-67056d48.js +2391 -0
  125. package/dist/cjs/index.cjs.js +2 -0
  126. package/dist/cjs/loader.cjs.js +22 -0
  127. package/dist/collection/assets/fonts/symbol-defs.svg +939 -0
  128. package/dist/collection/assets/images/404.svg +104 -0
  129. package/dist/collection/assets/images/no-cards.svg +5 -0
  130. package/dist/collection/assets/images/no-connection.svg +56 -0
  131. package/dist/collection/assets/images/no-data.svg +38 -0
  132. package/dist/collection/assets/images/no-lists.svg +10 -0
  133. package/dist/collection/assets/images/not-authorized.svg +6 -0
  134. package/dist/collection/assets/images/user.svg +4 -0
  135. package/dist/collection/assets/js/svgxuse.min.js +12 -0
  136. package/dist/collection/collection-manifest.json +29 -0
  137. package/dist/collection/components/ds-activity-log/ds-activity-log.css +91 -0
  138. package/dist/collection/components/ds-activity-log/ds-activity-log.js +105 -0
  139. package/dist/collection/components/ds-alert/ds-alert.css +34 -0
  140. package/dist/collection/components/ds-alert/ds-alert.js +61 -0
  141. package/dist/collection/components/ds-approvals/ds-approvals.css +60 -0
  142. package/dist/collection/components/ds-approvals/ds-approvals.js +71 -0
  143. package/dist/collection/components/ds-attachments/ds-attachments.css +84 -0
  144. package/dist/collection/components/ds-attachments/ds-attachments.js +229 -0
  145. package/dist/collection/components/ds-avatar/ds-avatar.css +84 -0
  146. package/dist/collection/components/ds-avatar/ds-avatar.js +138 -0
  147. package/dist/collection/components/ds-button/ds-button.css +196 -0
  148. package/dist/collection/components/ds-button/ds-button.js +313 -0
  149. package/dist/collection/components/ds-card/ds-card.css +53 -0
  150. package/dist/collection/components/ds-card/ds-card.js +64 -0
  151. package/dist/collection/components/ds-file-picker/ds-file-picker.css +79 -0
  152. package/dist/collection/components/ds-file-picker/ds-file-picker.js +67 -0
  153. package/dist/collection/components/ds-icon/ds-icon.js +55 -0
  154. package/dist/collection/components/ds-icon/stc-icon.css +1403 -0
  155. package/dist/collection/components/ds-loading-chart/ds-loading-chart.css +80 -0
  156. package/dist/collection/components/ds-loading-chart/ds-loading-chart.js +70 -0
  157. package/dist/collection/components/ds-loading-page/ds-loading-page.css +116 -0
  158. package/dist/collection/components/ds-loading-page/ds-loading-page.js +18 -0
  159. package/dist/collection/components/ds-loading-table/ds-loading-table.css +3 -0
  160. package/dist/collection/components/ds-loading-table/ds-loading-table.js +90 -0
  161. package/dist/collection/components/ds-message/ds-message.css +28 -0
  162. package/dist/collection/components/ds-message/ds-message.js +95 -0
  163. package/dist/collection/components/ds-sla/ds-sla.css +6 -0
  164. package/dist/collection/components/ds-sla/ds-sla.js +196 -0
  165. package/dist/collection/components/ds-slider/ds-slider.css +111 -0
  166. package/dist/collection/components/ds-slider/ds-slider.js +329 -0
  167. package/dist/collection/components/ds-splash/ds-splash.css +62 -0
  168. package/dist/collection/components/ds-splash/ds-splash.js +42 -0
  169. package/dist/collection/components/ds-status/ds-status.css +47 -0
  170. package/dist/collection/components/ds-status/ds-status.js +106 -0
  171. package/dist/collection/components/ds-user-card/ds-user-card.css +54 -0
  172. package/dist/collection/components/ds-user-card/ds-user-card.js +102 -0
  173. package/dist/collection/index.js +1 -0
  174. package/dist/collection/utils/ej2.min.js +10 -0
  175. package/dist/collection/utils/generate-icons.js +72 -0
  176. package/dist/collection/utils/myScripts.js +0 -0
  177. package/dist/collection/utils/rollup-utils.js +41 -0
  178. package/dist/collection/utils/svgxuse.min.js +12 -0
  179. package/dist/collection/utils/utils.js +1 -0
  180. package/dist/components/ds-activity-log.d.ts +11 -0
  181. package/dist/components/ds-activity-log.js +105 -0
  182. package/dist/components/ds-alert.d.ts +11 -0
  183. package/dist/components/ds-alert.js +44 -0
  184. package/dist/components/ds-approvals.d.ts +11 -0
  185. package/dist/components/ds-approvals.js +76 -0
  186. package/dist/components/ds-attachments.d.ts +11 -0
  187. package/dist/components/ds-attachments.js +6 -0
  188. package/dist/components/ds-attachments2.js +103 -0
  189. package/dist/components/ds-avatar.d.ts +11 -0
  190. package/dist/components/ds-avatar.js +6 -0
  191. package/dist/components/ds-avatar2.js +72 -0
  192. package/dist/components/ds-button.d.ts +11 -0
  193. package/dist/components/ds-button.js +6 -0
  194. package/dist/components/ds-button2.js +99 -0
  195. package/dist/components/ds-card.d.ts +11 -0
  196. package/dist/components/ds-card.js +58 -0
  197. package/dist/components/ds-file-picker.d.ts +11 -0
  198. package/dist/components/ds-file-picker.js +43 -0
  199. package/dist/components/ds-icon.d.ts +11 -0
  200. package/dist/components/ds-icon.js +6 -0
  201. package/dist/components/ds-icon2.js +44 -0
  202. package/dist/components/ds-loading-chart.d.ts +11 -0
  203. package/dist/components/ds-loading-chart.js +60 -0
  204. package/dist/components/ds-loading-page.d.ts +11 -0
  205. package/dist/components/ds-loading-page.js +33 -0
  206. package/dist/components/ds-loading-table.d.ts +11 -0
  207. package/dist/components/ds-loading-table.js +49 -0
  208. package/dist/components/ds-message.d.ts +11 -0
  209. package/dist/components/ds-message.js +61 -0
  210. package/dist/components/ds-sla.d.ts +11 -0
  211. package/dist/components/ds-sla.js +71 -0
  212. package/dist/components/ds-slider.d.ts +11 -0
  213. package/dist/components/ds-slider.js +235 -0
  214. package/dist/components/ds-splash.d.ts +11 -0
  215. package/dist/components/ds-splash.js +36 -0
  216. package/dist/components/ds-status.d.ts +11 -0
  217. package/dist/components/ds-status.js +6 -0
  218. package/dist/components/ds-status2.js +48 -0
  219. package/dist/components/ds-user-card.d.ts +11 -0
  220. package/dist/components/ds-user-card.js +6 -0
  221. package/dist/components/ds-user-card2.js +58 -0
  222. package/dist/components/index.d.ts +48 -0
  223. package/dist/components/index.js +19 -0
  224. package/dist/ds-components/ds-components.css +5780 -0
  225. package/dist/ds-components/ds-components.esm.js +1 -0
  226. package/dist/ds-components/index.esm.js +0 -0
  227. package/dist/ds-components/p-2bf203e1.entry.js +1 -0
  228. package/dist/ds-components/p-60a24d37.entry.js +1 -0
  229. package/dist/ds-components/p-a4922f25.entry.js +1 -0
  230. package/dist/ds-components/p-f85fbdb4.js +2 -0
  231. package/dist/esm/ds-activity-log_16.entry.js +748 -0
  232. package/dist/esm/ds-components.js +18 -0
  233. package/dist/esm/ds-loading-page.entry.js +15 -0
  234. package/dist/esm/ds-splash.entry.js +16 -0
  235. package/dist/esm/index-b257ae8c.js +2362 -0
  236. package/dist/esm/index.js +1 -0
  237. package/dist/esm/loader.js +18 -0
  238. package/dist/esm/polyfills/core-js.js +11 -0
  239. package/dist/esm/polyfills/css-shim.js +1 -0
  240. package/dist/esm/polyfills/dom.js +79 -0
  241. package/dist/esm/polyfills/es5-html-element.js +1 -0
  242. package/dist/esm/polyfills/index.js +34 -0
  243. package/dist/esm/polyfills/system.js +6 -0
  244. package/dist/index.cjs.js +1 -0
  245. package/dist/index.js +1 -0
  246. package/dist/types/components/ds-activity-log/ds-activity-log.d.ts +22 -0
  247. package/dist/types/components/ds-alert/ds-alert.d.ts +5 -0
  248. package/dist/types/components/ds-approvals/ds-approvals.d.ts +18 -0
  249. package/dist/types/components/ds-attachments/ds-attachments.d.ts +26 -0
  250. package/dist/types/components/ds-avatar/ds-avatar.d.ts +14 -0
  251. package/dist/types/components/ds-button/ds-button.d.ts +23 -0
  252. package/dist/types/components/ds-card/ds-card.d.ts +20 -0
  253. package/dist/types/components/ds-file-picker/ds-file-picker.d.ts +9 -0
  254. package/dist/types/components/ds-icon/ds-icon.d.ts +4 -0
  255. package/dist/types/components/ds-loading-chart/ds-loading-chart.d.ts +9 -0
  256. package/dist/types/components/ds-loading-page/ds-loading-page.d.ts +3 -0
  257. package/dist/types/components/ds-loading-table/ds-loading-table.d.ts +8 -0
  258. package/dist/types/components/ds-message/ds-message.d.ts +8 -0
  259. package/dist/types/components/ds-sla/ds-sla.d.ts +18 -0
  260. package/dist/types/components/ds-slider/ds-slider.d.ts +50 -0
  261. package/dist/types/components/ds-splash/ds-splash.d.ts +4 -0
  262. package/dist/types/components/ds-status/ds-status.d.ts +8 -0
  263. package/dist/types/components/ds-user-card/ds-user-card.d.ts +15 -0
  264. package/dist/types/components.d.ts +389 -0
  265. package/dist/types/index.d.ts +1 -0
  266. package/dist/types/stencil-public-runtime.d.ts +1637 -0
  267. package/dist/types/utils/utils.d.ts +3 -0
  268. package/hydrate/index.d.ts +217 -0
  269. package/hydrate/index.js +7561 -0
  270. package/hydrate/package.json +6 -0
  271. package/loader/cdn.js +3 -0
  272. package/loader/index.cjs.js +3 -0
  273. package/loader/index.d.ts +21 -0
  274. package/loader/index.es2017.js +3 -0
  275. package/loader/index.js +4 -0
  276. package/loader/package.json +11 -0
  277. package/package.json +40 -0
  278. package/readme.md +75 -0
@@ -0,0 +1,2391 @@
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 = 'ds-components';
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 contentRef;
35
+ let hostTagName;
36
+ let useNativeShadowDom = false;
37
+ let checkSlotFallbackVisibility = false;
38
+ let checkSlotRelocate = false;
39
+ let isSvgMode = false;
40
+ let queuePending = false;
41
+ const createTime = (fnName, tagName = '') => {
42
+ {
43
+ return () => {
44
+ return;
45
+ };
46
+ }
47
+ };
48
+ const uniqueTime = (key, measureText) => {
49
+ {
50
+ return () => {
51
+ return;
52
+ };
53
+ }
54
+ };
55
+ const CONTENT_REF_ID = 'r';
56
+ const ORG_LOCATION_ID = 'o';
57
+ const SLOT_NODE_ID = 's';
58
+ const TEXT_NODE_ID = 't';
59
+ const HYDRATE_ID = 's-id';
60
+ const HYDRATED_STYLE_ID = 'sty-id';
61
+ const HYDRATE_CHILD_ID = 'c-id';
62
+ const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
63
+ const XLINK_NS = 'http://www.w3.org/1999/xlink';
64
+ /**
65
+ * Default style mode id
66
+ */
67
+ /**
68
+ * Reusable empty obj/array
69
+ * Don't add values to these!!
70
+ */
71
+ const EMPTY_OBJ = {};
72
+ /**
73
+ * Namespaces
74
+ */
75
+ const SVG_NS = 'http://www.w3.org/2000/svg';
76
+ const HTML_NS = 'http://www.w3.org/1999/xhtml';
77
+ const isDef = (v) => v != null;
78
+ const isComplexType = (o) => {
79
+ // https://jsperf.com/typeof-fn-object/5
80
+ o = typeof o;
81
+ return o === 'object' || o === 'function';
82
+ };
83
+ /**
84
+ * Helper method for querying a `meta` tag that contains a nonce value
85
+ * out of a DOM's head.
86
+ *
87
+ * @param doc The DOM containing the `head` to query against
88
+ * @returns The content of the meta tag representing the nonce value, or `undefined` if no tag
89
+ * exists or the tag has no content.
90
+ */
91
+ function queryNonceMetaTagContent(doc) {
92
+ var _a, _b, _c;
93
+ 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;
94
+ }
95
+ /**
96
+ * Production h() function based on Preact by
97
+ * Jason Miller (@developit)
98
+ * Licensed under the MIT License
99
+ * https://github.com/developit/preact/blob/master/LICENSE
100
+ *
101
+ * Modified for Stencil's compiler and vdom
102
+ */
103
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
104
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
105
+ const h = (nodeName, vnodeData, ...children) => {
106
+ let child = null;
107
+ let key = null;
108
+ let slotName = null;
109
+ let simple = false;
110
+ let lastSimple = false;
111
+ const vNodeChildren = [];
112
+ const walk = (c) => {
113
+ for (let i = 0; i < c.length; i++) {
114
+ child = c[i];
115
+ if (Array.isArray(child)) {
116
+ walk(child);
117
+ }
118
+ else if (child != null && typeof child !== 'boolean') {
119
+ if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
120
+ child = String(child);
121
+ }
122
+ if (simple && lastSimple) {
123
+ // If the previous child was simple (string), we merge both
124
+ vNodeChildren[vNodeChildren.length - 1].$text$ += child;
125
+ }
126
+ else {
127
+ // Append a new vNode, if it's text, we create a text vNode
128
+ vNodeChildren.push(simple ? newVNode(null, child) : child);
129
+ }
130
+ lastSimple = simple;
131
+ }
132
+ }
133
+ };
134
+ walk(children);
135
+ if (vnodeData) {
136
+ // normalize class / classname attributes
137
+ if (vnodeData.key) {
138
+ key = vnodeData.key;
139
+ }
140
+ if (vnodeData.name) {
141
+ slotName = vnodeData.name;
142
+ }
143
+ {
144
+ const classData = vnodeData.className || vnodeData.class;
145
+ if (classData) {
146
+ vnodeData.class =
147
+ typeof classData !== 'object'
148
+ ? classData
149
+ : Object.keys(classData)
150
+ .filter((k) => classData[k])
151
+ .join(' ');
152
+ }
153
+ }
154
+ }
155
+ if (typeof nodeName === 'function') {
156
+ // nodeName is a functional component
157
+ return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
158
+ }
159
+ const vnode = newVNode(nodeName, null);
160
+ vnode.$attrs$ = vnodeData;
161
+ if (vNodeChildren.length > 0) {
162
+ vnode.$children$ = vNodeChildren;
163
+ }
164
+ {
165
+ vnode.$key$ = key;
166
+ }
167
+ {
168
+ vnode.$name$ = slotName;
169
+ }
170
+ return vnode;
171
+ };
172
+ /**
173
+ * A utility function for creating a virtual DOM node from a tag and some
174
+ * possible text content.
175
+ *
176
+ * @param tag the tag for this element
177
+ * @param text possible text content for the node
178
+ * @returns a newly-minted virtual DOM node
179
+ */
180
+ const newVNode = (tag, text) => {
181
+ const vnode = {
182
+ $flags$: 0,
183
+ $tag$: tag,
184
+ $text$: text,
185
+ $elm$: null,
186
+ $children$: null,
187
+ };
188
+ {
189
+ vnode.$attrs$ = null;
190
+ }
191
+ {
192
+ vnode.$key$ = null;
193
+ }
194
+ {
195
+ vnode.$name$ = null;
196
+ }
197
+ return vnode;
198
+ };
199
+ const Host = {};
200
+ /**
201
+ * Check whether a given node is a Host node or not
202
+ *
203
+ * @param node the virtual DOM node to check
204
+ * @returns whether it's a Host node or not
205
+ */
206
+ const isHost = (node) => node && node.$tag$ === Host;
207
+ /**
208
+ * Implementation of {@link d.FunctionalUtilities} for Stencil's VDom.
209
+ *
210
+ * Note that these functions convert from {@link d.VNode} to
211
+ * {@link d.ChildNode} to give functional component developers a friendly
212
+ * interface.
213
+ */
214
+ const vdomFnUtils = {
215
+ forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
216
+ map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate),
217
+ };
218
+ /**
219
+ * Convert a {@link d.VNode} to a {@link d.ChildNode} in order to present a
220
+ * friendlier public interface (hence, 'convertToPublic').
221
+ *
222
+ * @param node the virtual DOM node to convert
223
+ * @returns a converted child node
224
+ */
225
+ const convertToPublic = (node) => ({
226
+ vattrs: node.$attrs$,
227
+ vchildren: node.$children$,
228
+ vkey: node.$key$,
229
+ vname: node.$name$,
230
+ vtag: node.$tag$,
231
+ vtext: node.$text$,
232
+ });
233
+ /**
234
+ * Convert a {@link d.ChildNode} back to an equivalent {@link d.VNode} in
235
+ * order to use the resulting object in the virtual DOM. The initial object was
236
+ * likely created as part of presenting a public API, so converting it back
237
+ * involved making it 'private' again (hence, `convertToPrivate`).
238
+ *
239
+ * @param node the child node to convert
240
+ * @returns a converted virtual DOM node
241
+ */
242
+ const convertToPrivate = (node) => {
243
+ if (typeof node.vtag === 'function') {
244
+ const vnodeData = Object.assign({}, node.vattrs);
245
+ if (node.vkey) {
246
+ vnodeData.key = node.vkey;
247
+ }
248
+ if (node.vname) {
249
+ vnodeData.name = node.vname;
250
+ }
251
+ return h(node.vtag, vnodeData, ...(node.vchildren || []));
252
+ }
253
+ const vnode = newVNode(node.vtag, node.vtext);
254
+ vnode.$attrs$ = node.vattrs;
255
+ vnode.$children$ = node.vchildren;
256
+ vnode.$key$ = node.vkey;
257
+ vnode.$name$ = node.vname;
258
+ return vnode;
259
+ };
260
+ const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
261
+ const endHydrate = createTime('hydrateClient', tagName);
262
+ const shadowRoot = hostElm.shadowRoot;
263
+ const childRenderNodes = [];
264
+ const slotNodes = [];
265
+ const shadowRootNodes = shadowRoot ? [] : null;
266
+ const vnode = (hostRef.$vnode$ = newVNode(tagName, null));
267
+ if (!plt.$orgLocNodes$) {
268
+ initializeDocumentHydrate(doc.body, (plt.$orgLocNodes$ = new Map()));
269
+ }
270
+ hostElm[HYDRATE_ID] = hostId;
271
+ hostElm.removeAttribute(HYDRATE_ID);
272
+ clientHydrate(vnode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, hostElm, hostId);
273
+ childRenderNodes.map((c) => {
274
+ const orgLocationId = c.$hostId$ + '.' + c.$nodeId$;
275
+ const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
276
+ const node = c.$elm$;
277
+ if (orgLocationNode && supportsShadow && orgLocationNode['s-en'] === '') {
278
+ orgLocationNode.parentNode.insertBefore(node, orgLocationNode.nextSibling);
279
+ }
280
+ if (!shadowRoot) {
281
+ node['s-hn'] = tagName;
282
+ if (orgLocationNode) {
283
+ node['s-ol'] = orgLocationNode;
284
+ node['s-ol']['s-nr'] = node;
285
+ }
286
+ }
287
+ plt.$orgLocNodes$.delete(orgLocationId);
288
+ });
289
+ if (shadowRoot) {
290
+ shadowRootNodes.map((shadowRootNode) => {
291
+ if (shadowRootNode) {
292
+ shadowRoot.appendChild(shadowRootNode);
293
+ }
294
+ });
295
+ }
296
+ endHydrate();
297
+ };
298
+ const clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node, hostId) => {
299
+ let childNodeType;
300
+ let childIdSplt;
301
+ let childVNode;
302
+ let i;
303
+ if (node.nodeType === 1 /* NODE_TYPE.ElementNode */) {
304
+ childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
305
+ if (childNodeType) {
306
+ // got the node data from the element's attribute
307
+ // `${hostId}.${nodeId}.${depth}.${index}`
308
+ childIdSplt = childNodeType.split('.');
309
+ if (childIdSplt[0] === hostId || childIdSplt[0] === '0') {
310
+ childVNode = {
311
+ $flags$: 0,
312
+ $hostId$: childIdSplt[0],
313
+ $nodeId$: childIdSplt[1],
314
+ $depth$: childIdSplt[2],
315
+ $index$: childIdSplt[3],
316
+ $tag$: node.tagName.toLowerCase(),
317
+ $elm$: node,
318
+ $attrs$: null,
319
+ $children$: null,
320
+ $key$: null,
321
+ $name$: null,
322
+ $text$: null,
323
+ };
324
+ childRenderNodes.push(childVNode);
325
+ node.removeAttribute(HYDRATE_CHILD_ID);
326
+ // this is a new child vnode
327
+ // so ensure its parent vnode has the vchildren array
328
+ if (!parentVNode.$children$) {
329
+ parentVNode.$children$ = [];
330
+ }
331
+ // add our child vnode to a specific index of the vnode's children
332
+ parentVNode.$children$[childVNode.$index$] = childVNode;
333
+ // this is now the new parent vnode for all the next child checks
334
+ parentVNode = childVNode;
335
+ if (shadowRootNodes && childVNode.$depth$ === '0') {
336
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
337
+ }
338
+ }
339
+ }
340
+ // recursively drill down, end to start so we can remove nodes
341
+ for (i = node.childNodes.length - 1; i >= 0; i--) {
342
+ clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.childNodes[i], hostId);
343
+ }
344
+ if (node.shadowRoot) {
345
+ // keep drilling down through the shadow root nodes
346
+ for (i = node.shadowRoot.childNodes.length - 1; i >= 0; i--) {
347
+ clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.shadowRoot.childNodes[i], hostId);
348
+ }
349
+ }
350
+ }
351
+ else if (node.nodeType === 8 /* NODE_TYPE.CommentNode */) {
352
+ // `${COMMENT_TYPE}.${hostId}.${nodeId}.${depth}.${index}`
353
+ childIdSplt = node.nodeValue.split('.');
354
+ if (childIdSplt[1] === hostId || childIdSplt[1] === '0') {
355
+ // comment node for either the host id or a 0 host id
356
+ childNodeType = childIdSplt[0];
357
+ childVNode = {
358
+ $flags$: 0,
359
+ $hostId$: childIdSplt[1],
360
+ $nodeId$: childIdSplt[2],
361
+ $depth$: childIdSplt[3],
362
+ $index$: childIdSplt[4],
363
+ $elm$: node,
364
+ $attrs$: null,
365
+ $children$: null,
366
+ $key$: null,
367
+ $name$: null,
368
+ $tag$: null,
369
+ $text$: null,
370
+ };
371
+ if (childNodeType === TEXT_NODE_ID) {
372
+ childVNode.$elm$ = node.nextSibling;
373
+ if (childVNode.$elm$ && childVNode.$elm$.nodeType === 3 /* NODE_TYPE.TextNode */) {
374
+ childVNode.$text$ = childVNode.$elm$.textContent;
375
+ childRenderNodes.push(childVNode);
376
+ // remove the text comment since it's no longer needed
377
+ node.remove();
378
+ if (!parentVNode.$children$) {
379
+ parentVNode.$children$ = [];
380
+ }
381
+ parentVNode.$children$[childVNode.$index$] = childVNode;
382
+ if (shadowRootNodes && childVNode.$depth$ === '0') {
383
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
384
+ }
385
+ }
386
+ }
387
+ else if (childVNode.$hostId$ === hostId) {
388
+ // this comment node is specifcally for this host id
389
+ if (childNodeType === SLOT_NODE_ID) {
390
+ // `${SLOT_NODE_ID}.${hostId}.${nodeId}.${depth}.${index}.${slotName}`;
391
+ childVNode.$tag$ = 'slot';
392
+ if (childIdSplt[5]) {
393
+ node['s-sn'] = childVNode.$name$ = childIdSplt[5];
394
+ }
395
+ else {
396
+ node['s-sn'] = '';
397
+ }
398
+ node['s-sr'] = true;
399
+ if (shadowRootNodes) {
400
+ // browser support shadowRoot and this is a shadow dom component
401
+ // create an actual slot element
402
+ childVNode.$elm$ = doc.createElement(childVNode.$tag$);
403
+ if (childVNode.$name$) {
404
+ // add the slot name attribute
405
+ childVNode.$elm$.setAttribute('name', childVNode.$name$);
406
+ }
407
+ // insert the new slot element before the slot comment
408
+ node.parentNode.insertBefore(childVNode.$elm$, node);
409
+ // remove the slot comment since it's not needed for shadow
410
+ node.remove();
411
+ if (childVNode.$depth$ === '0') {
412
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
413
+ }
414
+ }
415
+ slotNodes.push(childVNode);
416
+ if (!parentVNode.$children$) {
417
+ parentVNode.$children$ = [];
418
+ }
419
+ parentVNode.$children$[childVNode.$index$] = childVNode;
420
+ }
421
+ else if (childNodeType === CONTENT_REF_ID) {
422
+ // `${CONTENT_REF_ID}.${hostId}`;
423
+ if (shadowRootNodes) {
424
+ // remove the content ref comment since it's not needed for shadow
425
+ node.remove();
426
+ }
427
+ else {
428
+ hostElm['s-cr'] = node;
429
+ node['s-cn'] = true;
430
+ }
431
+ }
432
+ }
433
+ }
434
+ }
435
+ else if (parentVNode && parentVNode.$tag$ === 'style') {
436
+ const vnode = newVNode(null, node.textContent);
437
+ vnode.$elm$ = node;
438
+ vnode.$index$ = '0';
439
+ parentVNode.$children$ = [vnode];
440
+ }
441
+ };
442
+ const initializeDocumentHydrate = (node, orgLocNodes) => {
443
+ if (node.nodeType === 1 /* NODE_TYPE.ElementNode */) {
444
+ let i = 0;
445
+ for (; i < node.childNodes.length; i++) {
446
+ initializeDocumentHydrate(node.childNodes[i], orgLocNodes);
447
+ }
448
+ if (node.shadowRoot) {
449
+ for (i = 0; i < node.shadowRoot.childNodes.length; i++) {
450
+ initializeDocumentHydrate(node.shadowRoot.childNodes[i], orgLocNodes);
451
+ }
452
+ }
453
+ }
454
+ else if (node.nodeType === 8 /* NODE_TYPE.CommentNode */) {
455
+ const childIdSplt = node.nodeValue.split('.');
456
+ if (childIdSplt[0] === ORG_LOCATION_ID) {
457
+ orgLocNodes.set(childIdSplt[1] + '.' + childIdSplt[2], node);
458
+ node.nodeValue = '';
459
+ // useful to know if the original location is
460
+ // the root light-dom of a shadow dom component
461
+ node['s-en'] = childIdSplt[3];
462
+ }
463
+ }
464
+ };
465
+ /**
466
+ * Parse a new property value for a given property type.
467
+ *
468
+ * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
469
+ * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
470
+ * 1. `any`, the type given to `propValue` in the function signature
471
+ * 2. the type stored from `propType`.
472
+ *
473
+ * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
474
+ *
475
+ * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
476
+ * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
477
+ * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
478
+ * ```tsx
479
+ * <my-cmp prop-val={0}></my-cmp>
480
+ * ```
481
+ *
482
+ * HTML prop values on the other hand, will always a string
483
+ *
484
+ * @param propValue the new value to coerce to some type
485
+ * @param propType the type of the prop, expressed as a binary number
486
+ * @returns the parsed/coerced value
487
+ */
488
+ const parsePropertyValue = (propValue, propType) => {
489
+ // ensure this value is of the correct prop type
490
+ if (propValue != null && !isComplexType(propValue)) {
491
+ if (propType & 4 /* MEMBER_FLAGS.Boolean */) {
492
+ // per the HTML spec, any string value means it is a boolean true value
493
+ // but we'll cheat here and say that the string "false" is the boolean false
494
+ return propValue === 'false' ? false : propValue === '' || !!propValue;
495
+ }
496
+ if (propType & 2 /* MEMBER_FLAGS.Number */) {
497
+ // force it to be a number
498
+ return parseFloat(propValue);
499
+ }
500
+ if (propType & 1 /* MEMBER_FLAGS.String */) {
501
+ // could have been passed as a number or boolean
502
+ // but we still want it as a string
503
+ return String(propValue);
504
+ }
505
+ // redundant return here for better minification
506
+ return propValue;
507
+ }
508
+ // not sure exactly what type we want
509
+ // so no need to change to a different type
510
+ return propValue;
511
+ };
512
+ const getElement = (ref) => (getHostRef(ref).$hostElement$ );
513
+ const createEvent = (ref, name, flags) => {
514
+ const elm = getElement(ref);
515
+ return {
516
+ emit: (detail) => {
517
+ return emitEvent(elm, name, {
518
+ bubbles: !!(flags & 4 /* EVENT_FLAGS.Bubbles */),
519
+ composed: !!(flags & 2 /* EVENT_FLAGS.Composed */),
520
+ cancelable: !!(flags & 1 /* EVENT_FLAGS.Cancellable */),
521
+ detail,
522
+ });
523
+ },
524
+ };
525
+ };
526
+ /**
527
+ * Helper function to create & dispatch a custom Event on a provided target
528
+ * @param elm the target of the Event
529
+ * @param name the name to give the custom Event
530
+ * @param opts options for configuring a custom Event
531
+ * @returns the custom Event
532
+ */
533
+ const emitEvent = (elm, name, opts) => {
534
+ const ev = plt.ce(name, opts);
535
+ elm.dispatchEvent(ev);
536
+ return ev;
537
+ };
538
+ const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
539
+ const registerStyle = (scopeId, cssText, allowCS) => {
540
+ let style = styles.get(scopeId);
541
+ if (supportsConstructableStylesheets && allowCS) {
542
+ style = (style || new CSSStyleSheet());
543
+ if (typeof style === 'string') {
544
+ style = cssText;
545
+ }
546
+ else {
547
+ style.replaceSync(cssText);
548
+ }
549
+ }
550
+ else {
551
+ style = cssText;
552
+ }
553
+ styles.set(scopeId, style);
554
+ };
555
+ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
556
+ var _a;
557
+ let scopeId = getScopeId(cmpMeta);
558
+ const style = styles.get(scopeId);
559
+ // if an element is NOT connected then getRootNode() will return the wrong root node
560
+ // so the fallback is to always use the document for the root node in those cases
561
+ styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
562
+ if (style) {
563
+ if (typeof style === 'string') {
564
+ styleContainerNode = styleContainerNode.head || styleContainerNode;
565
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
566
+ let styleElm;
567
+ if (!appliedStyles) {
568
+ rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
569
+ }
570
+ if (!appliedStyles.has(scopeId)) {
571
+ if (styleContainerNode.host &&
572
+ (styleElm = styleContainerNode.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId}"]`))) {
573
+ // This is only happening on native shadow-dom, do not needs CSS var shim
574
+ styleElm.innerHTML = style;
575
+ }
576
+ else {
577
+ {
578
+ styleElm = doc.createElement('style');
579
+ styleElm.innerHTML = style;
580
+ }
581
+ // Apply CSP nonce to the style tag if it exists
582
+ const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
583
+ if (nonce != null) {
584
+ styleElm.setAttribute('nonce', nonce);
585
+ }
586
+ styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
587
+ }
588
+ if (appliedStyles) {
589
+ appliedStyles.add(scopeId);
590
+ }
591
+ }
592
+ }
593
+ else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
594
+ styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
595
+ }
596
+ }
597
+ return scopeId;
598
+ };
599
+ const attachStyles = (hostRef) => {
600
+ const cmpMeta = hostRef.$cmpMeta$;
601
+ const elm = hostRef.$hostElement$;
602
+ const flags = cmpMeta.$flags$;
603
+ const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
604
+ const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
605
+ if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
606
+ // only required when we're NOT using native shadow dom (slot)
607
+ // or this browser doesn't support native shadow dom
608
+ // and this host element was NOT created with SSR
609
+ // let's pick out the inner content for slot projection
610
+ // create a node to represent where the original
611
+ // content was first placed, which is useful later on
612
+ // DOM WRITE!!
613
+ elm['s-sc'] = scopeId;
614
+ elm.classList.add(scopeId + '-h');
615
+ }
616
+ endAttachStyles();
617
+ };
618
+ const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
619
+ const convertScopedToShadow = (css) => css.replace(/\/\*!@([^\/]+)\*\/[^\{]+\{/g, '$1{');
620
+ /**
621
+ * Production setAccessor() function based on Preact by
622
+ * Jason Miller (@developit)
623
+ * Licensed under the MIT License
624
+ * https://github.com/developit/preact/blob/master/LICENSE
625
+ *
626
+ * Modified for Stencil's compiler and vdom
627
+ */
628
+ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
629
+ if (oldValue !== newValue) {
630
+ let isProp = isMemberInElement(elm, memberName);
631
+ let ln = memberName.toLowerCase();
632
+ if (memberName === 'class') {
633
+ const classList = elm.classList;
634
+ const oldClasses = parseClassList(oldValue);
635
+ const newClasses = parseClassList(newValue);
636
+ classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
637
+ classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
638
+ }
639
+ else if (memberName === 'style') {
640
+ // update style attribute, css properties and values
641
+ {
642
+ for (const prop in oldValue) {
643
+ if (!newValue || newValue[prop] == null) {
644
+ if (prop.includes('-')) {
645
+ elm.style.removeProperty(prop);
646
+ }
647
+ else {
648
+ elm.style[prop] = '';
649
+ }
650
+ }
651
+ }
652
+ }
653
+ for (const prop in newValue) {
654
+ if (!oldValue || newValue[prop] !== oldValue[prop]) {
655
+ if (prop.includes('-')) {
656
+ elm.style.setProperty(prop, newValue[prop]);
657
+ }
658
+ else {
659
+ elm.style[prop] = newValue[prop];
660
+ }
661
+ }
662
+ }
663
+ }
664
+ else if (memberName === 'key')
665
+ ;
666
+ else if (memberName === 'ref') {
667
+ // minifier will clean this up
668
+ if (newValue) {
669
+ newValue(elm);
670
+ }
671
+ }
672
+ else if ((!isProp ) &&
673
+ memberName[0] === 'o' &&
674
+ memberName[1] === 'n') {
675
+ // Event Handlers
676
+ // so if the member name starts with "on" and the 3rd characters is
677
+ // a capital letter, and it's not already a member on the element,
678
+ // then we're assuming it's an event listener
679
+ if (memberName[2] === '-') {
680
+ // on- prefixed events
681
+ // allows to be explicit about the dom event to listen without any magic
682
+ // under the hood:
683
+ // <my-cmp on-click> // listens for "click"
684
+ // <my-cmp on-Click> // listens for "Click"
685
+ // <my-cmp on-ionChange> // listens for "ionChange"
686
+ // <my-cmp on-EVENTS> // listens for "EVENTS"
687
+ memberName = memberName.slice(3);
688
+ }
689
+ else if (isMemberInElement(win, ln)) {
690
+ // standard event
691
+ // the JSX attribute could have been "onMouseOver" and the
692
+ // member name "onmouseover" is on the window's prototype
693
+ // so let's add the listener "mouseover", which is all lowercased
694
+ memberName = ln.slice(2);
695
+ }
696
+ else {
697
+ // custom event
698
+ // the JSX attribute could have been "onMyCustomEvent"
699
+ // so let's trim off the "on" prefix and lowercase the first character
700
+ // and add the listener "myCustomEvent"
701
+ // except for the first character, we keep the event name case
702
+ memberName = ln[2] + memberName.slice(3);
703
+ }
704
+ if (oldValue) {
705
+ plt.rel(elm, memberName, oldValue, false);
706
+ }
707
+ if (newValue) {
708
+ plt.ael(elm, memberName, newValue, false);
709
+ }
710
+ }
711
+ else {
712
+ // Set property if it exists and it's not a SVG
713
+ const isComplex = isComplexType(newValue);
714
+ if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
715
+ try {
716
+ if (!elm.tagName.includes('-')) {
717
+ const n = newValue == null ? '' : newValue;
718
+ // Workaround for Safari, moving the <input> caret when re-assigning the same valued
719
+ if (memberName === 'list') {
720
+ isProp = false;
721
+ }
722
+ else if (oldValue == null || elm[memberName] != n) {
723
+ elm[memberName] = n;
724
+ }
725
+ }
726
+ else {
727
+ elm[memberName] = newValue;
728
+ }
729
+ }
730
+ catch (e) { }
731
+ }
732
+ /**
733
+ * Need to manually update attribute if:
734
+ * - memberName is not an attribute
735
+ * - if we are rendering the host element in order to reflect attribute
736
+ * - if it's a SVG, since properties might not work in <svg>
737
+ * - if the newValue is null/undefined or 'false'.
738
+ */
739
+ let xlink = false;
740
+ {
741
+ if (ln !== (ln = ln.replace(/^xlink\:?/, ''))) {
742
+ memberName = ln;
743
+ xlink = true;
744
+ }
745
+ }
746
+ if (newValue == null || newValue === false) {
747
+ if (newValue !== false || elm.getAttribute(memberName) === '') {
748
+ if (xlink) {
749
+ elm.removeAttributeNS(XLINK_NS, memberName);
750
+ }
751
+ else {
752
+ elm.removeAttribute(memberName);
753
+ }
754
+ }
755
+ }
756
+ else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
757
+ newValue = newValue === true ? '' : newValue;
758
+ if (xlink) {
759
+ elm.setAttributeNS(XLINK_NS, memberName, newValue);
760
+ }
761
+ else {
762
+ elm.setAttribute(memberName, newValue);
763
+ }
764
+ }
765
+ }
766
+ }
767
+ };
768
+ const parseClassListRegex = /\s/;
769
+ const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
770
+ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
771
+ // if the element passed in is a shadow root, which is a document fragment
772
+ // then we want to be adding attrs/props to the shadow root's "host" element
773
+ // if it's not a shadow root, then we add attrs/props to the same element
774
+ const elm = newVnode.$elm$.nodeType === 11 /* NODE_TYPE.DocumentFragment */ && newVnode.$elm$.host
775
+ ? newVnode.$elm$.host
776
+ : newVnode.$elm$;
777
+ const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
778
+ const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
779
+ {
780
+ // remove attributes no longer present on the vnode by setting them to undefined
781
+ for (memberName in oldVnodeAttrs) {
782
+ if (!(memberName in newVnodeAttrs)) {
783
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
784
+ }
785
+ }
786
+ }
787
+ // add new & update changed attributes
788
+ for (memberName in newVnodeAttrs) {
789
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
790
+ }
791
+ };
792
+ /**
793
+ * Create a DOM Node corresponding to one of the children of a given VNode.
794
+ *
795
+ * @param oldParentVNode the parent VNode from the previous render
796
+ * @param newParentVNode the parent VNode from the current render
797
+ * @param childIndex the index of the VNode, in the _new_ parent node's
798
+ * children, for which we will create a new DOM node
799
+ * @param parentElm the parent DOM node which our new node will be a child of
800
+ * @returns the newly created node
801
+ */
802
+ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
803
+ // tslint:disable-next-line: prefer-const
804
+ const newVNode = newParentVNode.$children$[childIndex];
805
+ let i = 0;
806
+ let elm;
807
+ let childNode;
808
+ let oldVNode;
809
+ if (!useNativeShadowDom) {
810
+ // remember for later we need to check to relocate nodes
811
+ checkSlotRelocate = true;
812
+ if (newVNode.$tag$ === 'slot') {
813
+ if (scopeId) {
814
+ // scoped css needs to add its scoped id to the parent element
815
+ parentElm.classList.add(scopeId + '-s');
816
+ }
817
+ newVNode.$flags$ |= newVNode.$children$
818
+ ? // slot element has fallback content
819
+ 2 /* VNODE_FLAGS.isSlotFallback */
820
+ : // slot element does not have fallback content
821
+ 1 /* VNODE_FLAGS.isSlotReference */;
822
+ }
823
+ }
824
+ if (newVNode.$text$ !== null) {
825
+ // create text node
826
+ elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
827
+ }
828
+ else if (newVNode.$flags$ & 1 /* VNODE_FLAGS.isSlotReference */) {
829
+ // create a slot reference node
830
+ elm = newVNode.$elm$ =
831
+ doc.createTextNode('');
832
+ }
833
+ else {
834
+ if (!isSvgMode) {
835
+ isSvgMode = newVNode.$tag$ === 'svg';
836
+ }
837
+ // create element
838
+ elm = newVNode.$elm$ = (doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, newVNode.$flags$ & 2 /* VNODE_FLAGS.isSlotFallback */
839
+ ? 'slot-fb'
840
+ : newVNode.$tag$)
841
+ );
842
+ if (isSvgMode && newVNode.$tag$ === 'foreignObject') {
843
+ isSvgMode = false;
844
+ }
845
+ // add css classes, attrs, props, listeners, etc.
846
+ {
847
+ updateElement(null, newVNode, isSvgMode);
848
+ }
849
+ if (isDef(scopeId) && elm['s-si'] !== scopeId) {
850
+ // if there is a scopeId and this is the initial render
851
+ // then let's add the scopeId as a css class
852
+ elm.classList.add((elm['s-si'] = scopeId));
853
+ }
854
+ if (newVNode.$children$) {
855
+ for (i = 0; i < newVNode.$children$.length; ++i) {
856
+ // create the node
857
+ childNode = createElm(oldParentVNode, newVNode, i, elm);
858
+ // return node could have been null
859
+ if (childNode) {
860
+ // append our new node
861
+ elm.appendChild(childNode);
862
+ }
863
+ }
864
+ }
865
+ {
866
+ if (newVNode.$tag$ === 'svg') {
867
+ // Only reset the SVG context when we're exiting <svg> element
868
+ isSvgMode = false;
869
+ }
870
+ else if (elm.tagName === 'foreignObject') {
871
+ // Reenter SVG context when we're exiting <foreignObject> element
872
+ isSvgMode = true;
873
+ }
874
+ }
875
+ }
876
+ {
877
+ elm['s-hn'] = hostTagName;
878
+ if (newVNode.$flags$ & (2 /* VNODE_FLAGS.isSlotFallback */ | 1 /* VNODE_FLAGS.isSlotReference */)) {
879
+ // remember the content reference comment
880
+ elm['s-sr'] = true;
881
+ // remember the content reference comment
882
+ elm['s-cr'] = contentRef;
883
+ // remember the slot name, or empty string for default slot
884
+ elm['s-sn'] = newVNode.$name$ || '';
885
+ // check if we've got an old vnode for this slot
886
+ oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
887
+ if (oldVNode && oldVNode.$tag$ === newVNode.$tag$ && oldParentVNode.$elm$) {
888
+ // we've got an old slot vnode and the wrapper is being replaced
889
+ // so let's move the old slot content back to it's original location
890
+ putBackInOriginalLocation(oldParentVNode.$elm$, false);
891
+ }
892
+ }
893
+ }
894
+ return elm;
895
+ };
896
+ const putBackInOriginalLocation = (parentElm, recursive) => {
897
+ plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
898
+ const oldSlotChildNodes = parentElm.childNodes;
899
+ for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
900
+ const childNode = oldSlotChildNodes[i];
901
+ if (childNode['s-hn'] !== hostTagName && childNode['s-ol']) {
902
+ // // this child node in the old element is from another component
903
+ // // remove this node from the old slot's parent
904
+ // childNode.remove();
905
+ // and relocate it back to it's original location
906
+ parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
907
+ // remove the old original location comment entirely
908
+ // later on the patch function will know what to do
909
+ // and move this to the correct spot in need be
910
+ childNode['s-ol'].remove();
911
+ childNode['s-ol'] = undefined;
912
+ checkSlotRelocate = true;
913
+ }
914
+ if (recursive) {
915
+ putBackInOriginalLocation(childNode, recursive);
916
+ }
917
+ }
918
+ plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
919
+ };
920
+ /**
921
+ * Create DOM nodes corresponding to a list of {@link d.Vnode} objects and
922
+ * add them to the DOM in the appropriate place.
923
+ *
924
+ * @param parentElm the DOM node which should be used as a parent for the new
925
+ * DOM nodes
926
+ * @param before a child of the `parentElm` which the new children should be
927
+ * inserted before (optional)
928
+ * @param parentVNode the parent virtual DOM node
929
+ * @param vnodes the new child virtual DOM nodes to produce DOM nodes for
930
+ * @param startIdx the index in the child virtual DOM nodes at which to start
931
+ * creating DOM nodes (inclusive)
932
+ * @param endIdx the index in the child virtual DOM nodes at which to stop
933
+ * creating DOM nodes (inclusive)
934
+ */
935
+ const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
936
+ let containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
937
+ let childNode;
938
+ if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
939
+ containerElm = containerElm.shadowRoot;
940
+ }
941
+ for (; startIdx <= endIdx; ++startIdx) {
942
+ if (vnodes[startIdx]) {
943
+ childNode = createElm(null, parentVNode, startIdx, parentElm);
944
+ if (childNode) {
945
+ vnodes[startIdx].$elm$ = childNode;
946
+ containerElm.insertBefore(childNode, referenceNode(before) );
947
+ }
948
+ }
949
+ }
950
+ };
951
+ /**
952
+ * Remove the DOM elements corresponding to a list of {@link d.VNode} objects.
953
+ * This can be used to, for instance, clean up after a list of children which
954
+ * should no longer be shown.
955
+ *
956
+ * This function also handles some of Stencil's slot relocation logic.
957
+ *
958
+ * @param vnodes a list of virtual DOM nodes to remove
959
+ * @param startIdx the index at which to start removing nodes (inclusive)
960
+ * @param endIdx the index at which to stop removing nodes (inclusive)
961
+ * @param vnode a VNode
962
+ * @param elm an element
963
+ */
964
+ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
965
+ for (; startIdx <= endIdx; ++startIdx) {
966
+ if ((vnode = vnodes[startIdx])) {
967
+ elm = vnode.$elm$;
968
+ callNodeRefs(vnode);
969
+ {
970
+ // we're removing this element
971
+ // so it's possible we need to show slot fallback content now
972
+ checkSlotFallbackVisibility = true;
973
+ if (elm['s-ol']) {
974
+ // remove the original location comment
975
+ elm['s-ol'].remove();
976
+ }
977
+ else {
978
+ // it's possible that child nodes of the node
979
+ // that's being removed are slot nodes
980
+ putBackInOriginalLocation(elm, true);
981
+ }
982
+ }
983
+ // remove the vnode's element from the dom
984
+ elm.remove();
985
+ }
986
+ }
987
+ };
988
+ /**
989
+ * Reconcile the children of a new VNode with the children of an old VNode by
990
+ * traversing the two collections of children, identifying nodes that are
991
+ * conserved or changed, calling out to `patch` to make any necessary
992
+ * updates to the DOM, and rearranging DOM nodes as needed.
993
+ *
994
+ * The algorithm for reconciling children works by analyzing two 'windows' onto
995
+ * the two arrays of children (`oldCh` and `newCh`). We keep track of the
996
+ * 'windows' by storing start and end indices and references to the
997
+ * corresponding array entries. Initially the two 'windows' are basically equal
998
+ * to the entire array, but we progressively narrow the windows until there are
999
+ * no children left to update by doing the following:
1000
+ *
1001
+ * 1. Skip any `null` entries at the beginning or end of the two arrays, so
1002
+ * that if we have an initial array like the following we'll end up dealing
1003
+ * only with a window bounded by the highlighted elements:
1004
+ *
1005
+ * [null, null, VNode1 , ... , VNode2, null, null]
1006
+ * ^^^^^^ ^^^^^^
1007
+ *
1008
+ * 2. Check to see if the elements at the head and tail positions are equal
1009
+ * across the windows. This will basically detect elements which haven't
1010
+ * been added, removed, or changed position, i.e. if you had the following
1011
+ * VNode elements (represented as HTML):
1012
+ *
1013
+ * oldVNode: `<div><p><span>HEY</span></p></div>`
1014
+ * newVNode: `<div><p><span>THERE</span></p></div>`
1015
+ *
1016
+ * Then when comparing the children of the `<div>` tag we check the equality
1017
+ * of the VNodes corresponding to the `<p>` tags and, since they are the
1018
+ * same tag in the same position, we'd be able to avoid completely
1019
+ * re-rendering the subtree under them with a new DOM element and would just
1020
+ * call out to `patch` to handle reconciling their children and so on.
1021
+ *
1022
+ * 3. Check, for both windows, to see if the element at the beginning of the
1023
+ * window corresponds to the element at the end of the other window. This is
1024
+ * a heuristic which will let us identify _some_ situations in which
1025
+ * elements have changed position, for instance it _should_ detect that the
1026
+ * children nodes themselves have not changed but merely moved in the
1027
+ * following example:
1028
+ *
1029
+ * oldVNode: `<div><element-one /><element-two /></div>`
1030
+ * newVNode: `<div><element-two /><element-one /></div>`
1031
+ *
1032
+ * If we find cases like this then we also need to move the concrete DOM
1033
+ * elements corresponding to the moved children to write the re-order to the
1034
+ * DOM.
1035
+ *
1036
+ * 4. Finally, if VNodes have the `key` attribute set on them we check for any
1037
+ * nodes in the old children which have the same key as the first element in
1038
+ * our window on the new children. If we find such a node we handle calling
1039
+ * out to `patch`, moving relevant DOM nodes, and so on, in accordance with
1040
+ * what we find.
1041
+ *
1042
+ * Finally, once we've narrowed our 'windows' to the point that either of them
1043
+ * collapse (i.e. they have length 0) we then handle any remaining VNode
1044
+ * insertion or deletion that needs to happen to get a DOM state that correctly
1045
+ * reflects the new child VNodes. If, for instance, after our window on the old
1046
+ * children has collapsed we still have more nodes on the new children that
1047
+ * we haven't dealt with yet then we need to add them, or if the new children
1048
+ * collapse but we still have unhandled _old_ children then we need to make
1049
+ * sure the corresponding DOM nodes are removed.
1050
+ *
1051
+ * @param parentElm the node into which the parent VNode is rendered
1052
+ * @param oldCh the old children of the parent node
1053
+ * @param newVNode the new VNode which will replace the parent
1054
+ * @param newCh the new children of the parent node
1055
+ */
1056
+ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
1057
+ let oldStartIdx = 0;
1058
+ let newStartIdx = 0;
1059
+ let idxInOld = 0;
1060
+ let i = 0;
1061
+ let oldEndIdx = oldCh.length - 1;
1062
+ let oldStartVnode = oldCh[0];
1063
+ let oldEndVnode = oldCh[oldEndIdx];
1064
+ let newEndIdx = newCh.length - 1;
1065
+ let newStartVnode = newCh[0];
1066
+ let newEndVnode = newCh[newEndIdx];
1067
+ let node;
1068
+ let elmToMove;
1069
+ while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
1070
+ if (oldStartVnode == null) {
1071
+ // VNode might have been moved left
1072
+ oldStartVnode = oldCh[++oldStartIdx];
1073
+ }
1074
+ else if (oldEndVnode == null) {
1075
+ oldEndVnode = oldCh[--oldEndIdx];
1076
+ }
1077
+ else if (newStartVnode == null) {
1078
+ newStartVnode = newCh[++newStartIdx];
1079
+ }
1080
+ else if (newEndVnode == null) {
1081
+ newEndVnode = newCh[--newEndIdx];
1082
+ }
1083
+ else if (isSameVnode(oldStartVnode, newStartVnode)) {
1084
+ // if the start nodes are the same then we should patch the new VNode
1085
+ // onto the old one, and increment our `newStartIdx` and `oldStartIdx`
1086
+ // indices to reflect that. We don't need to move any DOM Nodes around
1087
+ // since things are matched up in order.
1088
+ patch(oldStartVnode, newStartVnode);
1089
+ oldStartVnode = oldCh[++oldStartIdx];
1090
+ newStartVnode = newCh[++newStartIdx];
1091
+ }
1092
+ else if (isSameVnode(oldEndVnode, newEndVnode)) {
1093
+ // likewise, if the end nodes are the same we patch new onto old and
1094
+ // decrement our end indices, and also likewise in this case we don't
1095
+ // need to move any DOM Nodes.
1096
+ patch(oldEndVnode, newEndVnode);
1097
+ oldEndVnode = oldCh[--oldEndIdx];
1098
+ newEndVnode = newCh[--newEndIdx];
1099
+ }
1100
+ else if (isSameVnode(oldStartVnode, newEndVnode)) {
1101
+ // case: "Vnode moved right"
1102
+ //
1103
+ // We've found that the last node in our window on the new children is
1104
+ // the same VNode as the _first_ node in our window on the old children
1105
+ // we're dealing with now. Visually, this is the layout of these two
1106
+ // nodes:
1107
+ //
1108
+ // newCh: [..., newStartVnode , ... , newEndVnode , ...]
1109
+ // ^^^^^^^^^^^
1110
+ // oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
1111
+ // ^^^^^^^^^^^^^
1112
+ //
1113
+ // In this situation we need to patch `newEndVnode` onto `oldStartVnode`
1114
+ // and move the DOM element for `oldStartVnode`.
1115
+ if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
1116
+ putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
1117
+ }
1118
+ patch(oldStartVnode, newEndVnode);
1119
+ // We need to move the element for `oldStartVnode` into a position which
1120
+ // will be appropriate for `newEndVnode`. For this we can use
1121
+ // `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
1122
+ // sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
1123
+ // `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
1124
+ //
1125
+ // <old-start-node />
1126
+ // <some-intervening-node />
1127
+ // <old-end-node />
1128
+ // <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
1129
+ // <next-sibling />
1130
+ //
1131
+ // If instead `oldEndVnode.$elm$` has no sibling then we just want to put
1132
+ // the node for `oldStartVnode` at the end of the children of
1133
+ // `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
1134
+ // aren't any siblings, and passing `null` to `Node.insertBefore` will
1135
+ // append it to the children of the parent element.
1136
+ parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
1137
+ oldStartVnode = oldCh[++oldStartIdx];
1138
+ newEndVnode = newCh[--newEndIdx];
1139
+ }
1140
+ else if (isSameVnode(oldEndVnode, newStartVnode)) {
1141
+ // case: "Vnode moved left"
1142
+ //
1143
+ // We've found that the first node in our window on the new children is
1144
+ // the same VNode as the _last_ node in our window on the old children.
1145
+ // Visually, this is the layout of these two nodes:
1146
+ //
1147
+ // newCh: [..., newStartVnode , ... , newEndVnode , ...]
1148
+ // ^^^^^^^^^^^^^
1149
+ // oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
1150
+ // ^^^^^^^^^^^
1151
+ //
1152
+ // In this situation we need to patch `newStartVnode` onto `oldEndVnode`
1153
+ // (which will handle updating any changed attributes, reconciling their
1154
+ // children etc) but we also need to move the DOM node to which
1155
+ // `oldEndVnode` corresponds.
1156
+ if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
1157
+ putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
1158
+ }
1159
+ patch(oldEndVnode, newStartVnode);
1160
+ // We've already checked above if `oldStartVnode` and `newStartVnode` are
1161
+ // the same node, so since we're here we know that they are not. Thus we
1162
+ // can move the element for `oldEndVnode` _before_ the element for
1163
+ // `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
1164
+ // future.
1165
+ parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
1166
+ oldEndVnode = oldCh[--oldEndIdx];
1167
+ newStartVnode = newCh[++newStartIdx];
1168
+ }
1169
+ else {
1170
+ // Here we do some checks to match up old and new nodes based on the
1171
+ // `$key$` attribute, which is set by putting a `key="my-key"` attribute
1172
+ // in the JSX for a DOM element in the implementation of a Stencil
1173
+ // component.
1174
+ //
1175
+ // First we check to see if there are any nodes in the array of old
1176
+ // children which have the same key as the first node in the new
1177
+ // children.
1178
+ idxInOld = -1;
1179
+ {
1180
+ for (i = oldStartIdx; i <= oldEndIdx; ++i) {
1181
+ if (oldCh[i] && oldCh[i].$key$ !== null && oldCh[i].$key$ === newStartVnode.$key$) {
1182
+ idxInOld = i;
1183
+ break;
1184
+ }
1185
+ }
1186
+ }
1187
+ if (idxInOld >= 0) {
1188
+ // We found a node in the old children which matches up with the first
1189
+ // node in the new children! So let's deal with that
1190
+ elmToMove = oldCh[idxInOld];
1191
+ if (elmToMove.$tag$ !== newStartVnode.$tag$) {
1192
+ // the tag doesn't match so we'll need a new DOM element
1193
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld, parentElm);
1194
+ }
1195
+ else {
1196
+ patch(elmToMove, newStartVnode);
1197
+ // invalidate the matching old node so that we won't try to update it
1198
+ // again later on
1199
+ oldCh[idxInOld] = undefined;
1200
+ node = elmToMove.$elm$;
1201
+ }
1202
+ newStartVnode = newCh[++newStartIdx];
1203
+ }
1204
+ else {
1205
+ // We either didn't find an element in the old children that matches
1206
+ // the key of the first new child OR the build is not using `key`
1207
+ // attributes at all. In either case we need to create a new element
1208
+ // for the new node.
1209
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx, parentElm);
1210
+ newStartVnode = newCh[++newStartIdx];
1211
+ }
1212
+ if (node) {
1213
+ // if we created a new node then handle inserting it to the DOM
1214
+ {
1215
+ parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
1216
+ }
1217
+ }
1218
+ }
1219
+ }
1220
+ if (oldStartIdx > oldEndIdx) {
1221
+ // we have some more new nodes to add which don't match up with old nodes
1222
+ addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
1223
+ }
1224
+ else if (newStartIdx > newEndIdx) {
1225
+ // there are nodes in the `oldCh` array which no longer correspond to nodes
1226
+ // in the new array, so lets remove them (which entails cleaning up the
1227
+ // relevant DOM nodes)
1228
+ removeVnodes(oldCh, oldStartIdx, oldEndIdx);
1229
+ }
1230
+ };
1231
+ /**
1232
+ * Compare two VNodes to determine if they are the same
1233
+ *
1234
+ * **NB**: This function is an equality _heuristic_ based on the available
1235
+ * information set on the two VNodes and can be misleading under certain
1236
+ * circumstances. In particular, if the two nodes do not have `key` attrs
1237
+ * (available under `$key$` on VNodes) then the function falls back on merely
1238
+ * checking that they have the same tag.
1239
+ *
1240
+ * So, in other words, if `key` attrs are not set on VNodes which may be
1241
+ * changing order within a `children` array or something along those lines then
1242
+ * we could obtain a false negative and then have to do needless re-rendering
1243
+ * (i.e. we'd say two VNodes aren't equal when in fact they should be).
1244
+ *
1245
+ * @param leftVNode the first VNode to check
1246
+ * @param rightVNode the second VNode to check
1247
+ * @returns whether they're equal or not
1248
+ */
1249
+ const isSameVnode = (leftVNode, rightVNode) => {
1250
+ // compare if two vnode to see if they're "technically" the same
1251
+ // need to have the same element tag, and same key to be the same
1252
+ if (leftVNode.$tag$ === rightVNode.$tag$) {
1253
+ if (leftVNode.$tag$ === 'slot') {
1254
+ return leftVNode.$name$ === rightVNode.$name$;
1255
+ }
1256
+ // this will be set if components in the build have `key` attrs set on them
1257
+ {
1258
+ return leftVNode.$key$ === rightVNode.$key$;
1259
+ }
1260
+ }
1261
+ return false;
1262
+ };
1263
+ const referenceNode = (node) => {
1264
+ // this node was relocated to a new location in the dom
1265
+ // because of some other component's slot
1266
+ // but we still have an html comment in place of where
1267
+ // it's original location was according to it's original vdom
1268
+ return (node && node['s-ol']) || node;
1269
+ };
1270
+ const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
1271
+ /**
1272
+ * Handle reconciling an outdated VNode with a new one which corresponds to
1273
+ * it. This function handles flushing updates to the DOM and reconciling the
1274
+ * children of the two nodes (if any).
1275
+ *
1276
+ * @param oldVNode an old VNode whose DOM element and children we want to update
1277
+ * @param newVNode a new VNode representing an updated version of the old one
1278
+ */
1279
+ const patch = (oldVNode, newVNode) => {
1280
+ const elm = (newVNode.$elm$ = oldVNode.$elm$);
1281
+ const oldChildren = oldVNode.$children$;
1282
+ const newChildren = newVNode.$children$;
1283
+ const tag = newVNode.$tag$;
1284
+ const text = newVNode.$text$;
1285
+ let defaultHolder;
1286
+ if (text === null) {
1287
+ {
1288
+ // test if we're rendering an svg element, or still rendering nodes inside of one
1289
+ // only add this to the when the compiler sees we're using an svg somewhere
1290
+ isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
1291
+ }
1292
+ {
1293
+ if (tag === 'slot')
1294
+ ;
1295
+ else {
1296
+ // either this is the first render of an element OR it's an update
1297
+ // AND we already know it's possible it could have changed
1298
+ // this updates the element's css classes, attrs, props, listeners, etc.
1299
+ updateElement(oldVNode, newVNode, isSvgMode);
1300
+ }
1301
+ }
1302
+ if (oldChildren !== null && newChildren !== null) {
1303
+ // looks like there's child vnodes for both the old and new vnodes
1304
+ // so we need to call `updateChildren` to reconcile them
1305
+ updateChildren(elm, oldChildren, newVNode, newChildren);
1306
+ }
1307
+ else if (newChildren !== null) {
1308
+ // no old child vnodes, but there are new child vnodes to add
1309
+ if (oldVNode.$text$ !== null) {
1310
+ // the old vnode was text, so be sure to clear it out
1311
+ elm.textContent = '';
1312
+ }
1313
+ // add the new vnode children
1314
+ addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
1315
+ }
1316
+ else if (oldChildren !== null) {
1317
+ // no new child vnodes, but there are old child vnodes to remove
1318
+ removeVnodes(oldChildren, 0, oldChildren.length - 1);
1319
+ }
1320
+ if (isSvgMode && tag === 'svg') {
1321
+ isSvgMode = false;
1322
+ }
1323
+ }
1324
+ else if ((defaultHolder = elm['s-cr'])) {
1325
+ // this element has slotted content
1326
+ defaultHolder.parentNode.textContent = text;
1327
+ }
1328
+ else if (oldVNode.$text$ !== text) {
1329
+ // update the text content for the text only vnode
1330
+ // and also only if the text is different than before
1331
+ elm.data = text;
1332
+ }
1333
+ };
1334
+ const updateFallbackSlotVisibility = (elm) => {
1335
+ // tslint:disable-next-line: prefer-const
1336
+ const childNodes = elm.childNodes;
1337
+ let childNode;
1338
+ let i;
1339
+ let ilen;
1340
+ let j;
1341
+ let slotNameAttr;
1342
+ let nodeType;
1343
+ for (i = 0, ilen = childNodes.length; i < ilen; i++) {
1344
+ childNode = childNodes[i];
1345
+ if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1346
+ if (childNode['s-sr']) {
1347
+ // this is a slot fallback node
1348
+ // get the slot name for this slot reference node
1349
+ slotNameAttr = childNode['s-sn'];
1350
+ // by default always show a fallback slot node
1351
+ // then hide it if there are other slots in the light dom
1352
+ childNode.hidden = false;
1353
+ for (j = 0; j < ilen; j++) {
1354
+ nodeType = childNodes[j].nodeType;
1355
+ if (childNodes[j]['s-hn'] !== childNode['s-hn'] || slotNameAttr !== '') {
1356
+ // this sibling node is from a different component OR is a named fallback slot node
1357
+ if (nodeType === 1 /* NODE_TYPE.ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
1358
+ childNode.hidden = true;
1359
+ break;
1360
+ }
1361
+ }
1362
+ else {
1363
+ // this is a default fallback slot node
1364
+ // any element or text node (with content)
1365
+ // should hide the default fallback slot node
1366
+ if (nodeType === 1 /* NODE_TYPE.ElementNode */ ||
1367
+ (nodeType === 3 /* NODE_TYPE.TextNode */ && childNodes[j].textContent.trim() !== '')) {
1368
+ childNode.hidden = true;
1369
+ break;
1370
+ }
1371
+ }
1372
+ }
1373
+ }
1374
+ // keep drilling down
1375
+ updateFallbackSlotVisibility(childNode);
1376
+ }
1377
+ }
1378
+ };
1379
+ const relocateNodes = [];
1380
+ const relocateSlotContent = (elm) => {
1381
+ // tslint:disable-next-line: prefer-const
1382
+ let childNode;
1383
+ let node;
1384
+ let hostContentNodes;
1385
+ let slotNameAttr;
1386
+ let relocateNodeData;
1387
+ let j;
1388
+ let i = 0;
1389
+ const childNodes = elm.childNodes;
1390
+ const ilen = childNodes.length;
1391
+ for (; i < ilen; i++) {
1392
+ childNode = childNodes[i];
1393
+ if (childNode['s-sr'] && (node = childNode['s-cr']) && node.parentNode) {
1394
+ // first got the content reference comment node
1395
+ // then we got it's parent, which is where all the host content is in now
1396
+ hostContentNodes = node.parentNode.childNodes;
1397
+ slotNameAttr = childNode['s-sn'];
1398
+ for (j = hostContentNodes.length - 1; j >= 0; j--) {
1399
+ node = hostContentNodes[j];
1400
+ if (!node['s-cn'] && !node['s-nr'] && node['s-hn'] !== childNode['s-hn']) {
1401
+ // let's do some relocating to its new home
1402
+ // but never relocate a content reference node
1403
+ // that is suppose to always represent the original content location
1404
+ if (isNodeLocatedInSlot(node, slotNameAttr)) {
1405
+ // it's possible we've already decided to relocate this node
1406
+ relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
1407
+ // made some changes to slots
1408
+ // let's make sure we also double check
1409
+ // fallbacks are correctly hidden or shown
1410
+ checkSlotFallbackVisibility = true;
1411
+ node['s-sn'] = node['s-sn'] || slotNameAttr;
1412
+ if (relocateNodeData) {
1413
+ // previously we never found a slot home for this node
1414
+ // but turns out we did, so let's remember it now
1415
+ relocateNodeData.$slotRefNode$ = childNode;
1416
+ }
1417
+ else {
1418
+ // add to our list of nodes to relocate
1419
+ relocateNodes.push({
1420
+ $slotRefNode$: childNode,
1421
+ $nodeToRelocate$: node,
1422
+ });
1423
+ }
1424
+ if (node['s-sr']) {
1425
+ relocateNodes.map((relocateNode) => {
1426
+ if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node['s-sn'])) {
1427
+ relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
1428
+ if (relocateNodeData && !relocateNode.$slotRefNode$) {
1429
+ relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
1430
+ }
1431
+ }
1432
+ });
1433
+ }
1434
+ }
1435
+ else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
1436
+ // so far this element does not have a slot home, not setting slotRefNode on purpose
1437
+ // if we never find a home for this element then we'll need to hide it
1438
+ relocateNodes.push({
1439
+ $nodeToRelocate$: node,
1440
+ });
1441
+ }
1442
+ }
1443
+ }
1444
+ }
1445
+ if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1446
+ relocateSlotContent(childNode);
1447
+ }
1448
+ }
1449
+ };
1450
+ const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
1451
+ if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1452
+ if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
1453
+ return true;
1454
+ }
1455
+ if (nodeToRelocate.getAttribute('slot') === slotNameAttr) {
1456
+ return true;
1457
+ }
1458
+ return false;
1459
+ }
1460
+ if (nodeToRelocate['s-sn'] === slotNameAttr) {
1461
+ return true;
1462
+ }
1463
+ return slotNameAttr === '';
1464
+ };
1465
+ const callNodeRefs = (vNode) => {
1466
+ {
1467
+ vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
1468
+ vNode.$children$ && vNode.$children$.map(callNodeRefs);
1469
+ }
1470
+ };
1471
+ /**
1472
+ * The main entry point for Stencil's virtual DOM-based rendering engine
1473
+ *
1474
+ * Given a {@link d.HostRef} container and some virtual DOM nodes, this
1475
+ * function will handle creating a virtual DOM tree with a single root, patching
1476
+ * the current virtual DOM tree onto an old one (if any), dealing with slot
1477
+ * relocation, and reflecting attributes.
1478
+ *
1479
+ * @param hostRef data needed to root and render the virtual DOM tree, such as
1480
+ * the DOM node into which it should be rendered.
1481
+ * @param renderFnResults the virtual DOM nodes to be rendered
1482
+ */
1483
+ const renderVdom = (hostRef, renderFnResults) => {
1484
+ const hostElm = hostRef.$hostElement$;
1485
+ const cmpMeta = hostRef.$cmpMeta$;
1486
+ const oldVNode = hostRef.$vnode$ || newVNode(null, null);
1487
+ const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
1488
+ hostTagName = hostElm.tagName;
1489
+ if (cmpMeta.$attrsToReflect$) {
1490
+ rootVnode.$attrs$ = rootVnode.$attrs$ || {};
1491
+ cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
1492
+ }
1493
+ rootVnode.$tag$ = null;
1494
+ rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
1495
+ hostRef.$vnode$ = rootVnode;
1496
+ rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
1497
+ {
1498
+ scopeId = hostElm['s-sc'];
1499
+ }
1500
+ {
1501
+ contentRef = hostElm['s-cr'];
1502
+ useNativeShadowDom = (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) !== 0;
1503
+ // always reset
1504
+ checkSlotFallbackVisibility = false;
1505
+ }
1506
+ // synchronous patch
1507
+ patch(oldVNode, rootVnode);
1508
+ {
1509
+ // while we're moving nodes around existing nodes, temporarily disable
1510
+ // the disconnectCallback from working
1511
+ plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
1512
+ if (checkSlotRelocate) {
1513
+ relocateSlotContent(rootVnode.$elm$);
1514
+ let relocateData;
1515
+ let nodeToRelocate;
1516
+ let orgLocationNode;
1517
+ let parentNodeRef;
1518
+ let insertBeforeNode;
1519
+ let refNode;
1520
+ let i = 0;
1521
+ for (; i < relocateNodes.length; i++) {
1522
+ relocateData = relocateNodes[i];
1523
+ nodeToRelocate = relocateData.$nodeToRelocate$;
1524
+ if (!nodeToRelocate['s-ol']) {
1525
+ // add a reference node marking this node's original location
1526
+ // keep a reference to this node for later lookups
1527
+ orgLocationNode =
1528
+ doc.createTextNode('');
1529
+ orgLocationNode['s-nr'] = nodeToRelocate;
1530
+ nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
1531
+ }
1532
+ }
1533
+ for (i = 0; i < relocateNodes.length; i++) {
1534
+ relocateData = relocateNodes[i];
1535
+ nodeToRelocate = relocateData.$nodeToRelocate$;
1536
+ if (relocateData.$slotRefNode$) {
1537
+ // by default we're just going to insert it directly
1538
+ // after the slot reference node
1539
+ parentNodeRef = relocateData.$slotRefNode$.parentNode;
1540
+ insertBeforeNode = relocateData.$slotRefNode$.nextSibling;
1541
+ orgLocationNode = nodeToRelocate['s-ol'];
1542
+ while ((orgLocationNode = orgLocationNode.previousSibling)) {
1543
+ refNode = orgLocationNode['s-nr'];
1544
+ if (refNode && refNode['s-sn'] === nodeToRelocate['s-sn'] && parentNodeRef === refNode.parentNode) {
1545
+ refNode = refNode.nextSibling;
1546
+ if (!refNode || !refNode['s-nr']) {
1547
+ insertBeforeNode = refNode;
1548
+ break;
1549
+ }
1550
+ }
1551
+ }
1552
+ if ((!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode) ||
1553
+ nodeToRelocate.nextSibling !== insertBeforeNode) {
1554
+ // we've checked that it's worth while to relocate
1555
+ // since that the node to relocate
1556
+ // has a different next sibling or parent relocated
1557
+ if (nodeToRelocate !== insertBeforeNode) {
1558
+ if (!nodeToRelocate['s-hn'] && nodeToRelocate['s-ol']) {
1559
+ // probably a component in the index.html that doesn't have it's hostname set
1560
+ nodeToRelocate['s-hn'] = nodeToRelocate['s-ol'].parentNode.nodeName;
1561
+ }
1562
+ // add it back to the dom but in its new home
1563
+ parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode);
1564
+ }
1565
+ }
1566
+ }
1567
+ else {
1568
+ // this node doesn't have a slot home to go to, so let's hide it
1569
+ if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1570
+ nodeToRelocate.hidden = true;
1571
+ }
1572
+ }
1573
+ }
1574
+ }
1575
+ if (checkSlotFallbackVisibility) {
1576
+ updateFallbackSlotVisibility(rootVnode.$elm$);
1577
+ }
1578
+ // done moving nodes around
1579
+ // allow the disconnect callback to work again
1580
+ plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
1581
+ // always reset
1582
+ relocateNodes.length = 0;
1583
+ }
1584
+ };
1585
+ const attachToAncestor = (hostRef, ancestorComponent) => {
1586
+ if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
1587
+ ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
1588
+ }
1589
+ };
1590
+ const scheduleUpdate = (hostRef, isInitialLoad) => {
1591
+ {
1592
+ hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
1593
+ }
1594
+ if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
1595
+ hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
1596
+ return;
1597
+ }
1598
+ attachToAncestor(hostRef, hostRef.$ancestorComponent$);
1599
+ // there is no ancestor component or the ancestor component
1600
+ // has already fired off its lifecycle update then
1601
+ // fire off the initial update
1602
+ const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
1603
+ return writeTask(dispatch) ;
1604
+ };
1605
+ const dispatchHooks = (hostRef, isInitialLoad) => {
1606
+ const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
1607
+ const instance = hostRef.$lazyInstance$ ;
1608
+ let promise;
1609
+ if (isInitialLoad) {
1610
+ {
1611
+ hostRef.$flags$ |= 256 /* HOST_FLAGS.isListenReady */;
1612
+ if (hostRef.$queuedListeners$) {
1613
+ hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
1614
+ hostRef.$queuedListeners$ = null;
1615
+ }
1616
+ }
1617
+ {
1618
+ promise = safeCall(instance, 'componentWillLoad');
1619
+ }
1620
+ }
1621
+ else {
1622
+ {
1623
+ promise = safeCall(instance, 'componentWillUpdate');
1624
+ }
1625
+ }
1626
+ {
1627
+ promise = then(promise, () => safeCall(instance, 'componentWillRender'));
1628
+ }
1629
+ endSchedule();
1630
+ return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
1631
+ };
1632
+ const updateComponent = async (hostRef, instance, isInitialLoad) => {
1633
+ // updateComponent
1634
+ const elm = hostRef.$hostElement$;
1635
+ const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
1636
+ const rc = elm['s-rc'];
1637
+ if (isInitialLoad) {
1638
+ // DOM WRITE!
1639
+ attachStyles(hostRef);
1640
+ }
1641
+ const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
1642
+ {
1643
+ callRender(hostRef, instance);
1644
+ }
1645
+ if (rc) {
1646
+ // ok, so turns out there are some child host elements
1647
+ // waiting on this parent element to load
1648
+ // let's fire off all update callbacks waiting
1649
+ rc.map((cb) => cb());
1650
+ elm['s-rc'] = undefined;
1651
+ }
1652
+ endRender();
1653
+ endUpdate();
1654
+ {
1655
+ const childrenPromises = elm['s-p'];
1656
+ const postUpdate = () => postUpdateComponent(hostRef);
1657
+ if (childrenPromises.length === 0) {
1658
+ postUpdate();
1659
+ }
1660
+ else {
1661
+ Promise.all(childrenPromises).then(postUpdate);
1662
+ hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
1663
+ childrenPromises.length = 0;
1664
+ }
1665
+ }
1666
+ };
1667
+ const callRender = (hostRef, instance, elm) => {
1668
+ try {
1669
+ instance = instance.render() ;
1670
+ {
1671
+ hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
1672
+ }
1673
+ {
1674
+ hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
1675
+ }
1676
+ {
1677
+ {
1678
+ // looks like we've got child nodes to render into this host element
1679
+ // or we need to update the css class/attrs on the host element
1680
+ // DOM WRITE!
1681
+ {
1682
+ renderVdom(hostRef, instance);
1683
+ }
1684
+ }
1685
+ }
1686
+ }
1687
+ catch (e) {
1688
+ consoleError(e, hostRef.$hostElement$);
1689
+ }
1690
+ return null;
1691
+ };
1692
+ const postUpdateComponent = (hostRef) => {
1693
+ const tagName = hostRef.$cmpMeta$.$tagName$;
1694
+ const elm = hostRef.$hostElement$;
1695
+ const endPostUpdate = createTime('postUpdate', tagName);
1696
+ const instance = hostRef.$lazyInstance$ ;
1697
+ const ancestorComponent = hostRef.$ancestorComponent$;
1698
+ {
1699
+ safeCall(instance, 'componentDidRender');
1700
+ }
1701
+ if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
1702
+ hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
1703
+ {
1704
+ // DOM WRITE!
1705
+ addHydratedFlag(elm);
1706
+ }
1707
+ {
1708
+ safeCall(instance, 'componentDidLoad');
1709
+ }
1710
+ endPostUpdate();
1711
+ {
1712
+ hostRef.$onReadyResolve$(elm);
1713
+ if (!ancestorComponent) {
1714
+ appDidLoad();
1715
+ }
1716
+ }
1717
+ }
1718
+ else {
1719
+ {
1720
+ safeCall(instance, 'componentDidUpdate');
1721
+ }
1722
+ endPostUpdate();
1723
+ }
1724
+ {
1725
+ hostRef.$onInstanceResolve$(elm);
1726
+ }
1727
+ // load events fire from bottom to top
1728
+ // the deepest elements load first then bubbles up
1729
+ {
1730
+ if (hostRef.$onRenderResolve$) {
1731
+ hostRef.$onRenderResolve$();
1732
+ hostRef.$onRenderResolve$ = undefined;
1733
+ }
1734
+ if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
1735
+ nextTick(() => scheduleUpdate(hostRef, false));
1736
+ }
1737
+ hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
1738
+ }
1739
+ // ( •_•)
1740
+ // ( •_•)>⌐■-■
1741
+ // (⌐■_■)
1742
+ };
1743
+ const appDidLoad = (who) => {
1744
+ // on appload
1745
+ // we have finish the first big initial render
1746
+ {
1747
+ addHydratedFlag(doc.documentElement);
1748
+ }
1749
+ nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
1750
+ };
1751
+ const safeCall = (instance, method, arg) => {
1752
+ if (instance && instance[method]) {
1753
+ try {
1754
+ return instance[method](arg);
1755
+ }
1756
+ catch (e) {
1757
+ consoleError(e);
1758
+ }
1759
+ }
1760
+ return undefined;
1761
+ };
1762
+ const then = (promise, thenFn) => {
1763
+ return promise && promise.then ? promise.then(thenFn) : thenFn();
1764
+ };
1765
+ const addHydratedFlag = (elm) => elm.classList.add('hydrated')
1766
+ ;
1767
+ const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
1768
+ const setValue = (ref, propName, newVal, cmpMeta) => {
1769
+ // check our new property value against our internal value
1770
+ const hostRef = getHostRef(ref);
1771
+ const elm = hostRef.$hostElement$ ;
1772
+ const oldVal = hostRef.$instanceValues$.get(propName);
1773
+ const flags = hostRef.$flags$;
1774
+ const instance = hostRef.$lazyInstance$ ;
1775
+ newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
1776
+ // explicitly check for NaN on both sides, as `NaN === NaN` is always false
1777
+ const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
1778
+ const didValueChange = newVal !== oldVal && !areBothNaN;
1779
+ if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
1780
+ // gadzooks! the property's value has changed!!
1781
+ // set our new value!
1782
+ hostRef.$instanceValues$.set(propName, newVal);
1783
+ if (instance) {
1784
+ // get an array of method names of watch functions to call
1785
+ if (cmpMeta.$watchers$ && flags & 128 /* HOST_FLAGS.isWatchReady */) {
1786
+ const watchMethods = cmpMeta.$watchers$[propName];
1787
+ if (watchMethods) {
1788
+ // this instance is watching for when this property changed
1789
+ watchMethods.map((watchMethodName) => {
1790
+ try {
1791
+ // fire off each of the watch methods that are watching this property
1792
+ instance[watchMethodName](newVal, oldVal, propName);
1793
+ }
1794
+ catch (e) {
1795
+ consoleError(e, elm);
1796
+ }
1797
+ });
1798
+ }
1799
+ }
1800
+ if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
1801
+ // looks like this value actually changed, so we've got work to do!
1802
+ // but only if we've already rendered, otherwise just chill out
1803
+ // queue that we need to do an update, but don't worry about queuing
1804
+ // up millions cuz this function ensures it only runs once
1805
+ scheduleUpdate(hostRef, false);
1806
+ }
1807
+ }
1808
+ }
1809
+ };
1810
+ /**
1811
+ * Attach a series of runtime constructs to a compiled Stencil component
1812
+ * constructor, including getters and setters for the `@Prop` and `@State`
1813
+ * decorators, callbacks for when attributes change, and so on.
1814
+ *
1815
+ * @param Cstr the constructor for a component that we need to process
1816
+ * @param cmpMeta metadata collected previously about the component
1817
+ * @param flags a number used to store a series of bit flags
1818
+ * @returns a reference to the same constructor passed in (but now mutated)
1819
+ */
1820
+ const proxyComponent = (Cstr, cmpMeta, flags) => {
1821
+ if (cmpMeta.$members$) {
1822
+ if (Cstr.watchers) {
1823
+ cmpMeta.$watchers$ = Cstr.watchers;
1824
+ }
1825
+ // It's better to have a const than two Object.entries()
1826
+ const members = Object.entries(cmpMeta.$members$);
1827
+ const prototype = Cstr.prototype;
1828
+ members.map(([memberName, [memberFlags]]) => {
1829
+ if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
1830
+ ((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
1831
+ // proxyComponent - prop
1832
+ Object.defineProperty(prototype, memberName, {
1833
+ get() {
1834
+ // proxyComponent, get value
1835
+ return getValue(this, memberName);
1836
+ },
1837
+ set(newValue) {
1838
+ // proxyComponent, set value
1839
+ setValue(this, memberName, newValue, cmpMeta);
1840
+ },
1841
+ configurable: true,
1842
+ enumerable: true,
1843
+ });
1844
+ }
1845
+ else if (flags & 1 /* PROXY_FLAGS.isElementConstructor */ &&
1846
+ memberFlags & 64 /* MEMBER_FLAGS.Method */) {
1847
+ // proxyComponent - method
1848
+ Object.defineProperty(prototype, memberName, {
1849
+ value(...args) {
1850
+ const ref = getHostRef(this);
1851
+ return ref.$onInstancePromise$.then(() => ref.$lazyInstance$[memberName](...args));
1852
+ },
1853
+ });
1854
+ }
1855
+ });
1856
+ if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
1857
+ const attrNameToPropName = new Map();
1858
+ prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
1859
+ plt.jmp(() => {
1860
+ const propName = attrNameToPropName.get(attrName);
1861
+ // In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
1862
+ // in the case where an attribute was set inline.
1863
+ // ```html
1864
+ // <my-component some-attribute="some-value"></my-component>
1865
+ // ```
1866
+ //
1867
+ // There is an edge case where a developer sets the attribute inline on a custom element and then
1868
+ // programmatically changes it before it has been upgraded as shown below:
1869
+ //
1870
+ // ```html
1871
+ // <!-- this component has _not_ been upgraded yet -->
1872
+ // <my-component id="test" some-attribute="some-value"></my-component>
1873
+ // <script>
1874
+ // // grab non-upgraded component
1875
+ // el = document.querySelector("#test");
1876
+ // el.someAttribute = "another-value";
1877
+ // // upgrade component
1878
+ // customElements.define('my-component', MyComponent);
1879
+ // </script>
1880
+ // ```
1881
+ // In this case if we do not unshadow here and use the value of the shadowing property, attributeChangedCallback
1882
+ // will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
1883
+ // to the value that was set inline i.e. "some-value" from above example. When
1884
+ // the connectedCallback attempts to unshadow it will use "some-value" as the initial value rather than "another-value"
1885
+ //
1886
+ // The case where the attribute was NOT set inline but was not set programmatically shall be handled/unshadowed
1887
+ // by connectedCallback as this attributeChangedCallback will not fire.
1888
+ //
1889
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1890
+ //
1891
+ // TODO(STENCIL-16) we should think about whether or not we actually want to be reflecting the attributes to
1892
+ // properties here given that this goes against best practices outlined here
1893
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy
1894
+ if (this.hasOwnProperty(propName)) {
1895
+ newValue = this[propName];
1896
+ delete this[propName];
1897
+ }
1898
+ else if (prototype.hasOwnProperty(propName) &&
1899
+ typeof this[propName] === 'number' &&
1900
+ this[propName] == newValue) {
1901
+ // if the propName exists on the prototype of `Cstr`, this update may be a result of Stencil using native
1902
+ // APIs to reflect props as attributes. Calls to `setAttribute(someElement, propName)` will result in
1903
+ // `propName` to be converted to a `DOMString`, which may not be what we want for other primitive props.
1904
+ return;
1905
+ }
1906
+ this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
1907
+ });
1908
+ };
1909
+ // create an array of attributes to observe
1910
+ // and also create a map of html attribute name to js property name
1911
+ Cstr.observedAttributes = members
1912
+ .filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */) // filter to only keep props that should match attributes
1913
+ .map(([propName, m]) => {
1914
+ const attrName = m[1] || propName;
1915
+ attrNameToPropName.set(attrName, propName);
1916
+ if (m[0] & 512 /* MEMBER_FLAGS.ReflectAttr */) {
1917
+ cmpMeta.$attrsToReflect$.push([propName, attrName]);
1918
+ }
1919
+ return attrName;
1920
+ });
1921
+ }
1922
+ }
1923
+ return Cstr;
1924
+ };
1925
+ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
1926
+ // initializeComponent
1927
+ if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
1928
+ {
1929
+ // we haven't initialized this element yet
1930
+ hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
1931
+ // lazy loaded components
1932
+ // request the component's implementation to be
1933
+ // wired up with the host element
1934
+ Cstr = loadModule(cmpMeta);
1935
+ if (Cstr.then) {
1936
+ // Await creates a micro-task avoid if possible
1937
+ const endLoad = uniqueTime();
1938
+ Cstr = await Cstr;
1939
+ endLoad();
1940
+ }
1941
+ if (!Cstr.isProxied) {
1942
+ // we've never proxied this Constructor before
1943
+ // let's add the getters/setters to its prototype before
1944
+ // the first time we create an instance of the implementation
1945
+ {
1946
+ cmpMeta.$watchers$ = Cstr.watchers;
1947
+ }
1948
+ proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
1949
+ Cstr.isProxied = true;
1950
+ }
1951
+ const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
1952
+ // ok, time to construct the instance
1953
+ // but let's keep track of when we start and stop
1954
+ // so that the getters/setters don't incorrectly step on data
1955
+ {
1956
+ hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
1957
+ }
1958
+ // construct the lazy-loaded component implementation
1959
+ // passing the hostRef is very important during
1960
+ // construction in order to directly wire together the
1961
+ // host element and the lazy-loaded instance
1962
+ try {
1963
+ new Cstr(hostRef);
1964
+ }
1965
+ catch (e) {
1966
+ consoleError(e);
1967
+ }
1968
+ {
1969
+ hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
1970
+ }
1971
+ {
1972
+ hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */;
1973
+ }
1974
+ endNewInstance();
1975
+ }
1976
+ if (Cstr.style) {
1977
+ // this component has styles but we haven't registered them yet
1978
+ let style = Cstr.style;
1979
+ const scopeId = getScopeId(cmpMeta);
1980
+ if (!styles.has(scopeId)) {
1981
+ const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
1982
+ registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
1983
+ endRegisterStyles();
1984
+ }
1985
+ }
1986
+ }
1987
+ // we've successfully created a lazy instance
1988
+ const ancestorComponent = hostRef.$ancestorComponent$;
1989
+ const schedule = () => scheduleUpdate(hostRef, true);
1990
+ if (ancestorComponent && ancestorComponent['s-rc']) {
1991
+ // this is the initial load and this component it has an ancestor component
1992
+ // but the ancestor component has NOT fired its will update lifecycle yet
1993
+ // so let's just cool our jets and wait for the ancestor to continue first
1994
+ // this will get fired off when the ancestor component
1995
+ // finally gets around to rendering its lazy self
1996
+ // fire off the initial update
1997
+ ancestorComponent['s-rc'].push(schedule);
1998
+ }
1999
+ else {
2000
+ schedule();
2001
+ }
2002
+ };
2003
+ const connectedCallback = (elm) => {
2004
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
2005
+ const hostRef = getHostRef(elm);
2006
+ const cmpMeta = hostRef.$cmpMeta$;
2007
+ const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
2008
+ if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
2009
+ // first time this component has connected
2010
+ hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
2011
+ let hostId;
2012
+ {
2013
+ hostId = elm.getAttribute(HYDRATE_ID);
2014
+ if (hostId) {
2015
+ if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
2016
+ const scopeId = addStyle(elm.shadowRoot, cmpMeta);
2017
+ elm.classList.remove(scopeId + '-h', scopeId + '-s');
2018
+ }
2019
+ initializeClientHydrate(elm, cmpMeta.$tagName$, hostId, hostRef);
2020
+ }
2021
+ }
2022
+ if (!hostId) {
2023
+ // initUpdate
2024
+ // if the slot polyfill is required we'll need to put some nodes
2025
+ // in here to act as original content anchors as we move nodes around
2026
+ // host element has been connected to the DOM
2027
+ if ((cmpMeta.$flags$ & (4 /* CMP_FLAGS.hasSlotRelocation */ | 8 /* CMP_FLAGS.needsShadowDomShim */))) {
2028
+ setContentReference(elm);
2029
+ }
2030
+ }
2031
+ {
2032
+ // find the first ancestor component (if there is one) and register
2033
+ // this component as one of the actively loading child components for its ancestor
2034
+ let ancestorComponent = elm;
2035
+ while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
2036
+ // climb up the ancestors looking for the first
2037
+ // component that hasn't finished its lifecycle update yet
2038
+ if ((ancestorComponent.nodeType === 1 /* NODE_TYPE.ElementNode */ &&
2039
+ ancestorComponent.hasAttribute('s-id') &&
2040
+ ancestorComponent['s-p']) ||
2041
+ ancestorComponent['s-p']) {
2042
+ // we found this components first ancestor component
2043
+ // keep a reference to this component's ancestor component
2044
+ attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
2045
+ break;
2046
+ }
2047
+ }
2048
+ }
2049
+ // Lazy properties
2050
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
2051
+ if (cmpMeta.$members$) {
2052
+ Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
2053
+ if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
2054
+ const value = elm[memberName];
2055
+ delete elm[memberName];
2056
+ elm[memberName] = value;
2057
+ }
2058
+ });
2059
+ }
2060
+ {
2061
+ initializeComponent(elm, hostRef, cmpMeta);
2062
+ }
2063
+ }
2064
+ else {
2065
+ // not the first time this has connected
2066
+ // reattach any event listeners to the host
2067
+ // since they would have been removed when disconnected
2068
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
2069
+ }
2070
+ endConnected();
2071
+ }
2072
+ };
2073
+ const setContentReference = (elm) => {
2074
+ // only required when we're NOT using native shadow dom (slot)
2075
+ // or this browser doesn't support native shadow dom
2076
+ // and this host element was NOT created with SSR
2077
+ // let's pick out the inner content for slot projection
2078
+ // create a node to represent where the original
2079
+ // content was first placed, which is useful later on
2080
+ const contentRefElm = (elm['s-cr'] = doc.createComment(''));
2081
+ contentRefElm['s-cn'] = true;
2082
+ elm.insertBefore(contentRefElm, elm.firstChild);
2083
+ };
2084
+ const disconnectedCallback = (elm) => {
2085
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
2086
+ const hostRef = getHostRef(elm);
2087
+ {
2088
+ if (hostRef.$rmListeners$) {
2089
+ hostRef.$rmListeners$.map((rmListener) => rmListener());
2090
+ hostRef.$rmListeners$ = undefined;
2091
+ }
2092
+ }
2093
+ }
2094
+ };
2095
+ const bootstrapLazy = (lazyBundles, options = {}) => {
2096
+ var _a;
2097
+ const endBootstrap = createTime();
2098
+ const cmpTags = [];
2099
+ const exclude = options.exclude || [];
2100
+ const customElements = win.customElements;
2101
+ const head = doc.head;
2102
+ const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
2103
+ const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
2104
+ const deferredConnectedCallbacks = [];
2105
+ const styles = /*@__PURE__*/ doc.querySelectorAll(`[${HYDRATED_STYLE_ID}]`);
2106
+ let appLoadFallback;
2107
+ let isBootstrapping = true;
2108
+ let i = 0;
2109
+ Object.assign(plt, options);
2110
+ plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
2111
+ {
2112
+ // If the app is already hydrated there is not point to disable the
2113
+ // async queue. This will improve the first input delay
2114
+ plt.$flags$ |= 2 /* PLATFORM_FLAGS.appLoaded */;
2115
+ }
2116
+ {
2117
+ for (; i < styles.length; i++) {
2118
+ registerStyle(styles[i].getAttribute(HYDRATED_STYLE_ID), convertScopedToShadow(styles[i].innerHTML), true);
2119
+ }
2120
+ }
2121
+ lazyBundles.map((lazyBundle) => {
2122
+ lazyBundle[1].map((compactMeta) => {
2123
+ const cmpMeta = {
2124
+ $flags$: compactMeta[0],
2125
+ $tagName$: compactMeta[1],
2126
+ $members$: compactMeta[2],
2127
+ $listeners$: compactMeta[3],
2128
+ };
2129
+ {
2130
+ cmpMeta.$members$ = compactMeta[2];
2131
+ }
2132
+ {
2133
+ cmpMeta.$listeners$ = compactMeta[3];
2134
+ }
2135
+ {
2136
+ cmpMeta.$attrsToReflect$ = [];
2137
+ }
2138
+ {
2139
+ cmpMeta.$watchers$ = {};
2140
+ }
2141
+ const tagName = cmpMeta.$tagName$;
2142
+ const HostElement = class extends HTMLElement {
2143
+ // StencilLazyHost
2144
+ constructor(self) {
2145
+ // @ts-ignore
2146
+ super(self);
2147
+ self = this;
2148
+ registerHost(self, cmpMeta);
2149
+ if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
2150
+ // this component is using shadow dom
2151
+ // and this browser supports shadow dom
2152
+ // add the read-only property "shadowRoot" to the host element
2153
+ // adding the shadow root build conditionals to minimize runtime
2154
+ {
2155
+ {
2156
+ self.attachShadow({ mode: 'open' });
2157
+ }
2158
+ }
2159
+ }
2160
+ }
2161
+ connectedCallback() {
2162
+ if (appLoadFallback) {
2163
+ clearTimeout(appLoadFallback);
2164
+ appLoadFallback = null;
2165
+ }
2166
+ if (isBootstrapping) {
2167
+ // connectedCallback will be processed once all components have been registered
2168
+ deferredConnectedCallbacks.push(this);
2169
+ }
2170
+ else {
2171
+ plt.jmp(() => connectedCallback(this));
2172
+ }
2173
+ }
2174
+ disconnectedCallback() {
2175
+ plt.jmp(() => disconnectedCallback(this));
2176
+ }
2177
+ componentOnReady() {
2178
+ return getHostRef(this).$onReadyPromise$;
2179
+ }
2180
+ };
2181
+ cmpMeta.$lazyBundleId$ = lazyBundle[0];
2182
+ if (!exclude.includes(tagName) && !customElements.get(tagName)) {
2183
+ cmpTags.push(tagName);
2184
+ customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
2185
+ }
2186
+ });
2187
+ });
2188
+ {
2189
+ visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
2190
+ visibilityStyle.setAttribute('data-styles', '');
2191
+ // Apply CSP nonce to the style tag if it exists
2192
+ const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
2193
+ if (nonce != null) {
2194
+ visibilityStyle.setAttribute('nonce', nonce);
2195
+ }
2196
+ head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
2197
+ }
2198
+ // Process deferred connectedCallbacks now all components have been registered
2199
+ isBootstrapping = false;
2200
+ if (deferredConnectedCallbacks.length) {
2201
+ deferredConnectedCallbacks.map((host) => host.connectedCallback());
2202
+ }
2203
+ else {
2204
+ {
2205
+ plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
2206
+ }
2207
+ }
2208
+ // Fallback appLoad event
2209
+ endBootstrap();
2210
+ };
2211
+ const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
2212
+ if (listeners) {
2213
+ listeners.map(([flags, name, method]) => {
2214
+ const target = getHostListenerTarget(elm, flags) ;
2215
+ const handler = hostListenerProxy(hostRef, method);
2216
+ const opts = hostListenerOpts(flags);
2217
+ plt.ael(target, name, handler, opts);
2218
+ (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
2219
+ });
2220
+ }
2221
+ };
2222
+ const hostListenerProxy = (hostRef, methodName) => (ev) => {
2223
+ try {
2224
+ {
2225
+ if (hostRef.$flags$ & 256 /* HOST_FLAGS.isListenReady */) {
2226
+ // instance is ready, let's call it's member method for this event
2227
+ hostRef.$lazyInstance$[methodName](ev);
2228
+ }
2229
+ else {
2230
+ (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
2231
+ }
2232
+ }
2233
+ }
2234
+ catch (e) {
2235
+ consoleError(e);
2236
+ }
2237
+ };
2238
+ const getHostListenerTarget = (elm, flags) => {
2239
+ if (flags & 8 /* LISTENER_FLAGS.TargetWindow */)
2240
+ return win;
2241
+ return elm;
2242
+ };
2243
+ // prettier-ignore
2244
+ const hostListenerOpts = (flags) => (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
2245
+ /**
2246
+ * Assigns the given value to the nonce property on the runtime platform object.
2247
+ * During runtime, this value is used to set the nonce attribute on all dynamically created script and style tags.
2248
+ * @param nonce The value to be assigned to the platform nonce property.
2249
+ * @returns void
2250
+ */
2251
+ const setNonce = (nonce) => (plt.$nonce$ = nonce);
2252
+ const hostRefs = /*@__PURE__*/ new WeakMap();
2253
+ const getHostRef = (ref) => hostRefs.get(ref);
2254
+ const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
2255
+ const registerHost = (elm, cmpMeta) => {
2256
+ const hostRef = {
2257
+ $flags$: 0,
2258
+ $hostElement$: elm,
2259
+ $cmpMeta$: cmpMeta,
2260
+ $instanceValues$: new Map(),
2261
+ };
2262
+ {
2263
+ hostRef.$onInstancePromise$ = new Promise((r) => (hostRef.$onInstanceResolve$ = r));
2264
+ }
2265
+ {
2266
+ hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
2267
+ elm['s-p'] = [];
2268
+ elm['s-rc'] = [];
2269
+ }
2270
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
2271
+ return hostRefs.set(elm, hostRef);
2272
+ };
2273
+ const isMemberInElement = (elm, memberName) => memberName in elm;
2274
+ const consoleError = (e, el) => (0, console.error)(e, el);
2275
+ const cmpModules = /*@__PURE__*/ new Map();
2276
+ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
2277
+ // loadModuleImport
2278
+ const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
2279
+ const bundleId = cmpMeta.$lazyBundleId$;
2280
+ const module = cmpModules.get(bundleId) ;
2281
+ if (module) {
2282
+ return module[exportName];
2283
+ }
2284
+
2285
+ if (!hmrVersionId || !BUILD.hotModuleReplacement) {
2286
+ const processMod = importedModule => {
2287
+ cmpModules.set(bundleId, importedModule);
2288
+ return importedModule[exportName];
2289
+ }
2290
+ switch(bundleId) {
2291
+
2292
+ case 'ds-activity-log_16.cjs':
2293
+ return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
2294
+ /* webpackMode: "lazy" */
2295
+ './ds-activity-log_16.cjs.entry.js')); }).then(processMod, consoleError);
2296
+ case 'ds-loading-page.cjs':
2297
+ return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
2298
+ /* webpackMode: "lazy" */
2299
+ './ds-loading-page.cjs.entry.js')); }).then(processMod, consoleError);
2300
+ case 'ds-splash.cjs':
2301
+ return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
2302
+ /* webpackMode: "lazy" */
2303
+ './ds-splash.cjs.entry.js')); }).then(processMod, consoleError);
2304
+ }
2305
+ }
2306
+ return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
2307
+ /* @vite-ignore */
2308
+ /* webpackInclude: /\.entry\.js$/ */
2309
+ /* webpackExclude: /\.system\.entry\.js$/ */
2310
+ /* webpackMode: "lazy" */
2311
+ `./${bundleId}.entry.js${''}`)); }).then((importedModule) => {
2312
+ {
2313
+ cmpModules.set(bundleId, importedModule);
2314
+ }
2315
+ return importedModule[exportName];
2316
+ }, consoleError);
2317
+ };
2318
+ const styles = /*@__PURE__*/ new Map();
2319
+ const win = typeof window !== 'undefined' ? window : {};
2320
+ const doc = win.document || { head: {} };
2321
+ const plt = {
2322
+ $flags$: 0,
2323
+ $resourcesUrl$: '',
2324
+ jmp: (h) => h(),
2325
+ raf: (h) => requestAnimationFrame(h),
2326
+ ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
2327
+ rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
2328
+ ce: (eventName, opts) => new CustomEvent(eventName, opts),
2329
+ };
2330
+ const supportsShadow = true;
2331
+ const promiseResolve = (v) => Promise.resolve(v);
2332
+ const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
2333
+ try {
2334
+ new CSSStyleSheet();
2335
+ return typeof new CSSStyleSheet().replaceSync === 'function';
2336
+ }
2337
+ catch (e) { }
2338
+ return false;
2339
+ })()
2340
+ ;
2341
+ const queueDomReads = [];
2342
+ const queueDomWrites = [];
2343
+ const queueTask = (queue, write) => (cb) => {
2344
+ queue.push(cb);
2345
+ if (!queuePending) {
2346
+ queuePending = true;
2347
+ if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
2348
+ nextTick(flush);
2349
+ }
2350
+ else {
2351
+ plt.raf(flush);
2352
+ }
2353
+ }
2354
+ };
2355
+ const consume = (queue) => {
2356
+ for (let i = 0; i < queue.length; i++) {
2357
+ try {
2358
+ queue[i](performance.now());
2359
+ }
2360
+ catch (e) {
2361
+ consoleError(e);
2362
+ }
2363
+ }
2364
+ queue.length = 0;
2365
+ };
2366
+ const flush = () => {
2367
+ // always force a bunch of medium callbacks to run, but still have
2368
+ // a throttle on how many can run in a certain time
2369
+ // DOM READS!!!
2370
+ consume(queueDomReads);
2371
+ // DOM WRITES!!!
2372
+ {
2373
+ consume(queueDomWrites);
2374
+ if ((queuePending = queueDomReads.length > 0)) {
2375
+ // still more to do yet, but we've run out of time
2376
+ // let's let this thing cool off and try again in the next tick
2377
+ plt.raf(flush);
2378
+ }
2379
+ }
2380
+ };
2381
+ const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
2382
+ const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
2383
+
2384
+ exports.Host = Host;
2385
+ exports.bootstrapLazy = bootstrapLazy;
2386
+ exports.createEvent = createEvent;
2387
+ exports.getElement = getElement;
2388
+ exports.h = h;
2389
+ exports.promiseResolve = promiseResolve;
2390
+ exports.registerInstance = registerInstance;
2391
+ exports.setNonce = setNonce;