@ttoss/layouts 0.11.20 → 0.11.21

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