@ttoss/ui 1.29.0 → 1.30.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/esm/index.js CHANGED
@@ -1,4 +1,10 @@
1
1
  /** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
2
+ var __defProp = Object.defineProperty;
3
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
+ var __publicField = (obj, key, value) => {
5
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
6
+ return value;
7
+ };
2
8
 
3
9
  // src/index.ts
4
10
  import { useResponsiveValue, useBreakpointIndex } from "@theme-ui/match-media";
@@ -267,11 +273,1926 @@ import { Spinner } from "theme-ui";
267
273
  // src/components/Radio.tsx
268
274
  import { Radio } from "theme-ui";
269
275
 
276
+ // ../../node_modules/@iconify-icon/react/dist/iconify.mjs
277
+ import React3 from "react";
278
+
279
+ // ../../node_modules/iconify-icon/dist/iconify-icon.mjs
280
+ var defaultIconDimensions = Object.freeze(
281
+ {
282
+ left: 0,
283
+ top: 0,
284
+ width: 16,
285
+ height: 16
286
+ }
287
+ );
288
+ var defaultIconTransformations = Object.freeze({
289
+ rotate: 0,
290
+ vFlip: false,
291
+ hFlip: false
292
+ });
293
+ var defaultIconProps = Object.freeze({
294
+ ...defaultIconDimensions,
295
+ ...defaultIconTransformations
296
+ });
297
+ var defaultExtendedIconProps = Object.freeze({
298
+ ...defaultIconProps,
299
+ body: "",
300
+ hidden: false
301
+ });
302
+ var defaultIconSizeCustomisations = Object.freeze({
303
+ width: null,
304
+ height: null
305
+ });
306
+ var defaultIconCustomisations = Object.freeze({
307
+ ...defaultIconSizeCustomisations,
308
+ ...defaultIconTransformations
309
+ });
310
+ function rotateFromString(value, defaultValue = 0) {
311
+ const units = value.replace(/^-?[0-9.]*/, "");
312
+ function cleanup(value2) {
313
+ while (value2 < 0) {
314
+ value2 += 4;
315
+ }
316
+ return value2 % 4;
317
+ }
318
+ if (units === "") {
319
+ const num = parseInt(value);
320
+ return isNaN(num) ? 0 : cleanup(num);
321
+ } else if (units !== value) {
322
+ let split = 0;
323
+ switch (units) {
324
+ case "%":
325
+ split = 25;
326
+ break;
327
+ case "deg":
328
+ split = 90;
329
+ }
330
+ if (split) {
331
+ let num = parseFloat(value.slice(0, value.length - units.length));
332
+ if (isNaN(num)) {
333
+ return 0;
334
+ }
335
+ num = num / split;
336
+ return num % 1 === 0 ? cleanup(num) : 0;
337
+ }
338
+ }
339
+ return defaultValue;
340
+ }
341
+ var separator = /[\s,]+/;
342
+ function flipFromString(custom, flip) {
343
+ flip.split(separator).forEach((str) => {
344
+ const value = str.trim();
345
+ switch (value) {
346
+ case "horizontal":
347
+ custom.hFlip = true;
348
+ break;
349
+ case "vertical":
350
+ custom.vFlip = true;
351
+ break;
352
+ }
353
+ });
354
+ }
355
+ var defaultCustomisations = {
356
+ ...defaultIconCustomisations,
357
+ preserveAspectRatio: ""
358
+ };
359
+ function getCustomisations(node) {
360
+ const customisations = {
361
+ ...defaultCustomisations
362
+ };
363
+ const attr = (key, def) => node.getAttribute(key) || def;
364
+ customisations.width = attr("width", null);
365
+ customisations.height = attr("height", null);
366
+ customisations.rotate = rotateFromString(attr("rotate", ""));
367
+ flipFromString(customisations, attr("flip", ""));
368
+ customisations.preserveAspectRatio = attr("preserveAspectRatio", attr("preserveaspectratio", ""));
369
+ return customisations;
370
+ }
371
+ function haveCustomisationsChanged(value1, value2) {
372
+ for (const key in defaultCustomisations) {
373
+ if (value1[key] !== value2[key]) {
374
+ return true;
375
+ }
376
+ }
377
+ return false;
378
+ }
379
+ var matchIconName = /^[a-z0-9]+(-[a-z0-9]+)*$/;
380
+ var stringToIcon = (value, validate, allowSimpleName, provider = "") => {
381
+ const colonSeparated = value.split(":");
382
+ if (value.slice(0, 1) === "@") {
383
+ if (colonSeparated.length < 2 || colonSeparated.length > 3) {
384
+ return null;
385
+ }
386
+ provider = colonSeparated.shift().slice(1);
387
+ }
388
+ if (colonSeparated.length > 3 || !colonSeparated.length) {
389
+ return null;
390
+ }
391
+ if (colonSeparated.length > 1) {
392
+ const name2 = colonSeparated.pop();
393
+ const prefix = colonSeparated.pop();
394
+ const result = {
395
+ provider: colonSeparated.length > 0 ? colonSeparated[0] : provider,
396
+ prefix,
397
+ name: name2
398
+ };
399
+ return validate && !validateIconName(result) ? null : result;
400
+ }
401
+ const name = colonSeparated[0];
402
+ const dashSeparated = name.split("-");
403
+ if (dashSeparated.length > 1) {
404
+ const result = {
405
+ provider,
406
+ prefix: dashSeparated.shift(),
407
+ name: dashSeparated.join("-")
408
+ };
409
+ return validate && !validateIconName(result) ? null : result;
410
+ }
411
+ if (allowSimpleName && provider === "") {
412
+ const result = {
413
+ provider,
414
+ prefix: "",
415
+ name
416
+ };
417
+ return validate && !validateIconName(result, allowSimpleName) ? null : result;
418
+ }
419
+ return null;
420
+ };
421
+ var validateIconName = (icon, allowSimpleName) => {
422
+ if (!icon) {
423
+ return false;
424
+ }
425
+ return !!((icon.provider === "" || icon.provider.match(matchIconName)) && (allowSimpleName && icon.prefix === "" || icon.prefix.match(matchIconName)) && icon.name.match(matchIconName));
426
+ };
427
+ function mergeIconTransformations(obj1, obj2) {
428
+ const result = {};
429
+ if (!obj1.hFlip !== !obj2.hFlip) {
430
+ result.hFlip = true;
431
+ }
432
+ if (!obj1.vFlip !== !obj2.vFlip) {
433
+ result.vFlip = true;
434
+ }
435
+ const rotate = ((obj1.rotate || 0) + (obj2.rotate || 0)) % 4;
436
+ if (rotate) {
437
+ result.rotate = rotate;
438
+ }
439
+ return result;
440
+ }
441
+ function mergeIconData(parent, child) {
442
+ const result = mergeIconTransformations(parent, child);
443
+ for (const key in defaultExtendedIconProps) {
444
+ if (key in defaultIconTransformations) {
445
+ if (key in parent && !(key in result)) {
446
+ result[key] = defaultIconTransformations[key];
447
+ }
448
+ } else if (key in child) {
449
+ result[key] = child[key];
450
+ } else if (key in parent) {
451
+ result[key] = parent[key];
452
+ }
453
+ }
454
+ return result;
455
+ }
456
+ function getIconsTree(data, names) {
457
+ const icons = data.icons;
458
+ const aliases = data.aliases || /* @__PURE__ */ Object.create(null);
459
+ const resolved = /* @__PURE__ */ Object.create(null);
460
+ function resolve(name) {
461
+ if (icons[name]) {
462
+ return resolved[name] = [];
463
+ }
464
+ if (!(name in resolved)) {
465
+ resolved[name] = null;
466
+ const parent = aliases[name] && aliases[name].parent;
467
+ const value = parent && resolve(parent);
468
+ if (value) {
469
+ resolved[name] = [parent].concat(value);
470
+ }
471
+ }
472
+ return resolved[name];
473
+ }
474
+ (names || Object.keys(icons).concat(Object.keys(aliases))).forEach(resolve);
475
+ return resolved;
476
+ }
477
+ function internalGetIconData(data, name, tree) {
478
+ const icons = data.icons;
479
+ const aliases = data.aliases || /* @__PURE__ */ Object.create(null);
480
+ let currentProps = {};
481
+ function parse(name2) {
482
+ currentProps = mergeIconData(
483
+ icons[name2] || aliases[name2],
484
+ currentProps
485
+ );
486
+ }
487
+ parse(name);
488
+ tree.forEach(parse);
489
+ return mergeIconData(data, currentProps);
490
+ }
491
+ function parseIconSet(data, callback) {
492
+ const names = [];
493
+ if (typeof data !== "object" || typeof data.icons !== "object") {
494
+ return names;
495
+ }
496
+ if (data.not_found instanceof Array) {
497
+ data.not_found.forEach((name) => {
498
+ callback(name, null);
499
+ names.push(name);
500
+ });
501
+ }
502
+ const tree = getIconsTree(data);
503
+ for (const name in tree) {
504
+ const item = tree[name];
505
+ if (item) {
506
+ callback(name, internalGetIconData(data, name, item));
507
+ names.push(name);
508
+ }
509
+ }
510
+ return names;
511
+ }
512
+ var optionalPropertyDefaults = {
513
+ provider: "",
514
+ aliases: {},
515
+ not_found: {},
516
+ ...defaultIconDimensions
517
+ };
518
+ function checkOptionalProps(item, defaults) {
519
+ for (const prop in defaults) {
520
+ if (prop in item && typeof item[prop] !== typeof defaults[prop]) {
521
+ return false;
522
+ }
523
+ }
524
+ return true;
525
+ }
526
+ function quicklyValidateIconSet(obj) {
527
+ if (typeof obj !== "object" || obj === null) {
528
+ return null;
529
+ }
530
+ const data = obj;
531
+ if (typeof data.prefix !== "string" || !obj.icons || typeof obj.icons !== "object") {
532
+ return null;
533
+ }
534
+ if (!checkOptionalProps(obj, optionalPropertyDefaults)) {
535
+ return null;
536
+ }
537
+ const icons = data.icons;
538
+ for (const name in icons) {
539
+ const icon = icons[name];
540
+ if (!name.match(matchIconName) || typeof icon.body !== "string" || !checkOptionalProps(
541
+ icon,
542
+ defaultExtendedIconProps
543
+ )) {
544
+ return null;
545
+ }
546
+ }
547
+ const aliases = data.aliases || /* @__PURE__ */ Object.create(null);
548
+ for (const name in aliases) {
549
+ const icon = aliases[name];
550
+ const parent = icon.parent;
551
+ if (!name.match(matchIconName) || typeof parent !== "string" || !icons[parent] && !aliases[parent] || !checkOptionalProps(
552
+ icon,
553
+ defaultExtendedIconProps
554
+ )) {
555
+ return null;
556
+ }
557
+ }
558
+ return data;
559
+ }
560
+ var dataStorage = /* @__PURE__ */ Object.create(null);
561
+ function newStorage(provider, prefix) {
562
+ return {
563
+ provider,
564
+ prefix,
565
+ icons: /* @__PURE__ */ Object.create(null),
566
+ missing: /* @__PURE__ */ new Set()
567
+ };
568
+ }
569
+ function getStorage(provider, prefix) {
570
+ const providerStorage = dataStorage[provider] || (dataStorage[provider] = /* @__PURE__ */ Object.create(null));
571
+ return providerStorage[prefix] || (providerStorage[prefix] = newStorage(provider, prefix));
572
+ }
573
+ function addIconSet(storage2, data) {
574
+ if (!quicklyValidateIconSet(data)) {
575
+ return [];
576
+ }
577
+ return parseIconSet(data, (name, icon) => {
578
+ if (icon) {
579
+ storage2.icons[name] = icon;
580
+ } else {
581
+ storage2.missing.add(name);
582
+ }
583
+ });
584
+ }
585
+ function addIconToStorage(storage2, name, icon) {
586
+ try {
587
+ if (typeof icon.body === "string") {
588
+ storage2.icons[name] = { ...icon };
589
+ return true;
590
+ }
591
+ } catch (err) {
592
+ }
593
+ return false;
594
+ }
595
+ function listIcons$1(provider, prefix) {
596
+ let allIcons = [];
597
+ const providers = typeof provider === "string" ? [provider] : Object.keys(dataStorage);
598
+ providers.forEach((provider2) => {
599
+ const prefixes = typeof provider2 === "string" && typeof prefix === "string" ? [prefix] : Object.keys(dataStorage[provider2] || {});
600
+ prefixes.forEach((prefix2) => {
601
+ const storage2 = getStorage(provider2, prefix2);
602
+ allIcons = allIcons.concat(
603
+ Object.keys(storage2.icons).map(
604
+ (name) => (provider2 !== "" ? "@" + provider2 + ":" : "") + prefix2 + ":" + name
605
+ )
606
+ );
607
+ });
608
+ });
609
+ return allIcons;
610
+ }
611
+ var simpleNames = false;
612
+ function allowSimpleNames(allow) {
613
+ if (typeof allow === "boolean") {
614
+ simpleNames = allow;
615
+ }
616
+ return simpleNames;
617
+ }
618
+ function getIconData(name) {
619
+ const icon = typeof name === "string" ? stringToIcon(name, true, simpleNames) : name;
620
+ if (icon) {
621
+ const storage2 = getStorage(icon.provider, icon.prefix);
622
+ const iconName = icon.name;
623
+ return storage2.icons[iconName] || (storage2.missing.has(iconName) ? null : void 0);
624
+ }
625
+ }
626
+ function addIcon$1(name, data) {
627
+ const icon = stringToIcon(name, true, simpleNames);
628
+ if (!icon) {
629
+ return false;
630
+ }
631
+ const storage2 = getStorage(icon.provider, icon.prefix);
632
+ return addIconToStorage(storage2, icon.name, data);
633
+ }
634
+ function addCollection$1(data, provider) {
635
+ if (typeof data !== "object") {
636
+ return false;
637
+ }
638
+ if (typeof provider !== "string") {
639
+ provider = data.provider || "";
640
+ }
641
+ if (simpleNames && !provider && !data.prefix) {
642
+ let added = false;
643
+ if (quicklyValidateIconSet(data)) {
644
+ data.prefix = "";
645
+ parseIconSet(data, (name, icon) => {
646
+ if (icon && addIcon$1(name, icon)) {
647
+ added = true;
648
+ }
649
+ });
650
+ }
651
+ return added;
652
+ }
653
+ const prefix = data.prefix;
654
+ if (!validateIconName({
655
+ provider,
656
+ prefix,
657
+ name: "a"
658
+ })) {
659
+ return false;
660
+ }
661
+ const storage2 = getStorage(provider, prefix);
662
+ return !!addIconSet(storage2, data);
663
+ }
664
+ function iconExists$1(name) {
665
+ return !!getIconData(name);
666
+ }
667
+ function getIcon$1(name) {
668
+ const result = getIconData(name);
669
+ return result ? {
670
+ ...defaultIconProps,
671
+ ...result
672
+ } : null;
673
+ }
674
+ function sortIcons(icons) {
675
+ const result = {
676
+ loaded: [],
677
+ missing: [],
678
+ pending: []
679
+ };
680
+ const storage2 = /* @__PURE__ */ Object.create(null);
681
+ icons.sort((a, b) => {
682
+ if (a.provider !== b.provider) {
683
+ return a.provider.localeCompare(b.provider);
684
+ }
685
+ if (a.prefix !== b.prefix) {
686
+ return a.prefix.localeCompare(b.prefix);
687
+ }
688
+ return a.name.localeCompare(b.name);
689
+ });
690
+ let lastIcon = {
691
+ provider: "",
692
+ prefix: "",
693
+ name: ""
694
+ };
695
+ icons.forEach((icon) => {
696
+ if (lastIcon.name === icon.name && lastIcon.prefix === icon.prefix && lastIcon.provider === icon.provider) {
697
+ return;
698
+ }
699
+ lastIcon = icon;
700
+ const provider = icon.provider;
701
+ const prefix = icon.prefix;
702
+ const name = icon.name;
703
+ const providerStorage = storage2[provider] || (storage2[provider] = /* @__PURE__ */ Object.create(null));
704
+ const localStorage = providerStorage[prefix] || (providerStorage[prefix] = getStorage(provider, prefix));
705
+ let list;
706
+ if (name in localStorage.icons) {
707
+ list = result.loaded;
708
+ } else if (prefix === "" || localStorage.missing.has(name)) {
709
+ list = result.missing;
710
+ } else {
711
+ list = result.pending;
712
+ }
713
+ const item = {
714
+ provider,
715
+ prefix,
716
+ name
717
+ };
718
+ list.push(item);
719
+ });
720
+ return result;
721
+ }
722
+ function removeCallback(storages, id) {
723
+ storages.forEach((storage2) => {
724
+ const items = storage2.loaderCallbacks;
725
+ if (items) {
726
+ storage2.loaderCallbacks = items.filter((row) => row.id !== id);
727
+ }
728
+ });
729
+ }
730
+ function updateCallbacks(storage2) {
731
+ if (!storage2.pendingCallbacksFlag) {
732
+ storage2.pendingCallbacksFlag = true;
733
+ setTimeout(() => {
734
+ storage2.pendingCallbacksFlag = false;
735
+ const items = storage2.loaderCallbacks ? storage2.loaderCallbacks.slice(0) : [];
736
+ if (!items.length) {
737
+ return;
738
+ }
739
+ let hasPending = false;
740
+ const provider = storage2.provider;
741
+ const prefix = storage2.prefix;
742
+ items.forEach((item) => {
743
+ const icons = item.icons;
744
+ const oldLength = icons.pending.length;
745
+ icons.pending = icons.pending.filter((icon) => {
746
+ if (icon.prefix !== prefix) {
747
+ return true;
748
+ }
749
+ const name = icon.name;
750
+ if (storage2.icons[name]) {
751
+ icons.loaded.push({
752
+ provider,
753
+ prefix,
754
+ name
755
+ });
756
+ } else if (storage2.missing.has(name)) {
757
+ icons.missing.push({
758
+ provider,
759
+ prefix,
760
+ name
761
+ });
762
+ } else {
763
+ hasPending = true;
764
+ return true;
765
+ }
766
+ return false;
767
+ });
768
+ if (icons.pending.length !== oldLength) {
769
+ if (!hasPending) {
770
+ removeCallback([storage2], item.id);
771
+ }
772
+ item.callback(
773
+ icons.loaded.slice(0),
774
+ icons.missing.slice(0),
775
+ icons.pending.slice(0),
776
+ item.abort
777
+ );
778
+ }
779
+ });
780
+ });
781
+ }
782
+ }
783
+ var idCounter = 0;
784
+ function storeCallback(callback, icons, pendingSources) {
785
+ const id = idCounter++;
786
+ const abort = removeCallback.bind(null, pendingSources, id);
787
+ if (!icons.pending.length) {
788
+ return abort;
789
+ }
790
+ const item = {
791
+ id,
792
+ icons,
793
+ callback,
794
+ abort
795
+ };
796
+ pendingSources.forEach((storage2) => {
797
+ (storage2.loaderCallbacks || (storage2.loaderCallbacks = [])).push(item);
798
+ });
799
+ return abort;
800
+ }
801
+ var storage = /* @__PURE__ */ Object.create(null);
802
+ function setAPIModule(provider, item) {
803
+ storage[provider] = item;
804
+ }
805
+ function getAPIModule(provider) {
806
+ return storage[provider] || storage[""];
807
+ }
808
+ function listToIcons(list, validate = true, simpleNames2 = false) {
809
+ const result = [];
810
+ list.forEach((item) => {
811
+ const icon = typeof item === "string" ? stringToIcon(item, validate, simpleNames2) : item;
812
+ if (icon) {
813
+ result.push(icon);
814
+ }
815
+ });
816
+ return result;
817
+ }
818
+ var defaultConfig = {
819
+ resources: [],
820
+ index: 0,
821
+ timeout: 2e3,
822
+ rotate: 750,
823
+ random: false,
824
+ dataAfterTimeout: false
825
+ };
826
+ function sendQuery(config, payload, query, done) {
827
+ const resourcesCount = config.resources.length;
828
+ const startIndex = config.random ? Math.floor(Math.random() * resourcesCount) : config.index;
829
+ let resources;
830
+ if (config.random) {
831
+ let list = config.resources.slice(0);
832
+ resources = [];
833
+ while (list.length > 1) {
834
+ const nextIndex = Math.floor(Math.random() * list.length);
835
+ resources.push(list[nextIndex]);
836
+ list = list.slice(0, nextIndex).concat(list.slice(nextIndex + 1));
837
+ }
838
+ resources = resources.concat(list);
839
+ } else {
840
+ resources = config.resources.slice(startIndex).concat(config.resources.slice(0, startIndex));
841
+ }
842
+ const startTime = Date.now();
843
+ let status = "pending";
844
+ let queriesSent = 0;
845
+ let lastError;
846
+ let timer = null;
847
+ let queue = [];
848
+ let doneCallbacks = [];
849
+ if (typeof done === "function") {
850
+ doneCallbacks.push(done);
851
+ }
852
+ function resetTimer() {
853
+ if (timer) {
854
+ clearTimeout(timer);
855
+ timer = null;
856
+ }
857
+ }
858
+ function abort() {
859
+ if (status === "pending") {
860
+ status = "aborted";
861
+ }
862
+ resetTimer();
863
+ queue.forEach((item) => {
864
+ if (item.status === "pending") {
865
+ item.status = "aborted";
866
+ }
867
+ });
868
+ queue = [];
869
+ }
870
+ function subscribe(callback, overwrite) {
871
+ if (overwrite) {
872
+ doneCallbacks = [];
873
+ }
874
+ if (typeof callback === "function") {
875
+ doneCallbacks.push(callback);
876
+ }
877
+ }
878
+ function getQueryStatus() {
879
+ return {
880
+ startTime,
881
+ payload,
882
+ status,
883
+ queriesSent,
884
+ queriesPending: queue.length,
885
+ subscribe,
886
+ abort
887
+ };
888
+ }
889
+ function failQuery() {
890
+ status = "failed";
891
+ doneCallbacks.forEach((callback) => {
892
+ callback(void 0, lastError);
893
+ });
894
+ }
895
+ function clearQueue() {
896
+ queue.forEach((item) => {
897
+ if (item.status === "pending") {
898
+ item.status = "aborted";
899
+ }
900
+ });
901
+ queue = [];
902
+ }
903
+ function moduleResponse(item, response, data) {
904
+ const isError = response !== "success";
905
+ queue = queue.filter((queued) => queued !== item);
906
+ switch (status) {
907
+ case "pending":
908
+ break;
909
+ case "failed":
910
+ if (isError || !config.dataAfterTimeout) {
911
+ return;
912
+ }
913
+ break;
914
+ default:
915
+ return;
916
+ }
917
+ if (response === "abort") {
918
+ lastError = data;
919
+ failQuery();
920
+ return;
921
+ }
922
+ if (isError) {
923
+ lastError = data;
924
+ if (!queue.length) {
925
+ if (!resources.length) {
926
+ failQuery();
927
+ } else {
928
+ execNext();
929
+ }
930
+ }
931
+ return;
932
+ }
933
+ resetTimer();
934
+ clearQueue();
935
+ if (!config.random) {
936
+ const index = config.resources.indexOf(item.resource);
937
+ if (index !== -1 && index !== config.index) {
938
+ config.index = index;
939
+ }
940
+ }
941
+ status = "completed";
942
+ doneCallbacks.forEach((callback) => {
943
+ callback(data);
944
+ });
945
+ }
946
+ function execNext() {
947
+ if (status !== "pending") {
948
+ return;
949
+ }
950
+ resetTimer();
951
+ const resource = resources.shift();
952
+ if (resource === void 0) {
953
+ if (queue.length) {
954
+ timer = setTimeout(() => {
955
+ resetTimer();
956
+ if (status === "pending") {
957
+ clearQueue();
958
+ failQuery();
959
+ }
960
+ }, config.timeout);
961
+ return;
962
+ }
963
+ failQuery();
964
+ return;
965
+ }
966
+ const item = {
967
+ status: "pending",
968
+ resource,
969
+ callback: (status2, data) => {
970
+ moduleResponse(item, status2, data);
971
+ }
972
+ };
973
+ queue.push(item);
974
+ queriesSent++;
975
+ timer = setTimeout(execNext, config.rotate);
976
+ query(resource, payload, item.callback);
977
+ }
978
+ setTimeout(execNext);
979
+ return getQueryStatus;
980
+ }
981
+ function initRedundancy(cfg) {
982
+ const config = {
983
+ ...defaultConfig,
984
+ ...cfg
985
+ };
986
+ let queries = [];
987
+ function cleanup() {
988
+ queries = queries.filter((item) => item().status === "pending");
989
+ }
990
+ function query(payload, queryCallback, doneCallback) {
991
+ const query2 = sendQuery(
992
+ config,
993
+ payload,
994
+ queryCallback,
995
+ (data, error) => {
996
+ cleanup();
997
+ if (doneCallback) {
998
+ doneCallback(data, error);
999
+ }
1000
+ }
1001
+ );
1002
+ queries.push(query2);
1003
+ return query2;
1004
+ }
1005
+ function find(callback) {
1006
+ return queries.find((value) => {
1007
+ return callback(value);
1008
+ }) || null;
1009
+ }
1010
+ const instance = {
1011
+ query,
1012
+ find,
1013
+ setIndex: (index) => {
1014
+ config.index = index;
1015
+ },
1016
+ getIndex: () => config.index,
1017
+ cleanup
1018
+ };
1019
+ return instance;
1020
+ }
1021
+ function createAPIConfig(source) {
1022
+ let resources;
1023
+ if (typeof source.resources === "string") {
1024
+ resources = [source.resources];
1025
+ } else {
1026
+ resources = source.resources;
1027
+ if (!(resources instanceof Array) || !resources.length) {
1028
+ return null;
1029
+ }
1030
+ }
1031
+ const result = {
1032
+ resources,
1033
+ path: source.path || "/",
1034
+ maxURL: source.maxURL || 500,
1035
+ rotate: source.rotate || 750,
1036
+ timeout: source.timeout || 5e3,
1037
+ random: source.random === true,
1038
+ index: source.index || 0,
1039
+ dataAfterTimeout: source.dataAfterTimeout !== false
1040
+ };
1041
+ return result;
1042
+ }
1043
+ var configStorage = /* @__PURE__ */ Object.create(null);
1044
+ var fallBackAPISources = [
1045
+ "https://api.simplesvg.com",
1046
+ "https://api.unisvg.com"
1047
+ ];
1048
+ var fallBackAPI = [];
1049
+ while (fallBackAPISources.length > 0) {
1050
+ if (fallBackAPISources.length === 1) {
1051
+ fallBackAPI.push(fallBackAPISources.shift());
1052
+ } else {
1053
+ if (Math.random() > 0.5) {
1054
+ fallBackAPI.push(fallBackAPISources.shift());
1055
+ } else {
1056
+ fallBackAPI.push(fallBackAPISources.pop());
1057
+ }
1058
+ }
1059
+ }
1060
+ configStorage[""] = createAPIConfig({
1061
+ resources: ["https://api.iconify.design"].concat(fallBackAPI)
1062
+ });
1063
+ function addAPIProvider$1(provider, customConfig) {
1064
+ const config = createAPIConfig(customConfig);
1065
+ if (config === null) {
1066
+ return false;
1067
+ }
1068
+ configStorage[provider] = config;
1069
+ return true;
1070
+ }
1071
+ function getAPIConfig(provider) {
1072
+ return configStorage[provider];
1073
+ }
1074
+ function listAPIProviders() {
1075
+ return Object.keys(configStorage);
1076
+ }
1077
+ function emptyCallback$1() {
1078
+ }
1079
+ var redundancyCache = /* @__PURE__ */ Object.create(null);
1080
+ function getRedundancyCache(provider) {
1081
+ if (!redundancyCache[provider]) {
1082
+ const config = getAPIConfig(provider);
1083
+ if (!config) {
1084
+ return;
1085
+ }
1086
+ const redundancy = initRedundancy(config);
1087
+ const cachedReundancy = {
1088
+ config,
1089
+ redundancy
1090
+ };
1091
+ redundancyCache[provider] = cachedReundancy;
1092
+ }
1093
+ return redundancyCache[provider];
1094
+ }
1095
+ function sendAPIQuery(target, query, callback) {
1096
+ let redundancy;
1097
+ let send2;
1098
+ if (typeof target === "string") {
1099
+ const api = getAPIModule(target);
1100
+ if (!api) {
1101
+ callback(void 0, 424);
1102
+ return emptyCallback$1;
1103
+ }
1104
+ send2 = api.send;
1105
+ const cached = getRedundancyCache(target);
1106
+ if (cached) {
1107
+ redundancy = cached.redundancy;
1108
+ }
1109
+ } else {
1110
+ const config = createAPIConfig(target);
1111
+ if (config) {
1112
+ redundancy = initRedundancy(config);
1113
+ const moduleKey = target.resources ? target.resources[0] : "";
1114
+ const api = getAPIModule(moduleKey);
1115
+ if (api) {
1116
+ send2 = api.send;
1117
+ }
1118
+ }
1119
+ }
1120
+ if (!redundancy || !send2) {
1121
+ callback(void 0, 424);
1122
+ return emptyCallback$1;
1123
+ }
1124
+ return redundancy.query(query, send2, callback)().abort;
1125
+ }
1126
+ var browserCacheVersion = "iconify2";
1127
+ var browserCachePrefix = "iconify";
1128
+ var browserCacheCountKey = browserCachePrefix + "-count";
1129
+ var browserCacheVersionKey = browserCachePrefix + "-version";
1130
+ var browserStorageHour = 36e5;
1131
+ var browserStorageCacheExpiration = 168;
1132
+ function getStoredItem(func, key) {
1133
+ try {
1134
+ return func.getItem(key);
1135
+ } catch (err) {
1136
+ }
1137
+ }
1138
+ function setStoredItem(func, key, value) {
1139
+ try {
1140
+ func.setItem(key, value);
1141
+ return true;
1142
+ } catch (err) {
1143
+ }
1144
+ }
1145
+ function removeStoredItem(func, key) {
1146
+ try {
1147
+ func.removeItem(key);
1148
+ } catch (err) {
1149
+ }
1150
+ }
1151
+ function setBrowserStorageItemsCount(storage2, value) {
1152
+ return setStoredItem(storage2, browserCacheCountKey, value.toString());
1153
+ }
1154
+ function getBrowserStorageItemsCount(storage2) {
1155
+ return parseInt(getStoredItem(storage2, browserCacheCountKey)) || 0;
1156
+ }
1157
+ var browserStorageConfig = {
1158
+ local: true,
1159
+ session: true
1160
+ };
1161
+ var browserStorageEmptyItems = {
1162
+ local: /* @__PURE__ */ new Set(),
1163
+ session: /* @__PURE__ */ new Set()
1164
+ };
1165
+ var browserStorageStatus = false;
1166
+ function setBrowserStorageStatus(status) {
1167
+ browserStorageStatus = status;
1168
+ }
1169
+ var _window = typeof window === "undefined" ? {} : window;
1170
+ function getBrowserStorage(key) {
1171
+ const attr = key + "Storage";
1172
+ try {
1173
+ if (_window && _window[attr] && typeof _window[attr].length === "number") {
1174
+ return _window[attr];
1175
+ }
1176
+ } catch (err) {
1177
+ }
1178
+ browserStorageConfig[key] = false;
1179
+ }
1180
+ function iterateBrowserStorage(key, callback) {
1181
+ const func = getBrowserStorage(key);
1182
+ if (!func) {
1183
+ return;
1184
+ }
1185
+ const version = getStoredItem(func, browserCacheVersionKey);
1186
+ if (version !== browserCacheVersion) {
1187
+ if (version) {
1188
+ const total2 = getBrowserStorageItemsCount(func);
1189
+ for (let i = 0; i < total2; i++) {
1190
+ removeStoredItem(func, browserCachePrefix + i.toString());
1191
+ }
1192
+ }
1193
+ setStoredItem(func, browserCacheVersionKey, browserCacheVersion);
1194
+ setBrowserStorageItemsCount(func, 0);
1195
+ return;
1196
+ }
1197
+ const minTime = Math.floor(Date.now() / browserStorageHour) - browserStorageCacheExpiration;
1198
+ const parseItem = (index) => {
1199
+ const name = browserCachePrefix + index.toString();
1200
+ const item = getStoredItem(func, name);
1201
+ if (typeof item !== "string") {
1202
+ return;
1203
+ }
1204
+ try {
1205
+ const data = JSON.parse(item);
1206
+ if (typeof data === "object" && typeof data.cached === "number" && data.cached > minTime && typeof data.provider === "string" && typeof data.data === "object" && typeof data.data.prefix === "string" && callback(data, index)) {
1207
+ return true;
1208
+ }
1209
+ } catch (err) {
1210
+ }
1211
+ removeStoredItem(func, name);
1212
+ };
1213
+ let total = getBrowserStorageItemsCount(func);
1214
+ for (let i = total - 1; i >= 0; i--) {
1215
+ if (!parseItem(i)) {
1216
+ if (i === total - 1) {
1217
+ total--;
1218
+ setBrowserStorageItemsCount(func, total);
1219
+ } else {
1220
+ browserStorageEmptyItems[key].add(i);
1221
+ }
1222
+ }
1223
+ }
1224
+ }
1225
+ function initBrowserStorage() {
1226
+ if (browserStorageStatus) {
1227
+ return;
1228
+ }
1229
+ setBrowserStorageStatus(true);
1230
+ for (const key in browserStorageConfig) {
1231
+ iterateBrowserStorage(key, (item) => {
1232
+ const iconSet = item.data;
1233
+ const provider = item.provider;
1234
+ const prefix = iconSet.prefix;
1235
+ const storage2 = getStorage(
1236
+ provider,
1237
+ prefix
1238
+ );
1239
+ if (!addIconSet(storage2, iconSet).length) {
1240
+ return false;
1241
+ }
1242
+ const lastModified = iconSet.lastModified || -1;
1243
+ storage2.lastModifiedCached = storage2.lastModifiedCached ? Math.min(storage2.lastModifiedCached, lastModified) : lastModified;
1244
+ return true;
1245
+ });
1246
+ }
1247
+ }
1248
+ function updateLastModified(storage2, lastModified) {
1249
+ const lastValue = storage2.lastModifiedCached;
1250
+ if (lastValue && lastValue >= lastModified) {
1251
+ return lastValue === lastModified;
1252
+ }
1253
+ storage2.lastModifiedCached = lastModified;
1254
+ if (lastValue) {
1255
+ for (const key in browserStorageConfig) {
1256
+ iterateBrowserStorage(key, (item) => {
1257
+ const iconSet = item.data;
1258
+ return item.provider !== storage2.provider || iconSet.prefix !== storage2.prefix || iconSet.lastModified === lastModified;
1259
+ });
1260
+ }
1261
+ }
1262
+ return true;
1263
+ }
1264
+ function storeInBrowserStorage(storage2, data) {
1265
+ if (!browserStorageStatus) {
1266
+ initBrowserStorage();
1267
+ }
1268
+ function store(key) {
1269
+ let func;
1270
+ if (!browserStorageConfig[key] || !(func = getBrowserStorage(key))) {
1271
+ return;
1272
+ }
1273
+ const set = browserStorageEmptyItems[key];
1274
+ let index;
1275
+ if (set.size) {
1276
+ set.delete(index = Array.from(set).shift());
1277
+ } else {
1278
+ index = getBrowserStorageItemsCount(func);
1279
+ if (!setBrowserStorageItemsCount(func, index + 1)) {
1280
+ return;
1281
+ }
1282
+ }
1283
+ const item = {
1284
+ cached: Math.floor(Date.now() / browserStorageHour),
1285
+ provider: storage2.provider,
1286
+ data
1287
+ };
1288
+ return setStoredItem(
1289
+ func,
1290
+ browserCachePrefix + index.toString(),
1291
+ JSON.stringify(item)
1292
+ );
1293
+ }
1294
+ if (data.lastModified && !updateLastModified(storage2, data.lastModified)) {
1295
+ return;
1296
+ }
1297
+ if (!Object.keys(data.icons).length) {
1298
+ return;
1299
+ }
1300
+ if (data.not_found) {
1301
+ data = Object.assign({}, data);
1302
+ delete data.not_found;
1303
+ }
1304
+ if (!store("local")) {
1305
+ store("session");
1306
+ }
1307
+ }
1308
+ function emptyCallback() {
1309
+ }
1310
+ function loadedNewIcons(storage2) {
1311
+ if (!storage2.iconsLoaderFlag) {
1312
+ storage2.iconsLoaderFlag = true;
1313
+ setTimeout(() => {
1314
+ storage2.iconsLoaderFlag = false;
1315
+ updateCallbacks(storage2);
1316
+ });
1317
+ }
1318
+ }
1319
+ function loadNewIcons(storage2, icons) {
1320
+ if (!storage2.iconsToLoad) {
1321
+ storage2.iconsToLoad = icons;
1322
+ } else {
1323
+ storage2.iconsToLoad = storage2.iconsToLoad.concat(icons).sort();
1324
+ }
1325
+ if (!storage2.iconsQueueFlag) {
1326
+ storage2.iconsQueueFlag = true;
1327
+ setTimeout(() => {
1328
+ storage2.iconsQueueFlag = false;
1329
+ const { provider, prefix } = storage2;
1330
+ const icons2 = storage2.iconsToLoad;
1331
+ delete storage2.iconsToLoad;
1332
+ let api;
1333
+ if (!icons2 || !(api = getAPIModule(provider))) {
1334
+ return;
1335
+ }
1336
+ const params = api.prepare(provider, prefix, icons2);
1337
+ params.forEach((item) => {
1338
+ sendAPIQuery(provider, item, (data) => {
1339
+ if (typeof data !== "object") {
1340
+ item.icons.forEach((name) => {
1341
+ storage2.missing.add(name);
1342
+ });
1343
+ } else {
1344
+ try {
1345
+ const parsed = addIconSet(
1346
+ storage2,
1347
+ data
1348
+ );
1349
+ if (!parsed.length) {
1350
+ return;
1351
+ }
1352
+ const pending = storage2.pendingIcons;
1353
+ if (pending) {
1354
+ parsed.forEach((name) => {
1355
+ pending.delete(name);
1356
+ });
1357
+ }
1358
+ storeInBrowserStorage(storage2, data);
1359
+ } catch (err) {
1360
+ console.error(err);
1361
+ }
1362
+ }
1363
+ loadedNewIcons(storage2);
1364
+ });
1365
+ });
1366
+ });
1367
+ }
1368
+ }
1369
+ var loadIcons$1 = (icons, callback) => {
1370
+ const cleanedIcons = listToIcons(icons, true, allowSimpleNames());
1371
+ const sortedIcons = sortIcons(cleanedIcons);
1372
+ if (!sortedIcons.pending.length) {
1373
+ let callCallback = true;
1374
+ if (callback) {
1375
+ setTimeout(() => {
1376
+ if (callCallback) {
1377
+ callback(
1378
+ sortedIcons.loaded,
1379
+ sortedIcons.missing,
1380
+ sortedIcons.pending,
1381
+ emptyCallback
1382
+ );
1383
+ }
1384
+ });
1385
+ }
1386
+ return () => {
1387
+ callCallback = false;
1388
+ };
1389
+ }
1390
+ const newIcons = /* @__PURE__ */ Object.create(null);
1391
+ const sources = [];
1392
+ let lastProvider, lastPrefix;
1393
+ sortedIcons.pending.forEach((icon) => {
1394
+ const { provider, prefix } = icon;
1395
+ if (prefix === lastPrefix && provider === lastProvider) {
1396
+ return;
1397
+ }
1398
+ lastProvider = provider;
1399
+ lastPrefix = prefix;
1400
+ sources.push(getStorage(provider, prefix));
1401
+ const providerNewIcons = newIcons[provider] || (newIcons[provider] = /* @__PURE__ */ Object.create(null));
1402
+ if (!providerNewIcons[prefix]) {
1403
+ providerNewIcons[prefix] = [];
1404
+ }
1405
+ });
1406
+ sortedIcons.pending.forEach((icon) => {
1407
+ const { provider, prefix, name } = icon;
1408
+ const storage2 = getStorage(provider, prefix);
1409
+ const pendingQueue = storage2.pendingIcons || (storage2.pendingIcons = /* @__PURE__ */ new Set());
1410
+ if (!pendingQueue.has(name)) {
1411
+ pendingQueue.add(name);
1412
+ newIcons[provider][prefix].push(name);
1413
+ }
1414
+ });
1415
+ sources.forEach((storage2) => {
1416
+ const { provider, prefix } = storage2;
1417
+ if (newIcons[provider][prefix].length) {
1418
+ loadNewIcons(storage2, newIcons[provider][prefix]);
1419
+ }
1420
+ });
1421
+ return callback ? storeCallback(callback, sortedIcons, sources) : emptyCallback;
1422
+ };
1423
+ var loadIcon$1 = (icon) => {
1424
+ return new Promise((fulfill, reject) => {
1425
+ const iconObj = typeof icon === "string" ? stringToIcon(icon, true) : icon;
1426
+ if (!iconObj) {
1427
+ reject(icon);
1428
+ return;
1429
+ }
1430
+ loadIcons$1([iconObj || icon], (loaded) => {
1431
+ if (loaded.length && iconObj) {
1432
+ const data = getIconData(iconObj);
1433
+ if (data) {
1434
+ fulfill({
1435
+ ...defaultIconProps,
1436
+ ...data
1437
+ });
1438
+ return;
1439
+ }
1440
+ }
1441
+ reject(icon);
1442
+ });
1443
+ });
1444
+ };
1445
+ function testIconObject(value) {
1446
+ try {
1447
+ const obj = typeof value === "string" ? JSON.parse(value) : value;
1448
+ if (typeof obj.body === "string") {
1449
+ return {
1450
+ ...obj
1451
+ };
1452
+ }
1453
+ } catch (err) {
1454
+ }
1455
+ }
1456
+ function parseIconValue(value, onload) {
1457
+ const name = typeof value === "string" ? stringToIcon(value, true, true) : null;
1458
+ if (!name) {
1459
+ const data2 = testIconObject(value);
1460
+ return {
1461
+ value,
1462
+ data: data2
1463
+ };
1464
+ }
1465
+ const data = getIconData(name);
1466
+ if (data !== void 0 || !name.prefix) {
1467
+ return {
1468
+ value,
1469
+ name,
1470
+ data
1471
+ };
1472
+ }
1473
+ const loading = loadIcons$1([name], () => onload(value, name, getIconData(name)));
1474
+ return {
1475
+ value,
1476
+ name,
1477
+ loading
1478
+ };
1479
+ }
1480
+ function getInline(node) {
1481
+ return node.hasAttribute("inline");
1482
+ }
1483
+ var isBuggedSafari = false;
1484
+ try {
1485
+ isBuggedSafari = navigator.vendor.indexOf("Apple") === 0;
1486
+ } catch (err) {
1487
+ }
1488
+ function getRenderMode(body, mode) {
1489
+ switch (mode) {
1490
+ case "svg":
1491
+ case "bg":
1492
+ case "mask":
1493
+ return mode;
1494
+ }
1495
+ if (mode !== "style" && (isBuggedSafari || body.indexOf("<a") === -1)) {
1496
+ return "svg";
1497
+ }
1498
+ return body.indexOf("currentColor") === -1 ? "bg" : "mask";
1499
+ }
1500
+ var unitsSplit = /(-?[0-9.]*[0-9]+[0-9.]*)/g;
1501
+ var unitsTest = /^-?[0-9.]*[0-9]+[0-9.]*$/g;
1502
+ function calculateSize$1(size, ratio, precision) {
1503
+ if (ratio === 1) {
1504
+ return size;
1505
+ }
1506
+ precision = precision || 100;
1507
+ if (typeof size === "number") {
1508
+ return Math.ceil(size * ratio * precision) / precision;
1509
+ }
1510
+ if (typeof size !== "string") {
1511
+ return size;
1512
+ }
1513
+ const oldParts = size.split(unitsSplit);
1514
+ if (oldParts === null || !oldParts.length) {
1515
+ return size;
1516
+ }
1517
+ const newParts = [];
1518
+ let code = oldParts.shift();
1519
+ let isNumber = unitsTest.test(code);
1520
+ while (true) {
1521
+ if (isNumber) {
1522
+ const num = parseFloat(code);
1523
+ if (isNaN(num)) {
1524
+ newParts.push(code);
1525
+ } else {
1526
+ newParts.push(Math.ceil(num * ratio * precision) / precision);
1527
+ }
1528
+ } else {
1529
+ newParts.push(code);
1530
+ }
1531
+ code = oldParts.shift();
1532
+ if (code === void 0) {
1533
+ return newParts.join("");
1534
+ }
1535
+ isNumber = !isNumber;
1536
+ }
1537
+ }
1538
+ var isUnsetKeyword = (value) => value === "unset" || value === "undefined" || value === "none";
1539
+ function iconToSVG(icon, customisations) {
1540
+ const fullIcon = {
1541
+ ...defaultIconProps,
1542
+ ...icon
1543
+ };
1544
+ const fullCustomisations = {
1545
+ ...defaultIconCustomisations,
1546
+ ...customisations
1547
+ };
1548
+ const box = {
1549
+ left: fullIcon.left,
1550
+ top: fullIcon.top,
1551
+ width: fullIcon.width,
1552
+ height: fullIcon.height
1553
+ };
1554
+ let body = fullIcon.body;
1555
+ [fullIcon, fullCustomisations].forEach((props) => {
1556
+ const transformations = [];
1557
+ const hFlip = props.hFlip;
1558
+ const vFlip = props.vFlip;
1559
+ let rotation = props.rotate;
1560
+ if (hFlip) {
1561
+ if (vFlip) {
1562
+ rotation += 2;
1563
+ } else {
1564
+ transformations.push(
1565
+ "translate(" + (box.width + box.left).toString() + " " + (0 - box.top).toString() + ")"
1566
+ );
1567
+ transformations.push("scale(-1 1)");
1568
+ box.top = box.left = 0;
1569
+ }
1570
+ } else if (vFlip) {
1571
+ transformations.push(
1572
+ "translate(" + (0 - box.left).toString() + " " + (box.height + box.top).toString() + ")"
1573
+ );
1574
+ transformations.push("scale(1 -1)");
1575
+ box.top = box.left = 0;
1576
+ }
1577
+ let tempValue;
1578
+ if (rotation < 0) {
1579
+ rotation -= Math.floor(rotation / 4) * 4;
1580
+ }
1581
+ rotation = rotation % 4;
1582
+ switch (rotation) {
1583
+ case 1:
1584
+ tempValue = box.height / 2 + box.top;
1585
+ transformations.unshift(
1586
+ "rotate(90 " + tempValue.toString() + " " + tempValue.toString() + ")"
1587
+ );
1588
+ break;
1589
+ case 2:
1590
+ transformations.unshift(
1591
+ "rotate(180 " + (box.width / 2 + box.left).toString() + " " + (box.height / 2 + box.top).toString() + ")"
1592
+ );
1593
+ break;
1594
+ case 3:
1595
+ tempValue = box.width / 2 + box.left;
1596
+ transformations.unshift(
1597
+ "rotate(-90 " + tempValue.toString() + " " + tempValue.toString() + ")"
1598
+ );
1599
+ break;
1600
+ }
1601
+ if (rotation % 2 === 1) {
1602
+ if (box.left !== box.top) {
1603
+ tempValue = box.left;
1604
+ box.left = box.top;
1605
+ box.top = tempValue;
1606
+ }
1607
+ if (box.width !== box.height) {
1608
+ tempValue = box.width;
1609
+ box.width = box.height;
1610
+ box.height = tempValue;
1611
+ }
1612
+ }
1613
+ if (transformations.length) {
1614
+ body = '<g transform="' + transformations.join(" ") + '">' + body + "</g>";
1615
+ }
1616
+ });
1617
+ const customisationsWidth = fullCustomisations.width;
1618
+ const customisationsHeight = fullCustomisations.height;
1619
+ const boxWidth = box.width;
1620
+ const boxHeight = box.height;
1621
+ let width;
1622
+ let height;
1623
+ if (customisationsWidth === null) {
1624
+ height = customisationsHeight === null ? "1em" : customisationsHeight === "auto" ? boxHeight : customisationsHeight;
1625
+ width = calculateSize$1(height, boxWidth / boxHeight);
1626
+ } else {
1627
+ width = customisationsWidth === "auto" ? boxWidth : customisationsWidth;
1628
+ height = customisationsHeight === null ? calculateSize$1(width, boxHeight / boxWidth) : customisationsHeight === "auto" ? boxHeight : customisationsHeight;
1629
+ }
1630
+ const attributes = {};
1631
+ const setAttr = (prop, value) => {
1632
+ if (!isUnsetKeyword(value)) {
1633
+ attributes[prop] = value.toString();
1634
+ }
1635
+ };
1636
+ setAttr("width", width);
1637
+ setAttr("height", height);
1638
+ attributes.viewBox = box.left.toString() + " " + box.top.toString() + " " + boxWidth.toString() + " " + boxHeight.toString();
1639
+ return {
1640
+ attributes,
1641
+ body
1642
+ };
1643
+ }
1644
+ var detectFetch = () => {
1645
+ let callback;
1646
+ try {
1647
+ callback = fetch;
1648
+ if (typeof callback === "function") {
1649
+ return callback;
1650
+ }
1651
+ } catch (err) {
1652
+ }
1653
+ };
1654
+ var fetchModule = detectFetch();
1655
+ function setFetch(fetch2) {
1656
+ fetchModule = fetch2;
1657
+ }
1658
+ function getFetch() {
1659
+ return fetchModule;
1660
+ }
1661
+ function calculateMaxLength(provider, prefix) {
1662
+ const config = getAPIConfig(provider);
1663
+ if (!config) {
1664
+ return 0;
1665
+ }
1666
+ let result;
1667
+ if (!config.maxURL) {
1668
+ result = 0;
1669
+ } else {
1670
+ let maxHostLength = 0;
1671
+ config.resources.forEach((item) => {
1672
+ const host = item;
1673
+ maxHostLength = Math.max(maxHostLength, host.length);
1674
+ });
1675
+ const url = prefix + ".json?icons=";
1676
+ result = config.maxURL - maxHostLength - config.path.length - url.length;
1677
+ }
1678
+ return result;
1679
+ }
1680
+ function shouldAbort(status) {
1681
+ return status === 404;
1682
+ }
1683
+ var prepare = (provider, prefix, icons) => {
1684
+ const results = [];
1685
+ const maxLength = calculateMaxLength(provider, prefix);
1686
+ const type = "icons";
1687
+ let item = {
1688
+ type,
1689
+ provider,
1690
+ prefix,
1691
+ icons: []
1692
+ };
1693
+ let length = 0;
1694
+ icons.forEach((name, index) => {
1695
+ length += name.length + 1;
1696
+ if (length >= maxLength && index > 0) {
1697
+ results.push(item);
1698
+ item = {
1699
+ type,
1700
+ provider,
1701
+ prefix,
1702
+ icons: []
1703
+ };
1704
+ length = name.length;
1705
+ }
1706
+ item.icons.push(name);
1707
+ });
1708
+ results.push(item);
1709
+ return results;
1710
+ };
1711
+ function getPath(provider) {
1712
+ if (typeof provider === "string") {
1713
+ const config = getAPIConfig(provider);
1714
+ if (config) {
1715
+ return config.path;
1716
+ }
1717
+ }
1718
+ return "/";
1719
+ }
1720
+ var send = (host, params, callback) => {
1721
+ if (!fetchModule) {
1722
+ callback("abort", 424);
1723
+ return;
1724
+ }
1725
+ let path = getPath(params.provider);
1726
+ switch (params.type) {
1727
+ case "icons": {
1728
+ const prefix = params.prefix;
1729
+ const icons = params.icons;
1730
+ const iconsList = icons.join(",");
1731
+ const urlParams = new URLSearchParams({
1732
+ icons: iconsList
1733
+ });
1734
+ path += prefix + ".json?" + urlParams.toString();
1735
+ break;
1736
+ }
1737
+ case "custom": {
1738
+ const uri = params.uri;
1739
+ path += uri.slice(0, 1) === "/" ? uri.slice(1) : uri;
1740
+ break;
1741
+ }
1742
+ default:
1743
+ callback("abort", 400);
1744
+ return;
1745
+ }
1746
+ let defaultError = 503;
1747
+ fetchModule(host + path).then((response) => {
1748
+ const status = response.status;
1749
+ if (status !== 200) {
1750
+ setTimeout(() => {
1751
+ callback(shouldAbort(status) ? "abort" : "next", status);
1752
+ });
1753
+ return;
1754
+ }
1755
+ defaultError = 501;
1756
+ return response.json();
1757
+ }).then((data) => {
1758
+ if (typeof data !== "object" || data === null) {
1759
+ setTimeout(() => {
1760
+ if (data === 404) {
1761
+ callback("abort", data);
1762
+ } else {
1763
+ callback("next", defaultError);
1764
+ }
1765
+ });
1766
+ return;
1767
+ }
1768
+ setTimeout(() => {
1769
+ callback("success", data);
1770
+ });
1771
+ }).catch(() => {
1772
+ callback("next", defaultError);
1773
+ });
1774
+ };
1775
+ var fetchAPIModule = {
1776
+ prepare,
1777
+ send
1778
+ };
1779
+ function toggleBrowserCache(storage2, value) {
1780
+ switch (storage2) {
1781
+ case "local":
1782
+ case "session":
1783
+ browserStorageConfig[storage2] = value;
1784
+ break;
1785
+ case "all":
1786
+ for (const key in browserStorageConfig) {
1787
+ browserStorageConfig[key] = value;
1788
+ }
1789
+ break;
1790
+ }
1791
+ }
1792
+ var nodeAttr = "data-style";
1793
+ var customStyle = "";
1794
+ function appendCustomStyle(style) {
1795
+ customStyle = style;
1796
+ }
1797
+ function updateStyle(parent, inline) {
1798
+ let styleNode = Array.from(parent.childNodes).find((node) => node.hasAttribute && node.hasAttribute(nodeAttr));
1799
+ if (!styleNode) {
1800
+ styleNode = document.createElement("style");
1801
+ styleNode.setAttribute(nodeAttr, nodeAttr);
1802
+ parent.appendChild(styleNode);
1803
+ }
1804
+ styleNode.textContent = ":host{display:inline-block;vertical-align:" + (inline ? "-0.125em" : "0") + "}span,svg{display:block}" + customStyle;
1805
+ }
1806
+ function exportFunctions() {
1807
+ setAPIModule("", fetchAPIModule);
1808
+ allowSimpleNames(true);
1809
+ let _window2;
1810
+ try {
1811
+ _window2 = window;
1812
+ } catch (err) {
1813
+ }
1814
+ if (_window2) {
1815
+ initBrowserStorage();
1816
+ if (_window2.IconifyPreload !== void 0) {
1817
+ const preload = _window2.IconifyPreload;
1818
+ const err = "Invalid IconifyPreload syntax.";
1819
+ if (typeof preload === "object" && preload !== null) {
1820
+ (preload instanceof Array ? preload : [preload]).forEach((item) => {
1821
+ try {
1822
+ if (typeof item !== "object" || item === null || item instanceof Array || typeof item.icons !== "object" || typeof item.prefix !== "string" || !addCollection$1(item)) {
1823
+ console.error(err);
1824
+ }
1825
+ } catch (e) {
1826
+ console.error(err);
1827
+ }
1828
+ });
1829
+ }
1830
+ }
1831
+ if (_window2.IconifyProviders !== void 0) {
1832
+ const providers = _window2.IconifyProviders;
1833
+ if (typeof providers === "object" && providers !== null) {
1834
+ for (const key in providers) {
1835
+ const err = "IconifyProviders[" + key + "] is invalid.";
1836
+ try {
1837
+ const value = providers[key];
1838
+ if (typeof value !== "object" || !value || value.resources === void 0) {
1839
+ continue;
1840
+ }
1841
+ if (!addAPIProvider$1(key, value)) {
1842
+ console.error(err);
1843
+ }
1844
+ } catch (e) {
1845
+ console.error(err);
1846
+ }
1847
+ }
1848
+ }
1849
+ }
1850
+ }
1851
+ const _api2 = {
1852
+ getAPIConfig,
1853
+ setAPIModule,
1854
+ sendAPIQuery,
1855
+ setFetch,
1856
+ getFetch,
1857
+ listAPIProviders
1858
+ };
1859
+ return {
1860
+ enableCache: (storage2) => toggleBrowserCache(storage2, true),
1861
+ disableCache: (storage2) => toggleBrowserCache(storage2, false),
1862
+ iconExists: iconExists$1,
1863
+ getIcon: getIcon$1,
1864
+ listIcons: listIcons$1,
1865
+ addIcon: addIcon$1,
1866
+ addCollection: addCollection$1,
1867
+ calculateSize: calculateSize$1,
1868
+ buildIcon: iconToSVG,
1869
+ loadIcons: loadIcons$1,
1870
+ loadIcon: loadIcon$1,
1871
+ addAPIProvider: addAPIProvider$1,
1872
+ appendCustomStyle,
1873
+ _api: _api2
1874
+ };
1875
+ }
1876
+ function iconToHTML(body, attributes) {
1877
+ let renderAttribsHTML = body.indexOf("xlink:") === -1 ? "" : ' xmlns:xlink="http://www.w3.org/1999/xlink"';
1878
+ for (const attr in attributes) {
1879
+ renderAttribsHTML += " " + attr + '="' + attributes[attr] + '"';
1880
+ }
1881
+ return '<svg xmlns="http://www.w3.org/2000/svg"' + renderAttribsHTML + ">" + body + "</svg>";
1882
+ }
1883
+ function encodeSVGforURL(svg) {
1884
+ return svg.replace(/"/g, "'").replace(/%/g, "%25").replace(/#/g, "%23").replace(/</g, "%3C").replace(/>/g, "%3E").replace(/\s+/g, " ");
1885
+ }
1886
+ function svgToURL(svg) {
1887
+ return 'url("data:image/svg+xml,' + encodeSVGforURL(svg) + '")';
1888
+ }
1889
+ var monotoneProps = {
1890
+ "background-color": "currentColor"
1891
+ };
1892
+ var coloredProps = {
1893
+ "background-color": "transparent"
1894
+ };
1895
+ var propsToAdd = {
1896
+ image: "var(--svg)",
1897
+ repeat: "no-repeat",
1898
+ size: "100% 100%"
1899
+ };
1900
+ var propsToAddTo = {
1901
+ "-webkit-mask": monotoneProps,
1902
+ "mask": monotoneProps,
1903
+ "background": coloredProps
1904
+ };
1905
+ for (const prefix in propsToAddTo) {
1906
+ const list = propsToAddTo[prefix];
1907
+ for (const prop in propsToAdd) {
1908
+ list[prefix + "-" + prop] = propsToAdd[prop];
1909
+ }
1910
+ }
1911
+ function fixSize(value) {
1912
+ return value + (value.match(/^[-0-9.]+$/) ? "px" : "");
1913
+ }
1914
+ function renderSPAN(data, icon, useMask) {
1915
+ const node = document.createElement("span");
1916
+ let body = data.body;
1917
+ if (body.indexOf("<a") !== -1) {
1918
+ body += "<!-- " + Date.now() + " -->";
1919
+ }
1920
+ const renderAttribs = data.attributes;
1921
+ const html = iconToHTML(body, {
1922
+ ...renderAttribs,
1923
+ width: icon.width + "",
1924
+ height: icon.height + ""
1925
+ });
1926
+ const url = svgToURL(html);
1927
+ const svgStyle = node.style;
1928
+ const styles = {
1929
+ "--svg": url,
1930
+ "width": fixSize(renderAttribs.width),
1931
+ "height": fixSize(renderAttribs.height),
1932
+ ...useMask ? monotoneProps : coloredProps
1933
+ };
1934
+ for (const prop in styles) {
1935
+ svgStyle.setProperty(prop, styles[prop]);
1936
+ }
1937
+ return node;
1938
+ }
1939
+ function renderSVG(data) {
1940
+ const node = document.createElement("span");
1941
+ node.innerHTML = iconToHTML(data.body, data.attributes);
1942
+ return node.firstChild;
1943
+ }
1944
+ function renderIcon(parent, state) {
1945
+ const iconData = state.icon.data;
1946
+ const customisations = state.customisations;
1947
+ const renderData = iconToSVG(iconData, customisations);
1948
+ if (customisations.preserveAspectRatio) {
1949
+ renderData.attributes["preserveAspectRatio"] = customisations.preserveAspectRatio;
1950
+ }
1951
+ const mode = state.renderedMode;
1952
+ let node;
1953
+ switch (mode) {
1954
+ case "svg":
1955
+ node = renderSVG(renderData);
1956
+ break;
1957
+ default:
1958
+ node = renderSPAN(renderData, {
1959
+ ...defaultIconProps,
1960
+ ...iconData
1961
+ }, mode === "mask");
1962
+ }
1963
+ const oldNode = Array.from(parent.childNodes).find((node2) => {
1964
+ const tag = node2.tagName && node2.tagName.toUpperCase();
1965
+ return tag === "SPAN" || tag === "SVG";
1966
+ });
1967
+ if (oldNode) {
1968
+ if (node.tagName === "SPAN" && oldNode.tagName === node.tagName) {
1969
+ oldNode.setAttribute("style", node.getAttribute("style"));
1970
+ } else {
1971
+ parent.replaceChild(node, oldNode);
1972
+ }
1973
+ } else {
1974
+ parent.appendChild(node);
1975
+ }
1976
+ }
1977
+ function setPendingState(icon, inline, lastState) {
1978
+ const lastRender = lastState && (lastState.rendered ? lastState : lastState.lastRender);
1979
+ return {
1980
+ rendered: false,
1981
+ inline,
1982
+ icon,
1983
+ lastRender
1984
+ };
1985
+ }
1986
+ function defineIconifyIcon(name = "iconify-icon") {
1987
+ let customElements;
1988
+ let ParentClass;
1989
+ try {
1990
+ customElements = window.customElements;
1991
+ ParentClass = window.HTMLElement;
1992
+ } catch (err) {
1993
+ return;
1994
+ }
1995
+ if (!customElements || !ParentClass) {
1996
+ return;
1997
+ }
1998
+ const ConflictingClass = customElements.get(name);
1999
+ if (ConflictingClass) {
2000
+ return ConflictingClass;
2001
+ }
2002
+ const attributes = [
2003
+ "icon",
2004
+ "mode",
2005
+ "inline",
2006
+ "width",
2007
+ "height",
2008
+ "rotate",
2009
+ "flip"
2010
+ ];
2011
+ const IconifyIcon = class extends ParentClass {
2012
+ constructor() {
2013
+ super();
2014
+ __publicField(this, "_shadowRoot");
2015
+ __publicField(this, "_state");
2016
+ __publicField(this, "_checkQueued", false);
2017
+ const root = this._shadowRoot = this.attachShadow({
2018
+ mode: "open"
2019
+ });
2020
+ const inline = getInline(this);
2021
+ updateStyle(root, inline);
2022
+ this._state = setPendingState({
2023
+ value: ""
2024
+ }, inline);
2025
+ this._queueCheck();
2026
+ }
2027
+ static get observedAttributes() {
2028
+ return attributes.slice(0);
2029
+ }
2030
+ attributeChangedCallback(name2) {
2031
+ if (name2 === "inline") {
2032
+ const newInline = getInline(this);
2033
+ const state = this._state;
2034
+ if (newInline !== state.inline) {
2035
+ state.inline = newInline;
2036
+ updateStyle(this._shadowRoot, newInline);
2037
+ }
2038
+ } else {
2039
+ this._queueCheck();
2040
+ }
2041
+ }
2042
+ get icon() {
2043
+ const value = this.getAttribute("icon");
2044
+ if (value && value.slice(0, 1) === "{") {
2045
+ try {
2046
+ return JSON.parse(value);
2047
+ } catch (err) {
2048
+ }
2049
+ }
2050
+ return value;
2051
+ }
2052
+ set icon(value) {
2053
+ if (typeof value === "object") {
2054
+ value = JSON.stringify(value);
2055
+ }
2056
+ this.setAttribute("icon", value);
2057
+ }
2058
+ get inline() {
2059
+ return getInline(this);
2060
+ }
2061
+ set inline(value) {
2062
+ this.setAttribute("inline", value ? "true" : null);
2063
+ }
2064
+ restartAnimation() {
2065
+ const state = this._state;
2066
+ if (state.rendered) {
2067
+ const root = this._shadowRoot;
2068
+ if (state.renderedMode === "svg") {
2069
+ try {
2070
+ root.lastChild.setCurrentTime(0);
2071
+ return;
2072
+ } catch (err) {
2073
+ }
2074
+ }
2075
+ renderIcon(root, state);
2076
+ }
2077
+ }
2078
+ get status() {
2079
+ const state = this._state;
2080
+ return state.rendered ? "rendered" : state.icon.data === null ? "failed" : "loading";
2081
+ }
2082
+ _queueCheck() {
2083
+ if (!this._checkQueued) {
2084
+ this._checkQueued = true;
2085
+ setTimeout(() => {
2086
+ this._check();
2087
+ });
2088
+ }
2089
+ }
2090
+ _check() {
2091
+ if (!this._checkQueued) {
2092
+ return;
2093
+ }
2094
+ this._checkQueued = false;
2095
+ const state = this._state;
2096
+ const newIcon = this.getAttribute("icon");
2097
+ if (newIcon !== state.icon.value) {
2098
+ this._iconChanged(newIcon);
2099
+ return;
2100
+ }
2101
+ if (!state.rendered) {
2102
+ return;
2103
+ }
2104
+ const mode = this.getAttribute("mode");
2105
+ const customisations = getCustomisations(this);
2106
+ if (state.attrMode !== mode || haveCustomisationsChanged(state.customisations, customisations)) {
2107
+ this._renderIcon(state.icon, customisations, mode);
2108
+ }
2109
+ }
2110
+ _iconChanged(newValue) {
2111
+ const icon = parseIconValue(newValue, (value, name2, data) => {
2112
+ const state = this._state;
2113
+ if (state.rendered || this.getAttribute("icon") !== value) {
2114
+ return;
2115
+ }
2116
+ const icon2 = {
2117
+ value,
2118
+ name: name2,
2119
+ data
2120
+ };
2121
+ if (icon2.data) {
2122
+ this._gotIconData(icon2);
2123
+ } else {
2124
+ state.icon = icon2;
2125
+ }
2126
+ });
2127
+ if (icon.data) {
2128
+ this._gotIconData(icon);
2129
+ } else {
2130
+ this._state = setPendingState(icon, this._state.inline, this._state);
2131
+ }
2132
+ }
2133
+ _gotIconData(icon) {
2134
+ this._checkQueued = false;
2135
+ this._renderIcon(icon, getCustomisations(this), this.getAttribute("mode"));
2136
+ }
2137
+ _renderIcon(icon, customisations, attrMode) {
2138
+ const renderedMode = getRenderMode(icon.data.body, attrMode);
2139
+ const inline = this._state.inline;
2140
+ renderIcon(this._shadowRoot, this._state = {
2141
+ rendered: true,
2142
+ icon,
2143
+ inline,
2144
+ customisations,
2145
+ attrMode,
2146
+ renderedMode
2147
+ });
2148
+ }
2149
+ };
2150
+ attributes.forEach((attr) => {
2151
+ if (!(attr in IconifyIcon.prototype)) {
2152
+ Object.defineProperty(IconifyIcon.prototype, attr, {
2153
+ get: function() {
2154
+ return this.getAttribute(attr);
2155
+ },
2156
+ set: function(value) {
2157
+ this.setAttribute(attr, value);
2158
+ }
2159
+ });
2160
+ }
2161
+ });
2162
+ const functions = exportFunctions();
2163
+ for (const key in functions) {
2164
+ IconifyIcon[key] = IconifyIcon.prototype[key] = functions[key];
2165
+ }
2166
+ customElements.define(name, IconifyIcon);
2167
+ return IconifyIcon;
2168
+ }
2169
+ var IconifyIconComponent = defineIconifyIcon() || exportFunctions();
2170
+ var { enableCache, disableCache, iconExists, getIcon, listIcons, addIcon, addCollection, calculateSize, buildIcon, loadIcons, loadIcon, addAPIProvider, _api } = IconifyIconComponent;
2171
+
2172
+ // ../../node_modules/@iconify-icon/react/dist/iconify.mjs
2173
+ var Icon = React3.forwardRef(
2174
+ (props, ref) => {
2175
+ const newProps = {
2176
+ ...props,
2177
+ ref
2178
+ };
2179
+ if (typeof props.icon === "object") {
2180
+ newProps.icon = JSON.stringify(props.icon);
2181
+ }
2182
+ if (!props.inline) {
2183
+ delete newProps.inline;
2184
+ }
2185
+ if (props.className) {
2186
+ newProps["class"] = props.className;
2187
+ }
2188
+ return React3.createElement("iconify-icon", newProps);
2189
+ }
2190
+ );
2191
+
270
2192
  // src/components/Icon.tsx
271
- import { Icon as IconUI } from "@iconify/react";
272
2193
  import { jsx as jsx3 } from "react/jsx-runtime";
273
- var Icon = ({ icon, sx, iconProps, ...props }) => {
274
- return /* @__PURE__ */ jsx3(Text, { sx, ...props, children: /* @__PURE__ */ jsx3(IconUI, { ...iconProps, icon }) });
2194
+ var Icon2 = (props) => {
2195
+ return /* @__PURE__ */ jsx3(Icon, { ...props });
275
2196
  };
276
2197
 
277
2198
  // src/components/Slider.tsx
@@ -281,12 +2202,12 @@ import { Slider } from "theme-ui";
281
2202
  import { Checkbox } from "theme-ui";
282
2203
 
283
2204
  // src/components/InfiniteLinearProgress.tsx
284
- import * as React3 from "react";
2205
+ import * as React4 from "react";
285
2206
  import { jsx as jsx4 } from "react/jsx-runtime";
286
2207
  var MAX_PROGRESS = 100;
287
2208
  var InfiniteLinearProgress = () => {
288
- const [progress, setProgress] = React3.useState(0);
289
- React3.useEffect(() => {
2209
+ const [progress, setProgress] = React4.useState(0);
2210
+ React4.useEffect(() => {
290
2211
  const timer = setInterval(() => {
291
2212
  setProgress((oldProgress) => {
292
2213
  if (oldProgress === MAX_PROGRESS) {
@@ -312,16 +2233,20 @@ var InfiniteLinearProgress = () => {
312
2233
 
313
2234
  // src/components/Textarea.tsx
314
2235
  import { Textarea } from "theme-ui";
2236
+
2237
+ // src/components/Container.tsx
2238
+ import { Container } from "theme-ui";
315
2239
  export {
316
2240
  Box,
317
2241
  Button,
318
2242
  Card,
319
2243
  Checkbox,
2244
+ Container,
320
2245
  Divider,
321
2246
  Flex,
322
2247
  Grid,
323
2248
  Heading,
324
- Icon,
2249
+ Icon2 as Icon,
325
2250
  Image,
326
2251
  InfiniteLinearProgress,
327
2252
  Input,
@@ -339,3 +2264,14 @@ export {
339
2264
  useResponsiveValue,
340
2265
  useTheme
341
2266
  };
2267
+ /**
2268
+ * (c) Iconify
2269
+ *
2270
+ * For the full copyright and license information, please view the license.txt
2271
+ * files at https://github.com/iconify/iconify
2272
+ *
2273
+ * Licensed under MIT.
2274
+ *
2275
+ * @license MIT
2276
+ * @version 1.0.3
2277
+ */