@maggioli-design-system/mds-paginator-item 1.0.0 → 1.0.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 (53) hide show
  1. package/dist/cjs/{index-e927fcce.js → index-09bfd856.js} +346 -183
  2. package/dist/cjs/loader.cjs.js +2 -2
  3. package/dist/cjs/mds-paginator-item.cjs.entry.js +6 -42
  4. package/dist/cjs/mds-paginator-item.cjs.js +2 -2
  5. package/dist/collection/collection-manifest.json +2 -2
  6. package/dist/collection/common/aria.js +19 -0
  7. package/dist/collection/components/mds-paginator-item/mds-paginator-item.css +0 -2
  8. package/dist/collection/components/mds-paginator-item/mds-paginator-item.js +70 -60
  9. package/dist/collection/dictionary/typography.js +3 -3
  10. package/dist/components/mds-paginator-item.js +5 -41
  11. package/dist/esm/{index-83a6cf7b.js → index-664c340a.js} +346 -183
  12. package/dist/esm/loader.js +2 -2
  13. package/dist/esm/mds-paginator-item.entry.js +6 -42
  14. package/dist/esm/mds-paginator-item.js +2 -2
  15. package/dist/esm/polyfills/css-shim.js +1 -1
  16. package/dist/esm-es5/index-664c340a.js +2 -0
  17. package/dist/esm-es5/loader.js +1 -1
  18. package/dist/esm-es5/mds-paginator-item.entry.js +1 -1
  19. package/dist/esm-es5/mds-paginator-item.js +1 -1
  20. package/dist/mds-paginator-item/mds-paginator-item.esm.js +1 -1
  21. package/dist/mds-paginator-item/mds-paginator-item.js +2 -1
  22. package/dist/mds-paginator-item/p-03657157.system.js +2 -0
  23. package/dist/mds-paginator-item/p-3399bcad.entry.js +1 -0
  24. package/dist/mds-paginator-item/p-393b666e.js +2 -0
  25. package/dist/mds-paginator-item/p-5e5227f1.system.entry.js +1 -0
  26. package/dist/mds-paginator-item/{p-5763f0b1.system.js → p-618229c2.system.js} +1 -1
  27. package/dist/stats.json +36 -34
  28. package/dist/types/common/aria.d.ts +4 -0
  29. package/dist/types/stencil-public-runtime.d.ts +20 -4
  30. package/dist/types/types/typography.d.ts +3 -3
  31. package/loader/package.json +1 -0
  32. package/package.json +3 -3
  33. package/src/common/aria.ts +27 -0
  34. package/src/components/mds-paginator-item/.gitlab-ci.yml +2 -2
  35. package/src/dictionary/typography.ts +3 -3
  36. package/src/fixtures/icons.json +2 -2
  37. package/src/types/typography.ts +3 -3
  38. package/www/build/mds-paginator-item.esm.js +1 -1
  39. package/www/build/mds-paginator-item.js +2 -1
  40. package/www/build/p-03657157.system.js +2 -0
  41. package/www/build/p-3399bcad.entry.js +1 -0
  42. package/www/build/p-393b666e.js +2 -0
  43. package/www/build/p-5e5227f1.system.entry.js +1 -0
  44. package/www/build/{p-5763f0b1.system.js → p-618229c2.system.js} +1 -1
  45. package/dist/esm-es5/index-83a6cf7b.js +0 -2
  46. package/dist/mds-paginator-item/p-443e8754.system.entry.js +0 -1
  47. package/dist/mds-paginator-item/p-4cba8bec.system.js +0 -2
  48. package/dist/mds-paginator-item/p-9275c4d0.js +0 -2
  49. package/dist/mds-paginator-item/p-b378e187.entry.js +0 -1
  50. package/www/build/p-443e8754.system.entry.js +0 -1
  51. package/www/build/p-4cba8bec.system.js +0 -2
  52. package/www/build/p-9275c4d0.js +0 -2
  53. package/www/build/p-b378e187.entry.js +0 -1
