@searchcraft/javascript-sdk 0.13.0 → 0.13.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 (112) hide show
  1. package/dist/components/index.d.ts +73 -1
  2. package/dist/components/index.js +58 -634
  3. package/dist/components/index.js.map +1 -1
  4. package/dist/components/{p-e8d97093.js → p-BV4HUriZ.js} +15 -10
  5. package/dist/components/p-BV4HUriZ.js.map +1 -0
  6. package/dist/components/{p-46ddde99.js → p-B_415D4A.js} +8 -5
  7. package/dist/components/p-B_415D4A.js.map +1 -0
  8. package/dist/components/{p-afe7ce60.js → p-BbSxfaD7.js} +12 -9
  9. package/dist/components/p-BbSxfaD7.js.map +1 -0
  10. package/dist/components/p-BfTCfPZ1.js +95 -0
  11. package/dist/components/p-BfTCfPZ1.js.map +1 -0
  12. package/dist/components/p-BlYgaV0q.js +1373 -0
  13. package/dist/components/p-BlYgaV0q.js.map +1 -0
  14. package/dist/components/{p-76d95772.js → p-C-wcIch1.js} +16 -13
  15. package/dist/components/p-C-wcIch1.js.map +1 -0
  16. package/dist/components/{p-87435aac.js → p-C1S92_N8.js} +12 -8
  17. package/dist/components/p-C1S92_N8.js.map +1 -0
  18. package/dist/components/{p-acf23bab.js → p-C681KruS.js} +10 -7
  19. package/dist/components/p-C681KruS.js.map +1 -0
  20. package/dist/components/{p-3d2107af.js → p-C7ZK8CYu.js} +11 -8
  21. package/dist/components/p-C7ZK8CYu.js.map +1 -0
  22. package/dist/components/{p-38b2dad0.js → p-Cju73I1E.js} +11 -8
  23. package/dist/components/p-Cju73I1E.js.map +1 -0
  24. package/dist/components/{p-e30203b1.js → p-D0j0UFpV.js} +2 -1
  25. package/dist/components/p-D0j0UFpV.js.map +1 -0
  26. package/dist/components/{p-16181756.js → p-D5p2scT9.js} +11 -8
  27. package/dist/components/p-D5p2scT9.js.map +1 -0
  28. package/dist/components/{p-5365011f.js → p-DO5g2x-l.js} +861 -186
  29. package/dist/components/p-DO5g2x-l.js.map +1 -0
  30. package/dist/components/{p-73db9122.js → p-Dc7S4y3b.js} +9 -6
  31. package/dist/components/p-Dc7S4y3b.js.map +1 -0
  32. package/dist/components/{p-f2585cdf.js → p-DjPZkCLP.js} +8 -5
  33. package/dist/components/p-DjPZkCLP.js.map +1 -0
  34. package/dist/components/{p-3286bbb3.js → p-DotXR-Gz.js} +10 -7
  35. package/dist/components/p-DotXR-Gz.js.map +1 -0
  36. package/dist/components/{p-90bc1590.js → p-Dr9rPC9v.js} +11 -8
  37. package/dist/components/p-Dr9rPC9v.js.map +1 -0
  38. package/dist/components/{p-fa799946.js → p-L4PwHqQC.js} +9 -6
  39. package/dist/components/p-L4PwHqQC.js.map +1 -0
  40. package/dist/components/{p-b4b67072.js → p-_aHgRsRD.js} +4 -3
  41. package/dist/components/p-_aHgRsRD.js.map +1 -0
  42. package/dist/components/{p-d54771ef.js → p-i8oXh7db.js} +2 -1
  43. package/dist/components/p-i8oXh7db.js.map +1 -0
  44. package/dist/components/searchcraft-ad.js +2 -1
  45. package/dist/components/searchcraft-button.js +2 -1
  46. package/dist/components/searchcraft-error-message.js +2 -1
  47. package/dist/components/searchcraft-facet-list.js +2 -1
  48. package/dist/components/searchcraft-filter-panel.js +11 -8
  49. package/dist/components/searchcraft-filter-panel.js.map +1 -1
  50. package/dist/components/searchcraft-input-form.js +2 -1
  51. package/dist/components/searchcraft-input-label.js +2 -1
  52. package/dist/components/searchcraft-loading.js +2 -1
  53. package/dist/components/searchcraft-pagination.js +12 -8
  54. package/dist/components/searchcraft-pagination.js.map +1 -1
  55. package/dist/components/searchcraft-popover-button.js +9 -6
  56. package/dist/components/searchcraft-popover-button.js.map +1 -1
  57. package/dist/components/searchcraft-popover-footer.js +2 -1
  58. package/dist/components/searchcraft-popover-form.js +17 -14
  59. package/dist/components/searchcraft-popover-form.js.map +1 -1
  60. package/dist/components/searchcraft-popover-list-item.js +2 -1
  61. package/dist/components/searchcraft-popover-list-view.js +2 -1
  62. package/dist/components/searchcraft-results-info.js +10 -7
  63. package/dist/components/searchcraft-results-info.js.map +1 -1
  64. package/dist/components/searchcraft-search-result.js +2 -1
  65. package/dist/components/searchcraft-search-results-per-page.js +11 -7
  66. package/dist/components/searchcraft-search-results-per-page.js.map +1 -1
  67. package/dist/components/searchcraft-search-results.js +11 -8
  68. package/dist/components/searchcraft-search-results.js.map +1 -1
  69. package/dist/components/searchcraft-select.js +2 -1
  70. package/dist/components/searchcraft-slider.js +2 -1
  71. package/dist/components/searchcraft-summary-box.js +12 -67
  72. package/dist/components/searchcraft-summary-box.js.map +1 -1
  73. package/dist/components/searchcraft-theme.js +8 -5
  74. package/dist/components/searchcraft-theme.js.map +1 -1
  75. package/dist/components/searchcraft-toggle-button.js +2 -1
  76. package/dist/hydrate/index.d.ts +40 -7
  77. package/dist/hydrate/index.js +3095 -2370
  78. package/dist/hydrate/index.mjs +3094 -2369
  79. package/dist/types/classes/SearchcraftCore.d.ts +1 -0
  80. package/dist/types/clients/MeasureClient.d.ts +2 -1
  81. package/dist/types/clients/SearchClient.d.ts +1 -1
  82. package/dist/types/clients/ad-clients/AdClient.d.ts +1 -1
  83. package/dist/types/clients/ad-clients/NativoClient.d.ts +1 -1
  84. package/dist/types/components/searchcraft-popover-form/searchcraft-popover-form.d.ts +1 -1
  85. package/dist/types/components/searchcraft-popover-list-item/searchcraft-popover-list-item.d.ts +1 -1
  86. package/dist/types/components/searchcraft-popover-list-view/searchcraft-popover-list-view.d.ts +1 -1
  87. package/dist/types/components/searchcraft-search-results/searchcraft-search-results.d.ts +2 -2
  88. package/dist/types/components.d.ts +70 -0
  89. package/dist/types/stencil-public-runtime.d.ts +84 -8
  90. package/package.json +2 -2
  91. package/dist/components/p-16181756.js.map +0 -1
  92. package/dist/components/p-3286bbb3.js.map +0 -1
  93. package/dist/components/p-38b2dad0.js.map +0 -1
  94. package/dist/components/p-3d2107af.js.map +0 -1
  95. package/dist/components/p-46ddde99.js.map +0 -1
  96. package/dist/components/p-5365011f.js.map +0 -1
  97. package/dist/components/p-5cdc6210.js +0 -82
  98. package/dist/components/p-5cdc6210.js.map +0 -1
  99. package/dist/components/p-73db9122.js.map +0 -1
  100. package/dist/components/p-76d95772.js.map +0 -1
  101. package/dist/components/p-87435aac.js.map +0 -1
  102. package/dist/components/p-90bc1590.js.map +0 -1
  103. package/dist/components/p-acf23bab.js.map +0 -1
  104. package/dist/components/p-afe7ce60.js.map +0 -1
  105. package/dist/components/p-b4b67072.js.map +0 -1
  106. package/dist/components/p-d54771ef.js.map +0 -1
  107. package/dist/components/p-e2a10337.js +0 -1355
  108. package/dist/components/p-e2a10337.js.map +0 -1
  109. package/dist/components/p-e30203b1.js.map +0 -1
  110. package/dist/components/p-e8d97093.js.map +0 -1
  111. package/dist/components/p-f2585cdf.js.map +0 -1
  112. 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.38.3 | 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,6 +466,8 @@ 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) => {
240
472
  let child = null;
241
473
  let key = null;
@@ -347,13 +579,380 @@ var convertToPrivate = (node) => {
347
579
  vnode.$name$ = node.vname;
348
580
  return vnode;
349
581
  };
350
- var parsePropertyValue = (propValue, propType) => {
582
+
583
+ // src/runtime/client-hydrate.ts
584
+ var initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
585
+ var _a, _b;
586
+ const endHydrate = createTime("hydrateClient", tagName);
587
+ const shadowRoot = hostElm.shadowRoot;
588
+ const childRenderNodes = [];
589
+ const slotNodes = [];
590
+ const slottedNodes = [];
591
+ const shadowRootNodes = null;
592
+ const vnode = newVNode(tagName, null);
593
+ vnode.$elm$ = hostElm;
594
+ if (win.document && (!plt.$orgLocNodes$ || !plt.$orgLocNodes$.size)) {
595
+ initializeDocumentHydrate(win.document.body, plt.$orgLocNodes$ = /* @__PURE__ */ new Map());
596
+ }
597
+ hostElm[HYDRATE_ID] = hostId;
598
+ hostElm.removeAttribute(HYDRATE_ID);
599
+ hostRef.$vnode$ = clientHydrate(
600
+ vnode,
601
+ childRenderNodes,
602
+ slotNodes,
603
+ shadowRootNodes,
604
+ hostElm,
605
+ hostElm,
606
+ hostId,
607
+ slottedNodes
608
+ );
609
+ let crIndex = 0;
610
+ const crLength = childRenderNodes.length;
611
+ let childRenderNode;
612
+ for (crIndex; crIndex < crLength; crIndex++) {
613
+ childRenderNode = childRenderNodes[crIndex];
614
+ const orgLocationId = childRenderNode.$hostId$ + "." + childRenderNode.$nodeId$;
615
+ const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
616
+ const node = childRenderNode.$elm$;
617
+ if (!shadowRoot) {
618
+ node["s-hn"] = tagName.toUpperCase();
619
+ if (childRenderNode.$tag$ === "slot") {
620
+ node["s-cr"] = hostElm["s-cr"];
621
+ }
622
+ } else if (((_a = childRenderNode.$tag$) == null ? void 0 : _a.toString().includes("-")) && childRenderNode.$tag$ !== "slot-fb" && !childRenderNode.$elm$.shadowRoot) {
623
+ const cmpMeta = getHostRef(childRenderNode.$elm$);
624
+ if (cmpMeta) {
625
+ const scopeId3 = getScopeId(
626
+ cmpMeta.$cmpMeta$);
627
+ const styleSheet = win.document.querySelector(`style[sty-id="${scopeId3}"]`);
628
+ if (styleSheet) {
629
+ hostElm.shadowRoot.append(styleSheet.cloneNode(true));
630
+ }
631
+ }
632
+ }
633
+ if (childRenderNode.$tag$ === "slot") {
634
+ childRenderNode.$name$ = childRenderNode.$elm$["s-sn"] || childRenderNode.$elm$["name"] || null;
635
+ if (childRenderNode.$children$) {
636
+ childRenderNode.$flags$ |= 2 /* isSlotFallback */;
637
+ if (!childRenderNode.$elm$.childNodes.length) {
638
+ childRenderNode.$children$.forEach((c) => {
639
+ childRenderNode.$elm$.appendChild(c.$elm$);
640
+ });
641
+ }
642
+ } else {
643
+ childRenderNode.$flags$ |= 1 /* isSlotReference */;
644
+ }
645
+ }
646
+ if (orgLocationNode && orgLocationNode.isConnected) {
647
+ if (orgLocationNode.parentElement.shadowRoot && orgLocationNode["s-en"] === "") {
648
+ orgLocationNode.parentNode.insertBefore(node, orgLocationNode.nextSibling);
649
+ }
650
+ orgLocationNode.parentNode.removeChild(orgLocationNode);
651
+ if (!shadowRoot) {
652
+ node["s-oo"] = parseInt(childRenderNode.$nodeId$);
653
+ }
654
+ }
655
+ if (orgLocationNode && !orgLocationNode["s-id"]) {
656
+ plt.$orgLocNodes$.delete(orgLocationId);
657
+ }
658
+ }
659
+ const hosts = [];
660
+ const snLen = slottedNodes.length;
661
+ let snIndex = 0;
662
+ let slotGroup;
663
+ let snGroupIdx;
664
+ let snGroupLen;
665
+ let slottedItem;
666
+ for (snIndex; snIndex < snLen; snIndex++) {
667
+ slotGroup = slottedNodes[snIndex];
668
+ if (!slotGroup || !slotGroup.length) continue;
669
+ snGroupLen = slotGroup.length;
670
+ snGroupIdx = 0;
671
+ for (snGroupIdx; snGroupIdx < snGroupLen; snGroupIdx++) {
672
+ slottedItem = slotGroup[snGroupIdx];
673
+ if (!hosts[slottedItem.hostId]) {
674
+ hosts[slottedItem.hostId] = plt.$orgLocNodes$.get(slottedItem.hostId);
675
+ }
676
+ if (!hosts[slottedItem.hostId]) continue;
677
+ const hostEle = hosts[slottedItem.hostId];
678
+ if (hostEle.shadowRoot && slottedItem.node.parentElement !== hostEle) {
679
+ hostEle.appendChild(slottedItem.node);
680
+ }
681
+ if (!hostEle.shadowRoot || !shadowRoot) {
682
+ if (!slottedItem.slot["s-cr"]) {
683
+ slottedItem.slot["s-cr"] = hostEle["s-cr"];
684
+ if (!slottedItem.slot["s-cr"] && hostEle.shadowRoot) {
685
+ slottedItem.slot["s-cr"] = hostEle;
686
+ } else {
687
+ slottedItem.slot["s-cr"] = (hostEle.__childNodes || hostEle.childNodes)[0];
688
+ }
689
+ }
690
+ addSlotRelocateNode(slottedItem.node, slottedItem.slot, false, slottedItem.node["s-oo"]);
691
+ if (((_b = slottedItem.node.parentElement) == null ? void 0 : _b.shadowRoot) && slottedItem.node["getAttribute"] && slottedItem.node.getAttribute("slot")) {
692
+ slottedItem.node.removeAttribute("slot");
693
+ }
694
+ }
695
+ }
696
+ }
697
+ hostRef.$hostElement$ = hostElm;
698
+ endHydrate();
699
+ };
700
+ var clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node, hostId, slottedNodes = []) => {
701
+ let childNodeType;
702
+ let childIdSplt;
703
+ let childVNode;
704
+ let i2;
705
+ if (node.nodeType === 1 /* ElementNode */) {
706
+ childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
707
+ if (childNodeType) {
708
+ childIdSplt = childNodeType.split(".");
709
+ if (childIdSplt[0] === hostId || childIdSplt[0] === "0") {
710
+ childVNode = createSimpleVNode({
711
+ $flags$: 0,
712
+ $hostId$: childIdSplt[0],
713
+ $nodeId$: childIdSplt[1],
714
+ $depth$: childIdSplt[2],
715
+ $index$: childIdSplt[3],
716
+ $tag$: node.tagName.toLowerCase(),
717
+ $elm$: node,
718
+ // If we don't add the initial classes to the VNode, the first `vdom-render.ts` patch
719
+ // won't try to reconcile them. Classes set on the node will be blown away.
720
+ $attrs$: { class: node.className || "" }
721
+ });
722
+ childRenderNodes.push(childVNode);
723
+ node.removeAttribute(HYDRATE_CHILD_ID);
724
+ if (!parentVNode.$children$) {
725
+ parentVNode.$children$ = [];
726
+ }
727
+ const slotName = childVNode.$elm$.getAttribute("s-sn");
728
+ if (typeof slotName === "string") {
729
+ if (childVNode.$tag$ === "slot-fb") {
730
+ addSlot(
731
+ slotName,
732
+ childIdSplt[2],
733
+ childVNode,
734
+ node,
735
+ parentVNode,
736
+ childRenderNodes,
737
+ slotNodes,
738
+ shadowRootNodes,
739
+ slottedNodes
740
+ );
741
+ }
742
+ childVNode.$elm$["s-sn"] = slotName;
743
+ childVNode.$elm$.removeAttribute("s-sn");
744
+ }
745
+ if (childVNode.$index$ !== void 0) {
746
+ parentVNode.$children$[childVNode.$index$] = childVNode;
747
+ }
748
+ parentVNode = childVNode;
749
+ }
750
+ }
751
+ if (node.shadowRoot) {
752
+ for (i2 = node.shadowRoot.childNodes.length - 1; i2 >= 0; i2--) {
753
+ clientHydrate(
754
+ parentVNode,
755
+ childRenderNodes,
756
+ slotNodes,
757
+ shadowRootNodes,
758
+ hostElm,
759
+ node.shadowRoot.childNodes[i2],
760
+ hostId,
761
+ slottedNodes
762
+ );
763
+ }
764
+ }
765
+ const nonShadowNodes = node.__childNodes || node.childNodes;
766
+ for (i2 = nonShadowNodes.length - 1; i2 >= 0; i2--) {
767
+ clientHydrate(
768
+ parentVNode,
769
+ childRenderNodes,
770
+ slotNodes,
771
+ shadowRootNodes,
772
+ hostElm,
773
+ nonShadowNodes[i2],
774
+ hostId,
775
+ slottedNodes
776
+ );
777
+ }
778
+ } else if (node.nodeType === 8 /* CommentNode */) {
779
+ childIdSplt = node.nodeValue.split(".");
780
+ if (childIdSplt[1] === hostId || childIdSplt[1] === "0") {
781
+ childNodeType = childIdSplt[0];
782
+ childVNode = createSimpleVNode({
783
+ $hostId$: childIdSplt[1],
784
+ $nodeId$: childIdSplt[2],
785
+ $depth$: childIdSplt[3],
786
+ $index$: childIdSplt[4] || "0",
787
+ $elm$: node,
788
+ $attrs$: null,
789
+ $children$: null,
790
+ $key$: null,
791
+ $name$: null,
792
+ $tag$: null,
793
+ $text$: null
794
+ });
795
+ if (childNodeType === TEXT_NODE_ID) {
796
+ childVNode.$elm$ = findCorrespondingNode(node, 3 /* TextNode */);
797
+ if (childVNode.$elm$ && childVNode.$elm$.nodeType === 3 /* TextNode */) {
798
+ childVNode.$text$ = childVNode.$elm$.textContent;
799
+ childRenderNodes.push(childVNode);
800
+ node.remove();
801
+ if (hostId === childVNode.$hostId$) {
802
+ if (!parentVNode.$children$) {
803
+ parentVNode.$children$ = [];
804
+ }
805
+ parentVNode.$children$[childVNode.$index$] = childVNode;
806
+ }
807
+ }
808
+ } else if (childNodeType === COMMENT_NODE_ID) {
809
+ childVNode.$elm$ = findCorrespondingNode(node, 8 /* CommentNode */);
810
+ if (childVNode.$elm$ && childVNode.$elm$.nodeType === 8 /* CommentNode */) {
811
+ childRenderNodes.push(childVNode);
812
+ node.remove();
813
+ }
814
+ } else if (childVNode.$hostId$ === hostId) {
815
+ if (childNodeType === SLOT_NODE_ID) {
816
+ const slotName = node["s-sn"] = childIdSplt[5] || "";
817
+ addSlot(
818
+ slotName,
819
+ childIdSplt[2],
820
+ childVNode,
821
+ node,
822
+ parentVNode,
823
+ childRenderNodes,
824
+ slotNodes,
825
+ shadowRootNodes,
826
+ slottedNodes
827
+ );
828
+ } else if (childNodeType === CONTENT_REF_ID) {
829
+ {
830
+ hostElm["s-cr"] = node;
831
+ node["s-cn"] = true;
832
+ }
833
+ }
834
+ }
835
+ }
836
+ } else if (parentVNode && parentVNode.$tag$ === "style") {
837
+ const vnode = newVNode(null, node.textContent);
838
+ vnode.$elm$ = node;
839
+ vnode.$index$ = "0";
840
+ parentVNode.$children$ = [vnode];
841
+ } else {
842
+ if (node.nodeType === 3 /* TextNode */ && !node.wholeText.trim() && !node["s-nr"]) {
843
+ node.remove();
844
+ }
845
+ }
846
+ return parentVNode;
847
+ };
848
+ var initializeDocumentHydrate = (node, orgLocNodes) => {
849
+ if (node.nodeType === 1 /* ElementNode */) {
850
+ const componentId = node[HYDRATE_ID] || node.getAttribute(HYDRATE_ID);
851
+ if (componentId) {
852
+ orgLocNodes.set(componentId, node);
853
+ }
854
+ let i2 = 0;
855
+ if (node.shadowRoot) {
856
+ for (; i2 < node.shadowRoot.childNodes.length; i2++) {
857
+ initializeDocumentHydrate(node.shadowRoot.childNodes[i2], orgLocNodes);
858
+ }
859
+ }
860
+ const nonShadowNodes = node.__childNodes || node.childNodes;
861
+ for (i2 = 0; i2 < nonShadowNodes.length; i2++) {
862
+ initializeDocumentHydrate(nonShadowNodes[i2], orgLocNodes);
863
+ }
864
+ } else if (node.nodeType === 8 /* CommentNode */) {
865
+ const childIdSplt = node.nodeValue.split(".");
866
+ if (childIdSplt[0] === ORG_LOCATION_ID) {
867
+ orgLocNodes.set(childIdSplt[1] + "." + childIdSplt[2], node);
868
+ node.nodeValue = "";
869
+ node["s-en"] = childIdSplt[3];
870
+ }
871
+ }
872
+ };
873
+ var createSimpleVNode = (vnode) => {
874
+ const defaultVNode = {
875
+ $flags$: 0,
876
+ $hostId$: null,
877
+ $nodeId$: null,
878
+ $depth$: null,
879
+ $index$: "0",
880
+ $elm$: null,
881
+ $attrs$: null,
882
+ $children$: null,
883
+ $key$: null,
884
+ $name$: null,
885
+ $tag$: null,
886
+ $text$: null
887
+ };
888
+ return { ...defaultVNode, ...vnode };
889
+ };
890
+ function addSlot(slotName, slotId, childVNode, node, parentVNode, childRenderNodes, slotNodes, shadowRootNodes, slottedNodes) {
891
+ node["s-sr"] = true;
892
+ childVNode.$name$ = slotName || null;
893
+ childVNode.$tag$ = "slot";
894
+ const parentNodeId = (parentVNode == null ? void 0 : parentVNode.$elm$) ? parentVNode.$elm$["s-id"] || parentVNode.$elm$.getAttribute("s-id") : "";
895
+ {
896
+ const slot = childVNode.$elm$;
897
+ const shouldMove = parentNodeId && parentNodeId !== childVNode.$hostId$ && parentVNode.$elm$.shadowRoot;
898
+ addSlottedNodes(slottedNodes, slotId, slotName, node, shouldMove ? parentNodeId : childVNode.$hostId$);
899
+ patchSlotNode(node);
900
+ if (shouldMove) {
901
+ parentVNode.$elm$.insertBefore(slot, parentVNode.$elm$.children[0]);
902
+ }
903
+ }
904
+ childRenderNodes.push(childVNode);
905
+ slotNodes.push(childVNode);
906
+ if (!parentVNode.$children$) {
907
+ parentVNode.$children$ = [];
908
+ }
909
+ parentVNode.$children$[childVNode.$index$] = childVNode;
910
+ }
911
+ var addSlottedNodes = (slottedNodes, slotNodeId, slotName, slotNode, hostId) => {
912
+ var _a, _b;
913
+ let slottedNode = slotNode.nextSibling;
914
+ slottedNodes[slotNodeId] = slottedNodes[slotNodeId] || [];
915
+ if (!slottedNode || ((_a = slottedNode.nodeValue) == null ? void 0 : _a.startsWith(SLOT_NODE_ID + "."))) return;
916
+ do {
917
+ 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 */))) {
918
+ slottedNode["s-sn"] = slotName;
919
+ slottedNodes[slotNodeId].push({ slot: slotNode, node: slottedNode, hostId });
920
+ }
921
+ slottedNode = slottedNode == null ? void 0 : slottedNode.nextSibling;
922
+ } while (slottedNode && !((_b = slottedNode.nodeValue) == null ? void 0 : _b.startsWith(SLOT_NODE_ID + ".")));
923
+ };
924
+ var findCorrespondingNode = (node, type) => {
925
+ let sibling = node;
926
+ do {
927
+ sibling = sibling.nextSibling;
928
+ } while (sibling && (sibling.nodeType !== type || !sibling.nodeValue));
929
+ return sibling;
930
+ };
931
+ var createSupportsRuleRe = (selector) => {
932
+ const safeSelector2 = escapeRegExpSpecialCharacters(selector);
933
+ return new RegExp(
934
+ // First capture group: match any context before the selector that's not inside @supports selector()
935
+ // Using negative lookahead to avoid matching inside @supports selector(...) condition
936
+ `(^|[^@]|@(?!supports\\s+selector\\s*\\([^{]*?${safeSelector2}))(${safeSelector2}\\b)`,
937
+ "g"
938
+ );
939
+ };
940
+ createSupportsRuleRe("::slotted");
941
+ createSupportsRuleRe(":host");
942
+ createSupportsRuleRe(":host-context");
943
+ var parsePropertyValue = (propValue, propType, isFormAssociated) => {
944
+ if (typeof propValue === "string" && propValue.startsWith(SERIALIZED_PREFIX)) {
945
+ propValue = deserializeProperty(propValue);
946
+ return propValue;
947
+ }
351
948
  if (propValue != null && !isComplexType(propValue)) {
352
949
  if (propType & 4 /* Boolean */) {
353
- return propValue === "false" ? false : propValue === "" || !!propValue;
950
+ {
951
+ return propValue === "false" ? false : propValue === "" || !!propValue;
952
+ }
354
953
  }
355
954
  if (propType & 2 /* Number */) {
356
- return parseFloat(propValue);
955
+ return typeof propValue === "string" ? parseFloat(propValue) : typeof propValue === "number" ? propValue : NaN;
357
956
  }
358
957
  if (propType & 1 /* String */) {
359
958
  return String(propValue);
@@ -362,7 +961,9 @@ var parsePropertyValue = (propValue, propType) => {
362
961
  }
363
962
  return propValue;
364
963
  };
365
- var getElement = (ref) => ref;
964
+ var getElement = (ref) => {
965
+ return ref;
966
+ };
366
967
 
367
968
  // src/runtime/event-emitter.ts
368
969
  var createEvent = (ref, name, flags) => {
@@ -370,9 +971,9 @@ var createEvent = (ref, name, flags) => {
370
971
  return {
371
972
  emit: (detail) => {
372
973
  return emitEvent(elm, name, {
373
- bubbles: !!(flags & 4 /* Bubbles */),
374
- composed: !!(flags & 2 /* Composed */),
375
- cancelable: !!(flags & 1 /* Cancellable */),
974
+ bubbles: true,
975
+ composed: true,
976
+ cancelable: true,
376
977
  detail
377
978
  });
378
979
  }
@@ -383,108 +984,108 @@ var emitEvent = (elm, name, opts) => {
383
984
  elm.dispatchEvent(ev);
384
985
  return ev;
385
986
  };
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]) {
987
+ var setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialRender) => {
988
+ if (oldValue === newValue) {
989
+ return;
990
+ }
991
+ let isProp = isMemberInElement(elm, memberName);
992
+ let ln = memberName.toLowerCase();
993
+ if (memberName === "class") {
994
+ const classList = elm.classList;
995
+ const oldClasses = parseClassList(oldValue);
996
+ let newClasses = parseClassList(newValue);
997
+ if ((elm["s-si"] || elm["s-sc"]) && initialRender) {
998
+ const scopeId2 = elm["s-sc"] || elm["s-si"];
999
+ newClasses.push(scopeId2);
1000
+ oldClasses.forEach((c) => {
1001
+ if (c.startsWith(scopeId2)) newClasses.push(c);
1002
+ });
1003
+ newClasses = [...new Set(newClasses)].filter((c) => c);
1004
+ classList.add(...newClasses);
1005
+ } else {
1006
+ classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
1007
+ classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
1008
+ }
1009
+ } else if (memberName === "style") {
1010
+ {
1011
+ for (const prop in oldValue) {
1012
+ if (!newValue || newValue[prop] == null) {
421
1013
  if (prop.includes("-")) {
422
- elm.style.setProperty(prop, newValue[prop]);
1014
+ elm.style.removeProperty(prop);
423
1015
  } else {
424
- elm.style[prop] = newValue[prop];
1016
+ elm.style[prop] = "";
425
1017
  }
426
1018
  }
427
1019
  }
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);
1020
+ }
1021
+ for (const prop in newValue) {
1022
+ if (!oldValue || newValue[prop] !== oldValue[prop]) {
1023
+ if (prop.includes("-")) {
1024
+ elm.style.setProperty(prop, newValue[prop]);
1025
+ } else {
1026
+ elm.style[prop] = newValue[prop];
444
1027
  }
445
1028
  }
1029
+ }
1030
+ } else if (memberName === "key") ; else if ((!elm.__lookupSetter__(memberName)) && memberName[0] === "o" && memberName[1] === "n") {
1031
+ if (memberName[2] === "-") {
1032
+ memberName = memberName.slice(3);
1033
+ } else if (isMemberInElement(win, ln)) {
1034
+ memberName = ln.slice(2);
446
1035
  } 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
- }
1036
+ memberName = ln[2] + memberName.slice(3);
1037
+ }
1038
+ if (oldValue || newValue) {
1039
+ const capture = memberName.endsWith(CAPTURE_EVENT_SUFFIX);
1040
+ memberName = memberName.replace(CAPTURE_EVENT_REGEX, "");
1041
+ if (oldValue) {
1042
+ plt.rel(elm, memberName, oldValue, capture);
1043
+ }
1044
+ if (newValue) {
1045
+ plt.ael(elm, memberName, newValue, capture);
1046
+ }
1047
+ }
1048
+ } else {
1049
+ const isComplex = isComplexType(newValue);
1050
+ if ((isProp || isComplex && newValue !== null) && !isSvg) {
1051
+ try {
1052
+ if (!elm.tagName.includes("-")) {
1053
+ const n = newValue == null ? "" : newValue;
1054
+ if (memberName === "list") {
1055
+ isProp = false;
1056
+ } else if (oldValue == null || elm[memberName] != n) {
1057
+ if (typeof elm.__lookupSetter__(memberName) === "function") {
1058
+ elm[memberName] = n;
1059
+ } else {
1060
+ elm.setAttribute(memberName, n);
460
1061
  }
461
- } else if (elm[memberName] !== newValue) {
462
- elm[memberName] = newValue;
463
1062
  }
464
- } catch (e) {
1063
+ } else if (elm[memberName] !== newValue) {
1064
+ elm[memberName] = newValue;
465
1065
  }
1066
+ } catch (e) {
466
1067
  }
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;
1068
+ }
1069
+ if (newValue == null || newValue === false) {
1070
+ if (newValue !== false || elm.getAttribute(memberName) === "") {
475
1071
  {
476
- elm.setAttribute(memberName, newValue);
1072
+ elm.removeAttribute(memberName);
477
1073
  }
478
1074
  }
1075
+ } else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex && elm.nodeType === 1 /* ElementNode */) {
1076
+ newValue = newValue === true ? "" : newValue;
1077
+ {
1078
+ elm.setAttribute(memberName, newValue);
1079
+ }
479
1080
  }
480
1081
  }
