@mantou/gem 1.6.8 → 1.6.12

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 (108) hide show
  1. package/dist/gem.es.js +3266 -0
  2. package/dist/gem.umd.js +229 -0
  3. package/elements/{dialog-base.d.ts → base/dialog.d.ts} +3 -3
  4. package/elements/base/dialog.d.ts.map +1 -0
  5. package/elements/{dialog-base.js → base/dialog.js} +24 -24
  6. package/elements/base/dialog.js.map +1 -0
  7. package/elements/base/gesture.d.ts +66 -0
  8. package/elements/base/gesture.d.ts.map +1 -0
  9. package/elements/base/gesture.js +214 -0
  10. package/elements/base/gesture.js.map +1 -0
  11. package/elements/base/link.d.ts +44 -0
  12. package/elements/base/link.d.ts.map +1 -0
  13. package/elements/base/link.js +206 -0
  14. package/elements/base/link.js.map +1 -0
  15. package/elements/{modal-base.d.ts → base/modal-factory.d.ts} +17 -8
  16. package/elements/base/modal-factory.d.ts.map +1 -0
  17. package/elements/{modal-base.js → base/modal-factory.js} +4 -4
  18. package/elements/base/modal-factory.js.map +1 -0
  19. package/elements/base/reflect.d.ts +6 -0
  20. package/elements/base/reflect.d.ts.map +1 -0
  21. package/elements/base/reflect.js +34 -0
  22. package/elements/base/reflect.js.map +1 -0
  23. package/elements/base/route.d.ts +78 -0
  24. package/elements/base/route.d.ts.map +1 -0
  25. package/elements/base/route.js +220 -0
  26. package/elements/base/route.js.map +1 -0
  27. package/elements/base/title.d.ts +30 -0
  28. package/elements/base/title.d.ts.map +1 -0
  29. package/elements/base/title.js +74 -0
  30. package/elements/base/title.js.map +1 -0
  31. package/elements/base/unsafe.d.ts +14 -0
  32. package/elements/base/unsafe.d.ts.map +1 -0
  33. package/elements/base/unsafe.js +42 -0
  34. package/elements/base/unsafe.js.map +1 -0
  35. package/elements/base/use.d.ts +19 -0
  36. package/elements/base/use.d.ts.map +1 -0
  37. package/elements/base/use.js +70 -0
  38. package/elements/base/use.js.map +1 -0
  39. package/elements/gesture.d.ts +1 -67
  40. package/elements/gesture.d.ts.map +1 -1
  41. package/elements/gesture.js +3 -219
  42. package/elements/gesture.js.map +1 -1
  43. package/elements/link.d.ts +1 -45
  44. package/elements/link.d.ts.map +1 -1
  45. package/elements/link.js +4 -208
  46. package/elements/link.js.map +1 -1
  47. package/elements/reflect.d.ts +1 -8
  48. package/elements/reflect.d.ts.map +1 -1
  49. package/elements/reflect.js +3 -39
  50. package/elements/reflect.js.map +1 -1
  51. package/elements/route.d.ts +1 -81
  52. package/elements/route.d.ts.map +1 -1
  53. package/elements/route.js +4 -228
  54. package/elements/route.js.map +1 -1
  55. package/elements/title.d.ts +1 -30
  56. package/elements/title.d.ts.map +1 -1
  57. package/elements/title.js +3 -75
  58. package/elements/title.js.map +1 -1
  59. package/elements/unsafe.d.ts +1 -14
  60. package/elements/unsafe.d.ts.map +1 -1
  61. package/elements/unsafe.js +3 -46
  62. package/elements/unsafe.js.map +1 -1
  63. package/elements/use.d.ts +1 -19
  64. package/elements/use.d.ts.map +1 -1
  65. package/elements/use.js +3 -74
  66. package/elements/use.js.map +1 -1
  67. package/lib/element.d.ts.map +1 -1
  68. package/lib/element.js +1 -1
  69. package/lib/element.js.map +1 -1
  70. package/lib/history.d.ts +28 -16
  71. package/lib/history.d.ts.map +1 -1
  72. package/lib/history.js +166 -168
  73. package/lib/history.js.map +1 -1
  74. package/lib/utils.d.ts +3 -1
  75. package/lib/utils.d.ts.map +1 -1
  76. package/lib/utils.js +16 -16
  77. package/lib/utils.js.map +1 -1
  78. package/package.json +9 -6
  79. package/src/{all.ts → dist.ts} +6 -3
  80. package/src/elements/{dialog-base.ts → base/dialog.ts} +4 -4
  81. package/src/elements/base/gesture.ts +256 -0
  82. package/src/elements/base/link.ts +178 -0
  83. package/src/elements/{modal-base.ts → base/modal-factory.ts} +3 -3
  84. package/src/elements/base/reflect.ts +30 -0
  85. package/src/elements/base/route.ts +244 -0
  86. package/src/elements/base/title.ts +68 -0
  87. package/src/elements/base/unsafe.ts +37 -0
  88. package/src/elements/base/use.ts +57 -0
  89. package/src/elements/gesture.ts +3 -257
  90. package/src/elements/link.ts +4 -179
  91. package/src/elements/reflect.ts +3 -31
  92. package/src/elements/route.ts +4 -248
  93. package/src/elements/title.ts +3 -68
  94. package/src/elements/unsafe.ts +3 -37
  95. package/src/elements/use.ts +3 -57
  96. package/src/lib/element.ts +3 -1
  97. package/src/lib/history.ts +182 -194
  98. package/src/lib/utils.ts +24 -16
  99. package/src/test/history.test.ts +15 -10
  100. package/src/test/utils.test.ts +6 -2
  101. package/all.d.ts +0 -14
  102. package/all.d.ts.map +0 -1
  103. package/all.js +0 -14
  104. package/all.js.map +0 -1
  105. package/elements/dialog-base.d.ts.map +0 -1
  106. package/elements/dialog-base.js.map +0 -1
  107. package/elements/modal-base.d.ts.map +0 -1
  108. package/elements/modal-base.js.map +0 -1