@@ -22,32 +22,18 @@ function _interopNamespace(e) {
22
22
 
23
23
  const NAMESPACE = 'mds-paginator-item';
24
24
 
25
+ /**
26
+ * Virtual DOM patching algorithm based on Snabbdom by
27
+ * Simon Friis Vindum (@paldepind)
28
+ * Licensed under the MIT License
29
+ * https://github.com/snabbdom/snabbdom/blob/master/LICENSE
30
+ *
31
+ * Modified for Stencil's renderer and slot projection
32
+ */
25
33
  let scopeId;
26
34
  let hostTagName;
27
35
  let isSvgMode = false;
28
36
  let queuePending = false;
29
- const win = typeof window !== 'undefined' ? window : {};
30
- const doc = win.document || { head: {} };
31
- const plt = {
32
- $flags$: 0,
33
- $resourcesUrl$: '',
34
- jmp: (h) => h(),
35
- raf: (h) => requestAnimationFrame(h),
36
- ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
37
- rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
38
- ce: (eventName, opts) => new CustomEvent(eventName, opts),
39
- };
40
- const promiseResolve = (v) => Promise.resolve(v);
41
- const supportsConstructibleStylesheets = /*@__PURE__*/ (() => {
42
- try {
43
- new CSSStyleSheet();
44
- return typeof new CSSStyleSheet().replace === 'function';
45
- }
46
- catch (e) { }
47
- return false;
48
- })()
49
- ;
50
- const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
51
37
  const createTime = (fnName, tagName = '') => {
52
38
  {
53
39
  return () => {
@@ -62,71 +48,7 @@ const uniqueTime = (key, measureText) => {
62
48
  };
63
49
  }
64
50
  };
65
- const rootAppliedStyles = new WeakMap();
66
- const registerStyle = (scopeId, cssText, allowCS) => {
67
- let style = styles.get(scopeId);
68
- if (supportsConstructibleStylesheets && allowCS) {
69
- style = (style || new CSSStyleSheet());
70
- style.replace(cssText);
71
- }
72
- else {
73
- style = cssText;
74
- }
75
- styles.set(scopeId, style);
76
- };
77
- const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
78
- let scopeId = getScopeId(cmpMeta);
79
- const style = styles.get(scopeId);
80
- // if an element is NOT connected then getRootNode() will return the wrong root node
81
- // so the fallback is to always use the document for the root node in those cases
82
- styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
83
- if (style) {
84
- if (typeof style === 'string') {
85
- styleContainerNode = styleContainerNode.head || styleContainerNode;
86
- let appliedStyles = rootAppliedStyles.get(styleContainerNode);
87
- let styleElm;
88
- if (!appliedStyles) {
89
- rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
90
- }
91
- if (!appliedStyles.has(scopeId)) {
92
- {
93
- {
94
- styleElm = doc.createElement('style');
95
- styleElm.innerHTML = style;
96
- }
97
- styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
98
- }
99
- if (appliedStyles) {
100
- appliedStyles.add(scopeId);
101
- }
102
- }
103
- }
104
- else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
105
- styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
106
- }
107
- }
108
- return scopeId;
109
- };
110
- const attachStyles = (hostRef) => {
111
- const cmpMeta = hostRef.$cmpMeta$;
112
- const elm = hostRef.$hostElement$;
113
- const flags = cmpMeta.$flags$;
114
- const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
115
- const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
116
- if (flags & 10 /* needsScopedEncapsulation */) {
117
- // only required when we're NOT using native shadow dom (slot)
118
- // or this browser doesn't support native shadow dom
119
- // and this host element was NOT created with SSR
120
- // let's pick out the inner content for slot projection
121
- // create a node to represent where the original
122
- // content was first placed, which is useful later on
123
- // DOM WRITE!!
124
- elm['s-sc'] = scopeId;
125
- elm.classList.add(scopeId + '-h');
126
- }
127
- endAttachStyles();
128
- };
129
- const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
51
+ const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
130
52
  /**
131
53
  * Default style mode id
132
54
  */
@@ -215,6 +137,131 @@ const newVNode = (tag, text) => {
215
137
  };
216
138
  const Host = {};
217
139
  const isHost = (node) => node && node.$tag$ === Host;