481
1082
  };
482
1083
  var parseClassListRegex = /\s/;
483
1084
  var parseClassList = (value) => {
484
- if (typeof value === "object" && "baseVal" in value) {
1085
+ if (typeof value === "object" && value && "baseVal" in value) {
485
1086
  value = value.baseVal;
486
1087
  }
487
- if (!value) {
1088
+ if (!value || typeof value !== "string") {
488
1089
  return [];
489
1090
  }
490
1091
  return value.split(parseClassListRegex);
@@ -493,19 +1094,35 @@ var CAPTURE_EVENT_SUFFIX = "Capture";
493
1094
  var CAPTURE_EVENT_REGEX = new RegExp(CAPTURE_EVENT_SUFFIX + "$");
494
1095
 
495
1096
  // src/runtime/vdom/update-element.ts
496
- var updateElement = (oldVnode, newVnode, isSvgMode2) => {
1097
+ var updateElement = (oldVnode, newVnode, isSvgMode2, isInitialRender) => {
497
1098
  const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host ? newVnode.$elm$.host : newVnode.$elm$;
498
1099
  const oldVnodeAttrs = oldVnode && oldVnode.$attrs$ || {};
499
1100
  const newVnodeAttrs = newVnode.$attrs$ || {};
500
1101
  {
501
1102
  for (const memberName of sortedAttrNames(Object.keys(oldVnodeAttrs))) {
502
1103
  if (!(memberName in newVnodeAttrs)) {
503
- setAccessor(elm, memberName, oldVnodeAttrs[memberName], void 0, isSvgMode2, newVnode.$flags$);
1104
+ setAccessor(
1105
+ elm,
1106
+ memberName,
1107
+ oldVnodeAttrs[memberName],
1108
+ void 0,
1109
+ isSvgMode2,
1110
+ newVnode.$flags$,
1111
+ isInitialRender
1112
+ );
504
1113
  }
505
1114
  }
506
1115
  }
507
1116
  for (const memberName of sortedAttrNames(Object.keys(newVnodeAttrs))) {
508
- setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode2, newVnode.$flags$);
1117
+ setAccessor(
1118
+ elm,
1119
+ memberName,
1120
+ oldVnodeAttrs[memberName],
1121
+ newVnodeAttrs[memberName],
1122
+ isSvgMode2,
1123
+ newVnode.$flags$,
1124
+ isInitialRender
1125
+ );
509
1126
  }
510
1127
  };
511
1128
  function sortedAttrNames(attrNames) {
@@ -546,14 +1163,22 @@ var createElm = (oldParentVNode, newParentVNode, childIndex) => {
546
1163
  }
547
1164
  }
548
1165
  if (newVNode2.$text$ !== null) {
549
- elm = newVNode2.$elm$ = doc.createTextNode(newVNode2.$text$);
1166
+ elm = newVNode2.$elm$ = win.document.createTextNode(newVNode2.$text$);
550
1167
  } else if (newVNode2.$flags$ & 1 /* isSlotReference */) {
551
- elm = newVNode2.$elm$ = doc.createTextNode("");
1168
+ elm = newVNode2.$elm$ = win.document.createTextNode("");
1169
+ {
1170
+ updateElement(null, newVNode2, isSvgMode);
1171
+ }
552
1172
  } else {
553
1173
  if (!isSvgMode) {
554
1174
  isSvgMode = newVNode2.$tag$ === "svg";
555
1175
  }
556
- elm = newVNode2.$elm$ = doc.createElementNS(
1176
+ if (!win.document) {
1177
+ throw new Error(
1178
+ "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."
1179
+ );
1180
+ }
1181
+ elm = newVNode2.$elm$ = win.document.createElementNS(
557
1182
  isSvgMode ? SVG_NS : HTML_NS,
558
1183
  !useNativeShadowDom && BUILD.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
559
1184
  ) ;
@@ -586,6 +1211,7 @@ var createElm = (oldParentVNode, newParentVNode, childIndex) => {
586
1211
  elm["s-cr"] = contentRef;
587
1212
  elm["s-sn"] = newVNode2.$name$ || "";
588
1213
  elm["s-rf"] = (_a = newVNode2.$attrs$) == null ? void 0 : _a.ref;
1214
+ patchSlotNode(elm);
589
1215
  oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
590
1216
  if (oldVNode && oldVNode.$tag$ === newVNode2.$tag$ && oldParentVNode.$elm$) {
591
1217
  {
@@ -599,14 +1225,6 @@ var createElm = (oldParentVNode, newParentVNode, childIndex) => {
599
1225
  var putBackInOriginalLocation = (parentElm, recursive) => {
600
1226
  plt.$flags$ |= 1 /* isTmpDisconnected */;
601
1227
  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
1228
  for (let i2 = oldSlotChildNodes.length - 1; i2 >= 0; i2--) {
611
1229
  const childNode = oldSlotChildNodes[i2];
612
1230
  if (childNode["s-hn"] !== hostTagName && childNode["s-ol"]) {
@@ -620,7 +1238,7 @@ var putBackInOriginalLocation = (parentElm, recursive) => {
620
1238
  putBackInOriginalLocation(childNode, recursive);
621
1239
  }
622
1240
  }
623
- plt.$flags$ &= ~1 /* isTmpDisconnected */;
1241
+ plt.$flags$ &= -2 /* isTmpDisconnected */;
624
1242
  };
625
1243
  var addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
626
1244
  let containerElm = parentElm["s-cr"] && parentElm["s-cr"].parentNode || parentElm;
@@ -776,9 +1394,7 @@ var patch = (oldVNode, newVNode2, isInitialRender = false) => {
776
1394
  isSvgMode = tag === "svg" ? true : tag === "foreignObject" ? false : isSvgMode;
777
1395
  }
778
1396
  {
779
- if (tag === "slot" && !useNativeShadowDom) ; else {
780
- updateElement(oldVNode, newVNode2, isSvgMode);
781
- }
1397
+ updateElement(oldVNode, newVNode2, isSvgMode, isInitialRender);
782
1398
  }
783
1399
  if (oldChildren !== null && newChildren !== null) {
784
1400
  updateChildren(elm, oldChildren, newVNode2, newChildren, isInitialRender);
@@ -792,6 +1408,8 @@ var patch = (oldVNode, newVNode2, isInitialRender = false) => {
792
1408
  !isInitialRender && BUILD.updatable && oldChildren !== null
793
1409
  ) {
794
1410
  removeVnodes(oldChildren, 0, oldChildren.length - 1);
1411
+ } else if (isInitialRender && BUILD.updatable && oldChildren !== null && newChildren === null) {
1412
+ newVNode2.$children$ = oldChildren;
795
1413
  }
796
1414
  if (isSvgMode && tag === "svg") {
797
1415
  isSvgMode = false;
@@ -814,7 +1432,7 @@ var markSlotContentForRelocation = (elm) => {
814
1432
  const slotName = childNode["s-sn"];
815
1433
  for (j = hostContentNodes.length - 1; j >= 0; j--) {
816
1434
  node = hostContentNodes[j];
817
- if (!node["s-cn"] && !node["s-nr"] && node["s-hn"] !== childNode["s-hn"] && (!BUILD.experimentalSlotFixes )) {
1435
+ if (!node["s-cn"] && !node["s-nr"] && node["s-hn"] !== childNode["s-hn"] && (true)) {
818
1436
  if (isNodeLocatedInSlot(node, slotName)) {
819
1437
  let relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
820
1438
  checkSlotFallbackVisibility = true;
@@ -861,7 +1479,8 @@ var renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
861
1479
  var _a, _b, _c, _d;
862
1480
  const hostElm = hostRef.$hostElement$;
863
1481
  const oldVNode = hostRef.$vnode$ || newVNode(null, null);
864
- const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
1482
+ const isHostElement = isHost(renderFnResults);
1483
+ const rootVnode = isHostElement ? renderFnResults : h(null, null, renderFnResults);
865
1484
  hostTagName = hostElm.tagName;
866
1485
  if (isInitialLoad && rootVnode.$attrs$) {
867
1486
  for (const key of Object.keys(rootVnode.$attrs$)) {
@@ -874,7 +1493,7 @@ var renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
874
1493
  rootVnode.$flags$ |= 4 /* isHost */;
875
1494
  hostRef.$vnode$ = rootVnode;
876
1495
  rootVnode.$elm$ = oldVNode.$elm$ = hostElm;
877
- useNativeShadowDom = supportsShadow ;
1496
+ useNativeShadowDom = supportsShadow;
878
1497
  {
879
1498
  contentRef = hostElm["s-cr"];
880
1499
  checkSlotFallbackVisibility = false;
@@ -886,8 +1505,8 @@ var renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
886
1505
  markSlotContentForRelocation(rootVnode.$elm$);
887
1506
  for (const relocateData of relocateNodes) {
888
1507
  const nodeToRelocate = relocateData.$nodeToRelocate$;
889
- if (!nodeToRelocate["s-ol"]) {
890
- const orgLocationNode = doc.createTextNode("");
1508
+ if (!nodeToRelocate["s-ol"] && win.document) {
1509
+ const orgLocationNode = win.document.createTextNode("");
891
1510
  orgLocationNode["s-nr"] = nodeToRelocate;
892
1511
  insertBefore(nodeToRelocate.parentNode, nodeToRelocate["s-ol"] = orgLocationNode, nodeToRelocate);
893
1512
  }
@@ -928,7 +1547,7 @@ var renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
928
1547
  }
929
1548
  }
930
1549
  }
931
- nodeToRelocate && typeof slotRefNode["s-rf"] === "function" && slotRefNode["s-rf"](nodeToRelocate);
1550
+ nodeToRelocate && typeof slotRefNode["s-rf"] === "function" && slotRefNode["s-rf"](slotRefNode);
932
1551
  } else {
933
1552
  if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
934
1553
  if (isInitialLoad) {
@@ -942,7 +1561,7 @@ var renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
942
1561
  if (checkSlotFallbackVisibility) {
943
1562
  updateFallbackSlotVisibility(rootVnode.$elm$);
944
1563
  }
945
- plt.$flags$ &= ~1 /* isTmpDisconnected */;
1564
+ plt.$flags$ &= -2 /* isTmpDisconnected */;
946
1565
  relocateNodes.length = 0;
947
1566
  }
948
1567
  contentRef = void 0;
@@ -971,6 +1590,12 @@ var scheduleUpdate = (hostRef, isInitialLoad) => {
971
1590
  }
972
1591
  attachToAncestor(hostRef, hostRef.$ancestorComponent$);
973
1592
  const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
1593
+ if (isInitialLoad) {
1594
+ queueMicrotask(() => {
1595
+ dispatch();
1596
+ });
1597
+ return;
1598
+ }
974
1599
  return writeTask(dispatch) ;
975
1600
  };
976
1601
  var dispatchHooks = (hostRef, isInitialLoad) => {
@@ -983,6 +1608,12 @@ var dispatchHooks = (hostRef, isInitialLoad) => {
983
1608
  );
984
1609
  }
985
1610
  let maybePromise;
1611
+ if (isInitialLoad) {
1612
+ maybePromise = safeCall(instance, "componentWillLoad", void 0, elm);
1613
+ } else {
1614
+ maybePromise = safeCall(instance, "componentWillUpdate", void 0, elm);
1615
+ }
1616
+ maybePromise = enqueue(maybePromise, () => safeCall(instance, "componentWillRender", void 0, elm));
986
1617
  endSchedule();
987
1618
  return enqueue(maybePromise, () => updateComponent(hostRef, instance, isInitialLoad));
988
1619
  };
@@ -1022,7 +1653,7 @@ var callRender = (hostRef, instance, elm, isInitialLoad) => {
1022
1653
  try {
1023
1654
  instance = instance.render() ;
1024
1655
  {
1025
- hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
1656
+ hostRef.$flags$ &= -17 /* isQueuedForUpdate */;
1026
1657
  }
1027
1658
  {
1028
1659
  hostRef.$flags$ |= 2 /* hasRendered */;
@@ -1045,14 +1676,13 @@ var postUpdateComponent = (hostRef) => {
1045
1676
  const endPostUpdate = createTime("postUpdate", tagName);
1046
1677
  const instance = elm;
1047
1678
  const ancestorComponent = hostRef.$ancestorComponent$;
1679
+ safeCall(instance, "componentDidRender", void 0, elm);
1048
1680
  if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
1049
1681
  hostRef.$flags$ |= 64 /* hasLoadedComponent */;
1050
1682
  {
1051
1683
  addHydratedFlag(elm);
1052
1684
  }
1053
- {
1054
- safeCall(instance, "componentDidLoad", void 0, elm);
1055
- }
1685
+ safeCall(instance, "componentDidLoad", void 0, elm);
1056
1686
  endPostUpdate();
1057
1687
  {
1058
1688
  hostRef.$onReadyResolve$(elm);
@@ -1061,6 +1691,7 @@ var postUpdateComponent = (hostRef) => {
1061
1691
  }
1062
1692
  }
1063
1693
  } else {
1694
+ safeCall(instance, "componentDidUpdate", void 0, elm);
1064
1695
  endPostUpdate();
1065
1696
  }
1066
1697
  {
@@ -1071,14 +1702,17 @@ var postUpdateComponent = (hostRef) => {
1071
1702
  if (hostRef.$flags$ & 512 /* needsRerender */) {
1072
1703
  nextTick(() => scheduleUpdate(hostRef, false));
1073
1704
  }
1074
- hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
1705
+ hostRef.$flags$ &= -517;
1075
1706
  }
1076
1707
  };
1077
1708
  var appDidLoad = (who) => {
1709
+ var _a;
1710
+ nextTick(() => emitEvent(win, "appload", { detail: { namespace: NAMESPACE } }));
1078
1711
  {
1079
- addHydratedFlag(doc.documentElement);
1712
+ if ((_a = plt.$orgLocNodes$) == null ? void 0 : _a.size) {
1713
+ plt.$orgLocNodes$.clear();
1714
+ }
1080
1715
  }
1081
- nextTick(() => emitEvent(win, "appload", { detail: { namespace: NAMESPACE } }));
1082
1716
  };
1083
1717
  var safeCall = (instance, method, arg, elm) => {
1084
1718
  if (instance && instance[method]) {
@@ -1099,11 +1733,16 @@ var addHydratedFlag = (elm) => {
1099
1733
  var getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
1100
1734
  var setValue = (ref, propName, newVal, cmpMeta) => {
1101
1735
  const hostRef = getHostRef(ref);
1736
+ if (!hostRef) {
1737
+ return;
1738
+ }
1102
1739
  const elm = ref;
1103
1740
  const oldVal = hostRef.$instanceValues$.get(propName);
1104
1741
  const flags = hostRef.$flags$;
1105
1742
  const instance = elm;
1106
- newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
1743
+ newVal = parsePropertyValue(
1744
+ newVal,
1745
+ cmpMeta.$members$[propName][0]);
1107
1746
  const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
1108
1747
  const didValueChange = newVal !== oldVal && !areBothNaN;
1109
1748
  if (didValueChange) {
@@ -1122,6 +1761,11 @@ var setValue = (ref, propName, newVal, cmpMeta) => {
1122
1761
  }
1123
1762
  }
1124
1763
  if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
1764
+ if (instance.componentShouldUpdate) {
1765
+ if (instance.componentShouldUpdate(newVal, oldVal, propName) === false) {
1766
+ return;
1767
+ }
1768
+ }
1125
1769
  scheduleUpdate(hostRef, false);
1126
1770
  }
1127
1771
  }
@@ -1132,9 +1776,17 @@ var setValue = (ref, propName, newVal, cmpMeta) => {
1132
1776
  var proxyComponent = (Cstr, cmpMeta, flags) => {
1133
1777
  var _a, _b;
1134
1778
  const prototype = Cstr.prototype;
1135
- if (cmpMeta.$members$ || (cmpMeta.$watchers$ || Cstr.watchers)) {
1136
- if (Cstr.watchers && !cmpMeta.$watchers$) {
1137
- cmpMeta.$watchers$ = Cstr.watchers;
1779
+ {
1780
+ {
1781
+ if (Cstr.watchers && !cmpMeta.$watchers$) {
1782
+ cmpMeta.$watchers$ = Cstr.watchers;
1783
+ }
1784
+ if (Cstr.deserializers && !cmpMeta.$deserializers$) {
1785
+ cmpMeta.$deserializers$ = Cstr.deserializers;
1786
+ }
1787
+ if (Cstr.serializers && !cmpMeta.$serializers$) {
1788
+ cmpMeta.$serializers$ = Cstr.serializers;
1789
+ }
1138
1790
  }
1139
1791
  const members = Object.entries((_a = cmpMeta.$members$) != null ? _a : {});
1140
1792
  members.map(([memberName, [memberFlags]]) => {
@@ -1142,7 +1794,7 @@ var proxyComponent = (Cstr, cmpMeta, flags) => {
1142
1794
  const { get: origGetter, set: origSetter } = Object.getOwnPropertyDescriptor(prototype, memberName) || {};
1143
1795
  if (origGetter) cmpMeta.$members$[memberName][0] |= 2048 /* Getter */;
1144
1796
  if (origSetter) cmpMeta.$members$[memberName][0] |= 4096 /* Setter */;
1145
- if (flags & 1 /* isElementConstructor */ || !origGetter) {
1797
+ {
1146
1798
  Object.defineProperty(prototype, memberName, {
1147
1799
  get() {
1148
1800
  {
@@ -1156,14 +1808,19 @@ var proxyComponent = (Cstr, cmpMeta, flags) => {
1156
1808
  Object.defineProperty(prototype, memberName, {
1157
1809
  set(newValue) {
1158
1810
  const ref = getHostRef(this);
1811
+ if (!ref) {
1812
+ return;
1813
+ }
1159
1814
  if (origSetter) {
1160
1815
  const currentValue = memberFlags & 32 /* State */ ? this[memberName] : ref.$hostElement$[memberName];
1161
1816
  if (typeof currentValue === "undefined" && ref.$instanceValues$.get(memberName)) {
1162
1817
  newValue = ref.$instanceValues$.get(memberName);
1163
- } else if (!ref.$instanceValues$.get(memberName) && currentValue) {
1164
- ref.$instanceValues$.set(memberName, currentValue);
1165
1818
  }
1166
- origSetter.apply(this, [parsePropertyValue(newValue, memberFlags)]);
1819
+ origSetter.apply(this, [
1820
+ parsePropertyValue(
1821
+ newValue,
1822
+ memberFlags)
1823
+ ]);
1167
1824
  newValue = memberFlags & 32 /* State */ ? this[memberName] : ref.$hostElement$[memberName];
1168
1825
  setValue(this, memberName, newValue, cmpMeta);
1169
1826
  return;
@@ -1182,16 +1839,14 @@ var proxyComponent = (Cstr, cmpMeta, flags) => {
1182
1839
  plt.jmp(() => {
1183
1840
  var _a2;
1184
1841
  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
1842
+ const hostRef = getHostRef(this);
1843
+ if (this.hasOwnProperty(propName) && BUILD.lazyLoad) ;
1844
+ if (prototype.hasOwnProperty(propName) && typeof this[propName] === "number" && // cast type to number to avoid TS compiler issues
1189
1845
  this[propName] == newValue) {
1190
1846
  return;
1191
1847
  } else if (propName == null) {
1192
- const hostRef = getHostRef(this);
1193
1848
  const flags2 = hostRef == null ? void 0 : hostRef.$flags$;
1194
- if (flags2 && !(flags2 & 8 /* isConstructingInstance */) && flags2 & 128 /* isWatchReady */ && newValue !== oldValue) {
1849
+ if (hostRef && flags2 && !(flags2 & 8 /* isConstructingInstance */) && flags2 & 128 /* isWatchReady */ && newValue !== oldValue) {
1195
1850
  const elm = this;
1196
1851
  const instance = elm;
1197
1852
  const entry = (_a2 = cmpMeta.$watchers$) == null ? void 0 : _a2[attrName];
@@ -1203,9 +1858,12 @@ var proxyComponent = (Cstr, cmpMeta, flags) => {
1203
1858
  }
1204
1859
  return;
1205
1860
  }
1861
+ const propFlags = members.find(([m]) => m === propName);
1862
+ if (propFlags && propFlags[1][0] & 4 /* Boolean */) {
1863
+ newValue = newValue === null || newValue === "false" ? false : true;
1864
+ }
1206
1865
  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)) {
1866
+ if (newValue != this[propName] && (!propDesc.get || !!propDesc.set)) {
1209
1867
  this[propName] = newValue;
1210
1868
  }
1211
1869
  });
@@ -1213,7 +1871,7 @@ var proxyComponent = (Cstr, cmpMeta, flags) => {
1213
1871
  Cstr.observedAttributes = Array.from(
1214
1872
  /* @__PURE__ */ new Set([
1215
1873
  ...Object.keys((_b = cmpMeta.$watchers$) != null ? _b : {}),
1216
- ...members.filter(([_, m]) => m[0] & 15 /* HasAttribute */).map(([propName, m]) => {
1874
+ ...members.filter(([_, m]) => m[0] & 31 /* HasAttribute */).map(([propName, m]) => {
1217
1875
  const attrName = m[1] || propName;
1218
1876
  attrNameToPropName.set(attrName, propName);
1219
1877
  return attrName;
@@ -1249,11 +1907,21 @@ var fireConnectedCallback = (instance, elm) => {
1249
1907
  var connectedCallback = (elm) => {
1250
1908
  if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1251
1909
  const hostRef = getHostRef(elm);
1910
+ if (!hostRef) {
1911
+ return;
1912
+ }
1252
1913
  const cmpMeta = hostRef.$cmpMeta$;
1253
1914
  const endConnected = createTime("connectedCallback", cmpMeta.$tagName$);
1254
1915
  if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
1255
1916
  hostRef.$flags$ |= 1 /* hasConnected */;
1917
+ let hostId;
1256
1918
  {
1919
+ hostId = elm.getAttribute(HYDRATE_ID);
1920
+ if (hostId) {
1921
+ initializeClientHydrate(elm, cmpMeta.$tagName$, hostId, hostRef);
1922
+ }
1923
+ }
1924
+ if (!hostId) {
1257
1925
  if (// TODO(STENCIL-854): Remove code related to legacy shadowDomShim field
1258
1926
  cmpMeta.$flags$ & (4 /* hasSlotRelocation */ | 8 /* needsShadowDomShim */)) {
1259
1927
  setContentReference(elm);
@@ -1262,7 +1930,7 @@ var connectedCallback = (elm) => {
1262
1930
  {
1263
1931
  let ancestorComponent = elm;
1264
1932
  while (ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host) {
1265
- if (ancestorComponent["s-p"]) {
1933
+ if (ancestorComponent.nodeType === 1 /* ElementNode */ && ancestorComponent.hasAttribute("s-id") && ancestorComponent["s-p"] || ancestorComponent["s-p"]) {
1266
1934
  attachToAncestor(hostRef, hostRef.$ancestorComponent$ = ancestorComponent);
1267
1935
  break;
1268
1936
  }
@@ -1270,7 +1938,7 @@ var connectedCallback = (elm) => {
1270
1938
  }
1271
1939
  if (cmpMeta.$members$) {
1272
1940
  Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
1273
- if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
1941
+ if (memberFlags & 31 /* Prop */ && memberName in elm && elm[memberName] !== Object.prototype[memberName]) {
1274
1942
  const value = elm[memberName];
1275
1943
  delete elm[memberName];
1276
1944
  elm[memberName] = value;
@@ -1289,7 +1957,10 @@ var connectedCallback = (elm) => {
1289
1957
  }
1290
1958
  };
1291
1959
  var setContentReference = (elm) => {
1292
- const contentRefElm = elm["s-cr"] = doc.createComment(
1960
+ if (!win.document) {
1961
+ return;
1962
+ }
1963
+ const contentRefElm = elm["s-cr"] = win.document.createComment(
1293
1964
  ""
1294
1965
  );
1295
1966
  contentRefElm["s-cn"] = true;
@@ -1316,6 +1987,8 @@ var proxyCustomElement = (Cstr, compactMeta) => {
1316
1987
  }
1317
1988
  {
1318
1989
  cmpMeta.$watchers$ = Cstr.$watchers$;
1990
+ cmpMeta.$deserializers$ = Cstr.$deserializers$;
1991
+ cmpMeta.$serializers$ = Cstr.$serializers$;
1319
1992
  }
1320
1993
  const originalConnectedCallback = Cstr.prototype.connectedCallback;
1321
1994
  const originalDisconnectedCallback = Cstr.prototype.disconnectedCallback;
@@ -1326,7 +1999,10 @@ var proxyCustomElement = (Cstr, compactMeta) => {
1326
1999
  },
1327
2000
  connectedCallback() {
1328
2001
  if (!this.__hasHostListenerAttached) {
1329
- getHostRef(this);
2002
+ const hostRef = getHostRef(this);
2003
+ if (!hostRef) {
2004
+ return;
2005
+ }
1330
2006
  this.__hasHostListenerAttached = true;
1331
2007
  }
1332
2008
  connectedCallback(this);
@@ -1339,16 +2015,6 @@ var proxyCustomElement = (Cstr, compactMeta) => {
1339
2015
  if (originalDisconnectedCallback) {
1340
2016
  originalDisconnectedCallback.call(this);
1341
2017
  }
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
2018
  },
1353
2019
  __attachShadow() {
1354
2020
  {
@@ -1357,7 +2023,7 @@ var proxyCustomElement = (Cstr, compactMeta) => {
1357
2023
  }
1358
2024
  });
1359
2025
  Cstr.is = cmpMeta.$tagName$;
1360
- return proxyComponent(Cstr, cmpMeta, 1 /* isElementConstructor */ | 2 /* proxyState */);
2026
+ return proxyComponent(Cstr, cmpMeta);
1361
2027
  };
1362
2028
 
1363
2029
  // src/runtime/fragment.ts
@@ -1369,6 +2035,15 @@ var setNonce = (nonce) => plt.$nonce$ = nonce;
1369
2035
  // src/runtime/platform-options.ts
1370
2036
  var setPlatformOptions = (opts) => Object.assign(plt, opts);
1371
2037
 
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 };
2038
+ // src/runtime/render.ts
2039
+ function render(vnode, container) {
2040
+ const ref = {
2041
+ $hostElement$: container
2042
+ };
2043
+ renderVdom(ref, vnode);
2044
+ }
2045
+
2046
+ 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 };
2047
+ //# sourceMappingURL=p-DO5g2x-l.js.map
1373
2048
 
1374
- //# sourceMappingURL=p-5365011f.js.map
2049
+ //# sourceMappingURL=p-DO5g2x-l.js.map