@xplortech/apollo-core 0.5.3 → 1.0.0-beta.1

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