@mgdis/mg-components 3.1.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 (271) hide show
  1. package/LICENSE +29 -0
  2. package/dist/cjs/css-shim-a22512c4.js +6 -0
  3. package/dist/cjs/index-85a4a0b6.js +1674 -0
  4. package/dist/cjs/index.cjs.js +2 -0
  5. package/dist/cjs/loader.cjs.js +35 -0
  6. package/dist/cjs/mg-badge_20.cjs.entry.js +4661 -0
  7. package/dist/cjs/mg-components.cjs.js +23 -0
  8. package/dist/cjs/shadow-css-8940f82d.js +390 -0
  9. package/dist/collection/collection-manifest.json +31 -0
  10. package/dist/collection/components/atoms/mg-badge/mg-badge.conf.js +4 -0
  11. package/dist/collection/components/atoms/mg-badge/mg-badge.css +99 -0
  12. package/dist/collection/components/atoms/mg-badge/mg-badge.js +148 -0
  13. package/dist/collection/components/atoms/mg-badge/mg-badge.stories.js +27 -0
  14. package/dist/collection/components/atoms/mg-button/mg-button.conf.js +4 -0
  15. package/dist/collection/components/atoms/mg-button/mg-button.css +134 -0
  16. package/dist/collection/components/atoms/mg-button/mg-button.js +236 -0
  17. package/dist/collection/components/atoms/mg-button/mg-button.stories.js +38 -0
  18. package/dist/collection/components/atoms/mg-character-left/mg-character-left.css +3 -0
  19. package/dist/collection/components/atoms/mg-character-left/mg-character-left.js +133 -0
  20. package/dist/collection/components/atoms/mg-character-left/mg-character-left.stories.js +15 -0
  21. package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js +54 -0
  22. package/dist/collection/components/atoms/mg-icon/mg-icon.css +57 -0
  23. package/dist/collection/components/atoms/mg-icon/mg-icon.js +155 -0
  24. package/dist/collection/components/atoms/mg-icon/mg-icon.stories.js +34 -0
  25. package/dist/collection/components/atoms/mg-input-title/mg-input-title.css +12 -0
  26. package/dist/collection/components/atoms/mg-input-title/mg-input-title.js +95 -0
  27. package/dist/collection/components/atoms/mg-input-title/mg-input-title.stories.js +21 -0
  28. package/dist/collection/components/atoms/mg-tag/mg-tag.conf.js +4 -0
  29. package/dist/collection/components/atoms/mg-tag/mg-tag.css +73 -0
  30. package/dist/collection/components/atoms/mg-tag/mg-tag.js +94 -0
  31. package/dist/collection/components/atoms/mg-tag/mg-tag.stories.js +25 -0
  32. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.css +44 -0
  33. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +225 -0
  34. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.stories.js +26 -0
  35. package/dist/collection/components/molecules/inputs/MgInput.conf.js +7 -0
  36. package/dist/collection/components/molecules/inputs/MgInput.js +130 -0
  37. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.js +1 -0
  38. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.css +156 -0
  39. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +444 -0
  40. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.stories.js +57 -0
  41. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.conf.js +7 -0
  42. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.css +171 -0
  43. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +467 -0
  44. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.stories.js +46 -0
  45. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.conf.js +11 -0
  46. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.css +199 -0
  47. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +633 -0
  48. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.stories.js +68 -0
  49. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.css +195 -0
  50. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +401 -0
  51. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.stories.js +43 -0
  52. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.conf.js +1 -0
  53. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.css +156 -0
  54. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +443 -0
  55. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.stories.js +65 -0
  56. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.conf.js +1 -0
  57. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.css +201 -0
  58. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +532 -0
  59. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.stories.js +70 -0
  60. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.css +222 -0
  61. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +589 -0
  62. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.stories.js +115 -0
  63. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.css +217 -0
  64. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +553 -0
  65. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.stories.js +52 -0
  66. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.conf.js +1 -0
  67. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.css +213 -0
  68. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +457 -0
  69. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.stories.js +73 -0
  70. package/dist/collection/components/molecules/mg-message/mg-message.conf.js +4 -0
  71. package/dist/collection/components/molecules/mg-message/mg-message.css +94 -0
  72. package/dist/collection/components/molecules/mg-message/mg-message.js +285 -0
  73. package/dist/collection/components/molecules/mg-message/mg-message.stories.js +43 -0
  74. package/dist/collection/components/molecules/mg-pagination/mg-pagination.conf.js +5 -0
  75. package/dist/collection/components/molecules/mg-pagination/mg-pagination.css +39 -0
  76. package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +218 -0
  77. package/dist/collection/components/molecules/mg-pagination/mg-pagination.stories.js +23 -0
  78. package/dist/collection/components/molecules/mg-popover/mg-popover.css +59 -0
  79. package/dist/collection/components/molecules/mg-popover/mg-popover.js +249 -0
  80. package/dist/collection/components/molecules/mg-popover/mg-popover.stories.js +36 -0
  81. package/dist/collection/components/molecules/mg-tabs/mg-tabs.conf.js +1 -0
  82. package/dist/collection/components/molecules/mg-tabs/mg-tabs.css +30 -0
  83. package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +212 -0
  84. package/dist/collection/components/molecules/mg-tabs/mg-tabs.stories.js +40 -0
  85. package/dist/collection/fonts/OpenSans-Regular.ttf +0 -0
  86. package/dist/collection/fonts/OpenSans-SemiBold.ttf +0 -0
  87. package/dist/collection/fonts/Poppins-Bold.ttf +0 -0
  88. package/dist/collection/index.js +1 -0
  89. package/dist/collection/locales/index.js +4 -0
  90. package/dist/collection/stories/buttons.stories.js +43 -0
  91. package/dist/collection/stories/grids.stories.js +50 -0
  92. package/dist/collection/stories/icons.stories.js +20 -0
  93. package/dist/collection/stories/messages.stories.js +44 -0
  94. package/dist/collection/stories/tags.stories.js +13 -0
  95. package/dist/collection/stories/typography.stories.js +28 -0
  96. package/dist/collection/utils/components.utils.js +67 -0
  97. package/dist/collection/utils/locale.utils.js +32 -0
  98. package/dist/collection/utils/test.utils.js +26 -0
  99. package/dist/collection/variables.css +177 -0
  100. package/dist/collection/variables.scss +177 -0
  101. package/dist/components/MgInput.js +140 -0
  102. package/dist/components/components.utils.js +69 -0
  103. package/dist/components/index.d.ts +26 -0
  104. package/dist/components/index.js +1 -0
  105. package/dist/components/index2.js +54 -0
  106. package/dist/components/locale.utils.js +35 -0
  107. package/dist/components/mg-badge.d.ts +11 -0
  108. package/dist/components/mg-badge.js +6 -0
  109. package/dist/components/mg-badge2.js +82 -0
  110. package/dist/components/mg-button.d.ts +11 -0
  111. package/dist/components/mg-button.js +6 -0
  112. package/dist/components/mg-button2.js +148 -0
  113. package/dist/components/mg-character-left.d.ts +11 -0
  114. package/dist/components/mg-character-left.js +6 -0
  115. package/dist/components/mg-character-left2.js +77 -0
  116. package/dist/components/mg-icon.d.ts +11 -0
  117. package/dist/components/mg-icon.js +6 -0
  118. package/dist/components/mg-icon2.js +147 -0
  119. package/dist/components/mg-input-checkbox.d.ts +11 -0
  120. package/dist/components/mg-input-checkbox.js +222 -0
  121. package/dist/components/mg-input-date.d.ts +11 -0
  122. package/dist/components/mg-input-date.js +245 -0
  123. package/dist/components/mg-input-numeric.d.ts +11 -0
  124. package/dist/components/mg-input-numeric.js +324 -0
  125. package/dist/components/mg-input-password.d.ts +11 -0
  126. package/dist/components/mg-input-password.js +171 -0
  127. package/dist/components/mg-input-radio.d.ts +11 -0
  128. package/dist/components/mg-input-radio.js +211 -0
  129. package/dist/components/mg-input-select.d.ts +11 -0
  130. package/dist/components/mg-input-select.js +6 -0
  131. package/dist/components/mg-input-select2.js +243 -0
  132. package/dist/components/mg-input-text.d.ts +11 -0
  133. package/dist/components/mg-input-text.js +242 -0
  134. package/dist/components/mg-input-textarea.d.ts +11 -0
  135. package/dist/components/mg-input-textarea.js +224 -0
  136. package/dist/components/mg-input-title.d.ts +11 -0
  137. package/dist/components/mg-input-title.js +6 -0
  138. package/dist/components/mg-input-title2.js +55 -0
  139. package/dist/components/mg-input-toggle.d.ts +11 -0
  140. package/dist/components/mg-input-toggle.js +247 -0
  141. package/dist/components/mg-message.d.ts +11 -0
  142. package/dist/components/mg-message.js +183 -0
  143. package/dist/components/mg-pagination.d.ts +11 -0
  144. package/dist/components/mg-pagination.js +175 -0
  145. package/dist/components/mg-popover.d.ts +11 -0
  146. package/dist/components/mg-popover.js +183 -0
  147. package/dist/components/mg-tabs.d.ts +11 -0
  148. package/dist/components/mg-tabs.js +160 -0
  149. package/dist/components/mg-tag.d.ts +11 -0
  150. package/dist/components/mg-tag.js +76 -0
  151. package/dist/components/mg-tooltip.d.ts +11 -0
  152. package/dist/components/mg-tooltip.js +6 -0
  153. package/dist/components/mg-tooltip2.js +150 -0
  154. package/dist/components/popper.js +1784 -0
  155. package/dist/esm/css-shim-7c240feb.js +4 -0
  156. package/dist/esm/index-e3e84606.js +1643 -0
  157. package/dist/esm/index.js +1 -0
  158. package/dist/esm/loader.js +31 -0
  159. package/dist/esm/mg-badge_20.entry.js +4638 -0
  160. package/dist/esm/mg-components.js +21 -0
  161. package/dist/esm/polyfills/core-js.js +11 -0
  162. package/dist/esm/polyfills/css-shim.js +1 -0
  163. package/dist/esm/polyfills/dom.js +79 -0
  164. package/dist/esm/polyfills/es5-html-element.js +1 -0
  165. package/dist/esm/polyfills/index.js +34 -0
  166. package/dist/esm/polyfills/system.js +6 -0
  167. package/dist/esm/shadow-css-5d2d01ce.js +388 -0
  168. package/dist/esm-es5/css-shim-7c240feb.js +1 -0
  169. package/dist/esm-es5/index-e3e84606.js +1 -0
  170. package/dist/esm-es5/index.js +0 -0
  171. package/dist/esm-es5/loader.js +1 -0
  172. package/dist/esm-es5/mg-badge_20.entry.js +2 -0
  173. package/dist/esm-es5/mg-components.js +1 -0
  174. package/dist/esm-es5/shadow-css-5d2d01ce.js +12 -0
  175. package/dist/index.cjs.js +1 -0
  176. package/dist/index.js +1 -0
  177. package/dist/mg-components/fonts/OpenSans-Regular.ttf +0 -0
  178. package/dist/mg-components/fonts/OpenSans-SemiBold.ttf +0 -0
  179. package/dist/mg-components/fonts/Poppins-Bold.ttf +0 -0
  180. package/dist/mg-components/index.esm.js +0 -0
  181. package/dist/mg-components/mg-components.css +1 -0
  182. package/dist/mg-components/mg-components.esm.js +1 -0
  183. package/dist/mg-components/mg-components.js +132 -0
  184. package/dist/mg-components/p-1cd24462.system.js +1 -0
  185. package/dist/mg-components/p-2e2f6b27.system.entry.js +2 -0
  186. package/dist/mg-components/p-366a224e.js +1 -0
  187. package/dist/mg-components/p-422c429b.system.js +1 -0
  188. package/dist/mg-components/p-50ea2036.system.js +1 -0
  189. package/dist/mg-components/p-62fa3797.js +1 -0
  190. package/dist/mg-components/p-71d57b8b.system.js +13 -0
  191. package/dist/mg-components/p-9a215712.system.js +1 -0
  192. package/dist/mg-components/p-cbf0464b.entry.js +1 -0
  193. package/dist/mg-components/p-f6455ab3.js +12 -0
  194. package/dist/mg-components/variables.css +177 -0
  195. package/dist/mg-components/variables.scss +177 -0
  196. package/dist/types/components/atoms/mg-badge/mg-badge.conf.d.ts +8 -0
  197. package/dist/types/components/atoms/mg-badge/mg-badge.d.ts +36 -0
  198. package/dist/types/components/atoms/mg-badge/mg-badge.stories.d.ts +19 -0
  199. package/dist/types/components/atoms/mg-button/mg-button.conf.d.ts +4 -0
  200. package/dist/types/components/atoms/mg-button/mg-button.d.ts +67 -0
  201. package/dist/types/components/atoms/mg-button/mg-button.stories.d.ts +16 -0
  202. package/dist/types/components/atoms/mg-character-left/mg-character-left.d.ts +39 -0
  203. package/dist/types/components/atoms/mg-character-left/mg-character-left.stories.d.ts +7 -0
  204. package/dist/types/components/atoms/mg-icon/mg-icon.conf.d.ts +12 -0
  205. package/dist/types/components/atoms/mg-icon/mg-icon.d.ts +36 -0
  206. package/dist/types/components/atoms/mg-icon/mg-icon.stories.d.ts +26 -0
  207. package/dist/types/components/atoms/mg-input-title/mg-input-title.d.ts +24 -0
  208. package/dist/types/components/atoms/mg-input-title/mg-input-title.stories.d.ts +6 -0
  209. package/dist/types/components/atoms/mg-tag/mg-tag.conf.d.ts +4 -0
  210. package/dist/types/components/atoms/mg-tag/mg-tag.d.ts +25 -0
  211. package/dist/types/components/atoms/mg-tag/mg-tag.stories.d.ts +14 -0
  212. package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +56 -0
  213. package/dist/types/components/atoms/mg-tooltip/mg-tooltip.stories.d.ts +11 -0
  214. package/dist/types/components/molecules/inputs/MgInput.conf.d.ts +10 -0
  215. package/dist/types/components/molecules/inputs/MgInput.d.ts +35 -0
  216. package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.d.ts +19 -0
  217. package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +120 -0
  218. package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.stories.d.ts +6 -0
  219. package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.conf.d.ts +6 -0
  220. package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +128 -0
  221. package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.stories.d.ts +7 -0
  222. package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.conf.d.ts +10 -0
  223. package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +173 -0
  224. package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.stories.d.ts +21 -0
  225. package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +111 -0
  226. package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.stories.d.ts +9 -0
  227. package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.conf.d.ts +9 -0
  228. package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +121 -0
  229. package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.stories.d.ts +15 -0
  230. package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.conf.d.ts +18 -0
  231. package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +133 -0
  232. package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.stories.d.ts +14 -0
  233. package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +160 -0
  234. package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.stories.d.ts +26 -0
  235. package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +150 -0
  236. package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.stories.d.ts +6 -0
  237. package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.conf.d.ts +8 -0
  238. package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +117 -0
  239. package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.stories.d.ts +7 -0
  240. package/dist/types/components/molecules/mg-message/mg-message.conf.d.ts +4 -0
  241. package/dist/types/components/molecules/mg-message/mg-message.d.ts +76 -0
  242. package/dist/types/components/molecules/mg-message/mg-message.stories.d.ts +16 -0
  243. package/dist/types/components/molecules/mg-pagination/mg-pagination.conf.d.ts +4 -0
  244. package/dist/types/components/molecules/mg-pagination/mg-pagination.d.ts +53 -0
  245. package/dist/types/components/molecules/mg-pagination/mg-pagination.stories.d.ts +6 -0
  246. package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +62 -0
  247. package/dist/types/components/molecules/mg-popover/mg-popover.stories.d.ts +12 -0
  248. package/dist/types/components/molecules/mg-tabs/mg-tabs.conf.d.ts +10 -0
  249. package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +63 -0
  250. package/dist/types/components/molecules/mg-tabs/mg-tabs.stories.d.ts +7 -0
  251. package/dist/types/components.d.ts +1987 -0
  252. package/dist/types/index.d.ts +1 -0
  253. package/dist/types/locales/index.d.ts +44 -0
  254. package/dist/types/stencil-public-runtime.d.ts +1565 -0
  255. package/dist/types/stories/buttons.stories.d.ts +13 -0
  256. package/dist/types/stories/grids.stories.d.ts +5 -0
  257. package/dist/types/stories/icons.stories.d.ts +13 -0
  258. package/dist/types/stories/messages.stories.d.ts +13 -0
  259. package/dist/types/stories/tags.stories.d.ts +5 -0
  260. package/dist/types/stories/typography.stories.d.ts +5 -0
  261. package/dist/types/utils/components.utils.d.ts +43 -0
  262. package/dist/types/utils/locale.utils.d.ts +22 -0
  263. package/dist/types/utils/test.utils.d.ts +5 -0
  264. package/loader/cdn.js +3 -0
  265. package/loader/index.cjs.js +3 -0
  266. package/loader/index.d.ts +12 -0
  267. package/loader/index.es2017.js +3 -0
  268. package/loader/index.js +4 -0
  269. package/loader/package.json +10 -0
  270. package/package.json +86 -0
  271. package/readme.md +159 -0