140
+ /**
141
+ * Parse a new property value for a given property type.
142
+ *
143
+ * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
144
+ * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
145
+ * 1. `any`, the type given to `propValue` in the function signature
146
+ * 2. the type stored from `propType`.
147
+ *
148
+ * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
149
+ *
150
+ * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
151
+ * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
152
+ * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
153
+ * ```tsx
154
+ * <my-cmp prop-val={0}></my-cmp>
155
+ * ```
156
+ *
157
+ * HTML prop values on the other hand, will always a string
158
+ *
159
+ * @param propValue the new value to coerce to some type
160
+ * @param propType the type of the prop, expressed as a binary number
161
+ * @returns the parsed/coerced value
162
+ */
163
+ const parsePropertyValue = (propValue, propType) => {
164
+ // ensure this value is of the correct prop type
165
+ if (propValue != null && !isComplexType(propValue)) {
166
+ if (propType & 4 /* MEMBER_FLAGS.Boolean */) {
167
+ // per the HTML spec, any string value means it is a boolean true value
168
+ // but we'll cheat here and say that the string "false" is the boolean false
169
+ return propValue === 'false' ? false : propValue === '' || !!propValue;
170
+ }
171
+ if (propType & 1 /* MEMBER_FLAGS.String */) {
172
+ // could have been passed as a number or boolean
173
+ // but we still want it as a string
174
+ return String(propValue);
175
+ }
176
+ // redundant return here for better minification
177
+ return propValue;
178
+ }
179
+ // not sure exactly what type we want
180
+ // so no need to change to a different type
181
+ return propValue;
182
+ };
183
+ /**
184
+ * Helper function to create & dispatch a custom Event on a provided target
185
+ * @param elm the target of the Event
186
+ * @param name the name to give the custom Event
187
+ * @param opts options for configuring a custom Event
188
+ * @returns the custom Event
189
+ */
190
+ const emitEvent = (elm, name, opts) => {
191
+ const ev = plt.ce(name, opts);
192
+ elm.dispatchEvent(ev);
193
+ return ev;
194
+ };
195
+ const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
196
+ const registerStyle = (scopeId, cssText, allowCS) => {
197
+ let style = styles.get(scopeId);
198
+ if (supportsConstructableStylesheets && allowCS) {
199
+ style = (style || new CSSStyleSheet());
200
+ if (typeof style === 'string') {
201
+ style = cssText;
202
+ }
203
+ else {
204
+ style.replaceSync(cssText);
205
+ }
206
+ }
207
+ else {
208
+ style = cssText;
209
+ }
210
+ styles.set(scopeId, style);
211
+ };
212
+ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
213
+ let scopeId = getScopeId(cmpMeta);
214
+ const style = styles.get(scopeId);
215
+ // if an element is NOT connected then getRootNode() will return the wrong root node
216
+ // so the fallback is to always use the document for the root node in those cases
217
+ styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
218
+ if (style) {
219
+ if (typeof style === 'string') {
220
+ styleContainerNode = styleContainerNode.head || styleContainerNode;
221
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
222
+ let styleElm;
223
+ if (!appliedStyles) {
224
+ rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
225
+ }
226
+ if (!appliedStyles.has(scopeId)) {
227
+ {
228
+ {
229
+ styleElm = doc.createElement('style');
230
+ styleElm.innerHTML = style;
231
+ }
232
+ styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
233
+ }
234
+ if (appliedStyles) {
235
+ appliedStyles.add(scopeId);
236
+ }
237
+ }
238
+ }
239
+ else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
240
+ styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
241
+ }
242
+ }
243
+ return scopeId;
244
+ };
245
+ const attachStyles = (hostRef) => {
246
+ const cmpMeta = hostRef.$cmpMeta$;
247
+ const elm = hostRef.$hostElement$;
248
+ const flags = cmpMeta.$flags$;
249
+ const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
250
+ const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
251
+ if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
252
+ // only required when we're NOT using native shadow dom (slot)
253
+ // or this browser doesn't support native shadow dom
254
+ // and this host element was NOT created with SSR
255
+ // let's pick out the inner content for slot projection
256
+ // create a node to represent where the original
257
+ // content was first placed, which is useful later on
258
+ // DOM WRITE!!
259
+ elm['s-sc'] = scopeId;
260
+ elm.classList.add(scopeId + '-h');
261
+ }
262
+ endAttachStyles();
263
+ };
264
+ const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
218
265
  /**
219
266
  * Production setAccessor() function based on Preact by
220
267
  * Jason Miller (@developit)
@@ -262,7 +309,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
262
309
  }
263
310
  }
264
311
  }
265
- else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
312
+ else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
266
313
  newValue = newValue === true ? '' : newValue;
267
314
  {
268
315
  elm.setAttribute(memberName, newValue);
@@ -277,7 +324,7 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
277
324
  // if the element passed in is a shadow root, which is a document fragment
278
325
  // then we want to be adding attrs/props to the shadow root's "host" element
279
326
  // if it's not a shadow root, then we add attrs/props to the same element
280
- const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host
327
+ const elm = newVnode.$elm$.nodeType === 11 /* NODE_TYPE.DocumentFragment */ && newVnode.$elm$.host
281
328
  ? newVnode.$elm$.host
282
329
  : newVnode.$elm$;
283
330
  const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
@@ -295,6 +342,16 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
295
342
  setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
296
343
  }
297
344
  };
345
+ /**
346
+ * Create a DOM Node corresponding to one of the children of a given VNode.
347
+ *
348
+ * @param oldParentVNode the parent VNode from the previous render
349
+ * @param newParentVNode the parent VNode from the current render
350
+ * @param childIndex the index of the VNode, in the _new_ parent node's
351
+ * children, for which we will create a new DOM node
352
+ * @param parentElm the parent DOM node which our new node will be a child of
353
+ * @returns the newly created node
354
+ */
298
355
  const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
299
356
  // tslint:disable-next-line: prefer-const
300
357
  const newVNode = newParentVNode.$children$[childIndex];
@@ -356,6 +413,74 @@ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
356
413
  }
357
414
  }
358
415
  };
