@searchcraft/javascript-sdk 0.13.0 → 0.13.2

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 (113) hide show
  1. package/dist/components/{p-e30203b1.js → CoreInstanceRegistry.js} +2 -1
  2. package/dist/components/CoreInstanceRegistry.js.map +1 -0
  3. package/dist/components/defineCustomElements.js +23 -23
  4. package/dist/components/{p-b4b67072.js → html.js} +4 -3
  5. package/dist/components/html.js.map +1 -0
  6. package/dist/components/index.d.ts +73 -1
  7. package/dist/components/index.js +82 -658
  8. package/dist/components/index.js.map +1 -1
  9. package/dist/components/{p-5365011f.js → index2.js} +867 -186
  10. package/dist/components/index2.js.map +1 -0
  11. package/dist/components/index3.js +95 -0
  12. package/dist/components/index3.js.map +1 -0
  13. package/dist/components/purify.es.js +1379 -0
  14. package/dist/components/purify.es.js.map +1 -0
  15. package/dist/components/searchcraft-ad.js +2 -1
  16. package/dist/components/{p-87435aac.js → searchcraft-ad2.js} +14 -10
  17. package/dist/components/searchcraft-ad2.js.map +1 -0
  18. package/dist/components/searchcraft-button.js +2 -1
  19. package/dist/components/{p-acf23bab.js → searchcraft-button2.js} +12 -9
  20. package/dist/components/searchcraft-button2.js.map +1 -0
  21. package/dist/components/searchcraft-error-message.js +2 -1
  22. package/dist/components/{p-f2585cdf.js → searchcraft-error-message2.js} +10 -7
  23. package/dist/components/searchcraft-error-message2.js.map +1 -0
  24. package/dist/components/searchcraft-facet-list.js +2 -1
  25. package/dist/components/{p-e8d97093.js → searchcraft-facet-list2.js} +17 -12
  26. package/dist/components/searchcraft-facet-list2.js.map +1 -0
  27. package/dist/components/searchcraft-filter-panel.js +16 -13
  28. package/dist/components/searchcraft-filter-panel.js.map +1 -1
  29. package/dist/components/searchcraft-input-form.js +2 -1
  30. package/dist/components/{p-76d95772.js → searchcraft-input-form2.js} +21 -18
  31. package/dist/components/searchcraft-input-form2.js.map +1 -0
  32. package/dist/components/searchcraft-input-label.js +2 -1
  33. package/dist/components/{p-fa799946.js → searchcraft-input-label2.js} +11 -8
  34. package/dist/components/searchcraft-input-label2.js.map +1 -0
  35. package/dist/components/searchcraft-loading.js +2 -1
  36. package/dist/components/{p-46ddde99.js → searchcraft-loading2.js} +10 -7
  37. package/dist/components/searchcraft-loading2.js.map +1 -0
  38. package/dist/components/searchcraft-pagination.js +15 -11
  39. package/dist/components/searchcraft-pagination.js.map +1 -1
  40. package/dist/components/searchcraft-popover-button.js +11 -8
  41. package/dist/components/searchcraft-popover-button.js.map +1 -1
  42. package/dist/components/searchcraft-popover-footer.js +2 -1
  43. package/dist/components/{p-3d2107af.js → searchcraft-popover-footer2.js} +13 -10
  44. package/dist/components/searchcraft-popover-footer2.js.map +1 -0
  45. package/dist/components/searchcraft-popover-form.js +28 -25
  46. package/dist/components/searchcraft-popover-form.js.map +1 -1
  47. package/dist/components/searchcraft-popover-list-item.js +2 -1
  48. package/dist/components/{p-38b2dad0.js → searchcraft-popover-list-item2.js} +13 -10
  49. package/dist/components/searchcraft-popover-list-item2.js.map +1 -0
  50. package/dist/components/searchcraft-popover-list-view.js +2 -1
  51. package/dist/components/{p-90bc1590.js → searchcraft-popover-list-view2.js} +15 -12
  52. package/dist/components/searchcraft-popover-list-view2.js.map +1 -0
  53. package/dist/components/searchcraft-results-info.js +12 -9
  54. package/dist/components/searchcraft-results-info.js.map +1 -1
  55. package/dist/components/searchcraft-search-result.js +2 -1
  56. package/dist/components/{p-3286bbb3.js → searchcraft-search-result2.js} +12 -9
  57. package/dist/components/searchcraft-search-result2.js.map +1 -0
  58. package/dist/components/searchcraft-search-results-per-page.js +14 -10
  59. package/dist/components/searchcraft-search-results-per-page.js.map +1 -1
  60. package/dist/components/searchcraft-search-results.js +16 -13
  61. package/dist/components/searchcraft-search-results.js.map +1 -1
  62. package/dist/components/searchcraft-select.js +2 -1
  63. package/dist/components/{p-73db9122.js → searchcraft-select2.js} +11 -8
  64. package/dist/components/searchcraft-select2.js.map +1 -0
  65. package/dist/components/searchcraft-slider.js +2 -1
  66. package/dist/components/{p-afe7ce60.js → searchcraft-slider2.js} +14 -11
  67. package/dist/components/searchcraft-slider2.js.map +1 -0
  68. package/dist/components/searchcraft-summary-box.js +15 -70
  69. package/dist/components/searchcraft-summary-box.js.map +1 -1
  70. package/dist/components/searchcraft-theme.js +10 -7
  71. package/dist/components/searchcraft-theme.js.map +1 -1
  72. package/dist/components/searchcraft-toggle-button.js +2 -1
  73. package/dist/components/{p-16181756.js → searchcraft-toggle-button2.js} +13 -10
  74. package/dist/components/searchcraft-toggle-button2.js.map +1 -0
  75. package/dist/components/{p-d54771ef.js → units.js} +2 -1
  76. package/dist/components/units.js.map +1 -0
  77. package/dist/hydrate/index.d.ts +52 -7
  78. package/dist/hydrate/index.js +3374 -2599
  79. package/dist/hydrate/index.mjs +3374 -2601
  80. package/dist/types/classes/SearchcraftCore.d.ts +1 -0
  81. package/dist/types/clients/MeasureClient.d.ts +2 -1
  82. package/dist/types/clients/SearchClient.d.ts +1 -1
  83. package/dist/types/clients/ad-clients/AdClient.d.ts +1 -1
  84. package/dist/types/clients/ad-clients/NativoClient.d.ts +1 -1
  85. package/dist/types/components/searchcraft-popover-form/searchcraft-popover-form.d.ts +1 -1
  86. package/dist/types/components/searchcraft-popover-list-item/searchcraft-popover-list-item.d.ts +1 -1
  87. package/dist/types/components/searchcraft-popover-list-view/searchcraft-popover-list-view.d.ts +1 -1
  88. package/dist/types/components/searchcraft-search-results/searchcraft-search-results.d.ts +2 -2
  89. package/dist/types/components.d.ts +70 -0
  90. package/dist/types/stencil-public-runtime.d.ts +127 -8
  91. package/package.json +3 -3
  92. package/dist/components/p-16181756.js.map +0 -1
  93. package/dist/components/p-3286bbb3.js.map +0 -1
  94. package/dist/components/p-38b2dad0.js.map +0 -1
  95. package/dist/components/p-3d2107af.js.map +0 -1
  96. package/dist/components/p-46ddde99.js.map +0 -1
  97. package/dist/components/p-5365011f.js.map +0 -1
  98. package/dist/components/p-5cdc6210.js +0 -82
  99. package/dist/components/p-5cdc6210.js.map +0 -1
  100. package/dist/components/p-73db9122.js.map +0 -1
  101. package/dist/components/p-76d95772.js.map +0 -1
  102. package/dist/components/p-87435aac.js.map +0 -1
  103. package/dist/components/p-90bc1590.js.map +0 -1
  104. package/dist/components/p-acf23bab.js.map +0 -1
  105. package/dist/components/p-afe7ce60.js.map +0 -1
  106. package/dist/components/p-b4b67072.js.map +0 -1
  107. package/dist/components/p-d54771ef.js.map +0 -1
  108. package/dist/components/p-e2a10337.js +0 -1355
  109. package/dist/components/p-e2a10337.js.map +0 -1
  110. package/dist/components/p-e30203b1.js.map +0 -1
  111. package/dist/components/p-e8d97093.js.map +0 -1
  112. package/dist/components/p-f2585cdf.js.map +0 -1
  113. package/dist/components/p-fa799946.js.map +0 -1
@@ -1,8 +1,8 @@
1
1
  const NAMESPACE = 'searchcraft-javascript-sdk';
2
- const BUILD = /* searchcraft-javascript-sdk */ { allRenderFn: true, appendChildSlotFix: false, asyncLoading: true, asyncQueue: false, attachStyles: true, cloneNodeFix: false, cmpDidLoad: true, cmpDidRender: false, cmpDidUnload: false, cmpDidUpdate: false, cmpShouldUpdate: false, cmpWillLoad: false, cmpWillRender: false, cmpWillUpdate: false, connectedCallback: true, constructableCSS: true, cssAnnotations: true, devTools: false, disconnectedCallback: true, element: false, event: true, experimentalScopedSlotChanges: false, experimentalSlotFixes: false, formAssociated: false, hasRenderFn: true, hostListener: false, hostListenerTarget: false, hostListenerTargetBody: false, hostListenerTargetDocument: false, hostListenerTargetParent: false, hostListenerTargetWindow: false, hotModuleReplacement: false, hydrateClientSide: false, hydrateServerSide: false, hydratedAttribute: false, hydratedClass: true, hydratedSelectorName: "hydrated", invisiblePrehydration: true, isDebug: false, isDev: false, isTesting: false, lazyLoad: false, lifecycle: true, lifecycleDOMEvents: false, member: true, method: false, mode: false, modernPropertyDecls: true, observeAttribute: true, profile: false, prop: true, propBoolean: true, propMutable: false, propNumber: true, propString: true, reflect: false, scoped: false, scopedSlotTextContentFix: false, scriptDataOpts: false, shadowDelegatesFocus: false, shadowDom: false, slot: true, slotChildNodesFix: false, slotRelocation: true, state: true, style: false, svg: true, taskQueue: true, updatable: true, vdomAttribute: true, vdomClass: true, vdomFunctional: true, vdomKey: true, vdomListener: true, vdomPropOrAttr: true, vdomRef: false, vdomRender: true, vdomStyle: true, vdomText: true, vdomXlink: false, watchCallback: true };
2
+ const BUILD = /* searchcraft-javascript-sdk */ { hydratedSelectorName: "hydrated", lazyLoad: false, shadowDom: false, slotRelocation: true, state: true, updatable: true};
3
3
 