@@ -0,0 +1,1674 @@
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 = 'mg-components';
24
+
25
+ let scopeId;
26
+ let contentRef;
27
+ let hostTagName;
28
+ let useNativeShadowDom = false;
29
+ let checkSlotFallbackVisibility = false;
30
+ let checkSlotRelocate = false;
31
+ let isSvgMode = false;
32
+ let queuePending = false;
33
+ const win = typeof window !== 'undefined' ? window : {};
34
+ const CSS = win.CSS ;
35
+ const doc = win.document || { head: {} };
36
+ const plt = {
37
+ $flags$: 0,
38
+ $resourcesUrl$: '',
39
+ jmp: (h) => h(),
40
+ raf: (h) => requestAnimationFrame(h),
41
+ ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
42
+ rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
43
+ ce: (eventName, opts) => new CustomEvent(eventName, opts),
44
+ };
45
+ const supportsShadow = /*@__PURE__*/ (() => (doc.head.attachShadow + '').indexOf('[native') > -1)()
46
+ ;
47
+ const promiseResolve = (v) => Promise.resolve(v);
48
+ const supportsConstructibleStylesheets = /*@__PURE__*/ (() => {
49
+ try {
50
+ new CSSStyleSheet();
51
+ return typeof new CSSStyleSheet().replace === 'function';
52
+ }
53
+ catch (e) { }
54
+ return false;
55
+ })()
56
+ ;
57
+ const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
58
+ const createTime = (fnName, tagName = '') => {
59
+ {
60
+ return () => {
61
+ return;
62
+ };
63
+ }
64
+ };
65
+ const uniqueTime = (key, measureText) => {
66
+ {
67
+ return () => {
68
+ return;
69
+ };
70
+ }
71
+ };
72
+ const rootAppliedStyles = new WeakMap();
73
+ const registerStyle = (scopeId, cssText, allowCS) => {
74
+ let style = styles.get(scopeId);
75
+ if (supportsConstructibleStylesheets && allowCS) {
76
+ style = (style || new CSSStyleSheet());
77
+ style.replace(cssText);
78
+ }
79
+ else {
80
+ style = cssText;
81
+ }
82
+ styles.set(scopeId, style);
83
+ };
84
+ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
85
+ let scopeId = getScopeId(cmpMeta);
86
+ let style = styles.get(scopeId);
87
+ // if an element is NOT connected then getRootNode() will return the wrong root node
88
+ // so the fallback is to always use the document for the root node in those cases
89
+ styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
90
+ if (style) {
91
+ if (typeof style === 'string') {
92
+ styleContainerNode = styleContainerNode.head || styleContainerNode;
93
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
94
+ let styleElm;
95
+ if (!appliedStyles) {
96
+ rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
97
+ }
98
+ if (!appliedStyles.has(scopeId)) {
99
+ {
100
+ if (plt.$cssShim$) {
101
+ styleElm = plt.$cssShim$.createHostStyle(hostElm, scopeId, style, !!(cmpMeta.$flags$ & 10 /* needsScopedEncapsulation */));
102
+ const newScopeId = styleElm['s-sc'];
103
+ if (newScopeId) {
104
+ scopeId = newScopeId;
105
+ // we don't want to add this styleID to the appliedStyles Set
106
+ // since the cssVarShim might need to apply several different
107
+ // stylesheets for the same component
108
+ appliedStyles = null;
109
+ }
110
+ }
111
+ else {
112
+ styleElm = doc.createElement('style');
113
+ styleElm.innerHTML = style;
114
+ }
115
+ styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
116
+ }
117
+ if (appliedStyles) {
118
+ appliedStyles.add(scopeId);
119
+ }
120
+ }
121
+ }
122
+ else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
123
+ styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
124
+ }
125
+ }
126
+ return scopeId;
127
+ };
128
+ const attachStyles = (hostRef) => {
129
+ const cmpMeta = hostRef.$cmpMeta$;
130
+ const elm = hostRef.$hostElement$;
131
+ const flags = cmpMeta.$flags$;
132
+ const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
133
+ const scopeId = addStyle(supportsShadow && elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta, hostRef.$modeName$, elm);
134
+ if (flags & 10 /* needsScopedEncapsulation */) {
135
+ // only required when we're NOT using native shadow dom (slot)
136
+ // or this browser doesn't support native shadow dom
137
+ // and this host element was NOT created with SSR
138
+ // let's pick out the inner content for slot projection
139
+ // create a node to represent where the original
140
+ // content was first placed, which is useful later on
141
+ // DOM WRITE!!
142
+ elm['s-sc'] = scopeId;
143
+ elm.classList.add(scopeId + '-h');
144
+ if (flags & 2 /* scopedCssEncapsulation */) {
145
+ elm.classList.add(scopeId + '-s');
146
+ }
147
+ }
148
+ endAttachStyles();
149
+ };
150
+ const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
151
+ /**
152
+ * Default style mode id
153
+ */
154
+ /**
155
+ * Reusable empty obj/array
156
+ * Don't add values to these!!
157
+ */
158
+ const EMPTY_OBJ = {};
159
+ /**
160
+ * Namespaces
161
+ */
162
+ const SVG_NS = 'http://www.w3.org/2000/svg';
163
+ const HTML_NS = 'http://www.w3.org/1999/xhtml';
164
+ const isDef = (v) => v != null;
165
+ const isComplexType = (o) => {
166
+ // https://jsperf.com/typeof-fn-object/5
167
+ o = typeof o;
168
+ return o === 'object' || o === 'function';
169
+ };
170
+ /**
171
+ * Production h() function based on Preact by
172
+ * Jason Miller (@developit)
173
+ * Licensed under the MIT License
174
+ * https://github.com/developit/preact/blob/master/LICENSE
175
+ *
176
+ * Modified for Stencil's compiler and vdom
177
+ */
178
+ // const stack: any[] = [];
179
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
180
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
181
+ const h = (nodeName, vnodeData, ...children) => {
182
+ let child = null;
183
+ let slotName = null;
184
+ let simple = false;
185
+ let lastSimple = false;
186
+ let vNodeChildren = [];
187
+ const walk = (c) => {
188
+ for (let i = 0; i < c.length; i++) {
189
+ child = c[i];
190
+ if (Array.isArray(child)) {
191
+ walk(child);
192
+ }
193
+ else if (child != null && typeof child !== 'boolean') {
194
+ if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
195
+ child = String(child);
196
+ }
197
+ if (simple && lastSimple) {
198
+ // If the previous child was simple (string), we merge both
199
+ vNodeChildren[vNodeChildren.length - 1].$text$ += child;
200
+ }
201
+ else {
202
+ // Append a new vNode, if it's text, we create a text vNode
203
+ vNodeChildren.push(simple ? newVNode(null, child) : child);
204
+ }
205
+ lastSimple = simple;
206
+ }
207
+ }
208
+ };
209
+ walk(children);
210
+ if (vnodeData) {
211
+ if (vnodeData.name) {
212
+ slotName = vnodeData.name;
213
+ }
214
+ {
215
+ const classData = vnodeData.className || vnodeData.class;
216
+ if (classData) {
217
+ vnodeData.class =
218
+ typeof classData !== 'object'
219
+ ? classData
220
+ : Object.keys(classData)
221
+ .filter((k) => classData[k])
222
+ .join(' ');
223
+ }
224
+ }
225
+ }
226
+ if (typeof nodeName === 'function') {
227
+ // nodeName is a functional component
228
+ return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
229
+ }
230
+ const vnode = newVNode(nodeName, null);
231
+ vnode.$attrs$ = vnodeData;
232
+ if (vNodeChildren.length > 0) {
233
+ vnode.$children$ = vNodeChildren;
234
+ }
235
+ {
236
+ vnode.$name$ = slotName;
237
+ }
238
+ return vnode;
239
+ };
240
+ const newVNode = (tag, text) => {
241
+ const vnode = {
242
+ $flags$: 0,
243
+ $tag$: tag,
244
+ $text$: text,
245
+ $elm$: null,
246
+ $children$: null,
247
+ };
248
+ {
249
+ vnode.$attrs$ = null;
250
+ }
251
+ {
252
+ vnode.$name$ = null;
253
+ }
254
+ return vnode;
255
+ };
256
+ const Host = {};
257
+ const isHost = (node) => node && node.$tag$ === Host;
258
+ const vdomFnUtils = {
259
+ forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
260
+ map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate),
261
+ };
262
+ const convertToPublic = (node) => ({
263
+ vattrs: node.$attrs$,
264
+ vchildren: node.$children$,
265
+ vkey: node.$key$,
266
+ vname: node.$name$,
267
+ vtag: node.$tag$,
268
+ vtext: node.$text$,
269
+ });
270
+ const convertToPrivate = (node) => {
271
+ if (typeof node.vtag === 'function') {
272
+ const vnodeData = Object.assign({}, node.vattrs);
273
+ if (node.vkey) {
274
+ vnodeData.key = node.vkey;
275
+ }
276
+ if (node.vname) {
277
+ vnodeData.name = node.vname;
278
+ }
279
+ return h(node.vtag, vnodeData, ...(node.vchildren || []));
280
+ }
281
+ const vnode = newVNode(node.vtag, node.vtext);
282
+ vnode.$attrs$ = node.vattrs;
283
+ vnode.$children$ = node.vchildren;
284
+ vnode.$key$ = node.vkey;
285
+ vnode.$name$ = node.vname;
286
+ return vnode;
287
+ };
288
+ /**
289
+ * Production setAccessor() function based on Preact by
290
+ * Jason Miller (@developit)
291
+ * Licensed under the MIT License
292
+ * https://github.com/developit/preact/blob/master/LICENSE
293
+ *
294
+ * Modified for Stencil's compiler and vdom
295
+ */
296
+ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
297
+ if (oldValue !== newValue) {
298
+ let isProp = isMemberInElement(elm, memberName);
299
+ let ln = memberName.toLowerCase();
300
+ if (memberName === 'class') {
301
+ const classList = elm.classList;
302
+ const oldClasses = parseClassList(oldValue);
303
+ const newClasses = parseClassList(newValue);
304
+ classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
305
+ classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
306
+ }
307
+ else if (memberName === 'ref') {
308
+ // minifier will clean this up
309
+ if (newValue) {
310
+ newValue(elm);
311
+ }
312
+ }
313
+ else if ((!isProp ) &&
314
+ memberName[0] === 'o' &&
315
+ memberName[1] === 'n') {
316
+ // Event Handlers
317
+ // so if the member name starts with "on" and the 3rd characters is
318
+ // a capital letter, and it's not already a member on the element,
319
+ // then we're assuming it's an event listener
320
+ if (memberName[2] === '-') {
321
+ // on- prefixed events
322
+ // allows to be explicit about the dom event to listen without any magic
323
+ // under the hood:
324
+ // <my-cmp on-click> // listens for "click"
325
+ // <my-cmp on-Click> // listens for "Click"
326
+ // <my-cmp on-ionChange> // listens for "ionChange"
327
+ // <my-cmp on-EVENTS> // listens for "EVENTS"
328
+ memberName = memberName.slice(3);
329
+ }
330
+ else if (isMemberInElement(win, ln)) {
331
+ // standard event
332
+ // the JSX attribute could have been "onMouseOver" and the
333
+ // member name "onmouseover" is on the window's prototype
334
+ // so let's add the listener "mouseover", which is all lowercased
335
+ memberName = ln.slice(2);
336
+ }
337
+ else {
338
+ // custom event
339
+ // the JSX attribute could have been "onMyCustomEvent"
340
+ // so let's trim off the "on" prefix and lowercase the first character
341
+ // and add the listener "myCustomEvent"
342
+ // except for the first character, we keep the event name case
343
+ memberName = ln[2] + memberName.slice(3);
344
+ }
345
+ if (oldValue) {
346
+ plt.rel(elm, memberName, oldValue, false);
347
+ }
348
+ if (newValue) {
349
+ plt.ael(elm, memberName, newValue, false);
350
+ }
351
+ }
352
+ else {
353
+ // Set property if it exists and it's not a SVG
354
+ const isComplex = isComplexType(newValue);
355
+ if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
356
+ try {
357
+ if (!elm.tagName.includes('-')) {
358
+ let n = newValue == null ? '' : newValue;
359
+ // Workaround for Safari, moving the <input> caret when re-assigning the same valued
360
+ if (memberName === 'list') {
361
+ isProp = false;
362
+ }
363
+ else if (oldValue == null || elm[memberName] != n) {
364
+ elm[memberName] = n;
365
+ }
366
+ }
367
+ else {
368
+ elm[memberName] = newValue;
369
+ }
370
+ }
371
+ catch (e) { }
372
+ }
373
+ if (newValue == null || newValue === false) {
374
+ if (newValue !== false || elm.getAttribute(memberName) === '') {
375
+ {
376
+ elm.removeAttribute(memberName);
377
+ }
378
+ }
379
+ }
380
+ else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
381
+ newValue = newValue === true ? '' : newValue;
382
+ {
383
+ elm.setAttribute(memberName, newValue);
384
+ }
385
+ }
386
+ }
387
+ }
388
+ };
389
+ const parseClassListRegex = /\s/;
390
+ const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
391
+ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
392
+ // if the element passed in is a shadow root, which is a document fragment
393
+ // then we want to be adding attrs/props to the shadow root's "host" element
394
+ // if it's not a shadow root, then we add attrs/props to the same element
395
+ const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host
396
+ ? newVnode.$elm$.host
397
+ : newVnode.$elm$;
398
+ const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
399
+ const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
400
+ {
401
+ // remove attributes no longer present on the vnode by setting them to undefined
402
+ for (memberName in oldVnodeAttrs) {
403
+ if (!(memberName in newVnodeAttrs)) {
404
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
405
+ }
406
+ }
407
+ }
408
+ // add new & update changed attributes
409
+ for (memberName in newVnodeAttrs) {
410
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
411
+ }
412
+ };
413
+ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
414
+ // tslint:disable-next-line: prefer-const
415
+ let newVNode = newParentVNode.$children$[childIndex];
416
+ let i = 0;
417
+ let elm;
418
+ let childNode;
419
+ let oldVNode;
420
+ if (!useNativeShadowDom) {
421
+ // remember for later we need to check to relocate nodes
422
+ checkSlotRelocate = true;
423
+ if (newVNode.$tag$ === 'slot') {
424
+ if (scopeId) {
425
+ // scoped css needs to add its scoped id to the parent element
426
+ parentElm.classList.add(scopeId + '-s');
427
+ }
428
+ newVNode.$flags$ |= newVNode.$children$
429
+ ? // slot element has fallback content
430
+ 2 /* isSlotFallback */
431
+ : // slot element does not have fallback content
432
+ 1 /* isSlotReference */;
433
+ }
434
+ }
435
+ if (newVNode.$text$ !== null) {
436
+ // create text node
437
+ elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
438
+ }
439
+ else if (newVNode.$flags$ & 1 /* isSlotReference */) {
440
+ // create a slot reference node
441
+ elm = newVNode.$elm$ =
442
+ doc.createTextNode('');
443
+ }
444
+ else {
445
+ if (!isSvgMode) {
446
+ isSvgMode = newVNode.$tag$ === 'svg';
447
+ }
448
+ // create element
449
+ elm = newVNode.$elm$ = (doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, newVNode.$flags$ & 2 /* isSlotFallback */
450
+ ? 'slot-fb'
451
+ : newVNode.$tag$)
452
+ );
453
+ if (isSvgMode && newVNode.$tag$ === 'foreignObject') {
454
+ isSvgMode = false;
455
+ }
456
+ // add css classes, attrs, props, listeners, etc.
457
+ {
458
+ updateElement(null, newVNode, isSvgMode);
459
+ }
460
+ if (isDef(scopeId) && elm['s-si'] !== scopeId) {
461
+ // if there is a scopeId and this is the initial render
462
+ // then let's add the scopeId as a css class
463
+ elm.classList.add((elm['s-si'] = scopeId));
464
+ }
465
+ if (newVNode.$children$) {
466
+ for (i = 0; i < newVNode.$children$.length; ++i) {
467
+ // create the node
468
+ childNode = createElm(oldParentVNode, newVNode, i, elm);
469
+ // return node could have been null
470
+ if (childNode) {
471
+ // append our new node
472
+ elm.appendChild(childNode);
473
+ }
474
+ }
475
+ }
476
+ {
477
+ if (newVNode.$tag$ === 'svg') {
478
+ // Only reset the SVG context when we're exiting <svg> element
479
+ isSvgMode = false;
480
+ }
481
+ else if (elm.tagName === 'foreignObject') {
482
+ // Reenter SVG context when we're exiting <foreignObject> element
483
+ isSvgMode = true;
484
+ }
485
+ }
486
+ }
487
+ {
488
+ elm['s-hn'] = hostTagName;
489
+ if (newVNode.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
490
+ // remember the content reference comment
491
+ elm['s-sr'] = true;
492
+ // remember the content reference comment
493
+ elm['s-cr'] = contentRef;
494
+ // remember the slot name, or empty string for default slot
495
+ elm['s-sn'] = newVNode.$name$ || '';
496
+ // check if we've got an old vnode for this slot
497
+ oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
498
+ if (oldVNode && oldVNode.$tag$ === newVNode.$tag$ && oldParentVNode.$elm$) {
499
+ // we've got an old slot vnode and the wrapper is being replaced
500
+ // so let's move the old slot content back to it's original location
501
+ putBackInOriginalLocation(oldParentVNode.$elm$, false);
502
+ }
503
+ }
504
+ }
505
+ return elm;
506
+ };
507
+ const putBackInOriginalLocation = (parentElm, recursive) => {
508
+ plt.$flags$ |= 1 /* isTmpDisconnected */;
509
+ const oldSlotChildNodes = parentElm.childNodes;
510
+ for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
511
+ const childNode = oldSlotChildNodes[i];
512
+ if (childNode['s-hn'] !== hostTagName && childNode['s-ol']) {
513
+ // // this child node in the old element is from another component
514
+ // // remove this node from the old slot's parent
515
+ // childNode.remove();
516
+ // and relocate it back to it's original location
517
+ parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
518
+ // remove the old original location comment entirely
519
+ // later on the patch function will know what to do
520
+ // and move this to the correct spot in need be
521
+ childNode['s-ol'].remove();
522
+ childNode['s-ol'] = undefined;
523
+ checkSlotRelocate = true;
524
+ }
525
+ if (recursive) {
526
+ putBackInOriginalLocation(childNode, recursive);
527
+ }
528
+ }
529
+ plt.$flags$ &= ~1 /* isTmpDisconnected */;
530
+ };
531
+ const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
532
+ let containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
533
+ let childNode;
534
+ if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
535
+ containerElm = containerElm.shadowRoot;
536
+ }
537
+ for (; startIdx <= endIdx; ++startIdx) {
538
+ if (vnodes[startIdx]) {
539
+ childNode = createElm(null, parentVNode, startIdx, parentElm);
540
+ if (childNode) {
541
+ vnodes[startIdx].$elm$ = childNode;
542
+ containerElm.insertBefore(childNode, referenceNode(before) );
543
+ }
544
+ }
545
+ }
546
+ };
547
+ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
548
+ for (; startIdx <= endIdx; ++startIdx) {
549
+ if ((vnode = vnodes[startIdx])) {
550
+ elm = vnode.$elm$;
551
+ callNodeRefs(vnode);
552
+ {
553
+ // we're removing this element
554
+ // so it's possible we need to show slot fallback content now
555
+ checkSlotFallbackVisibility = true;
556
+ if (elm['s-ol']) {
557
+ // remove the original location comment
558
+ elm['s-ol'].remove();
559
+ }
560
+ else {
561
+ // it's possible that child nodes of the node
562
+ // that's being removed are slot nodes
563
+ putBackInOriginalLocation(elm, true);
564
+ }
565
+ }
566
+ // remove the vnode's element from the dom
567
+ elm.remove();
568
+ }
569
+ }
570
+ };
571
+ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
572
+ let oldStartIdx = 0;
573
+ let newStartIdx = 0;
574
+ let oldEndIdx = oldCh.length - 1;
575
+ let oldStartVnode = oldCh[0];
576
+ let oldEndVnode = oldCh[oldEndIdx];
577
+ let newEndIdx = newCh.length - 1;
578
+ let newStartVnode = newCh[0];
579
+ let newEndVnode = newCh[newEndIdx];
580
+ let node;
581
+ while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
582
+ if (oldStartVnode == null) {
583
+ // Vnode might have been moved left
584
+ oldStartVnode = oldCh[++oldStartIdx];
585
+ }
586
+ else if (oldEndVnode == null) {
587
+ oldEndVnode = oldCh[--oldEndIdx];
588
+ }
589
+ else if (newStartVnode == null) {
590
+ newStartVnode = newCh[++newStartIdx];
591
+ }
592
+ else if (newEndVnode == null) {
593
+ newEndVnode = newCh[--newEndIdx];
594
+ }
595
+ else if (isSameVnode(oldStartVnode, newStartVnode)) {
596
+ patch(oldStartVnode, newStartVnode);
597
+ oldStartVnode = oldCh[++oldStartIdx];
598
+ newStartVnode = newCh[++newStartIdx];
599
+ }
600
+ else if (isSameVnode(oldEndVnode, newEndVnode)) {
601
+ patch(oldEndVnode, newEndVnode);
602
+ oldEndVnode = oldCh[--oldEndIdx];
603
+ newEndVnode = newCh[--newEndIdx];
604
+ }
605
+ else if (isSameVnode(oldStartVnode, newEndVnode)) {
606
+ // Vnode moved right
607
+ if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
608
+ putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
609
+ }
610
+ patch(oldStartVnode, newEndVnode);
611
+ parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
612
+ oldStartVnode = oldCh[++oldStartIdx];
613
+ newEndVnode = newCh[--newEndIdx];
614
+ }
615
+ else if (isSameVnode(oldEndVnode, newStartVnode)) {
616
+ // Vnode moved left
617
+ if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
618
+ putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
619
+ }
620
+ patch(oldEndVnode, newStartVnode);
621
+ parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
622
+ oldEndVnode = oldCh[--oldEndIdx];
623
+ newStartVnode = newCh[++newStartIdx];
624
+ }
625
+ else {
626
+ {
627
+ // new element
628
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx, parentElm);
629
+ newStartVnode = newCh[++newStartIdx];
630
+ }
631
+ if (node) {
632
+ {
633
+ parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
634
+ }
635
+ }
636
+ }
637
+ }
638
+ if (oldStartIdx > oldEndIdx) {
639
+ addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
640
+ }
641
+ else if (newStartIdx > newEndIdx) {
642
+ removeVnodes(oldCh, oldStartIdx, oldEndIdx);
643
+ }
644
+ };
645
+ const isSameVnode = (vnode1, vnode2) => {
646
+ // compare if two vnode to see if they're "technically" the same
647
+ // need to have the same element tag, and same key to be the same
648
+ if (vnode1.$tag$ === vnode2.$tag$) {
649
+ if (vnode1.$tag$ === 'slot') {
650
+ return vnode1.$name$ === vnode2.$name$;
651
+ }
652
+ return true;
653
+ }
654
+ return false;
655
+ };
656
+ const referenceNode = (node) => {
657
+ // this node was relocated to a new location in the dom
658
+ // because of some other component's slot
659
+ // but we still have an html comment in place of where
660
+ // it's original location was according to it's original vdom
661
+ return (node && node['s-ol']) || node;
662
+ };
663
+ const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
664
+ const patch = (oldVNode, newVNode) => {
665
+ const elm = (newVNode.$elm$ = oldVNode.$elm$);
666
+ const oldChildren = oldVNode.$children$;
667
+ const newChildren = newVNode.$children$;
668
+ const tag = newVNode.$tag$;
669
+ const text = newVNode.$text$;
670
+ let defaultHolder;
671
+ if (text === null) {
672
+ {
673
+ // test if we're rendering an svg element, or still rendering nodes inside of one
674
+ // only add this to the when the compiler sees we're using an svg somewhere
675
+ isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
676
+ }
677
+ // element node
678
+ {
679
+ if (tag === 'slot')
680
+ ;
681
+ else {
682
+ // either this is the first render of an element OR it's an update
683
+ // AND we already know it's possible it could have changed
684
+ // this updates the element's css classes, attrs, props, listeners, etc.
685
+ updateElement(oldVNode, newVNode, isSvgMode);
686
+ }
687
+ }
688
+ if (oldChildren !== null && newChildren !== null) {
689
+ // looks like there's child vnodes for both the old and new vnodes
690
+ updateChildren(elm, oldChildren, newVNode, newChildren);
691
+ }
692
+ else if (newChildren !== null) {
693
+ // no old child vnodes, but there are new child vnodes to add
694
+ if (oldVNode.$text$ !== null) {
695
+ // the old vnode was text, so be sure to clear it out
696
+ elm.textContent = '';
697
+ }
698
+ // add the new vnode children
699
+ addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
700
+ }
701
+ else if (oldChildren !== null) {
702
+ // no new child vnodes, but there are old child vnodes to remove
703
+ removeVnodes(oldChildren, 0, oldChildren.length - 1);
704
+ }
705
+ if (isSvgMode && tag === 'svg') {
706
+ isSvgMode = false;
707
+ }
708
+ }
709
+ else if ((defaultHolder = elm['s-cr'])) {
710
+ // this element has slotted content
711
+ defaultHolder.parentNode.textContent = text;
712
+ }
713
+ else if (oldVNode.$text$ !== text) {
714
+ // update the text content for the text only vnode
715
+ // and also only if the text is different than before
716
+ elm.data = text;
717
+ }
718
+ };
719
+ const updateFallbackSlotVisibility = (elm) => {
720
+ // tslint:disable-next-line: prefer-const
721
+ let childNodes = elm.childNodes;
722
+ let childNode;
723
+ let i;
724
+ let ilen;
725
+ let j;
726
+ let slotNameAttr;
727
+ let nodeType;
728
+ for (i = 0, ilen = childNodes.length; i < ilen; i++) {
729
+ childNode = childNodes[i];
730
+ if (childNode.nodeType === 1 /* ElementNode */) {
731
+ if (childNode['s-sr']) {
732
+ // this is a slot fallback node
733
+ // get the slot name for this slot reference node
734
+ slotNameAttr = childNode['s-sn'];
735
+ // by default always show a fallback slot node
736
+ // then hide it if there are other slots in the light dom
737
+ childNode.hidden = false;
738
+ for (j = 0; j < ilen; j++) {
739
+ nodeType = childNodes[j].nodeType;
740
+ if (childNodes[j]['s-hn'] !== childNode['s-hn'] || slotNameAttr !== '') {
741
+ // this sibling node is from a different component OR is a named fallback slot node
742
+ if (nodeType === 1 /* ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
743
+ childNode.hidden = true;
744
+ break;
745
+ }
746
+ }
747
+ else {
748
+ // this is a default fallback slot node
749
+ // any element or text node (with content)
750
+ // should hide the default fallback slot node
751
+ if (nodeType === 1 /* ElementNode */ ||
752
+ (nodeType === 3 /* TextNode */ && childNodes[j].textContent.trim() !== '')) {
753
+ childNode.hidden = true;
754
+ break;
755
+ }
756
+ }
757
+ }
758
+ }
759
+ // keep drilling down
760
+ updateFallbackSlotVisibility(childNode);
761
+ }
762
+ }
763
+ };
764
+ const relocateNodes = [];
765
+ const relocateSlotContent = (elm) => {
766
+ // tslint:disable-next-line: prefer-const
767
+ let childNode;
768
+ let node;
769
+ let hostContentNodes;
770
+ let slotNameAttr;
771
+ let relocateNodeData;
772
+ let j;
773
+ let i = 0;
774
+ let childNodes = elm.childNodes;
775
+ let ilen = childNodes.length;
776
+ for (; i < ilen; i++) {
777
+ childNode = childNodes[i];
778
+ if (childNode['s-sr'] && (node = childNode['s-cr']) && node.parentNode) {
779
+ // first got the content reference comment node
780
+ // then we got it's parent, which is where all the host content is in now
781
+ hostContentNodes = node.parentNode.childNodes;
782
+ slotNameAttr = childNode['s-sn'];
783
+ for (j = hostContentNodes.length - 1; j >= 0; j--) {
784
+ node = hostContentNodes[j];
785
+ if (!node['s-cn'] && !node['s-nr'] && node['s-hn'] !== childNode['s-hn']) {
786
+ // let's do some relocating to its new home
787
+ // but never relocate a content reference node
788
+ // that is suppose to always represent the original content location
789
+ if (isNodeLocatedInSlot(node, slotNameAttr)) {
790
+ // it's possible we've already decided to relocate this node
791
+ relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
792
+ // made some changes to slots
793
+ // let's make sure we also double check
794
+ // fallbacks are correctly hidden or shown
795
+ checkSlotFallbackVisibility = true;
796
+ node['s-sn'] = node['s-sn'] || slotNameAttr;
797
+ if (relocateNodeData) {
798
+ // previously we never found a slot home for this node
799
+ // but turns out we did, so let's remember it now
800
+ relocateNodeData.$slotRefNode$ = childNode;
801
+ }
802
+ else {
803
+ // add to our list of nodes to relocate
804
+ relocateNodes.push({
805
+ $slotRefNode$: childNode,
806
+ $nodeToRelocate$: node,
807
+ });
808
+ }
809
+ if (node['s-sr']) {
810
+ relocateNodes.map((relocateNode) => {
811
+ if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node['s-sn'])) {
812
+ relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
813
+ if (relocateNodeData && !relocateNode.$slotRefNode$) {
814
+ relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
815
+ }
816
+ }
817
+ });
818
+ }
819
+ }
820
+ else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
821
+ // so far this element does not have a slot home, not setting slotRefNode on purpose
822
+ // if we never find a home for this element then we'll need to hide it
823
+ relocateNodes.push({
824
+ $nodeToRelocate$: node,
825
+ });
826
+ }
827
+ }
828
+ }
829
+ }
830
+ if (childNode.nodeType === 1 /* ElementNode */) {
831
+ relocateSlotContent(childNode);
832
+ }
833
+ }
834
+ };
835
+ const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
836
+ if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
837
+ if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
838
+ return true;
839
+ }
840
+ if (nodeToRelocate.getAttribute('slot') === slotNameAttr) {
841
+ return true;
842
+ }
843
+ return false;
844
+ }
845
+ if (nodeToRelocate['s-sn'] === slotNameAttr) {
846
+ return true;
847
+ }
848
+ return slotNameAttr === '';
849
+ };
850
+ const callNodeRefs = (vNode) => {
851
+ {
852
+ vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
853
+ vNode.$children$ && vNode.$children$.map(callNodeRefs);
854
+ }
855
+ };
856
+ const renderVdom = (hostRef, renderFnResults) => {
857
+ const hostElm = hostRef.$hostElement$;
858
+ const cmpMeta = hostRef.$cmpMeta$;
859
+ const oldVNode = hostRef.$vnode$ || newVNode(null, null);
860
+ const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
861
+ hostTagName = hostElm.tagName;
862
+ if (cmpMeta.$attrsToReflect$) {
863
+ rootVnode.$attrs$ = rootVnode.$attrs$ || {};
864
+ cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
865
+ }
866
+ rootVnode.$tag$ = null;
867
+ rootVnode.$flags$ |= 4 /* isHost */;
868
+ hostRef.$vnode$ = rootVnode;
869
+ rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
870
+ {
871
+ scopeId = hostElm['s-sc'];
872
+ }
873
+ {
874
+ contentRef = hostElm['s-cr'];
875
+ useNativeShadowDom = supportsShadow && (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) !== 0;
876
+ // always reset
877
+ checkSlotFallbackVisibility = false;
878
+ }
879
+ // synchronous patch
880
+ patch(oldVNode, rootVnode);
881
+ {
882
+ // while we're moving nodes around existing nodes, temporarily disable
883
+ // the disconnectCallback from working
884
+ plt.$flags$ |= 1 /* isTmpDisconnected */;
885
+ if (checkSlotRelocate) {
886
+ relocateSlotContent(rootVnode.$elm$);
887
+ let relocateData;
888
+ let nodeToRelocate;
889
+ let orgLocationNode;
890
+ let parentNodeRef;
891
+ let insertBeforeNode;
892
+ let refNode;
893
+ let i = 0;
894
+ for (; i < relocateNodes.length; i++) {
895
+ relocateData = relocateNodes[i];
896
+ nodeToRelocate = relocateData.$nodeToRelocate$;
897
+ if (!nodeToRelocate['s-ol']) {
898
+ // add a reference node marking this node's original location
899
+ // keep a reference to this node for later lookups
900
+ orgLocationNode =
901
+ doc.createTextNode('');
902
+ orgLocationNode['s-nr'] = nodeToRelocate;
903
+ nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
904
+ }
905
+ }
906
+ for (i = 0; i < relocateNodes.length; i++) {
907
+ relocateData = relocateNodes[i];
908
+ nodeToRelocate = relocateData.$nodeToRelocate$;
909
+ if (relocateData.$slotRefNode$) {
910
+ // by default we're just going to insert it directly
911
+ // after the slot reference node
912
+ parentNodeRef = relocateData.$slotRefNode$.parentNode;
913
+ insertBeforeNode = relocateData.$slotRefNode$.nextSibling;
914
+ orgLocationNode = nodeToRelocate['s-ol'];
915
+ while ((orgLocationNode = orgLocationNode.previousSibling)) {
916
+ refNode = orgLocationNode['s-nr'];
917
+ if (refNode && refNode['s-sn'] === nodeToRelocate['s-sn'] && parentNodeRef === refNode.parentNode) {
918
+ refNode = refNode.nextSibling;
919
+ if (!refNode || !refNode['s-nr']) {
920
+ insertBeforeNode = refNode;
921
+ break;
922
+ }
923
+ }
924
+ }
925
+ if ((!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode) ||
926
+ nodeToRelocate.nextSibling !== insertBeforeNode) {
927
+ // we've checked that it's worth while to relocate
928
+ // since that the node to relocate
929
+ // has a different next sibling or parent relocated
930
+ if (nodeToRelocate !== insertBeforeNode) {
931
+ if (!nodeToRelocate['s-hn'] && nodeToRelocate['s-ol']) {
932
+ // probably a component in the index.html that doesn't have it's hostname set
933
+ nodeToRelocate['s-hn'] = nodeToRelocate['s-ol'].parentNode.nodeName;
934
+ }
935
+ // add it back to the dom but in its new home
936
+ parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode);
937
+ }
938
+ }
939
+ }
940
+ else {
941
+ // this node doesn't have a slot home to go to, so let's hide it
942
+ if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
943
+ nodeToRelocate.hidden = true;
944
+ }
945
+ }
946
+ }
947
+ }
948
+ if (checkSlotFallbackVisibility) {
949
+ updateFallbackSlotVisibility(rootVnode.$elm$);
950
+ }
951
+ // done moving nodes around
952
+ // allow the disconnect callback to work again
953
+ plt.$flags$ &= ~1 /* isTmpDisconnected */;
954
+ // always reset
955
+ relocateNodes.length = 0;
956
+ }
957
+ };
958
+ const getElement = (ref) => (getHostRef(ref).$hostElement$ );
959
+ const createEvent = (ref, name, flags) => {
960
+ const elm = getElement(ref);
961
+ return {
962
+ emit: (detail) => {
963
+ return emitEvent(elm, name, {
964
+ bubbles: !!(flags & 4 /* Bubbles */),
965
+ composed: !!(flags & 2 /* Composed */),
966
+ cancelable: !!(flags & 1 /* Cancellable */),
967
+ detail,
968
+ });
969
+ },
970
+ };
971
+ };
972
+ /**
973
+ * Helper function to create & dispatch a custom Event on a provided target
974
+ * @param elm the target of the Event
975
+ * @param name the name to give the custom Event
976
+ * @param opts options for configuring a custom Event
977
+ * @returns the custom Event
978
+ */
979
+ const emitEvent = (elm, name, opts) => {
980
+ const ev = plt.ce(name, opts);
981
+ elm.dispatchEvent(ev);
982
+ return ev;
983
+ };
984
+ const attachToAncestor = (hostRef, ancestorComponent) => {
985
+ if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
986
+ ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
987
+ }
988
+ };
989
+ const scheduleUpdate = (hostRef, isInitialLoad) => {
990
+ {
991
+ hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
992
+ }
993
+ if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
994
+ hostRef.$flags$ |= 512 /* needsRerender */;
995
+ return;
996
+ }
997
+ attachToAncestor(hostRef, hostRef.$ancestorComponent$);
998
+ // there is no ancestor component or the ancestor component
999
+ // has already fired off its lifecycle update then
1000
+ // fire off the initial update
1001
+ const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
1002
+ return writeTask(dispatch) ;
1003
+ };
1004
+ const dispatchHooks = (hostRef, isInitialLoad) => {
1005
+ const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
1006
+ const instance = hostRef.$lazyInstance$ ;
1007
+ let promise;
1008
+ if (isInitialLoad) {
1009
+ {
1010
+ promise = safeCall(instance, 'componentWillLoad');
1011
+ }
1012
+ }
1013
+ endSchedule();
1014
+ return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
1015
+ };
1016
+ const updateComponent = async (hostRef, instance, isInitialLoad) => {
1017
+ // updateComponent
1018
+ const elm = hostRef.$hostElement$;
1019
+ const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
1020
+ const rc = elm['s-rc'];
1021
+ if (isInitialLoad) {
1022
+ // DOM WRITE!
1023
+ attachStyles(hostRef);
1024
+ }
1025
+ const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
1026
+ {
1027
+ callRender(hostRef, instance);
1028
+ }
1029
+ if (plt.$cssShim$) {
1030
+ plt.$cssShim$.updateHost(elm);
1031
+ }
1032
+ if (rc) {
1033
+ // ok, so turns out there are some child host elements
1034
+ // waiting on this parent element to load
1035
+ // let's fire off all update callbacks waiting
1036
+ rc.map((cb) => cb());
1037
+ elm['s-rc'] = undefined;
1038
+ }
1039
+ endRender();
1040
+ endUpdate();
1041
+ {
1042
+ const childrenPromises = elm['s-p'];
1043
+ const postUpdate = () => postUpdateComponent(hostRef);
1044
+ if (childrenPromises.length === 0) {
1045
+ postUpdate();
1046
+ }
1047
+ else {
1048
+ Promise.all(childrenPromises).then(postUpdate);
1049
+ hostRef.$flags$ |= 4 /* isWaitingForChildren */;
1050
+ childrenPromises.length = 0;
1051
+ }
1052
+ }
1053
+ };
1054
+ const callRender = (hostRef, instance, elm) => {
1055
+ try {
1056
+ instance = instance.render() ;
1057
+ {
1058
+ hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
1059
+ }
1060
+ {
1061
+ hostRef.$flags$ |= 2 /* hasRendered */;
1062
+ }
1063
+ {
1064
+ {
1065
+ // looks like we've got child nodes to render into this host element
1066
+ // or we need to update the css class/attrs on the host element
1067
+ // DOM WRITE!
1068
+ {
1069
+ renderVdom(hostRef, instance);
1070
+ }
1071
+ }
1072
+ }
1073
+ }
1074
+ catch (e) {
1075
+ consoleError(e, hostRef.$hostElement$);
1076
+ }
1077
+ return null;
1078
+ };
1079
+ const postUpdateComponent = (hostRef) => {
1080
+ const tagName = hostRef.$cmpMeta$.$tagName$;
1081
+ const elm = hostRef.$hostElement$;
1082
+ const endPostUpdate = createTime('postUpdate', tagName);
1083
+ const instance = hostRef.$lazyInstance$ ;
1084
+ const ancestorComponent = hostRef.$ancestorComponent$;
1085
+ if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
1086
+ hostRef.$flags$ |= 64 /* hasLoadedComponent */;
1087
+ {
1088
+ // DOM WRITE!
1089
+ addHydratedFlag(elm);
1090
+ }
1091
+ {
1092
+ safeCall(instance, 'componentDidLoad');
1093
+ }
1094
+ endPostUpdate();
1095
+ {
1096
+ hostRef.$onReadyResolve$(elm);
1097
+ if (!ancestorComponent) {
1098
+ appDidLoad();
1099
+ }
1100
+ }
1101
+ }
1102
+ else {
1103
+ endPostUpdate();
1104
+ }
1105
+ // load events fire from bottom to top
1106
+ // the deepest elements load first then bubbles up
1107
+ {
1108
+ if (hostRef.$onRenderResolve$) {
1109
+ hostRef.$onRenderResolve$();
1110
+ hostRef.$onRenderResolve$ = undefined;
1111
+ }
1112
+ if (hostRef.$flags$ & 512 /* needsRerender */) {
1113
+ nextTick(() => scheduleUpdate(hostRef, false));
1114
+ }
1115
+ hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
1116
+ }
1117
+ // ( •_•)
1118
+ // ( •_•)>⌐■-■
1119
+ // (⌐■_■)
1120
+ };
1121
+ const appDidLoad = (who) => {
1122
+ // on appload
1123
+ // we have finish the first big initial render
1124
+ {
1125
+ addHydratedFlag(doc.documentElement);
1126
+ }
1127
+ nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
1128
+ };
1129
+ const safeCall = (instance, method, arg) => {
1130
+ if (instance && instance[method]) {
1131
+ try {
1132
+ return instance[method](arg);
1133
+ }
1134
+ catch (e) {
1135
+ consoleError(e);
1136
+ }
1137
+ }
1138
+ return undefined;
1139
+ };
1140
+ const then = (promise, thenFn) => {
1141
+ return promise && promise.then ? promise.then(thenFn) : thenFn();
1142
+ };
1143
+ const addHydratedFlag = (elm) => elm.classList.add('hydrated')
1144
+ ;
1145
+ /**
1146
+ * Parse a new property value for a given property type.
1147
+ *
1148
+ * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
1149
+ * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
1150
+ * 1. `any`, the type given to `propValue` in the function signature
1151
+ * 2. the type stored from `propType`.
1152
+ *
1153
+ * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
1154
+ *
1155
+ * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
1156
+ * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
1157
+ * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
1158
+ * ```tsx
1159
+ * <my-cmp prop-val={0}></my-cmp>
1160
+ * ```
1161
+ *
1162
+ * HTML prop values on the other hand, will always a string
1163
+ *
1164
+ * @param propValue the new value to coerce to some type
1165
+ * @param propType the type of the prop, expressed as a binary number
1166
+ * @returns the parsed/coerced value
1167
+ */
1168
+ const parsePropertyValue = (propValue, propType) => {
1169
+ // ensure this value is of the correct prop type
1170
+ if (propValue != null && !isComplexType(propValue)) {
1171
+ if (propType & 4 /* Boolean */) {
1172
+ // per the HTML spec, any string value means it is a boolean true value
1173
+ // but we'll cheat here and say that the string "false" is the boolean false
1174
+ return propValue === 'false' ? false : propValue === '' || !!propValue;
1175
+ }
1176
+ if (propType & 2 /* Number */) {
1177
+ // force it to be a number
1178
+ return parseFloat(propValue);
1179
+ }
1180
+ if (propType & 1 /* String */) {
1181
+ // could have been passed as a number or boolean
1182
+ // but we still want it as a string
1183
+ return String(propValue);
1184
+ }
1185
+ // redundant return here for better minification
1186
+ return propValue;
1187
+ }
1188
+ // not sure exactly what type we want
1189
+ // so no need to change to a different type
1190
+ return propValue;
1191
+ };
1192
+ const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
1193
+ const setValue = (ref, propName, newVal, cmpMeta) => {
1194
+ // check our new property value against our internal value
1195
+ const hostRef = getHostRef(ref);
1196
+ const elm = hostRef.$hostElement$ ;
1197
+ const oldVal = hostRef.$instanceValues$.get(propName);
1198
+ const flags = hostRef.$flags$;
1199
+ const instance = hostRef.$lazyInstance$ ;
1200
+ newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
1201
+ // explicitly check for NaN on both sides, as `NaN === NaN` is always false
1202
+ const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
1203
+ const didValueChange = newVal !== oldVal && !areBothNaN;
1204
+ if ((!(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && didValueChange) {
1205
+ // gadzooks! the property's value has changed!!
1206
+ // set our new value!
1207
+ hostRef.$instanceValues$.set(propName, newVal);
1208
+ if (instance) {
1209
+ // get an array of method names of watch functions to call
1210
+ if (cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
1211
+ const watchMethods = cmpMeta.$watchers$[propName];
1212
+ if (watchMethods) {
1213
+ // this instance is watching for when this property changed
1214
+ watchMethods.map((watchMethodName) => {
1215
+ try {
1216
+ // fire off each of the watch methods that are watching this property
1217
+ instance[watchMethodName](newVal, oldVal, propName);
1218
+ }
1219
+ catch (e) {
1220
+ consoleError(e, elm);
1221
+ }
1222
+ });
1223
+ }
1224
+ }
1225
+ if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
1226
+ // looks like this value actually changed, so we've got work to do!
1227
+ // but only if we've already rendered, otherwise just chill out
1228
+ // queue that we need to do an update, but don't worry about queuing
1229
+ // up millions cuz this function ensures it only runs once
1230
+ scheduleUpdate(hostRef, false);
1231
+ }
1232
+ }
1233
+ }
1234
+ };
1235
+ const proxyComponent = (Cstr, cmpMeta, flags) => {
1236
+ if (cmpMeta.$members$) {
1237
+ if (Cstr.watchers) {
1238
+ cmpMeta.$watchers$ = Cstr.watchers;
1239
+ }
1240
+ // It's better to have a const than two Object.entries()
1241
+ const members = Object.entries(cmpMeta.$members$);
1242
+ const prototype = Cstr.prototype;
1243
+ members.map(([memberName, [memberFlags]]) => {
1244
+ if ((memberFlags & 31 /* Prop */ ||
1245
+ ((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
1246
+ // proxyComponent - prop
1247
+ Object.defineProperty(prototype, memberName, {
1248
+ get() {
1249
+ // proxyComponent, get value
1250
+ return getValue(this, memberName);
1251
+ },
1252
+ set(newValue) {
1253
+ // proxyComponent, set value
1254
+ setValue(this, memberName, newValue, cmpMeta);
1255
+ },
1256
+ configurable: true,
1257
+ enumerable: true,
1258
+ });
1259
+ }
1260
+ });
1261
+ if ((flags & 1 /* isElementConstructor */)) {
1262
+ const attrNameToPropName = new Map();
1263
+ prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
1264
+ plt.jmp(() => {
1265
+ const propName = attrNameToPropName.get(attrName);
1266
+ // In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
1267
+ // in the case where an attribute was set inline.
1268
+ // ```html
1269
+ // <my-component some-attribute="some-value"></my-component>
1270
+ // ```
1271
+ //
1272
+ // There is an edge case where a developer sets the attribute inline on a custom element and then
1273
+ // programmatically changes it before it has been upgraded as shown below:
1274
+ //
1275
+ // ```html
1276
+ // <!-- this component has _not_ been upgraded yet -->
1277
+ // <my-component id="test" some-attribute="some-value"></my-component>
1278
+ // <script>
1279
+ // // grab non-upgraded component
1280
+ // el = document.querySelector("#test");
1281
+ // el.someAttribute = "another-value";
1282
+ // // upgrade component
1283
+ // customElements.define('my-component', MyComponent);
1284
+ // </script>
1285
+ // ```
1286
+ // In this case if we do not unshadow here and use the value of the shadowing property, attributeChangedCallback
1287
+ // will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
1288
+ // to the value that was set inline i.e. "some-value" from above example. When
1289
+ // the connectedCallback attempts to unshadow it will use "some-value" as the initial value rather than "another-value"
1290
+ //
1291
+ // The case where the attribute was NOT set inline but was not set programmatically shall be handled/unshadowed
1292
+ // by connectedCallback as this attributeChangedCallback will not fire.
1293
+ //
1294
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1295
+ //
1296
+ // TODO(STENCIL-16) we should think about whether or not we actually want to be reflecting the attributes to
1297
+ // properties here given that this goes against best practices outlined here
1298
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy
1299
+ if (this.hasOwnProperty(propName)) {
1300
+ newValue = this[propName];
1301
+ delete this[propName];
1302
+ }
1303
+ else if (prototype.hasOwnProperty(propName) &&
1304
+ typeof this[propName] === 'number' &&
1305
+ this[propName] == newValue) {
1306
+ // if the propName exists on the prototype of `Cstr`, this update may be a result of Stencil using native
1307
+ // APIs to reflect props as attributes. Calls to `setAttribute(someElement, propName)` will result in
1308
+ // `propName` to be converted to a `DOMString`, which may not be what we want for other primitive props.
1309
+ return;
1310
+ }
1311
+ this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
1312
+ });
1313
+ };
1314
+ // create an array of attributes to observe
1315
+ // and also create a map of html attribute name to js property name
1316
+ Cstr.observedAttributes = members
1317
+ .filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
1318
+ .map(([propName, m]) => {
1319
+ const attrName = m[1] || propName;
1320
+ attrNameToPropName.set(attrName, propName);
1321
+ if (m[0] & 512 /* ReflectAttr */) {
1322
+ cmpMeta.$attrsToReflect$.push([propName, attrName]);
1323
+ }
1324
+ return attrName;
1325
+ });
1326
+ }
1327
+ }
1328
+ return Cstr;
1329
+ };
1330
+ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
1331
+ // initializeComponent
1332
+ if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
1333
+ {
1334
+ // we haven't initialized this element yet
1335
+ hostRef.$flags$ |= 32 /* hasInitializedComponent */;
1336
+ // lazy loaded components
1337
+ // request the component's implementation to be
1338
+ // wired up with the host element
1339
+ Cstr = loadModule(cmpMeta);
1340
+ if (Cstr.then) {
1341
+ // Await creates a micro-task avoid if possible
1342
+ const endLoad = uniqueTime();
1343
+ Cstr = await Cstr;
1344
+ endLoad();
1345
+ }
1346
+ if (!Cstr.isProxied) {
1347
+ // we've never proxied this Constructor before
1348
+ // let's add the getters/setters to its prototype before
1349
+ // the first time we create an instance of the implementation
1350
+ {
1351
+ cmpMeta.$watchers$ = Cstr.watchers;
1352
+ }
1353
+ proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
1354
+ Cstr.isProxied = true;
1355
+ }
1356
+ const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
1357
+ // ok, time to construct the instance
1358
+ // but let's keep track of when we start and stop
1359
+ // so that the getters/setters don't incorrectly step on data
1360
+ {
1361
+ hostRef.$flags$ |= 8 /* isConstructingInstance */;
1362
+ }
1363
+ // construct the lazy-loaded component implementation
1364
+ // passing the hostRef is very important during
1365
+ // construction in order to directly wire together the
1366
+ // host element and the lazy-loaded instance
1367
+ try {
1368
+ new Cstr(hostRef);
1369
+ }
1370
+ catch (e) {
1371
+ consoleError(e);
1372
+ }
1373
+ {
1374
+ hostRef.$flags$ &= ~8 /* isConstructingInstance */;
1375
+ }
1376
+ {
1377
+ hostRef.$flags$ |= 128 /* isWatchReady */;
1378
+ }
1379
+ endNewInstance();
1380
+ }
1381
+ if (Cstr.style) {
1382
+ // this component has styles but we haven't registered them yet
1383
+ let style = Cstr.style;
1384
+ const scopeId = getScopeId(cmpMeta);
1385
+ if (!styles.has(scopeId)) {
1386
+ const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
1387
+ if (cmpMeta.$flags$ & 8 /* needsShadowDomShim */) {
1388
+ style = await Promise.resolve().then(function () { return require('./shadow-css-8940f82d.js'); }).then((m) => m.scopeCss(style, scopeId, false));
1389
+ }
1390
+ registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
1391
+ endRegisterStyles();
1392
+ }
1393
+ }
1394
+ }
1395
+ // we've successfully created a lazy instance
1396
+ const ancestorComponent = hostRef.$ancestorComponent$;
1397
+ const schedule = () => scheduleUpdate(hostRef, true);
1398
+ if (ancestorComponent && ancestorComponent['s-rc']) {
1399
+ // this is the initial load and this component it has an ancestor component
1400
+ // but the ancestor component has NOT fired its will update lifecycle yet
1401
+ // so let's just cool our jets and wait for the ancestor to continue first
1402
+ // this will get fired off when the ancestor component
1403
+ // finally gets around to rendering its lazy self
1404
+ // fire off the initial update
1405
+ ancestorComponent['s-rc'].push(schedule);
1406
+ }
1407
+ else {
1408
+ schedule();
1409
+ }
1410
+ };
1411
+ const connectedCallback = (elm) => {
1412
+ if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1413
+ const hostRef = getHostRef(elm);
1414
+ const cmpMeta = hostRef.$cmpMeta$;
1415
+ const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
1416
+ if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
1417
+ // first time this component has connected
1418
+ hostRef.$flags$ |= 1 /* hasConnected */;
1419
+ {
1420
+ // initUpdate
1421
+ // if the slot polyfill is required we'll need to put some nodes
1422
+ // in here to act as original content anchors as we move nodes around
1423
+ // host element has been connected to the DOM
1424
+ if ((cmpMeta.$flags$ & (4 /* hasSlotRelocation */ | 8 /* needsShadowDomShim */))) {
1425
+ setContentReference(elm);
1426
+ }
1427
+ }
1428
+ {
1429
+ // find the first ancestor component (if there is one) and register
1430
+ // this component as one of the actively loading child components for its ancestor
1431
+ let ancestorComponent = elm;
1432
+ while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
1433
+ // climb up the ancestors looking for the first
1434
+ // component that hasn't finished its lifecycle update yet
1435
+ if (ancestorComponent['s-p']) {
1436
+ // we found this components first ancestor component
1437
+ // keep a reference to this component's ancestor component
1438
+ attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
1439
+ break;
1440
+ }
1441
+ }
1442
+ }
1443
+ // Lazy properties
1444
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1445
+ if (cmpMeta.$members$) {
1446
+ Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
1447
+ if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
1448
+ const value = elm[memberName];
1449
+ delete elm[memberName];
1450
+ elm[memberName] = value;
1451
+ }
1452
+ });
1453
+ }
1454
+ {
1455
+ initializeComponent(elm, hostRef, cmpMeta);
1456
+ }
1457
+ }
1458
+ endConnected();
1459
+ }
1460
+ };
1461
+ const setContentReference = (elm) => {
1462
+ // only required when we're NOT using native shadow dom (slot)
1463
+ // or this browser doesn't support native shadow dom
1464
+ // and this host element was NOT created with SSR
1465
+ // let's pick out the inner content for slot projection
1466
+ // create a node to represent where the original
1467
+ // content was first placed, which is useful later on
1468
+ const contentRefElm = (elm['s-cr'] = doc.createComment(''));
1469
+ contentRefElm['s-cn'] = true;
1470
+ elm.insertBefore(contentRefElm, elm.firstChild);
1471
+ };
1472
+ const disconnectedCallback = (elm) => {
1473
+ if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1474
+ getHostRef(elm);
1475
+ // clear CSS var-shim tracking
1476
+ if (plt.$cssShim$) {
1477
+ plt.$cssShim$.removeHost(elm);
1478
+ }
1479
+ }
1480
+ };
1481
+ const bootstrapLazy = (lazyBundles, options = {}) => {
1482
+ const endBootstrap = createTime();
1483
+ const cmpTags = [];
1484
+ const exclude = options.exclude || [];
1485
+ const customElements = win.customElements;
1486
+ const head = doc.head;
1487
+ const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
1488
+ const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
1489
+ const deferredConnectedCallbacks = [];
1490
+ let appLoadFallback;
1491
+ let isBootstrapping = true;
1492
+ Object.assign(plt, options);
1493
+ plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
1494
+ lazyBundles.map((lazyBundle) => {
1495
+ lazyBundle[1].map((compactMeta) => {
1496
+ const cmpMeta = {
1497
+ $flags$: compactMeta[0],
1498
+ $tagName$: compactMeta[1],
1499
+ $members$: compactMeta[2],
1500
+ $listeners$: compactMeta[3],
1501
+ };
1502
+ {
1503
+ cmpMeta.$members$ = compactMeta[2];
1504
+ }
1505
+ {
1506
+ cmpMeta.$attrsToReflect$ = [];
1507
+ }
1508
+ {
1509
+ cmpMeta.$watchers$ = {};
1510
+ }
1511
+ if (!supportsShadow && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
1512
+ cmpMeta.$flags$ |= 8 /* needsShadowDomShim */;
1513
+ }
1514
+ const tagName = cmpMeta.$tagName$;
1515
+ const HostElement = class extends HTMLElement {
1516
+ // StencilLazyHost
1517
+ constructor(self) {
1518
+ // @ts-ignore
1519
+ super(self);
1520
+ self = this;
1521
+ registerHost(self, cmpMeta);
1522
+ if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
1523
+ // this component is using shadow dom
1524
+ // and this browser supports shadow dom
1525
+ // add the read-only property "shadowRoot" to the host element
1526
+ // adding the shadow root build conditionals to minimize runtime
1527
+ if (supportsShadow) {
1528
+ {
1529
+ self.attachShadow({ mode: 'open' });
1530
+ }
1531
+ }
1532
+ else if (!('shadowRoot' in self)) {
1533
+ self.shadowRoot = self;
1534
+ }
1535
+ }
1536
+ }
1537
+ connectedCallback() {
1538
+ if (appLoadFallback) {
1539
+ clearTimeout(appLoadFallback);
1540
+ appLoadFallback = null;
1541
+ }
1542
+ if (isBootstrapping) {
1543
+ // connectedCallback will be processed once all components have been registered
1544
+ deferredConnectedCallbacks.push(this);
1545
+ }
1546
+ else {
1547
+ plt.jmp(() => connectedCallback(this));
1548
+ }
1549
+ }
1550
+ disconnectedCallback() {
1551
+ plt.jmp(() => disconnectedCallback(this));
1552
+ }
1553
+ componentOnReady() {
1554
+ return getHostRef(this).$onReadyPromise$;
1555
+ }
1556
+ };
1557
+ cmpMeta.$lazyBundleId$ = lazyBundle[0];
1558
+ if (!exclude.includes(tagName) && !customElements.get(tagName)) {
1559
+ cmpTags.push(tagName);
1560
+ customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
1561
+ }
1562
+ });
1563
+ });
1564
+ {
1565
+ visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
1566
+ visibilityStyle.setAttribute('data-styles', '');
1567
+ head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
1568
+ }
1569
+ // Process deferred connectedCallbacks now all components have been registered
1570
+ isBootstrapping = false;
1571
+ if (deferredConnectedCallbacks.length) {
1572
+ deferredConnectedCallbacks.map((host) => host.connectedCallback());
1573
+ }
1574
+ else {
1575
+ {
1576
+ plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
1577
+ }
1578
+ }
1579
+ // Fallback appLoad event
1580
+ endBootstrap();
1581
+ };
1582
+ const hostRefs = new WeakMap();
1583
+ const getHostRef = (ref) => hostRefs.get(ref);
1584
+ const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
1585
+ const registerHost = (elm, cmpMeta) => {
1586
+ const hostRef = {
1587
+ $flags$: 0,
1588
+ $hostElement$: elm,
1589
+ $cmpMeta$: cmpMeta,
1590
+ $instanceValues$: new Map(),
1591
+ };
1592
+ {
1593
+ hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
1594
+ elm['s-p'] = [];
1595
+ elm['s-rc'] = [];
1596
+ }
1597
+ return hostRefs.set(elm, hostRef);
1598
+ };
1599
+ const isMemberInElement = (elm, memberName) => memberName in elm;
1600
+ const consoleError = (e, el) => (0, console.error)(e, el);
1601
+ const cmpModules = /*@__PURE__*/ new Map();
1602
+ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1603
+ // loadModuleImport
1604
+ const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
1605
+ const bundleId = cmpMeta.$lazyBundleId$;
1606
+ const module = cmpModules.get(bundleId) ;
1607
+ if (module) {
1608
+ return module[exportName];
1609
+ }
1610
+ return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
1611
+ /* webpackInclude: /\.entry\.js$/ */
1612
+ /* webpackExclude: /\.system\.entry\.js$/ */
1613
+ /* webpackMode: "lazy" */
1614
+ `./${bundleId}.entry.js${''}`)); }).then((importedModule) => {
1615
+ {
1616
+ cmpModules.set(bundleId, importedModule);
1617
+ }
1618
+ return importedModule[exportName];
1619
+ }, consoleError);
1620
+ };
1621
+ const styles = new Map();
1622
+ const queueDomReads = [];
1623
+ const queueDomWrites = [];
1624
+ const queueTask = (queue, write) => (cb) => {
1625
+ queue.push(cb);
1626
+ if (!queuePending) {
1627
+ queuePending = true;
1628
+ if (write && plt.$flags$ & 4 /* queueSync */) {
1629
+ nextTick(flush);
1630
+ }
1631
+ else {
1632
+ plt.raf(flush);
1633
+ }
1634
+ }
1635
+ };
1636
+ const consume = (queue) => {
1637
+ for (let i = 0; i < queue.length; i++) {
1638
+ try {
1639
+ queue[i](performance.now());
1640
+ }
1641
+ catch (e) {
1642
+ consoleError(e);
1643
+ }
1644
+ }
1645
+ queue.length = 0;
1646
+ };
1647
+ const flush = () => {
1648
+ // always force a bunch of medium callbacks to run, but still have
1649
+ // a throttle on how many can run in a certain time
1650
+ // DOM READS!!!
1651
+ consume(queueDomReads);
1652
+ // DOM WRITES!!!
1653
+ {
1654
+ consume(queueDomWrites);
1655
+ if ((queuePending = queueDomReads.length > 0)) {
1656
+ // still more to do yet, but we've run out of time
1657
+ // let's let this thing cool off and try again in the next tick
1658
+ plt.raf(flush);
1659
+ }
1660
+ }
1661
+ };
1662
+ const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
1663
+ const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
1664
+
1665
+ exports.CSS = CSS;
1666
+ exports.Host = Host;
1667
+ exports.bootstrapLazy = bootstrapLazy;
1668
+ exports.createEvent = createEvent;
1669
+ exports.getElement = getElement;
1670
+ exports.h = h;
1671
+ exports.plt = plt;
1672
+ exports.promiseResolve = promiseResolve;
1673
+ exports.registerInstance = registerInstance;
1674
+ exports.win = win;