@helpdice/ui 2.6.0-beta.9 → 2.6.0

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.
@@ -2,8 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var Button = require('components/button');
6
- var react = require('react');
5
+ var React = require('react');
6
+ var theme = require('@helpdice/theme');
7
7
  var jsxRuntime = require('react/jsx-runtime');
8
8
 
9
9
  function _arrayLikeToArray(r, a) {
@@ -14,6 +14,62 @@ function _arrayLikeToArray(r, a) {
14
14
  function _arrayWithHoles(r) {
15
15
  if (Array.isArray(r)) return r;
16
16
  }
17
+ function _createForOfIteratorHelper(r, e) {
18
+ var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
19
+ if (!t) {
20
+ if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) {
21
+ t && (r = t);
22
+ var n = 0,
23
+ F = function () {};
24
+ return {
25
+ s: F,
26
+ n: function () {
27
+ return n >= r.length ? {
28
+ done: true
29
+ } : {
30
+ done: false,
31
+ value: r[n++]
32
+ };
33
+ },
34
+ e: function (r) {
35
+ throw r;
36
+ },
37
+ f: F
38
+ };
39
+ }
40
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
41
+ }
42
+ var o,
43
+ a = true,
44
+ u = false;
45
+ return {
46
+ s: function () {
47
+ t = t.call(r);
48
+ },
49
+ n: function () {
50
+ var r = t.next();
51
+ return a = r.done, r;
52
+ },
53
+ e: function (r) {
54
+ u = true, o = r;
55
+ },
56
+ f: function () {
57
+ try {
58
+ a || null == t.return || t.return();
59
+ } finally {
60
+ if (u) throw o;
61
+ }
62
+ }
63
+ };
64
+ }
65
+ function _defineProperty(e, r, t) {
66
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
67
+ value: t,
68
+ enumerable: true,
69
+ configurable: true,
70
+ writable: true
71
+ }) : e[r] = t, e;
72
+ }
17
73
  function _iterableToArrayLimit(r, l) {
18
74
  var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
19
75
  if (null != t) {
@@ -25,7 +81,10 @@ function _iterableToArrayLimit(r, l) {
25
81
  f = true,
26
82
  o = false;
27
83
  try {
28
- if (i = (t = t.call(r)).next, 0 === l) ; else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
84
+ if (i = (t = t.call(r)).next, 0 === l) {
85
+ if (Object(t) !== t) return;
86
+ f = !1;
87
+ } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
29
88
  } catch (r) {
30
89
  o = true, n = r;
31
90
  } finally {
@@ -41,9 +100,64 @@ function _iterableToArrayLimit(r, l) {
41
100
  function _nonIterableRest() {
42
101
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
43
102
  }
103
+ function ownKeys(e, r) {
104
+ var t = Object.keys(e);
105
+ if (Object.getOwnPropertySymbols) {
106
+ var o = Object.getOwnPropertySymbols(e);
107
+ r && (o = o.filter(function (r) {
108
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
109
+ })), t.push.apply(t, o);
110
+ }
111
+ return t;
112
+ }
113
+ function _objectSpread2(e) {
114
+ for (var r = 1; r < arguments.length; r++) {
115
+ var t = null != arguments[r] ? arguments[r] : {};
116
+ r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
117
+ _defineProperty(e, r, t[r]);
118
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
119
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
120
+ });
121
+ }
122
+ return e;
123
+ }
124
+ function _objectWithoutProperties(e, t) {
125
+ if (null == e) return {};
126
+ var o,
127
+ r,
128
+ i = _objectWithoutPropertiesLoose(e, t);
129
+ if (Object.getOwnPropertySymbols) {
130
+ var n = Object.getOwnPropertySymbols(e);
131
+ for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
132
+ }
133
+ return i;
134
+ }
135
+ function _objectWithoutPropertiesLoose(r, e) {
136
+ if (null == r) return {};
137
+ var t = {};
138
+ for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
139
+ if (-1 !== e.indexOf(n)) continue;
140
+ t[n] = r[n];
141
+ }
142
+ return t;
143
+ }
44
144
  function _slicedToArray(r, e) {
45
145
  return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
46
146
  }
147
+ function _toPrimitive(t, r) {
148
+ if ("object" != typeof t || !t) return t;
149
+ var e = t[Symbol.toPrimitive];
150
+ if (void 0 !== e) {
151
+ var i = e.call(t, r);
152
+ if ("object" != typeof i) return i;
153
+ throw new TypeError("@@toPrimitive must return a primitive value.");
154
+ }
155
+ return ("string" === r ? String : Number)(t);
156
+ }
157
+ function _toPropertyKey(t) {
158
+ var i = _toPrimitive(t, "string");
159
+ return "symbol" == typeof i ? i : i + "";
160
+ }
47
161
  function _unsupportedIterableToArray(r, a) {
48
162
  if (r) {
49
163
  if ("string" == typeof r) return _arrayLikeToArray(r, a);
@@ -52,6 +166,1378 @@ function _unsupportedIterableToArray(r, a) {
52
166
  }
53
167
  }
54
168
 
169
+ function getDefaultExportFromCjs (x) {
170
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
171
+ }
172
+
173
+ var index = {};
174
+
175
+ var hasRequiredIndex;
176
+
177
+ function requireIndex () {
178
+ if (hasRequiredIndex) return index;
179
+ hasRequiredIndex = 1;
180
+ var React$1 = React;
181
+
182
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
183
+
184
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React$1);
185
+
186
+ /*
187
+ Based on Glamor's sheet
188
+ https://github.com/threepointone/glamor/blob/667b480d31b3721a905021b26e1290ce92ca2879/src/sheet.js
189
+ */ function _defineProperties(target, props) {
190
+ for(var i = 0; i < props.length; i++){
191
+ var descriptor = props[i];
192
+ descriptor.enumerable = descriptor.enumerable || false;
193
+ descriptor.configurable = true;
194
+ if ("value" in descriptor) descriptor.writable = true;
195
+ Object.defineProperty(target, descriptor.key, descriptor);
196
+ }
197
+ }
198
+ function _createClass(Constructor, protoProps, staticProps) {
199
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
200
+ return Constructor;
201
+ }
202
+ var isProd = typeof process !== "undefined" && process.env && process.env.NODE_ENV === "production";
203
+ var isString = function(o) {
204
+ return Object.prototype.toString.call(o) === "[object String]";
205
+ };
206
+ var StyleSheet = /*#__PURE__*/ function() {
207
+ function StyleSheet(param) {
208
+ var ref = param === void 0 ? {} : param, _name = ref.name, name = _name === void 0 ? "stylesheet" : _name, _optimizeForSpeed = ref.optimizeForSpeed, optimizeForSpeed = _optimizeForSpeed === void 0 ? isProd : _optimizeForSpeed;
209
+ invariant$1(isString(name), "`name` must be a string");
210
+ this._name = name;
211
+ this._deletedRulePlaceholder = "#" + name + "-deleted-rule____{}";
212
+ invariant$1(typeof optimizeForSpeed === "boolean", "`optimizeForSpeed` must be a boolean");
213
+ this._optimizeForSpeed = optimizeForSpeed;
214
+ this._serverSheet = undefined;
215
+ this._tags = [];
216
+ this._injected = false;
217
+ this._rulesCount = 0;
218
+ var node = typeof window !== "undefined" && document.querySelector('meta[property="csp-nonce"]');
219
+ this._nonce = node ? node.getAttribute("content") : null;
220
+ }
221
+ var _proto = StyleSheet.prototype;
222
+ _proto.setOptimizeForSpeed = function setOptimizeForSpeed(bool) {
223
+ invariant$1(typeof bool === "boolean", "`setOptimizeForSpeed` accepts a boolean");
224
+ invariant$1(this._rulesCount === 0, "optimizeForSpeed cannot be when rules have already been inserted");
225
+ this.flush();
226
+ this._optimizeForSpeed = bool;
227
+ this.inject();
228
+ };
229
+ _proto.isOptimizeForSpeed = function isOptimizeForSpeed() {
230
+ return this._optimizeForSpeed;
231
+ };
232
+ _proto.inject = function inject() {
233
+ var _this = this;
234
+ invariant$1(!this._injected, "sheet already injected");
235
+ this._injected = true;
236
+ if (typeof window !== "undefined" && this._optimizeForSpeed) {
237
+ this._tags[0] = this.makeStyleTag(this._name);
238
+ this._optimizeForSpeed = "insertRule" in this.getSheet();
239
+ if (!this._optimizeForSpeed) {
240
+ if (!isProd) {
241
+ console.warn("StyleSheet: optimizeForSpeed mode not supported falling back to standard mode.");
242
+ }
243
+ this.flush();
244
+ this._injected = true;
245
+ }
246
+ return;
247
+ }
248
+ this._serverSheet = {
249
+ cssRules: [],
250
+ insertRule: function(rule, index) {
251
+ if (typeof index === "number") {
252
+ _this._serverSheet.cssRules[index] = {
253
+ cssText: rule
254
+ };
255
+ } else {
256
+ _this._serverSheet.cssRules.push({
257
+ cssText: rule
258
+ });
259
+ }
260
+ return index;
261
+ },
262
+ deleteRule: function(index) {
263
+ _this._serverSheet.cssRules[index] = null;
264
+ }
265
+ };
266
+ };
267
+ _proto.getSheetForTag = function getSheetForTag(tag) {
268
+ if (tag.sheet) {
269
+ return tag.sheet;
270
+ }
271
+ // this weirdness brought to you by firefox
272
+ for(var i = 0; i < document.styleSheets.length; i++){
273
+ if (document.styleSheets[i].ownerNode === tag) {
274
+ return document.styleSheets[i];
275
+ }
276
+ }
277
+ };
278
+ _proto.getSheet = function getSheet() {
279
+ return this.getSheetForTag(this._tags[this._tags.length - 1]);
280
+ };
281
+ _proto.insertRule = function insertRule(rule, index) {
282
+ invariant$1(isString(rule), "`insertRule` accepts only strings");
283
+ if (typeof window === "undefined") {
284
+ if (typeof index !== "number") {
285
+ index = this._serverSheet.cssRules.length;
286
+ }
287
+ this._serverSheet.insertRule(rule, index);
288
+ return this._rulesCount++;
289
+ }
290
+ if (this._optimizeForSpeed) {
291
+ var sheet = this.getSheet();
292
+ if (typeof index !== "number") {
293
+ index = sheet.cssRules.length;
294
+ }
295
+ // this weirdness for perf, and chrome's weird bug
296
+ // https://stackoverflow.com/questions/20007992/chrome-suddenly-stopped-accepting-insertrule
297
+ try {
298
+ sheet.insertRule(rule, index);
299
+ } catch (error) {
300
+ if (!isProd) {
301
+ console.warn("StyleSheet: illegal rule: \n\n" + rule + "\n\nSee https://stackoverflow.com/q/20007992 for more info");
302
+ }
303
+ return -1;
304
+ }
305
+ } else {
306
+ var insertionPoint = this._tags[index];
307
+ this._tags.push(this.makeStyleTag(this._name, rule, insertionPoint));
308
+ }
309
+ return this._rulesCount++;
310
+ };
311
+ _proto.replaceRule = function replaceRule(index, rule) {
312
+ if (this._optimizeForSpeed || typeof window === "undefined") {
313
+ var sheet = typeof window !== "undefined" ? this.getSheet() : this._serverSheet;
314
+ if (!rule.trim()) {
315
+ rule = this._deletedRulePlaceholder;
316
+ }
317
+ if (!sheet.cssRules[index]) {
318
+ // @TBD Should we throw an error?
319
+ return index;
320
+ }
321
+ sheet.deleteRule(index);
322
+ try {
323
+ sheet.insertRule(rule, index);
324
+ } catch (error) {
325
+ if (!isProd) {
326
+ console.warn("StyleSheet: illegal rule: \n\n" + rule + "\n\nSee https://stackoverflow.com/q/20007992 for more info");
327
+ }
328
+ // In order to preserve the indices we insert a deleteRulePlaceholder
329
+ sheet.insertRule(this._deletedRulePlaceholder, index);
330
+ }
331
+ } else {
332
+ var tag = this._tags[index];
333
+ invariant$1(tag, "old rule at index `" + index + "` not found");
334
+ tag.textContent = rule;
335
+ }
336
+ return index;
337
+ };
338
+ _proto.deleteRule = function deleteRule(index) {
339
+ if (typeof window === "undefined") {
340
+ this._serverSheet.deleteRule(index);
341
+ return;
342
+ }
343
+ if (this._optimizeForSpeed) {
344
+ this.replaceRule(index, "");
345
+ } else {
346
+ var tag = this._tags[index];
347
+ invariant$1(tag, "rule at index `" + index + "` not found");
348
+ tag.parentNode.removeChild(tag);
349
+ this._tags[index] = null;
350
+ }
351
+ };
352
+ _proto.flush = function flush() {
353
+ this._injected = false;
354
+ this._rulesCount = 0;
355
+ if (typeof window !== "undefined") {
356
+ this._tags.forEach(function(tag) {
357
+ return tag && tag.parentNode.removeChild(tag);
358
+ });
359
+ this._tags = [];
360
+ } else {
361
+ // simpler on server
362
+ this._serverSheet.cssRules = [];
363
+ }
364
+ };
365
+ _proto.cssRules = function cssRules() {
366
+ var _this = this;
367
+ if (typeof window === "undefined") {
368
+ return this._serverSheet.cssRules;
369
+ }
370
+ return this._tags.reduce(function(rules, tag) {
371
+ if (tag) {
372
+ rules = rules.concat(Array.prototype.map.call(_this.getSheetForTag(tag).cssRules, function(rule) {
373
+ return rule.cssText === _this._deletedRulePlaceholder ? null : rule;
374
+ }));
375
+ } else {
376
+ rules.push(null);
377
+ }
378
+ return rules;
379
+ }, []);
380
+ };
381
+ _proto.makeStyleTag = function makeStyleTag(name, cssString, relativeToTag) {
382
+ if (cssString) {
383
+ invariant$1(isString(cssString), "makeStyleTag accepts only strings as second parameter");
384
+ }
385
+ var tag = document.createElement("style");
386
+ if (this._nonce) tag.setAttribute("nonce", this._nonce);
387
+ tag.type = "text/css";
388
+ tag.setAttribute("data-" + name, "");
389
+ if (cssString) {
390
+ tag.appendChild(document.createTextNode(cssString));
391
+ }
392
+ var head = document.head || document.getElementsByTagName("head")[0];
393
+ if (relativeToTag) {
394
+ head.insertBefore(tag, relativeToTag);
395
+ } else {
396
+ head.appendChild(tag);
397
+ }
398
+ return tag;
399
+ };
400
+ _createClass(StyleSheet, [
401
+ {
402
+ key: "length",
403
+ get: function get() {
404
+ return this._rulesCount;
405
+ }
406
+ }
407
+ ]);
408
+ return StyleSheet;
409
+ }();
410
+ function invariant$1(condition, message) {
411
+ if (!condition) {
412
+ throw new Error("StyleSheet: " + message + ".");
413
+ }
414
+ }
415
+
416
+ function hash(str) {
417
+ var _$hash = 5381, i = str.length;
418
+ while(i){
419
+ _$hash = _$hash * 33 ^ str.charCodeAt(--i);
420
+ }
421
+ /* JavaScript does bitwise operations (like XOR, above) on 32-bit signed
422
+ * integers. Since we want the results to be always positive, convert the
423
+ * signed int to an unsigned by doing an unsigned bitshift. */ return _$hash >>> 0;
424
+ }
425
+ var stringHash = hash;
426
+
427
+ var sanitize = function(rule) {
428
+ return rule.replace(/\/style/gi, "\\/style");
429
+ };
430
+ var cache = {};
431
+ /**
432
+ * computeId
433
+ *
434
+ * Compute and memoize a jsx id from a basedId and optionally props.
435
+ */ function computeId(baseId, props) {
436
+ if (!props) {
437
+ return "jsx-" + baseId;
438
+ }
439
+ var propsToString = String(props);
440
+ var key = baseId + propsToString;
441
+ if (!cache[key]) {
442
+ cache[key] = "jsx-" + stringHash(baseId + "-" + propsToString);
443
+ }
444
+ return cache[key];
445
+ }
446
+ /**
447
+ * computeSelector
448
+ *
449
+ * Compute and memoize dynamic selectors.
450
+ */ function computeSelector(id, css) {
451
+ var selectoPlaceholderRegexp = /__jsx-style-dynamic-selector/g;
452
+ // Sanitize SSR-ed CSS.
453
+ // Client side code doesn't need to be sanitized since we use
454
+ // document.createTextNode (dev) and the CSSOM api sheet.insertRule (prod).
455
+ if (typeof window === "undefined") {
456
+ css = sanitize(css);
457
+ }
458
+ var idcss = id + css;
459
+ if (!cache[idcss]) {
460
+ cache[idcss] = css.replace(selectoPlaceholderRegexp, id);
461
+ }
462
+ return cache[idcss];
463
+ }
464
+
465
+ function mapRulesToStyle(cssRules, options) {
466
+ if (options === void 0) options = {};
467
+ return cssRules.map(function(args) {
468
+ var id = args[0];
469
+ var css = args[1];
470
+ return /*#__PURE__*/ React__default["default"].createElement("style", {
471
+ id: "__" + id,
472
+ // Avoid warnings upon render with a key
473
+ key: "__" + id,
474
+ nonce: options.nonce ? options.nonce : undefined,
475
+ dangerouslySetInnerHTML: {
476
+ __html: css
477
+ }
478
+ });
479
+ });
480
+ }
481
+ var StyleSheetRegistry = /*#__PURE__*/ function() {
482
+ function StyleSheetRegistry(param) {
483
+ var ref = param === void 0 ? {} : param, _styleSheet = ref.styleSheet, styleSheet = _styleSheet === void 0 ? null : _styleSheet, _optimizeForSpeed = ref.optimizeForSpeed, optimizeForSpeed = _optimizeForSpeed === void 0 ? false : _optimizeForSpeed;
484
+ this._sheet = styleSheet || new StyleSheet({
485
+ name: "styled-jsx",
486
+ optimizeForSpeed: optimizeForSpeed
487
+ });
488
+ this._sheet.inject();
489
+ if (styleSheet && typeof optimizeForSpeed === "boolean") {
490
+ this._sheet.setOptimizeForSpeed(optimizeForSpeed);
491
+ this._optimizeForSpeed = this._sheet.isOptimizeForSpeed();
492
+ }
493
+ this._fromServer = undefined;
494
+ this._indices = {};
495
+ this._instancesCounts = {};
496
+ }
497
+ var _proto = StyleSheetRegistry.prototype;
498
+ _proto.add = function add(props) {
499
+ var _this = this;
500
+ if (undefined === this._optimizeForSpeed) {
501
+ this._optimizeForSpeed = Array.isArray(props.children);
502
+ this._sheet.setOptimizeForSpeed(this._optimizeForSpeed);
503
+ this._optimizeForSpeed = this._sheet.isOptimizeForSpeed();
504
+ }
505
+ if (typeof window !== "undefined" && !this._fromServer) {
506
+ this._fromServer = this.selectFromServer();
507
+ this._instancesCounts = Object.keys(this._fromServer).reduce(function(acc, tagName) {
508
+ acc[tagName] = 0;
509
+ return acc;
510
+ }, {});
511
+ }
512
+ var ref = this.getIdAndRules(props), styleId = ref.styleId, rules = ref.rules;
513
+ // Deduping: just increase the instances count.
514
+ if (styleId in this._instancesCounts) {
515
+ this._instancesCounts[styleId] += 1;
516
+ return;
517
+ }
518
+ var indices = rules.map(function(rule) {
519
+ return _this._sheet.insertRule(rule);
520
+ })// Filter out invalid rules
521
+ .filter(function(index) {
522
+ return index !== -1;
523
+ });
524
+ this._indices[styleId] = indices;
525
+ this._instancesCounts[styleId] = 1;
526
+ };
527
+ _proto.remove = function remove(props) {
528
+ var _this = this;
529
+ var styleId = this.getIdAndRules(props).styleId;
530
+ invariant(styleId in this._instancesCounts, "styleId: `" + styleId + "` not found");
531
+ this._instancesCounts[styleId] -= 1;
532
+ if (this._instancesCounts[styleId] < 1) {
533
+ var tagFromServer = this._fromServer && this._fromServer[styleId];
534
+ if (tagFromServer) {
535
+ tagFromServer.parentNode.removeChild(tagFromServer);
536
+ delete this._fromServer[styleId];
537
+ } else {
538
+ this._indices[styleId].forEach(function(index) {
539
+ return _this._sheet.deleteRule(index);
540
+ });
541
+ delete this._indices[styleId];
542
+ }
543
+ delete this._instancesCounts[styleId];
544
+ }
545
+ };
546
+ _proto.update = function update(props, nextProps) {
547
+ this.add(nextProps);
548
+ this.remove(props);
549
+ };
550
+ _proto.flush = function flush() {
551
+ this._sheet.flush();
552
+ this._sheet.inject();
553
+ this._fromServer = undefined;
554
+ this._indices = {};
555
+ this._instancesCounts = {};
556
+ };
557
+ _proto.cssRules = function cssRules() {
558
+ var _this = this;
559
+ var fromServer = this._fromServer ? Object.keys(this._fromServer).map(function(styleId) {
560
+ return [
561
+ styleId,
562
+ _this._fromServer[styleId]
563
+ ];
564
+ }) : [];
565
+ var cssRules = this._sheet.cssRules();
566
+ return fromServer.concat(Object.keys(this._indices).map(function(styleId) {
567
+ return [
568
+ styleId,
569
+ _this._indices[styleId].map(function(index) {
570
+ return cssRules[index].cssText;
571
+ }).join(_this._optimizeForSpeed ? "" : "\n")
572
+ ];
573
+ })// filter out empty rules
574
+ .filter(function(rule) {
575
+ return Boolean(rule[1]);
576
+ }));
577
+ };
578
+ _proto.styles = function styles(options) {
579
+ return mapRulesToStyle(this.cssRules(), options);
580
+ };
581
+ _proto.getIdAndRules = function getIdAndRules(props) {
582
+ var css = props.children, dynamic = props.dynamic, id = props.id;
583
+ if (dynamic) {
584
+ var styleId = computeId(id, dynamic);
585
+ return {
586
+ styleId: styleId,
587
+ rules: Array.isArray(css) ? css.map(function(rule) {
588
+ return computeSelector(styleId, rule);
589
+ }) : [
590
+ computeSelector(styleId, css)
591
+ ]
592
+ };
593
+ }
594
+ return {
595
+ styleId: computeId(id),
596
+ rules: Array.isArray(css) ? css : [
597
+ css
598
+ ]
599
+ };
600
+ };
601
+ /**
602
+ * selectFromServer
603
+ *
604
+ * Collects style tags from the document with id __jsx-XXX
605
+ */ _proto.selectFromServer = function selectFromServer() {
606
+ var elements = Array.prototype.slice.call(document.querySelectorAll('[id^="__jsx-"]'));
607
+ return elements.reduce(function(acc, element) {
608
+ var id = element.id.slice(2);
609
+ acc[id] = element;
610
+ return acc;
611
+ }, {});
612
+ };
613
+ return StyleSheetRegistry;
614
+ }();
615
+ function invariant(condition, message) {
616
+ if (!condition) {
617
+ throw new Error("StyleSheetRegistry: " + message + ".");
618
+ }
619
+ }
620
+ var StyleSheetContext = /*#__PURE__*/ React$1.createContext(null);
621
+ StyleSheetContext.displayName = "StyleSheetContext";
622
+ function createStyleRegistry() {
623
+ return new StyleSheetRegistry();
624
+ }
625
+ function StyleRegistry(param) {
626
+ var configuredRegistry = param.registry, children = param.children;
627
+ var rootRegistry = React$1.useContext(StyleSheetContext);
628
+ var ref = React$1.useState(function() {
629
+ return rootRegistry || configuredRegistry || createStyleRegistry();
630
+ }), registry = ref[0];
631
+ return /*#__PURE__*/ React__default["default"].createElement(StyleSheetContext.Provider, {
632
+ value: registry
633
+ }, children);
634
+ }
635
+ function useStyleRegistry() {
636
+ return React$1.useContext(StyleSheetContext);
637
+ }
638
+
639
+ // Opt-into the new `useInsertionEffect` API in React 18, fallback to `useLayoutEffect`.
640
+ // https://github.com/reactwg/react-18/discussions/110
641
+ var useInsertionEffect = React__default["default"].useInsertionEffect || React$1.useLayoutEffect;
642
+ var defaultRegistry = typeof window !== "undefined" ? createStyleRegistry() : undefined;
643
+ function JSXStyle(props) {
644
+ var registry = defaultRegistry ? defaultRegistry : useStyleRegistry();
645
+ var insertionEffectCalled = React$1.useRef(false);
646
+ // `registry` might not exist while server-side rendering
647
+ if (!registry) {
648
+ return null;
649
+ }
650
+ if (typeof window === "undefined") {
651
+ registry.add(props);
652
+ return null;
653
+ }
654
+ useInsertionEffect(function() {
655
+ // ReactDOM removes all DOM during hydration in certain cases
656
+ if (!document.head) {
657
+ return;
658
+ }
659
+ registry.add(props);
660
+ insertionEffectCalled.current = true;
661
+ return function() {
662
+ insertionEffectCalled.current = false;
663
+ registry.remove(props);
664
+ };
665
+ }, [
666
+ props.id,
667
+ String(props.dynamic)
668
+ ]);
669
+ React$1.useLayoutEffect(function() {
670
+ if (!document.head || insertionEffectCalled.current) {
671
+ return;
672
+ }
673
+ registry.add(props);
674
+ return function() {
675
+ registry.remove(props);
676
+ };
677
+ // props.children can be string[], will be striped since id is identical
678
+ }, [
679
+ props.id,
680
+ String(props.dynamic)
681
+ ]);
682
+ return null;
683
+ }
684
+ JSXStyle.dynamic = function(info) {
685
+ return info.map(function(tagInfo) {
686
+ var baseId = tagInfo[0];
687
+ var props = tagInfo[1];
688
+ return computeId(baseId, props);
689
+ }).join(" ");
690
+ };
691
+
692
+ index.StyleRegistry = StyleRegistry;
693
+ index.createStyleRegistry = createStyleRegistry;
694
+ index.style = JSXStyle;
695
+ index.useStyleRegistry = useStyleRegistry;
696
+ return index;
697
+ }
698
+
699
+ var style;
700
+ var hasRequiredStyle;
701
+
702
+ function requireStyle () {
703
+ if (hasRequiredStyle) return style;
704
+ hasRequiredStyle = 1;
705
+ style = requireIndex().style;
706
+ return style;
707
+ }
708
+
709
+ var styleExports = requireStyle();
710
+ var _JSXStyle = /*@__PURE__*/getDefaultExportFromCjs(styleExports);
711
+
712
+ /* "use client" */
713
+
714
+ var ScalePropKeys = ['width', 'height', 'padding', 'margin', 'w', 'h', 'paddingLeft', 'paddingRight', 'paddingTop', 'paddingBottom', 'pl', 'pr', 'pt', 'pb', 'marginLeft', 'marginRight', 'marginTop', 'marginBottom', 'ml', 'mr', 'mt', 'mb', 'px', 'py', 'mx', 'my', 'font', 'unit', 'scale'];
715
+ var defaultDynamicLayoutPipe = function defaultDynamicLayoutPipe(scale1x) {
716
+ return "".concat(scale1x);
717
+ };
718
+ var defaultContext$1 = {
719
+ getScaleProps: function getScaleProps() {
720
+ return undefined;
721
+ },
722
+ getAllScaleProps: function getAllScaleProps() {
723
+ return {};
724
+ },
725
+ SCALES: {
726
+ pl: defaultDynamicLayoutPipe,
727
+ pr: defaultDynamicLayoutPipe,
728
+ pb: defaultDynamicLayoutPipe,
729
+ pt: defaultDynamicLayoutPipe,
730
+ px: defaultDynamicLayoutPipe,
731
+ py: defaultDynamicLayoutPipe,
732
+ mb: defaultDynamicLayoutPipe,
733
+ ml: defaultDynamicLayoutPipe,
734
+ mr: defaultDynamicLayoutPipe,
735
+ mt: defaultDynamicLayoutPipe,
736
+ mx: defaultDynamicLayoutPipe,
737
+ my: defaultDynamicLayoutPipe,
738
+ width: defaultDynamicLayoutPipe,
739
+ height: defaultDynamicLayoutPipe,
740
+ font: defaultDynamicLayoutPipe
741
+ },
742
+ unit: '16px'
743
+ };
744
+ var ScaleContext = /*#__PURE__*/React.createContext(defaultContext$1);
745
+ var useScale = function useScale() {
746
+ return React.useContext(ScaleContext);
747
+ };
748
+
749
+ /* "use client" */
750
+
751
+ var isCSSNumberValue = function isCSSNumberValue(value) {
752
+ return value !== undefined && !Number.isNaN(+value);
753
+ };
754
+
755
+ var generateGetScaleProps = function generateGetScaleProps(props) {
756
+ var getScaleProps = function getScaleProps(keyOrKeys) {
757
+ if (!Array.isArray(keyOrKeys)) return props[keyOrKeys];
758
+ var value = undefined;
759
+ var _iterator = _createForOfIteratorHelper(keyOrKeys),
760
+ _step;
761
+ try {
762
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
763
+ var key = _step.value;
764
+ var currentValue = props[key];
765
+ if (typeof currentValue !== 'undefined') {
766
+ value = currentValue;
767
+ }
768
+ }
769
+ } catch (err) {
770
+ _iterator.e(err);
771
+ } finally {
772
+ _iterator.f();
773
+ }
774
+ return value;
775
+ };
776
+ return getScaleProps;
777
+ };
778
+ var generateGetAllScaleProps = function generateGetAllScaleProps(props) {
779
+ var getAllScaleProps = function getAllScaleProps() {
780
+ var scaleProps = {};
781
+ var _iterator2 = _createForOfIteratorHelper(ScalePropKeys),
782
+ _step2;
783
+ try {
784
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
785
+ var key = _step2.value;
786
+ var value = props[key];
787
+ if (typeof value !== 'undefined') {
788
+ scaleProps[key] = value;
789
+ }
790
+ }
791
+ } catch (err) {
792
+ _iterator2.e(err);
793
+ } finally {
794
+ _iterator2.f();
795
+ }
796
+ return scaleProps;
797
+ };
798
+ return getAllScaleProps;
799
+ };
800
+
801
+ var _excluded$3 = ["children"];
802
+ var reduceScaleCoefficient = function reduceScaleCoefficient(scale) {
803
+ if (scale === 1) return scale;
804
+ var diff = Math.abs((scale - 1) / 2);
805
+ return scale > 1 ? 1 + diff : 1 - diff;
806
+ };
807
+ var withScale = function withScale(Render) {
808
+ var ScaleFC = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
809
+ var _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9, _ref0, _ref1, _ref10, _ref11, _ref12, _ref13, _ref14, _ref15, _ref16, _ref17, _ref18, _ref19, _ref20, _ref21, _ref22, _ref23, _ref24, _ref25, _ref26, _ref27, _ref28, _ref29, _ref30, _ref31;
810
+ var children = _ref.children,
811
+ props = _objectWithoutProperties(_ref, _excluded$3);
812
+ var _useTheme = theme.useTheme(),
813
+ layout = _useTheme.layout;
814
+ var paddingLeft = props.paddingLeft,
815
+ pl = props.pl,
816
+ paddingRight = props.paddingRight,
817
+ pr = props.pr,
818
+ paddingTop = props.paddingTop,
819
+ pt = props.pt,
820
+ paddingBottom = props.paddingBottom,
821
+ pb = props.pb,
822
+ marginTop = props.marginTop,
823
+ mt = props.mt,
824
+ marginRight = props.marginRight,
825
+ mr = props.mr,
826
+ marginBottom = props.marginBottom,
827
+ mb = props.mb,
828
+ marginLeft = props.marginLeft,
829
+ ml = props.ml,
830
+ px = props.px,
831
+ py = props.py,
832
+ mx = props.mx,
833
+ my = props.my,
834
+ width = props.width,
835
+ height = props.height,
836
+ font = props.font,
837
+ w = props.w,
838
+ h = props.h,
839
+ margin = props.margin,
840
+ padding = props.padding,
841
+ _props$unit = props.unit,
842
+ unit = _props$unit === void 0 ? layout.unit : _props$unit,
843
+ _props$scale = props.scale,
844
+ scale = _props$scale === void 0 ? 1 : _props$scale;
845
+ var makeScaleHandler = function makeScaleHandler(attrValue) {
846
+ return function (scale1x, defaultValue) {
847
+ // 0 means disable scale and the default value is 0
848
+ if (scale1x === 0) {
849
+ scale1x = 1;
850
+ defaultValue = defaultValue || 0;
851
+ }
852
+ var factor = reduceScaleCoefficient(scale) * scale1x;
853
+ if (typeof attrValue === 'undefined') {
854
+ if (typeof defaultValue !== 'undefined') return "".concat(defaultValue);
855
+ return "calc(".concat(factor, " * ").concat(unit, ")");
856
+ }
857
+ if (!isCSSNumberValue(attrValue)) return "".concat(attrValue);
858
+ var customFactor = factor * Number(attrValue);
859
+ return "calc(".concat(customFactor, " * ").concat(unit, ")");
860
+ };
861
+ };
862
+ var value = {
863
+ unit: unit,
864
+ SCALES: {
865
+ pt: makeScaleHandler((_ref2 = (_ref3 = paddingTop !== null && paddingTop !== void 0 ? paddingTop : pt) !== null && _ref3 !== void 0 ? _ref3 : py) !== null && _ref2 !== void 0 ? _ref2 : padding),
866
+ pr: makeScaleHandler((_ref4 = (_ref5 = paddingRight !== null && paddingRight !== void 0 ? paddingRight : pr) !== null && _ref5 !== void 0 ? _ref5 : px) !== null && _ref4 !== void 0 ? _ref4 : padding),
867
+ pb: makeScaleHandler((_ref6 = (_ref7 = paddingBottom !== null && paddingBottom !== void 0 ? paddingBottom : pb) !== null && _ref7 !== void 0 ? _ref7 : py) !== null && _ref6 !== void 0 ? _ref6 : padding),
868
+ pl: makeScaleHandler((_ref8 = (_ref9 = paddingLeft !== null && paddingLeft !== void 0 ? paddingLeft : pl) !== null && _ref9 !== void 0 ? _ref9 : px) !== null && _ref8 !== void 0 ? _ref8 : padding),
869
+ px: makeScaleHandler((_ref0 = (_ref1 = (_ref10 = (_ref11 = px !== null && px !== void 0 ? px : paddingLeft) !== null && _ref11 !== void 0 ? _ref11 : paddingRight) !== null && _ref10 !== void 0 ? _ref10 : pl) !== null && _ref1 !== void 0 ? _ref1 : pr) !== null && _ref0 !== void 0 ? _ref0 : padding),
870
+ py: makeScaleHandler((_ref12 = (_ref13 = (_ref14 = (_ref15 = py !== null && py !== void 0 ? py : paddingTop) !== null && _ref15 !== void 0 ? _ref15 : paddingBottom) !== null && _ref14 !== void 0 ? _ref14 : pt) !== null && _ref13 !== void 0 ? _ref13 : pb) !== null && _ref12 !== void 0 ? _ref12 : padding),
871
+ mt: makeScaleHandler((_ref16 = (_ref17 = marginTop !== null && marginTop !== void 0 ? marginTop : mt) !== null && _ref17 !== void 0 ? _ref17 : my) !== null && _ref16 !== void 0 ? _ref16 : margin),
872
+ mr: makeScaleHandler((_ref18 = (_ref19 = marginRight !== null && marginRight !== void 0 ? marginRight : mr) !== null && _ref19 !== void 0 ? _ref19 : mx) !== null && _ref18 !== void 0 ? _ref18 : margin),
873
+ mb: makeScaleHandler((_ref20 = (_ref21 = marginBottom !== null && marginBottom !== void 0 ? marginBottom : mb) !== null && _ref21 !== void 0 ? _ref21 : my) !== null && _ref20 !== void 0 ? _ref20 : margin),
874
+ ml: makeScaleHandler((_ref22 = (_ref23 = marginLeft !== null && marginLeft !== void 0 ? marginLeft : ml) !== null && _ref23 !== void 0 ? _ref23 : mx) !== null && _ref22 !== void 0 ? _ref22 : margin),
875
+ mx: makeScaleHandler((_ref24 = (_ref25 = (_ref26 = (_ref27 = mx !== null && mx !== void 0 ? mx : marginLeft) !== null && _ref27 !== void 0 ? _ref27 : marginRight) !== null && _ref26 !== void 0 ? _ref26 : ml) !== null && _ref25 !== void 0 ? _ref25 : mr) !== null && _ref24 !== void 0 ? _ref24 : margin),
876
+ my: makeScaleHandler((_ref28 = (_ref29 = (_ref30 = (_ref31 = my !== null && my !== void 0 ? my : marginTop) !== null && _ref31 !== void 0 ? _ref31 : marginBottom) !== null && _ref30 !== void 0 ? _ref30 : mt) !== null && _ref29 !== void 0 ? _ref29 : mb) !== null && _ref28 !== void 0 ? _ref28 : margin),
877
+ width: makeScaleHandler(width !== null && width !== void 0 ? width : w),
878
+ height: makeScaleHandler(height !== null && height !== void 0 ? height : h),
879
+ font: makeScaleHandler(font)
880
+ },
881
+ getScaleProps: generateGetScaleProps(props),
882
+ getAllScaleProps: generateGetAllScaleProps(props)
883
+ };
884
+ return /*#__PURE__*/jsxRuntime.jsx(ScaleContext.Provider, {
885
+ value: value,
886
+ children: /*#__PURE__*/jsxRuntime.jsx(Render, _objectSpread2(_objectSpread2({}, props), {}, {
887
+ ref: ref,
888
+ children: children
889
+ }))
890
+ });
891
+ });
892
+ ScaleFC.displayName = "Scale".concat(Render.displayName || 'Wrapper');
893
+ return ScaleFC;
894
+ };
895
+
896
+ var ButtonDrip = function ButtonDrip(_ref) {
897
+ var _ref$x = _ref.x,
898
+ x = _ref$x === void 0 ? 0 : _ref$x,
899
+ _ref$y = _ref.y,
900
+ y = _ref$y === void 0 ? 0 : _ref$y,
901
+ color = _ref.color,
902
+ onCompleted = _ref.onCompleted;
903
+ var dripRef = React.useRef(null);
904
+ /* istanbul ignore next */
905
+ var top = Number.isNaN(+y) ? 0 : y - 10;
906
+ /* istanbul ignore next */
907
+ var left = Number.isNaN(+x) ? 0 : x - 10;
908
+ React.useEffect(function () {
909
+ /* istanbul ignore next */
910
+ if (!dripRef.current) return;
911
+ dripRef.current.addEventListener('animationend', onCompleted);
912
+ return function () {
913
+ /* istanbul ignore next */
914
+ if (!dripRef.current) return;
915
+ dripRef.current.removeEventListener('animationend', onCompleted);
916
+ };
917
+ });
918
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
919
+ ref: dripRef,
920
+ className: "jsx-3424889537" + " " + "drip",
921
+ children: [/*#__PURE__*/jsxRuntime.jsx("svg", {
922
+ width: "20",
923
+ height: "20",
924
+ viewBox: "0 0 20 20",
925
+ style: {
926
+ top: top,
927
+ left: left
928
+ },
929
+ className: "jsx-3424889537",
930
+ children: /*#__PURE__*/jsxRuntime.jsx("g", {
931
+ stroke: "none",
932
+ strokeWidth: "1",
933
+ fill: "none",
934
+ fillRule: "evenodd",
935
+ className: "jsx-3424889537",
936
+ children: /*#__PURE__*/jsxRuntime.jsx("g", {
937
+ fill: color,
938
+ className: "jsx-3424889537",
939
+ children: /*#__PURE__*/jsxRuntime.jsx("rect", {
940
+ width: "100%",
941
+ height: "100%",
942
+ rx: "10",
943
+ className: "jsx-3424889537"
944
+ })
945
+ })
946
+ })
947
+ }), /*#__PURE__*/jsxRuntime.jsx(_JSXStyle, {
948
+ id: "3424889537",
949
+ children: ".drip.jsx-3424889537{position:absolute;left:0;right:0;top:0;bottom:0;}svg.jsx-3424889537{position:absolute;-webkit-animation:350ms ease-in expand-jsx-3424889537;animation:350ms ease-in expand-jsx-3424889537;-webkit-animation-fill-mode:forwards;animation-fill-mode:forwards;width:1rem;height:1rem;}@-webkit-keyframes expand-jsx-3424889537{0%{opacity:0;-webkit-transform:scale(1);-ms-transform:scale(1);transform:scale(1);}30%{opacity:1;}80%{opacity:0.5;}100%{-webkit-transform:scale(28);-ms-transform:scale(28);transform:scale(28);opacity:0;}}@keyframes expand-jsx-3424889537{0%{opacity:0;-webkit-transform:scale(1);-ms-transform:scale(1);transform:scale(1);}30%{opacity:1;}80%{opacity:0.5;}100%{-webkit-transform:scale(28);-ms-transform:scale(28);transform:scale(28);opacity:0;}}"
950
+ })]
951
+ });
952
+ };
953
+ ButtonDrip.displayName = 'ButtonDrip';
954
+
955
+ var _excluded$2 = ["children", "type", "color", "className", "spaceRatio"];
956
+ var getIconBgColor = function getIconBgColor(type, palette, color) {
957
+ var colors = {
958
+ "default": palette.accents_6,
959
+ secondary: palette.secondary,
960
+ success: palette.success,
961
+ warning: palette.warning,
962
+ error: palette.error
963
+ };
964
+ return color ? color : colors[type];
965
+ };
966
+ var LoadingComponent = function LoadingComponent(_ref) {
967
+ var children = _ref.children,
968
+ _ref$type = _ref.type,
969
+ type = _ref$type === void 0 ? 'default' : _ref$type,
970
+ color = _ref.color,
971
+ _ref$className = _ref.className,
972
+ className = _ref$className === void 0 ? '' : _ref$className,
973
+ _ref$spaceRatio = _ref.spaceRatio,
974
+ spaceRatio = _ref$spaceRatio === void 0 ? 1 : _ref$spaceRatio,
975
+ props = _objectWithoutProperties(_ref, _excluded$2);
976
+ var theme$1 = theme.useTheme();
977
+ var _useScale = useScale(),
978
+ SCALES = _useScale.SCALES;
979
+ var classes = theme.useClasses('loading-container', className);
980
+ var bgColor = React.useMemo(function () {
981
+ return getIconBgColor(type, theme$1.palette, color);
982
+ }, [type, theme$1.palette, color]);
983
+ return /*#__PURE__*/jsxRuntime.jsxs("div", _objectSpread2(_objectSpread2({}, props), {}, {
984
+ className: _JSXStyle.dynamic([["2201634259", [SCALES.font(1), SCALES.width(1, '100%'), SCALES.height(1, '100%'), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), theme$1.palette.accents_5, bgColor, spaceRatio]]]) + " " + (props && props.className != null && props.className || classes || ""),
985
+ children: [/*#__PURE__*/jsxRuntime.jsxs("span", {
986
+ className: _JSXStyle.dynamic([["2201634259", [SCALES.font(1), SCALES.width(1, '100%'), SCALES.height(1, '100%'), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), theme$1.palette.accents_5, bgColor, spaceRatio]]]) + " " + "loading",
987
+ children: [children && /*#__PURE__*/jsxRuntime.jsx("label", {
988
+ className: _JSXStyle.dynamic([["2201634259", [SCALES.font(1), SCALES.width(1, '100%'), SCALES.height(1, '100%'), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), theme$1.palette.accents_5, bgColor, spaceRatio]]]),
989
+ children: children
990
+ }), /*#__PURE__*/jsxRuntime.jsx("i", {
991
+ className: _JSXStyle.dynamic([["2201634259", [SCALES.font(1), SCALES.width(1, '100%'), SCALES.height(1, '100%'), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), theme$1.palette.accents_5, bgColor, spaceRatio]]])
992
+ }), /*#__PURE__*/jsxRuntime.jsx("i", {
993
+ className: _JSXStyle.dynamic([["2201634259", [SCALES.font(1), SCALES.width(1, '100%'), SCALES.height(1, '100%'), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), theme$1.palette.accents_5, bgColor, spaceRatio]]])
994
+ }), /*#__PURE__*/jsxRuntime.jsx("i", {
995
+ className: _JSXStyle.dynamic([["2201634259", [SCALES.font(1), SCALES.width(1, '100%'), SCALES.height(1, '100%'), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), theme$1.palette.accents_5, bgColor, spaceRatio]]])
996
+ })]
997
+ }), /*#__PURE__*/jsxRuntime.jsx(_JSXStyle, {
998
+ id: "2201634259",
999
+ dynamic: [SCALES.font(1), SCALES.width(1, '100%'), SCALES.height(1, '100%'), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), theme$1.palette.accents_5, bgColor, spaceRatio],
1000
+ children: ".loading-container.__jsx-style-dynamic-selector{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;position:relative;font-size:".concat(SCALES.font(1), ";width:").concat(SCALES.width(1, '100%'), ";height:").concat(SCALES.height(1, '100%'), ";min-height:1em;padding:").concat(SCALES.pt(0), " ").concat(SCALES.pr(0), " ").concat(SCALES.pb(0), " ").concat(SCALES.pl(0), ";margin:").concat(SCALES.mt(0), " ").concat(SCALES.mr(0), " ").concat(SCALES.mb(0), " ").concat(SCALES.ml(0), ";}label.__jsx-style-dynamic-selector{margin-right:0.5em;color:").concat(theme$1.palette.accents_5, ";line-height:1;}label.__jsx-style-dynamic-selector *{margin:0;}.loading.__jsx-style-dynamic-selector{position:absolute;top:50%;left:50%;width:100%;height:100%;-webkit-transform:translate(-50%,-50%);-ms-transform:translate(-50%,-50%);transform:translate(-50%,-50%);display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;background-color:transparent;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}i.__jsx-style-dynamic-selector{width:0.25em;height:0.25em;border-radius:50%;background-color:").concat(bgColor, ";margin:0 calc(0.25em / 2 * ").concat(spaceRatio, ");display:inline-block;-webkit-animation:loading-blink-__jsx-style-dynamic-selector 1.4s infinite both;animation:loading-blink-__jsx-style-dynamic-selector 1.4s infinite both;}i.__jsx-style-dynamic-selector:nth-child(2){-webkit-animation-delay:0.2s;animation-delay:0.2s;}i.__jsx-style-dynamic-selector:nth-child(3){-webkit-animation-delay:0.4s;animation-delay:0.4s;}@-webkit-keyframes loading-blink-__jsx-style-dynamic-selector{0%{opacity:0.2;}20%{opacity:1;}100%{opacity:0.2;}}@keyframes loading-blink-__jsx-style-dynamic-selector{0%{opacity:0.2;}20%{opacity:1;}100%{opacity:0.2;}}")
1001
+ })]
1002
+ }));
1003
+ };
1004
+ LoadingComponent.displayName = 'Loading';
1005
+ var Loading = withScale(LoadingComponent);
1006
+
1007
+ var ButtonLoading = function ButtonLoading(_ref) {
1008
+ var color = _ref.color;
1009
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
1010
+ className: "jsx-212623367" + " " + "btn-loading",
1011
+ children: [/*#__PURE__*/jsxRuntime.jsx(Loading, {
1012
+ color: color
1013
+ }), /*#__PURE__*/jsxRuntime.jsx(_JSXStyle, {
1014
+ id: "212623367",
1015
+ children: ".btn-loading.jsx-212623367{position:absolute;top:0;left:0;right:0;bottom:0;z-index:2;background-color:var(--helpdice-ui-button-bg);}"
1016
+ })]
1017
+ });
1018
+ };
1019
+ ButtonLoading.displayName = 'ButtonLoading';
1020
+
1021
+ var _excluded$1 = ["isRight", "isSingle", "children", "className"];
1022
+ var ButtonIcon = function ButtonIcon(_ref) {
1023
+ var _ref$isRight = _ref.isRight,
1024
+ isRight = _ref$isRight === void 0 ? false : _ref$isRight,
1025
+ isSingle = _ref.isSingle,
1026
+ children = _ref.children,
1027
+ _ref$className = _ref.className,
1028
+ className = _ref$className === void 0 ? '' : _ref$className,
1029
+ props = _objectWithoutProperties(_ref, _excluded$1);
1030
+ var classes = theme.useClasses('icon', {
1031
+ right: isRight,
1032
+ single: isSingle
1033
+ }, className);
1034
+ return /*#__PURE__*/jsxRuntime.jsxs("span", _objectSpread2(_objectSpread2({}, props), {}, {
1035
+ className: "jsx-2467502931" + " " + (props && props.className != null && props.className || classes || ""),
1036
+ children: [children, /*#__PURE__*/jsxRuntime.jsx(_JSXStyle, {
1037
+ id: "2467502931",
1038
+ children: ".icon.jsx-2467502931{position:absolute;left:var(--helpdice-ui-button-icon-padding);right:auto;top:50%;-webkit-transform:translateY(-50%);-ms-transform:translateY(-50%);transform:translateY(-50%);display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;color:var(--helpdice-ui-button-color);z-index:1;}.right.jsx-2467502931{right:var(--helpdice-ui-button-icon-padding);left:auto;}.icon.jsx-2467502931 svg{background:transparent;height:calc(var(--helpdice-ui-button-height) / 2.35);width:calc(var(--helpdice-ui-button-height) / 2.35);}.single.jsx-2467502931{position:static;-webkit-transform:none;-ms-transform:none;transform:none;}"
1039
+ })]
1040
+ }));
1041
+ };
1042
+ ButtonIcon.displayName = 'ButtonIcon';
1043
+
1044
+ var getButtonChildrenWithIcon = function getButtonChildrenWithIcon(auto, children, icons) {
1045
+ var icon = icons.icon,
1046
+ iconRight = icons.iconRight;
1047
+ var hasIcon = icon || iconRight;
1048
+ var isRight = Boolean(iconRight);
1049
+ var paddingForAutoMode = auto ? "calc(var(--helpdice-ui-button-height) / 2 + var(--helpdice-ui-button-icon-padding) * .5)" : 0;
1050
+ var classes = theme.useClasses('text', isRight ? 'right' : 'left');
1051
+ if (!hasIcon) return /*#__PURE__*/jsxRuntime.jsx("div", {
1052
+ className: "text",
1053
+ children: children
1054
+ });
1055
+ if (React.Children.count(children) === 0) {
1056
+ return /*#__PURE__*/jsxRuntime.jsx(ButtonIcon, {
1057
+ isRight: isRight,
1058
+ isSingle: true,
1059
+ children: hasIcon
1060
+ });
1061
+ }
1062
+ return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
1063
+ children: [/*#__PURE__*/jsxRuntime.jsx(ButtonIcon, {
1064
+ isRight: isRight,
1065
+ children: hasIcon
1066
+ }), /*#__PURE__*/jsxRuntime.jsxs("div", {
1067
+ className: _JSXStyle.dynamic([["3568181479", [paddingForAutoMode, paddingForAutoMode]]]) + " " + (classes || ""),
1068
+ children: [children, /*#__PURE__*/jsxRuntime.jsx(_JSXStyle, {
1069
+ id: "3568181479",
1070
+ dynamic: [paddingForAutoMode, paddingForAutoMode],
1071
+ children: ".left.__jsx-style-dynamic-selector{padding-left:".concat(paddingForAutoMode, ";}.right.__jsx-style-dynamic-selector{padding-right:").concat(paddingForAutoMode, ";}")
1072
+ })]
1073
+ })]
1074
+ });
1075
+ };
1076
+ var filterPropsWithGroup = function filterPropsWithGroup(props, config) {
1077
+ if (!config.isButtonGroup) return props;
1078
+ return _objectSpread2(_objectSpread2({}, props), {}, {
1079
+ auto: true,
1080
+ shadow: false,
1081
+ ghost: config.ghost || props.ghost,
1082
+ type: config.type || props.type,
1083
+ disabled: config.disabled || props.disabled
1084
+ });
1085
+ };
1086
+
1087
+ /* "use client" */
1088
+
1089
+ var defaultContext = {
1090
+ isButtonGroup: false,
1091
+ disabled: false
1092
+ };
1093
+ var ButtonGroupContext = /*#__PURE__*/React.createContext(defaultContext);
1094
+ var useButtonGroupContext = function useButtonGroupContext() {
1095
+ return React.useContext(ButtonGroupContext);
1096
+ };
1097
+
1098
+ var hexToRgb = function hexToRgb(color) {
1099
+ var fullReg = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
1100
+ var full = color.replace(fullReg, function (_, r, g, b) {
1101
+ return "".concat(r).concat(r).concat(g).concat(g).concat(b).concat(b);
1102
+ });
1103
+ var values = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(full);
1104
+ if (!values) {
1105
+ throw new Error("Helpdice UI: Unsupported ".concat(color, " color."));
1106
+ }
1107
+ return [Number.parseInt(values[1], 16), Number.parseInt(values[2], 16), Number.parseInt(values[3], 16)];
1108
+ };
1109
+ var colorToRgbValues = function colorToRgbValues(color) {
1110
+ if (color.charAt(0) === '#') return hexToRgb(color);
1111
+ var safeColor = color.replace(/ /g, '');
1112
+ var colorType = color.substr(0, 4);
1113
+ var regArray = safeColor.match(/\((.+)\)/);
1114
+ if (!colorType.startsWith('rgb') || !regArray) {
1115
+ console.log(color);
1116
+ throw new Error("Helpdice UI: Only support [\"RGB\", \"RGBA\", \"HEX\"] color.");
1117
+ }
1118
+ return regArray[1].split(',').map(function (str) {
1119
+ return Number.parseFloat(str);
1120
+ });
1121
+ };
1122
+ var addColorAlpha = function addColorAlpha(color, alpha) {
1123
+ if (!/^#|rgb|RGB/.test(color)) return color;
1124
+ var _colorToRgbValues = colorToRgbValues(color),
1125
+ _colorToRgbValues2 = _slicedToArray(_colorToRgbValues, 3),
1126
+ r = _colorToRgbValues2[0],
1127
+ g = _colorToRgbValues2[1],
1128
+ b = _colorToRgbValues2[2];
1129
+ var safeAlpha = alpha > 1 ? 1 : alpha < 0 ? 0 : alpha;
1130
+ return "rgba(".concat(r, ", ").concat(g, ", ").concat(b, ", ").concat(safeAlpha, ")");
1131
+ };
1132
+
1133
+ var getButtonGhostColors = function getButtonGhostColors(palette, _color) {
1134
+ var colors = {
1135
+ secondary: {
1136
+ bg: palette.background,
1137
+ border: palette.foreground,
1138
+ color: palette.foreground,
1139
+ ripple: ''
1140
+ },
1141
+ success: {
1142
+ bg: palette.background,
1143
+ border: palette.success,
1144
+ color: palette.success,
1145
+ ripple: ''
1146
+ },
1147
+ warning: {
1148
+ bg: palette.background,
1149
+ border: palette.warning,
1150
+ color: palette.warning,
1151
+ ripple: ''
1152
+ },
1153
+ error: {
1154
+ bg: palette.background,
1155
+ border: palette.error,
1156
+ color: palette.error,
1157
+ ripple: ''
1158
+ }
1159
+ };
1160
+ return colors[_color] || null;
1161
+ };
1162
+ var getButtonColors = function getButtonColors(palette, props) {
1163
+ var color = props.color,
1164
+ disabled = props.disabled,
1165
+ ghost = props.ghost;
1166
+ var colors = {
1167
+ "default": {
1168
+ bg: palette.background,
1169
+ border: palette.border,
1170
+ color: palette.accents_5,
1171
+ ripple: palette.accents_1
1172
+ },
1173
+ secondary: {
1174
+ bg: palette.foreground,
1175
+ border: palette.foreground,
1176
+ color: palette.background,
1177
+ ripple: palette.accents_1
1178
+ },
1179
+ success: {
1180
+ bg: palette.success,
1181
+ border: palette.success,
1182
+ color: '#fff',
1183
+ ripple: '#1f93ffff'
1184
+ },
1185
+ warning: {
1186
+ bg: palette.warning,
1187
+ border: palette.warning,
1188
+ color: '#fff',
1189
+ ripple: '#ffca29ff'
1190
+ },
1191
+ error: {
1192
+ bg: palette.error,
1193
+ border: palette.error,
1194
+ color: '#fff',
1195
+ ripple: '#ff5a55ff'
1196
+ },
1197
+ abort: {
1198
+ bg: 'transparent',
1199
+ border: 'transparent',
1200
+ color: palette.accents_5,
1201
+ ripple: palette.accents_1
1202
+ }
1203
+ };
1204
+ if (disabled) return {
1205
+ bg: palette.accents_1,
1206
+ border: palette.accents_2,
1207
+ color: '#ccc',
1208
+ ripple: ''
1209
+ };
1210
+
1211
+ /**
1212
+ * The '-light' type is the same color as the common type,
1213
+ * only hover's color is different.
1214
+ * e.g.
1215
+ * Color['success'] === Color['success-light']
1216
+ * Color['warning'] === Color['warning-light']
1217
+ */
1218
+ var withoutLightType = color === null || color === void 0 ? void 0 : color.replace('-light', '');
1219
+ var defaultColor = colors["default"];
1220
+ if (ghost) return getButtonGhostColors(palette, withoutLightType) || defaultColor;
1221
+ return colors[withoutLightType] || defaultColor;
1222
+ };
1223
+ var getButtonGhostHoverColors = function getButtonGhostHoverColors(palette, _color) {
1224
+ var colors = {
1225
+ secondary: {
1226
+ bg: palette.foreground,
1227
+ border: palette.background,
1228
+ color: palette.background
1229
+ },
1230
+ success: {
1231
+ bg: palette.success,
1232
+ border: palette.background,
1233
+ color: 'white'
1234
+ },
1235
+ warning: {
1236
+ bg: palette.warning,
1237
+ border: palette.background,
1238
+ color: 'white'
1239
+ },
1240
+ error: {
1241
+ bg: palette.error,
1242
+ border: palette.background,
1243
+ color: 'white'
1244
+ }
1245
+ };
1246
+ var withoutLightType = _color === null || _color === void 0 ? void 0 : _color.replace('-light', '');
1247
+ return colors[withoutLightType] || null;
1248
+ };
1249
+ var getButtonHoverColors = function getButtonHoverColors(palette, props) {
1250
+ var color = props.color,
1251
+ disabled = props.disabled,
1252
+ loading = props.loading,
1253
+ shadow = props.shadow,
1254
+ ghost = props.ghost;
1255
+ var defaultColor = getButtonColors(palette, props);
1256
+ var alphaBackground = addColorAlpha(defaultColor.bg, 0.85);
1257
+ var colors = {
1258
+ "default": {
1259
+ bg: palette.background,
1260
+ border: palette.foreground
1261
+ },
1262
+ secondary: {
1263
+ bg: palette.background,
1264
+ border: palette.foreground
1265
+ },
1266
+ success: {
1267
+ bg: palette.background,
1268
+ border: palette.success
1269
+ },
1270
+ warning: {
1271
+ bg: palette.background,
1272
+ border: palette.warning
1273
+ },
1274
+ error: {
1275
+ bg: palette.background,
1276
+ border: palette.error
1277
+ },
1278
+ abort: {
1279
+ bg: 'transparent',
1280
+ border: 'transparent',
1281
+ color: palette.accents_5
1282
+ },
1283
+ 'secondary-light': _objectSpread2(_objectSpread2({}, defaultColor), {}, {
1284
+ bg: alphaBackground
1285
+ }),
1286
+ 'success-light': _objectSpread2(_objectSpread2({}, defaultColor), {}, {
1287
+ bg: alphaBackground
1288
+ }),
1289
+ 'warning-light': _objectSpread2(_objectSpread2({}, defaultColor), {}, {
1290
+ bg: alphaBackground
1291
+ }),
1292
+ 'error-light': _objectSpread2(_objectSpread2({}, defaultColor), {}, {
1293
+ bg: alphaBackground
1294
+ })
1295
+ };
1296
+ if (disabled) return {
1297
+ bg: palette.accents_1,
1298
+ border: palette.accents_2,
1299
+ color: '#ccc'
1300
+ };
1301
+ if (loading) return _objectSpread2(_objectSpread2({}, defaultColor), {}, {
1302
+ color: 'transparent'
1303
+ });
1304
+ if (shadow) return defaultColor;
1305
+ var hoverColor = (ghost ? getButtonGhostHoverColors(palette, color) : colors[color]) || colors["default"];
1306
+ return _objectSpread2(_objectSpread2({}, hoverColor), {}, {
1307
+ color: hoverColor.color || hoverColor.border
1308
+ });
1309
+ };
1310
+ var getButtonCursor = function getButtonCursor(disabled, loading) {
1311
+ if (disabled) return {
1312
+ cursor: 'not-allowed',
1313
+ events: 'auto'
1314
+ };
1315
+ if (loading) return {
1316
+ cursor: 'default',
1317
+ events: 'none'
1318
+ };
1319
+ return {
1320
+ cursor: 'pointer',
1321
+ events: 'auto'
1322
+ };
1323
+ };
1324
+ var getButtonDripColor = function getButtonDripColor(palette, props) {
1325
+ var type = props.type;
1326
+ var isLightHover = type ? type.endsWith('light') : false;
1327
+ var hoverColors = getButtonHoverColors(palette, props);
1328
+ return isLightHover ? addColorAlpha(hoverColors.bg, 0.65) : addColorAlpha(palette.accents_2, 0.65);
1329
+ };
1330
+
1331
+ var _excluded = ["children", "disabled", "color", "loading", "shadow", "ghost", "effect", "round", "relative", "replace", "a", "to", "onClick", "auto", "icon", "type", "iconRight", "className", "crossOrigin"];
1332
+ var ButtonComponent = /*#__PURE__*/React.forwardRef(function (btnProps, ref) {
1333
+ var theme$1 = theme.useTheme();
1334
+ // const navigate = useNavigate();
1335
+ var _useScale = useScale(),
1336
+ SCALES = _useScale.SCALES;
1337
+ var buttonRef = React.useRef(null);
1338
+ React.useImperativeHandle(ref, function () {
1339
+ return buttonRef.current;
1340
+ }); // Changed with !
1341
+
1342
+ var _useState = React.useState(false),
1343
+ _useState2 = _slicedToArray(_useState, 2),
1344
+ dripShow = _useState2[0],
1345
+ setDripShow = _useState2[1];
1346
+ var _useState3 = React.useState(0),
1347
+ _useState4 = _slicedToArray(_useState3, 2),
1348
+ dripX = _useState4[0],
1349
+ setDripX = _useState4[1];
1350
+ var _useState5 = React.useState(0),
1351
+ _useState6 = _slicedToArray(_useState5, 2),
1352
+ dripY = _useState6[0],
1353
+ setDripY = _useState6[1];
1354
+ var groupConfig = useButtonGroupContext();
1355
+ var filteredProps = filterPropsWithGroup(btnProps, groupConfig);
1356
+ /* eslint-disable @typescript-eslint/no-unused-vars */
1357
+ var children = filteredProps.children,
1358
+ _filteredProps$disabl = filteredProps.disabled,
1359
+ disabled = _filteredProps$disabl === void 0 ? false : _filteredProps$disabl;
1360
+ filteredProps.color;
1361
+ var _filteredProps$loadin = filteredProps.loading,
1362
+ loading = _filteredProps$loadin === void 0 ? false : _filteredProps$loadin,
1363
+ _filteredProps$shadow = filteredProps.shadow,
1364
+ shadow = _filteredProps$shadow === void 0 ? false : _filteredProps$shadow,
1365
+ _filteredProps$ghost = filteredProps.ghost,
1366
+ ghost = _filteredProps$ghost === void 0 ? false : _filteredProps$ghost,
1367
+ _filteredProps$effect = filteredProps.effect,
1368
+ effect = _filteredProps$effect === void 0 ? true : _filteredProps$effect,
1369
+ _filteredProps$round = filteredProps.round,
1370
+ round = _filteredProps$round === void 0 ? false : _filteredProps$round;
1371
+ filteredProps.relative;
1372
+ filteredProps.replace;
1373
+ filteredProps.a;
1374
+ var to = filteredProps.to,
1375
+ onClick = filteredProps.onClick,
1376
+ _filteredProps$auto = filteredProps.auto,
1377
+ auto = _filteredProps$auto === void 0 ? false : _filteredProps$auto,
1378
+ icon = filteredProps.icon,
1379
+ _filteredProps$type = filteredProps.type,
1380
+ type = _filteredProps$type === void 0 ? 'button' : _filteredProps$type,
1381
+ iconRight = filteredProps.iconRight,
1382
+ _filteredProps$classN = filteredProps.className,
1383
+ className = _filteredProps$classN === void 0 ? '' : _filteredProps$classN;
1384
+ filteredProps.crossOrigin;
1385
+ var props = _objectWithoutProperties(filteredProps, _excluded);
1386
+ /* eslint-enable @typescript-eslint/no-unused-vars */
1387
+
1388
+ var _useMemo = React.useMemo(function () {
1389
+ return getButtonColors(theme$1.palette, filteredProps);
1390
+ }, [theme$1.palette, filteredProps]),
1391
+ bg = _useMemo.bg,
1392
+ border = _useMemo.border,
1393
+ color = _useMemo.color,
1394
+ rippleColor = _useMemo.ripple;
1395
+ var hover = React.useMemo(function () {
1396
+ return getButtonHoverColors(theme$1.palette, filteredProps);
1397
+ }, [theme$1.palette, filteredProps]);
1398
+ var _useMemo2 = React.useMemo(function () {
1399
+ return getButtonCursor(disabled, loading);
1400
+ }, [disabled, loading]),
1401
+ cursor = _useMemo2.cursor,
1402
+ events = _useMemo2.events;
1403
+ var dripColor = React.useMemo(function () {
1404
+ return getButtonDripColor(theme$1.palette, filteredProps);
1405
+ }, [theme$1.palette, filteredProps]);
1406
+
1407
+ /* istanbul ignore next */
1408
+ var dripCompletedHandle = function dripCompletedHandle() {
1409
+ setDripShow(false);
1410
+ setDripX(0);
1411
+ setDripY(0);
1412
+ };
1413
+ var createRipple = function createRipple(event) {
1414
+ var button = buttonRef.current;
1415
+ if (!button) return;
1416
+ var rect = button.getBoundingClientRect();
1417
+ var size = Math.max(rect.width, rect.height);
1418
+ var x = event.clientX - rect.left - size / 2;
1419
+ var y = event.clientY - rect.top - size / 2;
1420
+ var rippleCount = 1; // number of rings
1421
+ var rippleDelay = 500; // ms between each ripple
1422
+ var _loop = function _loop() {
1423
+ var ripple = document.createElement('span');
1424
+ Object.assign(ripple.style, {
1425
+ position: 'absolute',
1426
+ borderRadius: '50%',
1427
+ backgroundColor: rippleColor,
1428
+ width: "".concat(size, "px"),
1429
+ height: "".concat(size, "px"),
1430
+ left: "".concat(x, "px"),
1431
+ top: "".concat(y, "px"),
1432
+ pointerEvents: 'none',
1433
+ transform: 'scale(0)',
1434
+ opacity: '1',
1435
+ transition: "transform 600ms ease-out ".concat(i * rippleDelay, "ms, opacity 600ms ease-out ").concat(i * rippleDelay, "ms"),
1436
+ zIndex: 1
1437
+ });
1438
+ button.appendChild(ripple);
1439
+
1440
+ // Force reflow to start transition
1441
+ window.getComputedStyle(ripple).opacity;
1442
+ ripple.style.transform = 'scale(2.5)';
1443
+ ripple.style.opacity = '0';
1444
+ ripple.addEventListener('transitionend', function () {
1445
+ ripple.remove();
1446
+ });
1447
+ };
1448
+ for (var i = 0; i < rippleCount; i++) {
1449
+ _loop();
1450
+ }
1451
+ };
1452
+ var clickHandler = function clickHandler(event) {
1453
+ if (disabled || loading) return;
1454
+ var showDrip = !shadow && !ghost && effect;
1455
+ /* istanbul ignore next */
1456
+ if (showDrip && buttonRef.current) {
1457
+ var rect = buttonRef.current.getBoundingClientRect();
1458
+ setDripShow(true);
1459
+ setDripX(event.clientX - rect.left);
1460
+ setDripY(event.clientY - rect.top);
1461
+ }
1462
+ if (shadow) {
1463
+ createRipple(event);
1464
+ }
1465
+ onClick && onClick(event);
1466
+ };
1467
+ var childrenWithIcon = React.useMemo(function () {
1468
+ return getButtonChildrenWithIcon(auto, children, {
1469
+ icon: icon,
1470
+ iconRight: iconRight
1471
+ });
1472
+ }, [auto, children, icon, iconRight]);
1473
+ var paddingLeft = auto ? SCALES.pl(1.15) : SCALES.pl(1.375),
1474
+ paddingRight = auto ? SCALES.pr(1.15) : SCALES.pr(1.375);
1475
+
1476
+ // If shadow provided is string then value other default
1477
+ var btnShadow = typeof shadow === 'string' ? shadow : shadow ? theme$1.shadows.level.z2 : 'none';
1478
+ return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
1479
+ children: [to ? /*#__PURE__*/jsxRuntime.jsxs("a", _objectSpread2(_objectSpread2({
1480
+ href: to
1481
+ }, props), {}, {
1482
+ className: _JSXStyle.dynamic([["612376042", [SCALES.height(2.5), round ? '50%' : theme$1.layout.radius, SCALES.font(0.875), color, bg, shadow ? 'transparent' : border, cursor !== null && cursor !== void 0 ? cursor : 'pointer', events, shadow ? btnShadow : 'none', SCALES.pl(0.727), SCALES.height(2.5), color, bg, auto ? 'min-content' : SCALES.width(10.5), auto ? 'auto' : 'initial', SCALES.height(2.5), SCALES.pt(0), paddingRight, SCALES.pb(0), paddingLeft, SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), hover.color, hover.color, hover.bg, hover.border, cursor, events, btnShadow, shadow ? '-1px' : '0px']]]) + " " + (props && props.className != null && props.className || theme.useClasses('btn', 'btn-link', className) || ""),
1483
+ children: [loading && /*#__PURE__*/jsxRuntime.jsx(ButtonLoading, {
1484
+ color: color
1485
+ }), childrenWithIcon]
1486
+ })) : /*#__PURE__*/jsxRuntime.jsxs("button", _objectSpread2(_objectSpread2({
1487
+ ref: buttonRef,
1488
+ type: type,
1489
+ disabled: disabled,
1490
+ onClick: clickHandler
1491
+ }, props), {}, {
1492
+ className: _JSXStyle.dynamic([["612376042", [SCALES.height(2.5), round ? '50%' : theme$1.layout.radius, SCALES.font(0.875), color, bg, shadow ? 'transparent' : border, cursor !== null && cursor !== void 0 ? cursor : 'pointer', events, shadow ? btnShadow : 'none', SCALES.pl(0.727), SCALES.height(2.5), color, bg, auto ? 'min-content' : SCALES.width(10.5), auto ? 'auto' : 'initial', SCALES.height(2.5), SCALES.pt(0), paddingRight, SCALES.pb(0), paddingLeft, SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), hover.color, hover.color, hover.bg, hover.border, cursor, events, btnShadow, shadow ? '-1px' : '0px']]]) + " " + (props && props.className != null && props.className || theme.useClasses('btn', className) || ""),
1493
+ children: [loading && /*#__PURE__*/jsxRuntime.jsx(ButtonLoading, {
1494
+ color: color
1495
+ }), childrenWithIcon, dripShow && /*#__PURE__*/jsxRuntime.jsx(ButtonDrip, {
1496
+ x: dripX,
1497
+ y: dripY,
1498
+ color: dripColor,
1499
+ onCompleted: dripCompletedHandle
1500
+ })]
1501
+ })), /*#__PURE__*/jsxRuntime.jsx(_JSXStyle, {
1502
+ id: "612376042",
1503
+ dynamic: [SCALES.height(2.5), round ? '50%' : theme$1.layout.radius, SCALES.font(0.875), color, bg, shadow ? 'transparent' : border, cursor !== null && cursor !== void 0 ? cursor : 'pointer', events, shadow ? btnShadow : 'none', SCALES.pl(0.727), SCALES.height(2.5), color, bg, auto ? 'min-content' : SCALES.width(10.5), auto ? 'auto' : 'initial', SCALES.height(2.5), SCALES.pt(0), paddingRight, SCALES.pb(0), paddingLeft, SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), hover.color, hover.color, hover.bg, hover.border, cursor, events, btnShadow, shadow ? '-1px' : '0px'],
1504
+ children: ".btn.__jsx-style-dynamic-selector{box-sizing:border-box;display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;line-height:".concat(SCALES.height(2.5), ";border-radius:").concat(round ? '50%' : theme$1.layout.radius, ";font-weight:400;font-size:").concat(SCALES.font(0.875), ";-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;outline:none;text-transform:capitalize;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;text-align:center;white-space:nowrap;-webkit-transition:background-color 200ms ease 0ms,box-shadow 200ms ease 0ms, border 200ms ease 0ms,color 200ms ease 0ms;transition:background-color 200ms ease 0ms,box-shadow 200ms ease 0ms, border 200ms ease 0ms,color 200ms ease 0ms;position:relative;overflow:hidden;color:").concat(color, ";background-color:").concat(bg, ";border:1px solid ").concat(shadow ? 'transparent' : border, ";cursor:").concat(cursor !== null && cursor !== void 0 ? cursor : 'pointer', ";pointer-events:").concat(events, ";box-shadow:").concat(shadow ? btnShadow : 'none', ";--helpdice-ui-button-icon-padding:").concat(SCALES.pl(0.727), ";--helpdice-ui-button-height:").concat(SCALES.height(2.5), ";--helpdice-ui-button-color:").concat(color, ";--helpdice-ui-button-bg:").concat(bg, ";min-width:").concat(auto ? 'min-content' : SCALES.width(10.5), ";width:").concat(auto ? 'auto' : 'initial', ";height:").concat(SCALES.height(2.5), ";padding:").concat(SCALES.pt(0), " ").concat(paddingRight, " ").concat(SCALES.pb(0), " ").concat(paddingLeft, ";margin:").concat(SCALES.mt(0), " ").concat(SCALES.mr(0), " ").concat(SCALES.mb(0), " ").concat(SCALES.ml(0), ";}.btn.__jsx-style-dynamic-selector:hover,.btn.__jsx-style-dynamic-selector:focus{color:").concat(hover.color, ";--helpdice-ui-button-color:").concat(hover.color, ";background-color:").concat(hover.bg, ";border-color:").concat(hover.border, ";cursor:").concat(cursor, ";pointer-events:").concat(events, ";box-shadow:").concat(btnShadow, ";}.btn-link.__jsx-style-dynamic-selector{-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}.btn.__jsx-style-dynamic-selector .text{position:relative;z-index:1;display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;text-align:center;line-height:inherit;top:-1px;}.btn.__jsx-style-dynamic-selector .text p,.btn.__jsx-style-dynamic-selector .text pre,.btn.__jsx-style-dynamic-selector .text div{margin:0;}.ripple.__jsx-style-dynamic-selector{position:absolute;border-radius:50%;-webkit-transform:scale(0);-ms-transform:scale(0);transform:scale(0);-webkit-animation:ripple-animation-__jsx-style-dynamic-selector 600ms ease-out;animation:ripple-animation-__jsx-style-dynamic-selector 600ms ease-out;background-color:rgba(0,0,0,0.3);pointer-events:none;z-index:1;}@-webkit-keyframes ripple-animation-__jsx-style-dynamic-selector{to{-webkit-transform:scale(2.5);-ms-transform:scale(2.5);transform:scale(2.5);opacity:0;}}@keyframes ripple-animation-__jsx-style-dynamic-selector{to{-webkit-transform:scale(2.5);-ms-transform:scale(2.5);transform:scale(2.5);opacity:0;}}")
1505
+ })]
1506
+ });
1507
+ });
1508
+ ButtonComponent.displayName = 'Button';
1509
+ var Button = withScale(ButtonComponent);
1510
+
1511
+ var CompactButton = function CompactButton(props) {
1512
+ // const theme = useTheme();
1513
+ return /*#__PURE__*/jsxRuntime.jsx(Button, _objectSpread2(_objectSpread2({
1514
+ scale: 2 / 3,
1515
+ px: 0.6
1516
+ }, _objectSpread2({
1517
+ auto: true
1518
+ }, props)), {}, {
1519
+ children: props.children
1520
+ }));
1521
+ };
1522
+ var IconButton = /*#__PURE__*/React.memo(CompactButton);
1523
+
1524
+ var SmallButton = function SmallButton(props) {
1525
+ // const theme = useTheme();
1526
+ return /*#__PURE__*/jsxRuntime.jsx(Button, _objectSpread2(_objectSpread2({
1527
+ auto: true,
1528
+ scale: 2 / 3,
1529
+ px: 0.6
1530
+ }, props), {}, {
1531
+ children: props.children
1532
+ }));
1533
+ };
1534
+ var SmallButton$1 = /*#__PURE__*/React.memo(SmallButton);
1535
+
1536
+ /* "use client" */
1537
+
1538
+ Button.Icon = IconButton;
1539
+ Button.Small = SmallButton$1;
1540
+
55
1541
  var Expandable = function Expandable(_ref) {
56
1542
  var children = _ref.children,
57
1543
  _ref$collapsedHeight = _ref.collapsedHeight,
@@ -61,27 +1547,27 @@ var Expandable = function Expandable(_ref) {
61
1547
  className = _ref.className,
62
1548
  _ref$transitionDurati = _ref.transitionDuration,
63
1549
  transitionDuration = _ref$transitionDurati === void 0 ? 300 : _ref$transitionDurati;
64
- var contentRef = react.useRef(null);
65
- var containerRef = react.useRef(null);
66
- var _useState = react.useState(false),
1550
+ var contentRef = React.useRef(null);
1551
+ var containerRef = React.useRef(null);
1552
+ var _useState = React.useState(false),
67
1553
  _useState2 = _slicedToArray(_useState, 2),
68
1554
  expanded = _useState2[0],
69
1555
  setExpanded = _useState2[1];
70
- var _useState3 = react.useState(false),
1556
+ var _useState3 = React.useState(false),
71
1557
  _useState4 = _slicedToArray(_useState3, 2),
72
1558
  isOverflowing = _useState4[0],
73
1559
  setIsOverflowing = _useState4[1];
74
- var _useState5 = react.useState(0),
1560
+ var _useState5 = React.useState(0),
75
1561
  _useState6 = _slicedToArray(_useState5, 2),
76
1562
  contentHeight = _useState6[0],
77
1563
  setContentHeight = _useState6[1];
78
- var _useState7 = react.useState("#fff"),
1564
+ var _useState7 = React.useState("#fff"),
79
1565
  _useState8 = _slicedToArray(_useState7, 2),
80
1566
  fadeColor = _useState8[0],
81
1567
  setFadeColor = _useState8[1];
82
1568
 
83
1569
  // Measure content height and detect overflow
84
- react.useEffect(function () {
1570
+ React.useEffect(function () {
85
1571
  var el = contentRef.current;
86
1572
  if (!el) return;
87
1573
  var updateHeight = function updateHeight() {