416
+ /**
417
+ * Reconcile the children of a new VNode with the children of an old VNode by
418
+ * traversing the two collections of children, identifying nodes that are
419
+ * conserved or changed, calling out to `patch` to make any necessary
420
+ * updates to the DOM, and rearranging DOM nodes as needed.
421
+ *
422
+ * The algorithm for reconciling children works by analyzing two 'windows' onto
423
+ * the two arrays of children (`oldCh` and `newCh`). We keep track of the
424
+ * 'windows' by storing start and end indices and references to the
425
+ * corresponding array entries. Initially the two 'windows' are basically equal
426
+ * to the entire array, but we progressively narrow the windows until there are
427
+ * no children left to update by doing the following:
428
+ *
429
+ * 1. Skip any `null` entries at the beginning or end of the two arrays, so
430
+ * that if we have an initial array like the following we'll end up dealing
431
+ * only with a window bounded by the highlighted elements:
432
+ *
433
+ * [null, null, VNode1 , ... , VNode2, null, null]
434
+ * ^^^^^^ ^^^^^^
435
+ *
436
+ * 2. Check to see if the elements at the head and tail positions are equal
437
+ * across the windows. This will basically detect elements which haven't
438
+ * been added, removed, or changed position, i.e. if you had the following
439
+ * VNode elements (represented as HTML):
440
+ *
441
+ * oldVNode: `<div><p><span>HEY</span></p></div>`
442
+ * newVNode: `<div><p><span>THERE</span></p></div>`
443
+ *
444
+ * Then when comparing the children of the `<div>` tag we check the equality
445
+ * of the VNodes corresponding to the `<p>` tags and, since they are the
446
+ * same tag in the same position, we'd be able to avoid completely
447
+ * re-rendering the subtree under them with a new DOM element and would just
448
+ * call out to `patch` to handle reconciling their children and so on.
449
+ *
450
+ * 3. Check, for both windows, to see if the element at the beginning of the
451
+ * window corresponds to the element at the end of the other window. This is
452
+ * a heuristic which will let us identify _some_ situations in which
453
+ * elements have changed position, for instance it _should_ detect that the
454
+ * children nodes themselves have not changed but merely moved in the
455
+ * following example:
456
+ *
457
+ * oldVNode: `<div><element-one /><element-two /></div>`
458
+ * newVNode: `<div><element-two /><element-one /></div>`
459
+ *
460
+ * If we find cases like this then we also need to move the concrete DOM
461
+ * elements corresponding to the moved children to write the re-order to the
462
+ * DOM.
463
+ *
464
+ * 4. Finally, if VNodes have the `key` attribute set on them we check for any
465
+ * nodes in the old children which have the same key as the first element in
466
+ * our window on the new children. If we find such a node we handle calling
467
+ * out to `patch`, moving relevant DOM nodes, and so on, in accordance with
468
+ * what we find.
469
+ *
470
+ * Finally, once we've narrowed our 'windows' to the point that either of them
471
+ * collapse (i.e. they have length 0) we then handle any remaining VNode
472
+ * insertion or deletion that needs to happen to get a DOM state that correctly
473
+ * reflects the new child VNodes. If, for instance, after our window on the old
474
+ * children has collapsed we still have more nodes on the new children that
475
+ * we haven't dealt with yet then we need to add them, or if the new children
476
+ * collapse but we still have unhandled _old_ children then we need to make
477
+ * sure the corresponding DOM nodes are removed.
478
+ *
479
+ * @param parentElm the node into which the parent VNode is rendered
480
+ * @param oldCh the old children of the parent node
481
+ * @param newVNode the new VNode which will replace the parent
482
+ * @param newCh the new children of the parent node
483
+ */
359
484
  const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
360
485
  let oldStartIdx = 0;
361
486
  let newStartIdx = 0;
@@ -368,7 +493,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
368
493
  let node;
369
494
  while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
370
495
  if (oldStartVnode == null) {
371
- // Vnode might have been moved left
496
+ // VNode might have been moved left
372
497
  oldStartVnode = oldCh[++oldStartIdx];
373
498
  }
374
499
  else if (oldEndVnode == null) {
@@ -381,34 +506,67 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
381
506
  newEndVnode = newCh[--newEndIdx];
382
507
  }
383
508
  else if (isSameVnode(oldStartVnode, newStartVnode)) {
509
+ // if the start nodes are the same then we should patch the new VNode
510
+ // onto the old one, and increment our `newStartIdx` and `oldStartIdx`
511
+ // indices to reflect that. We don't need to move any DOM Nodes around
512
+ // since things are matched up in order.
384
513
  patch(oldStartVnode, newStartVnode);
385
514
  oldStartVnode = oldCh[++oldStartIdx];
386
515
  newStartVnode = newCh[++newStartIdx];
387
516
  }
