@ttoss/forms 0.22.2 → 0.22.3

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