package/dist/gem.es.js ADDED
@@ -0,0 +1,3266 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key2, value) => key2 in obj ? __defProp(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __accessCheck = (obj, member, msg) => {
21
+ if (!member.has(obj))
22
+ throw TypeError("Cannot " + msg);
23
+ };
24
+ var __privateGet = (obj, member, getter) => {
25
+ __accessCheck(obj, member, "read from private field");
26
+ return getter ? getter.call(obj) : member.get(obj);
27
+ };
28
+ var __privateAdd = (obj, member, value) => {
29
+ if (member.has(obj))
30
+ throw TypeError("Cannot add the same private member more than once");
31
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
32
+ };
33
+ var __privateSet = (obj, member, value, setter) => {
34
+ __accessCheck(obj, member, "write to private field");
35
+ setter ? setter.call(obj, value) : member.set(obj, value);
36
+ return value;
37
+ };
38
+ var __privateMethod = (obj, member, method) => {
39
+ __accessCheck(obj, member, "access private method");
40
+ return method;
41
+ };
42
+ var _map, _firstItem, _lastItem, _delete, delete_fn, _stringify, _parse, _nextSibling, _parentElement, _inertStore, _a, _cacheCurrentKey, cacheCurrentKey_get, _urlParamsLang, urlParamsLang_get, _cacheLang, cacheLang_get, _isMain, isMain_get, _lang, lang_set;
43
+ var Gem = /* @__PURE__ */ Object.freeze({
44
+ __proto__: null,
45
+ [Symbol.toStringTag]: "Module",
46
+ get StoreListenerMap() {
47
+ return StoreListenerMap;
48
+ },
49
+ get createStore() {
50
+ return createStore;
51
+ },
52
+ get createStoreSet() {
53
+ return createStoreSet;
54
+ },
55
+ get updateStore() {
56
+ return updateStore;
57
+ },
58
+ get connect() {
59
+ return connect;
60
+ },
61
+ get disconnect() {
62
+ return disconnect;
63
+ },
64
+ get history() {
65
+ return history;
66
+ },
67
+ get titleStore() {
68
+ return titleStore;
69
+ },
70
+ get basePathStore() {
71
+ return basePathStore;
72
+ },
73
+ get html() {
74
+ return html;
75
+ },
76
+ get svg() {
77
+ return svg;
78
+ },
79
+ get render() {
80
+ return render;
81
+ },
82
+ get directive() {
83
+ return directive;
84
+ },
85
+ get TemplateResult() {
86
+ return TemplateResult;
87
+ },
88
+ get SVGTemplateResult() {
89
+ return SVGTemplateResult;
90
+ },
91
+ get repeat() {
92
+ return repeat;
93
+ },
94
+ get guard() {
95
+ return guard;
96
+ },
97
+ get ifDefined() {
98
+ return ifDefined;
99
+ },
100
+ get GemElement() {
101
+ return GemElement;
102
+ },
103
+ get defineAttribute() {
104
+ return defineAttribute;
105
+ },
106
+ get defineProperty() {
107
+ return defineProperty;
108
+ },
109
+ get defineRef() {
110
+ return defineRef;
111
+ },
112
+ get defineCSSState() {
113
+ return defineCSSState;
114
+ },
115
+ get nativeDefineElement() {
116
+ return nativeDefineElement;
117
+ },
118
+ get refobject() {
119
+ return refobject;
120
+ },
121
+ get attribute() {
122
+ return attribute;
123
+ },
124
+ get boolattribute() {
125
+ return boolattribute;
126
+ },
127
+ get numattribute() {
128
+ return numattribute;
129
+ },
130
+ get property() {
131
+ return property;
132
+ },
133
+ get state() {
134
+ return state;
135
+ },
136
+ get slot() {
137
+ return slot;
138
+ },
139
+ get part() {
140
+ return part;
141
+ },
142
+ get emitter() {
143
+ return emitter;
144
+ },
145
+ get globalemitter() {
146
+ return globalemitter;
147
+ },
148
+ get adoptedStyle() {
149
+ return adoptedStyle;
150
+ },
151
+ get connectStore() {
152
+ return connectStore;
153
+ },
154
+ get rootElement() {
155
+ return rootElement;
156
+ },
157
+ get customElement() {
158
+ return customElement;
159
+ },
160
+ get addMicrotask() {
161
+ return addMicrotask;
162
+ },
163
+ get addMicrotaskToStack() {
164
+ return addMicrotaskToStack;
165
+ },
166
+ get absoluteLocation() {
167
+ return absoluteLocation;
168
+ },
169
+ get LinkedList() {
170
+ return LinkedList;
171
+ },
172
+ get PropProxyMap() {
173
+ return PropProxyMap;
174
+ },
175
+ get QueryString() {
176
+ return QueryString;
177
+ },
178
+ get raw() {
179
+ return raw;
180
+ },
181
+ get css() {
182
+ return css;
183
+ },
184
+ get SheetToken() {
185
+ return SheetToken;
186
+ },
187
+ get useNativeCSSStyleSheet() {
188
+ return useNativeCSSStyleSheet;
189
+ },
190
+ get createCSSSheet() {
191
+ return createCSSSheet;
192
+ },
193
+ get randomStr() {
194
+ return randomStr;
195
+ },
196
+ get styled() {
197
+ return styled;
198
+ },
199
+ get camelToKebabCase() {
200
+ return camelToKebabCase;
201
+ },
202
+ get kebabToCamelCase() {
203
+ return kebabToCamelCase;
204
+ },
205
+ get cleanObject() {
206
+ return cleanObject;
207
+ },
208
+ get GemError() {
209
+ return GemError;
210
+ },
211
+ get isArrayChange() {
212
+ return isArrayChange;
213
+ },
214
+ get removeItems() {
215
+ return removeItems;
216
+ },
217
+ get objectMapToString() {
218
+ return objectMapToString;
219
+ },
220
+ get styleMap() {
221
+ return styleMap;
222
+ },
223
+ get classMap() {
224
+ return classMap;
225
+ },
226
+ get partMap() {
227
+ return partMap;
228
+ },
229
+ get exportPartsMap() {
230
+ return exportPartsMap;
231
+ },
232
+ get version() {
233
+ return version;
234
+ }
235
+ });
236
+ /**
237
+ * @license
238
+ * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
239
+ * This code may only be used under the BSD style license found at
240
+ * http://polymer.github.io/LICENSE.txt
241
+ * The complete set of authors may be found at
242
+ * http://polymer.github.io/AUTHORS.txt
243
+ * The complete set of contributors may be found at
244
+ * http://polymer.github.io/CONTRIBUTORS.txt
245
+ * Code distributed by Google as part of the polymer project is also
246
+ * subject to an additional IP rights grant found at
247
+ * http://polymer.github.io/PATENTS.txt
248
+ */
249
+ const directives = new WeakMap();
250
+ const directive = (f) => (...args) => {
251
+ const d = f(...args);
252
+ directives.set(d, true);
253
+ return d;
254
+ };
255
+ const isDirective = (o) => {
256
+ return typeof o === "function" && directives.has(o);
257
+ };
258
+ /**
259
+ * @license
260
+ * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
261
+ * This code may only be used under the BSD style license found at
262
+ * http://polymer.github.io/LICENSE.txt
263
+ * The complete set of authors may be found at
264
+ * http://polymer.github.io/AUTHORS.txt
265
+ * The complete set of contributors may be found at
266
+ * http://polymer.github.io/CONTRIBUTORS.txt
267
+ * Code distributed by Google as part of the polymer project is also
268
+ * subject to an additional IP rights grant found at
269
+ * http://polymer.github.io/PATENTS.txt
270
+ */
271
+ const isCEPolyfill = typeof window !== "undefined" && window.customElements != null && window.customElements.polyfillWrapFlushCallback !== void 0;
272
+ const reparentNodes = (container, start, end = null, before = null) => {
273
+ while (start !== end) {
274
+ const n = start.nextSibling;
275
+ container.insertBefore(start, before);
276
+ start = n;
277
+ }
278
+ };
279
+ const removeNodes = (container, start, end = null) => {
280
+ while (start !== end) {
281
+ const n = start.nextSibling;
282
+ container.removeChild(start);
283
+ start = n;
284
+ }
285
+ };
286
+ /**
287
+ * @license
288
+ * Copyright (c) 2018 The Polymer Project Authors. All rights reserved.
289
+ * This code may only be used under the BSD style license found at
290
+ * http://polymer.github.io/LICENSE.txt
291
+ * The complete set of authors may be found at
292
+ * http://polymer.github.io/AUTHORS.txt
293
+ * The complete set of contributors may be found at
294
+ * http://polymer.github.io/CONTRIBUTORS.txt
295
+ * Code distributed by Google as part of the polymer project is also
296
+ * subject to an additional IP rights grant found at
297
+ * http://polymer.github.io/PATENTS.txt
298
+ */
299
+ const noChange = {};
300
+ const nothing = {};
301
+ /**
302
+ * @license
303
+ * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
304
+ * This code may only be used under the BSD style license found at
305
+ * http://polymer.github.io/LICENSE.txt
306
+ * The complete set of authors may be found at
307
+ * http://polymer.github.io/AUTHORS.txt
308
+ * The complete set of contributors may be found at
309
+ * http://polymer.github.io/CONTRIBUTORS.txt
310
+ * Code distributed by Google as part of the polymer project is also
311
+ * subject to an additional IP rights grant found at
312
+ * http://polymer.github.io/PATENTS.txt
313
+ */
314
+ const marker = `{{lit-${String(Math.random()).slice(2)}}}`;
315
+ const nodeMarker = `<!--${marker}-->`;
316
+ const markerRegex = new RegExp(`${marker}|${nodeMarker}`);
317
+ const boundAttributeSuffix = "$lit$";
318
+ class Template {
319
+ constructor(result, element) {
320
+ this.parts = [];
321
+ this.element = element;
322
+ const nodesToRemove = [];
323
+ const stack = [];
324
+ const walker = document.createTreeWalker(element.content, 133, null, false);
325
+ let lastPartIndex = 0;
326
+ let index = -1;
327
+ let partIndex = 0;
328
+ const { strings, values: { length } } = result;
329
+ while (partIndex < length) {
330
+ const node = walker.nextNode();
331
+ if (node === null) {
332
+ walker.currentNode = stack.pop();
333
+ continue;
334
+ }
335
+ index++;
336
+ if (node.nodeType === 1) {
337
+ if (node.hasAttributes()) {
338
+ const attributes = node.attributes;
339
+ const { length: length2 } = attributes;
340
+ let count = 0;
341
+ for (let i = 0; i < length2; i++) {
342
+ if (endsWith(attributes[i].name, boundAttributeSuffix)) {
343
+ count++;
344
+ }
345
+ }
346
+ while (count-- > 0) {
347
+ const stringForPart = strings[partIndex];
348
+ const name = lastAttributeNameRegex.exec(stringForPart)[2];
349
+ const attributeLookupName = name.toLowerCase() + boundAttributeSuffix;
350
+ const attributeValue = node.getAttribute(attributeLookupName);
351
+ node.removeAttribute(attributeLookupName);
352
+ const statics = attributeValue.split(markerRegex);
353
+ this.parts.push({ type: "attribute", index, name, strings: statics });
354
+ partIndex += statics.length - 1;
355
+ }
356
+ }
357
+ if (node.tagName === "TEMPLATE") {
358
+ stack.push(node);
359
+ walker.currentNode = node.content;
360
+ }
361
+ } else if (node.nodeType === 3) {
362
+ const data = node.data;
363
+ if (data.indexOf(marker) >= 0) {
364
+ const parent = node.parentNode;
365
+ const strings2 = data.split(markerRegex);
366
+ const lastIndex = strings2.length - 1;
367
+ for (let i = 0; i < lastIndex; i++) {
368
+ let insert;
369
+ let s = strings2[i];
370
+ if (s === "") {
371
+ insert = createMarker();
372
+ } else {
373
+ const match = lastAttributeNameRegex.exec(s);
374
+ if (match !== null && endsWith(match[2], boundAttributeSuffix)) {
375
+ s = s.slice(0, match.index) + match[1] + match[2].slice(0, -boundAttributeSuffix.length) + match[3];
376
+ }
377
+ insert = document.createTextNode(s);
378
+ }
379
+ parent.insertBefore(insert, node);
380
+ this.parts.push({ type: "node", index: ++index });
381
+ }
382
+ if (strings2[lastIndex] === "") {
383
+ parent.insertBefore(createMarker(), node);
384
+ nodesToRemove.push(node);
385
+ } else {
386
+ node.data = strings2[lastIndex];
387
+ }
388
+ partIndex += lastIndex;
389
+ }
390
+ } else if (node.nodeType === 8) {
391
+ if (node.data === marker) {
392
+ const parent = node.parentNode;
393
+ if (node.previousSibling === null || index === lastPartIndex) {
394
+ index++;
395
+ parent.insertBefore(createMarker(), node);
396
+ }
397
+ lastPartIndex = index;
398
+ this.parts.push({ type: "node", index });
399
+ if (node.nextSibling === null) {
400
+ node.data = "";
401
+ } else {
402
+ nodesToRemove.push(node);
403
+ index--;
404
+ }
405
+ partIndex++;
406
+ } else {
407
+ let i = -1;
408
+ while ((i = node.data.indexOf(marker, i + 1)) !== -1) {
409
+ this.parts.push({ type: "node", index: -1 });
410
+ partIndex++;
411
+ }
412
+ }
413
+ }
414
+ }
415
+ for (const n of nodesToRemove) {
416
+ n.parentNode.removeChild(n);
417
+ }
418
+ }
419
+ }
420
+ const endsWith = (str, suffix) => {
421
+ const index = str.length - suffix.length;
422
+ return index >= 0 && str.slice(index) === suffix;
423
+ };
424
+ const isTemplatePartActive = (part2) => part2.index !== -1;
425
+ const createMarker = () => document.createComment("");
426
+ const lastAttributeNameRegex = /([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/;
427
+ /**
428
+ * @license
429
+ * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
430
+ * This code may only be used under the BSD style license found at
431
+ * http://polymer.github.io/LICENSE.txt
432
+ * The complete set of authors may be found at
433
+ * http://polymer.github.io/AUTHORS.txt
434
+ * The complete set of contributors may be found at
435
+ * http://polymer.github.io/CONTRIBUTORS.txt
436
+ * Code distributed by Google as part of the polymer project is also
437
+ * subject to an additional IP rights grant found at
438
+ * http://polymer.github.io/PATENTS.txt
439
+ */
440
+ class TemplateInstance {
441
+ constructor(template, processor, options) {
442
+ this.__parts = [];
443
+ this.template = template;
444
+ this.processor = processor;
445
+ this.options = options;
446
+ }
447
+ update(values) {
448
+ let i = 0;
449
+ for (const part2 of this.__parts) {
450
+ if (part2 !== void 0) {
451
+ part2.setValue(values[i]);
452
+ }
453
+ i++;
454
+ }
455
+ for (const part2 of this.__parts) {
456
+ if (part2 !== void 0) {
457
+ part2.commit();
458
+ }
459
+ }
460
+ }
461
+ _clone() {
462
+ const fragment = isCEPolyfill ? this.template.element.content.cloneNode(true) : document.importNode(this.template.element.content, true);
463
+ const stack = [];
464
+ const parts2 = this.template.parts;
465
+ const walker = document.createTreeWalker(fragment, 133, null, false);
466
+ let partIndex = 0;
467
+ let nodeIndex = 0;
468
+ let part2;
469
+ let node = walker.nextNode();
470
+ while (partIndex < parts2.length) {
471
+ part2 = parts2[partIndex];
472
+ if (!isTemplatePartActive(part2)) {
473
+ this.__parts.push(void 0);
474
+ partIndex++;
475
+ continue;
476
+ }
477
+ while (nodeIndex < part2.index) {
478
+ nodeIndex++;
479
+ if (node.nodeName === "TEMPLATE") {
480
+ stack.push(node);
481
+ walker.currentNode = node.content;
482
+ }
483
+ if ((node = walker.nextNode()) === null) {
484
+ walker.currentNode = stack.pop();
485
+ node = walker.nextNode();
486
+ }
487
+ }
488
+ if (part2.type === "node") {
489
+ const part3 = this.processor.handleTextExpression(this.options);
490
+ part3.insertAfterNode(node.previousSibling);
491
+ this.__parts.push(part3);
492
+ } else {
493
+ this.__parts.push(...this.processor.handleAttributeExpressions(node, part2.name, part2.strings, this.options));
494
+ }
495
+ partIndex++;
496
+ }
497
+ if (isCEPolyfill) {
498
+ document.adoptNode(fragment);
499
+ customElements.upgrade(fragment);
500
+ }
501
+ return fragment;
502
+ }
503
+ }
504
+ /**
505
+ * @license
506
+ * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
507
+ * This code may only be used under the BSD style license found at
508
+ * http://polymer.github.io/LICENSE.txt
509
+ * The complete set of authors may be found at
510
+ * http://polymer.github.io/AUTHORS.txt
511
+ * The complete set of contributors may be found at
512
+ * http://polymer.github.io/CONTRIBUTORS.txt
513
+ * Code distributed by Google as part of the polymer project is also
514
+ * subject to an additional IP rights grant found at
515
+ * http://polymer.github.io/PATENTS.txt
516
+ */
517
+ const policy = window.trustedTypes && trustedTypes.createPolicy("lit-html", { createHTML: (s) => s });
518
+ const commentMarker = ` ${marker} `;
519
+ class TemplateResult {
520
+ constructor(strings, values, type, processor) {
521
+ this.strings = strings;
522
+ this.values = values;
523
+ this.type = type;
524
+ this.processor = processor;
525
+ }
526
+ getHTML() {
527
+ const l = this.strings.length - 1;
528
+ let html2 = "";
529
+ let isCommentBinding = false;
530
+ for (let i = 0; i < l; i++) {
531
+ const s = this.strings[i];
532
+ const commentOpen = s.lastIndexOf("<!--");
533
+ isCommentBinding = (commentOpen > -1 || isCommentBinding) && s.indexOf("-->", commentOpen + 1) === -1;
534
+ const attributeMatch = lastAttributeNameRegex.exec(s);
535
+ if (attributeMatch === null) {
536
+ html2 += s + (isCommentBinding ? commentMarker : nodeMarker);
537
+ } else {
538
+ html2 += s.substr(0, attributeMatch.index) + attributeMatch[1] + attributeMatch[2] + boundAttributeSuffix + attributeMatch[3] + marker;
539
+ }
540
+ }
541
+ html2 += this.strings[l];
542
+ return html2;
543
+ }
544
+ getTemplateElement() {
545
+ const template = document.createElement("template");
546
+ let value = this.getHTML();
547
+ if (policy !== void 0) {
548
+ value = policy.createHTML(value);
549
+ }
550
+ template.innerHTML = value;
551
+ return template;
552
+ }
553
+ }
554
+ class SVGTemplateResult extends TemplateResult {
555
+ getHTML() {
556
+ return `<svg>${super.getHTML()}</svg>`;
557
+ }
558
+ getTemplateElement() {
559
+ const template = super.getTemplateElement();
560
+ const content = template.content;
561
+ const svgElement = content.firstChild;
562
+ content.removeChild(svgElement);
563
+ reparentNodes(content, svgElement.firstChild);
564
+ return template;
565
+ }
566
+ }
567
+ /**
568
+ * @license
569
+ * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
570
+ * This code may only be used under the BSD style license found at
571
+ * http://polymer.github.io/LICENSE.txt
572
+ * The complete set of authors may be found at
573
+ * http://polymer.github.io/AUTHORS.txt
574
+ * The complete set of contributors may be found at
575
+ * http://polymer.github.io/CONTRIBUTORS.txt
576
+ * Code distributed by Google as part of the polymer project is also
577
+ * subject to an additional IP rights grant found at
578
+ * http://polymer.github.io/PATENTS.txt
579
+ */
580
+ const isPrimitive = (value) => {
581
+ return value === null || !(typeof value === "object" || typeof value === "function");
582
+ };
583
+ const isIterable = (value) => {
584
+ return Array.isArray(value) || !!(value && value[Symbol.iterator]);
585
+ };
586
+ class AttributeCommitter {
587
+ constructor(element, name, strings) {
588
+ this.dirty = true;
589
+ this.element = element;
590
+ this.name = name;
591
+ this.strings = strings;
592
+ this.parts = [];
593
+ for (let i = 0; i < strings.length - 1; i++) {
594
+ this.parts[i] = this._createPart();
595
+ }
596
+ }
597
+ _createPart() {
598
+ return new AttributePart(this);
599
+ }
600
+ _getValue() {
601
+ const strings = this.strings;
602
+ const l = strings.length - 1;
603
+ const parts2 = this.parts;
604
+ if (l === 1 && strings[0] === "" && strings[1] === "") {
605
+ const v = parts2[0].value;
606
+ if (typeof v === "symbol") {
607
+ return String(v);
608
+ }
609
+ if (typeof v === "string" || !isIterable(v)) {
610
+ return v;
611
+ }
612
+ }
613
+ let text = "";
614
+ for (let i = 0; i < l; i++) {
615
+ text += strings[i];
616
+ const part2 = parts2[i];
617
+ if (part2 !== void 0) {
618
+ const v = part2.value;
619
+ if (isPrimitive(v) || !isIterable(v)) {
620
+ text += typeof v === "string" ? v : String(v);
621
+ } else {
622
+ for (const t of v) {
623
+ text += typeof t === "string" ? t : String(t);
624
+ }
625
+ }
626
+ }
627
+ }
628
+ text += strings[l];
629
+ return text;
630
+ }
631
+ commit() {
632
+ if (this.dirty) {
633
+ this.dirty = false;
634
+ this.element.setAttribute(this.name, this._getValue());
635
+ }
636
+ }
637
+ }
638
+ class AttributePart {
639
+ constructor(committer) {
640
+ this.value = void 0;
641
+ this.committer = committer;
642
+ }
643
+ setValue(value) {
644
+ if (value !== noChange && (!isPrimitive(value) || value !== this.value)) {
645
+ this.value = value;
646
+ if (!isDirective(value)) {
647
+ this.committer.dirty = true;
648
+ }
649
+ }
650
+ }
651
+ commit() {
652
+ while (isDirective(this.value)) {
653
+ const directive2 = this.value;
654
+ this.value = noChange;
655
+ directive2(this);
656
+ }
657
+ if (this.value === noChange) {
658
+ return;
659
+ }
660
+ this.committer.commit();
661
+ }
662
+ }
663
+ class NodePart {
664
+ constructor(options) {
665
+ this.value = void 0;
666
+ this.__pendingValue = void 0;
667
+ this.options = options;
668
+ }
669
+ appendInto(container) {
670
+ this.startNode = container.appendChild(createMarker());
671
+ this.endNode = container.appendChild(createMarker());
672
+ }
673
+ insertAfterNode(ref) {
674
+ this.startNode = ref;
675
+ this.endNode = ref.nextSibling;
676
+ }
677
+ appendIntoPart(part2) {
678
+ part2.__insert(this.startNode = createMarker());
679
+ part2.__insert(this.endNode = createMarker());
680
+ }
681
+ insertAfterPart(ref) {
682
+ ref.__insert(this.startNode = createMarker());
683
+ this.endNode = ref.endNode;
684
+ ref.endNode = this.startNode;
685
+ }
686
+ setValue(value) {
687
+ this.__pendingValue = value;
688
+ }
689
+ commit() {
690
+ if (this.startNode.parentNode === null) {
691
+ return;
692
+ }
693
+ while (isDirective(this.__pendingValue)) {
694
+ const directive2 = this.__pendingValue;
695
+ this.__pendingValue = noChange;
696
+ directive2(this);
697
+ }
698
+ const value = this.__pendingValue;
699
+ if (value === noChange) {
700
+ return;
701
+ }
702
+ if (isPrimitive(value)) {
703
+ if (value !== this.value) {
704
+ this.__commitText(value);
705
+ }
706
+ } else if (value instanceof TemplateResult) {
707
+ this.__commitTemplateResult(value);
708
+ } else if (value instanceof Node) {
709
+ this.__commitNode(value);
710
+ } else if (isIterable(value)) {
711
+ this.__commitIterable(value);
712
+ } else if (value === nothing) {
713
+ this.value = nothing;
714
+ this.clear();
715
+ } else {
716
+ this.__commitText(value);
717
+ }
718
+ }
719
+ __insert(node) {
720
+ this.endNode.parentNode.insertBefore(node, this.endNode);
721
+ }
722
+ __commitNode(value) {
723
+ if (this.value === value) {
724
+ return;
725
+ }
726
+ this.clear();
727
+ this.__insert(value);
728
+ this.value = value;
729
+ }
730
+ __commitText(value) {
731
+ const node = this.startNode.nextSibling;
732
+ value = value == null ? "" : value;
733
+ const valueAsString = typeof value === "string" ? value : String(value);
734
+ if (node === this.endNode.previousSibling && node.nodeType === 3) {
735
+ node.data = valueAsString;
736
+ } else {
737
+ this.__commitNode(document.createTextNode(valueAsString));
738
+ }
739
+ this.value = value;
740
+ }
741
+ __commitTemplateResult(value) {
742
+ const template = this.options.templateFactory(value);
743
+ if (this.value instanceof TemplateInstance && this.value.template === template) {
744
+ this.value.update(value.values);
745
+ } else {
746
+ const instance = new TemplateInstance(template, value.processor, this.options);
747
+ const fragment = instance._clone();
748
+ instance.update(value.values);
749
+ this.__commitNode(fragment);
750
+ this.value = instance;
751
+ }
752
+ }
753
+ __commitIterable(value) {
754
+ if (!Array.isArray(this.value)) {
755
+ this.value = [];
756
+ this.clear();
757
+ }
758
+ const itemParts = this.value;
759
+ let partIndex = 0;
760
+ let itemPart;
761
+ for (const item of value) {
762
+ itemPart = itemParts[partIndex];
763
+ if (itemPart === void 0) {
764
+ itemPart = new NodePart(this.options);
765
+ itemParts.push(itemPart);
766
+ if (partIndex === 0) {
767
+ itemPart.appendIntoPart(this);
768
+ } else {
769
+ itemPart.insertAfterPart(itemParts[partIndex - 1]);
770
+ }
771
+ }
772
+ itemPart.setValue(item);
773
+ itemPart.commit();
774
+ partIndex++;
775
+ }
776
+ if (partIndex < itemParts.length) {
777
+ itemParts.length = partIndex;
778
+ this.clear(itemPart && itemPart.endNode);
779
+ }
780
+ }
781
+ clear(startNode = this.startNode) {
782
+ removeNodes(this.startNode.parentNode, startNode.nextSibling, this.endNode);
783
+ }
784
+ }
785
+ class BooleanAttributePart {
786
+ constructor(element, name, strings) {
787
+ this.value = void 0;
788
+ this.__pendingValue = void 0;
789
+ if (strings.length !== 2 || strings[0] !== "" || strings[1] !== "") {
790
+ throw new Error("Boolean attributes can only contain a single expression");
791
+ }
792
+ this.element = element;
793
+ this.name = name;
794
+ this.strings = strings;
795
+ }
796
+ setValue(value) {
797
+ this.__pendingValue = value;
798
+ }
799
+ commit() {
800
+ while (isDirective(this.__pendingValue)) {
801
+ const directive2 = this.__pendingValue;
802
+ this.__pendingValue = noChange;
803
+ directive2(this);
804
+ }
805
+ if (this.__pendingValue === noChange) {
806
+ return;
807
+ }
808
+ const value = !!this.__pendingValue;
809
+ if (this.value !== value) {
810
+ if (value) {
811
+ this.element.setAttribute(this.name, "");
812
+ } else {
813
+ this.element.removeAttribute(this.name);
814
+ }
815
+ this.value = value;
816
+ }
817
+ this.__pendingValue = noChange;
818
+ }
819
+ }
820
+ class PropertyCommitter extends AttributeCommitter {
821
+ constructor(element, name, strings) {
822
+ super(element, name, strings);
823
+ this.single = strings.length === 2 && strings[0] === "" && strings[1] === "";
824
+ }
825
+ _createPart() {
826
+ return new PropertyPart(this);
827
+ }
828
+ _getValue() {
829
+ if (this.single) {
830
+ return this.parts[0].value;
831
+ }
832
+ return super._getValue();
833
+ }
834
+ commit() {
835
+ if (this.dirty) {
836
+ this.dirty = false;
837
+ this.element[this.name] = this._getValue();
838
+ }
839
+ }
840
+ }
841
+ class PropertyPart extends AttributePart {
842
+ }
843
+ let eventOptionsSupported = false;
844
+ (() => {
845
+ try {
846
+ const options = {
847
+ get capture() {
848
+ eventOptionsSupported = true;
849
+ return false;
850
+ }
851
+ };
852
+ window.addEventListener("test", options, options);
853
+ window.removeEventListener("test", options, options);
854
+ } catch (_e) {
855
+ }
856
+ })();
857
+ class EventPart {
858
+ constructor(element, eventName, eventContext) {
859
+ this.value = void 0;
860
+ this.__pendingValue = void 0;
861
+ this.element = element;
862
+ this.eventName = eventName;
863
+ this.eventContext = eventContext;
864
+ this.__boundHandleEvent = (e) => this.handleEvent(e);
865
+ }
866
+ setValue(value) {
867
+ this.__pendingValue = value;
868
+ }
869
+ commit() {
870
+ while (isDirective(this.__pendingValue)) {
871
+ const directive2 = this.__pendingValue;
872
+ this.__pendingValue = noChange;
873
+ directive2(this);
874
+ }
875
+ if (this.__pendingValue === noChange) {
876
+ return;
877
+ }
878
+ const newListener = this.__pendingValue;
879
+ const oldListener = this.value;
880
+ const shouldRemoveListener = newListener == null || oldListener != null && (newListener.capture !== oldListener.capture || newListener.once !== oldListener.once || newListener.passive !== oldListener.passive);
881
+ const shouldAddListener = newListener != null && (oldListener == null || shouldRemoveListener);
882
+ if (shouldRemoveListener) {
883
+ this.element.removeEventListener(this.eventName, this.__boundHandleEvent, this.__options);
884
+ }
885
+ if (shouldAddListener) {
886
+ this.__options = getOptions(newListener);
887
+ this.element.addEventListener(this.eventName, this.__boundHandleEvent, this.__options);
888
+ }
889
+ this.value = newListener;
890
+ this.__pendingValue = noChange;
891
+ }
892
+ handleEvent(event) {
893
+ if (typeof this.value === "function") {
894
+ this.value.call(this.eventContext || this.element, event);
895
+ } else {
896
+ this.value.handleEvent(event);
897
+ }
898
+ }
899
+ }
900
+ const getOptions = (o) => o && (eventOptionsSupported ? { capture: o.capture, passive: o.passive, once: o.once } : o.capture);
901
+ /**
902
+ * @license
903
+ * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
904
+ * This code may only be used under the BSD style license found at
905
+ * http://polymer.github.io/LICENSE.txt
906
+ * The complete set of authors may be found at
907
+ * http://polymer.github.io/AUTHORS.txt
908
+ * The complete set of contributors may be found at
909
+ * http://polymer.github.io/CONTRIBUTORS.txt
910
+ * Code distributed by Google as part of the polymer project is also
911
+ * subject to an additional IP rights grant found at
912
+ * http://polymer.github.io/PATENTS.txt
913
+ */
914
+ class DefaultTemplateProcessor {
915
+ handleAttributeExpressions(element, name, strings, options) {
916
+ const prefix = name[0];
917
+ if (prefix === ".") {
918
+ const committer2 = new PropertyCommitter(element, name.slice(1), strings);
919
+ return committer2.parts;
920
+ }
921
+ if (prefix === "@") {
922
+ return [new EventPart(element, name.slice(1), options.eventContext)];
923
+ }
924
+ if (prefix === "?") {
925
+ return [new BooleanAttributePart(element, name.slice(1), strings)];
926
+ }
927
+ const committer = new AttributeCommitter(element, name, strings);
928
+ return committer.parts;
929
+ }
930
+ handleTextExpression(options) {
931
+ return new NodePart(options);
932
+ }
933
+ }
934
+ const defaultTemplateProcessor = new DefaultTemplateProcessor();
935
+ /**
936
+ * @license
937
+ * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
938
+ * This code may only be used under the BSD style license found at
939
+ * http://polymer.github.io/LICENSE.txt
940
+ * The complete set of authors may be found at
941
+ * http://polymer.github.io/AUTHORS.txt
942
+ * The complete set of contributors may be found at
943
+ * http://polymer.github.io/CONTRIBUTORS.txt
944
+ * Code distributed by Google as part of the polymer project is also
945
+ * subject to an additional IP rights grant found at
946
+ * http://polymer.github.io/PATENTS.txt
947
+ */
948
+ function templateFactory(result) {
949
+ let templateCache = templateCaches.get(result.type);
950
+ if (templateCache === void 0) {
951
+ templateCache = {
952
+ stringsArray: new WeakMap(),
953
+ keyString: new Map()
954
+ };
955
+ templateCaches.set(result.type, templateCache);
956
+ }
957
+ let template = templateCache.stringsArray.get(result.strings);
958
+ if (template !== void 0) {
959
+ return template;
960
+ }
961
+ const key2 = result.strings.join(marker);
962
+ template = templateCache.keyString.get(key2);
963
+ if (template === void 0) {
964
+ template = new Template(result, result.getTemplateElement());
965
+ templateCache.keyString.set(key2, template);
966
+ }
967
+ templateCache.stringsArray.set(result.strings, template);
968
+ return template;
969
+ }
970
+ const templateCaches = new Map();
971
+ /**
972
+ * @license
973
+ * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
974
+ * This code may only be used under the BSD style license found at
975
+ * http://polymer.github.io/LICENSE.txt
976
+ * The complete set of authors may be found at
977
+ * http://polymer.github.io/AUTHORS.txt
978
+ * The complete set of contributors may be found at
979
+ * http://polymer.github.io/CONTRIBUTORS.txt
980
+ * Code distributed by Google as part of the polymer project is also
981
+ * subject to an additional IP rights grant found at
982
+ * http://polymer.github.io/PATENTS.txt
983
+ */
984
+ const parts = new WeakMap();
985
+ const render = (result, container, options) => {
986
+ let part2 = parts.get(container);
987
+ if (part2 === void 0) {
988
+ removeNodes(container, container.firstChild);
989
+ parts.set(container, part2 = new NodePart(Object.assign({ templateFactory }, options)));
990
+ part2.appendInto(container);
991
+ }
992
+ part2.setValue(result);
993
+ part2.commit();
994
+ };
995
+ /**
996
+ * @license
997
+ * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
998
+ * This code may only be used under the BSD style license found at
999
+ * http://polymer.github.io/LICENSE.txt
1000
+ * The complete set of authors may be found at
1001
+ * http://polymer.github.io/AUTHORS.txt
1002
+ * The complete set of contributors may be found at
1003
+ * http://polymer.github.io/CONTRIBUTORS.txt
1004
+ * Code distributed by Google as part of the polymer project is also
1005
+ * subject to an additional IP rights grant found at
1006
+ * http://polymer.github.io/PATENTS.txt
1007
+ */
1008
+ if (typeof window !== "undefined") {
1009
+ (window["litHtmlVersions"] || (window["litHtmlVersions"] = [])).push("1.4.1");
1010
+ }
1011
+ const html = (strings, ...values) => new TemplateResult(strings, values, "html", defaultTemplateProcessor);
1012
+ const svg = (strings, ...values) => new SVGTemplateResult(strings, values, "svg", defaultTemplateProcessor);
1013
+ const microtaskSet = new Set();
1014
+ function addMicrotask(func) {
1015
+ if (typeof func !== "function")
1016
+ return;
1017
+ if (!microtaskSet.size) {
1018
+ globalThis.queueMicrotask(() => {
1019
+ microtaskSet.forEach((func2) => func2());
1020
+ microtaskSet.clear();
1021
+ });
1022
+ }
1023
+ microtaskSet.delete(func);
1024
+ microtaskSet.add(func);
1025
+ }
1026
+ const microtaskStack = [];
1027
+ function execMicrotaskStack() {
1028
+ for (let i = microtaskStack.length - 1; i >= 0; i--) {
1029
+ microtaskStack[i]();
1030
+ }
1031
+ microtaskStack.length = 0;
1032
+ }
1033
+ function addMicrotaskToStack(func) {
1034
+ if (!microtaskStack.length) {
1035
+ addMicrotask(execMicrotaskStack);
1036
+ }
1037
+ microtaskStack.push(func);
1038
+ }
1039
+ function absoluteLocation(currentPath = "", relativePath = "") {
1040
+ const { pathname, search, hash } = new URL(relativePath, location.origin + currentPath);
1041
+ return pathname + search + hash;
1042
+ }
1043
+ class LinkedList extends (globalThis.EventTarget || Object) {
1044
+ constructor() {
1045
+ super(...arguments);
1046
+ __privateAdd(this, _delete);
1047
+ __privateAdd(this, _map, void 0);
1048
+ __privateAdd(this, _firstItem, void 0);
1049
+ __privateAdd(this, _lastItem, void 0);
1050
+ __privateSet(this, _map, new Map());
1051
+ }
1052
+ get size() {
1053
+ return __privateGet(this, _map).size;
1054
+ }
1055
+ add(value) {
1056
+ if (!__privateGet(this, _lastItem)) {
1057
+ this.dispatchEvent(new CustomEvent("start"));
1058
+ }
1059
+ const item = __privateMethod(this, _delete, delete_fn).call(this, value) || { value };
1060
+ item.prev = __privateGet(this, _lastItem);
1061
+ if (item.prev) {
1062
+ item.prev.next = item;
1063
+ }
1064
+ item.next = void 0;
1065
+ __privateSet(this, _lastItem, item);
1066
+ if (!__privateGet(this, _firstItem)) {
1067
+ __privateSet(this, _firstItem, item);
1068
+ }
1069
+ __privateGet(this, _map).set(value, item);
1070
+ }
1071
+ delete(value) {
1072
+ const deleteItem = __privateMethod(this, _delete, delete_fn).call(this, value);
1073
+ if (!__privateGet(this, _firstItem)) {
1074
+ this.dispatchEvent(new CustomEvent("end"));
1075
+ }
1076
+ return deleteItem;
1077
+ }
1078
+ get() {
1079
+ const firstItem = __privateGet(this, _firstItem);
1080
+ if (!firstItem)
1081
+ return;
1082
+ __privateMethod(this, _delete, delete_fn).call(this, firstItem.value);
1083
+ return firstItem.value;
1084
+ }
1085
+ }
1086
+ _map = new WeakMap();
1087
+ _firstItem = new WeakMap();
1088
+ _lastItem = new WeakMap();
1089
+ _delete = new WeakSet();
1090
+ delete_fn = function(value) {
1091
+ const existItem = __privateGet(this, _map).get(value);
1092
+ if (existItem) {
1093
+ if (existItem.prev) {
1094
+ existItem.prev.next = existItem.next;
1095
+ } else {
1096
+ __privateSet(this, _firstItem, existItem.next);
1097
+ }
1098
+ if (existItem.next) {
1099
+ existItem.next.prev = existItem.prev;
1100
+ } else {
1101
+ __privateSet(this, _lastItem, existItem.prev);
1102
+ }
1103
+ __privateGet(this, _map).delete(value);
1104
+ }
1105
+ return existItem;
1106
+ };
1107
+ class PropProxyMap extends WeakMap {
1108
+ get(ele) {
1109
+ let proxy = super.get(ele);
1110
+ if (!proxy) {
1111
+ proxy = {};
1112
+ this.set(ele, proxy);
1113
+ }
1114
+ return proxy;
1115
+ }
1116
+ }
1117
+ class QueryString extends URLSearchParams {
1118
+ constructor(param) {
1119
+ super(param);
1120
+ __privateAdd(this, _stringify, (value) => typeof value === "string" ? value : JSON.stringify(value));
1121
+ __privateAdd(this, _parse, (value) => {
1122
+ if (!value)
1123
+ return null;
1124
+ try {
1125
+ return JSON.parse(value);
1126
+ } catch {
1127
+ return null;
1128
+ }
1129
+ });
1130
+ }
1131
+ concat(param) {
1132
+ let query;
1133
+ if (typeof param === "string") {
1134
+ query = Object.fromEntries(new URLSearchParams(param).entries());
1135
+ } else {
1136
+ query = param;
1137
+ }
1138
+ Object.entries(query).forEach(([key2, value]) => {
1139
+ this.append(key2, __privateGet(this, _stringify).call(this, value));
1140
+ });
1141
+ }
1142
+ setAny(key2, value) {
1143
+ if (Array.isArray(value)) {
1144
+ this.delete(key2);
1145
+ value.forEach((e) => this.append(key2, __privateGet(this, _stringify).call(this, e)));
1146
+ } else {
1147
+ const v = __privateGet(this, _stringify).call(this, value);
1148
+ v ? this.set(key2, v) : this.delete(key2);
1149
+ }
1150
+ }
1151
+ getAny(key2) {
1152
+ return this.getAnyAll(key2)[0];
1153
+ }
1154
+ getAnyAll(key2) {
1155
+ return this.getAll(key2).filter((e) => e !== "").map((e) => __privateGet(this, _parse).call(this, e));
1156
+ }
1157
+ toString() {
1158
+ const string = super.toString();
1159
+ return string ? `?${string}` : "";
1160
+ }
1161
+ toJSON() {
1162
+ return this.toString();
1163
+ }
1164
+ }
1165
+ _stringify = new WeakMap();
1166
+ _parse = new WeakMap();
1167
+ function raw(arr, ...args) {
1168
+ return arr.reduce((prev, current, index) => {
1169
+ var _a2;
1170
+ return prev + ((_a2 = args[index - 1]) != null ? _a2 : "") + current;
1171
+ });
1172
+ }
1173
+ function css(arr, ...args) {
1174
+ return raw(arr, ...args);
1175
+ }
1176
+ const SheetToken = Symbol.for("gem@sheetToken");
1177
+ let useNativeCSSStyleSheet = true;
1178
+ let CSSStyleSheet = window.CSSStyleSheet;
1179
+ try {
1180
+ new CSSStyleSheet();
1181
+ } catch {
1182
+ useNativeCSSStyleSheet = false;
1183
+ CSSStyleSheet = class {
1184
+ constructor() {
1185
+ this.media = { mediaText: "" };
1186
+ this.style = "";
1187
+ this.replaceSync = (style) => this.style = style;
1188
+ }
1189
+ };
1190
+ }
1191
+ function createCSSSheet(rules, mediaQuery2 = "") {
1192
+ const styleSheet = new CSSStyleSheet();
1193
+ const sheet = {};
1194
+ styleSheet.media.mediaText = mediaQuery2;
1195
+ let style = "";
1196
+ if (typeof rules === "string") {
1197
+ style = rules;
1198
+ } else {
1199
+ Object.keys(rules).forEach((key2) => {
1200
+ sheet[key2] = `${key2}-${randomStr()}`;
1201
+ style += rules[key2].styledContent.replace(/&/g, sheet[key2]);
1202
+ });
1203
+ }
1204
+ styleSheet.replaceSync(style);
1205
+ sheet[SheetToken] = styleSheet;
1206
+ return sheet;
1207
+ }
1208
+ function randomStr(number = 5, origin = "0123456789abcdefghijklmnopqrstuvwxyz") {
1209
+ const len = origin.length;
1210
+ let str = "";
1211
+ for (let i = 0; i < number; i++) {
1212
+ str += origin[Math.floor(Math.random() * len)];
1213
+ }
1214
+ return str;
1215
+ }
1216
+ const nestingRuleRegExp = new RegExp("&.*{((.|\n)*)}", "g");
1217
+ function flatStyled(style, type) {
1218
+ const nestingRules = [];
1219
+ let styledContent = `& {${style.replace(nestingRuleRegExp, (substr) => {
1220
+ nestingRules.push(substr);
1221
+ return "";
1222
+ })}}` + nestingRules.join("");
1223
+ styledContent = styledContent.replace(/&/g, type === "class" ? ".&" : "#&");
1224
+ return { styledContent, type };
1225
+ }
1226
+ const styled = {
1227
+ class: (arr, ...args) => {
1228
+ const style = raw(arr, ...args);
1229
+ return flatStyled(style, "class");
1230
+ },
1231
+ id: (arr, ...args) => {
1232
+ const style = raw(arr, ...args);
1233
+ return flatStyled(style, "id");
1234
+ },
1235
+ keyframes: (arr, ...args) => {
1236
+ const keyframesContent = raw(arr, ...args);
1237
+ const styledContent = `@keyframes & {${keyframesContent}}`;
1238
+ return { styledContent, type: "keyframes" };
1239
+ }
1240
+ };
1241
+ function camelToKebabCase(str) {
1242
+ return str.replace(/[A-Z]/g, ($1) => "-" + $1.toLowerCase());
1243
+ }
1244
+ function kebabToCamelCase(str) {
1245
+ return str.replace(/-(.)/g, (_substr, $1) => $1.toUpperCase());
1246
+ }
1247
+ function cleanObject(o) {
1248
+ Object.keys(o).forEach((key2) => {
1249
+ const k = key2;
1250
+ delete o[k];
1251
+ });
1252
+ return o;
1253
+ }
1254
+ class GemError extends Error {
1255
+ constructor(msg) {
1256
+ super(msg);
1257
+ this.message = `gem: ${this.message}`;
1258
+ }
1259
+ }
1260
+ function isArrayChange(newValues, oldValues) {
1261
+ const length = newValues.length;
1262
+ if (oldValues.length !== length)
1263
+ return true;
1264
+ for (let i = 0; i < length; i++) {
1265
+ if (newValues[i] !== oldValues[i])
1266
+ return true;
1267
+ }
1268
+ return false;
1269
+ }
1270
+ function removeItems(target, items) {
1271
+ const set = new Set(items);
1272
+ return target.filter((e) => {
1273
+ if (set.has(e)) {
1274
+ set.delete(e);
1275
+ return false;
1276
+ }
1277
+ return true;
1278
+ });
1279
+ }
1280
+ function objectMapToString(object, separate, toString) {
1281
+ let result = separate;
1282
+ for (const key2 in object) {
1283
+ const s = toString(key2, object[key2]);
1284
+ result += s ? s + separate : "";
1285
+ }
1286
+ return result;
1287
+ }
1288
+ function styleMap(object) {
1289
+ return objectMapToString(object, ";", (key2, value) => value !== void 0 ? `${camelToKebabCase(key2)}:${value}` : "");
1290
+ }
1291
+ function classMap(object) {
1292
+ return objectMapToString(object, " ", (key2, value) => value ? key2 : "");
1293
+ }
1294
+ const partMap = classMap;
1295
+ function exportPartsMap(object) {
1296
+ return objectMapToString(object, ",", (key2, value) => value !== void 0 ? `${key2}:${value}` : "");
1297
+ }
1298
+ const StoreListenerMap = new WeakMap();
1299
+ function createStore(originStore) {
1300
+ if (StoreListenerMap.has(originStore)) {
1301
+ throw new GemError("argument error");
1302
+ }
1303
+ StoreListenerMap.set(originStore, new Set());
1304
+ return originStore;
1305
+ }
1306
+ function createStoreSet(originStoreSet) {
1307
+ const keys = Object.keys(originStoreSet);
1308
+ keys.forEach((key2) => {
1309
+ createStore(originStoreSet[key2]);
1310
+ });
1311
+ return originStoreSet;
1312
+ }
1313
+ function updateStore(store2, value) {
1314
+ Object.assign(store2, value);
1315
+ const listeners = StoreListenerMap.get(store2);
1316
+ listeners == null ? void 0 : listeners.forEach((func) => {
1317
+ addMicrotask(func);
1318
+ });
1319
+ }
1320
+ function connect(store2, func) {
1321
+ const listeners = StoreListenerMap.get(store2);
1322
+ listeners == null ? void 0 : listeners.add(func);
1323
+ }
1324
+ function disconnect(store2, func) {
1325
+ const listeners = StoreListenerMap.get(store2);
1326
+ listeners == null ? void 0 : listeners.delete(func);
1327
+ }
1328
+ /**
1329
+ * @license
1330
+ * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
1331
+ * This code may only be used under the BSD style license found at
1332
+ * http://polymer.github.io/LICENSE.txt
1333
+ * The complete set of authors may be found at
1334
+ * http://polymer.github.io/AUTHORS.txt
1335
+ * The complete set of contributors may be found at
1336
+ * http://polymer.github.io/CONTRIBUTORS.txt
1337
+ * Code distributed by Google as part of the polymer project is also
1338
+ * subject to an additional IP rights grant found at
1339
+ * http://polymer.github.io/PATENTS.txt
1340
+ */
1341
+ const createAndInsertPart = (containerPart, beforePart) => {
1342
+ const container = containerPart.startNode.parentNode;
1343
+ const beforeNode = beforePart === void 0 ? containerPart.endNode : beforePart.startNode;
1344
+ const startNode = container.insertBefore(createMarker(), beforeNode);
1345
+ container.insertBefore(createMarker(), beforeNode);
1346
+ const newPart = new NodePart(containerPart.options);
1347
+ newPart.insertAfterNode(startNode);
1348
+ return newPart;
1349
+ };
1350
+ const updatePart = (part2, value) => {
1351
+ part2.setValue(value);
1352
+ part2.commit();
1353
+ return part2;
1354
+ };
1355
+ const insertPartBefore = (containerPart, part2, ref) => {
1356
+ const container = containerPart.startNode.parentNode;
1357
+ const beforeNode = ref ? ref.startNode : containerPart.endNode;
1358
+ const endNode = part2.endNode.nextSibling;
1359
+ if (endNode !== beforeNode) {
1360
+ reparentNodes(container, part2.startNode, endNode, beforeNode);
1361
+ }
1362
+ };
1363
+ const removePart = (part2) => {
1364
+ removeNodes(part2.startNode.parentNode, part2.startNode, part2.endNode.nextSibling);
1365
+ };
1366
+ const generateMap = (list, start, end) => {
1367
+ const map = new Map();
1368
+ for (let i = start; i <= end; i++) {
1369
+ map.set(list[i], i);
1370
+ }
1371
+ return map;
1372
+ };
1373
+ const partListCache = new WeakMap();
1374
+ const keyListCache = new WeakMap();
1375
+ const repeat = directive((items, keyFnOrTemplate, template) => {
1376
+ let keyFn;
1377
+ if (template === void 0) {
1378
+ template = keyFnOrTemplate;
1379
+ } else if (keyFnOrTemplate !== void 0) {
1380
+ keyFn = keyFnOrTemplate;
1381
+ }
1382
+ return (containerPart) => {
1383
+ if (!(containerPart instanceof NodePart)) {
1384
+ throw new Error("repeat can only be used in text bindings");
1385
+ }
1386
+ const oldParts = partListCache.get(containerPart) || [];
1387
+ const oldKeys = keyListCache.get(containerPart) || [];
1388
+ const newParts = [];
1389
+ const newValues = [];
1390
+ const newKeys = [];
1391
+ let index = 0;
1392
+ for (const item of items) {
1393
+ newKeys[index] = keyFn ? keyFn(item, index) : index;
1394
+ newValues[index] = template(item, index);
1395
+ index++;
1396
+ }
1397
+ let newKeyToIndexMap;
1398
+ let oldKeyToIndexMap;
1399
+ let oldHead = 0;
1400
+ let oldTail = oldParts.length - 1;
1401
+ let newHead = 0;
1402
+ let newTail = newValues.length - 1;
1403
+ while (oldHead <= oldTail && newHead <= newTail) {
1404
+ if (oldParts[oldHead] === null) {
1405
+ oldHead++;
1406
+ } else if (oldParts[oldTail] === null) {
1407
+ oldTail--;
1408
+ } else if (oldKeys[oldHead] === newKeys[newHead]) {
1409
+ newParts[newHead] = updatePart(oldParts[oldHead], newValues[newHead]);
1410
+ oldHead++;
1411
+ newHead++;
1412
+ } else if (oldKeys[oldTail] === newKeys[newTail]) {
1413
+ newParts[newTail] = updatePart(oldParts[oldTail], newValues[newTail]);
1414
+ oldTail--;
1415
+ newTail--;
1416
+ } else if (oldKeys[oldHead] === newKeys[newTail]) {
1417
+ newParts[newTail] = updatePart(oldParts[oldHead], newValues[newTail]);
1418
+ insertPartBefore(containerPart, oldParts[oldHead], newParts[newTail + 1]);
1419
+ oldHead++;
1420
+ newTail--;
1421
+ } else if (oldKeys[oldTail] === newKeys[newHead]) {
1422
+ newParts[newHead] = updatePart(oldParts[oldTail], newValues[newHead]);
1423
+ insertPartBefore(containerPart, oldParts[oldTail], oldParts[oldHead]);
1424
+ oldTail--;
1425
+ newHead++;
1426
+ } else {
1427
+ if (newKeyToIndexMap === void 0) {
1428
+ newKeyToIndexMap = generateMap(newKeys, newHead, newTail);
1429
+ oldKeyToIndexMap = generateMap(oldKeys, oldHead, oldTail);
1430
+ }
1431
+ if (!newKeyToIndexMap.has(oldKeys[oldHead])) {
1432
+ removePart(oldParts[oldHead]);
1433
+ oldHead++;
1434
+ } else if (!newKeyToIndexMap.has(oldKeys[oldTail])) {
1435
+ removePart(oldParts[oldTail]);
1436
+ oldTail--;
1437
+ } else {
1438
+ const oldIndex = oldKeyToIndexMap.get(newKeys[newHead]);
1439
+ const oldPart = oldIndex !== void 0 ? oldParts[oldIndex] : null;
1440
+ if (oldPart === null) {
1441
+ const newPart = createAndInsertPart(containerPart, oldParts[oldHead]);
1442
+ updatePart(newPart, newValues[newHead]);
1443
+ newParts[newHead] = newPart;
1444
+ } else {
1445
+ newParts[newHead] = updatePart(oldPart, newValues[newHead]);
1446
+ insertPartBefore(containerPart, oldPart, oldParts[oldHead]);
1447
+ oldParts[oldIndex] = null;
1448
+ }
1449
+ newHead++;
1450
+ }
1451
+ }
1452
+ }
1453
+ while (newHead <= newTail) {
1454
+ const newPart = createAndInsertPart(containerPart, newParts[newTail + 1]);
1455
+ updatePart(newPart, newValues[newHead]);
1456
+ newParts[newHead++] = newPart;
1457
+ }
1458
+ while (oldHead <= oldTail) {
1459
+ const oldPart = oldParts[oldHead++];
1460
+ if (oldPart !== null) {
1461
+ removePart(oldPart);
1462
+ }
1463
+ }
1464
+ partListCache.set(containerPart, newParts);
1465
+ keyListCache.set(containerPart, newKeys);
1466
+ };
1467
+ });
1468
+ /**
1469
+ * @license
1470
+ * Copyright (c) 2018 The Polymer Project Authors. All rights reserved.
1471
+ * This code may only be used under the BSD style license found at
1472
+ * http://polymer.github.io/LICENSE.txt
1473
+ * The complete set of authors may be found at
1474
+ * http://polymer.github.io/AUTHORS.txt
1475
+ * The complete set of contributors may be found at
1476
+ * http://polymer.github.io/CONTRIBUTORS.txt
1477
+ * Code distributed by Google as part of the polymer project is also
1478
+ * subject to an additional IP rights grant found at
1479
+ * http://polymer.github.io/PATENTS.txt
1480
+ */
1481
+ const previousValues$1 = new WeakMap();
1482
+ const guard = directive((value, f) => (part2) => {
1483
+ const previousValue = previousValues$1.get(part2);
1484
+ if (Array.isArray(value)) {
1485
+ if (Array.isArray(previousValue) && previousValue.length === value.length && value.every((v, i) => v === previousValue[i])) {
1486
+ return;
1487
+ }
1488
+ } else if (previousValue === value && (value !== void 0 || previousValues$1.has(part2))) {
1489
+ return;
1490
+ }
1491
+ part2.setValue(f());
1492
+ previousValues$1.set(part2, Array.isArray(value) ? Array.from(value) : value);
1493
+ });
1494
+ /**
1495
+ * @license
1496
+ * Copyright (c) 2018 The Polymer Project Authors. All rights reserved.
1497
+ * This code may only be used under the BSD style license found at
1498
+ * http://polymer.github.io/LICENSE.txt
1499
+ * The complete set of authors may be found at
1500
+ * http://polymer.github.io/AUTHORS.txt
1501
+ * The complete set of contributors may be found at
1502
+ * http://polymer.github.io/CONTRIBUTORS.txt
1503
+ * Code distributed by Google as part of the polymer project is also
1504
+ * subject to an additional IP rights grant found at
1505
+ * http://polymer.github.io/PATENTS.txt
1506
+ */
1507
+ const previousValues = new WeakMap();
1508
+ const ifDefined = directive((value) => (part2) => {
1509
+ const previousValue = previousValues.get(part2);
1510
+ if (value === void 0 && part2 instanceof AttributePart) {
1511
+ if (previousValue !== void 0 || !previousValues.has(part2)) {
1512
+ const name = part2.committer.name;
1513
+ part2.committer.element.removeAttribute(name);
1514
+ }
1515
+ } else if (value !== previousValue) {
1516
+ part2.setValue(value);
1517
+ }
1518
+ previousValues.set(part2, value);
1519
+ });
1520
+ var __accessCheck$1 = (obj, member, msg) => {
1521
+ if (!member.has(obj))
1522
+ throw TypeError("Cannot " + msg);
1523
+ };
1524
+ var __privateGet$1 = (obj, member, getter) => {
1525
+ __accessCheck$1(obj, member, "read from private field");
1526
+ return getter ? getter.call(obj) : member.get(obj);
1527
+ };
1528
+ var __privateAdd$1 = (obj, member, value) => {
1529
+ if (member.has(obj))
1530
+ throw TypeError("Cannot add the same private member more than once");
1531
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1532
+ };
1533
+ var __privateSet$1 = (obj, member, value, setter) => {
1534
+ __accessCheck$1(obj, member, "write to private field");
1535
+ setter ? setter.call(obj, value) : member.set(obj, value);
1536
+ return value;
1537
+ };
1538
+ var _renderRoot, _internals, _isAppendReason, _isAsync, _effectList, _momeList, _unmountCallback, _exec, _execEffect, _execMemo, _initEffect, _render, _shouldUpdate, _updateCallback, _update, _updated, _connectedCallback;
1539
+ function emptyFunction() {
1540
+ }
1541
+ function execCallback(fun) {
1542
+ typeof fun === "function" && fun();
1543
+ }
1544
+ const asyncRenderTaskList = new LinkedList();
1545
+ const tick = (timeStamp = performance.now()) => {
1546
+ if (performance.now() > timeStamp + 16)
1547
+ return requestAnimationFrame(tick);
1548
+ const task = asyncRenderTaskList.get();
1549
+ if (task) {
1550
+ task();
1551
+ tick(timeStamp);
1552
+ }
1553
+ };
1554
+ asyncRenderTaskList.addEventListener("start", () => addMicrotask(tick));
1555
+ const initSymbol = Symbol("init");
1556
+ const updateSymbol = Symbol("update");
1557
+ class GemElement extends HTMLElement {
1558
+ constructor({ isAsync, isLight, delegatesFocus } = {}) {
1559
+ super();
1560
+ __privateAdd$1(this, _renderRoot, void 0);
1561
+ __privateAdd$1(this, _internals, void 0);
1562
+ __privateAdd$1(this, _isAppendReason, void 0);
1563
+ __privateAdd$1(this, _isAsync, void 0);
1564
+ __privateAdd$1(this, _effectList, void 0);
1565
+ __privateAdd$1(this, _momeList, void 0);
1566
+ __privateAdd$1(this, _unmountCallback, void 0);
1567
+ this.setState = (payload) => {
1568
+ if (!this.state)
1569
+ throw new GemError("`state` not initialized");
1570
+ Object.assign(this.state, payload);
1571
+ addMicrotask(__privateGet$1(this, _update));
1572
+ };
1573
+ __privateAdd$1(this, _exec, (list) => {
1574
+ list == null ? void 0 : list.forEach((effectItem) => {
1575
+ const { callback, getDep, values, preCallback } = effectItem;
1576
+ const newValues = getDep == null ? void 0 : getDep();
1577
+ if (!getDep || !values || isArrayChange(values, newValues)) {
1578
+ execCallback(preCallback);
1579
+ effectItem.preCallback = callback(newValues, values);
1580
+ effectItem.values = newValues;
1581
+ }
1582
+ });
1583
+ });
1584
+ __privateAdd$1(this, _execEffect, () => {
1585
+ __privateGet$1(this, _exec).call(this, __privateGet$1(this, _effectList));
1586
+ });
1587
+ __privateAdd$1(this, _execMemo, () => {
1588
+ __privateGet$1(this, _exec).call(this, __privateGet$1(this, _momeList));
1589
+ });
1590
+ this.effect = (callback, getDep) => {
1591
+ if (!__privateGet$1(this, _effectList))
1592
+ __privateSet$1(this, _effectList, []);
1593
+ const effectItem = {
1594
+ callback,
1595
+ getDep,
1596
+ values: void 0,
1597
+ initialized: !!this.isConnected
1598
+ };
1599
+ if (this.isConnected) {
1600
+ effectItem.values = getDep == null ? void 0 : getDep();
1601
+ effectItem.preCallback = callback(effectItem.values);
1602
+ }
1603
+ __privateGet$1(this, _effectList).push(effectItem);
1604
+ };
1605
+ this.memo = (callback, getDep) => {
1606
+ if (!__privateGet$1(this, _momeList))
1607
+ __privateSet$1(this, _momeList, []);
1608
+ __privateGet$1(this, _momeList).push({
1609
+ callback,
1610
+ getDep,
1611
+ values: [Symbol()],
1612
+ initialized: this.isConnected
1613
+ });
1614
+ };
1615
+ __privateAdd$1(this, _initEffect, () => {
1616
+ var _a2;
1617
+ (_a2 = __privateGet$1(this, _effectList)) == null ? void 0 : _a2.forEach((effectItem) => {
1618
+ const { callback, getDep, initialized } = effectItem;
1619
+ if (!initialized) {
1620
+ effectItem.values = getDep == null ? void 0 : getDep();
1621
+ effectItem.preCallback = callback(effectItem.values);
1622
+ effectItem.initialized = true;
1623
+ }
1624
+ });
1625
+ });
1626
+ __privateAdd$1(this, _render, () => {
1627
+ var _a2, _b;
1628
+ __privateGet$1(this, _execMemo).call(this);
1629
+ const styles = useNativeCSSStyleSheet ? "" : html`${(_b = (_a2 = this.shadowRoot) == null ? void 0 : _a2.adoptedStyleSheets) == null ? void 0 : _b.map((e) => html`
1630
+ <style media=${e.media.mediaText}>
1631
+ ${e.style}
1632
+ </style>
1633
+ `)}`;
1634
+ if (this.render)
1635
+ return html`${this.render()}${styles}`;
1636
+ return __privateGet$1(this, _renderRoot) === this ? void 0 : html`<slot></slot>${styles}`;
1637
+ });
1638
+ __privateAdd$1(this, _shouldUpdate, () => {
1639
+ return this.shouldUpdate ? this.shouldUpdate() : true;
1640
+ });
1641
+ __privateAdd$1(this, _updateCallback, () => {
1642
+ if (this.isConnected && __privateGet$1(this, _shouldUpdate).call(this)) {
1643
+ const temp = __privateGet$1(this, _render).call(this);
1644
+ temp !== void 0 && render(temp, __privateGet$1(this, _renderRoot));
1645
+ addMicrotask(__privateGet$1(this, _updated));
1646
+ addMicrotask(__privateGet$1(this, _execEffect));
1647
+ }
1648
+ });
1649
+ __privateAdd$1(this, _update, () => {
1650
+ if (__privateGet$1(this, _isAsync)) {
1651
+ asyncRenderTaskList.add(__privateGet$1(this, _updateCallback));
1652
+ } else {
1653
+ __privateGet$1(this, _updateCallback).call(this);
1654
+ }
1655
+ });
1656
+ this.update = () => {
1657
+ addMicrotask(__privateGet$1(this, _update));
1658
+ };
1659
+ __privateAdd$1(this, _updated, () => {
1660
+ var _a2;
1661
+ (_a2 = this.updated) == null ? void 0 : _a2.call(this);
1662
+ });
1663
+ __privateAdd$1(this, _connectedCallback, () => {
1664
+ var _a2, _b, _c;
1665
+ if (__privateGet$1(this, _isAppendReason)) {
1666
+ __privateSet$1(this, _isAppendReason, false);
1667
+ return;
1668
+ }
1669
+ (_a2 = this.willMount) == null ? void 0 : _a2.call(this);
1670
+ const { observedStores, rootElement: rootElement2 } = this.constructor;
1671
+ observedStores == null ? void 0 : observedStores.forEach((store2) => {
1672
+ connect(store2, __privateGet$1(this, _update));
1673
+ });
1674
+ const temp = __privateGet$1(this, _render).call(this);
1675
+ temp !== void 0 && render(temp, __privateGet$1(this, _renderRoot));
1676
+ __privateSet$1(this, _unmountCallback, (_b = this.mounted) == null ? void 0 : _b.call(this));
1677
+ __privateGet$1(this, _initEffect).call(this);
1678
+ if (rootElement2 && ((_c = this.getRootNode().host) == null ? void 0 : _c.tagName) !== rootElement2.toUpperCase()) {
1679
+ throw new GemError(`not allow current root type`);
1680
+ }
1681
+ });
1682
+ addMicrotask(() => this[initSymbol] = false);
1683
+ this[initSymbol] = true;
1684
+ this[updateSymbol] = () => {
1685
+ if (this.isConnected) {
1686
+ addMicrotask(__privateGet$1(this, _update));
1687
+ }
1688
+ };
1689
+ __privateSet$1(this, _isAsync, isAsync);
1690
+ __privateSet$1(this, _renderRoot, isLight ? this : this.attachShadow({ mode: "open", delegatesFocus }));
1691
+ const { adoptedStyleSheets } = new.target;
1692
+ if (adoptedStyleSheets) {
1693
+ const sheets = adoptedStyleSheets.map((item) => item[SheetToken] || item);
1694
+ if (this.shadowRoot) {
1695
+ this.shadowRoot.adoptedStyleSheets = sheets;
1696
+ } else {
1697
+ this.effect(() => {
1698
+ const root = this.getRootNode();
1699
+ if (!useNativeCSSStyleSheet) {
1700
+ const ele = root === document ? document.body : root;
1701
+ ele._sheets = ele._sheets || {};
1702
+ sheets.forEach(({ style, media }) => {
1703
+ if (ele._sheets[style]) {
1704
+ ele._sheets[style].count++;
1705
+ } else {
1706
+ const s = document.createElement("style");
1707
+ s.innerHTML = style;
1708
+ s.media = media.mediaText;
1709
+ ele.append(s);
1710
+ ele._sheets[style] = { ele: s, count: 1 };
1711
+ }
1712
+ });
1713
+ return () => {
1714
+ sheets.forEach(({ style }) => {
1715
+ ele._sheets[style].count--;
1716
+ if (!ele._sheets[style].count) {
1717
+ delete ele._sheets[style];
1718
+ }
1719
+ });
1720
+ };
1721
+ } else {
1722
+ root.adoptedStyleSheets = [...root.adoptedStyleSheets, ...sheets];
1723
+ return () => {
1724
+ root.adoptedStyleSheets = removeItems(root.adoptedStyleSheets, sheets);
1725
+ };
1726
+ }
1727
+ }, () => []);
1728
+ }
1729
+ }
1730
+ }
1731
+ get internals() {
1732
+ if (!__privateGet$1(this, _internals)) {
1733
+ const getCustomStateSet = () => {
1734
+ const getV = (v) => v.replace(/-/g, "");
1735
+ return {
1736
+ has: (v) => getV(v) in this.dataset,
1737
+ add: (v) => {
1738
+ this.dataset[getV(v)] = "";
1739
+ },
1740
+ delete: (v) => delete this.dataset[getV(v)]
1741
+ };
1742
+ };
1743
+ if (!this.attachInternals) {
1744
+ this.attachInternals = () => {
1745
+ return { states: getCustomStateSet() };
1746
+ };
1747
+ }
1748
+ __privateSet$1(this, _internals, this.attachInternals());
1749
+ if (!__privateGet$1(this, _internals).states) {
1750
+ __privateGet$1(this, _internals).states = getCustomStateSet();
1751
+ }
1752
+ }
1753
+ return __privateGet$1(this, _internals);
1754
+ }
1755
+ attributeChangedCallback() {
1756
+ if (this.isConnected) {
1757
+ addMicrotask(__privateGet$1(this, _update));
1758
+ }
1759
+ }
1760
+ closestElement(constructorOrTag) {
1761
+ const isConstructor = typeof constructorOrTag === "function";
1762
+ const tagName = typeof constructorOrTag === "string" && constructorOrTag.toUpperCase();
1763
+ const getRootElement = (ele) => {
1764
+ const rootEle = ele.parentElement || ele.getRootNode().host;
1765
+ if (!rootEle)
1766
+ return null;
1767
+ if (isConstructor) {
1768
+ if (rootEle.constructor === constructorOrTag) {
1769
+ return rootEle;
1770
+ }
1771
+ } else if (rootEle.tagName === tagName) {
1772
+ return rootEle;
1773
+ }
1774
+ return getRootElement(rootEle);
1775
+ };
1776
+ return getRootElement(this);
1777
+ }
1778
+ connectedCallback() {
1779
+ if (__privateGet$1(this, _isAsync)) {
1780
+ asyncRenderTaskList.add(__privateGet$1(this, _connectedCallback));
1781
+ } else {
1782
+ __privateGet$1(this, _connectedCallback).call(this);
1783
+ }
1784
+ }
1785
+ disconnectedCallback() {
1786
+ var _a2, _b, _c;
1787
+ if (this.isConnected) {
1788
+ __privateSet$1(this, _isAppendReason, true);
1789
+ return;
1790
+ }
1791
+ const { observedStores } = this.constructor;
1792
+ observedStores == null ? void 0 : observedStores.forEach((store2) => {
1793
+ disconnect(store2, __privateGet$1(this, _update));
1794
+ });
1795
+ execCallback(__privateGet$1(this, _unmountCallback));
1796
+ (_a2 = this.unmounted) == null ? void 0 : _a2.call(this);
1797
+ (_b = __privateGet$1(this, _effectList)) == null ? void 0 : _b.forEach((effectItem) => {
1798
+ execCallback(effectItem.preCallback);
1799
+ });
1800
+ __privateSet$1(this, _momeList, (_c = __privateGet$1(this, _momeList)) == null ? void 0 : _c.filter(({ initialized }) => !initialized));
1801
+ }
1802
+ }
1803
+ _renderRoot = new WeakMap();
1804
+ _internals = new WeakMap();
1805
+ _isAppendReason = new WeakMap();
1806
+ _isAsync = new WeakMap();
1807
+ _effectList = new WeakMap();
1808
+ _momeList = new WeakMap();
1809
+ _unmountCallback = new WeakMap();
1810
+ _exec = new WeakMap();
1811
+ _execEffect = new WeakMap();
1812
+ _execMemo = new WeakMap();
1813
+ _initEffect = new WeakMap();
1814
+ _render = new WeakMap();
1815
+ _shouldUpdate = new WeakMap();
1816
+ _updateCallback = new WeakMap();
1817
+ _update = new WeakMap();
1818
+ _updated = new WeakMap();
1819
+ _connectedCallback = new WeakMap();
1820
+ const gemElementProxyMap = new PropProxyMap();
1821
+ function defineAttribute(target, prop, attr) {
1822
+ const { booleanAttributes, numberAttributes } = target.constructor;
1823
+ Object.defineProperty(target, prop, {
1824
+ configurable: true,
1825
+ get() {
1826
+ if (!(initSymbol in this))
1827
+ return;
1828
+ const that = this;
1829
+ const value = that.getAttribute(attr);
1830
+ if (booleanAttributes == null ? void 0 : booleanAttributes.has(attr)) {
1831
+ return value === null ? false : true;
1832
+ }
1833
+ if (numberAttributes == null ? void 0 : numberAttributes.has(attr)) {
1834
+ return Number(value);
1835
+ }
1836
+ return value || "";
1837
+ },
1838
+ set(v) {
1839
+ const that = this;
1840
+ const proxy = gemElementProxyMap.get(this);
1841
+ const hasSet = proxy[prop];
1842
+ const value = that.getAttribute(attr);
1843
+ if (this[initSymbol] && value !== null && !hasSet)
1844
+ return;
1845
+ proxy[prop] = true;
1846
+ const isBool = booleanAttributes == null ? void 0 : booleanAttributes.has(attr);
1847
+ if (v === null || v === void 0) {
1848
+ that.removeAttribute(attr);
1849
+ } else if (isBool) {
1850
+ that.toggleAttribute(attr, !!v);
1851
+ } else {
1852
+ if (value !== String(v))
1853
+ that.setAttribute(attr, String(v));
1854
+ }
1855
+ }
1856
+ });
1857
+ }
1858
+ const isEventHandleSymbol = Symbol("event handle");
1859
+ function defineProperty(target, prop, event, eventOptions) {
1860
+ Object.defineProperty(target, prop, {
1861
+ configurable: true,
1862
+ get() {
1863
+ const value = gemElementProxyMap.get(this)[prop];
1864
+ if (value || !event) {
1865
+ return value;
1866
+ } else {
1867
+ this[prop] = emptyFunction;
1868
+ return this[prop];
1869
+ }
1870
+ },
1871
+ set(v) {
1872
+ const that = this;
1873
+ const proxy = gemElementProxyMap.get(that);
1874
+ if (v !== proxy[prop]) {
1875
+ if (event) {
1876
+ proxy[prop] = (v == null ? void 0 : v[isEventHandleSymbol]) ? v : (detail, options) => {
1877
+ const evt = new CustomEvent(event, __spreadProps(__spreadValues(__spreadValues({}, options), eventOptions), { detail }));
1878
+ that.dispatchEvent(evt);
1879
+ v(detail, options);
1880
+ };
1881
+ proxy[prop][isEventHandleSymbol] = true;
1882
+ } else {
1883
+ proxy[prop] = v;
1884
+ this[updateSymbol]();
1885
+ }
1886
+ }
1887
+ }
1888
+ });
1889
+ }
1890
+ function defineRef(target, prop, ref) {
1891
+ Object.defineProperty(target, prop, {
1892
+ configurable: true,
1893
+ get() {
1894
+ const proxy = gemElementProxyMap.get(this);
1895
+ let refobject2 = proxy[prop];
1896
+ if (!refobject2) {
1897
+ const that = this;
1898
+ const ele = that.shadowRoot || that;
1899
+ refobject2 = {
1900
+ get ref() {
1901
+ return ref;
1902
+ },
1903
+ get element() {
1904
+ const gemReflects = [...ele.querySelectorAll("[data-gemreflect]")].map((e) => e.target);
1905
+ for (const e of [ele, ...gemReflects]) {
1906
+ const result = e.querySelector(`[ref=${ref}]`);
1907
+ if (result)
1908
+ return result;
1909
+ }
1910
+ }
1911
+ };
1912
+ proxy[prop] = refobject2;
1913
+ }
1914
+ return refobject2;
1915
+ }
1916
+ });
1917
+ }
1918
+ function defineCSSState(target, prop, state2) {
1919
+ Object.defineProperty(target, prop, {
1920
+ configurable: true,
1921
+ get() {
1922
+ var _a2;
1923
+ const that = this;
1924
+ const { states } = that.internals;
1925
+ return (_a2 = states.has) == null ? void 0 : _a2.call(states, state2);
1926
+ },
1927
+ set(v) {
1928
+ const that = this;
1929
+ const { states } = that.internals;
1930
+ if (v) {
1931
+ states.add(state2);
1932
+ } else {
1933
+ states.delete(state2);
1934
+ }
1935
+ }
1936
+ });
1937
+ }
1938
+ const nativeDefineElement = customElements.define.bind(customElements);
1939
+ customElements.define = (name, cls, options) => {
1940
+ if (cls.prototype instanceof GemElement) {
1941
+ const { observedAttributes, observedPropertys, defineEvents, defineCSSStates, defineRefs } = cls;
1942
+ observedAttributes == null ? void 0 : observedAttributes.forEach((attr) => defineAttribute(cls.prototype, kebabToCamelCase(attr), attr));
1943
+ observedPropertys == null ? void 0 : observedPropertys.forEach((prop) => defineProperty(cls.prototype, prop));
1944
+ defineEvents == null ? void 0 : defineEvents.forEach((event) => defineProperty(cls.prototype, kebabToCamelCase(event), event));
1945
+ defineCSSStates == null ? void 0 : defineCSSStates.forEach((state2) => defineCSSState(cls.prototype, kebabToCamelCase(state2), `--${state2}`));
1946
+ defineRefs == null ? void 0 : defineRefs.forEach((ref) => defineRef(cls.prototype, kebabToCamelCase(ref), ref));
1947
+ }
1948
+ nativeDefineElement(name, cls, options);
1949
+ };
1950
+ function pushStaticField(target, field, member, isSet = false) {
1951
+ const cls = target.constructor;
1952
+ const current = cls[field];
1953
+ if (!cls.hasOwnProperty(field)) {
1954
+ Object.defineProperty(cls, field, {
1955
+ value: isSet ? new Set(current) : current ? Array.from(current) : []
1956
+ });
1957
+ }
1958
+ cls[field][isSet ? "add" : "push"](member);
1959
+ }
1960
+ function refobject(target, prop) {
1961
+ const ref = `${camelToKebabCase(prop)}-${randomStr()}`;
1962
+ pushStaticField(target, "defineRefs", ref);
1963
+ defineRef(target, prop, ref);
1964
+ }
1965
+ function defineAttr(target, prop, attr) {
1966
+ pushStaticField(target, "observedAttributes", attr);
1967
+ defineAttribute(target, prop, attr);
1968
+ }
1969
+ function attribute(target, prop) {
1970
+ defineAttr(target, prop, camelToKebabCase(prop));
1971
+ }
1972
+ function boolattribute(target, prop) {
1973
+ const attr = camelToKebabCase(prop);
1974
+ pushStaticField(target, "booleanAttributes", attr, true);
1975
+ defineAttr(target, prop, attr);
1976
+ }
1977
+ function numattribute(target, prop) {
1978
+ const attr = camelToKebabCase(prop);
1979
+ pushStaticField(target, "numberAttributes", attr, true);
1980
+ defineAttr(target, prop, attr);
1981
+ }
1982
+ function property(target, prop) {
1983
+ pushStaticField(target, "observedPropertys", prop);
1984
+ defineProperty(target, prop);
1985
+ }
1986
+ function state(target, prop) {
1987
+ const attr = camelToKebabCase(prop);
1988
+ pushStaticField(target, "defineCSSStates", attr);
1989
+ defineCSSState(target, prop, `--${attr}`);
1990
+ }
1991
+ function slot(target, prop) {
1992
+ const attr = camelToKebabCase(target[prop] || prop);
1993
+ target[prop] = attr;
1994
+ pushStaticField(target instanceof GemElement ? target : target.prototype, "defineSlots", attr);
1995
+ }
1996
+ function part(target, prop) {
1997
+ const attr = camelToKebabCase(target[prop] || prop);
1998
+ target[prop] = attr;
1999
+ pushStaticField(target instanceof GemElement ? target : target.prototype, "defineParts", attr);
2000
+ }
2001
+ function emitter(target, prop) {
2002
+ defineEmitter(target, prop);
2003
+ }
2004
+ function globalemitter(target, prop) {
2005
+ defineEmitter(target, prop, { bubbles: true, composed: true });
2006
+ }
2007
+ function defineEmitter(target, prop, options) {
2008
+ const event = camelToKebabCase(prop);
2009
+ pushStaticField(target, "defineEvents", event);
2010
+ defineProperty(target, prop, event, options);
2011
+ }
2012
+ function adoptedStyle(style) {
2013
+ return function(cls) {
2014
+ const con = cls;
2015
+ pushStaticField(con.prototype, "adoptedStyleSheets", style);
2016
+ };
2017
+ }
2018
+ function connectStore(store2) {
2019
+ return function(cls) {
2020
+ const con = cls;
2021
+ pushStaticField(con.prototype, "observedStores", store2);
2022
+ };
2023
+ }
2024
+ function rootElement(rootType) {
2025
+ return function(cls) {
2026
+ const con = cls;
2027
+ con.rootElement = rootType;
2028
+ };
2029
+ }
2030
+ function customElement(name) {
2031
+ return function(cls) {
2032
+ nativeDefineElement(name, cls);
2033
+ };
2034
+ }
2035
+ const nativeHistory = window.history;
2036
+ const nativePushState = nativeHistory.pushState.bind(nativeHistory);
2037
+ const nativeReplaceState = nativeHistory.replaceState.bind(nativeHistory);
2038
+ let key = 0;
2039
+ const getKey = () => `${performance.now()}-${++key}`;
2040
+ const store = createStore({
2041
+ $hasCloseHandle: false,
2042
+ $hasOpenHandle: false,
2043
+ $hasShouldCloseHandle: false,
2044
+ $key: ""
2045
+ });
2046
+ const paramsMap = new Map();
2047
+ function validData({ $key, $hasCloseHandle, $hasOpenHandle, $hasShouldCloseHandle } = {}) {
2048
+ if (store.$key === $key)
2049
+ return;
2050
+ if ($key)
2051
+ throw new GemError("`$key` is not allowed");
2052
+ if ($hasCloseHandle)
2053
+ throw new GemError("`$hasCloseHandle` is not allowed");
2054
+ if ($hasOpenHandle)
2055
+ throw new GemError("`$hasOpenHandle` is not allowed");
2056
+ if ($hasShouldCloseHandle)
2057
+ throw new GemError("`$hasShouldCloseHandle` is not allowed");
2058
+ }
2059
+ function getUrlbarPath(internalPath) {
2060
+ return gemHistory.basePath ? gemHistory.basePath + internalPath : internalPath;
2061
+ }
2062
+ function getInternalPath(urlbarPath) {
2063
+ if (urlbarPath === gemHistory.basePath)
2064
+ return "/";
2065
+ return urlbarPath.replace(new RegExp(`^${gemHistory.basePath}/`), "/");
2066
+ }
2067
+ function normalizeParams(params) {
2068
+ const current = paramsMap.get(store.$key) || {};
2069
+ const path = params.path ? absoluteLocation(current.path, params.path) : getInternalPath(location.pathname);
2070
+ const query = new QueryString(params.query || (params.path ? "" : location.search));
2071
+ const pathChanged = params.path && params.path !== current.path || params.query && String(params.query) !== String(current.query);
2072
+ const title = params.title || (pathChanged ? "" : document.title);
2073
+ const statusChanged = params.close || params.data || params.open || params.shouldClose;
2074
+ const hash = params.hash || (!pathChanged && statusChanged ? decodeURIComponent(location.hash) : "");
2075
+ return __spreadProps(__spreadValues({}, params), { title, path, query, hash });
2076
+ }
2077
+ function updateHistory(p, native) {
2078
+ validData(p.data);
2079
+ const params = normalizeParams(p);
2080
+ const { title, path, query, hash, close, open: open2, shouldClose, data } = params;
2081
+ const state2 = __spreadValues({
2082
+ $hasCloseHandle: !!close,
2083
+ $hasOpenHandle: !!open2,
2084
+ $hasShouldCloseHandle: !!shouldClose,
2085
+ $key: getKey()
2086
+ }, data);
2087
+ paramsMap.set(state2.$key, params);
2088
+ updateStore(cleanObject(store), state2);
2089
+ const url = getUrlbarPath(path) + new QueryString(query) + hash;
2090
+ const prevHash = decodeURIComponent(location.hash);
2091
+ native(state2, title, url);
2092
+ if (prevHash !== hash)
2093
+ window.dispatchEvent(new CustomEvent("hashchange"));
2094
+ }
2095
+ function updateHistoryByNative(data, title, originUrl, native) {
2096
+ validData(data);
2097
+ const state2 = __spreadValues({
2098
+ $key: getKey()
2099
+ }, data || {});
2100
+ const { pathname, search, hash } = new URL(originUrl, location.origin + location.pathname);
2101
+ const params = normalizeParams({ path: pathname, query: new QueryString(search), hash, title, data });
2102
+ paramsMap.set(state2.$key, params);
2103
+ updateStore(cleanObject(store), state2);
2104
+ const url = getUrlbarPath(pathname) + params.query + hash;
2105
+ const prevHash = location.hash;
2106
+ native(state2, title, url);
2107
+ if (prevHash !== hash)
2108
+ window.dispatchEvent(new CustomEvent("hashchange"));
2109
+ }
2110
+ const gemBasePathStore = createStore({
2111
+ basePath: ""
2112
+ });
2113
+ class GemHistory {
2114
+ get store() {
2115
+ return store;
2116
+ }
2117
+ get basePath() {
2118
+ return gemBasePathStore.basePath;
2119
+ }
2120
+ set basePath(basePath) {
2121
+ updateStore(gemBasePathStore, { basePath });
2122
+ Object.assign(paramsMap.get(store.$key), { path: getInternalPath(location.pathname) });
2123
+ }
2124
+ getParams() {
2125
+ return paramsMap.get(store.$key);
2126
+ }
2127
+ updateParams(params) {
2128
+ Object.assign(paramsMap.get(store.$key), params);
2129
+ updateStore(store, {});
2130
+ }
2131
+ push(params) {
2132
+ updateHistory(params, nativePushState);
2133
+ }
2134
+ replace(params) {
2135
+ updateHistory(params, nativeReplaceState);
2136
+ }
2137
+ pushIgnoreCloseHandle(params) {
2138
+ var _a2, _b;
2139
+ if (store.$hasCloseHandle) {
2140
+ (_b = (_a2 = paramsMap.get(store.$key)) == null ? void 0 : _a2.close) == null ? void 0 : _b.call(_a2);
2141
+ this.replace(params);
2142
+ } else {
2143
+ this.push(params);
2144
+ }
2145
+ }
2146
+ forward() {
2147
+ nativeHistory.forward();
2148
+ }
2149
+ back() {
2150
+ nativeHistory.back();
2151
+ }
2152
+ }
2153
+ const gemHistory = new GemHistory();
2154
+ const gemTitleStore = createStore({ title: "" });
2155
+ const _GEMHISTORY = { history: gemHistory, titleStore: gemTitleStore, basePathStore: gemBasePathStore };
2156
+ if (!window._GEMHISTORY) {
2157
+ window._GEMHISTORY = _GEMHISTORY;
2158
+ nativeHistory.pushState = function(state2, title, path) {
2159
+ updateHistoryByNative(state2, title, path, nativePushState);
2160
+ };
2161
+ nativeHistory.replaceState = function(state2, title, path) {
2162
+ updateHistoryByNative(state2, title, path, nativeReplaceState);
2163
+ };
2164
+ window.addEventListener("hashchange", ({ isTrusted }) => {
2165
+ if (isTrusted) {
2166
+ gemHistory.replace({ hash: decodeURIComponent(location.hash) });
2167
+ }
2168
+ });
2169
+ if (!nativeHistory.state) {
2170
+ const { pathname, search, hash } = location;
2171
+ gemHistory.replace({ path: pathname, query: search, hash });
2172
+ } else if (nativeHistory.state.$hasCloseHandle) {
2173
+ updateStore(store, nativeHistory.state);
2174
+ const params = normalizeParams({ title: document.title });
2175
+ paramsMap.set(store.$key, params);
2176
+ gemHistory.back();
2177
+ } else {
2178
+ const params = normalizeParams({ title: document.title, hash: location.hash });
2179
+ updateStore(store, __spreadValues({
2180
+ $key: getKey()
2181
+ }, nativeHistory.state || {}));
2182
+ paramsMap.set(store.$key, params);
2183
+ }
2184
+ connect(gemTitleStore, () => {
2185
+ const params = paramsMap.get(store.$key);
2186
+ if (params) {
2187
+ params.title = gemTitleStore.title;
2188
+ }
2189
+ });
2190
+ connect(store, () => {
2191
+ const { title } = gemHistory.getParams();
2192
+ if (title !== gemTitleStore.title) {
2193
+ updateStore(gemTitleStore, { title });
2194
+ }
2195
+ });
2196
+ let navigating = false;
2197
+ window.addEventListener("popstate", (event) => {
2198
+ var _a2, _b;
2199
+ const newState = event.state;
2200
+ if (!(newState == null ? void 0 : newState.$key)) {
2201
+ return;
2202
+ }
2203
+ if (navigating) {
2204
+ navigating = false;
2205
+ return;
2206
+ }
2207
+ if (!paramsMap.has(newState.$key)) {
2208
+ const { pathname, search, hash } = location;
2209
+ paramsMap.set(newState.$key, {
2210
+ path: pathname,
2211
+ query: new QueryString(search),
2212
+ hash,
2213
+ title: document.title,
2214
+ data: newState
2215
+ });
2216
+ }
2217
+ const prevState = store;
2218
+ if (parseFloat(newState.$key) > parseFloat(prevState.$key) && newState.$hasOpenHandle) {
2219
+ (_b = (_a2 = paramsMap.get(newState.$key)) == null ? void 0 : _a2.open) == null ? void 0 : _b.call(_a2);
2220
+ } else if (prevState.$hasCloseHandle) {
2221
+ const prevParams = paramsMap.get(prevState.$key);
2222
+ const closeHandle = prevParams == null ? void 0 : prevParams.close;
2223
+ const shouldCloseHandle = prevParams == null ? void 0 : prevParams.shouldClose;
2224
+ const notAllowClose = shouldCloseHandle && !shouldCloseHandle();
2225
+ if (notAllowClose) {
2226
+ navigating = true;
2227
+ gemHistory.forward();
2228
+ return;
2229
+ } else {
2230
+ if (closeHandle) {
2231
+ closeHandle();
2232
+ } else if (newState.$hasCloseHandle) {
2233
+ navigating = true;
2234
+ gemHistory.back();
2235
+ }
2236
+ }
2237
+ }
2238
+ updateStore(cleanObject(store), newState);
2239
+ });
2240
+ }
2241
+ const { history, titleStore, basePathStore } = window._GEMHISTORY;
2242
+ var __defProp$6 = Object.defineProperty;
2243
+ var __getOwnPropDesc$6 = Object.getOwnPropertyDescriptor;
2244
+ var __decorateClass$6 = (decorators, target, key2, kind) => {
2245
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$6(target, key2) : target;
2246
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
2247
+ if (decorator = decorators[i])
2248
+ result = (kind ? decorator(target, key2, result) : decorator(result)) || result;
2249
+ if (kind && result)
2250
+ __defProp$6(target, key2, result);
2251
+ return result;
2252
+ };
2253
+ var __accessCheck2 = (obj, member, msg) => {
2254
+ if (!member.has(obj))
2255
+ throw TypeError("Cannot " + msg);
2256
+ };
2257
+ var __privateGet2 = (obj, member, getter) => {
2258
+ __accessCheck2(obj, member, "read from private field");
2259
+ return getter ? getter.call(obj) : member.get(obj);
2260
+ };
2261
+ var __privateAdd2 = (obj, member, value) => {
2262
+ if (member.has(obj))
2263
+ throw TypeError("Cannot add the same private member more than once");
2264
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
2265
+ };
2266
+ var __privateSet2 = (obj, member, value, setter) => {
2267
+ __accessCheck2(obj, member, "write to private field");
2268
+ setter ? setter.call(obj, value) : member.set(obj, value);
2269
+ return value;
2270
+ };
2271
+ var _lastLoader, _updateLocationStore, _setContent;
2272
+ class ParamsRegExp extends RegExp {
2273
+ constructor(pattern) {
2274
+ const namePosition = {};
2275
+ let i = 0;
2276
+ super(`^${pattern.replace(/:([^/$]+)/g, (_m, name) => {
2277
+ namePosition[name] = i++;
2278
+ return `([^/]+)`;
2279
+ }).replace("*", ".*")}$`, "i");
2280
+ this.namePosition = namePosition;
2281
+ }
2282
+ }
2283
+ function matchPath(pattern, path) {
2284
+ const reg = new ParamsRegExp(pattern);
2285
+ const matchResult = path.match(reg) || `${path}/`.match(reg);
2286
+ if (!matchResult)
2287
+ return null;
2288
+ const params = {};
2289
+ if (matchResult) {
2290
+ Object.keys(reg.namePosition).forEach((name) => {
2291
+ params[name] = matchResult[reg.namePosition[name] + 1];
2292
+ });
2293
+ }
2294
+ return params;
2295
+ }
2296
+ function createPath(route, options) {
2297
+ let path = route.pattern;
2298
+ const params = options == null ? void 0 : options.params;
2299
+ if (params) {
2300
+ Object.keys(params).forEach((key2) => {
2301
+ path = path.replace(new RegExp(`:${key2}`, "g"), params[key2]);
2302
+ });
2303
+ }
2304
+ return path;
2305
+ }
2306
+ function createHistoryParams(route, options) {
2307
+ const path = createPath(route, options);
2308
+ return __spreadValues({
2309
+ path
2310
+ }, options);
2311
+ }
2312
+ let GemRouteElement = class extends GemElement {
2313
+ constructor({ isLight, routes } = {}) {
2314
+ super({ isLight });
2315
+ this.currentParams = {};
2316
+ __privateAdd2(this, _lastLoader, void 0);
2317
+ this.state = {
2318
+ content: void 0
2319
+ };
2320
+ __privateAdd2(this, _updateLocationStore, () => {
2321
+ if (this.locationStore) {
2322
+ const { path, query, data } = history.getParams();
2323
+ updateStore(this.locationStore, {
2324
+ path,
2325
+ params: this.currentParams,
2326
+ query,
2327
+ data
2328
+ });
2329
+ }
2330
+ });
2331
+ __privateAdd2(this, _setContent, (route, params, content) => {
2332
+ __privateSet2(this, _lastLoader, void 0);
2333
+ this.currentRoute = route;
2334
+ this.currentParams = params;
2335
+ this.setState({ content });
2336
+ this.routechange(this.currentRoute);
2337
+ __privateGet2(this, _updateLocationStore).call(this);
2338
+ });
2339
+ this.routes = routes;
2340
+ }
2341
+ mounted() {
2342
+ this.effect(([key2, path], old) => {
2343
+ if (old && key2 === old[0] && path === old[1]) {
2344
+ __privateGet2(this, _updateLocationStore).call(this);
2345
+ return;
2346
+ }
2347
+ const { route, params = {} } = GemRouteElement.findRoute(this.routes, path);
2348
+ const { redirect, content, getContent } = route || {};
2349
+ if (redirect) {
2350
+ history.replace({ path: redirect });
2351
+ return;
2352
+ }
2353
+ const title = route == null ? void 0 : route.title;
2354
+ if (title)
2355
+ updateStore(titleStore, { title });
2356
+ const contentOrLoader = content || (getContent == null ? void 0 : getContent(params));
2357
+ if (contentOrLoader instanceof Promise) {
2358
+ this.loading(route);
2359
+ __privateSet2(this, _lastLoader, contentOrLoader);
2360
+ const isSomeLoader = () => __privateGet2(this, _lastLoader) === contentOrLoader;
2361
+ contentOrLoader.then((content2) => {
2362
+ if (isSomeLoader())
2363
+ __privateGet2(this, _setContent).call(this, route, params, content2);
2364
+ }).catch((err) => {
2365
+ if (isSomeLoader())
2366
+ this.error(err);
2367
+ });
2368
+ return;
2369
+ }
2370
+ __privateGet2(this, _setContent).call(this, route, params, contentOrLoader);
2371
+ }, () => {
2372
+ const { path } = history.getParams();
2373
+ return [this.key, path, location.search];
2374
+ });
2375
+ }
2376
+ shouldUpdate() {
2377
+ if (this.inert)
2378
+ return false;
2379
+ return true;
2380
+ }
2381
+ render() {
2382
+ const { content } = this.state;
2383
+ if (!this.shadowRoot)
2384
+ return html`${content}`;
2385
+ return html`
2386
+ <style>
2387
+ :host,
2388
+ :not(:defined) {
2389
+ display: contents;
2390
+ }
2391
+ </style>
2392
+ ${content != null ? content : html`<slot></slot>`}
2393
+ `;
2394
+ }
2395
+ };
2396
+ _lastLoader = new WeakMap();
2397
+ _updateLocationStore = new WeakMap();
2398
+ _setContent = new WeakMap();
2399
+ GemRouteElement.createLocationStore = () => {
2400
+ const { path, query, data } = history.getParams();
2401
+ return createStore({ path, query, data, params: {} });
2402
+ };
2403
+ GemRouteElement.findRoute = (target = [], path) => {
2404
+ let defaultRoute = null;
2405
+ let routes;
2406
+ if (target instanceof Array) {
2407
+ routes = target;
2408
+ } else {
2409
+ routes = Object.values(target);
2410
+ }
2411
+ for (const route of routes) {
2412
+ if (route.pattern === "*") {
2413
+ defaultRoute = route;
2414
+ } else {
2415
+ const params = matchPath(route.pattern, path);
2416
+ if (params) {
2417
+ return { route, params };
2418
+ }
2419
+ }
2420
+ }
2421
+ return { route: defaultRoute };
2422
+ };
2423
+ __decorateClass$6([
2424
+ property
2425
+ ], GemRouteElement.prototype, "routes", 2);
2426
+ __decorateClass$6([
2427
+ property
2428
+ ], GemRouteElement.prototype, "locationStore", 2);
2429
+ __decorateClass$6([
2430
+ property
2431
+ ], GemRouteElement.prototype, "key", 2);
2432
+ __decorateClass$6([
2433
+ emitter
2434
+ ], GemRouteElement.prototype, "routechange", 2);
2435
+ __decorateClass$6([
2436
+ emitter
2437
+ ], GemRouteElement.prototype, "loading", 2);
2438
+ __decorateClass$6([
2439
+ emitter
2440
+ ], GemRouteElement.prototype, "error", 2);
2441
+ GemRouteElement = __decorateClass$6([
2442
+ connectStore(history.store)
2443
+ ], GemRouteElement);
2444
+ class GemLightRouteElement extends GemRouteElement {
2445
+ constructor(options = {}) {
2446
+ super(__spreadProps(__spreadValues({}, options), { isLight: true }));
2447
+ }
2448
+ }
2449
+ var __defProp$5 = Object.defineProperty;
2450
+ var __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor;
2451
+ var __decorateClass$5 = (decorators, target, key2, kind) => {
2452
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key2) : target;
2453
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
2454
+ if (decorator = decorators[i])
2455
+ result = (kind ? decorator(target, key2, result) : decorator(result)) || result;
2456
+ if (kind && result)
2457
+ __defProp$5(target, key2, result);
2458
+ return result;
2459
+ };
2460
+ let GemLinkElement = class extends GemElement {
2461
+ constructor() {
2462
+ super();
2463
+ this.clickHandle = async (e) => {
2464
+ var _a2;
2465
+ const pathInfo = this.getPathInfo();
2466
+ if (!pathInfo)
2467
+ return;
2468
+ if (this.isExternal(pathInfo)) {
2469
+ switch (this.target) {
2470
+ case "_self":
2471
+ window.location.href = pathInfo;
2472
+ return;
2473
+ case "_parent":
2474
+ window.parent.location.href = pathInfo;
2475
+ return;
2476
+ case "_top":
2477
+ window.top.location.href = pathInfo;
2478
+ return;
2479
+ default:
2480
+ window.open(pathInfo);
2481
+ return;
2482
+ }
2483
+ }
2484
+ const { path, query, hash } = history.getParams();
2485
+ if (path + query + hash === pathInfo) {
2486
+ return;
2487
+ }
2488
+ e.stopPropagation();
2489
+ await ((_a2 = this.prepare) == null ? void 0 : _a2.call(this));
2490
+ if (this.route) {
2491
+ history.pushIgnoreCloseHandle(__spreadProps(__spreadValues({}, createHistoryParams(this.route, this.options)), {
2492
+ title: this.route.title || this.docTitle
2493
+ }));
2494
+ } else if (this.href) {
2495
+ const { pathname, search, hash: hash2 } = new URL(pathInfo, location.origin);
2496
+ history.pushIgnoreCloseHandle({
2497
+ path: pathname,
2498
+ query: search,
2499
+ hash: hash2,
2500
+ title: this.docTitle
2501
+ });
2502
+ } else {
2503
+ history.pushIgnoreCloseHandle({ path: this.path, query: this.query, hash: this.hash, title: this.docTitle });
2504
+ }
2505
+ };
2506
+ this.preventDefault = (e) => {
2507
+ e.preventDefault();
2508
+ };
2509
+ this.tabIndex = 0;
2510
+ this.addEventListener("click", this.clickHandle);
2511
+ }
2512
+ getPathInfo() {
2513
+ var _a2, _b;
2514
+ if (this.route) {
2515
+ const queryProp = ((_a2 = this.options) == null ? void 0 : _a2.query) || "";
2516
+ const hashProp = ((_b = this.options) == null ? void 0 : _b.hash) || "";
2517
+ return createPath(this.route, this.options) + queryProp + hashProp;
2518
+ } else {
2519
+ const url = this.href || this.path + this.query + this.hash;
2520
+ const { path, query } = history.getParams();
2521
+ if (url.startsWith("#")) {
2522
+ return `${path}${query}${url}`;
2523
+ } else if (url.startsWith("?")) {
2524
+ return `${path}${url}`;
2525
+ } else if (url.startsWith(".")) {
2526
+ return absoluteLocation(path, url);
2527
+ } else {
2528
+ return url;
2529
+ }
2530
+ }
2531
+ }
2532
+ isExternal(pathInfo) {
2533
+ return !pathInfo.startsWith("/");
2534
+ }
2535
+ render(pathInfo = this.getPathInfo()) {
2536
+ return html`
2537
+ <style>
2538
+ :host {
2539
+ /* link default style */
2540
+ cursor: pointer;
2541
+ color: blue;
2542
+ text-decoration: underline;
2543
+ }
2544
+ a {
2545
+ all: unset;
2546
+ display: contents;
2547
+ }
2548
+ a:visited {
2549
+ color: unset;
2550
+ }
2551
+ </style>
2552
+ <a
2553
+ part=${this.link}
2554
+ @click=${this.preventDefault}
2555
+ href=${ifDefined(this.hint === "off" ? void 0 : this.isExternal(pathInfo) ? pathInfo : new URL(history.basePath + pathInfo, location.origin).toString())}
2556
+ >
2557
+ <slot></slot>
2558
+ </a>
2559
+ `;
2560
+ }
2561
+ };
2562
+ __decorateClass$5([
2563
+ attribute
2564
+ ], GemLinkElement.prototype, "href", 2);
2565
+ __decorateClass$5([
2566
+ attribute
2567
+ ], GemLinkElement.prototype, "target", 2);
2568
+ __decorateClass$5([
2569
+ attribute
2570
+ ], GemLinkElement.prototype, "path", 2);
2571
+ __decorateClass$5([
2572
+ attribute
2573
+ ], GemLinkElement.prototype, "query", 2);
2574
+ __decorateClass$5([
2575
+ attribute
2576
+ ], GemLinkElement.prototype, "hash", 2);
2577
+ __decorateClass$5([
2578
+ attribute
2579
+ ], GemLinkElement.prototype, "docTitle", 2);
2580
+ __decorateClass$5([
2581
+ attribute
2582
+ ], GemLinkElement.prototype, "hint", 2);
2583
+ __decorateClass$5([
2584
+ property
2585
+ ], GemLinkElement.prototype, "route", 2);
2586
+ __decorateClass$5([
2587
+ property
2588
+ ], GemLinkElement.prototype, "options", 2);
2589
+ __decorateClass$5([
2590
+ property
2591
+ ], GemLinkElement.prototype, "prepare", 2);
2592
+ __decorateClass$5([
2593
+ part
2594
+ ], GemLinkElement.prototype, "link", 2);
2595
+ GemLinkElement = __decorateClass$5([
2596
+ connectStore(basePathStore)
2597
+ ], GemLinkElement);
2598
+ let GemActiveLinkElement = class extends GemLinkElement {
2599
+ render() {
2600
+ const { path, query, hash } = history.getParams();
2601
+ const isMatchPattern = this.pattern && matchPath(this.pattern, path);
2602
+ const pathInfo = this.getPathInfo();
2603
+ if (isMatchPattern || path + query + hash === pathInfo) {
2604
+ this.active = true;
2605
+ } else {
2606
+ this.active = false;
2607
+ }
2608
+ return super.render(pathInfo);
2609
+ }
2610
+ };
2611
+ __decorateClass$5([
2612
+ attribute
2613
+ ], GemActiveLinkElement.prototype, "pattern", 2);
2614
+ __decorateClass$5([
2615
+ state
2616
+ ], GemActiveLinkElement.prototype, "active", 2);
2617
+ GemActiveLinkElement = __decorateClass$5([
2618
+ connectStore(history.store)
2619
+ ], GemActiveLinkElement);
2620
+ customElements.define("gem-link", GemLinkElement);
2621
+ customElements.define("gem-active-link", GemActiveLinkElement);
2622
+ customElements.define("gem-route", GemRouteElement);
2623
+ customElements.define("gem-light-route", GemLightRouteElement);
2624
+ var __defProp$4 = Object.defineProperty;
2625
+ var __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor;
2626
+ var __decorateClass$4 = (decorators, target, key2, kind) => {
2627
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key2) : target;
2628
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
2629
+ if (decorator = decorators[i])
2630
+ result = (kind ? decorator(target, key2, result) : decorator(result)) || result;
2631
+ if (kind && result)
2632
+ __defProp$4(target, key2, result);
2633
+ return result;
2634
+ };
2635
+ let GemTitleElement = class extends GemElement {
2636
+ static setTitle(title) {
2637
+ updateStore(titleStore, { title });
2638
+ }
2639
+ static updateTitle(str = "", suffix = "") {
2640
+ const { title } = titleStore;
2641
+ if (title && title !== GemTitleElement.defaultTitle) {
2642
+ GemTitleElement.title = title;
2643
+ document.title = GemTitleElement.title + suffix;
2644
+ } else if (str) {
2645
+ GemTitleElement.title = str;
2646
+ document.title = GemTitleElement.title + suffix;
2647
+ } else {
2648
+ GemTitleElement.title = GemTitleElement.defaultTitle;
2649
+ document.title = GemTitleElement.title;
2650
+ }
2651
+ }
2652
+ constructor() {
2653
+ super();
2654
+ new MutationObserver(() => this.update()).observe(this, { childList: true, characterData: true, subtree: true });
2655
+ }
2656
+ render() {
2657
+ GemTitleElement.updateTitle(this.textContent || "", this.suffix);
2658
+ if (this.hidden) {
2659
+ return html``;
2660
+ }
2661
+ return html`${GemTitleElement.title}`;
2662
+ }
2663
+ };
2664
+ GemTitleElement.title = document.title;
2665
+ GemTitleElement.defaultTitle = document.title;
2666
+ GemTitleElement.defaultSuffix = ` - ${document.title}`;
2667
+ __decorateClass$4([
2668
+ attribute
2669
+ ], GemTitleElement.prototype, "suffix", 2);
2670
+ GemTitleElement = __decorateClass$4([
2671
+ connectStore(titleStore)
2672
+ ], GemTitleElement);
2673
+ connect(titleStore, GemTitleElement.updateTitle);
2674
+ customElements.define("gem-title", GemTitleElement);
2675
+ var __defProp$3 = Object.defineProperty;
2676
+ var __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor;
2677
+ var __decorateClass$3 = (decorators, target, key2, kind) => {
2678
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key2) : target;
2679
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
2680
+ if (decorator = decorators[i])
2681
+ result = (kind ? decorator(target, key2, result) : decorator(result)) || result;
2682
+ if (kind && result)
2683
+ __defProp$3(target, key2, result);
2684
+ return result;
2685
+ };
2686
+ const eleCache = new Map();
2687
+ class GemUseElement extends GemElement {
2688
+ getContent() {
2689
+ const ele = this.element || (this.selector ? (this.root || document).querySelector(this.selector) : null);
2690
+ if (typeof ele === "string") {
2691
+ let temp = eleCache.get(ele);
2692
+ if (!temp) {
2693
+ temp = document.createElement("template");
2694
+ temp.innerHTML = ele;
2695
+ eleCache.set(ele, temp);
2696
+ }
2697
+ return temp.content.cloneNode(true);
2698
+ } else if (ele instanceof HTMLTemplateElement) {
2699
+ return ele.content.cloneNode(true);
2700
+ } else {
2701
+ return ele == null ? void 0 : ele.cloneNode(true);
2702
+ }
2703
+ }
2704
+ render() {
2705
+ return html`
2706
+ <style>
2707
+ :host {
2708
+ position: relative;
2709
+ }
2710
+ :host(:not([hidden])) {
2711
+ display: inline-flex;
2712
+ align-items: center;
2713
+ }
2714
+ svg {
2715
+ width: 100%;
2716
+ height: 100%;
2717
+ }
2718
+ </style>
2719
+ ${this.getContent()}
2720
+ <slot></slot>
2721
+ `;
2722
+ }
2723
+ }
2724
+ __decorateClass$3([
2725
+ attribute
2726
+ ], GemUseElement.prototype, "selector", 2);
2727
+ __decorateClass$3([
2728
+ property
2729
+ ], GemUseElement.prototype, "root", 2);
2730
+ __decorateClass$3([
2731
+ property
2732
+ ], GemUseElement.prototype, "element", 2);
2733
+ __decorateClass$3([
2734
+ state
2735
+ ], GemUseElement.prototype, "active", 2);
2736
+ customElements.define("gem-use", GemUseElement);
2737
+ var __defProp$2 = Object.defineProperty;
2738
+ var __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor;
2739
+ var __decorateClass$2 = (decorators, target, key2, kind) => {
2740
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key2) : target;
2741
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
2742
+ if (decorator = decorators[i])
2743
+ result = (kind ? decorator(target, key2, result) : decorator(result)) || result;
2744
+ if (kind && result)
2745
+ __defProp$2(target, key2, result);
2746
+ return result;
2747
+ };
2748
+ class GemUnsafeElement extends GemElement {
2749
+ constructor() {
2750
+ super();
2751
+ this.effect(() => {
2752
+ if (this.shadowRoot) {
2753
+ this.shadowRoot.innerHTML = `
2754
+ <style>
2755
+ :host {
2756
+ display: contents;
2757
+ }
2758
+ ${this.contentcss}
2759
+ </style>
2760
+ ${this.content}
2761
+ `;
2762
+ }
2763
+ }, () => [this.content, this.contentcss]);
2764
+ }
2765
+ render() {
2766
+ return void 0;
2767
+ }
2768
+ }
2769
+ __decorateClass$2([
2770
+ attribute
2771
+ ], GemUnsafeElement.prototype, "content", 2);
2772
+ __decorateClass$2([
2773
+ attribute
2774
+ ], GemUnsafeElement.prototype, "contentcss", 2);
2775
+ customElements.define("gem-unsafe", GemUnsafeElement);
2776
+ var __defProp$1 = Object.defineProperty;
2777
+ var __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor;
2778
+ var __decorateClass$1 = (decorators, target, key2, kind) => {
2779
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key2) : target;
2780
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
2781
+ if (decorator = decorators[i])
2782
+ result = (kind ? decorator(target, key2, result) : decorator(result)) || result;
2783
+ if (kind && result)
2784
+ __defProp$1(target, key2, result);
2785
+ return result;
2786
+ };
2787
+ document.querySelectorAll("[data-reflect]").forEach((e) => e.remove());
2788
+ class GemReflectElement extends GemElement {
2789
+ constructor() {
2790
+ super({ isLight: true });
2791
+ this.target = document.head;
2792
+ this.hidden = true;
2793
+ this.dataset.gemreflect = "";
2794
+ this.effect(() => {
2795
+ const childNodes = [...this.childNodes];
2796
+ childNodes.forEach((node) => {
2797
+ if (node instanceof HTMLElement) {
2798
+ node.dataset.reflect = "";
2799
+ }
2800
+ this.target.append(node);
2801
+ });
2802
+ return () => {
2803
+ childNodes.forEach((node) => node.remove());
2804
+ };
2805
+ }, () => [this.target]);
2806
+ }
2807
+ }
2808
+ __decorateClass$1([
2809
+ property
2810
+ ], GemReflectElement.prototype, "target", 2);
2811
+ customElements.define("gem-reflect", GemReflectElement);
2812
+ const open = Symbol("open mark");
2813
+ function createModalClass(options) {
2814
+ var _a2;
2815
+ return _a2 = class extends GemElement {
2816
+ constructor() {
2817
+ super();
2818
+ this.label = "";
2819
+ this.internals.role = "alertdialog";
2820
+ this.internals.ariaModal = "true";
2821
+ }
2822
+ static get isOpen() {
2823
+ return this.store[open];
2824
+ }
2825
+ static get observedStores() {
2826
+ return [history.store, this.store];
2827
+ }
2828
+ static open(opts) {
2829
+ const instance = new this();
2830
+ this.instance = instance;
2831
+ this.inertStore = [...document.body.children].filter((e) => !e.inert);
2832
+ this.inertStore.forEach((e) => e.inert = true);
2833
+ document.body.append(instance);
2834
+ const changeStore = () => updateStore(this.store, __spreadValues({ [open]: true }, opts));
2835
+ setTimeout(() => {
2836
+ changeStore();
2837
+ history.push({
2838
+ title: instance.label,
2839
+ open: changeStore,
2840
+ close: this.closeHandle.bind(this),
2841
+ shouldClose: this.shouldClose.bind(this)
2842
+ });
2843
+ }, 100);
2844
+ }
2845
+ static close() {
2846
+ history.back();
2847
+ }
2848
+ static closeHandle() {
2849
+ var _a3;
2850
+ this.inertStore.forEach((e) => e.inert = false);
2851
+ (_a3 = this.instance) == null ? void 0 : _a3.remove();
2852
+ updateStore(this.store, __spreadValues({ [open]: false }, options));
2853
+ }
2854
+ static shouldClose() {
2855
+ return true;
2856
+ }
2857
+ }, _a2.inertStore = [], _a2.instance = null, _a2.store = createStore(__spreadValues({
2858
+ [open]: false
2859
+ }, options)), _a2;
2860
+ }
2861
+ var __defProp2 = Object.defineProperty;
2862
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
2863
+ var __decorateClass = (decorators, target, key2, kind) => {
2864
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key2) : target;
2865
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
2866
+ if (decorator = decorators[i])
2867
+ result = (kind ? decorator(target, key2, result) : decorator(result)) || result;
2868
+ if (kind && result)
2869
+ __defProp2(target, key2, result);
2870
+ return result;
2871
+ };
2872
+ let GemDialogBaseElement = (_a = class extends GemElement {
2873
+ constructor() {
2874
+ super();
2875
+ __privateAdd(this, _nextSibling, void 0);
2876
+ __privateAdd(this, _parentElement, void 0);
2877
+ __privateAdd(this, _inertStore, void 0);
2878
+ this.inert = true;
2879
+ __privateSet(this, _inertStore, []);
2880
+ this.closeHandle = () => {
2881
+ var _a2;
2882
+ this.inert = true;
2883
+ __privateGet(this, _inertStore).forEach((e) => e.inert = false);
2884
+ if (__privateGet(this, _nextSibling)) {
2885
+ __privateGet(this, _nextSibling).before(this);
2886
+ } else if (__privateGet(this, _parentElement)) {
2887
+ (_a2 = __privateGet(this, _parentElement)) == null ? void 0 : _a2.appendChild(this);
2888
+ }
2889
+ this.dispatchEvent(new CustomEvent("close"));
2890
+ this.opened = false;
2891
+ };
2892
+ this.openHandle = () => {
2893
+ this.hidden = false;
2894
+ this.inert = false;
2895
+ __privateSet(this, _nextSibling, this.nextSibling);
2896
+ __privateSet(this, _parentElement, this.parentElement || this.getRootNode());
2897
+ __privateSet(this, _inertStore, [...document.body.children].filter((e) => !e.inert));
2898
+ __privateGet(this, _inertStore).forEach((e) => e.inert = true);
2899
+ document.body.append(this);
2900
+ this.dispatchEvent(new CustomEvent("open"));
2901
+ this.opened = true;
2902
+ };
2903
+ this.open = () => {
2904
+ if (this.opened)
2905
+ return;
2906
+ this.openHandle();
2907
+ history.push({
2908
+ title: this.label,
2909
+ open: this.openHandle,
2910
+ close: this.closeHandle,
2911
+ shouldClose: this.shouldClose
2912
+ });
2913
+ };
2914
+ this.close = () => {
2915
+ history.back();
2916
+ };
2917
+ this.forceClose = () => {
2918
+ this.opened = false;
2919
+ setTimeout(this.close, 100);
2920
+ };
2921
+ this.internals.role = "dialog";
2922
+ this.internals.ariaModal = "true";
2923
+ }
2924
+ shouldClose() {
2925
+ return true;
2926
+ }
2927
+ }, _nextSibling = new WeakMap(), _parentElement = new WeakMap(), _inertStore = new WeakMap(), _a);
2928
+ __decorateClass([
2929
+ attribute
2930
+ ], GemDialogBaseElement.prototype, "label", 2);
2931
+ __decorateClass([
2932
+ state
2933
+ ], GemDialogBaseElement.prototype, "opened", 2);
2934
+ GemDialogBaseElement = __decorateClass([
2935
+ connectStore(history.store)
2936
+ ], GemDialogBaseElement);
2937
+ const themeStoreMap = new WeakMap();
2938
+ function getThemeStore(theme) {
2939
+ return themeStoreMap.get(theme);
2940
+ }
2941
+ const themePropMap = new WeakMap();
2942
+ function getThemeProp(theme) {
2943
+ return themePropMap.get(theme);
2944
+ }
2945
+ function replaceStyle(style, theme) {
2946
+ const themeStore = themeStoreMap.get(theme);
2947
+ const themeProp = themePropMap.get(theme);
2948
+ const rules = Object.keys(themeStore).reduce((prev, key2) => {
2949
+ if (!themeStore[key2])
2950
+ return prev;
2951
+ return prev + `${themeProp[key2]}:${themeStore[key2]};`;
2952
+ }, "");
2953
+ style.textContent = `:root, :host {${rules}}`;
2954
+ }
2955
+ function createTheme(themeObj) {
2956
+ const salt = randomStr();
2957
+ const style = document.createElement("style");
2958
+ const themeStore = createStore(themeObj);
2959
+ const theme = {};
2960
+ const themeProp = {};
2961
+ themePropMap.set(theme, themeProp);
2962
+ themeStoreMap.set(theme, themeStore);
2963
+ Object.keys(themeStore).forEach((key2) => {
2964
+ themeProp[key2] = `--${camelToKebabCase(key2)}-${salt}`;
2965
+ theme[key2] = `var(${themeProp[key2]})`;
2966
+ });
2967
+ const replace = () => replaceStyle(style, theme);
2968
+ connect(themeStore, replace);
2969
+ replace();
2970
+ (document.head || document.documentElement).append(style);
2971
+ return theme;
2972
+ }
2973
+ function updateTheme(theme, newThemeObj) {
2974
+ const store2 = getThemeStore(theme);
2975
+ updateStore(store2, newThemeObj);
2976
+ }
2977
+ const splitReg = /\$\d(?:<[^>]*>)?/;
2978
+ const matchReg = /\$(\d)(<([^>]*)>)?/g;
2979
+ const matchStrIndex = 3;
2980
+ function splice(rawValue, ...rest) {
2981
+ const templateArr = rawValue.split(splitReg);
2982
+ const values = [];
2983
+ let result;
2984
+ while (result = matchReg.exec(rawValue)) {
2985
+ const str = result[matchStrIndex];
2986
+ const index = Number(result[1]) - 1;
2987
+ const arg = rest[index];
2988
+ values.push(typeof arg === "string" ? arg : arg(str));
2989
+ }
2990
+ return html(templateArr, ...values);
2991
+ }
2992
+ const modules = new Set();
2993
+ const _I18n = class {
2994
+ constructor(options) {
2995
+ __privateAdd(this, _cacheCurrentKey);
2996
+ __privateAdd(this, _urlParamsLang);
2997
+ __privateAdd(this, _cacheLang);
2998
+ __privateAdd(this, _isMain);
2999
+ __privateAdd(this, _lang);
3000
+ this.cachePrefix = "gem-i18n";
3001
+ if (!options.resources[options.fallbackLanguage]) {
3002
+ throw new GemError("i18n: fallbackLanguage invalid");
3003
+ }
3004
+ this.store = createStore(this);
3005
+ Object.assign(this, options);
3006
+ let currentLanguage = __privateGet(this, _urlParamsLang, urlParamsLang_get) || this.currentLanguage || __privateGet(this, _cacheLang, cacheLang_get);
3007
+ const ele = document.querySelector(`[type*=${this.cachePrefix}]`);
3008
+ if (ele) {
3009
+ try {
3010
+ const prerenderData = JSON.parse(ele.textContent || "");
3011
+ currentLanguage = prerenderData.currentLanguage;
3012
+ this.resources[prerenderData.currentLanguage] = prerenderData.currentLanguagePack;
3013
+ } catch {
3014
+ }
3015
+ }
3016
+ if (currentLanguage) {
3017
+ __privateSet(this, _lang, currentLanguage, lang_set);
3018
+ this.setLanguage(currentLanguage);
3019
+ } else {
3020
+ this.resetLanguage();
3021
+ }
3022
+ }
3023
+ get(s, ...rest) {
3024
+ const currentLanguagePack = this.resources[this.currentLanguage];
3025
+ const fallbackLanguagePack = this.resources[this.fallbackLanguage];
3026
+ const msg = currentLanguagePack[s] || fallbackLanguagePack[s];
3027
+ const rawValue = (msg == null ? void 0 : msg.message) || msg || `[${s}]`;
3028
+ if (!rest.length)
3029
+ return rawValue;
3030
+ return splice(rawValue, ...rest);
3031
+ }
3032
+ detectLanguage() {
3033
+ const availableLangs = Object.keys(this.resources);
3034
+ const uiLangs = navigator.languages.map((lang) => lang.replace(/-(.*)/, ($1) => $1.toUpperCase()));
3035
+ for (const lang of uiLangs) {
3036
+ const matched = availableLangs.find((e) => e === lang || lang.startsWith(`${e}-`));
3037
+ if (matched)
3038
+ return matched;
3039
+ }
3040
+ return this.fallbackLanguage;
3041
+ }
3042
+ async setLanguage(lang) {
3043
+ if (__privateGet(this, _isMain, isMain_get)) {
3044
+ modules.forEach(async (i18n) => await i18n.setLanguage(lang));
3045
+ }
3046
+ let pack;
3047
+ const data = this.resources[lang];
3048
+ if (!data) {
3049
+ console.warn(`${this.cachePrefix}: not found \`${lang}\``);
3050
+ return this.resetLanguage();
3051
+ }
3052
+ if (typeof data === "string") {
3053
+ const prefix = `${this.cachePrefix}:`;
3054
+ const localKey = `${prefix}${data}`;
3055
+ const localPackString = localStorage.getItem(localKey);
3056
+ const fetchPack = async () => {
3057
+ const pack2 = await (await fetch(data)).json();
3058
+ if (this.cache) {
3059
+ for (let i = 0; i < localStorage.length; i++) {
3060
+ const key2 = localStorage.key(i);
3061
+ if (key2.startsWith(prefix)) {
3062
+ localStorage.removeItem(key2);
3063
+ }
3064
+ }
3065
+ localStorage.setItem(localKey, JSON.stringify(pack2));
3066
+ }
3067
+ return pack2;
3068
+ };
3069
+ if (localPackString) {
3070
+ try {
3071
+ pack = JSON.parse(localPackString);
3072
+ } catch (e) {
3073
+ pack = await fetchPack();
3074
+ }
3075
+ } else {
3076
+ pack = await fetchPack();
3077
+ }
3078
+ } else {
3079
+ pack = data;
3080
+ }
3081
+ this.resources[lang] = pack;
3082
+ updateStore(this.store, {});
3083
+ if (lang !== this.currentLanguage) {
3084
+ __privateSet(this, _lang, lang, lang_set);
3085
+ }
3086
+ if (this.cache === true) {
3087
+ this.setCache();
3088
+ }
3089
+ return lang;
3090
+ }
3091
+ resetLanguage() {
3092
+ if (__privateGet(this, _isMain, isMain_get)) {
3093
+ modules.forEach((i18n) => i18n.resetLanguage());
3094
+ }
3095
+ __privateSet(this, _lang, this.fallbackLanguage, lang_set);
3096
+ if (this.cache) {
3097
+ localStorage.removeItem(__privateGet(this, _cacheCurrentKey, cacheCurrentKey_get));
3098
+ }
3099
+ return this.setLanguage(this.detectLanguage());
3100
+ }
3101
+ setCache() {
3102
+ if (__privateGet(this, _isMain, isMain_get)) {
3103
+ modules.forEach((i18n) => i18n.setCache());
3104
+ }
3105
+ localStorage.setItem(__privateGet(this, _cacheCurrentKey, cacheCurrentKey_get), this.currentLanguage);
3106
+ }
3107
+ createSubModule(name, resources) {
3108
+ const module = new _I18n({
3109
+ resources,
3110
+ cachePrefix: `${this.cachePrefix}-${name}`,
3111
+ currentLanguage: this.currentLanguage,
3112
+ fallbackLanguage: this.fallbackLanguage,
3113
+ cache: this.cache
3114
+ });
3115
+ modules.add(module);
3116
+ return module;
3117
+ }
3118
+ toJSON() {
3119
+ return {
3120
+ currentLanguage: this.currentLanguage,
3121
+ currentLanguagePack: this.resources[this.currentLanguage]
3122
+ };
3123
+ }
3124
+ };
3125
+ let I18n = _I18n;
3126
+ _cacheCurrentKey = new WeakSet();
3127
+ cacheCurrentKey_get = function() {
3128
+ return `${this.cachePrefix}:current`;
3129
+ };
3130
+ _urlParamsLang = new WeakSet();
3131
+ urlParamsLang_get = function() {
3132
+ const { hostname, pathname, search } = location;
3133
+ const parts2 = hostname.split(".");
3134
+ switch (this.urlParamsType) {
3135
+ case "ccTLD":
3136
+ return parts2.pop();
3137
+ case "gTLD":
3138
+ return parts2.shift();
3139
+ case "path":
3140
+ return pathname.split("/")[1];
3141
+ default:
3142
+ const fragment = this.urlParamsName && new URLSearchParams(search).get(this.urlParamsName) || "";
3143
+ return fragment in this.resources ? fragment : "";
3144
+ }
3145
+ };
3146
+ _cacheLang = new WeakSet();
3147
+ cacheLang_get = function() {
3148
+ return this.cache && localStorage.getItem(__privateGet(this, _cacheCurrentKey, cacheCurrentKey_get)) || "";
3149
+ };
3150
+ _isMain = new WeakSet();
3151
+ isMain_get = function() {
3152
+ return !modules.has(this);
3153
+ };
3154
+ _lang = new WeakSet();
3155
+ lang_set = function(lang) {
3156
+ var _a2;
3157
+ if (__privateGet(this, _isMain, isMain_get)) {
3158
+ document.documentElement.lang = lang;
3159
+ }
3160
+ this.currentLanguage = lang;
3161
+ (_a2 = this.onChange) == null ? void 0 : _a2.call(this, lang);
3162
+ };
3163
+ const defaultReq = {
3164
+ credentials: "include",
3165
+ mode: "cors"
3166
+ };
3167
+ async function request(uri, options = {}) {
3168
+ const res = await fetch(uri, __spreadValues(__spreadValues({}, defaultReq), options));
3169
+ if (res.status === 0)
3170
+ throw new Error("Request fail");
3171
+ if (res.status >= 500)
3172
+ throw new Error(res.statusText);
3173
+ if (res.status >= 400)
3174
+ throw new Error(await res.text() || res.statusText);
3175
+ return await res.json();
3176
+ }
3177
+ const TypedArray = Object.getPrototypeOf(Object.getPrototypeOf(new Int8Array()));
3178
+ function serializationBody(body) {
3179
+ if (body instanceof FormData || body instanceof Blob || body instanceof TypedArray || body instanceof URLSearchParams || body instanceof ReadableStream || body instanceof ArrayBuffer) {
3180
+ return body;
3181
+ }
3182
+ if (typeof body === "object") {
3183
+ return JSON.stringify(body);
3184
+ }
3185
+ return body;
3186
+ }
3187
+ function get(url, params) {
3188
+ const { origin, pathname, search } = new URL(url, location.origin);
3189
+ const query = new URLSearchParams(params).toString();
3190
+ return request(`${origin}${pathname}${search ? `${search}&` : query ? "?" : ""}${query}`, {
3191
+ method: "GET"
3192
+ });
3193
+ }
3194
+ function del(url) {
3195
+ return request(url, { method: "DELETE" });
3196
+ }
3197
+ function put(url, body) {
3198
+ return request(url, { method: "PUT", body: serializationBody(body) });
3199
+ }
3200
+ function post(url, body) {
3201
+ return request(url, { method: "POST", body: serializationBody(body) });
3202
+ }
3203
+ const matche = (query) => window.matchMedia(query).matches;
3204
+ const mediaQuery = {
3205
+ PRINT: "print",
3206
+ get isPrint() {
3207
+ return matche(this.PRINT);
3208
+ },
3209
+ HOVER: "(hover: hover)",
3210
+ get isHover() {
3211
+ return matche(this.HOVER);
3212
+ },
3213
+ PHONE: "(min-width: 319px) and (max-width: 480px)",
3214
+ get isPhone() {
3215
+ return matche(this.PHONE);
3216
+ },
3217
+ LAPTOP: "(min-width: 1023px) and (max-width: 1280px) and (orientation: landscape)",
3218
+ get isLaptop() {
3219
+ return matche(this.LAPTOP);
3220
+ },
3221
+ DESKTOP: "(min-width: 1279px) and (orientation: landscape)",
3222
+ get isDesktop() {
3223
+ return matche(this.DESKTOP);
3224
+ },
3225
+ WIDTHSCREEN: "(min-width: 1919px) and (orientation: landscape)",
3226
+ get isWidthScreen() {
3227
+ return matche(this.WIDTHSCREEN);
3228
+ },
3229
+ PHONE_LANDSCAPE: "(min-width: 479px) and (max-width: 767px) and (orientation: landscape)",
3230
+ get isPhoneLandscape() {
3231
+ return matche(this.PHONE_LANDSCAPE);
3232
+ },
3233
+ TABLET: "(min-width: 768px) and (max-width: 1024px)",
3234
+ get isTablet() {
3235
+ return matche(this.TABLET);
3236
+ },
3237
+ SMALL_PHONE: "(min-width: 319px) and (max-width: 480px) and (max-height: 640px)",
3238
+ get isSmallPhone() {
3239
+ return matche(this.SMALL_PHONE);
3240
+ },
3241
+ WATCH: "(max-width: 319px)",
3242
+ get isWatch() {
3243
+ return matche(this.WATCH);
3244
+ },
3245
+ SHORT: "(min-width: 479px) and (max-height: 320px)",
3246
+ get isShort() {
3247
+ return matche(this.SHORT);
3248
+ },
3249
+ PWA: "(display-mode: standalone)",
3250
+ get isPWA() {
3251
+ return matche(this.PWA);
3252
+ },
3253
+ MOTION_REDUCE: "(prefers-reduced-motion: reduce)",
3254
+ get isMotionReduce() {
3255
+ return matche(this.MOTION_REDUCE);
3256
+ },
3257
+ DATA_REDUCE: "(prefers-reduced-data: reduce)",
3258
+ get isDataReduce() {
3259
+ return matche(this.DATA_REDUCE);
3260
+ }
3261
+ };
3262
+ const version = "1.6.5";
3263
+ if (window.__GEM_DEVTOOLS__HOOK__) {
3264
+ Object.assign(window.__GEM_DEVTOOLS__HOOK__, __spreadValues({}, Gem));
3265
+ }
3266
+ export { GemActiveLinkElement, GemDialogBaseElement, GemElement, GemError, GemLightRouteElement, GemLinkElement, GemReflectElement, GemRouteElement, GemTitleElement, GemUnsafeElement, GemUseElement, I18n, LinkedList, PropProxyMap, QueryString, SVGTemplateResult, SheetToken, StoreListenerMap, TemplateResult, absoluteLocation, addMicrotask, addMicrotaskToStack, adoptedStyle, attribute, basePathStore, boolattribute, camelToKebabCase, classMap, cleanObject, connect, connectStore, createCSSSheet, createHistoryParams, createModalClass, createPath, createStore, createStoreSet, createTheme, css, customElement, defineAttribute, defineCSSState, defineProperty, defineRef, del, directive, disconnect, emitter, exportPartsMap, get, getThemeProp, getThemeStore, globalemitter, guard, history, html, ifDefined, isArrayChange, kebabToCamelCase, matchPath, mediaQuery, nativeDefineElement, numattribute, objectMapToString, part, partMap, post, property, put, randomStr, raw, refobject, removeItems, render, repeat, request, rootElement, slot, splice, state, styleMap, styled, svg, titleStore, updateStore, updateTheme, useNativeCSSStyleSheet, version };