388
517
  else if (isSameVnode(oldEndVnode, newEndVnode)) {
518
+ // likewise, if the end nodes are the same we patch new onto old and
519
+ // decrement our end indices, and also likewise in this case we don't
520
+ // need to move any DOM Nodes.
389
521
  patch(oldEndVnode, newEndVnode);
390
522
  oldEndVnode = oldCh[--oldEndIdx];
391
523
  newEndVnode = newCh[--newEndIdx];
392
524
  }
393
525
  else if (isSameVnode(oldStartVnode, newEndVnode)) {
394
526
  patch(oldStartVnode, newEndVnode);
527
+ // We need to move the element for `oldStartVnode` into a position which
528
+ // will be appropriate for `newEndVnode`. For this we can use
529
+ // `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
530
+ // sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
531
+ // `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
532
+ //
533
+ // <old-start-node />
534
+ // <some-intervening-node />
535
+ // <old-end-node />
536
+ // <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
537
+ // <next-sibling />
538
+ //
539
+ // If instead `oldEndVnode.$elm$` has no sibling then we just want to put
540
+ // the node for `oldStartVnode` at the end of the children of
541
+ // `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
542
+ // aren't any siblings, and passing `null` to `Node.insertBefore` will
543
+ // append it to the children of the parent element.
395
544
  parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
396
545
  oldStartVnode = oldCh[++oldStartIdx];
397
546
  newEndVnode = newCh[--newEndIdx];
398
547
  }
399
548
  else if (isSameVnode(oldEndVnode, newStartVnode)) {
400
549
  patch(oldEndVnode, newStartVnode);
550
+ // We've already checked above if `oldStartVnode` and `newStartVnode` are
551
+ // the same node, so since we're here we know that they are not. Thus we
552
+ // can move the element for `oldEndVnode` _before_ the element for
553
+ // `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
554
+ // future.
401
555
  parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
402
556
  oldEndVnode = oldCh[--oldEndIdx];
403
557
  newStartVnode = newCh[++newStartIdx];
404
558
  }
405
559
  else {
406
560
  {
407
- // new element
561
+ // We either didn't find an element in the old children that matches
562
+ // the key of the first new child OR the build is not using `key`
563
+ // attributes at all. In either case we need to create a new element
564
+ // for the new node.
408
565
  node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
409
566
  newStartVnode = newCh[++newStartIdx];
410
567
  }
411
568
  if (node) {
569
+ // if we created a new node then handle inserting it to the DOM
412
570
  {
413
571
  oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
414
572
  }
@@ -416,20 +574,49 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
416
574
  }
417
575
  }
418
576
  if (oldStartIdx > oldEndIdx) {
577
+ // we have some more new nodes to add which don't match up with old nodes
419
578
  addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
420
579
  }
421
580
  else if (newStartIdx > newEndIdx) {
581
+ // there are nodes in the `oldCh` array which no longer correspond to nodes
582
+ // in the new array, so lets remove them (which entails cleaning up the
583
+ // relevant DOM nodes)
422
584
  removeVnodes(oldCh, oldStartIdx, oldEndIdx);
423
585
  }
424
586
  };