4
4
  /*
5
- Stencil Client Platform v4.25.0 | MIT Licensed | https://stenciljs.com
5
+ Stencil Client Platform v4.39.0 | MIT Licensed | https://stenciljs.com
6
6
  */
7
7
  var __defProp = Object.defineProperty;
8
8
  var __export = (target, all) => {
@@ -13,8 +13,30 @@ var __export = (target, all) => {
13
13
  // src/utils/constants.ts
14
14
  var SVG_NS = "http://www.w3.org/2000/svg";
15
15
  var HTML_NS = "http://www.w3.org/1999/xhtml";
16
-
17
- // src/utils/es2022-rewire-class-members.ts
16
+ var PrimitiveType = /* @__PURE__ */ ((PrimitiveType2) => {
17
+ PrimitiveType2["Undefined"] = "undefined";
18
+ PrimitiveType2["Null"] = "null";
19
+ PrimitiveType2["String"] = "string";
20
+ PrimitiveType2["Number"] = "number";
21
+ PrimitiveType2["SpecialNumber"] = "number";
22
+ PrimitiveType2["Boolean"] = "boolean";
23
+ PrimitiveType2["BigInt"] = "bigint";
24
+ return PrimitiveType2;
25
+ })(PrimitiveType || {});
26
+ var NonPrimitiveType = /* @__PURE__ */ ((NonPrimitiveType2) => {
27
+ NonPrimitiveType2["Array"] = "array";
28
+ NonPrimitiveType2["Date"] = "date";
29
+ NonPrimitiveType2["Map"] = "map";
30
+ NonPrimitiveType2["Object"] = "object";
31
+ NonPrimitiveType2["RegularExpression"] = "regexp";
32
+ NonPrimitiveType2["Set"] = "set";
33
+ NonPrimitiveType2["Channel"] = "channel";
34
+ NonPrimitiveType2["Symbol"] = "symbol";
35
+ return NonPrimitiveType2;
36
+ })(NonPrimitiveType || {});
37
+ var TYPE_CONSTANT = "type";
38
+ var VALUE_CONSTANT = "value";
39
+ var SERIALIZED_PREFIX = "serialized:";
18
40
  var reWireGetterSetter = (instance, hostRef) => {
19
41
  var _a;
20
42
  const cmpMeta = hostRef.$cmpMeta$;
@@ -22,48 +44,71 @@ var reWireGetterSetter = (instance, hostRef) => {
22
44
  members.map(([memberName, [memberFlags]]) => {
23
45
  if ((memberFlags & 31 /* Prop */ || memberFlags & 32 /* State */)) {
24
46
  const ogValue = instance[memberName];
25
- const ogDescriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(instance), memberName);
26
- Object.defineProperty(instance, memberName, {
27
- get() {
28
- return ogDescriptor.get.call(this);
29
- },
30
- set(newValue) {
31
- ogDescriptor.set.call(this, newValue);
32
- },
33
- configurable: true,
34
- enumerable: true
35
- });
47
+ const ogDescriptor = getPropertyDescriptor(Object.getPrototypeOf(instance), memberName) || Object.getOwnPropertyDescriptor(instance, memberName);
48
+ if (ogDescriptor) {
49
+ Object.defineProperty(instance, memberName, {
50
+ get() {
51
+ return ogDescriptor.get.call(this);
52
+ },
53
+ set(newValue) {
54
+ ogDescriptor.set.call(this, newValue);
55
+ },
56
+ configurable: true,
57
+ enumerable: true
58
+ });
59
+ }
36
60
  instance[memberName] = hostRef.$instanceValues$.has(memberName) ? hostRef.$instanceValues$.get(memberName) : ogValue;
37
61
  }
38
62
  });
39
63
  };
64
+ function getPropertyDescriptor(obj, memberName) {
65
+ while (obj) {
66
+ const desc = Object.getOwnPropertyDescriptor(obj, memberName);
67
+ if (desc == null ? void 0 : desc.get) return desc;
68
+ obj = Object.getPrototypeOf(obj);
69
+ }
70
+ return void 0;
71
+ }
40
72
 
41
73
  // src/client/client-host-ref.ts
42
- var hostRefs = /* @__PURE__ */ new WeakMap();
43
- var deleteHostRef = (ref) => hostRefs.delete(ref);
44
- var getHostRef = (ref) => hostRefs.get(ref);
74
+ var getHostRef = (ref) => {
75
+ if (ref.__stencil__getHostRef) {
76
+ return ref.__stencil__getHostRef();
77
+ }
78
+ return void 0;
79
+ };
45
80
  var registerHost = (hostElement, cmpMeta) => {
46
81
  const hostRef = {
47
82
  $flags$: 0,
48
83
  $hostElement$: hostElement,
49
84
  $cmpMeta$: cmpMeta,
50
- $instanceValues$: /* @__PURE__ */ new Map()
85
+ $instanceValues$: /* @__PURE__ */ new Map(),
86
+ $serializerValues$: /* @__PURE__ */ new Map()
51
87
  };
52
88
  {
53
89
  hostRef.$onReadyPromise$ = new Promise((r) => hostRef.$onReadyResolve$ = r);
54
90
  hostElement["s-p"] = [];
55
91
  hostElement["s-rc"] = [];
56
92
  }
57
- const ref = hostRefs.set(hostElement, hostRef);
58
- {
93
+ const ref = hostRef;
94
+ hostElement.__stencil__getHostRef = () => ref;
95
+ if (cmpMeta.$flags$ & 512 /* hasModernPropertyDecls */ && (BUILD.state)) {
59
96
  reWireGetterSetter(hostElement, hostRef);
60
97
  }
61
98
  return ref;
62
99
  };
63
100
  var isMemberInElement = (elm, memberName) => memberName in elm;
64
101
  var consoleError = (e, el) => (0, console.error)(e, el);
102
+
103
+ // src/runtime/runtime-constants.ts
104
+ var CONTENT_REF_ID = "r";
105
+ var ORG_LOCATION_ID = "o";
106
+ var SLOT_NODE_ID = "s";
107
+ var TEXT_NODE_ID = "t";
108
+ var COMMENT_NODE_ID = "c";
109
+ var HYDRATE_ID = "s-id";
110
+ var HYDRATE_CHILD_ID = "c-id";
65
111
  var win = typeof window !== "undefined" ? window : {};
66
- var doc = win.document || { head: {} };
67
112
  var H = win.HTMLElement || class {
68
113
  };
69
114
  var plt = {
@@ -124,6 +169,106 @@ var isComplexType = (o) => {
124
169
  return o === "object" || o === "function";
125
170
  };
126
171
 
172
+ // src/utils/regular-expression.ts
173
+ var escapeRegExpSpecialCharacters = (text) => {
174
+ return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
175
+ };
176
+
177
+ // src/utils/remote-value.ts
178
+ var RemoteValue = class _RemoteValue {
179
+ /**
180
+ * Deserializes a LocalValue serialized object back to its original JavaScript representation
181
+ *
182
+ * @param serialized The serialized LocalValue object
183
+ * @returns The original JavaScript value/object
184
+ */
185
+ static fromLocalValue(serialized) {
186
+ const type = serialized[TYPE_CONSTANT];
187
+ const value = VALUE_CONSTANT in serialized ? serialized[VALUE_CONSTANT] : void 0;
188
+ switch (type) {
189
+ case "string" /* String */:
190
+ return value;
191
+ case "boolean" /* Boolean */:
192
+ return value;
193
+ case "bigint" /* BigInt */:
194
+ return BigInt(value);
195
+ case "undefined" /* Undefined */:
196
+ return void 0;
197
+ case "null" /* Null */:
198
+ return null;
199
+ case "number" /* Number */:
200
+ if (value === "NaN") return NaN;
201
+ if (value === "-0") return -0;
202
+ if (value === "Infinity") return Infinity;
203
+ if (value === "-Infinity") return -Infinity;
204
+ return value;
205
+ case "array" /* Array */:
206
+ return value.map((item) => _RemoteValue.fromLocalValue(item));
207
+ case "date" /* Date */:
208
+ return new Date(value);
209
+ case "map" /* Map */:
210
+ const map2 = /* @__PURE__ */ new Map();
211
+ for (const [key, val] of value) {
212
+ const deserializedKey = typeof key === "object" && key !== null ? _RemoteValue.fromLocalValue(key) : key;
213
+ const deserializedValue = _RemoteValue.fromLocalValue(val);
214
+ map2.set(deserializedKey, deserializedValue);
215
+ }
216
+ return map2;
217
+ case "object" /* Object */:
218
+ const obj = {};
219
+ for (const [key, val] of value) {
220
+ obj[key] = _RemoteValue.fromLocalValue(val);
221
+ }
222
+ return obj;
223
+ case "regexp" /* RegularExpression */:
224
+ const { pattern, flags } = value;
225
+ return new RegExp(pattern, flags);
226
+ case "set" /* Set */:
227
+ const set = /* @__PURE__ */ new Set();
228
+ for (const item of value) {
229
+ set.add(_RemoteValue.fromLocalValue(item));
230
+ }
231
+ return set;
232
+ case "symbol" /* Symbol */:
233
+ return Symbol(value);
234
+ default:
235
+ throw new Error(`Unsupported type: ${type}`);
236
+ }
237
+ }
238
+ /**
239
+ * Utility method to deserialize multiple LocalValues at once
240
+ *
241
+ * @param serializedValues Array of serialized LocalValue objects
242
+ * @returns Array of deserialized JavaScript values
243
+ */
244
+ static fromLocalValueArray(serializedValues) {
245
+ return serializedValues.map((value) => _RemoteValue.fromLocalValue(value));
246
+ }
247
+ /**
248
+ * Verifies if the given object matches the structure of a serialized LocalValue
249
+ *
250
+ * @param obj Object to verify
251
+ * @returns boolean indicating if the object has LocalValue structure
252
+ */
253
+ static isLocalValueObject(obj) {
254
+ if (typeof obj !== "object" || obj === null) {
255
+ return false;
256
+ }
257
+ if (!obj.hasOwnProperty(TYPE_CONSTANT)) {
258
+ return false;
259
+ }
260
+ const type = obj[TYPE_CONSTANT];
261
+ const hasTypeProperty = Object.values({ ...PrimitiveType, ...NonPrimitiveType }).includes(type);
262
+ if (!hasTypeProperty) {
263
+ return false;
264
+ }
265
+ if (type !== "null" /* Null */ && type !== "undefined" /* Undefined */) {
266
+ return obj.hasOwnProperty(VALUE_CONSTANT);
267
+ }
268
+ return true;
269
+ }
270
+ };
271
+
127
272
  // src/utils/result.ts
128
273
  var result_exports = {};
129
274
  __export(result_exports, {
@@ -172,13 +317,20 @@ var unwrapErr = (result) => {
172
317
  throw result.value;
173
318
  }
174
319
  };
320
+
321
+ // src/utils/serialize.ts
322
+ function deserializeProperty(value) {
323
+ if (typeof value !== "string" || !value.startsWith(SERIALIZED_PREFIX)) {
324
+ return value;
325
+ }
326
+ return RemoteValue.fromLocalValue(JSON.parse(atob(value.slice(SERIALIZED_PREFIX.length))));
327
+ }
175
328
  var updateFallbackSlotVisibility = (elm) => {
176
- const childNodes = elm.__childNodes || elm.childNodes;
329
+ const childNodes = internalCall(elm, "childNodes");
177
330
  if (elm.tagName && elm.tagName.includes("-") && elm["s-cr"] && elm.tagName !== "SLOT-FB") {
178
331
  getHostSlotNodes(childNodes, elm.tagName).forEach((slotNode) => {
179
- var _a;
180
332
  if (slotNode.nodeType === 1 /* ElementNode */ && slotNode.tagName === "SLOT-FB") {
181
- if ((_a = getHostSlotChildNodes(slotNode, slotNode["s-sn"], false)) == null ? void 0 : _a.length) {
333
+ if (getSlotChildSiblings(slotNode, getSlotName(slotNode), false).length) {
182
334
  slotNode.hidden = true;
183
335
  } else {
184
336
  slotNode.hidden = false;
@@ -186,31 +338,43 @@ var updateFallbackSlotVisibility = (elm) => {
186
338
  }
187
339
  });
188
340
  }
189
- for (const childNode of childNodes) {
190
- if (childNode.nodeType === 1 /* ElementNode */ && (childNode.__childNodes || childNode.childNodes).length) {
341
+ let i2 = 0;
342
+ for (i2 = 0; i2 < childNodes.length; i2++) {
343
+ const childNode = childNodes[i2];
344
+ if (childNode.nodeType === 1 /* ElementNode */ && internalCall(childNode, "childNodes").length) {
191
345
  updateFallbackSlotVisibility(childNode);
192
346
  }
193
347
  }
194
348
  };
349
+ var getSlottedChildNodes = (childNodes) => {
350
+ const result = [];
351
+ for (let i2 = 0; i2 < childNodes.length; i2++) {
352
+ const slottedNode = childNodes[i2]["s-nr"] || void 0;
353
+ if (slottedNode && slottedNode.isConnected) {
354
+ result.push(slottedNode);
355
+ }
356
+ }
357
+ return result;
358
+ };
195
359
  function getHostSlotNodes(childNodes, hostName, slotName) {
196
360
  let i2 = 0;
197
361
  let slottedNodes = [];
198
362
  let childNode;
199
363
  for (; i2 < childNodes.length; i2++) {
200
364
  childNode = childNodes[i2];
201
- if (childNode["s-sr"] && childNode["s-hn"] === hostName && (slotName === void 0 || childNode["s-sn"] === slotName)) {
365
+ if (childNode["s-sr"] && (!hostName || childNode["s-hn"] === hostName) && (slotName === void 0)) {
202
366
  slottedNodes.push(childNode);
203
- if (typeof slotName !== "undefined") return slottedNodes;
204
367
  }
205
368
  slottedNodes = [...slottedNodes, ...getHostSlotNodes(childNode.childNodes, hostName, slotName)];
206
369
  }
207
370
  return slottedNodes;
208
371
  }
209
- var getHostSlotChildNodes = (node, slotName, includeSlot = true) => {
372
+ var getSlotChildSiblings = (slot, slotName, includeSlot = true) => {
210
373
  const childNodes = [];
211
- if (includeSlot && node["s-sr"] || !node["s-sr"]) childNodes.push(node);
212
- while ((node = node.nextSibling) && node["s-sn"] === slotName) {
213
- childNodes.push(node);
374
+ if (includeSlot && slot["s-sr"] || !slot["s-sr"]) childNodes.push(slot);
375
+ let node = slot;
376
+ while (node = node.nextSibling) {
377
+ if (getSlotName(node) === slotName && (includeSlot || !node["s-sr"])) childNodes.push(node);
214
378
  }
215
379
  return childNodes;
216
380
  };
@@ -229,6 +393,72 @@ var isNodeLocatedInSlot = (nodeToRelocate, slotName) => {
229
393
  }
230
394
  return slotName === "";
231
395
  };
396
+ var addSlotRelocateNode = (newChild, slotNode, prepend, position) => {
397
+ if (newChild["s-ol"] && newChild["s-ol"].isConnected) {
398
+ return;
399
+ }
400
+ const slottedNodeLocation = document.createTextNode("");
401
+ slottedNodeLocation["s-nr"] = newChild;
402
+ if (!slotNode["s-cr"] || !slotNode["s-cr"].parentNode) return;
403
+ const parent = slotNode["s-cr"].parentNode;
404
+ const appendMethod = internalCall(parent, "appendChild");
405
+ if (typeof position !== "undefined") {
406
+ slottedNodeLocation["s-oo"] = position;
407
+ const childNodes = internalCall(parent, "childNodes");
408
+ const slotRelocateNodes = [slottedNodeLocation];
409
+ childNodes.forEach((n) => {
410
+ if (n["s-nr"]) slotRelocateNodes.push(n);
411
+ });
412
+ slotRelocateNodes.sort((a, b) => {
413
+ if (!a["s-oo"] || a["s-oo"] < (b["s-oo"] || 0)) return -1;
414
+ else if (!b["s-oo"] || b["s-oo"] < a["s-oo"]) return 1;
415
+ return 0;
416
+ });
417
+ slotRelocateNodes.forEach((n) => appendMethod.call(parent, n));
418
+ } else {
419
+ appendMethod.call(parent, slottedNodeLocation);
420
+ }
421
+ newChild["s-ol"] = slottedNodeLocation;
422
+ newChild["s-sh"] = slotNode["s-hn"];
423
+ };
424
+ var getSlotName = (node) => typeof node["s-sn"] === "string" ? node["s-sn"] : node.nodeType === 1 && node.getAttribute("slot") || void 0;
425
+ function patchSlotNode(node) {
426
+ if (node.assignedElements || node.assignedNodes || !node["s-sr"]) return;
427
+ const assignedFactory = (elementsOnly) => (function(opts) {
428
+ const toReturn = [];
429
+ const slotName = this["s-sn"];
430
+ if (opts == null ? void 0 : opts.flatten) {
431
+ console.error(`
432
+ Flattening is not supported for Stencil non-shadow slots.
433
+ You can use \`.childNodes\` to nested slot fallback content.
434
+ If you have a particular use case, please open an issue on the Stencil repo.
435
+ `);
436
+ }
437
+ const parent = this["s-cr"].parentElement;
438
+ const slottedNodes = parent.__childNodes ? parent.childNodes : getSlottedChildNodes(parent.childNodes);
439
+ slottedNodes.forEach((n) => {
440
+ if (slotName === getSlotName(n)) {
441
+ toReturn.push(n);
442
+ }
443
+ });
444
+ if (elementsOnly) {
445
+ return toReturn.filter((n) => n.nodeType === 1 /* ElementNode */);
446
+ }
447
+ return toReturn;
448
+ }).bind(node);
449
+ node.assignedElements = assignedFactory(true);
450
+ node.assignedNodes = assignedFactory(false);
451
+ }
452
+ function internalCall(node, method) {
453
+ if ("__" + method in node) {
454
+ const toReturn = node["__" + method];
455
+ if (typeof toReturn !== "function") return toReturn;
456
+ return toReturn.bind(node);
457
+ } else {
458
+ if (typeof node[method] !== "function") return node[method];
459
+ return node[method].bind(node);
460
+ }
461
+ }
232
462
  var createTime = (fnName, tagName = "") => {
233
463
  {
234
464
  return () => {
@@ -236,7 +466,12 @@ var createTime = (fnName, tagName = "") => {
236
466
  };
237
467
  }
238
468
  };
469
+ var rootAppliedStyles = /* @__PURE__ */ new WeakMap();
470
+ var getScopeId = (cmp, mode) => "sc-" + (cmp.$tagName$);
239
471
  var h = (nodeName, vnodeData, ...children) => {
472
+ if (typeof nodeName === "string") {
473
+ nodeName = transformTag(nodeName);
474
+ }
240
475
  let child = null;
241
476
  let key = null;
242
477
  let slotName = null;
@@ -347,13 +582,380 @@ var convertToPrivate = (node) => {
347
582
  vnode.$name$ = node.vname;
348
583
  return vnode;
349
584
  };
350
- var parsePropertyValue = (propValue, propType) => {
585
+
586
+ // src/runtime/client-hydrate.ts
587
+ var initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
588
+ var _a, _b;
589
+ const endHydrate = createTime("hydrateClient", tagName);
590
+ const shadowRoot = hostElm.shadowRoot;
591
+ const childRenderNodes = [];
592
+ const slotNodes = [];
593
+ const slottedNodes = [];
594
+ const shadowRootNodes = null;
595
+ const vnode = newVNode(tagName, null);
596
+ vnode.$elm$ = hostElm;
597
+ if (win.document && (!plt.$orgLocNodes$ || !plt.$orgLocNodes$.size)) {
598
+ initializeDocumentHydrate(win.document.body, plt.$orgLocNodes$ = /* @__PURE__ */ new Map());
599
+ }
600
+ hostElm[HYDRATE_ID] = hostId;
601
+ hostElm.removeAttribute(HYDRATE_ID);
602
+ hostRef.$vnode$ = clientHydrate(
603
+ vnode,
604
+ childRenderNodes,
605
+ slotNodes,
606
+ shadowRootNodes,
607
+ hostElm,
608
+ hostElm,
609
+ hostId,
610
+ slottedNodes
611
+ );
612
+ let crIndex = 0;
613
+ const crLength = childRenderNodes.length;
614
+ let childRenderNode;
615
+ for (crIndex; crIndex < crLength; crIndex++) {
616
+ childRenderNode = childRenderNodes[crIndex];
617
+ const orgLocationId = childRenderNode.$hostId$ + "." + childRenderNode.$nodeId$;
618
+ const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
619
+ const node = childRenderNode.$elm$;
620
+ if (!shadowRoot) {
621
+ node["s-hn"] = transformTag(tagName).toUpperCase();
622
+ if (childRenderNode.$tag$ === "slot") {
623
+ node["s-cr"] = hostElm["s-cr"];
624
+ }
625
+ } else if (((_a = childRenderNode.$tag$) == null ? void 0 : _a.toString().includes("-")) && childRenderNode.$tag$ !== "slot-fb" && !childRenderNode.$elm$.shadowRoot) {
626
+ const cmpMeta = getHostRef(childRenderNode.$elm$);
627
+ if (cmpMeta) {
628
+ const scopeId3 = getScopeId(
629
+ cmpMeta.$cmpMeta$);
630
+ const styleSheet = win.document.querySelector(`style[sty-id="${scopeId3}"]`);
631
+ if (styleSheet) {
632
+ hostElm.shadowRoot.append(styleSheet.cloneNode(true));
633
+ }
634
+ }
635
+ }
636
+ if (childRenderNode.$tag$ === "slot") {
637
+ childRenderNode.$name$ = childRenderNode.$elm$["s-sn"] || childRenderNode.$elm$["name"] || null;
638
+ if (childRenderNode.$children$) {
639
+ childRenderNode.$flags$ |= 2 /* isSlotFallback */;
640
+ if (!childRenderNode.$elm$.childNodes.length) {
641
+ childRenderNode.$children$.forEach((c) => {
642
+ childRenderNode.$elm$.appendChild(c.$elm$);
643
+ });
644
+ }
645
+ } else {
646
+ childRenderNode.$flags$ |= 1 /* isSlotReference */;
647
+ }
648
+ }
649
+ if (orgLocationNode && orgLocationNode.isConnected) {
650
+ if (orgLocationNode.parentElement.shadowRoot && orgLocationNode["s-en"] === "") {
651
+ orgLocationNode.parentNode.insertBefore(node, orgLocationNode.nextSibling);
652
+ }
653
+ orgLocationNode.parentNode.removeChild(orgLocationNode);
654
+ if (!shadowRoot) {
655
+ node["s-oo"] = parseInt(childRenderNode.$nodeId$);
656
+ }
657
+ }
658
+ if (orgLocationNode && !orgLocationNode["s-id"]) {
659
+ plt.$orgLocNodes$.delete(orgLocationId);
660
+ }
661
+ }
662
+ const hosts = [];
663
+ const snLen = slottedNodes.length;
664
+ let snIndex = 0;
665
+ let slotGroup;
666
+ let snGroupIdx;
667
+ let snGroupLen;
668
+ let slottedItem;
669
+ for (snIndex; snIndex < snLen; snIndex++) {
670
+ slotGroup = slottedNodes[snIndex];
671
+ if (!slotGroup || !slotGroup.length) continue;
672
+ snGroupLen = slotGroup.length;
673
+ snGroupIdx = 0;
674
+ for (snGroupIdx; snGroupIdx < snGroupLen; snGroupIdx++) {
675
+ slottedItem = slotGroup[snGroupIdx];
676
+ if (!hosts[slottedItem.hostId]) {
677
+ hosts[slottedItem.hostId] = plt.$orgLocNodes$.get(slottedItem.hostId);
678
+ }
679
+ if (!hosts[slottedItem.hostId]) continue;
680
+ const hostEle = hosts[slottedItem.hostId];
681
+ if (hostEle.shadowRoot && slottedItem.node.parentElement !== hostEle) {
682
+ hostEle.appendChild(slottedItem.node);
683
+ }
684
+ if (!hostEle.shadowRoot || !shadowRoot) {
685
+ if (!slottedItem.slot["s-cr"]) {
686
+ slottedItem.slot["s-cr"] = hostEle["s-cr"];
687
+ if (!slottedItem.slot["s-cr"] && hostEle.shadowRoot) {
688
+ slottedItem.slot["s-cr"] = hostEle;
689
+ } else {
690
+ slottedItem.slot["s-cr"] = (hostEle.__childNodes || hostEle.childNodes)[0];
691
+ }
692
+ }
693
+ addSlotRelocateNode(slottedItem.node, slottedItem.slot, false, slottedItem.node["s-oo"]);
694
+ if (((_b = slottedItem.node.parentElement) == null ? void 0 : _b.shadowRoot) && slottedItem.node["getAttribute"] && slottedItem.node.getAttribute("slot")) {
695
+ slottedItem.node.removeAttribute("slot");
696
+ }
697
+ }
698
+ }
699
+ }
700
+ hostRef.$hostElement$ = hostElm;
701
+ endHydrate();
702
+ };
703
+ var clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node, hostId, slottedNodes = []) => {
704
+ let childNodeType;
705
+ let childIdSplt;
706
+ let childVNode;
707
+ let i2;
708
+ if (node.nodeType === 1 /* ElementNode */) {
709
+ childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
710
+ if (childNodeType) {
711
+ childIdSplt = childNodeType.split(".");
712
+ if (childIdSplt[0] === hostId || childIdSplt[0] === "0") {
713
+ childVNode = createSimpleVNode({
714
+ $flags$: 0,
715
+ $hostId$: childIdSplt[0],
716
+ $nodeId$: childIdSplt[1],
717
+ $depth$: childIdSplt[2],
718
+ $index$: childIdSplt[3],
719
+ $tag$: node.tagName.toLowerCase(),
720
+ $elm$: node,
721
+ // If we don't add the initial classes to the VNode, the first `vdom-render.ts` patch
722
+ // won't try to reconcile them. Classes set on the node will be blown away.
723
+ $attrs$: { class: node.className || "" }
724
+ });
725
+ childRenderNodes.push(childVNode);
726
+ node.removeAttribute(HYDRATE_CHILD_ID);
727
+ if (!parentVNode.$children$) {
728
+ parentVNode.$children$ = [];
729
+ }
730
+ const slotName = childVNode.$elm$.getAttribute("s-sn");
731
+ if (typeof slotName === "string") {
732
+ if (childVNode.$tag$ === "slot-fb") {
733
+ addSlot(
734
+ slotName,
735
+ childIdSplt[2],
736
+ childVNode,
737
+ node,
738
+ parentVNode,
739
+ childRenderNodes,
740
+ slotNodes,
741
+ shadowRootNodes,
742
+ slottedNodes
743
+ );
744
+ }
745
+ childVNode.$elm$["s-sn"] = slotName;
746
+ childVNode.$elm$.removeAttribute("s-sn");
747
+ }
748
+ if (childVNode.$index$ !== void 0) {
749
+ parentVNode.$children$[childVNode.$index$] = childVNode;
750
+ }
751
+ parentVNode = childVNode;
752
+ }
753
+ }
754
+ if (node.shadowRoot) {
755
+ for (i2 = node.shadowRoot.childNodes.length - 1; i2 >= 0; i2--) {
756
+ clientHydrate(
757
+ parentVNode,
758
+ childRenderNodes,
759
+ slotNodes,
760
+ shadowRootNodes,
761
+ hostElm,
762
+ node.shadowRoot.childNodes[i2],
763
+ hostId,
764
+ slottedNodes
765
+ );
766
+ }
767
+ }
768
+ const nonShadowNodes = node.__childNodes || node.childNodes;
769
+ for (i2 = nonShadowNodes.length - 1; i2 >= 0; i2--) {
770
+ clientHydrate(
771
+ parentVNode,
772
+ childRenderNodes,
773
+ slotNodes,
774
+ shadowRootNodes,
775
+ hostElm,
776
+ nonShadowNodes[i2],
777
+ hostId,
778
+ slottedNodes
779
+ );
780
+ }
781
+ } else if (node.nodeType === 8 /* CommentNode */) {
782
+ childIdSplt = node.nodeValue.split(".");
783
+ if (childIdSplt[1] === hostId || childIdSplt[1] === "0") {
784
+ childNodeType = childIdSplt[0];
785
+ childVNode = createSimpleVNode({
786
+ $hostId$: childIdSplt[1],
787
+ $nodeId$: childIdSplt[2],
788
+ $depth$: childIdSplt[3],
789
+ $index$: childIdSplt[4] || "0",
790
+ $elm$: node,
791
+ $attrs$: null,
792
+ $children$: null,
793
+ $key$: null,
794
+ $name$: null,
795
+ $tag$: null,
796
+ $text$: null
797
+ });
798
+ if (childNodeType === TEXT_NODE_ID) {
799
+ childVNode.$elm$ = findCorrespondingNode(node, 3 /* TextNode */);
800
+ if (childVNode.$elm$ && childVNode.$elm$.nodeType === 3 /* TextNode */) {
801
+ childVNode.$text$ = childVNode.$elm$.textContent;
802
+ childRenderNodes.push(childVNode);
803
+ node.remove();
804
+ if (hostId === childVNode.$hostId$) {
805
+ if (!parentVNode.$children$) {
806
+ parentVNode.$children$ = [];
807
+ }
808
+ parentVNode.$children$[childVNode.$index$] = childVNode;
809
+ }
810
+ }
811
+ } else if (childNodeType === COMMENT_NODE_ID) {
812
+ childVNode.$elm$ = findCorrespondingNode(node, 8 /* CommentNode */);
813
+ if (childVNode.$elm$ && childVNode.$elm$.nodeType === 8 /* CommentNode */) {
814
+ childRenderNodes.push(childVNode);
815
+ node.remove();
816
+ }
817
+ } else if (childVNode.$hostId$ === hostId) {
818
+ if (childNodeType === SLOT_NODE_ID) {
819
+ const slotName = node["s-sn"] = childIdSplt[5] || "";
820
+ addSlot(
821
+ slotName,
822
+ childIdSplt[2],
823
+ childVNode,
824
+ node,
825
+ parentVNode,
826
+ childRenderNodes,
827
+ slotNodes,
828
+ shadowRootNodes,
829
+ slottedNodes
830
+ );
831
+ } else if (childNodeType === CONTENT_REF_ID) {
832
+ {
833
+ hostElm["s-cr"] = node;
834
+ node["s-cn"] = true;
835
+ }
836
+ }
837
+ }
838
+ }
839
+ } else if (parentVNode && parentVNode.$tag$ === "style") {
840
+ const vnode = newVNode(null, node.textContent);
841
+ vnode.$elm$ = node;
842
+ vnode.$index$ = "0";
843
+ parentVNode.$children$ = [vnode];
844
+ } else {
845
+ if (node.nodeType === 3 /* TextNode */ && !node.wholeText.trim() && !node["s-nr"]) {
846
+ node.remove();
847
+ }
848
+ }
849
+ return parentVNode;
850
+ };
851
+ var initializeDocumentHydrate = (node, orgLocNodes) => {
852
+ if (node.nodeType === 1 /* ElementNode */) {
853
+ const componentId = node[HYDRATE_ID] || node.getAttribute(HYDRATE_ID);
854
+ if (componentId) {
855
+ orgLocNodes.set(componentId, node);
856
+ }
857
+ let i2 = 0;
858
+ if (node.shadowRoot) {
859
+ for (; i2 < node.shadowRoot.childNodes.length; i2++) {
860
+ initializeDocumentHydrate(node.shadowRoot.childNodes[i2], orgLocNodes);
861
+ }
862
+ }
863
+ const nonShadowNodes = node.__childNodes || node.childNodes;
864
+ for (i2 = 0; i2 < nonShadowNodes.length; i2++) {
865
+ initializeDocumentHydrate(nonShadowNodes[i2], orgLocNodes);
866
+ }
867
+ } else if (node.nodeType === 8 /* CommentNode */) {
868
+ const childIdSplt = node.nodeValue.split(".");
869
+ if (childIdSplt[0] === ORG_LOCATION_ID) {
870
+ orgLocNodes.set(childIdSplt[1] + "." + childIdSplt[2], node);
871
+ node.nodeValue = "";
872
+ node["s-en"] = childIdSplt[3];
873
+ }
874
+ }
875
+ };
876
+ var createSimpleVNode = (vnode) => {
877
+ const defaultVNode = {
878
+ $flags$: 0,
879
+ $hostId$: null,
880
+ $nodeId$: null,
881
+ $depth$: null,
882
+ $index$: "0",
883
+ $elm$: null,
884
+ $attrs$: null,
885
+ $children$: null,
886
+ $key$: null,
887
+ $name$: null,
888
+ $tag$: null,
889
+ $text$: null
890
+ };
891
+ return { ...defaultVNode, ...vnode };
892
+ };
893
+ function addSlot(slotName, slotId, childVNode, node, parentVNode, childRenderNodes, slotNodes, shadowRootNodes, slottedNodes) {
894
+ node["s-sr"] = true;
895
+ childVNode.$name$ = slotName || null;
896
+ childVNode.$tag$ = "slot";
897
+ const parentNodeId = (parentVNode == null ? void 0 : parentVNode.$elm$) ? parentVNode.$elm$["s-id"] || parentVNode.$elm$.getAttribute("s-id") : "";
898
+ {
899
+ const slot = childVNode.$elm$;
900
+ const shouldMove = parentNodeId && parentNodeId !== childVNode.$hostId$ && parentVNode.$elm$.shadowRoot;
901
+ addSlottedNodes(slottedNodes, slotId, slotName, node, shouldMove ? parentNodeId : childVNode.$hostId$);
902
+ patchSlotNode(node);
903
+ if (shouldMove) {
904
+ parentVNode.$elm$.insertBefore(slot, parentVNode.$elm$.children[0]);
905
+ }
906
+ }
907
+ childRenderNodes.push(childVNode);
908
+ slotNodes.push(childVNode);
909
+ if (!parentVNode.$children$) {
910
+ parentVNode.$children$ = [];
911
+ }
912
+ parentVNode.$children$[childVNode.$index$] = childVNode;
913
+ }
914
+ var addSlottedNodes = (slottedNodes, slotNodeId, slotName, slotNode, hostId) => {
915
+ var _a, _b;
916
+ let slottedNode = slotNode.nextSibling;
917
+ slottedNodes[slotNodeId] = slottedNodes[slotNodeId] || [];
918
+ if (!slottedNode || ((_a = slottedNode.nodeValue) == null ? void 0 : _a.startsWith(SLOT_NODE_ID + "."))) return;
919
+ do {
920
+ if (slottedNode && ((slottedNode["getAttribute"] && slottedNode.getAttribute("slot") || slottedNode["s-sn"]) === slotName || slotName === "" && !slottedNode["s-sn"] && (!slottedNode["getAttribute"] || !slottedNode.getAttribute("slot")) && (slottedNode.nodeType === 8 /* CommentNode */ || slottedNode.nodeType === 3 /* TextNode */))) {
921
+ slottedNode["s-sn"] = slotName;
922
+ slottedNodes[slotNodeId].push({ slot: slotNode, node: slottedNode, hostId });
923
+ }
924
+ slottedNode = slottedNode == null ? void 0 : slottedNode.nextSibling;
925
+ } while (slottedNode && !((_b = slottedNode.nodeValue) == null ? void 0 : _b.startsWith(SLOT_NODE_ID + ".")));
926
+ };
927
+ var findCorrespondingNode = (node, type) => {
928
+ let sibling = node;
929
+ do {
930
+ sibling = sibling.nextSibling;
931
+ } while (sibling && (sibling.nodeType !== type || !sibling.nodeValue));
932
+ return sibling;
933
+ };
934
+ var createSupportsRuleRe = (selector) => {
935
+ const safeSelector2 = escapeRegExpSpecialCharacters(selector);
936
+ return new RegExp(
937
+ // First capture group: match any context before the selector that's not inside @supports selector()
938
+ // Using negative lookahead to avoid matching inside @supports selector(...) condition
939
+ `(^|[^@]|@(?!supports\\s+selector\\s*\\([^{]*?${safeSelector2}))(${safeSelector2}\\b)`,
940
+ "g"
941
+ );
942
+ };
943
+ createSupportsRuleRe("::slotted");
944
+ createSupportsRuleRe(":host");
945
+ createSupportsRuleRe(":host-context");
946
+ var parsePropertyValue = (propValue, propType, isFormAssociated) => {
947
+ if (typeof propValue === "string" && propValue.startsWith(SERIALIZED_PREFIX)) {
948
+ propValue = deserializeProperty(propValue);
949
+ return propValue;
950
+ }
351
951
  if (propValue != null && !isComplexType(propValue)) {
352
952
  if (propType & 4 /* Boolean */) {
353
- return propValue === "false" ? false : propValue === "" || !!propValue;
953
+ {
954
+ return propValue === "false" ? false : propValue === "" || !!propValue;
955
+ }
354
956
  }
355
957
  if (propType & 2 /* Number */) {
356
- return parseFloat(propValue);
958
+ return typeof propValue === "string" ? parseFloat(propValue) : typeof propValue === "number" ? propValue : NaN;
357
959
  }
358
960
  if (propType & 1 /* String */) {
359
961
  return String(propValue);
@@ -362,7 +964,9 @@ var parsePropertyValue = (propValue, propType) => {
362
964
  }
363
965
  return propValue;
364
966
  };
365
- var getElement = (ref) => ref;
967
+ var getElement = (ref) => {
968
+ return ref;
969
+ };
366
970
 
367
971
  // src/runtime/event-emitter.ts
368
972
  var createEvent = (ref, name, flags) => {
@@ -370,9 +974,9 @@ var createEvent = (ref, name, flags) => {
370
974
  return {
371
975
  emit: (detail) => {
372
976
  return emitEvent(elm, name, {
373
- bubbles: !!(flags & 4 /* Bubbles */),
374
- composed: !!(flags & 2 /* Composed */),
375
- cancelable: !!(flags & 1 /* Cancellable */),
977
+ bubbles: true,
978
+ composed: true,
979
+ cancelable: true,
376
980
  detail
377
981
  });
378
982
  }
@@ -383,108 +987,108 @@ var emitEvent = (elm, name, opts) => {
383
987
  elm.dispatchEvent(ev);
384
988
  return ev;
385
989
  };
386
- var rootAppliedStyles = /* @__PURE__ */ new WeakMap();
387
- var setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
388
- if (oldValue !== newValue) {
389
- let isProp = isMemberInElement(elm, memberName);
390
- let ln = memberName.toLowerCase();
391
- if (memberName === "class") {
392
- const classList = elm.classList;
393
- const oldClasses = parseClassList(oldValue);
394
- let newClasses = parseClassList(newValue);
395
- if (elm["s-si"]) {
396
- newClasses.push(elm["s-si"]);
397
- oldClasses.forEach((c) => {
398
- if (c.startsWith(elm["s-si"])) newClasses.push(c);
399
- });
400
- newClasses = [...new Set(newClasses)];
401
- classList.add(...newClasses);
402
- delete elm["s-si"];
403
- } else {
404
- classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
405
- classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
406
- }
407
- } else if (memberName === "style") {
408
- {
409
- for (const prop in oldValue) {
410
- if (!newValue || newValue[prop] == null) {
411
- if (prop.includes("-")) {
412
- elm.style.removeProperty(prop);
413
- } else {
414
- elm.style[prop] = "";
415
- }
416
- }
417
- }
418
- }
419
- for (const prop in newValue) {
420
- if (!oldValue || newValue[prop] !== oldValue[prop]) {
990
+ var setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialRender) => {
991
+ if (oldValue === newValue) {
992
+ return;
993
+ }
994
+ let isProp = isMemberInElement(elm, memberName);
995
+ let ln = memberName.toLowerCase();
996
+ if (memberName === "class") {
997
+ const classList = elm.classList;
998
+ const oldClasses = parseClassList(oldValue);
999
+ let newClasses = parseClassList(newValue);
1000
+ if ((elm["s-si"] || elm["s-sc"]) && initialRender) {
1001
+ const scopeId2 = elm["s-sc"] || elm["s-si"];
1002
+ newClasses.push(scopeId2);
1003
+ oldClasses.forEach((c) => {
1004
+ if (c.startsWith(scopeId2)) newClasses.push(c);
1005
+ });
1006
+ newClasses = [...new Set(newClasses)].filter((c) => c);
1007
+ classList.add(...newClasses);
1008
+ } else {
1009
+ classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
1010
+ classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
1011
+ }
1012
+ } else if (memberName === "style") {
1013
+ {
1014
+ for (const prop in oldValue) {
1015
+ if (!newValue || newValue[prop] == null) {
421
1016
  if (prop.includes("-")) {
422
- elm.style.setProperty(prop, newValue[prop]);
1017
+ elm.style.removeProperty(prop);
423
1018
  } else {
424
- elm.style[prop] = newValue[prop];
1019
+ elm.style[prop] = "";
425
1020
  }
426
1021
  }
427
1022
  }
428
- } else if (memberName === "key") ; else if ((!elm.__lookupSetter__(memberName)) && memberName[0] === "o" && memberName[1] === "n") {
429
- if (memberName[2] === "-") {
430
- memberName = memberName.slice(3);
431
- } else if (isMemberInElement(win, ln)) {
432
- memberName = ln.slice(2);
433
- } else {
434
- memberName = ln[2] + memberName.slice(3);
435
- }
436
- if (oldValue || newValue) {
437
- const capture = memberName.endsWith(CAPTURE_EVENT_SUFFIX);
438
- memberName = memberName.replace(CAPTURE_EVENT_REGEX, "");
439
- if (oldValue) {
440
- plt.rel(elm, memberName, oldValue, capture);
441
- }
442
- if (newValue) {
443
- plt.ael(elm, memberName, newValue, capture);
1023
+ }
1024
+ for (const prop in newValue) {
1025
+ if (!oldValue || newValue[prop] !== oldValue[prop]) {
1026
+ if (prop.includes("-")) {
1027
+ elm.style.setProperty(prop, newValue[prop]);
1028
+ } else {
1029
+ elm.style[prop] = newValue[prop];
444
1030
  }
445
1031
  }
1032
+ }
1033
+ } else if (memberName === "key") ; else if ((!elm.__lookupSetter__(memberName)) && memberName[0] === "o" && memberName[1] === "n") {
1034
+ if (memberName[2] === "-") {
1035
+ memberName = memberName.slice(3);
1036
+ } else if (isMemberInElement(win, ln)) {
1037
+ memberName = ln.slice(2);
446
1038
  } else {
447
- const isComplex = isComplexType(newValue);
448
- if ((isProp || isComplex && newValue !== null) && !isSvg) {
449
- try {
450
- if (!elm.tagName.includes("-")) {
451
- const n = newValue == null ? "" : newValue;
452
- if (memberName === "list") {
453
- isProp = false;
454
- } else if (oldValue == null || elm[memberName] != n) {
455
- if (typeof elm.__lookupSetter__(memberName) === "function") {
456
- elm[memberName] = n;
457
- } else {
458
- elm.setAttribute(memberName, n);
459
- }
1039
+ memberName = ln[2] + memberName.slice(3);
1040
+ }
1041
+ if (oldValue || newValue) {
1042
+ const capture = memberName.endsWith(CAPTURE_EVENT_SUFFIX);
1043
+ memberName = memberName.replace(CAPTURE_EVENT_REGEX, "");
1044
+ if (oldValue) {
1045
+ plt.rel(elm, memberName, oldValue, capture);
1046
+ }
1047
+ if (newValue) {
1048
+ plt.ael(elm, memberName, newValue, capture);
1049
+ }
1050
+ }
1051
+ } else {
1052
+ const isComplex = isComplexType(newValue);
1053
+ if ((isProp || isComplex && newValue !== null) && !isSvg) {
1054
+ try {
1055
+ if (!elm.tagName.includes("-")) {
1056
+ const n = newValue == null ? "" : newValue;
1057
+ if (memberName === "list") {
1058
+ isProp = false;
1059
+ } else if (oldValue == null || elm[memberName] != n) {
1060
+ if (typeof elm.__lookupSetter__(memberName) === "function") {
1061
+ elm[memberName] = n;
1062
+ } else {
1063
+ elm.setAttribute(memberName, n);
460
1064
  }
461
- } else if (elm[memberName] !== newValue) {
462
- elm[memberName] = newValue;
463
1065
  }
464
- } catch (e) {
1066
+ } else if (elm[memberName] !== newValue) {
1067
+ elm[memberName] = newValue;
465
1068
  }
1069
+ } catch (e) {
466
1070
  }
467
- if (newValue == null || newValue === false) {
468
- if (newValue !== false || elm.getAttribute(memberName) === "") {
469
- {
470
- elm.removeAttribute(memberName);
471
- }
472
- }
473
- } else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
474
- newValue = newValue === true ? "" : newValue;
1071
+ }
1072
+ if (newValue == null || newValue === false) {
1073
+ if (newValue !== false || elm.getAttribute(memberName) === "") {
475
1074
  {
476
- elm.setAttribute(memberName, newValue);
1075
+ elm.removeAttribute(memberName);
477
1076
  }
478
1077
  }
1078
+ } else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex && elm.nodeType === 1 /* ElementNode */) {
1079
+ newValue = newValue === true ? "" : newValue;
1080
+ {
1081
+ elm.setAttribute(memberName, newValue);
1082
+ }
479
1083
  }
480
1084
  }
481
1085
  };
482
1086
  var parseClassListRegex = /\s/;
483
1087
  var parseClassList = (value) => {
484
- if (typeof value === "object" && "baseVal" in value) {
1088
+ if (typeof value === "object" && value && "baseVal" in value) {
485
1089
  value = value.baseVal;
486
1090
  }
487
- if (!value) {
1091
+ if (!value || typeof value !== "string") {
488
1092
  return [];
489
1093
  }
490
1094
  return value.split(parseClassListRegex);
@@ -493,19 +1097,35 @@ var CAPTURE_EVENT_SUFFIX = "Capture";
493
1097
  var CAPTURE_EVENT_REGEX = new RegExp(CAPTURE_EVENT_SUFFIX + "$");
494
1098
 
495
1099
  // src/runtime/vdom/update-element.ts
496
- var updateElement = (oldVnode, newVnode, isSvgMode2) => {
1100
+ var updateElement = (oldVnode, newVnode, isSvgMode2, isInitialRender) => {
497
1101
  const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host ? newVnode.$elm$.host : newVnode.$elm$;
498
1102
  const oldVnodeAttrs = oldVnode && oldVnode.$attrs$ || {};
499
1103
  const newVnodeAttrs = newVnode.$attrs$ || {};
500
1104
  {
501
1105
  for (const memberName of sortedAttrNames(Object.keys(oldVnodeAttrs))) {
502
1106
  if (!(memberName in newVnodeAttrs)) {
503
- setAccessor(elm, memberName, oldVnodeAttrs[memberName], void 0, isSvgMode2, newVnode.$flags$);
1107
+ setAccessor(
1108
+ elm,
1109
+ memberName,
1110
+ oldVnodeAttrs[memberName],
1111
+ void 0,
1112
+ isSvgMode2,
1113
+ newVnode.$flags$,
1114
+ isInitialRender
1115
+ );
504
1116
  }
505
1117
  }
506
1118
  }
507
1119
  for (const memberName of sortedAttrNames(Object.keys(newVnodeAttrs))) {
508
- setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode2, newVnode.$flags$);
1120
+ setAccessor(
1121
+ elm,
1122
+ memberName,
1123
+ oldVnodeAttrs[memberName],
1124
+ newVnodeAttrs[memberName],
1125
+ isSvgMode2,
1126
+ newVnode.$flags$,
1127
+ isInitialRender
1128
+ );
509
1129
  }
510
1130
  };
511
1131
  function sortedAttrNames(attrNames) {
@@ -546,14 +1166,22 @@ var createElm = (oldParentVNode, newParentVNode, childIndex) => {
546
1166
  }
547
1167
  }
548
1168
  if (newVNode2.$text$ !== null) {
549
- elm = newVNode2.$elm$ = doc.createTextNode(newVNode2.$text$);
1169
+ elm = newVNode2.$elm$ = win.document.createTextNode(newVNode2.$text$);
550
1170
  } else if (newVNode2.$flags$ & 1 /* isSlotReference */) {
551
- elm = newVNode2.$elm$ = doc.createTextNode("");
1171
+ elm = newVNode2.$elm$ = win.document.createTextNode("");
1172
+ {
1173
+ updateElement(null, newVNode2, isSvgMode);
1174
+ }
552
1175
  } else {
553
1176
  if (!isSvgMode) {
554
1177
  isSvgMode = newVNode2.$tag$ === "svg";
555
1178
  }
556
- elm = newVNode2.$elm$ = doc.createElementNS(
1179
+ if (!win.document) {
1180
+ throw new Error(
1181
+ "You are trying to render a Stencil component in an environment that doesn't support the DOM. Make sure to populate the [`window`](https://developer.mozilla.org/en-US/docs/Web/API/Window/window) object before rendering a component."
1182
+ );
1183
+ }
1184
+ elm = newVNode2.$elm$ = win.document.createElementNS(
557
1185
  isSvgMode ? SVG_NS : HTML_NS,
558
1186
  !useNativeShadowDom && BUILD.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
559
1187
  ) ;
@@ -586,6 +1214,7 @@ var createElm = (oldParentVNode, newParentVNode, childIndex) => {
586
1214
  elm["s-cr"] = contentRef;
587
1215
  elm["s-sn"] = newVNode2.$name$ || "";
588
1216
  elm["s-rf"] = (_a = newVNode2.$attrs$) == null ? void 0 : _a.ref;
1217
+ patchSlotNode(elm);
589
1218
  oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
590
1219
  if (oldVNode && oldVNode.$tag$ === newVNode2.$tag$ && oldParentVNode.$elm$) {
591
1220
  {
@@ -599,14 +1228,6 @@ var createElm = (oldParentVNode, newParentVNode, childIndex) => {
599
1228
  var putBackInOriginalLocation = (parentElm, recursive) => {
600
1229
  plt.$flags$ |= 1 /* isTmpDisconnected */;
601
1230
  const oldSlotChildNodes = Array.from(parentElm.__childNodes || parentElm.childNodes);
602
- if (parentElm["s-sr"] && BUILD.experimentalSlotFixes) {
603
- let node = parentElm;
604
- while (node = node.nextSibling) {
605
- if (node && node["s-sn"] === parentElm["s-sn"] && node["s-sh"] === hostTagName) {
606
- oldSlotChildNodes.push(node);
607
- }
608
- }
609
- }
610
1231
  for (let i2 = oldSlotChildNodes.length - 1; i2 >= 0; i2--) {
611
1232
  const childNode = oldSlotChildNodes[i2];
612
1233
  if (childNode["s-hn"] !== hostTagName && childNode["s-ol"]) {
@@ -620,7 +1241,7 @@ var putBackInOriginalLocation = (parentElm, recursive) => {
620
1241
  putBackInOriginalLocation(childNode, recursive);
621
1242
  }
622
1243
  }
623
- plt.$flags$ &= ~1 /* isTmpDisconnected */;
1244
+ plt.$flags$ &= -2 /* isTmpDisconnected */;
624
1245
  };
625
1246
  var addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
626
1247
  let containerElm = parentElm["s-cr"] && parentElm["s-cr"].parentNode || parentElm;
@@ -776,9 +1397,7 @@ var patch = (oldVNode, newVNode2, isInitialRender = false) => {
776
1397
  isSvgMode = tag === "svg" ? true : tag === "foreignObject" ? false : isSvgMode;
777
1398
  }
778
1399
  {
779
- if (tag === "slot" && !useNativeShadowDom) ; else {
780
- updateElement(oldVNode, newVNode2, isSvgMode);
781
- }
1400
+ updateElement(oldVNode, newVNode2, isSvgMode, isInitialRender);
782
1401
  }
783
1402
  if (oldChildren !== null && newChildren !== null) {
784
1403
  updateChildren(elm, oldChildren, newVNode2, newChildren, isInitialRender);
@@ -792,6 +1411,8 @@ var patch = (oldVNode, newVNode2, isInitialRender = false) => {
792
1411
  !isInitialRender && BUILD.updatable && oldChildren !== null
793
1412
  ) {
794
1413
  removeVnodes(oldChildren, 0, oldChildren.length - 1);
1414
+ } else if (isInitialRender && BUILD.updatable && oldChildren !== null && newChildren === null) {
1415
+ newVNode2.$children$ = oldChildren;
795
1416
  }
796
1417
  if (isSvgMode && tag === "svg") {
797
1418
  isSvgMode = false;
@@ -814,7 +1435,7 @@ var markSlotContentForRelocation = (elm) => {
814
1435
  const slotName = childNode["s-sn"];
815
1436
  for (j = hostContentNodes.length - 1; j >= 0; j--) {
816
1437
  node = hostContentNodes[j];
817
- if (!node["s-cn"] && !node["s-nr"] && node["s-hn"] !== childNode["s-hn"] && (!BUILD.experimentalSlotFixes )) {
1438
+ if (!node["s-cn"] && !node["s-nr"] && node["s-hn"] !== childNode["s-hn"] && (true)) {
818
1439
  if (isNodeLocatedInSlot(node, slotName)) {
819
1440
  let relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
820
1441
  checkSlotFallbackVisibility = true;
@@ -861,7 +1482,8 @@ var renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
861
1482
  var _a, _b, _c, _d;
862
1483
  const hostElm = hostRef.$hostElement$;
863
1484
  const oldVNode = hostRef.$vnode$ || newVNode(null, null);
864
- const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
1485
+ const isHostElement = isHost(renderFnResults);
1486
+ const rootVnode = isHostElement ? renderFnResults : h(null, null, renderFnResults);
865
1487
  hostTagName = hostElm.tagName;
866
1488
  if (isInitialLoad && rootVnode.$attrs$) {
867
1489
  for (const key of Object.keys(rootVnode.$attrs$)) {
@@ -874,7 +1496,7 @@ var renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
874
1496
  rootVnode.$flags$ |= 4 /* isHost */;
875
1497
  hostRef.$vnode$ = rootVnode;
876
1498
  rootVnode.$elm$ = oldVNode.$elm$ = hostElm;
877
- useNativeShadowDom = supportsShadow ;
1499
+ useNativeShadowDom = supportsShadow;
878
1500
  {
879
1501
  contentRef = hostElm["s-cr"];
880
1502
  checkSlotFallbackVisibility = false;
@@ -886,8 +1508,8 @@ var renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
886
1508
  markSlotContentForRelocation(rootVnode.$elm$);
887
1509
  for (const relocateData of relocateNodes) {
888
1510
  const nodeToRelocate = relocateData.$nodeToRelocate$;
889
- if (!nodeToRelocate["s-ol"]) {
890
- const orgLocationNode = doc.createTextNode("");
1511
+ if (!nodeToRelocate["s-ol"] && win.document) {
1512
+ const orgLocationNode = win.document.createTextNode("");
891
1513
  orgLocationNode["s-nr"] = nodeToRelocate;
892
1514
  insertBefore(nodeToRelocate.parentNode, nodeToRelocate["s-ol"] = orgLocationNode, nodeToRelocate);
893
1515
  }
@@ -928,7 +1550,7 @@ var renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
928
1550
  }
929
1551
  }
930
1552
  }
931
- nodeToRelocate && typeof slotRefNode["s-rf"] === "function" && slotRefNode["s-rf"](nodeToRelocate);
1553
+ nodeToRelocate && typeof slotRefNode["s-rf"] === "function" && slotRefNode["s-rf"](slotRefNode);
932
1554
  } else {
933
1555
  if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
934
1556
  if (isInitialLoad) {
@@ -942,7 +1564,7 @@ var renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
942
1564
  if (checkSlotFallbackVisibility) {
943
1565
  updateFallbackSlotVisibility(rootVnode.$elm$);
944
1566
  }
945
- plt.$flags$ &= ~1 /* isTmpDisconnected */;
1567
+ plt.$flags$ &= -2 /* isTmpDisconnected */;
946
1568
  relocateNodes.length = 0;
947
1569
  }
948
1570
  contentRef = void 0;
@@ -971,6 +1593,12 @@ var scheduleUpdate = (hostRef, isInitialLoad) => {
971
1593
  }
972
1594
  attachToAncestor(hostRef, hostRef.$ancestorComponent$);
973
1595
  const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
1596
+ if (isInitialLoad) {
1597
+ queueMicrotask(() => {
1598
+ dispatch();
1599
+ });
1600
+ return;
1601
+ }
974
1602
  return writeTask(dispatch) ;
975
1603
  };
976
1604
  var dispatchHooks = (hostRef, isInitialLoad) => {
@@ -983,6 +1611,12 @@ var dispatchHooks = (hostRef, isInitialLoad) => {
983
1611
  );
984
1612
  }
985
1613
  let maybePromise;
1614
+ if (isInitialLoad) {
1615
+ maybePromise = safeCall(instance, "componentWillLoad", void 0, elm);
1616
+ } else {
1617
+ maybePromise = safeCall(instance, "componentWillUpdate", void 0, elm);
1618
+ }
1619
+ maybePromise = enqueue(maybePromise, () => safeCall(instance, "componentWillRender", void 0, elm));
986
1620
  endSchedule();
987
1621
  return enqueue(maybePromise, () => updateComponent(hostRef, instance, isInitialLoad));
988
1622
  };
@@ -1022,7 +1656,7 @@ var callRender = (hostRef, instance, elm, isInitialLoad) => {
1022
1656
  try {
1023
1657
  instance = instance.render() ;
1024
1658
  {
1025
- hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
1659
+ hostRef.$flags$ &= -17 /* isQueuedForUpdate */;
1026
1660
  }
1027
1661
  {
1028
1662
  hostRef.$flags$ |= 2 /* hasRendered */;
@@ -1045,14 +1679,13 @@ var postUpdateComponent = (hostRef) => {
1045
1679
  const endPostUpdate = createTime("postUpdate", tagName);
1046
1680
  const instance = elm;
1047
1681
  const ancestorComponent = hostRef.$ancestorComponent$;
1682
+ safeCall(instance, "componentDidRender", void 0, elm);
1048
1683
  if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
1049
1684
  hostRef.$flags$ |= 64 /* hasLoadedComponent */;
1050
1685
  {
1051
1686
  addHydratedFlag(elm);
1052
1687
  }
1053
- {
1054
- safeCall(instance, "componentDidLoad", void 0, elm);
1055
- }
1688
+ safeCall(instance, "componentDidLoad", void 0, elm);
1056
1689
  endPostUpdate();
1057
1690
  {
1058
1691
  hostRef.$onReadyResolve$(elm);
@@ -1061,6 +1694,7 @@ var postUpdateComponent = (hostRef) => {
1061
1694
  }
1062
1695
  }
1063
1696
  } else {
1697
+ safeCall(instance, "componentDidUpdate", void 0, elm);
1064
1698
  endPostUpdate();
1065
1699
  }
1066
1700
  {
@@ -1071,14 +1705,17 @@ var postUpdateComponent = (hostRef) => {
1071
1705
  if (hostRef.$flags$ & 512 /* needsRerender */) {
1072
1706
  nextTick(() => scheduleUpdate(hostRef, false));
1073
1707
  }
1074
- hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
1708
+ hostRef.$flags$ &= -517;
1075
1709
  }
1076
1710
  };
1077
1711
  var appDidLoad = (who) => {
1712
+ var _a;
1713
+ nextTick(() => emitEvent(win, "appload", { detail: { namespace: NAMESPACE } }));
1078
1714
  {
1079
- addHydratedFlag(doc.documentElement);
1715
+ if ((_a = plt.$orgLocNodes$) == null ? void 0 : _a.size) {
1716
+ plt.$orgLocNodes$.clear();
1717
+ }
1080
1718
  }
1081
- nextTick(() => emitEvent(win, "appload", { detail: { namespace: NAMESPACE } }));
1082
1719
  };
1083
1720
  var safeCall = (instance, method, arg, elm) => {
1084
1721
  if (instance && instance[method]) {
@@ -1099,11 +1736,16 @@ var addHydratedFlag = (elm) => {
1099
1736
  var getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
1100
1737
  var setValue = (ref, propName, newVal, cmpMeta) => {
1101
1738
  const hostRef = getHostRef(ref);
1739
+ if (!hostRef) {
1740
+ return;
1741
+ }
1102
1742
  const elm = ref;
1103
1743
  const oldVal = hostRef.$instanceValues$.get(propName);
1104
1744
  const flags = hostRef.$flags$;
1105
1745
  const instance = elm;
1106
- newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
1746
+ newVal = parsePropertyValue(
1747
+ newVal,
1748
+ cmpMeta.$members$[propName][0]);
1107
1749
  const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
1108
1750
  const didValueChange = newVal !== oldVal && !areBothNaN;
1109
1751
  if (didValueChange) {
@@ -1122,6 +1764,11 @@ var setValue = (ref, propName, newVal, cmpMeta) => {
1122
1764
  }
1123
1765
  }
1124
1766
  if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
1767
+ if (instance.componentShouldUpdate) {
1768
+ if (instance.componentShouldUpdate(newVal, oldVal, propName) === false) {
1769
+ return;
1770
+ }
1771
+ }
1125
1772
  scheduleUpdate(hostRef, false);
1126
1773
  }
1127
1774
  }
@@ -1132,9 +1779,17 @@ var setValue = (ref, propName, newVal, cmpMeta) => {
1132
1779
  var proxyComponent = (Cstr, cmpMeta, flags) => {
1133
1780
  var _a, _b;
1134
1781
  const prototype = Cstr.prototype;
1135
- if (cmpMeta.$members$ || (cmpMeta.$watchers$ || Cstr.watchers)) {
1136
- if (Cstr.watchers && !cmpMeta.$watchers$) {
1137
- cmpMeta.$watchers$ = Cstr.watchers;
1782
+ {
1783
+ {
1784
+ if (Cstr.watchers && !cmpMeta.$watchers$) {
1785
+ cmpMeta.$watchers$ = Cstr.watchers;
1786
+ }
1787
+ if (Cstr.deserializers && !cmpMeta.$deserializers$) {
1788
+ cmpMeta.$deserializers$ = Cstr.deserializers;
1789
+ }
1790
+ if (Cstr.serializers && !cmpMeta.$serializers$) {
1791
+ cmpMeta.$serializers$ = Cstr.serializers;
1792
+ }
1138
1793
  }
1139
1794
  const members = Object.entries((_a = cmpMeta.$members$) != null ? _a : {});
1140
1795
  members.map(([memberName, [memberFlags]]) => {
@@ -1142,7 +1797,7 @@ var proxyComponent = (Cstr, cmpMeta, flags) => {
1142
1797
  const { get: origGetter, set: origSetter } = Object.getOwnPropertyDescriptor(prototype, memberName) || {};
1143
1798
  if (origGetter) cmpMeta.$members$[memberName][0] |= 2048 /* Getter */;
1144
1799
  if (origSetter) cmpMeta.$members$[memberName][0] |= 4096 /* Setter */;
1145
- if (flags & 1 /* isElementConstructor */ || !origGetter) {
1800
+ {
1146
1801
  Object.defineProperty(prototype, memberName, {
1147
1802
  get() {
1148
1803
  {
@@ -1156,14 +1811,19 @@ var proxyComponent = (Cstr, cmpMeta, flags) => {
1156
1811
  Object.defineProperty(prototype, memberName, {
1157
1812
  set(newValue) {
1158
1813
  const ref = getHostRef(this);
1814
+ if (!ref) {
1815
+ return;
1816
+ }
1159
1817
  if (origSetter) {
1160
1818
  const currentValue = memberFlags & 32 /* State */ ? this[memberName] : ref.$hostElement$[memberName];
1161
1819
  if (typeof currentValue === "undefined" && ref.$instanceValues$.get(memberName)) {
1162
1820
  newValue = ref.$instanceValues$.get(memberName);
1163
- } else if (!ref.$instanceValues$.get(memberName) && currentValue) {
1164
- ref.$instanceValues$.set(memberName, currentValue);
1165
1821
  }
1166
- origSetter.apply(this, [parsePropertyValue(newValue, memberFlags)]);
1822
+ origSetter.apply(this, [
1823
+ parsePropertyValue(
1824
+ newValue,
1825
+ memberFlags)
1826
+ ]);
1167
1827
  newValue = memberFlags & 32 /* State */ ? this[memberName] : ref.$hostElement$[memberName];
1168
1828
  setValue(this, memberName, newValue, cmpMeta);
1169
1829
  return;
@@ -1182,16 +1842,14 @@ var proxyComponent = (Cstr, cmpMeta, flags) => {
1182
1842
  plt.jmp(() => {
1183
1843
  var _a2;
1184
1844
  const propName = attrNameToPropName.get(attrName);
1185
- if (this.hasOwnProperty(propName) && BUILD.lazyLoad) {
1186
- newValue = this[propName];
1187
- delete this[propName];
1188
- } else if (prototype.hasOwnProperty(propName) && typeof this[propName] === "number" && // cast type to number to avoid TS compiler issues
1845
+ const hostRef = getHostRef(this);
1846
+ if (this.hasOwnProperty(propName) && BUILD.lazyLoad) ;
1847
+ if (prototype.hasOwnProperty(propName) && typeof this[propName] === "number" && // cast type to number to avoid TS compiler issues
1189
1848
  this[propName] == newValue) {
1190
1849
  return;
1191
1850
  } else if (propName == null) {
1192
- const hostRef = getHostRef(this);
1193
1851
  const flags2 = hostRef == null ? void 0 : hostRef.$flags$;
1194
- if (flags2 && !(flags2 & 8 /* isConstructingInstance */) && flags2 & 128 /* isWatchReady */ && newValue !== oldValue) {
1852
+ if (hostRef && flags2 && !(flags2 & 8 /* isConstructingInstance */) && flags2 & 128 /* isWatchReady */ && newValue !== oldValue) {
1195
1853
  const elm = this;
1196
1854
  const instance = elm;
1197
1855
  const entry = (_a2 = cmpMeta.$watchers$) == null ? void 0 : _a2[attrName];
@@ -1203,9 +1861,12 @@ var proxyComponent = (Cstr, cmpMeta, flags) => {
1203
1861
  }
1204
1862
  return;
1205
1863
  }
1864
+ const propFlags = members.find(([m]) => m === propName);
1865
+ if (propFlags && propFlags[1][0] & 4 /* Boolean */) {
1866
+ newValue = newValue === null || newValue === "false" ? false : true;
1867
+ }
1206
1868
  const propDesc = Object.getOwnPropertyDescriptor(prototype, propName);
1207
- newValue = newValue === null && typeof this[propName] === "boolean" ? false : newValue;
1208
- if (newValue !== this[propName] && (!propDesc.get || !!propDesc.set)) {
1869
+ if (newValue != this[propName] && (!propDesc.get || !!propDesc.set)) {
1209
1870
  this[propName] = newValue;
1210
1871
  }
1211
1872
  });
@@ -1213,7 +1874,7 @@ var proxyComponent = (Cstr, cmpMeta, flags) => {
1213
1874
  Cstr.observedAttributes = Array.from(
1214
1875
  /* @__PURE__ */ new Set([
1215
1876
  ...Object.keys((_b = cmpMeta.$watchers$) != null ? _b : {}),
1216
- ...members.filter(([_, m]) => m[0] & 15 /* HasAttribute */).map(([propName, m]) => {
1877
+ ...members.filter(([_, m]) => m[0] & 31 /* HasAttribute */).map(([propName, m]) => {
1217
1878
  const attrName = m[1] || propName;
1218
1879
  attrNameToPropName.set(attrName, propName);
1219
1880
  return attrName;
@@ -1249,11 +1910,21 @@ var fireConnectedCallback = (instance, elm) => {
1249
1910
  var connectedCallback = (elm) => {
1250
1911
  if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1251
1912
  const hostRef = getHostRef(elm);
1913
+ if (!hostRef) {
1914
+ return;
1915
+ }
1252
1916
  const cmpMeta = hostRef.$cmpMeta$;
1253
1917
  const endConnected = createTime("connectedCallback", cmpMeta.$tagName$);
1254
1918
  if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
1255
1919
  hostRef.$flags$ |= 1 /* hasConnected */;
1920
+ let hostId;
1256
1921
  {
1922
+ hostId = elm.getAttribute(HYDRATE_ID);
1923
+ if (hostId) {
1924
+ initializeClientHydrate(elm, cmpMeta.$tagName$, hostId, hostRef);
1925
+ }
1926
+ }
1927
+ if (!hostId) {
1257
1928
  if (// TODO(STENCIL-854): Remove code related to legacy shadowDomShim field
1258
1929
  cmpMeta.$flags$ & (4 /* hasSlotRelocation */ | 8 /* needsShadowDomShim */)) {
1259
1930
  setContentReference(elm);
@@ -1262,7 +1933,7 @@ var connectedCallback = (elm) => {
1262
1933
  {
1263
1934
  let ancestorComponent = elm;
1264
1935
  while (ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host) {
1265
- if (ancestorComponent["s-p"]) {
1936
+ if (ancestorComponent.nodeType === 1 /* ElementNode */ && ancestorComponent.hasAttribute("s-id") && ancestorComponent["s-p"] || ancestorComponent["s-p"]) {
1266
1937
  attachToAncestor(hostRef, hostRef.$ancestorComponent$ = ancestorComponent);
1267
1938
  break;
1268
1939
  }
@@ -1270,7 +1941,7 @@ var connectedCallback = (elm) => {
1270
1941
  }
1271
1942
  if (cmpMeta.$members$) {
1272
1943
  Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
1273
- if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
1944
+ if (memberFlags & 31 /* Prop */ && memberName in elm && elm[memberName] !== Object.prototype[memberName]) {
1274
1945
  const value = elm[memberName];
1275
1946
  delete elm[memberName];
1276
1947
  elm[memberName] = value;
@@ -1289,7 +1960,10 @@ var connectedCallback = (elm) => {
1289
1960
  }
1290
1961
  };
1291
1962
  var setContentReference = (elm) => {
1292
- const contentRefElm = elm["s-cr"] = doc.createComment(
1963
+ if (!win.document) {
1964
+ return;
1965
+ }
1966
+ const contentRefElm = elm["s-cr"] = win.document.createComment(
1293
1967
  ""
1294
1968
  );
1295
1969
  contentRefElm["s-cn"] = true;
@@ -1316,6 +1990,8 @@ var proxyCustomElement = (Cstr, compactMeta) => {
1316
1990
  }
1317
1991
  {
1318
1992
  cmpMeta.$watchers$ = Cstr.$watchers$;
1993
+ cmpMeta.$deserializers$ = Cstr.$deserializers$;
1994
+ cmpMeta.$serializers$ = Cstr.$serializers$;
1319
1995
  }
1320
1996
  const originalConnectedCallback = Cstr.prototype.connectedCallback;
1321
1997
  const originalDisconnectedCallback = Cstr.prototype.disconnectedCallback;
@@ -1326,7 +2002,10 @@ var proxyCustomElement = (Cstr, compactMeta) => {
1326
2002
  },
1327
2003
  connectedCallback() {
1328
2004
  if (!this.__hasHostListenerAttached) {
1329
- getHostRef(this);
2005
+ const hostRef = getHostRef(this);
2006
+ if (!hostRef) {
2007
+ return;
2008
+ }
1330
2009
  this.__hasHostListenerAttached = true;
1331
2010
  }
1332
2011
  connectedCallback(this);
@@ -1339,16 +2018,6 @@ var proxyCustomElement = (Cstr, compactMeta) => {
1339
2018
  if (originalDisconnectedCallback) {
1340
2019
  originalDisconnectedCallback.call(this);
1341
2020
  }
1342
- plt.raf(() => {
1343
- var _a;
1344
- const hostRef = getHostRef(this);
1345
- if (((_a = hostRef == null ? void 0 : hostRef.$vnode$) == null ? void 0 : _a.$elm$) instanceof Node && !hostRef.$vnode$.$elm$.isConnected) {
1346
- delete hostRef.$vnode$;
1347
- }
1348
- if (this instanceof Node && !this.isConnected) {
1349
- deleteHostRef(this);
1350
- }
1351
- });
1352
2021
  },
1353
2022
  __attachShadow() {
1354
2023
  {
@@ -1357,7 +2026,7 @@ var proxyCustomElement = (Cstr, compactMeta) => {
1357
2026
  }
1358
2027
  });
1359
2028
  Cstr.is = cmpMeta.$tagName$;
1360
- return proxyComponent(Cstr, cmpMeta, 1 /* isElementConstructor */ | 2 /* proxyState */);
2029
+ return proxyComponent(Cstr, cmpMeta);
1361
2030
  };
1362
2031
 
1363
2032
  // src/runtime/fragment.ts
@@ -1369,6 +2038,18 @@ var setNonce = (nonce) => plt.$nonce$ = nonce;
1369
2038
  // src/runtime/platform-options.ts
1370
2039
  var setPlatformOptions = (opts) => Object.assign(plt, opts);
1371
2040
 
1372
- export { Fragment as F, H, setNonce as a, setPlatformOptions as b, createEvent as c, getAssetPath as g, h, proxyCustomElement as p, setAssetPath as s };
2041
+ // src/runtime/render.ts
2042
+ function render(vnode, container) {
2043
+ const ref = {
2044
+ $hostElement$: container
2045
+ };
2046
+ renderVdom(ref, vnode);
2047
+ }
2048
+ function transformTag(tag) {
2049
+ return tag;
2050
+ }
2051
+
2052
+ export { Fragment as F, H, setNonce as a, setPlatformOptions as b, createEvent as c, getAssetPath as g, h, proxyCustomElement as p, render as r, setAssetPath as s, transformTag as t };
2053
+ //# sourceMappingURL=index2.js.map
1373
2054
 
1374
- //# sourceMappingURL=p-5365011f.js.map
2055
+ //# sourceMappingURL=index2.js.map