425
- const isSameVnode = (vnode1, vnode2) => {
587
+ /**
588
+ * Compare two VNodes to determine if they are the same
589
+ *
590
+ * **NB**: This function is an equality _heuristic_ based on the available
591
+ * information set on the two VNodes and can be misleading under certain
592
+ * circumstances. In particular, if the two nodes do not have `key` attrs
593
+ * (available under `$key$` on VNodes) then the function falls back on merely
594
+ * checking that they have the same tag.
595
+ *
596
+ * So, in other words, if `key` attrs are not set on VNodes which may be
597
+ * changing order within a `children` array or something along those lines then
598
+ * we could obtain a false positive and then have to do needless re-rendering.
599
+ *
600
+ * @param leftVNode the first VNode to check
601
+ * @param rightVNode the second VNode to check
602
+ * @returns whether they're equal or not
603
+ */
604
+ const isSameVnode = (leftVNode, rightVNode) => {
426
605
  // compare if two vnode to see if they're "technically" the same
427
606
  // need to have the same element tag, and same key to be the same
428
- if (vnode1.$tag$ === vnode2.$tag$) {
607
+ if (leftVNode.$tag$ === rightVNode.$tag$) {
429
608
  return true;
430
609
  }
431
610
  return false;
432
611
  };
612
+ /**
613
+ * Handle reconciling an outdated VNode with a new one which corresponds to
614
+ * it. This function handles flushing updates to the DOM and reconciling the
615
+ * children of the two nodes (if any).
616
+ *
617
+ * @param oldVNode an old VNode whose DOM element and children we want to update
618
+ * @param newVNode a new VNode representing an updated version of the old one
619
+ */
433
620
  const patch = (oldVNode, newVNode) => {
434
621
  const elm = (newVNode.$elm$ = oldVNode.$elm$);
435
622
  const oldChildren = oldVNode.$children$;
@@ -437,7 +624,6 @@ const patch = (oldVNode, newVNode) => {
437
624
  const tag = newVNode.$tag$;
438
625
  const text = newVNode.$text$;
439
626
  if (text === null) {
440
- // element node
441
627
  {
442
628
  if (tag === 'slot')
443
629
  ;
@@ -450,6 +636,7 @@ const patch = (oldVNode, newVNode) => {
450
636
  }
451
637
  if (oldChildren !== null && newChildren !== null) {
452
638
  // looks like there's child vnodes for both the old and new vnodes
639
+ // so we need to call `updateChildren` to reconcile them
453
640
  updateChildren(elm, oldChildren, newVNode, newChildren);
454
641
  }
455
642
  else if (newChildren !== null) {
@@ -483,7 +670,7 @@ const renderVdom = (hostRef, renderFnResults) => {
483
670
  cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
484
671
  }
485
672
  rootVnode.$tag$ = null;
486
- rootVnode.$flags$ |= 4 /* isHost */;
673
+ rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
487
674
  hostRef.$vnode$ = rootVnode;
488
675
  rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
489
676
  {
@@ -492,18 +679,6 @@ const renderVdom = (hostRef, renderFnResults) => {
492
679
  // synchronous patch
493
680
  patch(oldVNode, rootVnode);
494
681
  };
495
- /**
496
- * Helper function to create & dispatch a custom Event on a provided target
497
- * @param elm the target of the Event
498
- * @param name the name to give the custom Event
499
- * @param opts options for configuring a custom Event
500
- * @returns the custom Event
501
- */
502
- const emitEvent = (elm, name, opts) => {
503
- const ev = plt.ce(name, opts);
504
- elm.dispatchEvent(ev);
505
- return ev;
506
- };
507
682
  const attachToAncestor = (hostRef, ancestorComponent) => {
508
683
  if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
509
684
  ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
@@ -511,10 +686,10 @@ const attachToAncestor = (hostRef, ancestorComponent) => {
511
686
  };
512
687
  const scheduleUpdate = (hostRef, isInitialLoad) => {
513
688
  {
514
- hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
689
+ hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
515
690
  }
516
- if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
517
- hostRef.$flags$ |= 512 /* needsRerender */;
691
+ if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
692
+ hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
518
693
  return;
519
694
  }
520
695
  attachToAncestor(hostRef, hostRef.$ancestorComponent$);
@@ -561,7 +736,7 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
561
736
  }
562
737
  else {
563
738
  Promise.all(childrenPromises).then(postUpdate);
564
- hostRef.$flags$ |= 4 /* isWaitingForChildren */;
739
+ hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
565
740
  childrenPromises.length = 0;
566
741
  }
567
742
  }
@@ -570,10 +745,10 @@ const callRender = (hostRef, instance, elm) => {
570
745
  try {
571
746
  instance = instance.render() ;
572
747
  {
573
- hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
748
+ hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
574
749
  }
575
750
  {
576
- hostRef.$flags$ |= 2 /* hasRendered */;
751
+ hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
577
752
  }
578
753
  {
579
754
  {
@@ -596,8 +771,8 @@ const postUpdateComponent = (hostRef) => {
596
771
  const elm = hostRef.$hostElement$;
597
772
  const endPostUpdate = createTime('postUpdate', tagName);
598
773
  const ancestorComponent = hostRef.$ancestorComponent$;
599
- if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
600
- hostRef.$flags$ |= 64 /* hasLoadedComponent */;
774
+ if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
775
+ hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
601
776
  {
602
777
  // DOM WRITE!
603
778
  addHydratedFlag(elm);
@@ -620,10 +795,10 @@ const postUpdateComponent = (hostRef) => {
620
795
  hostRef.$onRenderResolve$();
621
796
  hostRef.$onRenderResolve$ = undefined;
622
797
  }
623
- if (hostRef.$flags$ & 512 /* needsRerender */) {
798
+ if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
624
799
  nextTick(() => scheduleUpdate(hostRef, false));
625
800
  }
626
- hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
801
+ hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
627
802
  }
628
803
  // ( •_•)
629
804
  // ( •_•)>⌐■-■
@@ -642,49 +817,6 @@ const then = (promise, thenFn) => {
642
817
  };
643
818
  const addHydratedFlag = (elm) => elm.classList.add('hydrated')
644
819
  ;
645
- /**
646
- * Parse a new property value for a given property type.
647
- *
648
- * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
649
- * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
650
- * 1. `any`, the type given to `propValue` in the function signature
651
- * 2. the type stored from `propType`.
652
- *
653
- * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
654
- *
655
- * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
656
- * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
657
- * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
658
- * ```tsx
659
- * <my-cmp prop-val={0}></my-cmp>
660
- * ```
661
- *
662
- * HTML prop values on the other hand, will always a string
663
- *
664
- * @param propValue the new value to coerce to some type
665
- * @param propType the type of the prop, expressed as a binary number
666
- * @returns the parsed/coerced value
667
- */
668
- const parsePropertyValue = (propValue, propType) => {
669
- // ensure this value is of the correct prop type
670
- if (propValue != null && !isComplexType(propValue)) {
671
- if (propType & 4 /* Boolean */) {
672
- // per the HTML spec, any string value means it is a boolean true value
673
- // but we'll cheat here and say that the string "false" is the boolean false
674
- return propValue === 'false' ? false : propValue === '' || !!propValue;
675
- }
676
- if (propType & 1 /* String */) {
677
- // could have been passed as a number or boolean
678
- // but we still want it as a string
679
- return String(propValue);
680
- }
681
- // redundant return here for better minification
682
- return propValue;
683
- }
684
- // not sure exactly what type we want
685
- // so no need to change to a different type
686
- return propValue;
687
- };
688
820
  const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
689
821
  const setValue = (ref, propName, newVal, cmpMeta) => {
690
822
  // check our new property value against our internal value
@@ -696,12 +828,12 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
696
828
  // explicitly check for NaN on both sides, as `NaN === NaN` is always false
697
829
  const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
698
830
  const didValueChange = newVal !== oldVal && !areBothNaN;
699
- if ((!(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && didValueChange) {
831
+ if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
700
832
  // gadzooks! the property's value has changed!!
701
833
  // set our new value!
702
834
  hostRef.$instanceValues$.set(propName, newVal);
703
835
  if (instance) {
704
- if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
836
+ if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
705
837
  // looks like this value actually changed, so we've got work to do!
706
838
  // but only if we've already rendered, otherwise just chill out
707
839
  // queue that we need to do an update, but don't worry about queuing
@@ -711,14 +843,24 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
711
843
  }
712
844
  }
713
845
  };
846
+ /**
847
+ * Attach a series of runtime constructs to a compiled Stencil component
848
+ * constructor, including getters and setters for the `@Prop` and `@State`
849
+ * decorators, callbacks for when attributes change, and so on.
850
+ *
851
+ * @param Cstr the constructor for a component that we need to process
852
+ * @param cmpMeta metadata collected previously about the component
853
+ * @param flags a number used to store a series of bit flags
854
+ * @returns a reference to the same constructor passed in (but now mutated)
855
+ */
714
856
  const proxyComponent = (Cstr, cmpMeta, flags) => {
715
857
  if (cmpMeta.$members$) {
716
858
  // It's better to have a const than two Object.entries()
717
859
  const members = Object.entries(cmpMeta.$members$);
718
860
  const prototype = Cstr.prototype;
719
861
  members.map(([memberName, [memberFlags]]) => {
720
- if ((memberFlags & 31 /* Prop */ ||
721
- ((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
862
+ if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
863
+ ((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
722
864
  // proxyComponent - prop
723
865
  Object.defineProperty(prototype, memberName, {
724
866
  get() {
@@ -734,7 +876,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
734
876
  });
735
877
  }
736
878
  });
737
- if ((flags & 1 /* isElementConstructor */)) {
879
+ if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
738
880
  const attrNameToPropName = new Map();
739
881
  prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
740
882
  plt.jmp(() => {
@@ -790,11 +932,11 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
790
932
  // create an array of attributes to observe
791
933
  // and also create a map of html attribute name to js property name
792
934
  Cstr.observedAttributes = members
793
- .filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
935
+ .filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */) // filter to only keep props that should match attributes
794
936
  .map(([propName, m]) => {
795
937
  const attrName = m[1] || propName;
796
938
  attrNameToPropName.set(attrName, propName);
797
- if (m[0] & 512 /* ReflectAttr */) {
939
+ if (m[0] & 512 /* MEMBER_FLAGS.ReflectAttr */) {
798
940
  cmpMeta.$attrsToReflect$.push([propName, attrName]);
799
941
  }
800
942
  return attrName;
@@ -805,10 +947,10 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
805
947
  };
806
948
  const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
807
949
  // initializeComponent
808
- if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
950
+ if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
809
951
  {
810
952
  // we haven't initialized this element yet
811
- hostRef.$flags$ |= 32 /* hasInitializedComponent */;
953
+ hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
812
954
  // lazy loaded components
813
955
  // request the component's implementation to be
814
956
  // wired up with the host element
@@ -820,7 +962,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
820
962
  endLoad();
821
963
  }
822
964
  if (!Cstr.isProxied) {
823
- proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
965
+ proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
824
966
  Cstr.isProxied = true;
825
967
  }
826
968
  const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
@@ -828,7 +970,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
828
970
  // but let's keep track of when we start and stop
829
971
  // so that the getters/setters don't incorrectly step on data
830
972
  {
831
- hostRef.$flags$ |= 8 /* isConstructingInstance */;
973
+ hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
832
974
  }
833
975
  // construct the lazy-loaded component implementation
834
976
  // passing the hostRef is very important during
@@ -841,7 +983,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
841
983
  consoleError(e);
842
984
  }
843
985
  {
844
- hostRef.$flags$ &= ~8 /* isConstructingInstance */;
986
+ hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
845
987
  }
846
988
  endNewInstance();
847
989
  }
@@ -851,7 +993,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
851
993
  const scopeId = getScopeId(cmpMeta);
852
994
  if (!styles.has(scopeId)) {
853
995
  const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
854
- registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
996
+ registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
855
997
  endRegisterStyles();
856
998
  }
857
999
  }
@@ -873,13 +1015,13 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
873
1015
  }
874
1016
  };
875
1017
  const connectedCallback = (elm) => {
876
- if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1018
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
877
1019
  const hostRef = getHostRef(elm);
878
1020
  const cmpMeta = hostRef.$cmpMeta$;
879
1021
  const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
880
- if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
1022
+ if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
881
1023
  // first time this component has connected
882
- hostRef.$flags$ |= 1 /* hasConnected */;
1024
+ hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
883
1025
  {
884
1026
  // find the first ancestor component (if there is one) and register
885
1027
  // this component as one of the actively loading child components for its ancestor
@@ -899,7 +1041,7 @@ const connectedCallback = (elm) => {
899
1041
  // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
900
1042
  if (cmpMeta.$members$) {
901
1043
  Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
902
- if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
1044
+ if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
903
1045
  const value = elm[memberName];
904
1046
  delete elm[memberName];
905
1047
  elm[memberName] = value;
@@ -914,7 +1056,7 @@ const connectedCallback = (elm) => {
914
1056
  }
915
1057
  };
916
1058
  const disconnectedCallback = (elm) => {
917
- if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1059
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
918
1060
  getHostRef(elm);
919
1061
  }
920
1062
  };
@@ -953,7 +1095,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
953
1095
  super(self);
954
1096
  self = this;
955
1097
  registerHost(self, cmpMeta);
956
- if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
1098
+ if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
957
1099
  // this component is using shadow dom
958
1100
  // and this browser supports shadow dom
959
1101
  // add the read-only property "shadowRoot" to the host element
@@ -988,7 +1130,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
988
1130
  cmpMeta.$lazyBundleId$ = lazyBundle[0];
989
1131
  if (!exclude.includes(tagName) && !customElements.get(tagName)) {
990
1132
  cmpTags.push(tagName);
991
- customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
1133
+ customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
992
1134
  }
993
1135
  });
994
1136
  });
@@ -1010,7 +1152,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1010
1152
  // Fallback appLoad event
1011
1153
  endBootstrap();
1012
1154
  };
1013
- const hostRefs = new WeakMap();
1155
+ const hostRefs = /*@__PURE__*/ new WeakMap();
1014
1156
  const getHostRef = (ref) => hostRefs.get(ref);
1015
1157
  const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
1016
1158
  const registerHost = (elm, cmpMeta) => {
@@ -1051,14 +1193,35 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1051
1193
  return importedModule[exportName];
1052
1194
  }, consoleError);
1053
1195
  };
1054
- const styles = new Map();
1196
+ const styles = /*@__PURE__*/ new Map();
1197
+ const win = typeof window !== 'undefined' ? window : {};
1198
+ const doc = win.document || { head: {} };
1199
+ const plt = {
1200
+ $flags$: 0,
1201
+ $resourcesUrl$: '',
1202
+ jmp: (h) => h(),
1203
+ raf: (h) => requestAnimationFrame(h),
1204
+ ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
1205
+ rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
1206
+ ce: (eventName, opts) => new CustomEvent(eventName, opts),
1207
+ };
1208
+ const promiseResolve = (v) => Promise.resolve(v);
1209
+ const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
1210
+ try {
1211
+ new CSSStyleSheet();
1212
+ return typeof new CSSStyleSheet().replaceSync === 'function';
1213
+ }
1214
+ catch (e) { }
1215
+ return false;
1216
+ })()
1217
+ ;
1055
1218
  const queueDomReads = [];
1056
1219
  const queueDomWrites = [];
1057
1220
  const queueTask = (queue, write) => (cb) => {
1058
1221
  queue.push(cb);
1059
1222
  if (!queuePending) {
1060
1223
  queuePending = true;
1061
- if (write && plt.$flags$ & 4 /* queueSync */) {
1224
+ if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
1062
1225
  nextTick(flush);
1063
1226
  }
1064
1227
  else {