@exyconn/common 1.0.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/README.md +121 -36
  2. package/dist/client/index.d.mts +2 -2
  3. package/dist/client/index.d.ts +2 -2
  4. package/dist/client/index.js +2330 -176
  5. package/dist/client/index.js.map +1 -1
  6. package/dist/client/index.mjs +2284 -178
  7. package/dist/client/index.mjs.map +1 -1
  8. package/dist/client/utils/index.d.mts +123 -1
  9. package/dist/client/utils/index.d.ts +123 -1
  10. package/dist/client/utils/index.js +207 -0
  11. package/dist/client/utils/index.js.map +1 -1
  12. package/dist/client/utils/index.mjs +204 -1
  13. package/dist/client/utils/index.mjs.map +1 -1
  14. package/dist/index-BLltj-zN.d.ts +1236 -0
  15. package/dist/index-CIUdLBjA.d.mts +1236 -0
  16. package/dist/{index-iTKxFa78.d.ts → index-DEzgM15j.d.ts} +10 -2
  17. package/dist/{index-ClWtDfwk.d.ts → index-DNFVgQx8.d.ts} +544 -2
  18. package/dist/{index-CcrANHAQ.d.mts → index-DbV04Dx8.d.mts} +10 -2
  19. package/dist/{index-DSW6JfD-.d.mts → index-DfqEP6Oe.d.mts} +544 -2
  20. package/dist/index.d.mts +582 -7
  21. package/dist/index.d.ts +582 -7
  22. package/dist/index.js +3428 -221
  23. package/dist/index.js.map +1 -1
  24. package/dist/index.mjs +3430 -223
  25. package/dist/index.mjs.map +1 -1
  26. package/dist/server/index.d.mts +1 -1
  27. package/dist/server/index.d.ts +1 -1
  28. package/dist/server/index.js +197 -0
  29. package/dist/server/index.js.map +1 -1
  30. package/dist/server/index.mjs +194 -2
  31. package/dist/server/index.mjs.map +1 -1
  32. package/dist/server/utils/index.d.mts +73 -1
  33. package/dist/server/utils/index.d.ts +73 -1
  34. package/dist/server/utils/index.js +199 -0
  35. package/dist/server/utils/index.js.map +1 -1
  36. package/dist/server/utils/index.mjs +195 -1
  37. package/dist/server/utils/index.mjs.map +1 -1
  38. package/dist/shared/index.d.mts +1 -1
  39. package/dist/shared/index.d.ts +1 -1
  40. package/dist/shared/index.js +296 -0
  41. package/dist/shared/index.js.map +1 -1
  42. package/dist/shared/index.mjs +274 -1
  43. package/dist/shared/index.mjs.map +1 -1
  44. package/package.json +9 -2
  45. package/dist/index-BNdT-2X4.d.ts +0 -229
  46. package/dist/index-Du0LLt9f.d.mts +0 -229
package/dist/index.mjs CHANGED
@@ -1,10 +1,11 @@
1
1
  import winston from 'winston';
2
2
  import DailyRotateFile from 'winston-daily-rotate-file';
3
- import path from 'path';
3
+ import path, { resolve } from 'path';
4
4
  import mongoose from 'mongoose';
5
5
  import jwt from 'jsonwebtoken';
6
+ import { existsSync, readFileSync } from 'fs';
6
7
  import axios from 'axios';
7
- import { useCallback, useState, useEffect, useRef } from 'react';
8
+ import { useState, useCallback, useMemo, useRef, useEffect } from 'react';
8
9
  import { subYears, subWeeks, subMonths, subMinutes, subHours, subDays, startOfYear, startOfWeek, startOfMonth, startOfDay as startOfDay$1, setSeconds, setMinutes, setHours, parseISO, isYesterday, isValid, isTomorrow, isToday as isToday$1, isThisYear, isThisWeek, isThisMonth, isSameYear, isSameWeek, isSameMonth, isSameDay, isPast as isPast$1, isFuture as isFuture$1, isEqual, isBefore, isAfter, intervalToDuration, getYear, getSeconds, getMonth, getMinutes, getHours, getDay, getDate, formatRelative, formatDuration, formatDistanceToNow, formatDistance, format, endOfYear, endOfWeek, endOfMonth, endOfDay as endOfDay$1, eachWeekOfInterval, eachMonthOfInterval, eachDayOfInterval, differenceInYears, differenceInWeeks, differenceInSeconds, differenceInMonths, differenceInMinutes, differenceInHours, differenceInDays, addYears, addWeeks, addMonths, addMinutes, addHours, addDays as addDays$1 } from 'date-fns';
9
10
  import { toZonedTime, fromZonedTime, formatInTimeZone } from 'date-fns-tz';
10
11
 
@@ -25,6 +26,7 @@ __export(server_exports, {
25
26
  buildFilter: () => buildFilter,
26
27
  buildPagination: () => buildPagination,
27
28
  buildPaginationMeta: () => buildPaginationMeta,
29
+ checkPackageServer: () => checkPackageServer,
28
30
  conflictResponse: () => conflictResponse,
29
31
  connectDB: () => connectDB,
30
32
  createLogger: () => createLogger,
@@ -35,13 +37,17 @@ __export(server_exports, {
35
37
  extractColumns: () => extractColumns,
36
38
  extractOrganization: () => extractOrganization,
37
39
  forbiddenResponse: () => forbiddenResponse,
40
+ formatPackageCheckResult: () => formatPackageCheckResult,
41
+ generateNcuCommand: () => generateNcuCommand,
38
42
  getConnectionStatus: () => getConnectionStatus,
39
43
  logger: () => logger,
40
44
  noContentResponse: () => noContentResponse,
41
45
  notFoundResponse: () => notFoundResponse,
42
46
  omitFields: () => omitFields,
43
47
  optionalAuthenticateJWT: () => optionalAuthenticateJWT,
48
+ packageCheckServer: () => packageCheckServer,
44
49
  pickFields: () => pickFields,
50
+ printPackageCheckSummary: () => printPackageCheckSummary,
45
51
  rateLimitResponse: () => rateLimitResponse,
46
52
  requireOrganization: () => requireOrganization,
47
53
  sanitizeDocument: () => sanitizeDocument,
@@ -569,6 +575,197 @@ var omitFields = (obj, fieldsToOmit) => {
569
575
  });
570
576
  return result;
571
577
  };
578
+ function parseVersion(version) {
579
+ return version.replace(/[\^~>=<|*x\s]/g, "").split(" ")[0] || "0.0.0";
580
+ }
581
+ function compareVersions(current, latest) {
582
+ const currentClean = parseVersion(current);
583
+ const latestClean = parseVersion(latest);
584
+ if (currentClean === latestClean) return "none";
585
+ const [curMajor, curMinor, curPatch] = currentClean.split(".").map(Number);
586
+ const [latMajor, latMinor, latPatch] = latestClean.split(".").map(Number);
587
+ if (latest.includes("-")) return "prerelease";
588
+ if (latMajor > curMajor) return "major";
589
+ if (latMinor > curMinor) return "minor";
590
+ if (latPatch > curPatch) return "patch";
591
+ return "none";
592
+ }
593
+ async function fetchLatestVersion(packageName) {
594
+ try {
595
+ const encodedName = packageName.startsWith("@") ? `@${encodeURIComponent(packageName.slice(1))}` : encodeURIComponent(packageName);
596
+ const response = await fetch(`https://registry.npmjs.org/${encodedName}`);
597
+ if (!response.ok) return null;
598
+ const data = await response.json();
599
+ return data["dist-tags"]?.latest || null;
600
+ } catch {
601
+ return null;
602
+ }
603
+ }
604
+ async function loadPackageJson(source) {
605
+ if (typeof source === "object") {
606
+ return source;
607
+ }
608
+ if (source.startsWith("http://") || source.startsWith("https://")) {
609
+ const response = await fetch(source);
610
+ if (!response.ok) {
611
+ throw new Error(`Failed to fetch: ${response.status}`);
612
+ }
613
+ return response.json();
614
+ }
615
+ const filePath = resolve(source);
616
+ if (!existsSync(filePath)) {
617
+ throw new Error(`File not found: ${filePath}`);
618
+ }
619
+ const content = readFileSync(filePath, "utf-8");
620
+ return JSON.parse(content);
621
+ }
622
+ async function checkDeps(deps, type, errors) {
623
+ if (!deps) return [];
624
+ const results = [];
625
+ const entries = Object.entries(deps);
626
+ const concurrencyLimit = 10;
627
+ for (let i = 0; i < entries.length; i += concurrencyLimit) {
628
+ const batch = entries.slice(i, i + concurrencyLimit);
629
+ const batchResults = await Promise.all(
630
+ batch.map(async ([name, currentVersion]) => {
631
+ try {
632
+ const latest = await fetchLatestVersion(name);
633
+ if (!latest) {
634
+ errors.push(`Could not fetch: ${name}`);
635
+ return {
636
+ name,
637
+ current: currentVersion,
638
+ latest: "unknown",
639
+ hasUpdate: false,
640
+ updateType: "none",
641
+ dependencyType: type
642
+ };
643
+ }
644
+ const updateType = compareVersions(currentVersion, latest);
645
+ return {
646
+ name,
647
+ current: currentVersion,
648
+ latest,
649
+ hasUpdate: updateType !== "none",
650
+ updateType,
651
+ dependencyType: type
652
+ };
653
+ } catch (err) {
654
+ errors.push(`Error: ${name} - ${err}`);
655
+ return {
656
+ name,
657
+ current: currentVersion,
658
+ latest: "error",
659
+ hasUpdate: false,
660
+ updateType: "none",
661
+ dependencyType: type
662
+ };
663
+ }
664
+ })
665
+ );
666
+ results.push(...batchResults);
667
+ }
668
+ return results;
669
+ }
670
+ async function checkPackageServer(source) {
671
+ const errors = [];
672
+ const pkg = await loadPackageJson(source);
673
+ const [dependencies, devDependencies, peerDependencies, optionalDependencies] = await Promise.all([
674
+ checkDeps(pkg.dependencies, "dependencies", errors),
675
+ checkDeps(pkg.devDependencies, "devDependencies", errors),
676
+ checkDeps(pkg.peerDependencies, "peerDependencies", errors),
677
+ checkDeps(pkg.optionalDependencies, "optionalDependencies", errors)
678
+ ]);
679
+ const allDeps = [...dependencies, ...devDependencies, ...peerDependencies, ...optionalDependencies];
680
+ return {
681
+ packageName: pkg.name || "unknown",
682
+ packageVersion: pkg.version || "0.0.0",
683
+ totalDependencies: allDeps.length,
684
+ outdatedCount: allDeps.filter((d) => d.hasUpdate).length,
685
+ dependencies: allDeps,
686
+ byType: { dependencies, devDependencies, peerDependencies, optionalDependencies },
687
+ byUpdateType: {
688
+ major: allDeps.filter((d) => d.updateType === "major"),
689
+ minor: allDeps.filter((d) => d.updateType === "minor"),
690
+ patch: allDeps.filter((d) => d.updateType === "patch"),
691
+ prerelease: allDeps.filter((d) => d.updateType === "prerelease")
692
+ },
693
+ checkedAt: /* @__PURE__ */ new Date(),
694
+ errors
695
+ };
696
+ }
697
+ function formatPackageCheckResult(result) {
698
+ const lines = [];
699
+ lines.push(`
700
+ \u{1F4E6} Package: ${result.packageName}@${result.packageVersion}`);
701
+ lines.push(`\u{1F4C5} Checked: ${result.checkedAt.toISOString()}`);
702
+ lines.push(`\u{1F4CA} Total: ${result.totalDependencies} | Outdated: ${result.outdatedCount}
703
+ `);
704
+ const formatDep = (d) => ` ${d.name.padEnd(35)} ${d.current.padEnd(15)} \u2192 ${d.latest}`;
705
+ if (result.byUpdateType.major.length > 0) {
706
+ lines.push("\u{1F534} MAJOR Updates:");
707
+ result.byUpdateType.major.forEach((d) => lines.push(formatDep(d)));
708
+ lines.push("");
709
+ }
710
+ if (result.byUpdateType.minor.length > 0) {
711
+ lines.push("\u{1F7E1} MINOR Updates:");
712
+ result.byUpdateType.minor.forEach((d) => lines.push(formatDep(d)));
713
+ lines.push("");
714
+ }
715
+ if (result.byUpdateType.patch.length > 0) {
716
+ lines.push("\u{1F7E2} PATCH Updates:");
717
+ result.byUpdateType.patch.forEach((d) => lines.push(formatDep(d)));
718
+ lines.push("");
719
+ }
720
+ if (result.errors.length > 0) {
721
+ lines.push("\u26A0\uFE0F Errors:");
722
+ result.errors.forEach((e) => lines.push(` ${e}`));
723
+ }
724
+ return lines.join("\n");
725
+ }
726
+ function generateNcuCommand(result, options = {}) {
727
+ const { updateType = "all", interactive = false, upgrade = false } = options;
728
+ let packages = [];
729
+ switch (updateType) {
730
+ case "major":
731
+ packages = result.byUpdateType.major.map((d) => d.name);
732
+ break;
733
+ case "minor":
734
+ packages = result.byUpdateType.minor.map((d) => d.name);
735
+ break;
736
+ case "patch":
737
+ packages = result.byUpdateType.patch.map((d) => d.name);
738
+ break;
739
+ default:
740
+ packages = result.dependencies.filter((d) => d.hasUpdate).map((d) => d.name);
741
+ }
742
+ if (packages.length === 0) return "# No updates available";
743
+ let cmd = "npx npm-check-updates";
744
+ if (packages.length < result.dependencies.length) {
745
+ cmd += ` --filter "${packages.join(",")}"`;
746
+ }
747
+ if (interactive) cmd += " --interactive";
748
+ if (upgrade) cmd += " --upgrade";
749
+ return cmd;
750
+ }
751
+ function printPackageCheckSummary(result) {
752
+ console.log(formatPackageCheckResult(result));
753
+ if (result.outdatedCount > 0) {
754
+ console.log("\n\u{1F4DD} Quick Commands:");
755
+ console.log(" Check all: npx npm-check-updates");
756
+ console.log(" Interactive: npx npm-check-updates --interactive");
757
+ console.log(" Update all: npx npm-check-updates --upgrade && npm install");
758
+ if (result.byUpdateType.patch.length > 0) {
759
+ console.log(` Patch only: ${generateNcuCommand(result, { updateType: "patch", upgrade: true })}`);
760
+ }
761
+ }
762
+ }
763
+ var packageCheckServer = {
764
+ check: checkPackageServer,
765
+ format: formatPackageCheckResult,
766
+ generateNcuCommand,
767
+ print: printPackageCheckSummary
768
+ };
572
769
 
573
770
  // src/client/index.ts
574
771
  var client_exports = {};
@@ -581,6 +778,7 @@ __export(client_exports, {
581
778
  camelToKebab: () => camelToKebab,
582
779
  capitalize: () => capitalize,
583
780
  capitalizeWords: () => capitalizeWords,
781
+ checkPackage: () => checkPackage,
584
782
  clientLogger: () => clientLogger,
585
783
  copyToClipboard: () => copyToClipboard,
586
784
  createApiEndpoints: () => createApiEndpoints,
@@ -596,7 +794,9 @@ __export(client_exports, {
596
794
  formatDateForInput: () => formatDateForInput,
597
795
  formatDateTime: () => formatDateTime,
598
796
  formatDateTimeForInput: () => formatDateTimeForInput,
797
+ formatPackageCheckResult: () => formatPackageCheckResult2,
599
798
  formatRelativeTime: () => formatRelativeTime,
799
+ generateNcuCommand: () => generateNcuCommand2,
600
800
  getErrorMessage: () => getErrorMessage,
601
801
  getNextPage: () => getNextPage,
602
802
  getPrevPage: () => getPrevPage,
@@ -616,6 +816,7 @@ __export(client_exports, {
616
816
  isToday: () => isToday,
617
817
  isUnauthorized: () => isUnauthorized,
618
818
  kebabToCamel: () => kebabToCamel,
819
+ packageCheck: () => packageCheck,
619
820
  parseError: () => parseError,
620
821
  parseFullResponse: () => parseFullResponse,
621
822
  parseResponse: () => parseResponse,
@@ -626,19 +827,63 @@ __export(client_exports, {
626
827
  truncate: () => truncate,
627
828
  truncateWords: () => truncateWords,
628
829
  unslugify: () => unslugify,
830
+ useBattery: () => useBattery_default,
831
+ useClickAway: () => useClickAway_default,
832
+ useContinuousRetry: () => useContinuousRetry_default,
629
833
  useCopyToClipboard: () => useCopyToClipboard_default,
834
+ useCountdown: () => useCountdown_default,
835
+ useCounter: () => useCounter_default,
630
836
  useDebounce: () => useDebounce_default,
837
+ useDefault: () => useDefault_default,
838
+ useDocumentTitle: () => useDocumentTitle_default,
839
+ useEventListener: () => useEventListener_default,
840
+ useFavicon: () => useFavicon_default,
841
+ useFetch: () => useFetch_default,
842
+ useGeolocation: () => useGeolocation_default,
843
+ useHistoryState: () => useHistoryState_default,
844
+ useHover: () => useHover_default,
845
+ useIdle: () => useIdle_default,
846
+ useIntersectionObserver: () => useIntersectionObserver_default,
631
847
  useInterval: () => useInterval_default,
848
+ useIntervalWhen: () => useIntervalWhen_default,
849
+ useIsClient: () => useIsClient_default,
632
850
  useIsDesktop: () => useIsDesktop,
851
+ useIsFirstRender: () => useIsFirstRender_default,
633
852
  useIsMobile: () => useIsMobile,
634
853
  useIsMobileOrTablet: () => useIsMobileOrTablet,
635
854
  useIsTablet: () => useIsTablet,
855
+ useKeyPress: () => useKeyPress_default,
856
+ useList: () => useList_default,
636
857
  useLocalStorage: () => useLocalStorage_default,
858
+ useLockBodyScroll: () => useLockBodyScroll_default,
859
+ useLogger: () => useLogger_default,
860
+ useLongPress: () => useLongPress_default,
861
+ useMap: () => useMap_default,
862
+ useMeasure: () => useMeasure_default,
637
863
  useMediaQuery: () => useMediaQuery_default,
864
+ useMouse: () => useMouse_default,
865
+ useNetworkState: () => useNetworkState_default,
866
+ useObjectState: () => useObjectState_default,
638
867
  useOnClickOutside: () => useOnClickOutside_default,
868
+ useOrientation: () => useOrientation_default,
869
+ usePageLeave: () => usePageLeave_default,
639
870
  usePageTitle: () => usePageTitle_default,
871
+ usePreferredLanguage: () => usePreferredLanguage_default,
872
+ usePrevious: () => usePrevious_default,
873
+ useQueue: () => useQueue_default,
874
+ useRandomInterval: () => useRandomInterval_default,
875
+ useRenderCount: () => useRenderCount_default,
876
+ useRenderInfo: () => useRenderInfo_default,
877
+ useScript: () => useScript_default,
878
+ useSessionStorage: () => useSessionStorage_default,
879
+ useSet: () => useSet_default,
640
880
  useSnackbar: () => useSnackbar_default,
641
881
  useThemeDetector: () => useThemeDetector_default,
882
+ useThrottle: () => useThrottle_default,
883
+ useTimeout: () => useTimeout_default,
884
+ useToggle: () => useToggle_default,
885
+ useVisibilityChange: () => useVisibilityChange_default,
886
+ useWindowScroll: () => useWindowScroll_default,
642
887
  useWindowSize: () => useWindowSize_default,
643
888
  withAbortSignal: () => withAbortSignal,
644
889
  withFormData: () => withFormData,
@@ -1218,93 +1463,608 @@ var createErrorResponse = (message, statusCode2 = 400, error) => ({
1218
1463
  error,
1219
1464
  statusCode: statusCode2
1220
1465
  });
1221
- function useLocalStorage(key, initialValue, options = {}) {
1222
- const {
1223
- serializer = JSON.stringify,
1224
- deserializer = JSON.parse,
1225
- syncTabs = true,
1226
- debug = false
1227
- } = options;
1228
- const log = useCallback(
1229
- (...args) => {
1230
- if (debug) console.log(`[useLocalStorage:${key}]`, ...args);
1231
- },
1232
- [debug, key]
1233
- );
1234
- const readValue = useCallback(() => {
1235
- if (typeof window === "undefined") {
1236
- return initialValue;
1466
+
1467
+ // src/client/utils/packageCheck.ts
1468
+ function parseVersion2(version) {
1469
+ return version.replace(/[\^~>=<|*x\s]/g, "").split(" ")[0] || "0.0.0";
1470
+ }
1471
+ function compareVersions2(current, latest) {
1472
+ const currentClean = parseVersion2(current);
1473
+ const latestClean = parseVersion2(latest);
1474
+ if (currentClean === latestClean) return "none";
1475
+ const [curMajor, curMinor, curPatch] = currentClean.split(".").map(Number);
1476
+ const [latMajor, latMinor, latPatch] = latestClean.split(".").map(Number);
1477
+ if (latest.includes("-")) return "prerelease";
1478
+ if (latMajor > curMajor) return "major";
1479
+ if (latMinor > curMinor) return "minor";
1480
+ if (latPatch > curPatch) return "patch";
1481
+ return "none";
1482
+ }
1483
+ async function fetchLatestVersion2(packageName) {
1484
+ try {
1485
+ const encodedName = packageName.startsWith("@") ? `@${encodeURIComponent(packageName.slice(1))}` : encodeURIComponent(packageName);
1486
+ const response = await fetch(`https://registry.npmjs.org/${encodedName}`);
1487
+ if (!response.ok) {
1488
+ return null;
1237
1489
  }
1238
- try {
1239
- const item = window.localStorage.getItem(key);
1240
- if (item === null) {
1241
- return initialValue;
1242
- }
1243
- const parsed = deserializer(item);
1244
- log("Read value:", parsed);
1245
- return parsed;
1246
- } catch (error) {
1247
- console.warn(`Error reading localStorage key "${key}":`, error);
1248
- return initialValue;
1490
+ const data = await response.json();
1491
+ return data["dist-tags"]?.latest || null;
1492
+ } catch {
1493
+ return null;
1494
+ }
1495
+ }
1496
+ async function fetchPackageJson(source) {
1497
+ if (typeof source === "object") {
1498
+ return source;
1499
+ }
1500
+ if (source.startsWith("http://") || source.startsWith("https://")) {
1501
+ const response = await fetch(source);
1502
+ if (!response.ok) {
1503
+ throw new Error(`Failed to fetch package.json from ${source}: ${response.status}`);
1249
1504
  }
1250
- }, [key, initialValue, deserializer, log]);
1251
- const [storedValue, setStoredValue] = useState(readValue);
1252
- const setValue = useCallback(
1505
+ return response.json();
1506
+ }
1507
+ throw new Error(
1508
+ "File path support requires Node.js environment. Use URL or pass package.json object directly."
1509
+ );
1510
+ }
1511
+ async function checkDependencyType(deps, type, errors) {
1512
+ if (!deps) return [];
1513
+ const results = [];
1514
+ const entries = Object.entries(deps);
1515
+ const concurrencyLimit = 10;
1516
+ for (let i = 0; i < entries.length; i += concurrencyLimit) {
1517
+ const batch = entries.slice(i, i + concurrencyLimit);
1518
+ const batchResults = await Promise.all(
1519
+ batch.map(async ([name, currentVersion]) => {
1520
+ try {
1521
+ const latest = await fetchLatestVersion2(name);
1522
+ if (!latest) {
1523
+ errors.push(`Could not fetch latest version for ${name}`);
1524
+ return {
1525
+ name,
1526
+ current: currentVersion,
1527
+ latest: "unknown",
1528
+ hasUpdate: false,
1529
+ updateType: "none",
1530
+ dependencyType: type
1531
+ };
1532
+ }
1533
+ const updateType = compareVersions2(currentVersion, latest);
1534
+ return {
1535
+ name,
1536
+ current: currentVersion,
1537
+ latest,
1538
+ hasUpdate: updateType !== "none",
1539
+ updateType,
1540
+ dependencyType: type
1541
+ };
1542
+ } catch (err) {
1543
+ errors.push(`Error checking ${name}: ${err}`);
1544
+ return {
1545
+ name,
1546
+ current: currentVersion,
1547
+ latest: "error",
1548
+ hasUpdate: false,
1549
+ updateType: "none",
1550
+ dependencyType: type
1551
+ };
1552
+ }
1553
+ })
1554
+ );
1555
+ results.push(...batchResults);
1556
+ }
1557
+ return results;
1558
+ }
1559
+ async function checkPackage(source) {
1560
+ const errors = [];
1561
+ let pkg;
1562
+ try {
1563
+ pkg = await fetchPackageJson(source);
1564
+ } catch (err) {
1565
+ throw new Error(`Failed to load package.json: ${err}`);
1566
+ }
1567
+ const [dependencies, devDependencies, peerDependencies, optionalDependencies] = await Promise.all([
1568
+ checkDependencyType(pkg.dependencies, "dependencies", errors),
1569
+ checkDependencyType(pkg.devDependencies, "devDependencies", errors),
1570
+ checkDependencyType(pkg.peerDependencies, "peerDependencies", errors),
1571
+ checkDependencyType(pkg.optionalDependencies, "optionalDependencies", errors)
1572
+ ]);
1573
+ const allDeps = [...dependencies, ...devDependencies, ...peerDependencies, ...optionalDependencies];
1574
+ return {
1575
+ packageName: pkg.name || "unknown",
1576
+ packageVersion: pkg.version || "0.0.0",
1577
+ totalDependencies: allDeps.length,
1578
+ outdatedCount: allDeps.filter((d) => d.hasUpdate).length,
1579
+ dependencies: allDeps,
1580
+ byType: {
1581
+ dependencies,
1582
+ devDependencies,
1583
+ peerDependencies,
1584
+ optionalDependencies
1585
+ },
1586
+ byUpdateType: {
1587
+ major: allDeps.filter((d) => d.updateType === "major"),
1588
+ minor: allDeps.filter((d) => d.updateType === "minor"),
1589
+ patch: allDeps.filter((d) => d.updateType === "patch"),
1590
+ prerelease: allDeps.filter((d) => d.updateType === "prerelease")
1591
+ },
1592
+ checkedAt: /* @__PURE__ */ new Date(),
1593
+ errors
1594
+ };
1595
+ }
1596
+ function formatPackageCheckResult2(result) {
1597
+ const lines = [];
1598
+ lines.push(`\u{1F4E6} Package: ${result.packageName}@${result.packageVersion}`);
1599
+ lines.push(`\u{1F4C5} Checked: ${result.checkedAt.toISOString()}`);
1600
+ lines.push(`\u{1F4CA} Total: ${result.totalDependencies} | Outdated: ${result.outdatedCount}`);
1601
+ lines.push("");
1602
+ if (result.byUpdateType.major.length > 0) {
1603
+ lines.push("\u{1F534} MAJOR Updates:");
1604
+ result.byUpdateType.major.forEach((d) => {
1605
+ lines.push(` ${d.name}: ${d.current} \u2192 ${d.latest}`);
1606
+ });
1607
+ lines.push("");
1608
+ }
1609
+ if (result.byUpdateType.minor.length > 0) {
1610
+ lines.push("\u{1F7E1} MINOR Updates:");
1611
+ result.byUpdateType.minor.forEach((d) => {
1612
+ lines.push(` ${d.name}: ${d.current} \u2192 ${d.latest}`);
1613
+ });
1614
+ lines.push("");
1615
+ }
1616
+ if (result.byUpdateType.patch.length > 0) {
1617
+ lines.push("\u{1F7E2} PATCH Updates:");
1618
+ result.byUpdateType.patch.forEach((d) => {
1619
+ lines.push(` ${d.name}: ${d.current} \u2192 ${d.latest}`);
1620
+ });
1621
+ lines.push("");
1622
+ }
1623
+ if (result.errors.length > 0) {
1624
+ lines.push("\u26A0\uFE0F Errors:");
1625
+ result.errors.forEach((e) => {
1626
+ lines.push(` ${e}`);
1627
+ });
1628
+ }
1629
+ return lines.join("\n");
1630
+ }
1631
+ function generateNcuCommand2(result, options = {}) {
1632
+ const { updateType = "all", interactive = false, upgrade = false } = options;
1633
+ let packages = [];
1634
+ switch (updateType) {
1635
+ case "major":
1636
+ packages = result.byUpdateType.major.map((d) => d.name);
1637
+ break;
1638
+ case "minor":
1639
+ packages = result.byUpdateType.minor.map((d) => d.name);
1640
+ break;
1641
+ case "patch":
1642
+ packages = result.byUpdateType.patch.map((d) => d.name);
1643
+ break;
1644
+ default:
1645
+ packages = result.dependencies.filter((d) => d.hasUpdate).map((d) => d.name);
1646
+ }
1647
+ if (packages.length === 0) {
1648
+ return "# No updates available";
1649
+ }
1650
+ let cmd = "npx npm-check-updates";
1651
+ if (packages.length > 0 && packages.length < result.dependencies.length) {
1652
+ cmd += ` --filter "${packages.join(",")}"`;
1653
+ }
1654
+ if (interactive) {
1655
+ cmd += " --interactive";
1656
+ }
1657
+ if (upgrade) {
1658
+ cmd += " --upgrade";
1659
+ }
1660
+ return cmd;
1661
+ }
1662
+ var packageCheck = {
1663
+ check: checkPackage,
1664
+ format: formatPackageCheckResult2,
1665
+ generateNcuCommand: generateNcuCommand2,
1666
+ parseVersion: parseVersion2,
1667
+ compareVersions: compareVersions2
1668
+ };
1669
+ function useToggle(initialValue = false) {
1670
+ const [value, setValue] = useState(initialValue);
1671
+ const toggle = useCallback(() => setValue((v) => !v), []);
1672
+ const setTrue = useCallback(() => setValue(true), []);
1673
+ const setFalse = useCallback(() => setValue(false), []);
1674
+ return {
1675
+ value,
1676
+ toggle,
1677
+ setTrue,
1678
+ setFalse,
1679
+ setValue
1680
+ };
1681
+ }
1682
+ var useToggle_default = useToggle;
1683
+ function useCounter(initialValue = 0, options = {}) {
1684
+ const { min = -Infinity, max = Infinity, step = 1 } = options;
1685
+ const clamp = useCallback(
1686
+ (value) => Math.min(Math.max(value, min), max),
1687
+ [min, max]
1688
+ );
1689
+ const [count, setCount] = useState(clamp(initialValue));
1690
+ const increment = useCallback(() => {
1691
+ setCount((c) => clamp(c + step));
1692
+ }, [clamp, step]);
1693
+ const decrement = useCallback(() => {
1694
+ setCount((c) => clamp(c - step));
1695
+ }, [clamp, step]);
1696
+ const set = useCallback(
1253
1697
  (value) => {
1254
- if (typeof window === "undefined") {
1255
- console.warn(`Cannot set localStorage key "${key}" in non-browser environment`);
1256
- return;
1257
- }
1258
- try {
1259
- const valueToStore = value instanceof Function ? value(storedValue) : value;
1260
- setStoredValue(valueToStore);
1261
- window.localStorage.setItem(key, serializer(valueToStore));
1262
- log("Set value:", valueToStore);
1263
- window.dispatchEvent(new StorageEvent("storage", { key, newValue: serializer(valueToStore) }));
1264
- } catch (error) {
1265
- console.warn(`Error setting localStorage key "${key}":`, error);
1266
- }
1698
+ setCount(clamp(value));
1267
1699
  },
1268
- [key, storedValue, serializer, log]
1700
+ [clamp]
1269
1701
  );
1270
- const removeValue = useCallback(() => {
1271
- if (typeof window === "undefined") {
1272
- return;
1273
- }
1274
- try {
1275
- window.localStorage.removeItem(key);
1276
- setStoredValue(initialValue);
1277
- log("Removed value");
1278
- window.dispatchEvent(new StorageEvent("storage", { key, newValue: null }));
1279
- } catch (error) {
1280
- console.warn(`Error removing localStorage key "${key}":`, error);
1281
- }
1282
- }, [key, initialValue, log]);
1702
+ const reset = useCallback(() => {
1703
+ setCount(clamp(initialValue));
1704
+ }, [clamp, initialValue]);
1705
+ return { count, increment, decrement, set, reset };
1706
+ }
1707
+ var useCounter_default = useCounter;
1708
+ function useDefault(initialValue, defaultValue) {
1709
+ const [state, setState] = useState(initialValue);
1710
+ const value = useMemo(() => {
1711
+ return state === null || state === void 0 ? defaultValue : state;
1712
+ }, [state, defaultValue]);
1713
+ const setValue = useCallback((newValue) => {
1714
+ setState(newValue);
1715
+ }, []);
1716
+ return [value, setValue];
1717
+ }
1718
+ var useDefault_default = useDefault;
1719
+ function usePrevious(value, initialValue) {
1720
+ const ref = useRef(initialValue);
1283
1721
  useEffect(() => {
1284
- if (!syncTabs || typeof window === "undefined") {
1285
- return;
1286
- }
1287
- const handleStorageChange = (event) => {
1288
- if (event.key !== key) {
1289
- return;
1722
+ ref.current = value;
1723
+ }, [value]);
1724
+ return ref.current;
1725
+ }
1726
+ var usePrevious_default = usePrevious;
1727
+ function useObjectState(initialState) {
1728
+ const [state, setStateInternal] = useState(initialState);
1729
+ const setState = useCallback((update) => {
1730
+ setStateInternal((prev) => {
1731
+ const newState = typeof update === "function" ? update(prev) : update;
1732
+ return { ...prev, ...newState };
1733
+ });
1734
+ }, []);
1735
+ const resetState = useCallback(() => {
1736
+ setStateInternal(initialState);
1737
+ }, [initialState]);
1738
+ const setProperty = useCallback((key, value) => {
1739
+ setStateInternal((prev) => ({ ...prev, [key]: value }));
1740
+ }, []);
1741
+ const removeProperty = useCallback((key) => {
1742
+ setStateInternal((prev) => {
1743
+ const newState = { ...prev };
1744
+ delete newState[key];
1745
+ return newState;
1746
+ });
1747
+ }, []);
1748
+ return { state, setState, resetState, setProperty, removeProperty };
1749
+ }
1750
+ var useObjectState_default = useObjectState;
1751
+ function useHistoryState(initialValue, options = {}) {
1752
+ const { maxLength = 100 } = options;
1753
+ const [history, setHistory] = useState([initialValue]);
1754
+ const [pointer, setPointer] = useState(0);
1755
+ const state = useMemo(() => history[pointer], [history, pointer]);
1756
+ const setState = useCallback(
1757
+ (value) => {
1758
+ setHistory((prev) => {
1759
+ const currentValue = prev[pointer];
1760
+ const newValue = typeof value === "function" ? value(currentValue) : value;
1761
+ const newHistory = prev.slice(0, pointer + 1);
1762
+ newHistory.push(newValue);
1763
+ if (newHistory.length > maxLength) {
1764
+ newHistory.shift();
1765
+ return newHistory;
1766
+ }
1767
+ return newHistory;
1768
+ });
1769
+ setPointer((prev) => Math.min(prev + 1, maxLength - 1));
1770
+ },
1771
+ [pointer, maxLength]
1772
+ );
1773
+ const undo = useCallback(() => {
1774
+ setPointer((prev) => Math.max(0, prev - 1));
1775
+ }, []);
1776
+ const redo = useCallback(() => {
1777
+ setPointer((prev) => Math.min(history.length - 1, prev + 1));
1778
+ }, [history.length]);
1779
+ const go = useCallback(
1780
+ (index) => {
1781
+ const targetIndex = Math.max(0, Math.min(history.length - 1, index));
1782
+ setPointer(targetIndex);
1783
+ },
1784
+ [history.length]
1785
+ );
1786
+ const clear = useCallback(
1787
+ (value) => {
1788
+ const resetValue = value ?? initialValue;
1789
+ setHistory([resetValue]);
1790
+ setPointer(0);
1791
+ },
1792
+ [initialValue]
1793
+ );
1794
+ const canUndo = pointer > 0;
1795
+ const canRedo = pointer < history.length - 1;
1796
+ return {
1797
+ state,
1798
+ setState,
1799
+ undo,
1800
+ redo,
1801
+ clear,
1802
+ canUndo,
1803
+ canRedo,
1804
+ history,
1805
+ pointer,
1806
+ go
1807
+ };
1808
+ }
1809
+ var useHistoryState_default = useHistoryState;
1810
+ function useQueue(initialValue = []) {
1811
+ const [queue, setQueue] = useState(initialValue);
1812
+ const enqueue = useCallback((item) => {
1813
+ setQueue((prev) => [...prev, item]);
1814
+ }, []);
1815
+ const enqueueAll = useCallback((items) => {
1816
+ setQueue((prev) => [...prev, ...items]);
1817
+ }, []);
1818
+ const dequeue = useCallback(() => {
1819
+ let dequeuedItem;
1820
+ setQueue((prev) => {
1821
+ if (prev.length === 0) return prev;
1822
+ dequeuedItem = prev[0];
1823
+ return prev.slice(1);
1824
+ });
1825
+ return dequeuedItem;
1826
+ }, []);
1827
+ const peek = useCallback(() => {
1828
+ return queue[0];
1829
+ }, [queue]);
1830
+ const clear = useCallback(() => {
1831
+ setQueue([]);
1832
+ }, []);
1833
+ const size = queue.length;
1834
+ const isEmpty = size === 0;
1835
+ const first = queue[0];
1836
+ const last = queue[queue.length - 1];
1837
+ return {
1838
+ queue,
1839
+ enqueue,
1840
+ enqueueAll,
1841
+ dequeue,
1842
+ peek,
1843
+ clear,
1844
+ size,
1845
+ isEmpty,
1846
+ first,
1847
+ last
1848
+ };
1849
+ }
1850
+ var useQueue_default = useQueue;
1851
+ function useList(initialValue = []) {
1852
+ const [list, setList] = useState(initialValue);
1853
+ const set = useCallback((newList) => {
1854
+ setList(newList);
1855
+ }, []);
1856
+ const push = useCallback((item) => {
1857
+ setList((prev) => [...prev, item]);
1858
+ }, []);
1859
+ const unshift = useCallback((item) => {
1860
+ setList((prev) => [item, ...prev]);
1861
+ }, []);
1862
+ const removeAt = useCallback((index) => {
1863
+ setList((prev) => prev.filter((_, i) => i !== index));
1864
+ }, []);
1865
+ const remove = useCallback((item) => {
1866
+ setList((prev) => {
1867
+ const index = prev.indexOf(item);
1868
+ if (index === -1) return prev;
1869
+ return prev.filter((_, i) => i !== index);
1870
+ });
1871
+ }, []);
1872
+ const removeWhere = useCallback((predicate) => {
1873
+ setList((prev) => prev.filter((item) => !predicate(item)));
1874
+ }, []);
1875
+ const updateAt = useCallback((index, item) => {
1876
+ setList((prev) => prev.map((v, i) => i === index ? item : v));
1877
+ }, []);
1878
+ const updateWhere = useCallback(
1879
+ (predicate, updater) => {
1880
+ setList((prev) => prev.map((item) => predicate(item) ? updater(item) : item));
1881
+ },
1882
+ []
1883
+ );
1884
+ const insertAt = useCallback((index, item) => {
1885
+ setList((prev) => [...prev.slice(0, index), item, ...prev.slice(index)]);
1886
+ }, []);
1887
+ const move = useCallback((fromIndex, toIndex) => {
1888
+ setList((prev) => {
1889
+ const newList = [...prev];
1890
+ const [item] = newList.splice(fromIndex, 1);
1891
+ newList.splice(toIndex, 0, item);
1892
+ return newList;
1893
+ });
1894
+ }, []);
1895
+ const clear = useCallback(() => {
1896
+ setList([]);
1897
+ }, []);
1898
+ const reset = useCallback(() => {
1899
+ setList(initialValue);
1900
+ }, [initialValue]);
1901
+ const filter = useCallback((predicate) => {
1902
+ setList((prev) => prev.filter(predicate));
1903
+ }, []);
1904
+ const sort = useCallback((compareFn) => {
1905
+ setList((prev) => [...prev].sort(compareFn));
1906
+ }, []);
1907
+ const reverse = useCallback(() => {
1908
+ setList((prev) => [...prev].reverse());
1909
+ }, []);
1910
+ const size = list.length;
1911
+ const isEmpty = size === 0;
1912
+ const first = list[0];
1913
+ const last = list[list.length - 1];
1914
+ return {
1915
+ list,
1916
+ set,
1917
+ push,
1918
+ unshift,
1919
+ removeAt,
1920
+ remove,
1921
+ removeWhere,
1922
+ updateAt,
1923
+ updateWhere,
1924
+ insertAt,
1925
+ move,
1926
+ clear,
1927
+ reset,
1928
+ filter,
1929
+ sort,
1930
+ reverse,
1931
+ size,
1932
+ isEmpty,
1933
+ first,
1934
+ last
1935
+ };
1936
+ }
1937
+ var useList_default = useList;
1938
+ function useMap(initialValue = []) {
1939
+ const [map, setMap] = useState(() => new Map(initialValue));
1940
+ const get = useCallback((key) => {
1941
+ return map.get(key);
1942
+ }, [map]);
1943
+ const set = useCallback((key, value) => {
1944
+ setMap((prev) => {
1945
+ const newMap = new Map(prev);
1946
+ newMap.set(key, value);
1947
+ return newMap;
1948
+ });
1949
+ }, []);
1950
+ const setAll = useCallback((entries2) => {
1951
+ setMap((prev) => {
1952
+ const newMap = new Map(prev);
1953
+ for (const [key, value] of entries2) {
1954
+ newMap.set(key, value);
1290
1955
  }
1291
- log("Storage event received:", event.newValue);
1292
- if (event.newValue === null) {
1293
- setStoredValue(initialValue);
1956
+ return newMap;
1957
+ });
1958
+ }, []);
1959
+ const has = useCallback((key) => {
1960
+ return map.has(key);
1961
+ }, [map]);
1962
+ const remove = useCallback((key) => {
1963
+ setMap((prev) => {
1964
+ const newMap = new Map(prev);
1965
+ newMap.delete(key);
1966
+ return newMap;
1967
+ });
1968
+ }, []);
1969
+ const removeAll = useCallback((keys2) => {
1970
+ setMap((prev) => {
1971
+ const newMap = new Map(prev);
1972
+ keys2.forEach((key) => newMap.delete(key));
1973
+ return newMap;
1974
+ });
1975
+ }, []);
1976
+ const clear = useCallback(() => {
1977
+ setMap(/* @__PURE__ */ new Map());
1978
+ }, []);
1979
+ const reset = useCallback(() => {
1980
+ setMap(new Map(initialValue));
1981
+ }, [initialValue]);
1982
+ const size = map.size;
1983
+ const keys = useMemo(() => Array.from(map.keys()), [map]);
1984
+ const values = useMemo(() => Array.from(map.values()), [map]);
1985
+ const entries = useMemo(() => Array.from(map.entries()), [map]);
1986
+ const isEmpty = size === 0;
1987
+ return {
1988
+ map,
1989
+ get,
1990
+ set,
1991
+ setAll,
1992
+ has,
1993
+ remove,
1994
+ removeAll,
1995
+ clear,
1996
+ reset,
1997
+ size,
1998
+ keys,
1999
+ values,
2000
+ entries,
2001
+ isEmpty
2002
+ };
2003
+ }
2004
+ var useMap_default = useMap;
2005
+ function useSet(initialValue = []) {
2006
+ const [set, setSet] = useState(() => new Set(initialValue));
2007
+ const add = useCallback((item) => {
2008
+ setSet((prev) => /* @__PURE__ */ new Set([...prev, item]));
2009
+ }, []);
2010
+ const addAll = useCallback((items) => {
2011
+ setSet((prev) => /* @__PURE__ */ new Set([...prev, ...items]));
2012
+ }, []);
2013
+ const has = useCallback((item) => {
2014
+ return set.has(item);
2015
+ }, [set]);
2016
+ const remove = useCallback((item) => {
2017
+ setSet((prev) => {
2018
+ const newSet = new Set(prev);
2019
+ newSet.delete(item);
2020
+ return newSet;
2021
+ });
2022
+ }, []);
2023
+ const removeAll = useCallback((items) => {
2024
+ setSet((prev) => {
2025
+ const newSet = new Set(prev);
2026
+ for (const item of items) {
2027
+ newSet.delete(item);
2028
+ }
2029
+ return newSet;
2030
+ });
2031
+ }, []);
2032
+ const toggle = useCallback((item) => {
2033
+ setSet((prev) => {
2034
+ const newSet = new Set(prev);
2035
+ if (newSet.has(item)) {
2036
+ newSet.delete(item);
1294
2037
  } else {
1295
- try {
1296
- setStoredValue(deserializer(event.newValue));
1297
- } catch {
1298
- console.warn(`Error parsing localStorage change for key "${key}"`);
1299
- }
2038
+ newSet.add(item);
1300
2039
  }
1301
- };
1302
- window.addEventListener("storage", handleStorageChange);
1303
- return () => window.removeEventListener("storage", handleStorageChange);
1304
- }, [key, initialValue, syncTabs, deserializer, log]);
1305
- return [storedValue, setValue, removeValue];
2040
+ return newSet;
2041
+ });
2042
+ }, []);
2043
+ const clear = useCallback(() => {
2044
+ setSet(/* @__PURE__ */ new Set());
2045
+ }, []);
2046
+ const reset = useCallback(() => {
2047
+ setSet(new Set(initialValue));
2048
+ }, [initialValue]);
2049
+ const size = set.size;
2050
+ const values = useMemo(() => Array.from(set), [set]);
2051
+ const isEmpty = size === 0;
2052
+ return {
2053
+ set,
2054
+ add,
2055
+ addAll,
2056
+ has,
2057
+ remove,
2058
+ removeAll,
2059
+ toggle,
2060
+ clear,
2061
+ reset,
2062
+ size,
2063
+ values,
2064
+ isEmpty
2065
+ };
1306
2066
  }
1307
- var useLocalStorage_default = useLocalStorage;
2067
+ var useSet_default = useSet;
1308
2068
  function useDebounce(value, delay = 500) {
1309
2069
  const [debouncedValue, setDebouncedValue] = useState(value);
1310
2070
  useEffect(() => {
@@ -1318,60 +2078,383 @@ function useDebounce(value, delay = 500) {
1318
2078
  return debouncedValue;
1319
2079
  }
1320
2080
  var useDebounce_default = useDebounce;
1321
- function useCopyToClipboard(resetDelay = 2e3) {
1322
- const [copied, setCopied] = useState(false);
1323
- const [error, setError] = useState(null);
1324
- const reset = useCallback(() => {
1325
- setCopied(false);
1326
- setError(null);
2081
+ function useThrottle(value, interval = 500) {
2082
+ const [throttledValue, setThrottledValue] = useState(value);
2083
+ const lastUpdated = useRef(Date.now());
2084
+ useEffect(() => {
2085
+ const now = Date.now();
2086
+ const timeSinceLastUpdate = now - lastUpdated.current;
2087
+ if (timeSinceLastUpdate >= interval) {
2088
+ lastUpdated.current = now;
2089
+ setThrottledValue(value);
2090
+ return;
2091
+ } else {
2092
+ const timeoutId = setTimeout(() => {
2093
+ lastUpdated.current = Date.now();
2094
+ setThrottledValue(value);
2095
+ }, interval - timeSinceLastUpdate);
2096
+ return () => clearTimeout(timeoutId);
2097
+ }
2098
+ }, [value, interval]);
2099
+ return throttledValue;
2100
+ }
2101
+ var useThrottle_default = useThrottle;
2102
+ function useTimeout(callback, delay) {
2103
+ const savedCallback = useRef(callback);
2104
+ const timeoutId = useRef(null);
2105
+ useEffect(() => {
2106
+ savedCallback.current = callback;
2107
+ }, [callback]);
2108
+ const clear = useCallback(() => {
2109
+ if (timeoutId.current) {
2110
+ clearTimeout(timeoutId.current);
2111
+ timeoutId.current = null;
2112
+ }
1327
2113
  }, []);
1328
- const copy = useCallback(
1329
- async (text) => {
1330
- if (!navigator?.clipboard) {
1331
- try {
1332
- const textarea = document.createElement("textarea");
1333
- textarea.value = text;
1334
- textarea.style.position = "fixed";
1335
- textarea.style.left = "-999999px";
1336
- textarea.style.top = "-999999px";
1337
- document.body.appendChild(textarea);
1338
- textarea.focus();
1339
- textarea.select();
1340
- const successful = document.execCommand("copy");
1341
- document.body.removeChild(textarea);
1342
- if (successful) {
1343
- setCopied(true);
1344
- setError(null);
1345
- setTimeout(reset, resetDelay);
1346
- return true;
1347
- } else {
1348
- throw new Error("execCommand failed");
1349
- }
1350
- } catch (err) {
1351
- const message = err instanceof Error ? err.message : "Failed to copy to clipboard";
1352
- setError(message);
1353
- setCopied(false);
1354
- return false;
1355
- }
2114
+ const reset = useCallback(() => {
2115
+ clear();
2116
+ if (delay !== null) {
2117
+ timeoutId.current = setTimeout(() => {
2118
+ savedCallback.current();
2119
+ }, delay);
2120
+ }
2121
+ }, [delay, clear]);
2122
+ useEffect(() => {
2123
+ if (delay === null) {
2124
+ return;
2125
+ }
2126
+ timeoutId.current = setTimeout(() => {
2127
+ savedCallback.current();
2128
+ }, delay);
2129
+ return clear;
2130
+ }, [delay, clear]);
2131
+ return { reset, clear };
2132
+ }
2133
+ var useTimeout_default = useTimeout;
2134
+ function useInterval(callback, delay) {
2135
+ const savedCallback = useRef(callback);
2136
+ useEffect(() => {
2137
+ savedCallback.current = callback;
2138
+ }, [callback]);
2139
+ useEffect(() => {
2140
+ if (delay === null) {
2141
+ return;
2142
+ }
2143
+ const tick = () => savedCallback.current();
2144
+ const id = setInterval(tick, delay);
2145
+ return () => clearInterval(id);
2146
+ }, [delay]);
2147
+ }
2148
+ var useInterval_default = useInterval;
2149
+ function useIntervalWhen(callback, delay, when, immediate = false) {
2150
+ const savedCallback = useRef(callback);
2151
+ const hasRunImmediate = useRef(false);
2152
+ useEffect(() => {
2153
+ savedCallback.current = callback;
2154
+ }, [callback]);
2155
+ useEffect(() => {
2156
+ if (!when) {
2157
+ hasRunImmediate.current = false;
2158
+ return;
2159
+ }
2160
+ if (immediate && !hasRunImmediate.current) {
2161
+ hasRunImmediate.current = true;
2162
+ savedCallback.current();
2163
+ }
2164
+ const id = setInterval(() => {
2165
+ savedCallback.current();
2166
+ }, delay);
2167
+ return () => clearInterval(id);
2168
+ }, [delay, when, immediate]);
2169
+ }
2170
+ var useIntervalWhen_default = useIntervalWhen;
2171
+ function useRandomInterval(callback, minDelay, maxDelay, enabled = true) {
2172
+ const savedCallback = useRef(callback);
2173
+ const timeoutId = useRef(null);
2174
+ useEffect(() => {
2175
+ savedCallback.current = callback;
2176
+ }, [callback]);
2177
+ const getRandomDelay = useCallback(() => {
2178
+ return Math.floor(Math.random() * (maxDelay - minDelay + 1)) + minDelay;
2179
+ }, [minDelay, maxDelay]);
2180
+ useEffect(() => {
2181
+ if (!enabled) {
2182
+ return;
2183
+ }
2184
+ const tick = () => {
2185
+ savedCallback.current();
2186
+ timeoutId.current = setTimeout(tick, getRandomDelay());
2187
+ };
2188
+ timeoutId.current = setTimeout(tick, getRandomDelay());
2189
+ return () => {
2190
+ if (timeoutId.current) {
2191
+ clearTimeout(timeoutId.current);
1356
2192
  }
2193
+ };
2194
+ }, [enabled, getRandomDelay]);
2195
+ }
2196
+ var useRandomInterval_default = useRandomInterval;
2197
+ function useCountdown(initialCount, options = {}) {
2198
+ const { interval = 1e3, onComplete, autoStart = false } = options;
2199
+ const [count, setCount] = useState(initialCount);
2200
+ const [isRunning, setIsRunning] = useState(autoStart);
2201
+ const intervalRef = useRef(null);
2202
+ const onCompleteRef = useRef(onComplete);
2203
+ useEffect(() => {
2204
+ onCompleteRef.current = onComplete;
2205
+ }, [onComplete]);
2206
+ const isComplete = count <= 0;
2207
+ const clear = useCallback(() => {
2208
+ if (intervalRef.current) {
2209
+ clearInterval(intervalRef.current);
2210
+ intervalRef.current = null;
2211
+ }
2212
+ }, []);
2213
+ const start = useCallback(() => {
2214
+ if (count <= 0) return;
2215
+ setIsRunning(true);
2216
+ }, [count]);
2217
+ const pause = useCallback(() => {
2218
+ setIsRunning(false);
2219
+ clear();
2220
+ }, [clear]);
2221
+ const resume = useCallback(() => {
2222
+ if (count > 0) {
2223
+ setIsRunning(true);
2224
+ }
2225
+ }, [count]);
2226
+ const reset = useCallback(
2227
+ (newCount) => {
2228
+ clear();
2229
+ setCount(newCount ?? initialCount);
2230
+ setIsRunning(false);
2231
+ },
2232
+ [clear, initialCount]
2233
+ );
2234
+ useEffect(() => {
2235
+ if (!isRunning || count <= 0) {
2236
+ clear();
2237
+ return;
2238
+ }
2239
+ intervalRef.current = setInterval(() => {
2240
+ setCount((prev) => {
2241
+ const newCount = prev - interval;
2242
+ if (newCount <= 0) {
2243
+ setIsRunning(false);
2244
+ onCompleteRef.current?.();
2245
+ return 0;
2246
+ }
2247
+ return newCount;
2248
+ });
2249
+ }, interval);
2250
+ return clear;
2251
+ }, [isRunning, interval, clear, count]);
2252
+ const formatted = {
2253
+ days: Math.floor(count / (1e3 * 60 * 60 * 24)),
2254
+ hours: Math.floor(count % (1e3 * 60 * 60 * 24) / (1e3 * 60 * 60)),
2255
+ minutes: Math.floor(count % (1e3 * 60 * 60) / (1e3 * 60)),
2256
+ seconds: Math.floor(count % (1e3 * 60) / 1e3)
2257
+ };
2258
+ return {
2259
+ count,
2260
+ start,
2261
+ pause,
2262
+ resume,
2263
+ reset,
2264
+ isRunning,
2265
+ isComplete,
2266
+ formatted
2267
+ };
2268
+ }
2269
+ var useCountdown_default = useCountdown;
2270
+ function useContinuousRetry(callback, options = {}) {
2271
+ const {
2272
+ maxAttempts = Infinity,
2273
+ delay = 1e3,
2274
+ exponentialBackoff = false,
2275
+ maxDelay = 3e4,
2276
+ autoStart = true
2277
+ } = options;
2278
+ const [attempts, setAttempts] = useState(0);
2279
+ const [error, setError] = useState(null);
2280
+ const [isRetrying, setIsRetrying] = useState(autoStart);
2281
+ const [isSuccess2, setIsSuccess] = useState(false);
2282
+ const callbackRef = useRef(callback);
2283
+ const timeoutRef = useRef(null);
2284
+ useEffect(() => {
2285
+ callbackRef.current = callback;
2286
+ }, [callback]);
2287
+ const isMaxAttempts = attempts >= maxAttempts;
2288
+ const calculateDelay = useCallback(
2289
+ (attempt) => {
2290
+ if (!exponentialBackoff) return delay;
2291
+ const exponentialDelay = delay * Math.pow(2, attempt);
2292
+ return Math.min(exponentialDelay, maxDelay);
2293
+ },
2294
+ [delay, exponentialBackoff, maxDelay]
2295
+ );
2296
+ const clear = useCallback(() => {
2297
+ if (timeoutRef.current) {
2298
+ clearTimeout(timeoutRef.current);
2299
+ timeoutRef.current = null;
2300
+ }
2301
+ }, []);
2302
+ const stop = useCallback(() => {
2303
+ clear();
2304
+ setIsRetrying(false);
2305
+ }, [clear]);
2306
+ const reset = useCallback(() => {
2307
+ clear();
2308
+ setAttempts(0);
2309
+ setError(null);
2310
+ setIsRetrying(false);
2311
+ setIsSuccess(false);
2312
+ }, [clear]);
2313
+ const start = useCallback(() => {
2314
+ reset();
2315
+ setIsRetrying(true);
2316
+ }, [reset]);
2317
+ useEffect(() => {
2318
+ if (!isRetrying || isSuccess2 || isMaxAttempts) {
2319
+ return;
2320
+ }
2321
+ const attemptCallback = async () => {
1357
2322
  try {
1358
- await navigator.clipboard.writeText(text);
1359
- setCopied(true);
1360
- setError(null);
1361
- setTimeout(reset, resetDelay);
1362
- return true;
2323
+ setAttempts((prev) => prev + 1);
2324
+ const result = await callbackRef.current();
2325
+ if (result) {
2326
+ setIsSuccess(true);
2327
+ setIsRetrying(false);
2328
+ } else {
2329
+ const currentDelay = calculateDelay(attempts);
2330
+ timeoutRef.current = setTimeout(attemptCallback, currentDelay);
2331
+ }
1363
2332
  } catch (err) {
1364
- const message = err instanceof Error ? err.message : "Failed to copy to clipboard";
1365
- setError(message);
1366
- setCopied(false);
1367
- return false;
2333
+ setError(err instanceof Error ? err : new Error(String(err)));
2334
+ const currentDelay = calculateDelay(attempts);
2335
+ timeoutRef.current = setTimeout(attemptCallback, currentDelay);
1368
2336
  }
1369
- },
1370
- [resetDelay, reset]
1371
- );
1372
- return { copy, copied, error, reset };
2337
+ };
2338
+ if (attempts === 0) {
2339
+ attemptCallback();
2340
+ }
2341
+ return clear;
2342
+ }, [isRetrying, isSuccess2, isMaxAttempts, attempts, calculateDelay, clear]);
2343
+ return {
2344
+ attempts,
2345
+ error,
2346
+ isRetrying,
2347
+ isSuccess: isSuccess2,
2348
+ isMaxAttempts,
2349
+ start,
2350
+ stop,
2351
+ reset
2352
+ };
1373
2353
  }
1374
- var useCopyToClipboard_default = useCopyToClipboard;
2354
+ var useContinuousRetry_default = useContinuousRetry;
2355
+ function useWindowSize(debounceMs = 100) {
2356
+ const getSize = () => ({
2357
+ width: typeof window !== "undefined" ? window.innerWidth : 0,
2358
+ height: typeof window !== "undefined" ? window.innerHeight : 0
2359
+ });
2360
+ const [windowSize, setWindowSize] = useState(getSize);
2361
+ useEffect(() => {
2362
+ if (typeof window === "undefined") return;
2363
+ let timeoutId;
2364
+ const handleResize = () => {
2365
+ clearTimeout(timeoutId);
2366
+ timeoutId = setTimeout(() => {
2367
+ setWindowSize(getSize());
2368
+ }, debounceMs);
2369
+ };
2370
+ setWindowSize(getSize());
2371
+ window.addEventListener("resize", handleResize);
2372
+ return () => {
2373
+ clearTimeout(timeoutId);
2374
+ window.removeEventListener("resize", handleResize);
2375
+ };
2376
+ }, [debounceMs]);
2377
+ return windowSize;
2378
+ }
2379
+ var useWindowSize_default = useWindowSize;
2380
+ function useWindowScroll() {
2381
+ const [scroll, setScroll] = useState({
2382
+ x: typeof window !== "undefined" ? window.scrollX : 0,
2383
+ y: typeof window !== "undefined" ? window.scrollY : 0,
2384
+ direction: null,
2385
+ isScrolling: false
2386
+ });
2387
+ useEffect(() => {
2388
+ if (typeof window === "undefined") return;
2389
+ let prevX = window.scrollX;
2390
+ let prevY = window.scrollY;
2391
+ let scrollTimeout;
2392
+ const handleScroll = () => {
2393
+ const x = window.scrollX;
2394
+ const y = window.scrollY;
2395
+ let direction = null;
2396
+ if (y > prevY) direction = "down";
2397
+ else if (y < prevY) direction = "up";
2398
+ else if (x > prevX) direction = "right";
2399
+ else if (x < prevX) direction = "left";
2400
+ prevX = x;
2401
+ prevY = y;
2402
+ setScroll({ x, y, direction, isScrolling: true });
2403
+ clearTimeout(scrollTimeout);
2404
+ scrollTimeout = setTimeout(() => {
2405
+ setScroll((prev) => ({ ...prev, isScrolling: false }));
2406
+ }, 150);
2407
+ };
2408
+ window.addEventListener("scroll", handleScroll, { passive: true });
2409
+ return () => {
2410
+ window.removeEventListener("scroll", handleScroll);
2411
+ clearTimeout(scrollTimeout);
2412
+ };
2413
+ }, []);
2414
+ const scrollTo = useCallback((options) => {
2415
+ if (typeof window !== "undefined") {
2416
+ window.scrollTo(options);
2417
+ }
2418
+ }, []);
2419
+ const scrollToTop = useCallback((behavior = "smooth") => {
2420
+ if (typeof window !== "undefined") {
2421
+ window.scrollTo({ top: 0, behavior });
2422
+ }
2423
+ }, []);
2424
+ const scrollToBottom = useCallback((behavior = "smooth") => {
2425
+ if (typeof window !== "undefined") {
2426
+ window.scrollTo({
2427
+ top: document.documentElement.scrollHeight,
2428
+ behavior
2429
+ });
2430
+ }
2431
+ }, []);
2432
+ return {
2433
+ ...scroll,
2434
+ scrollTo,
2435
+ scrollToTop,
2436
+ scrollToBottom
2437
+ };
2438
+ }
2439
+ var useWindowScroll_default = useWindowScroll;
2440
+ function useDocumentTitle(title, options = {}) {
2441
+ const { restoreOnUnmount = true, template } = options;
2442
+ const previousTitle = useRef(null);
2443
+ useEffect(() => {
2444
+ if (typeof document === "undefined") return;
2445
+ if (previousTitle.current === null) {
2446
+ previousTitle.current = document.title;
2447
+ }
2448
+ const finalTitle = template ? template.replace("%s", title) : title;
2449
+ document.title = finalTitle;
2450
+ return () => {
2451
+ if (restoreOnUnmount && previousTitle.current !== null) {
2452
+ document.title = previousTitle.current;
2453
+ }
2454
+ };
2455
+ }, [title, template, restoreOnUnmount]);
2456
+ }
2457
+ var useDocumentTitle_default = useDocumentTitle;
1375
2458
  function usePageTitle(title, options = {}) {
1376
2459
  const { suffix, separator = " | ", restoreOnUnmount = true } = options;
1377
2460
  useEffect(() => {
@@ -1379,46 +2462,1379 @@ function usePageTitle(title, options = {}) {
1379
2462
  const newTitle = suffix ? `${title}${separator}${suffix}` : title;
1380
2463
  document.title = newTitle;
1381
2464
  return () => {
1382
- if (restoreOnUnmount) {
1383
- document.title = originalTitle;
2465
+ if (restoreOnUnmount) {
2466
+ document.title = originalTitle;
2467
+ }
2468
+ };
2469
+ }, [title, suffix, separator, restoreOnUnmount]);
2470
+ }
2471
+ var usePageTitle_default = usePageTitle;
2472
+ function useFavicon(href, restoreOnUnmount = true) {
2473
+ const originalHref = useRef(null);
2474
+ useEffect(() => {
2475
+ if (typeof document === "undefined") return;
2476
+ const link = document.querySelector("link[rel*='icon']") || document.createElement("link");
2477
+ if (originalHref.current === null) {
2478
+ originalHref.current = link.href;
2479
+ }
2480
+ link.type = "image/x-icon";
2481
+ link.rel = "shortcut icon";
2482
+ link.href = href;
2483
+ document.head.appendChild(link);
2484
+ return () => {
2485
+ if (restoreOnUnmount && originalHref.current) {
2486
+ link.href = originalHref.current;
2487
+ }
2488
+ };
2489
+ }, [href, restoreOnUnmount]);
2490
+ }
2491
+ var useFavicon_default = useFavicon;
2492
+ function useVisibilityChange(onVisibilityChange) {
2493
+ const [state, setState] = useState(() => ({
2494
+ isVisible: typeof document !== "undefined" ? !document.hidden : true,
2495
+ visibilityState: typeof document !== "undefined" ? document.visibilityState : "visible",
2496
+ lastChanged: null
2497
+ }));
2498
+ const handleVisibilityChange = useCallback(() => {
2499
+ const isVisible = !document.hidden;
2500
+ const visibilityState = document.visibilityState;
2501
+ setState({
2502
+ isVisible,
2503
+ visibilityState,
2504
+ lastChanged: /* @__PURE__ */ new Date()
2505
+ });
2506
+ onVisibilityChange?.(isVisible);
2507
+ }, [onVisibilityChange]);
2508
+ useEffect(() => {
2509
+ if (typeof document === "undefined") return;
2510
+ document.addEventListener("visibilitychange", handleVisibilityChange);
2511
+ return () => {
2512
+ document.removeEventListener("visibilitychange", handleVisibilityChange);
2513
+ };
2514
+ }, [handleVisibilityChange]);
2515
+ return state;
2516
+ }
2517
+ var useVisibilityChange_default = useVisibilityChange;
2518
+ function usePageLeave(onLeave, options = {}) {
2519
+ const { showConfirmation = false, confirmationMessage = "" } = options;
2520
+ const onLeaveRef = useRef(onLeave);
2521
+ useEffect(() => {
2522
+ onLeaveRef.current = onLeave;
2523
+ }, [onLeave]);
2524
+ const handleMouseLeave = useCallback((e) => {
2525
+ if (e.clientY <= 0) {
2526
+ onLeaveRef.current?.();
2527
+ }
2528
+ }, []);
2529
+ const handleBeforeUnload = useCallback(
2530
+ (e) => {
2531
+ onLeaveRef.current?.();
2532
+ if (showConfirmation) {
2533
+ e.preventDefault();
2534
+ e.returnValue = confirmationMessage;
2535
+ return confirmationMessage;
2536
+ }
2537
+ },
2538
+ [showConfirmation, confirmationMessage]
2539
+ );
2540
+ useEffect(() => {
2541
+ if (typeof window === "undefined") return;
2542
+ document.addEventListener("mouseleave", handleMouseLeave);
2543
+ window.addEventListener("beforeunload", handleBeforeUnload);
2544
+ return () => {
2545
+ document.removeEventListener("mouseleave", handleMouseLeave);
2546
+ window.removeEventListener("beforeunload", handleBeforeUnload);
2547
+ };
2548
+ }, [handleMouseLeave, handleBeforeUnload]);
2549
+ }
2550
+ var usePageLeave_default = usePageLeave;
2551
+ function useLockBodyScroll(locked = true) {
2552
+ useEffect(() => {
2553
+ if (typeof document === "undefined" || !locked) return;
2554
+ const originalStyle = window.getComputedStyle(document.body).overflow;
2555
+ const originalPaddingRight = window.getComputedStyle(document.body).paddingRight;
2556
+ const scrollbarWidth = window.innerWidth - document.documentElement.clientWidth;
2557
+ document.body.style.overflow = "hidden";
2558
+ if (scrollbarWidth > 0) {
2559
+ document.body.style.paddingRight = `${scrollbarWidth}px`;
2560
+ }
2561
+ return () => {
2562
+ document.body.style.overflow = originalStyle;
2563
+ document.body.style.paddingRight = originalPaddingRight;
2564
+ };
2565
+ }, [locked]);
2566
+ }
2567
+ var useLockBodyScroll_default = useLockBodyScroll;
2568
+ function useIsClient() {
2569
+ const [isClient, setIsClient] = useState(false);
2570
+ useEffect(() => {
2571
+ setIsClient(true);
2572
+ }, []);
2573
+ return isClient;
2574
+ }
2575
+ var useIsClient_default = useIsClient;
2576
+ function useIsFirstRender() {
2577
+ const isFirst = useRef(true);
2578
+ if (isFirst.current) {
2579
+ isFirst.current = false;
2580
+ return true;
2581
+ }
2582
+ return isFirst.current;
2583
+ }
2584
+ var useIsFirstRender_default = useIsFirstRender;
2585
+ function useEventListener(eventName, handler, element, options) {
2586
+ const savedHandler = useRef(handler);
2587
+ useEffect(() => {
2588
+ savedHandler.current = handler;
2589
+ }, [handler]);
2590
+ useEffect(() => {
2591
+ const targetElement = element ?? (typeof window !== "undefined" ? window : null);
2592
+ if (!targetElement?.addEventListener) {
2593
+ return;
2594
+ }
2595
+ const eventListener = (event) => {
2596
+ savedHandler.current(event);
2597
+ };
2598
+ targetElement.addEventListener(eventName, eventListener, options);
2599
+ return () => {
2600
+ targetElement.removeEventListener(eventName, eventListener, options);
2601
+ };
2602
+ }, [eventName, element, options]);
2603
+ }
2604
+ var useEventListener_default = useEventListener;
2605
+ function useKeyPress(targetKey, callback, options = {}) {
2606
+ const {
2607
+ target,
2608
+ event: eventType = "keydown",
2609
+ preventDefault = false,
2610
+ stopPropagation = false
2611
+ } = options;
2612
+ const [pressed, setPressed] = useState(false);
2613
+ const [event, setEvent] = useState(null);
2614
+ const keys = Array.isArray(targetKey) ? targetKey : [targetKey];
2615
+ const downHandler = useCallback(
2616
+ (e) => {
2617
+ if (keys.includes(e.key)) {
2618
+ if (preventDefault) e.preventDefault();
2619
+ if (stopPropagation) e.stopPropagation();
2620
+ setPressed(true);
2621
+ setEvent(e);
2622
+ callback?.(e);
2623
+ }
2624
+ },
2625
+ [keys, callback, preventDefault, stopPropagation]
2626
+ );
2627
+ const upHandler = useCallback(
2628
+ (e) => {
2629
+ if (keys.includes(e.key)) {
2630
+ setPressed(false);
2631
+ }
2632
+ },
2633
+ [keys]
2634
+ );
2635
+ useEffect(() => {
2636
+ const targetElement = target ?? (typeof document !== "undefined" ? document : null);
2637
+ if (!targetElement) return;
2638
+ targetElement.addEventListener(eventType, downHandler);
2639
+ targetElement.addEventListener("keyup", upHandler);
2640
+ return () => {
2641
+ targetElement.removeEventListener(eventType, downHandler);
2642
+ targetElement.removeEventListener("keyup", upHandler);
2643
+ };
2644
+ }, [target, eventType, downHandler, upHandler]);
2645
+ return { pressed, event };
2646
+ }
2647
+ var useKeyPress_default = useKeyPress;
2648
+ function useHover(onHoverChange) {
2649
+ const [isHovered, setIsHovered] = useState(false);
2650
+ const ref = useRef(null);
2651
+ const onMouseEnter = useCallback(() => {
2652
+ setIsHovered(true);
2653
+ onHoverChange?.(true);
2654
+ }, [onHoverChange]);
2655
+ const onMouseLeave = useCallback(() => {
2656
+ setIsHovered(false);
2657
+ onHoverChange?.(false);
2658
+ }, [onHoverChange]);
2659
+ return {
2660
+ ref,
2661
+ isHovered,
2662
+ bind: {
2663
+ onMouseEnter,
2664
+ onMouseLeave
2665
+ }
2666
+ };
2667
+ }
2668
+ var useHover_default = useHover;
2669
+ function useClickAway(callback, events = ["mousedown", "touchstart"]) {
2670
+ const ref = useRef(null);
2671
+ const savedCallback = useRef(callback);
2672
+ useEffect(() => {
2673
+ savedCallback.current = callback;
2674
+ }, [callback]);
2675
+ const handleClickAway = useCallback((event) => {
2676
+ const el = ref.current;
2677
+ if (!el || el.contains(event.target)) {
2678
+ return;
2679
+ }
2680
+ savedCallback.current(event);
2681
+ }, []);
2682
+ useEffect(() => {
2683
+ if (typeof document === "undefined") return;
2684
+ events.forEach((eventType) => {
2685
+ document.addEventListener(eventType, handleClickAway);
2686
+ });
2687
+ return () => {
2688
+ events.forEach((eventType) => {
2689
+ document.removeEventListener(eventType, handleClickAway);
2690
+ });
2691
+ };
2692
+ }, [events, handleClickAway]);
2693
+ return ref;
2694
+ }
2695
+ var useClickAway_default = useClickAway;
2696
+ function useOnClickOutside(ref, handler, enabled = true) {
2697
+ useEffect(() => {
2698
+ if (!enabled) return;
2699
+ const listener = (event) => {
2700
+ const el = ref?.current;
2701
+ if (!el || el.contains(event.target)) {
2702
+ return;
2703
+ }
2704
+ handler(event);
2705
+ };
2706
+ document.addEventListener("mousedown", listener);
2707
+ document.addEventListener("touchstart", listener);
2708
+ return () => {
2709
+ document.removeEventListener("mousedown", listener);
2710
+ document.removeEventListener("touchstart", listener);
2711
+ };
2712
+ }, [ref, handler, enabled]);
2713
+ }
2714
+ var useOnClickOutside_default = useOnClickOutside;
2715
+ function useLongPress(options = {}) {
2716
+ const {
2717
+ threshold = 400,
2718
+ onLongPress,
2719
+ onClick,
2720
+ onStart,
2721
+ onFinish,
2722
+ onCancel
2723
+ } = options;
2724
+ const [isPressed, setIsPressed] = useState(false);
2725
+ const [isLongPress, setIsLongPress] = useState(false);
2726
+ const timerRef = useRef(null);
2727
+ const isLongPressRef = useRef(false);
2728
+ const start = useCallback(
2729
+ (event) => {
2730
+ setIsPressed(true);
2731
+ setIsLongPress(false);
2732
+ isLongPressRef.current = false;
2733
+ onStart?.(event);
2734
+ timerRef.current = setTimeout(() => {
2735
+ isLongPressRef.current = true;
2736
+ setIsLongPress(true);
2737
+ onLongPress?.(event);
2738
+ }, threshold);
2739
+ },
2740
+ [threshold, onLongPress, onStart]
2741
+ );
2742
+ const cancel = useCallback(
2743
+ (event) => {
2744
+ setIsPressed(false);
2745
+ if (timerRef.current) {
2746
+ clearTimeout(timerRef.current);
2747
+ timerRef.current = null;
2748
+ }
2749
+ if (!isLongPressRef.current) {
2750
+ onCancel?.(event);
2751
+ }
2752
+ },
2753
+ [onCancel]
2754
+ );
2755
+ const end = useCallback(
2756
+ (event) => {
2757
+ setIsPressed(false);
2758
+ if (timerRef.current) {
2759
+ clearTimeout(timerRef.current);
2760
+ timerRef.current = null;
2761
+ }
2762
+ if (isLongPressRef.current) {
2763
+ onFinish?.(event);
2764
+ } else {
2765
+ onClick?.(event);
2766
+ }
2767
+ },
2768
+ [onClick, onFinish]
2769
+ );
2770
+ return {
2771
+ isPressed,
2772
+ isLongPress,
2773
+ bind: {
2774
+ onMouseDown: start,
2775
+ onMouseUp: end,
2776
+ onMouseLeave: cancel,
2777
+ onTouchStart: start,
2778
+ onTouchEnd: end
2779
+ }
2780
+ };
2781
+ }
2782
+ var useLongPress_default = useLongPress;
2783
+ function useMouse(options = {}) {
2784
+ const { enabled = true } = options;
2785
+ const ref = useRef(null);
2786
+ const [position, setPosition] = useState({
2787
+ x: 0,
2788
+ y: 0,
2789
+ pageX: 0,
2790
+ pageY: 0,
2791
+ elementX: 0,
2792
+ elementY: 0,
2793
+ isInElement: false
2794
+ });
2795
+ const handleMouseMove = useCallback((event) => {
2796
+ let elementX = 0;
2797
+ let elementY = 0;
2798
+ let isInElement = false;
2799
+ if (ref.current) {
2800
+ const rect = ref.current.getBoundingClientRect();
2801
+ elementX = event.clientX - rect.left;
2802
+ elementY = event.clientY - rect.top;
2803
+ isInElement = elementX >= 0 && elementX <= rect.width && elementY >= 0 && elementY <= rect.height;
2804
+ }
2805
+ setPosition({
2806
+ x: event.clientX,
2807
+ y: event.clientY,
2808
+ pageX: event.pageX,
2809
+ pageY: event.pageY,
2810
+ elementX,
2811
+ elementY,
2812
+ isInElement
2813
+ });
2814
+ }, []);
2815
+ useEffect(() => {
2816
+ if (!enabled || typeof window === "undefined") return;
2817
+ window.addEventListener("mousemove", handleMouseMove);
2818
+ return () => {
2819
+ window.removeEventListener("mousemove", handleMouseMove);
2820
+ };
2821
+ }, [enabled, handleMouseMove]);
2822
+ return {
2823
+ ref,
2824
+ ...position
2825
+ };
2826
+ }
2827
+ var useMouse_default = useMouse;
2828
+ function useCopyToClipboard(resetDelay = 2e3) {
2829
+ const [copied, setCopied] = useState(false);
2830
+ const [error, setError] = useState(null);
2831
+ const reset = useCallback(() => {
2832
+ setCopied(false);
2833
+ setError(null);
2834
+ }, []);
2835
+ const copy = useCallback(
2836
+ async (text) => {
2837
+ if (!navigator?.clipboard) {
2838
+ try {
2839
+ const textarea = document.createElement("textarea");
2840
+ textarea.value = text;
2841
+ textarea.style.position = "fixed";
2842
+ textarea.style.left = "-999999px";
2843
+ textarea.style.top = "-999999px";
2844
+ document.body.appendChild(textarea);
2845
+ textarea.focus();
2846
+ textarea.select();
2847
+ const successful = document.execCommand("copy");
2848
+ document.body.removeChild(textarea);
2849
+ if (successful) {
2850
+ setCopied(true);
2851
+ setError(null);
2852
+ setTimeout(reset, resetDelay);
2853
+ return true;
2854
+ } else {
2855
+ throw new Error("execCommand failed");
2856
+ }
2857
+ } catch (err) {
2858
+ const message = err instanceof Error ? err.message : "Failed to copy to clipboard";
2859
+ setError(message);
2860
+ setCopied(false);
2861
+ return false;
2862
+ }
2863
+ }
2864
+ try {
2865
+ await navigator.clipboard.writeText(text);
2866
+ setCopied(true);
2867
+ setError(null);
2868
+ setTimeout(reset, resetDelay);
2869
+ return true;
2870
+ } catch (err) {
2871
+ const message = err instanceof Error ? err.message : "Failed to copy to clipboard";
2872
+ setError(message);
2873
+ setCopied(false);
2874
+ return false;
2875
+ }
2876
+ },
2877
+ [resetDelay, reset]
2878
+ );
2879
+ return { copy, copied, error, reset };
2880
+ }
2881
+ var useCopyToClipboard_default = useCopyToClipboard;
2882
+ function useMediaQuery(query) {
2883
+ const getMatches = (query2) => {
2884
+ if (typeof window === "undefined") return false;
2885
+ return window.matchMedia(query2).matches;
2886
+ };
2887
+ const [matches, setMatches] = useState(getMatches(query));
2888
+ useEffect(() => {
2889
+ if (typeof window === "undefined") return;
2890
+ const mediaQuery = window.matchMedia(query);
2891
+ const handleChange = () => setMatches(mediaQuery.matches);
2892
+ handleChange();
2893
+ mediaQuery.addEventListener("change", handleChange);
2894
+ return () => mediaQuery.removeEventListener("change", handleChange);
2895
+ }, [query]);
2896
+ return matches;
2897
+ }
2898
+ var useIsMobile = () => useMediaQuery("(max-width: 767px)");
2899
+ var useIsTablet = () => useMediaQuery("(min-width: 768px) and (max-width: 1023px)");
2900
+ var useIsDesktop = () => useMediaQuery("(min-width: 1024px)");
2901
+ var useIsMobileOrTablet = () => useMediaQuery("(max-width: 1023px)");
2902
+ var useMediaQuery_default = useMediaQuery;
2903
+ function useOrientation() {
2904
+ const getOrientation = () => {
2905
+ if (typeof window === "undefined" || !window.screen?.orientation) {
2906
+ return {
2907
+ angle: 0,
2908
+ type: "portrait-primary",
2909
+ isPortrait: true,
2910
+ isLandscape: false
2911
+ };
2912
+ }
2913
+ const { angle, type } = window.screen.orientation;
2914
+ const isPortrait = type.includes("portrait");
2915
+ const isLandscape = type.includes("landscape");
2916
+ return { angle, type, isPortrait, isLandscape };
2917
+ };
2918
+ const [orientation, setOrientation] = useState(getOrientation);
2919
+ useEffect(() => {
2920
+ if (typeof window === "undefined") return;
2921
+ const handleOrientationChange = () => {
2922
+ setOrientation(getOrientation());
2923
+ };
2924
+ if (window.screen?.orientation) {
2925
+ window.screen.orientation.addEventListener("change", handleOrientationChange);
2926
+ }
2927
+ window.addEventListener("orientationchange", handleOrientationChange);
2928
+ window.addEventListener("resize", handleOrientationChange);
2929
+ return () => {
2930
+ if (window.screen?.orientation) {
2931
+ window.screen.orientation.removeEventListener("change", handleOrientationChange);
2932
+ }
2933
+ window.removeEventListener("orientationchange", handleOrientationChange);
2934
+ window.removeEventListener("resize", handleOrientationChange);
2935
+ };
2936
+ }, []);
2937
+ return orientation;
2938
+ }
2939
+ var useOrientation_default = useOrientation;
2940
+ function useBattery() {
2941
+ const [battery, setBattery] = useState({
2942
+ isSupported: false,
2943
+ charging: false,
2944
+ chargingTime: Infinity,
2945
+ dischargingTime: Infinity,
2946
+ level: 1,
2947
+ percentage: 100
2948
+ });
2949
+ useEffect(() => {
2950
+ if (typeof navigator === "undefined") return;
2951
+ const nav = navigator;
2952
+ if (!nav.getBattery) {
2953
+ setBattery((prev) => ({ ...prev, isSupported: false }));
2954
+ return;
2955
+ }
2956
+ let batteryManager = null;
2957
+ const updateBattery = (battery2) => {
2958
+ setBattery({
2959
+ isSupported: true,
2960
+ charging: battery2.charging,
2961
+ chargingTime: battery2.chargingTime,
2962
+ dischargingTime: battery2.dischargingTime,
2963
+ level: battery2.level,
2964
+ percentage: Math.round(battery2.level * 100)
2965
+ });
2966
+ };
2967
+ const handleChange = () => {
2968
+ if (batteryManager) {
2969
+ updateBattery(batteryManager);
2970
+ }
2971
+ };
2972
+ nav.getBattery().then((battery2) => {
2973
+ batteryManager = battery2;
2974
+ updateBattery(battery2);
2975
+ battery2.addEventListener("chargingchange", handleChange);
2976
+ battery2.addEventListener("chargingtimechange", handleChange);
2977
+ battery2.addEventListener("dischargingtimechange", handleChange);
2978
+ battery2.addEventListener("levelchange", handleChange);
2979
+ });
2980
+ return () => {
2981
+ if (batteryManager) {
2982
+ batteryManager.removeEventListener("chargingchange", handleChange);
2983
+ batteryManager.removeEventListener("chargingtimechange", handleChange);
2984
+ batteryManager.removeEventListener("dischargingtimechange", handleChange);
2985
+ batteryManager.removeEventListener("levelchange", handleChange);
2986
+ }
2987
+ };
2988
+ }, []);
2989
+ return battery;
2990
+ }
2991
+ var useBattery_default = useBattery;
2992
+ function useNetworkState() {
2993
+ const getConnection = () => {
2994
+ if (typeof navigator === "undefined") return void 0;
2995
+ const nav = navigator;
2996
+ return nav.connection || nav.mozConnection || nav.webkitConnection;
2997
+ };
2998
+ const getNetworkState = () => {
2999
+ const online = typeof navigator !== "undefined" ? navigator.onLine : true;
3000
+ const connection = getConnection();
3001
+ return {
3002
+ online,
3003
+ offline: !online,
3004
+ downlink: connection?.downlink,
3005
+ effectiveType: connection?.effectiveType,
3006
+ rtt: connection?.rtt,
3007
+ saveData: connection?.saveData,
3008
+ type: connection?.type,
3009
+ since: /* @__PURE__ */ new Date()
3010
+ };
3011
+ };
3012
+ const [state, setState] = useState(getNetworkState);
3013
+ useEffect(() => {
3014
+ if (typeof window === "undefined") return;
3015
+ const handleOnline = () => {
3016
+ setState((prev) => ({ ...prev, online: true, offline: false, since: /* @__PURE__ */ new Date() }));
3017
+ };
3018
+ const handleOffline = () => {
3019
+ setState((prev) => ({ ...prev, online: false, offline: true, since: /* @__PURE__ */ new Date() }));
3020
+ };
3021
+ const handleConnectionChange = () => {
3022
+ setState(getNetworkState());
3023
+ };
3024
+ window.addEventListener("online", handleOnline);
3025
+ window.addEventListener("offline", handleOffline);
3026
+ const connection = getConnection();
3027
+ if (connection) {
3028
+ connection.addEventListener("change", handleConnectionChange);
3029
+ }
3030
+ return () => {
3031
+ window.removeEventListener("online", handleOnline);
3032
+ window.removeEventListener("offline", handleOffline);
3033
+ if (connection) {
3034
+ connection.removeEventListener("change", handleConnectionChange);
3035
+ }
3036
+ };
3037
+ }, []);
3038
+ return state;
3039
+ }
3040
+ var useNetworkState_default = useNetworkState;
3041
+ var DEFAULT_EVENTS = [
3042
+ "mousemove",
3043
+ "mousedown",
3044
+ "keydown",
3045
+ "touchstart",
3046
+ "scroll",
3047
+ "wheel"
3048
+ ];
3049
+ function useIdle(options = {}) {
3050
+ const {
3051
+ timeout = 6e4,
3052
+ events = DEFAULT_EVENTS,
3053
+ initialState = false,
3054
+ onIdle,
3055
+ onActive
3056
+ } = options;
3057
+ const [isIdle, setIsIdle] = useState(initialState);
3058
+ const [lastActive, setLastActive] = useState(/* @__PURE__ */ new Date());
3059
+ const [isTracking, setIsTracking] = useState(true);
3060
+ const timeoutRef = useRef(null);
3061
+ const onIdleRef = useRef(onIdle);
3062
+ const onActiveRef = useRef(onActive);
3063
+ useEffect(() => {
3064
+ onIdleRef.current = onIdle;
3065
+ onActiveRef.current = onActive;
3066
+ }, [onIdle, onActive]);
3067
+ const handleActivity = useCallback(() => {
3068
+ if (!isTracking) return;
3069
+ setLastActive(/* @__PURE__ */ new Date());
3070
+ if (isIdle) {
3071
+ setIsIdle(false);
3072
+ onActiveRef.current?.();
3073
+ }
3074
+ if (timeoutRef.current) {
3075
+ clearTimeout(timeoutRef.current);
3076
+ }
3077
+ timeoutRef.current = setTimeout(() => {
3078
+ setIsIdle(true);
3079
+ onIdleRef.current?.();
3080
+ }, timeout);
3081
+ }, [isIdle, isTracking, timeout]);
3082
+ const reset = useCallback(() => {
3083
+ handleActivity();
3084
+ }, [handleActivity]);
3085
+ const start = useCallback(() => {
3086
+ setIsTracking(true);
3087
+ handleActivity();
3088
+ }, [handleActivity]);
3089
+ const stop = useCallback(() => {
3090
+ setIsTracking(false);
3091
+ if (timeoutRef.current) {
3092
+ clearTimeout(timeoutRef.current);
3093
+ timeoutRef.current = null;
3094
+ }
3095
+ }, []);
3096
+ useEffect(() => {
3097
+ if (typeof window === "undefined" || !isTracking) return;
3098
+ timeoutRef.current = setTimeout(() => {
3099
+ setIsIdle(true);
3100
+ onIdleRef.current?.();
3101
+ }, timeout);
3102
+ events.forEach((event) => {
3103
+ window.addEventListener(event, handleActivity, { passive: true });
3104
+ });
3105
+ return () => {
3106
+ if (timeoutRef.current) {
3107
+ clearTimeout(timeoutRef.current);
3108
+ }
3109
+ events.forEach((event) => {
3110
+ window.removeEventListener(event, handleActivity);
3111
+ });
3112
+ };
3113
+ }, [events, handleActivity, isTracking, timeout]);
3114
+ return {
3115
+ isIdle,
3116
+ lastActive,
3117
+ reset,
3118
+ start,
3119
+ stop
3120
+ };
3121
+ }
3122
+ var useIdle_default = useIdle;
3123
+ function useGeolocation(options = {}) {
3124
+ const {
3125
+ enableHighAccuracy = false,
3126
+ maximumAge = 0,
3127
+ timeout = Infinity,
3128
+ watch = false
3129
+ } = options;
3130
+ const isSupported = typeof navigator !== "undefined" && "geolocation" in navigator;
3131
+ const [state, setState] = useState({
3132
+ loading: true,
3133
+ error: null,
3134
+ latitude: null,
3135
+ longitude: null,
3136
+ accuracy: null,
3137
+ altitude: null,
3138
+ altitudeAccuracy: null,
3139
+ heading: null,
3140
+ speed: null,
3141
+ timestamp: null
3142
+ });
3143
+ const handleSuccess = useCallback((position) => {
3144
+ setState({
3145
+ loading: false,
3146
+ error: null,
3147
+ latitude: position.coords.latitude,
3148
+ longitude: position.coords.longitude,
3149
+ accuracy: position.coords.accuracy,
3150
+ altitude: position.coords.altitude,
3151
+ altitudeAccuracy: position.coords.altitudeAccuracy,
3152
+ heading: position.coords.heading,
3153
+ speed: position.coords.speed,
3154
+ timestamp: position.timestamp
3155
+ });
3156
+ }, []);
3157
+ const handleError = useCallback((error) => {
3158
+ setState((prev) => ({
3159
+ ...prev,
3160
+ loading: false,
3161
+ error: error.message
3162
+ }));
3163
+ }, []);
3164
+ const refresh = useCallback(() => {
3165
+ if (!isSupported) return;
3166
+ setState((prev) => ({ ...prev, loading: true }));
3167
+ navigator.geolocation.getCurrentPosition(handleSuccess, handleError, {
3168
+ enableHighAccuracy,
3169
+ maximumAge,
3170
+ timeout
3171
+ });
3172
+ }, [isSupported, enableHighAccuracy, maximumAge, timeout, handleSuccess, handleError]);
3173
+ useEffect(() => {
3174
+ if (!isSupported) {
3175
+ setState((prev) => ({
3176
+ ...prev,
3177
+ loading: false,
3178
+ error: "Geolocation is not supported"
3179
+ }));
3180
+ return;
3181
+ }
3182
+ const positionOptions = {
3183
+ enableHighAccuracy,
3184
+ maximumAge,
3185
+ timeout
3186
+ };
3187
+ navigator.geolocation.getCurrentPosition(
3188
+ handleSuccess,
3189
+ handleError,
3190
+ positionOptions
3191
+ );
3192
+ let watchId = null;
3193
+ if (watch) {
3194
+ watchId = navigator.geolocation.watchPosition(
3195
+ handleSuccess,
3196
+ handleError,
3197
+ positionOptions
3198
+ );
3199
+ }
3200
+ return () => {
3201
+ if (watchId !== null) {
3202
+ navigator.geolocation.clearWatch(watchId);
3203
+ }
3204
+ };
3205
+ }, [isSupported, enableHighAccuracy, maximumAge, timeout, watch, handleSuccess, handleError]);
3206
+ return {
3207
+ ...state,
3208
+ refresh,
3209
+ isSupported
3210
+ };
3211
+ }
3212
+ var useGeolocation_default = useGeolocation;
3213
+ function usePreferredLanguage() {
3214
+ const getLanguageState = () => {
3215
+ if (typeof navigator === "undefined") {
3216
+ return { language: "en", languages: ["en"] };
3217
+ }
3218
+ return {
3219
+ language: navigator.language || "en",
3220
+ languages: navigator.languages || [navigator.language || "en"]
3221
+ };
3222
+ };
3223
+ const [state, setState] = useState(getLanguageState);
3224
+ useEffect(() => {
3225
+ if (typeof window === "undefined") return;
3226
+ const handleLanguageChange = () => {
3227
+ setState(getLanguageState());
3228
+ };
3229
+ window.addEventListener("languagechange", handleLanguageChange);
3230
+ return () => {
3231
+ window.removeEventListener("languagechange", handleLanguageChange);
3232
+ };
3233
+ }, []);
3234
+ return state;
3235
+ }
3236
+ var usePreferredLanguage_default = usePreferredLanguage;
3237
+ function useThemeDetector() {
3238
+ const getCurrentTheme = () => {
3239
+ if (typeof window === "undefined") return "light";
3240
+ return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
3241
+ };
3242
+ const [theme, setTheme] = useState(getCurrentTheme);
3243
+ useEffect(() => {
3244
+ if (typeof window === "undefined") return;
3245
+ const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
3246
+ const handleChange = (e) => {
3247
+ setTheme(e.matches ? "dark" : "light");
3248
+ };
3249
+ mediaQuery.addEventListener("change", handleChange);
3250
+ return () => mediaQuery.removeEventListener("change", handleChange);
3251
+ }, []);
3252
+ return theme;
3253
+ }
3254
+ var useThemeDetector_default = useThemeDetector;
3255
+ function useLocalStorage(key, initialValue, options = {}) {
3256
+ const {
3257
+ serializer = JSON.stringify,
3258
+ deserializer = JSON.parse,
3259
+ syncTabs = true,
3260
+ debug = false
3261
+ } = options;
3262
+ const log = useCallback(
3263
+ (...args) => {
3264
+ if (debug) console.log(`[useLocalStorage:${key}]`, ...args);
3265
+ },
3266
+ [debug, key]
3267
+ );
3268
+ const readValue = useCallback(() => {
3269
+ if (typeof window === "undefined") {
3270
+ return initialValue;
3271
+ }
3272
+ try {
3273
+ const item = window.localStorage.getItem(key);
3274
+ if (item === null) {
3275
+ return initialValue;
3276
+ }
3277
+ const parsed = deserializer(item);
3278
+ log("Read value:", parsed);
3279
+ return parsed;
3280
+ } catch (error) {
3281
+ console.warn(`Error reading localStorage key "${key}":`, error);
3282
+ return initialValue;
3283
+ }
3284
+ }, [key, initialValue, deserializer, log]);
3285
+ const [storedValue, setStoredValue] = useState(readValue);
3286
+ const setValue = useCallback(
3287
+ (value) => {
3288
+ if (typeof window === "undefined") {
3289
+ console.warn(`Cannot set localStorage key "${key}" in non-browser environment`);
3290
+ return;
3291
+ }
3292
+ try {
3293
+ const valueToStore = value instanceof Function ? value(storedValue) : value;
3294
+ setStoredValue(valueToStore);
3295
+ window.localStorage.setItem(key, serializer(valueToStore));
3296
+ log("Set value:", valueToStore);
3297
+ window.dispatchEvent(new StorageEvent("storage", { key, newValue: serializer(valueToStore) }));
3298
+ } catch (error) {
3299
+ console.warn(`Error setting localStorage key "${key}":`, error);
3300
+ }
3301
+ },
3302
+ [key, storedValue, serializer, log]
3303
+ );
3304
+ const removeValue = useCallback(() => {
3305
+ if (typeof window === "undefined") {
3306
+ return;
3307
+ }
3308
+ try {
3309
+ window.localStorage.removeItem(key);
3310
+ setStoredValue(initialValue);
3311
+ log("Removed value");
3312
+ window.dispatchEvent(new StorageEvent("storage", { key, newValue: null }));
3313
+ } catch (error) {
3314
+ console.warn(`Error removing localStorage key "${key}":`, error);
3315
+ }
3316
+ }, [key, initialValue, log]);
3317
+ useEffect(() => {
3318
+ if (!syncTabs || typeof window === "undefined") {
3319
+ return;
3320
+ }
3321
+ const handleStorageChange = (event) => {
3322
+ if (event.key !== key) {
3323
+ return;
3324
+ }
3325
+ log("Storage event received:", event.newValue);
3326
+ if (event.newValue === null) {
3327
+ setStoredValue(initialValue);
3328
+ } else {
3329
+ try {
3330
+ setStoredValue(deserializer(event.newValue));
3331
+ } catch {
3332
+ console.warn(`Error parsing localStorage change for key "${key}"`);
3333
+ }
3334
+ }
3335
+ };
3336
+ window.addEventListener("storage", handleStorageChange);
3337
+ return () => window.removeEventListener("storage", handleStorageChange);
3338
+ }, [key, initialValue, syncTabs, deserializer, log]);
3339
+ return [storedValue, setValue, removeValue];
3340
+ }
3341
+ var useLocalStorage_default = useLocalStorage;
3342
+ function useSessionStorage(key, initialValue, options = {}) {
3343
+ const {
3344
+ serializer = JSON.stringify,
3345
+ deserializer = JSON.parse,
3346
+ debug = false
3347
+ } = options;
3348
+ const log = useCallback(
3349
+ (...args) => {
3350
+ if (debug) console.log(`[useSessionStorage:${key}]`, ...args);
3351
+ },
3352
+ [debug, key]
3353
+ );
3354
+ const readValue = useCallback(() => {
3355
+ if (typeof window === "undefined") {
3356
+ return initialValue;
3357
+ }
3358
+ try {
3359
+ const item = window.sessionStorage.getItem(key);
3360
+ if (item === null) {
3361
+ return initialValue;
3362
+ }
3363
+ const parsed = deserializer(item);
3364
+ log("Read value:", parsed);
3365
+ return parsed;
3366
+ } catch (error) {
3367
+ console.warn(`Error reading sessionStorage key "${key}":`, error);
3368
+ return initialValue;
3369
+ }
3370
+ }, [key, initialValue, deserializer, log]);
3371
+ const [storedValue, setStoredValue] = useState(readValue);
3372
+ const setValue = useCallback(
3373
+ (value) => {
3374
+ if (typeof window === "undefined") {
3375
+ console.warn(`Cannot set sessionStorage key "${key}" in non-browser environment`);
3376
+ return;
3377
+ }
3378
+ try {
3379
+ const valueToStore = value instanceof Function ? value(storedValue) : value;
3380
+ setStoredValue(valueToStore);
3381
+ window.sessionStorage.setItem(key, serializer(valueToStore));
3382
+ log("Set value:", valueToStore);
3383
+ } catch (error) {
3384
+ console.warn(`Error setting sessionStorage key "${key}":`, error);
3385
+ }
3386
+ },
3387
+ [key, storedValue, serializer, log]
3388
+ );
3389
+ const removeValue = useCallback(() => {
3390
+ if (typeof window === "undefined") {
3391
+ return;
3392
+ }
3393
+ try {
3394
+ window.sessionStorage.removeItem(key);
3395
+ setStoredValue(initialValue);
3396
+ log("Removed value");
3397
+ } catch (error) {
3398
+ console.warn(`Error removing sessionStorage key "${key}":`, error);
3399
+ }
3400
+ }, [key, initialValue, log]);
3401
+ useEffect(() => {
3402
+ if (typeof window === "undefined") return;
3403
+ const handleStorageChange = (e) => {
3404
+ if (e.storageArea !== sessionStorage || e.key !== key) {
3405
+ return;
3406
+ }
3407
+ try {
3408
+ if (e.newValue === null) {
3409
+ setStoredValue(initialValue);
3410
+ } else {
3411
+ setStoredValue(deserializer(e.newValue));
3412
+ }
3413
+ } catch (error) {
3414
+ console.warn(`Error handling storage event for key "${key}":`, error);
3415
+ }
3416
+ };
3417
+ window.addEventListener("storage", handleStorageChange);
3418
+ return () => {
3419
+ window.removeEventListener("storage", handleStorageChange);
3420
+ };
3421
+ }, [key, initialValue, deserializer]);
3422
+ return [storedValue, setValue, removeValue];
3423
+ }
3424
+ var useSessionStorage_default = useSessionStorage;
3425
+ var cache = /* @__PURE__ */ new Map();
3426
+ function useFetch(url, options = {}) {
3427
+ const {
3428
+ skip = false,
3429
+ transform,
3430
+ retries = 0,
3431
+ retryDelay = 1e3,
3432
+ cacheKey,
3433
+ cacheTime = 0,
3434
+ onSuccess,
3435
+ onError,
3436
+ body,
3437
+ ...fetchOptions
3438
+ } = options;
3439
+ const [data, setData] = useState(null);
3440
+ const [loading, setLoading] = useState(!skip && !!url);
3441
+ const [isFetching, setIsFetching] = useState(!skip && !!url);
3442
+ const [error, setError] = useState(null);
3443
+ const [status, setStatus] = useState(null);
3444
+ const abortControllerRef = useRef(null);
3445
+ const retriesRef = useRef(0);
3446
+ const fetchData = useCallback(async () => {
3447
+ if (!url) return null;
3448
+ const key = cacheKey || url;
3449
+ if (cacheTime > 0) {
3450
+ const cached = cache.get(key);
3451
+ if (cached && Date.now() - cached.timestamp < cacheTime) {
3452
+ const cachedData = cached.data;
3453
+ setData(cachedData);
3454
+ setLoading(false);
3455
+ setIsFetching(false);
3456
+ return cachedData;
3457
+ }
3458
+ }
3459
+ if (abortControllerRef.current) {
3460
+ abortControllerRef.current.abort();
3461
+ }
3462
+ abortControllerRef.current = new AbortController();
3463
+ setIsFetching(true);
3464
+ setError(null);
3465
+ try {
3466
+ let processedBody;
3467
+ if (body !== null && body !== void 0) {
3468
+ if (typeof body === "object" && !(body instanceof FormData) && !(body instanceof Blob)) {
3469
+ processedBody = JSON.stringify(body);
3470
+ fetchOptions.headers = {
3471
+ "Content-Type": "application/json",
3472
+ ...fetchOptions.headers
3473
+ };
3474
+ } else {
3475
+ processedBody = body;
3476
+ }
3477
+ }
3478
+ const response = await fetch(url, {
3479
+ ...fetchOptions,
3480
+ body: processedBody,
3481
+ signal: abortControllerRef.current.signal
3482
+ });
3483
+ setStatus(response.status);
3484
+ if (!response.ok) {
3485
+ throw new Error(`HTTP error! status: ${response.status}`);
3486
+ }
3487
+ const responseData = await response.json();
3488
+ const transformedData = transform ? transform(responseData) : responseData;
3489
+ if (cacheTime > 0) {
3490
+ cache.set(key, { data: transformedData, timestamp: Date.now() });
3491
+ }
3492
+ setData(transformedData);
3493
+ setError(null);
3494
+ setLoading(false);
3495
+ setIsFetching(false);
3496
+ retriesRef.current = 0;
3497
+ onSuccess?.(transformedData);
3498
+ return transformedData;
3499
+ } catch (err) {
3500
+ if (err.name === "AbortError") {
3501
+ return null;
3502
+ }
3503
+ const fetchError = err instanceof Error ? err : new Error(String(err));
3504
+ if (retriesRef.current < retries) {
3505
+ retriesRef.current++;
3506
+ await new Promise((resolve2) => setTimeout(resolve2, retryDelay));
3507
+ return fetchData();
3508
+ }
3509
+ setError(fetchError);
3510
+ setLoading(false);
3511
+ setIsFetching(false);
3512
+ retriesRef.current = 0;
3513
+ onError?.(fetchError);
3514
+ return null;
3515
+ }
3516
+ }, [url, cacheKey, cacheTime, transform, retries, retryDelay, body, fetchOptions, onSuccess, onError]);
3517
+ const abort = useCallback(() => {
3518
+ if (abortControllerRef.current) {
3519
+ abortControllerRef.current.abort();
3520
+ }
3521
+ }, []);
3522
+ const refetch = useCallback(async () => {
3523
+ const key = cacheKey || url || "";
3524
+ cache.delete(key);
3525
+ setLoading(true);
3526
+ return fetchData();
3527
+ }, [fetchData, cacheKey, url]);
3528
+ useEffect(() => {
3529
+ if (skip || !url) {
3530
+ setLoading(false);
3531
+ setIsFetching(false);
3532
+ return;
3533
+ }
3534
+ fetchData();
3535
+ return () => {
3536
+ abort();
3537
+ };
3538
+ }, [url, skip]);
3539
+ return {
3540
+ data,
3541
+ loading,
3542
+ error,
3543
+ refetch,
3544
+ abort,
3545
+ isFetching,
3546
+ status
3547
+ };
3548
+ }
3549
+ var useFetch_default = useFetch;
3550
+ var scriptCache = /* @__PURE__ */ new Map();
3551
+ function useScript(src, options = {}) {
3552
+ const { shouldLoad = true, removeOnUnmount = false, attributes = {} } = options;
3553
+ const [status, setStatus] = useState(() => {
3554
+ if (!src) return "idle";
3555
+ if (typeof window === "undefined") return "idle";
3556
+ const existingScript = document.querySelector(`script[src="${src}"]`);
3557
+ if (existingScript) {
3558
+ return scriptCache.get(src) || "ready";
3559
+ }
3560
+ return "idle";
3561
+ });
3562
+ const load = useCallback(() => {
3563
+ if (!src || typeof document === "undefined") return;
3564
+ const existingScript = document.querySelector(`script[src="${src}"]`);
3565
+ if (existingScript) {
3566
+ const cachedStatus = scriptCache.get(src);
3567
+ if (cachedStatus) {
3568
+ setStatus(cachedStatus);
3569
+ }
3570
+ return;
3571
+ }
3572
+ setStatus("loading");
3573
+ scriptCache.set(src, "loading");
3574
+ const script = document.createElement("script");
3575
+ script.src = src;
3576
+ script.async = true;
3577
+ Object.entries(attributes).forEach(([key, value]) => {
3578
+ script.setAttribute(key, value);
3579
+ });
3580
+ const handleLoad = () => {
3581
+ setStatus("ready");
3582
+ scriptCache.set(src, "ready");
3583
+ };
3584
+ const handleError = () => {
3585
+ setStatus("error");
3586
+ scriptCache.set(src, "error");
3587
+ };
3588
+ script.addEventListener("load", handleLoad);
3589
+ script.addEventListener("error", handleError);
3590
+ document.body.appendChild(script);
3591
+ }, [src, attributes]);
3592
+ const remove = useCallback(() => {
3593
+ if (!src || typeof document === "undefined") return;
3594
+ const existingScript = document.querySelector(`script[src="${src}"]`);
3595
+ if (existingScript) {
3596
+ document.body.removeChild(existingScript);
3597
+ scriptCache.delete(src);
3598
+ setStatus("idle");
3599
+ }
3600
+ }, [src]);
3601
+ useEffect(() => {
3602
+ if (shouldLoad && status === "idle") {
3603
+ load();
3604
+ }
3605
+ }, [shouldLoad, status, load]);
3606
+ useEffect(() => {
3607
+ return () => {
3608
+ if (removeOnUnmount) {
3609
+ remove();
1384
3610
  }
1385
3611
  };
1386
- }, [title, suffix, separator, restoreOnUnmount]);
3612
+ }, [removeOnUnmount, remove]);
3613
+ return {
3614
+ status,
3615
+ ready: status === "ready",
3616
+ loading: status === "loading",
3617
+ error: status === "error",
3618
+ load,
3619
+ remove
3620
+ };
1387
3621
  }
1388
- var usePageTitle_default = usePageTitle;
1389
- function useInterval(callback, delay) {
1390
- const savedCallback = useRef(callback);
3622
+ var useScript_default = useScript;
3623
+ function useRenderInfo(componentName = "Component") {
3624
+ const renderCount = useRef(0);
3625
+ const lastRenderTime = useRef(Date.now());
3626
+ const currentTime = Date.now();
3627
+ const sinceLastRender = currentTime - lastRenderTime.current;
3628
+ renderCount.current++;
3629
+ const renders = renderCount.current;
1391
3630
  useEffect(() => {
1392
- savedCallback.current = callback;
1393
- }, [callback]);
3631
+ lastRenderTime.current = currentTime;
3632
+ });
3633
+ const info = {
3634
+ name: componentName,
3635
+ renders,
3636
+ sinceLastRender,
3637
+ timestamp: currentTime
3638
+ };
3639
+ if (process.env.NODE_ENV === "development") {
3640
+ console.log(`[${componentName}] Render #${renders} (${sinceLastRender}ms since last)`);
3641
+ }
3642
+ return info;
3643
+ }
3644
+ var useRenderInfo_default = useRenderInfo;
3645
+ function useRenderCount() {
3646
+ const renderCount = useRef(0);
3647
+ renderCount.current++;
3648
+ return renderCount.current;
3649
+ }
3650
+ var useRenderCount_default = useRenderCount;
3651
+ function useLogger(componentName, props, options = {}) {
3652
+ const {
3653
+ logProps = true,
3654
+ logLifecycle = true,
3655
+ logger: logger2 = console.log
3656
+ } = options;
3657
+ const previousProps = useRef(props);
3658
+ const renderCount = useRef(0);
3659
+ renderCount.current++;
1394
3660
  useEffect(() => {
1395
- if (delay === null) {
3661
+ if (logLifecycle) {
3662
+ logger2(`[${componentName}] Mounted`);
3663
+ }
3664
+ return () => {
3665
+ if (logLifecycle) {
3666
+ logger2(`[${componentName}] Unmounted (rendered ${renderCount.current} times)`);
3667
+ }
3668
+ };
3669
+ }, []);
3670
+ useEffect(() => {
3671
+ if (!logProps || !props || !previousProps.current) {
3672
+ previousProps.current = props;
1396
3673
  return;
1397
3674
  }
1398
- const tick = () => savedCallback.current();
1399
- const id = setInterval(tick, delay);
1400
- return () => clearInterval(id);
1401
- }, [delay]);
3675
+ const changedProps = {};
3676
+ let hasChanges = false;
3677
+ Object.keys(props).forEach((key) => {
3678
+ if (previousProps.current?.[key] !== props[key]) {
3679
+ changedProps[key] = {
3680
+ from: previousProps.current?.[key],
3681
+ to: props[key]
3682
+ };
3683
+ hasChanges = true;
3684
+ }
3685
+ });
3686
+ if (previousProps.current) {
3687
+ Object.keys(previousProps.current).forEach((key) => {
3688
+ if (!(key in props)) {
3689
+ changedProps[key] = {
3690
+ from: previousProps.current?.[key],
3691
+ to: void 0
3692
+ };
3693
+ hasChanges = true;
3694
+ }
3695
+ });
3696
+ }
3697
+ if (hasChanges) {
3698
+ logger2(`[${componentName}] Props changed:`, changedProps);
3699
+ }
3700
+ previousProps.current = props;
3701
+ }, [componentName, props, logProps, logger2]);
3702
+ if (process.env.NODE_ENV === "development") {
3703
+ logger2(`[${componentName}] Render #${renderCount.current}`);
3704
+ }
1402
3705
  }
1403
- var useInterval_default = useInterval;
1404
- function useThemeDetector() {
1405
- const getCurrentTheme = () => {
1406
- if (typeof window === "undefined") return "light";
1407
- return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
1408
- };
1409
- const [theme, setTheme] = useState(getCurrentTheme);
3706
+ var useLogger_default = useLogger;
3707
+ var defaultDimensions = {
3708
+ width: 0,
3709
+ height: 0,
3710
+ top: 0,
3711
+ left: 0,
3712
+ bottom: 0,
3713
+ right: 0,
3714
+ x: 0,
3715
+ y: 0
3716
+ };
3717
+ function useMeasure() {
3718
+ const [dimensions, setDimensions] = useState(defaultDimensions);
3719
+ const elementRef = useRef(null);
3720
+ const observerRef = useRef(null);
3721
+ const measure = useCallback(() => {
3722
+ if (!elementRef.current) return;
3723
+ const rect = elementRef.current.getBoundingClientRect();
3724
+ setDimensions({
3725
+ width: rect.width,
3726
+ height: rect.height,
3727
+ top: rect.top,
3728
+ left: rect.left,
3729
+ bottom: rect.bottom,
3730
+ right: rect.right,
3731
+ x: rect.x,
3732
+ y: rect.y
3733
+ });
3734
+ }, []);
3735
+ const ref = useCallback((node) => {
3736
+ if (observerRef.current) {
3737
+ observerRef.current.disconnect();
3738
+ observerRef.current = null;
3739
+ }
3740
+ if (node) {
3741
+ elementRef.current = node;
3742
+ if (typeof ResizeObserver !== "undefined") {
3743
+ observerRef.current = new ResizeObserver((entries) => {
3744
+ if (entries[0]) {
3745
+ const rect2 = entries[0].target.getBoundingClientRect();
3746
+ setDimensions({
3747
+ width: rect2.width,
3748
+ height: rect2.height,
3749
+ top: rect2.top,
3750
+ left: rect2.left,
3751
+ bottom: rect2.bottom,
3752
+ right: rect2.right,
3753
+ x: rect2.x,
3754
+ y: rect2.y
3755
+ });
3756
+ }
3757
+ });
3758
+ observerRef.current.observe(node);
3759
+ }
3760
+ const rect = node.getBoundingClientRect();
3761
+ setDimensions({
3762
+ width: rect.width,
3763
+ height: rect.height,
3764
+ top: rect.top,
3765
+ left: rect.left,
3766
+ bottom: rect.bottom,
3767
+ right: rect.right,
3768
+ x: rect.x,
3769
+ y: rect.y
3770
+ });
3771
+ } else {
3772
+ elementRef.current = null;
3773
+ }
3774
+ }, []);
1410
3775
  useEffect(() => {
1411
- if (typeof window === "undefined") return;
1412
- const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
1413
- const handleChange = (e) => {
1414
- setTheme(e.matches ? "dark" : "light");
3776
+ return () => {
3777
+ if (observerRef.current) {
3778
+ observerRef.current.disconnect();
3779
+ }
1415
3780
  };
1416
- mediaQuery.addEventListener("change", handleChange);
1417
- return () => mediaQuery.removeEventListener("change", handleChange);
1418
3781
  }, []);
1419
- return theme;
3782
+ return { ref, dimensions, measure };
1420
3783
  }
1421
- var useThemeDetector_default = useThemeDetector;
3784
+ var useMeasure_default = useMeasure;
3785
+ function useIntersectionObserver(options = {}) {
3786
+ const {
3787
+ root = null,
3788
+ rootMargin = "0px",
3789
+ threshold = 0,
3790
+ freezeOnceVisible = false,
3791
+ initialIsIntersecting = false,
3792
+ onChange
3793
+ } = options;
3794
+ const [entry, setEntry] = useState(null);
3795
+ const [isIntersecting, setIsIntersecting] = useState(initialIsIntersecting);
3796
+ const elementRef = useRef(null);
3797
+ const observerRef = useRef(null);
3798
+ const frozen = useRef(false);
3799
+ const ref = useCallback(
3800
+ (node) => {
3801
+ if (observerRef.current) {
3802
+ observerRef.current.disconnect();
3803
+ observerRef.current = null;
3804
+ }
3805
+ if (frozen.current) return;
3806
+ if (node && typeof IntersectionObserver !== "undefined") {
3807
+ elementRef.current = node;
3808
+ observerRef.current = new IntersectionObserver(
3809
+ ([observerEntry]) => {
3810
+ const newIsIntersecting = observerEntry.isIntersecting;
3811
+ setEntry(observerEntry);
3812
+ setIsIntersecting(newIsIntersecting);
3813
+ onChange?.(newIsIntersecting, observerEntry);
3814
+ if (freezeOnceVisible && newIsIntersecting) {
3815
+ frozen.current = true;
3816
+ observerRef.current?.disconnect();
3817
+ }
3818
+ },
3819
+ { root, rootMargin, threshold }
3820
+ );
3821
+ observerRef.current.observe(node);
3822
+ } else {
3823
+ elementRef.current = null;
3824
+ }
3825
+ },
3826
+ [root, rootMargin, threshold, freezeOnceVisible, onChange]
3827
+ );
3828
+ useEffect(() => {
3829
+ return () => {
3830
+ if (observerRef.current) {
3831
+ observerRef.current.disconnect();
3832
+ }
3833
+ };
3834
+ }, []);
3835
+ return { ref, isIntersecting, entry };
3836
+ }
3837
+ var useIntersectionObserver_default = useIntersectionObserver;
1422
3838
  var DEFAULT_DURATION = 4e3;
1423
3839
  function useSnackbar(defaultDuration = DEFAULT_DURATION) {
1424
3840
  const [state, setState] = useState({
@@ -1460,86 +3876,44 @@ function useSnackbar(defaultDuration = DEFAULT_DURATION) {
1460
3876
  return { state, show, success, error, warning, info, close };
1461
3877
  }
1462
3878
  var useSnackbar_default = useSnackbar;
1463
- function useMediaQuery(query) {
1464
- const getMatches = (query2) => {
1465
- if (typeof window === "undefined") return false;
1466
- return window.matchMedia(query2).matches;
1467
- };
1468
- const [matches, setMatches] = useState(getMatches(query));
1469
- useEffect(() => {
1470
- if (typeof window === "undefined") return;
1471
- const mediaQuery = window.matchMedia(query);
1472
- const handleChange = () => setMatches(mediaQuery.matches);
1473
- handleChange();
1474
- mediaQuery.addEventListener("change", handleChange);
1475
- return () => mediaQuery.removeEventListener("change", handleChange);
1476
- }, [query]);
1477
- return matches;
1478
- }
1479
- var useIsMobile = () => useMediaQuery("(max-width: 767px)");
1480
- var useIsTablet = () => useMediaQuery("(min-width: 768px) and (max-width: 1023px)");
1481
- var useIsDesktop = () => useMediaQuery("(min-width: 1024px)");
1482
- var useIsMobileOrTablet = () => useMediaQuery("(max-width: 1023px)");
1483
- var useMediaQuery_default = useMediaQuery;
1484
- function useOnClickOutside(ref, handler, enabled = true) {
1485
- useEffect(() => {
1486
- if (!enabled) return;
1487
- const listener = (event) => {
1488
- const el = ref?.current;
1489
- if (!el || el.contains(event.target)) {
1490
- return;
1491
- }
1492
- handler(event);
1493
- };
1494
- document.addEventListener("mousedown", listener);
1495
- document.addEventListener("touchstart", listener);
1496
- return () => {
1497
- document.removeEventListener("mousedown", listener);
1498
- document.removeEventListener("touchstart", listener);
1499
- };
1500
- }, [ref, handler, enabled]);
1501
- }
1502
- var useOnClickOutside_default = useOnClickOutside;
1503
- function useWindowSize(debounceMs = 100) {
1504
- const getSize = () => ({
1505
- width: typeof window !== "undefined" ? window.innerWidth : 0,
1506
- height: typeof window !== "undefined" ? window.innerHeight : 0
1507
- });
1508
- const [windowSize, setWindowSize] = useState(getSize);
1509
- useEffect(() => {
1510
- if (typeof window === "undefined") return;
1511
- let timeoutId;
1512
- const handleResize = () => {
1513
- clearTimeout(timeoutId);
1514
- timeoutId = setTimeout(() => {
1515
- setWindowSize(getSize());
1516
- }, debounceMs);
1517
- };
1518
- setWindowSize(getSize());
1519
- window.addEventListener("resize", handleResize);
1520
- return () => {
1521
- clearTimeout(timeoutId);
1522
- window.removeEventListener("resize", handleResize);
1523
- };
1524
- }, [debounceMs]);
1525
- return windowSize;
1526
- }
1527
- var useWindowSize_default = useWindowSize;
1528
3879
 
1529
3880
  // src/shared/index.ts
1530
3881
  var shared_exports = {};
1531
3882
  __export(shared_exports, {
3883
+ BREAKPOINTS: () => BREAKPOINTS,
3884
+ CONTAINER_WIDTHS: () => CONTAINER_WIDTHS,
3885
+ DATE_FORMAT: () => DATE_FORMAT,
1532
3886
  DATE_FORMATS: () => DATE_FORMATS,
3887
+ ENUMS: () => ENUMS,
3888
+ ENUMS_DEFAULT: () => enums_default,
3889
+ FILE_TYPE: () => FILE_TYPE,
3890
+ GENDER: () => GENDER,
1533
3891
  HTTP_STATUS: () => HTTP_STATUS,
1534
3892
  HTTP_STATUS_MESSAGES: () => HTTP_STATUS_MESSAGES,
3893
+ INTERVAL: () => INTERVAL,
3894
+ LOCALE: () => LOCALE,
3895
+ MEDIA_QUERIES: () => MEDIA_QUERIES,
3896
+ MEDIA_QUERIES_MAX: () => MEDIA_QUERIES_MAX,
3897
+ NOTIFICATION_TYPE: () => NOTIFICATION_TYPE,
3898
+ ORDER_STATUS: () => ORDER_STATUS,
1535
3899
  PAGINATION: () => PAGINATION,
3900
+ PAYMENT_STATUS: () => PAYMENT_STATUS,
3901
+ PERMISSION_LEVEL: () => PERMISSION_LEVEL,
3902
+ PRIORITY: () => PRIORITY,
3903
+ ROLE: () => ROLE,
1536
3904
  ROLES: () => ROLES,
3905
+ SORT: () => SORT,
3906
+ SORT_DIRECTION: () => SORT_DIRECTION,
1537
3907
  STATUS: () => STATUS,
3908
+ SUBSCRIPTION_STATUS: () => SUBSCRIPTION_STATUS,
3909
+ TASK_STATUS: () => TASK_STATUS,
3910
+ THEME: () => THEME,
1538
3911
  TOKEN_TYPES: () => TOKEN_TYPES,
1539
3912
  USER_STATUS: () => USER_STATUS,
1540
3913
  VALIDATION_MESSAGES: () => VALIDATION_MESSAGES,
1541
3914
  VALIDATION_PATTERNS: () => VALIDATION_PATTERNS,
1542
3915
  VALIDATION_RULES: () => VALIDATION_RULES,
3916
+ VISIBILITY: () => VISIBILITY,
1543
3917
  addDays: () => addDays$1,
1544
3918
  addHours: () => addHours,
1545
3919
  addMinutes: () => addMinutes,
@@ -1786,6 +4160,279 @@ var TOKEN_TYPES = {
1786
4160
  RESET_PASSWORD: "reset_password",
1787
4161
  EMAIL_VERIFICATION: "email_verification"
1788
4162
  };
4163
+
4164
+ // src/shared/constants/enums.ts
4165
+ var STATUS2 = {
4166
+ ACTIVE: "active",
4167
+ INACTIVE: "inactive",
4168
+ PENDING: "pending",
4169
+ APPROVED: "approved",
4170
+ REJECTED: "rejected",
4171
+ ARCHIVED: "archived",
4172
+ DELETED: "deleted",
4173
+ DRAFT: "draft",
4174
+ PUBLISHED: "published",
4175
+ SUSPENDED: "suspended",
4176
+ EXPIRED: "expired",
4177
+ CANCELLED: "cancelled"
4178
+ };
4179
+ var USER_STATUS2 = {
4180
+ ACTIVE: "active",
4181
+ INACTIVE: "inactive",
4182
+ PENDING: "pending",
4183
+ SUSPENDED: "suspended",
4184
+ BANNED: "banned",
4185
+ DELETED: "deleted",
4186
+ UNVERIFIED: "unverified",
4187
+ VERIFIED: "verified"
4188
+ };
4189
+ var ORDER_STATUS = {
4190
+ PENDING: "pending",
4191
+ CONFIRMED: "confirmed",
4192
+ PROCESSING: "processing",
4193
+ SHIPPED: "shipped",
4194
+ DELIVERED: "delivered",
4195
+ CANCELLED: "cancelled",
4196
+ REFUNDED: "refunded",
4197
+ FAILED: "failed",
4198
+ ON_HOLD: "on_hold"
4199
+ };
4200
+ var PAYMENT_STATUS = {
4201
+ PENDING: "pending",
4202
+ PROCESSING: "processing",
4203
+ COMPLETED: "completed",
4204
+ FAILED: "failed",
4205
+ CANCELLED: "cancelled",
4206
+ REFUNDED: "refunded",
4207
+ PARTIALLY_REFUNDED: "partially_refunded",
4208
+ DISPUTED: "disputed"
4209
+ };
4210
+ var TASK_STATUS = {
4211
+ TODO: "todo",
4212
+ IN_PROGRESS: "in_progress",
4213
+ IN_REVIEW: "in_review",
4214
+ DONE: "done",
4215
+ BLOCKED: "blocked",
4216
+ CANCELLED: "cancelled",
4217
+ ON_HOLD: "on_hold"
4218
+ };
4219
+ var SUBSCRIPTION_STATUS = {
4220
+ ACTIVE: "active",
4221
+ TRIAL: "trial",
4222
+ PAST_DUE: "past_due",
4223
+ CANCELLED: "cancelled",
4224
+ EXPIRED: "expired",
4225
+ PAUSED: "paused",
4226
+ PENDING: "pending"
4227
+ };
4228
+ var SORT_DIRECTION = {
4229
+ ASC: "asc",
4230
+ DESC: "desc"
4231
+ };
4232
+ var SORT = {
4233
+ // Date sorting
4234
+ NEWEST: "newest",
4235
+ OLDEST: "oldest",
4236
+ CREATED_AT_ASC: "created_at_asc",
4237
+ CREATED_AT_DESC: "created_at_desc",
4238
+ UPDATED_AT_ASC: "updated_at_asc",
4239
+ UPDATED_AT_DESC: "updated_at_desc",
4240
+ // Alphabetical
4241
+ NAME_ASC: "name_asc",
4242
+ NAME_DESC: "name_desc",
4243
+ TITLE_ASC: "title_asc",
4244
+ TITLE_DESC: "title_desc",
4245
+ ALPHABETICAL: "alphabetical",
4246
+ REVERSE_ALPHABETICAL: "reverse_alphabetical",
4247
+ // Numeric
4248
+ PRICE_ASC: "price_asc",
4249
+ PRICE_DESC: "price_desc",
4250
+ AMOUNT_ASC: "amount_asc",
4251
+ AMOUNT_DESC: "amount_desc",
4252
+ // Popularity/Engagement
4253
+ POPULAR: "popular",
4254
+ TRENDING: "trending",
4255
+ MOST_VIEWED: "most_viewed",
4256
+ MOST_LIKED: "most_liked",
4257
+ MOST_COMMENTED: "most_commented",
4258
+ TOP_RATED: "top_rated",
4259
+ // Relevance
4260
+ RELEVANCE: "relevance",
4261
+ BEST_MATCH: "best_match",
4262
+ // Custom
4263
+ CUSTOM: "custom",
4264
+ MANUAL: "manual",
4265
+ RANDOM: "random"
4266
+ };
4267
+ var ROLE = {
4268
+ // System roles
4269
+ SUPER_ADMIN: "super_admin",
4270
+ ADMIN: "admin",
4271
+ MODERATOR: "moderator",
4272
+ SUPPORT: "support",
4273
+ // User roles
4274
+ USER: "user",
4275
+ MEMBER: "member",
4276
+ GUEST: "guest",
4277
+ // Business roles
4278
+ OWNER: "owner",
4279
+ MANAGER: "manager",
4280
+ EDITOR: "editor",
4281
+ VIEWER: "viewer",
4282
+ CONTRIBUTOR: "contributor",
4283
+ // Team roles
4284
+ TEAM_LEAD: "team_lead",
4285
+ TEAM_MEMBER: "team_member",
4286
+ // API roles
4287
+ API_USER: "api_user",
4288
+ SERVICE: "service",
4289
+ BOT: "bot"
4290
+ };
4291
+ var PERMISSION_LEVEL = {
4292
+ NONE: 0,
4293
+ READ: 1,
4294
+ WRITE: 2,
4295
+ DELETE: 3,
4296
+ ADMIN: 4,
4297
+ SUPER_ADMIN: 5
4298
+ };
4299
+ var PRIORITY = {
4300
+ LOWEST: "lowest",
4301
+ LOW: "low",
4302
+ MEDIUM: "medium",
4303
+ HIGH: "high",
4304
+ HIGHEST: "highest",
4305
+ URGENT: "urgent",
4306
+ CRITICAL: "critical"
4307
+ };
4308
+ var VISIBILITY = {
4309
+ PUBLIC: "public",
4310
+ PRIVATE: "private",
4311
+ INTERNAL: "internal",
4312
+ RESTRICTED: "restricted",
4313
+ HIDDEN: "hidden",
4314
+ UNLISTED: "unlisted"
4315
+ };
4316
+ var BREAKPOINTS = {
4317
+ xs: 0,
4318
+ sm: 640,
4319
+ md: 768,
4320
+ lg: 1024,
4321
+ xl: 1280,
4322
+ "2xl": 1536
4323
+ };
4324
+ var MEDIA_QUERIES = {
4325
+ xs: "(min-width: 0px)",
4326
+ sm: "(min-width: 640px)",
4327
+ md: "(min-width: 768px)",
4328
+ lg: "(min-width: 1024px)",
4329
+ xl: "(min-width: 1280px)",
4330
+ "2xl": "(min-width: 1536px)"
4331
+ };
4332
+ var MEDIA_QUERIES_MAX = {
4333
+ xs: "(max-width: 639px)",
4334
+ sm: "(max-width: 767px)",
4335
+ md: "(max-width: 1023px)",
4336
+ lg: "(max-width: 1279px)",
4337
+ xl: "(max-width: 1535px)",
4338
+ "2xl": "(max-width: 9999px)"
4339
+ };
4340
+ var CONTAINER_WIDTHS = {
4341
+ sm: 640,
4342
+ md: 768,
4343
+ lg: 1024,
4344
+ xl: 1280,
4345
+ "2xl": 1536
4346
+ };
4347
+ var FILE_TYPE = {
4348
+ IMAGE: "image",
4349
+ VIDEO: "video",
4350
+ AUDIO: "audio",
4351
+ DOCUMENT: "document",
4352
+ SPREADSHEET: "spreadsheet",
4353
+ PRESENTATION: "presentation",
4354
+ ARCHIVE: "archive",
4355
+ CODE: "code",
4356
+ OTHER: "other"
4357
+ };
4358
+ var NOTIFICATION_TYPE = {
4359
+ INFO: "info",
4360
+ SUCCESS: "success",
4361
+ WARNING: "warning",
4362
+ ERROR: "error",
4363
+ ALERT: "alert"
4364
+ };
4365
+ var THEME = {
4366
+ LIGHT: "light",
4367
+ DARK: "dark",
4368
+ SYSTEM: "system"
4369
+ };
4370
+ var LOCALE = {
4371
+ EN_US: "en-US",
4372
+ EN_GB: "en-GB",
4373
+ ES_ES: "es-ES",
4374
+ FR_FR: "fr-FR",
4375
+ DE_DE: "de-DE",
4376
+ IT_IT: "it-IT",
4377
+ PT_BR: "pt-BR",
4378
+ JA_JP: "ja-JP",
4379
+ ZH_CN: "zh-CN",
4380
+ ZH_TW: "zh-TW",
4381
+ KO_KR: "ko-KR",
4382
+ HI_IN: "hi-IN",
4383
+ AR_SA: "ar-SA",
4384
+ RU_RU: "ru-RU"
4385
+ };
4386
+ var DATE_FORMAT = {
4387
+ ISO: "yyyy-MM-dd",
4388
+ US: "MM/dd/yyyy",
4389
+ EU: "dd/MM/yyyy",
4390
+ LONG: "MMMM d, yyyy",
4391
+ SHORT: "MMM d, yyyy",
4392
+ WITH_TIME: "yyyy-MM-dd HH:mm:ss",
4393
+ RELATIVE: "relative"
4394
+ };
4395
+ var INTERVAL = {
4396
+ DAILY: "daily",
4397
+ WEEKLY: "weekly",
4398
+ BIWEEKLY: "biweekly",
4399
+ MONTHLY: "monthly",
4400
+ QUARTERLY: "quarterly",
4401
+ YEARLY: "yearly",
4402
+ ONCE: "once"
4403
+ };
4404
+ var GENDER = {
4405
+ MALE: "male",
4406
+ FEMALE: "female",
4407
+ OTHER: "other",
4408
+ PREFER_NOT_TO_SAY: "prefer_not_to_say"
4409
+ };
4410
+ var ENUMS = {
4411
+ STATUS: STATUS2,
4412
+ USER_STATUS: USER_STATUS2,
4413
+ ORDER_STATUS,
4414
+ PAYMENT_STATUS,
4415
+ TASK_STATUS,
4416
+ SUBSCRIPTION_STATUS,
4417
+ SORT_DIRECTION,
4418
+ SORT,
4419
+ ROLE,
4420
+ PERMISSION_LEVEL,
4421
+ PRIORITY,
4422
+ VISIBILITY,
4423
+ BREAKPOINTS,
4424
+ MEDIA_QUERIES,
4425
+ MEDIA_QUERIES_MAX,
4426
+ CONTAINER_WIDTHS,
4427
+ FILE_TYPE,
4428
+ NOTIFICATION_TYPE,
4429
+ THEME,
4430
+ LOCALE,
4431
+ DATE_FORMAT,
4432
+ INTERVAL,
4433
+ GENDER
4434
+ };
4435
+ var enums_default = ENUMS;
1789
4436
  var parseDate = (date) => {
1790
4437
  if (date instanceof Date) return date;
1791
4438
  if (typeof date === "string") return parseISO(date);
@@ -2262,27 +4909,137 @@ var VALIDATION_RULES = {
2262
4909
  // src/data/index.ts
2263
4910
  var data_exports = {};
2264
4911
  __export(data_exports, {
4912
+ AADHAAR_INDIA: () => AADHAAR_INDIA,
4913
+ ALPHANUMERIC: () => ALPHANUMERIC,
4914
+ AMEX: () => AMEX,
4915
+ APPS: () => APPS,
4916
+ ARCHIVE_EXT: () => ARCHIVE_EXT,
4917
+ AUDIO_EXT: () => AUDIO_EXT,
4918
+ BASE64: () => BASE64,
4919
+ BRANDS: () => BRANDS,
4920
+ CARD_EXPIRY: () => CARD_EXPIRY,
4921
+ CREDIT_CARD: () => CREDIT_CARD,
4922
+ CUID: () => CUID,
4923
+ CUID2: () => CUID2,
4924
+ CVV: () => CVV,
4925
+ DATETIME_ISO: () => DATETIME_ISO,
4926
+ DATE_DMY: () => DATE_DMY,
4927
+ DATE_ISO: () => DATE_ISO,
4928
+ DATE_MDY: () => DATE_MDY,
4929
+ DECIMAL: () => DECIMAL,
4930
+ DISCOVER: () => DISCOVER,
4931
+ DL_INDIA: () => DL_INDIA,
4932
+ DOCUMENT_EXT: () => DOCUMENT_EXT,
4933
+ DOMAIN: () => DOMAIN,
4934
+ EMAIL: () => EMAIL,
4935
+ EMAIL_COMMON_DOMAINS: () => EMAIL_COMMON_DOMAINS,
4936
+ EMAIL_RFC5322: () => EMAIL_RFC5322,
4937
+ EMOJI: () => EMOJI,
4938
+ GST_INDIA: () => GST_INDIA,
4939
+ HANDLE: () => HANDLE,
4940
+ HASHTAG: () => HASHTAG,
4941
+ HAS_DIGIT: () => HAS_DIGIT,
4942
+ HAS_LOWERCASE: () => HAS_LOWERCASE,
4943
+ HAS_SPECIAL: () => HAS_SPECIAL,
4944
+ HAS_UPPERCASE: () => HAS_UPPERCASE,
4945
+ HEX_COLOR: () => HEX_COLOR,
4946
+ HEX_COLOR_ALPHA: () => HEX_COLOR_ALPHA,
4947
+ HSL_COLOR: () => HSL_COLOR,
4948
+ HTML_TAG: () => HTML_TAG,
4949
+ IFSC_INDIA: () => IFSC_INDIA,
4950
+ IMAGE_EXT: () => IMAGE_EXT,
4951
+ IPV4: () => IPV4,
4952
+ IPV6: () => IPV6,
4953
+ JSON_STRING: () => JSON_STRING,
4954
+ JWT: () => JWT,
4955
+ LATITUDE: () => LATITUDE,
4956
+ LETTERS_ONLY: () => LETTERS_ONLY,
4957
+ LOCALHOST: () => LOCALHOST,
4958
+ LONGITUDE: () => LONGITUDE,
4959
+ MAC_ADDRESS: () => MAC_ADDRESS,
4960
+ MASTERCARD: () => MASTERCARD,
4961
+ MENTION: () => MENTION,
4962
+ MONGO_OBJECT_ID: () => MONGO_OBJECT_ID,
4963
+ NANOID: () => NANOID,
4964
+ NON_NEGATIVE_INTEGER: () => NON_NEGATIVE_INTEGER,
4965
+ NO_SPECIAL_CHARS: () => NO_SPECIAL_CHARS,
4966
+ NO_WHITESPACE: () => NO_WHITESPACE,
4967
+ NUMBERS_ONLY: () => NUMBERS_ONLY,
4968
+ PAN_INDIA: () => PAN_INDIA,
4969
+ PASSWORD_ALPHANUMERIC: () => PASSWORD_ALPHANUMERIC,
4970
+ PASSWORD_MEDIUM: () => PASSWORD_MEDIUM,
4971
+ PASSWORD_MIN_8: () => PASSWORD_MIN_8,
4972
+ PASSWORD_STRONG: () => PASSWORD_STRONG,
4973
+ PASSWORD_VERY_STRONG: () => PASSWORD_VERY_STRONG,
4974
+ PHONE_10_DIGIT: () => PHONE_10_DIGIT,
4975
+ PHONE_INDIA: () => PHONE_INDIA,
4976
+ PHONE_INTERNATIONAL: () => PHONE_INTERNATIONAL,
4977
+ PHONE_UK: () => PHONE_UK,
4978
+ PHONE_US: () => PHONE_US,
4979
+ PHONE_WITH_CODE: () => PHONE_WITH_CODE,
4980
+ PIN_INDIA: () => PIN_INDIA,
4981
+ PLZ_GERMANY: () => PLZ_GERMANY,
4982
+ POSITIVE_INTEGER: () => POSITIVE_INTEGER,
4983
+ POSTAL_CANADA: () => POSTAL_CANADA,
4984
+ POSTAL_GENERIC: () => POSTAL_GENERIC,
4985
+ POSTAL_UK: () => POSTAL_UK,
4986
+ REGEX: () => regex_default,
4987
+ RGBA_COLOR: () => RGBA_COLOR,
4988
+ RGB_COLOR: () => RGB_COLOR,
4989
+ SAFE_FILENAME: () => SAFE_FILENAME,
4990
+ SEMVER: () => SEMVER,
4991
+ SLUG: () => SLUG,
4992
+ SSN_US: () => SSN_US,
4993
+ SUBDOMAIN: () => SUBDOMAIN,
4994
+ TIME_12H: () => TIME_12H,
4995
+ TIME_24H: () => TIME_24H,
4996
+ TIME_24H_SECONDS: () => TIME_24H_SECONDS,
4997
+ URL_BASIC: () => URL_BASIC,
4998
+ URL_OPTIONAL_PROTOCOL: () => URL_OPTIONAL_PROTOCOL,
4999
+ URL_STRICT: () => URL_STRICT,
5000
+ USERNAME: () => USERNAME,
5001
+ USERNAME_ALPHA_START: () => USERNAME_ALPHA_START,
5002
+ UUID: () => UUID,
5003
+ UUID_V4: () => UUID_V4,
5004
+ VEHICLE_INDIA: () => VEHICLE_INDIA,
5005
+ VIDEO_EXT: () => VIDEO_EXT,
5006
+ VISA: () => VISA,
5007
+ ZIP_US: () => ZIP_US,
2265
5008
  brands: () => logos_default,
5009
+ codeToFlag: () => codeToFlag,
2266
5010
  countries: () => countries_default,
5011
+ createAppConfig: () => createAppConfig,
2267
5012
  currencies: () => currencies_default,
5013
+ detectCurrentBrand: () => detectCurrentBrand,
2268
5014
  formatCurrency: () => formatCurrency,
2269
5015
  formatCurrencyNative: () => formatCurrencyNative,
5016
+ getAllBrandIds: () => getAllBrandIds,
2270
5017
  getAllBrandKeys: () => getAllBrandKeys,
2271
- getAllBrands: () => getAllBrands,
5018
+ getAllBrands: () => getAllBrands2,
2272
5019
  getAllCities: () => getAllCities,
5020
+ getAllCountriesWithFlags: () => getAllCountriesWithFlags,
5021
+ getAppConfigByDomain: () => getAppConfigByDomain,
2273
5022
  getBrand: () => getBrand,
2274
- getBrandByDomain: () => getBrandByDomain,
5023
+ getBrandByDomain: () => getBrandByDomain2,
5024
+ getBrandById: () => getBrandById,
2275
5025
  getCitiesByState: () => getCitiesByState,
2276
5026
  getCountriesByContinent: () => getCountriesByContinent,
2277
5027
  getCountryByCode: () => getCountryByCode,
2278
5028
  getCountryByName: () => getCountryByName,
5029
+ getCountryWithFlag: () => getCountryWithFlag,
2279
5030
  getCurrencyByCode: () => getCurrencyByCode,
2280
- getLogo: () => getLogo,
5031
+ getFlag: () => getFlag,
5032
+ getLegacyAllBrands: () => getAllBrands,
5033
+ getLegacyBrandByDomain: () => getBrandByDomain,
5034
+ getLegacyLogo: () => getLogo,
5035
+ getLogo: () => getLogo2,
2281
5036
  getPhoneCodeByCountry: () => getPhoneCodeByCountry,
2282
5037
  getPhoneCodesByPrefix: () => getPhoneCodesByPrefix,
2283
5038
  getStatesByCountry: () => getStatesByCountry,
5039
+ getThemedLogo: () => getThemedLogo,
2284
5040
  getTimezoneByName: () => getTimezoneByName,
2285
5041
  getTimezonesByOffset: () => getTimezonesByOffset,
5042
+ legacyBrands: () => brands,
2286
5043
  phoneCodes: () => phone_codes_default,
2287
5044
  searchCountries: () => searchCountries,
2288
5045
  searchCurrencies: () => searchCurrencies,
@@ -2293,11 +5050,16 @@ __export(data_exports, {
2293
5050
  });
2294
5051
 
2295
5052
  // src/data/countries.ts
5053
+ var codeToFlag = (countryCode) => {
5054
+ const codePoints = countryCode.toUpperCase().split("").map((char) => 127397 + char.charCodeAt(0));
5055
+ return String.fromCodePoint(...codePoints);
5056
+ };
2296
5057
  var countries = [
2297
5058
  {
2298
5059
  name: "Afghanistan",
2299
5060
  code: "AF",
2300
5061
  code3: "AFG",
5062
+ flag: "\u{1F1E6}\u{1F1EB}",
2301
5063
  phoneCode: "+93",
2302
5064
  currency: "AFN",
2303
5065
  currencySymbol: "\u060B",
@@ -2314,6 +5076,7 @@ var countries = [
2314
5076
  name: "Albania",
2315
5077
  code: "AL",
2316
5078
  code3: "ALB",
5079
+ flag: "\u{1F1E6}\u{1F1F1}",
2317
5080
  phoneCode: "+355",
2318
5081
  currency: "ALL",
2319
5082
  currencySymbol: "L",
@@ -2329,6 +5092,7 @@ var countries = [
2329
5092
  name: "Algeria",
2330
5093
  code: "DZ",
2331
5094
  code3: "DZA",
5095
+ flag: "\u{1F1E9}\u{1F1FF}",
2332
5096
  phoneCode: "+213",
2333
5097
  currency: "DZD",
2334
5098
  currencySymbol: "\u062F.\u062C",
@@ -2344,6 +5108,7 @@ var countries = [
2344
5108
  name: "Argentina",
2345
5109
  code: "AR",
2346
5110
  code3: "ARG",
5111
+ flag: "\u{1F1E6}\u{1F1F7}",
2347
5112
  phoneCode: "+54",
2348
5113
  currency: "ARS",
2349
5114
  currencySymbol: "$",
@@ -2360,6 +5125,7 @@ var countries = [
2360
5125
  name: "Australia",
2361
5126
  code: "AU",
2362
5127
  code3: "AUS",
5128
+ flag: "\u{1F1E6}\u{1F1FA}",
2363
5129
  phoneCode: "+61",
2364
5130
  currency: "AUD",
2365
5131
  currencySymbol: "$",
@@ -2381,6 +5147,7 @@ var countries = [
2381
5147
  name: "Austria",
2382
5148
  code: "AT",
2383
5149
  code3: "AUT",
5150
+ flag: "\u{1F1E6}\u{1F1F9}",
2384
5151
  phoneCode: "+43",
2385
5152
  currency: "EUR",
2386
5153
  currencySymbol: "\u20AC",
@@ -2397,6 +5164,7 @@ var countries = [
2397
5164
  name: "Bangladesh",
2398
5165
  code: "BD",
2399
5166
  code3: "BGD",
5167
+ flag: "\u{1F1E7}\u{1F1E9}",
2400
5168
  phoneCode: "+880",
2401
5169
  currency: "BDT",
2402
5170
  currencySymbol: "\u09F3",
@@ -2415,6 +5183,7 @@ var countries = [
2415
5183
  name: "Belgium",
2416
5184
  code: "BE",
2417
5185
  code3: "BEL",
5186
+ flag: "\u{1F1E7}\u{1F1EA}",
2418
5187
  phoneCode: "+32",
2419
5188
  currency: "EUR",
2420
5189
  currencySymbol: "\u20AC",
@@ -2431,6 +5200,7 @@ var countries = [
2431
5200
  name: "Brazil",
2432
5201
  code: "BR",
2433
5202
  code3: "BRA",
5203
+ flag: "\u{1F1E7}\u{1F1F7}",
2434
5204
  phoneCode: "+55",
2435
5205
  currency: "BRL",
2436
5206
  currencySymbol: "R$",
@@ -2451,6 +5221,7 @@ var countries = [
2451
5221
  name: "Canada",
2452
5222
  code: "CA",
2453
5223
  code3: "CAN",
5224
+ flag: "\u{1F1E8}\u{1F1E6}",
2454
5225
  phoneCode: "+1",
2455
5226
  currency: "CAD",
2456
5227
  currencySymbol: "$",
@@ -3229,6 +6000,21 @@ var searchCountries = (query) => {
3229
6000
  (c) => c.name.toLowerCase().includes(lowerQuery) || c.code.toLowerCase() === lowerQuery || c.code3.toLowerCase() === lowerQuery
3230
6001
  );
3231
6002
  };
6003
+ var getFlag = (countryCode) => {
6004
+ const country = getCountryByCode(countryCode);
6005
+ return country?.flag || codeToFlag(countryCode);
6006
+ };
6007
+ var getCountryWithFlag = (code) => {
6008
+ const country = getCountryByCode(code);
6009
+ if (!country) return void 0;
6010
+ return { ...country, flag: country.flag || codeToFlag(country.code) };
6011
+ };
6012
+ var getAllCountriesWithFlags = () => {
6013
+ return countries.map((c) => ({
6014
+ ...c,
6015
+ flag: c.flag || codeToFlag(c.code)
6016
+ }));
6017
+ };
3232
6018
  var countries_default = countries;
3233
6019
 
3234
6020
  // src/data/phone-codes.ts
@@ -3675,6 +6461,211 @@ var sortTimezonesByOffset = (ascending = true) => {
3675
6461
  };
3676
6462
  var timezones_default = timezones;
3677
6463
 
6464
+ // src/data/regex.ts
6465
+ var EMAIL = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
6466
+ var EMAIL_RFC5322 = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
6467
+ var EMAIL_COMMON_DOMAINS = /^[^\s@]+@(gmail|yahoo|outlook|hotmail|icloud|proton|aol|mail)\.[a-z]{2,}$/i;
6468
+ var PASSWORD_MIN_8 = /^.{8,}$/;
6469
+ var PASSWORD_ALPHANUMERIC = /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}$/;
6470
+ var PASSWORD_MEDIUM = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[A-Za-z\d@$!%*?&]{8,}$/;
6471
+ var PASSWORD_STRONG = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/;
6472
+ var PASSWORD_VERY_STRONG = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*#?&^()_+=[\]{}|;:'"<>,.\/\\-])[A-Za-z\d@$!%*#?&^()_+=[\]{}|;:'"<>,.\/\\-]{12,}$/;
6473
+ var PHONE_INTERNATIONAL = /^\+?[1-9]\d{1,14}$/;
6474
+ var PHONE_US = /^(\+1)?[-.\s]?\(?[0-9]{3}\)?[-.\s]?[0-9]{3}[-.\s]?[0-9]{4}$/;
6475
+ var PHONE_INDIA = /^(\+91)?[-.\s]?[6-9]\d{9}$/;
6476
+ var PHONE_UK = /^(\+44)?[-.\s]?[0-9]{10,11}$/;
6477
+ var PHONE_10_DIGIT = /^\d{10}$/;
6478
+ var PHONE_WITH_CODE = /^\+?[\d\s\-().]{10,20}$/;
6479
+ var ZIP_US = /^\d{5}(-\d{4})?$/;
6480
+ var PIN_INDIA = /^[1-9][0-9]{5}$/;
6481
+ var POSTAL_UK = /^[A-Z]{1,2}\d[A-Z\d]?\s*\d[A-Z]{2}$/i;
6482
+ var POSTAL_CANADA = /^[A-Z]\d[A-Z]\s?\d[A-Z]\d$/i;
6483
+ var PLZ_GERMANY = /^\d{5}$/;
6484
+ var POSTAL_GENERIC = /^[A-Z0-9]{4,10}$/i;
6485
+ var UUID_V4 = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
6486
+ var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
6487
+ var MONGO_OBJECT_ID = /^[0-9a-f]{24}$/i;
6488
+ var CUID = /^c[a-z0-9]{24}$/i;
6489
+ var CUID2 = /^[a-z][a-z0-9]{23}$/;
6490
+ var NANOID = /^[A-Za-z0-9_-]{21}$/;
6491
+ var AADHAAR_INDIA = /^[2-9]\d{11}$/;
6492
+ var PAN_INDIA = /^[A-Z]{5}[0-9]{4}[A-Z]$/;
6493
+ var GST_INDIA = /^[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z][1-9A-Z]Z[0-9A-Z]$/;
6494
+ var SSN_US = /^\d{3}-?\d{2}-?\d{4}$/;
6495
+ var DL_INDIA = /^[A-Z]{2}[0-9]{2}[0-9]{4}[0-9]{7}$/;
6496
+ var VEHICLE_INDIA = /^[A-Z]{2}[0-9]{2}[A-Z]{1,2}[0-9]{4}$/;
6497
+ var IFSC_INDIA = /^[A-Z]{4}0[A-Z0-9]{6}$/;
6498
+ var URL_BASIC = /^https?:\/\/[^\s$.?#].[^\s]*$/i;
6499
+ var URL_OPTIONAL_PROTOCOL = /^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([\/\w .-]*)*\/?$/i;
6500
+ var URL_STRICT = /^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)$/;
6501
+ var DOMAIN = /^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]$/i;
6502
+ var SUBDOMAIN = /^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i;
6503
+ var LOCALHOST = /^(localhost|127\.0\.0\.1)(:\d{1,5})?$/;
6504
+ var SLUG = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
6505
+ var USERNAME = /^[a-zA-Z0-9_-]{3,30}$/;
6506
+ var USERNAME_ALPHA_START = /^[a-zA-Z][a-zA-Z0-9_-]{2,29}$/;
6507
+ var HANDLE = /^@?[a-zA-Z0-9_]{1,15}$/;
6508
+ var CREDIT_CARD = /^\d{13,19}$/;
6509
+ var VISA = /^4[0-9]{12}(?:[0-9]{3})?$/;
6510
+ var MASTERCARD = /^5[1-5][0-9]{14}$/;
6511
+ var AMEX = /^3[47][0-9]{13}$/;
6512
+ var DISCOVER = /^6(?:011|5[0-9]{2})[0-9]{12}$/;
6513
+ var CVV = /^\d{3,4}$/;
6514
+ var CARD_EXPIRY = /^(0[1-9]|1[0-2])\/(\d{2}|\d{4})$/;
6515
+ var DATE_ISO = /^\d{4}-\d{2}-\d{2}$/;
6516
+ var DATE_DMY = /^(0[1-9]|[12]\d|3[01])\/(0[1-9]|1[0-2])\/\d{4}$/;
6517
+ var DATE_MDY = /^(0[1-9]|1[0-2])\/(0[1-9]|[12]\d|3[01])\/\d{4}$/;
6518
+ var TIME_24H = /^([01]\d|2[0-3]):([0-5]\d)$/;
6519
+ var TIME_24H_SECONDS = /^([01]\d|2[0-3]):([0-5]\d):([0-5]\d)$/;
6520
+ var TIME_12H = /^(0?[1-9]|1[0-2]):[0-5]\d\s?(AM|PM|am|pm)$/;
6521
+ var DATETIME_ISO = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{3})?(Z|[+-]\d{2}:\d{2})?$/;
6522
+ var IPV4 = /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
6523
+ var IPV6 = /^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/;
6524
+ var MAC_ADDRESS = /^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/;
6525
+ var IMAGE_EXT = /\.(jpg|jpeg|png|gif|bmp|webp|svg|ico|tiff?)$/i;
6526
+ var VIDEO_EXT = /\.(mp4|webm|ogg|avi|mov|wmv|flv|mkv)$/i;
6527
+ var AUDIO_EXT = /\.(mp3|wav|ogg|aac|flac|wma|m4a)$/i;
6528
+ var DOCUMENT_EXT = /\.(pdf|doc|docx|xls|xlsx|ppt|pptx|txt|rtf|odt|ods|odp)$/i;
6529
+ var ARCHIVE_EXT = /\.(zip|rar|7z|tar|gz|bz2)$/i;
6530
+ var SAFE_FILENAME = /^[a-zA-Z0-9._-]+$/;
6531
+ var HEX_COLOR = /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/;
6532
+ var HEX_COLOR_ALPHA = /^#([A-Fa-f0-9]{8}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{4}|[A-Fa-f0-9]{3})$/;
6533
+ var RGB_COLOR = /^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/;
6534
+ var RGBA_COLOR = /^rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(0|1|0?\.\d+)\s*\)$/;
6535
+ var HSL_COLOR = /^hsl\(\s*(\d{1,3})\s*,\s*(\d{1,3})%\s*,\s*(\d{1,3})%\s*\)$/;
6536
+ var ALPHANUMERIC = /^[a-zA-Z0-9]+$/;
6537
+ var LETTERS_ONLY = /^[a-zA-Z]+$/;
6538
+ var NUMBERS_ONLY = /^\d+$/;
6539
+ var DECIMAL = /^-?\d+(\.\d+)?$/;
6540
+ var POSITIVE_INTEGER = /^[1-9]\d*$/;
6541
+ var NON_NEGATIVE_INTEGER = /^\d+$/;
6542
+ var NO_WHITESPACE = /^\S+$/;
6543
+ var NO_SPECIAL_CHARS = /^[a-zA-Z0-9\s]+$/;
6544
+ var HAS_UPPERCASE = /[A-Z]/;
6545
+ var HAS_LOWERCASE = /[a-z]/;
6546
+ var HAS_DIGIT = /\d/;
6547
+ var HAS_SPECIAL = /[!@#$%^&*(),.?":{}|<>]/;
6548
+ var HTML_TAG = /<[^>]*>/g;
6549
+ var EMOJI = /[\u{1F600}-\u{1F64F}\u{1F300}-\u{1F5FF}\u{1F680}-\u{1F6FF}\u{1F1E0}-\u{1F1FF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}]/u;
6550
+ var HASHTAG = /#[a-zA-Z0-9_]+/g;
6551
+ var MENTION = /@[a-zA-Z0-9_]+/g;
6552
+ var JSON_STRING = /^[\],:{}\s]*$/;
6553
+ var BASE64 = /^[A-Za-z0-9+/]+=*$/;
6554
+ var JWT = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
6555
+ var SEMVER = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;
6556
+ var LATITUDE = /^-?([0-8]?[0-9]|90)(\.[0-9]{1,10})?$/;
6557
+ var LONGITUDE = /^-?([0-9]{1,2}|1[0-7][0-9]|180)(\.[0-9]{1,10})?$/;
6558
+ var REGEX = {
6559
+ // Email
6560
+ EMAIL,
6561
+ EMAIL_RFC5322,
6562
+ EMAIL_COMMON_DOMAINS,
6563
+ // Password
6564
+ PASSWORD_MIN_8,
6565
+ PASSWORD_ALPHANUMERIC,
6566
+ PASSWORD_MEDIUM,
6567
+ PASSWORD_STRONG,
6568
+ PASSWORD_VERY_STRONG,
6569
+ // Phone
6570
+ PHONE_INTERNATIONAL,
6571
+ PHONE_US,
6572
+ PHONE_INDIA,
6573
+ PHONE_UK,
6574
+ PHONE_10_DIGIT,
6575
+ PHONE_WITH_CODE,
6576
+ // Postal
6577
+ ZIP_US,
6578
+ PIN_INDIA,
6579
+ POSTAL_UK,
6580
+ POSTAL_CANADA,
6581
+ PLZ_GERMANY,
6582
+ POSTAL_GENERIC,
6583
+ // IDs
6584
+ UUID_V4,
6585
+ UUID,
6586
+ MONGO_OBJECT_ID,
6587
+ CUID,
6588
+ CUID2,
6589
+ NANOID,
6590
+ // Government IDs
6591
+ AADHAAR_INDIA,
6592
+ PAN_INDIA,
6593
+ GST_INDIA,
6594
+ SSN_US,
6595
+ DL_INDIA,
6596
+ VEHICLE_INDIA,
6597
+ IFSC_INDIA,
6598
+ // URL
6599
+ URL_BASIC,
6600
+ URL_OPTIONAL_PROTOCOL,
6601
+ URL_STRICT,
6602
+ DOMAIN,
6603
+ SUBDOMAIN,
6604
+ LOCALHOST,
6605
+ // Slug & Username
6606
+ SLUG,
6607
+ USERNAME,
6608
+ USERNAME_ALPHA_START,
6609
+ HANDLE,
6610
+ // Credit Card
6611
+ CREDIT_CARD,
6612
+ VISA,
6613
+ MASTERCARD,
6614
+ AMEX,
6615
+ DISCOVER,
6616
+ CVV,
6617
+ CARD_EXPIRY,
6618
+ // Date & Time
6619
+ DATE_ISO,
6620
+ DATE_DMY,
6621
+ DATE_MDY,
6622
+ TIME_24H,
6623
+ TIME_24H_SECONDS,
6624
+ TIME_12H,
6625
+ DATETIME_ISO,
6626
+ // IP
6627
+ IPV4,
6628
+ IPV6,
6629
+ MAC_ADDRESS,
6630
+ // File
6631
+ IMAGE_EXT,
6632
+ VIDEO_EXT,
6633
+ AUDIO_EXT,
6634
+ DOCUMENT_EXT,
6635
+ ARCHIVE_EXT,
6636
+ SAFE_FILENAME,
6637
+ // Color
6638
+ HEX_COLOR,
6639
+ HEX_COLOR_ALPHA,
6640
+ RGB_COLOR,
6641
+ RGBA_COLOR,
6642
+ HSL_COLOR,
6643
+ // Misc
6644
+ ALPHANUMERIC,
6645
+ LETTERS_ONLY,
6646
+ NUMBERS_ONLY,
6647
+ DECIMAL,
6648
+ POSITIVE_INTEGER,
6649
+ NON_NEGATIVE_INTEGER,
6650
+ NO_WHITESPACE,
6651
+ NO_SPECIAL_CHARS,
6652
+ HAS_UPPERCASE,
6653
+ HAS_LOWERCASE,
6654
+ HAS_DIGIT,
6655
+ HAS_SPECIAL,
6656
+ HTML_TAG,
6657
+ EMOJI,
6658
+ HASHTAG,
6659
+ MENTION,
6660
+ JSON_STRING,
6661
+ BASE64,
6662
+ JWT,
6663
+ SEMVER,
6664
+ LATITUDE,
6665
+ LONGITUDE
6666
+ };
6667
+ var regex_default = REGEX;
6668
+
3678
6669
  // src/data/logos.ts
3679
6670
  var brands = {
3680
6671
  botify: {
@@ -3787,6 +6778,222 @@ var getAllBrandKeys = () => {
3787
6778
  };
3788
6779
  var logos_default = brands;
3789
6780
 
6781
+ // src/data/brand-identity.ts
6782
+ var BRANDS = {
6783
+ botify: {
6784
+ id: "botify",
6785
+ name: "Botify",
6786
+ tagline: "AI-Powered Chatbots",
6787
+ domain: "botify.life",
6788
+ logo: {
6789
+ light: "https://botify.life/logos/botify-full-light.svg",
6790
+ dark: "https://botify.life/logos/botify-full-dark.svg",
6791
+ logoOnly: "https://botify.life/logos/botify-icon-light.svg",
6792
+ darkLogoOnly: "https://botify.life/logos/botify-icon-dark.svg",
6793
+ favicon: "https://botify.life/favicon.ico"
6794
+ },
6795
+ colors: {
6796
+ primary: "#6366F1",
6797
+ secondary: "#8B5CF6",
6798
+ accent: "#A78BFA"
6799
+ },
6800
+ contact: {
6801
+ supportEmail: "support@botify.life",
6802
+ salesEmail: "sales@botify.life"
6803
+ },
6804
+ social: {
6805
+ twitter: "https://twitter.com/botifylife",
6806
+ github: "https://github.com/botifylife"
6807
+ },
6808
+ seo: {
6809
+ title: "Botify - AI-Powered Chatbots",
6810
+ description: "Create intelligent chatbots with Botify. AI-powered conversations for your business.",
6811
+ keywords: ["chatbot", "AI", "conversational AI", "customer support", "automation"]
6812
+ }
6813
+ },
6814
+ exyconn: {
6815
+ id: "exyconn",
6816
+ name: "Exyconn",
6817
+ tagline: "Connect. Create. Collaborate.",
6818
+ domain: "exyconn.com",
6819
+ logo: {
6820
+ light: "https://exyconn.com/logos/exyconn-full-light.svg",
6821
+ dark: "https://exyconn.com/logos/exyconn-full-dark.svg",
6822
+ logoOnly: "https://exyconn.com/logos/exyconn-icon-light.svg",
6823
+ darkLogoOnly: "https://exyconn.com/logos/exyconn-icon-dark.svg",
6824
+ favicon: "https://exyconn.com/favicon.ico"
6825
+ },
6826
+ colors: {
6827
+ primary: "#0EA5E9",
6828
+ secondary: "#06B6D4",
6829
+ accent: "#22D3EE"
6830
+ },
6831
+ contact: {
6832
+ supportEmail: "support@exyconn.com",
6833
+ salesEmail: "sales@exyconn.com"
6834
+ },
6835
+ social: {
6836
+ twitter: "https://twitter.com/exyconn",
6837
+ linkedin: "https://linkedin.com/company/exyconn",
6838
+ github: "https://github.com/exyconn"
6839
+ },
6840
+ seo: {
6841
+ title: "Exyconn - Connect. Create. Collaborate.",
6842
+ description: "The platform that brings teams together. Connect, create, and collaborate seamlessly.",
6843
+ keywords: ["collaboration", "team", "productivity", "communication", "workspace"]
6844
+ }
6845
+ },
6846
+ partywings: {
6847
+ id: "partywings",
6848
+ name: "PartyWings",
6849
+ tagline: "Your Party, Your Rules",
6850
+ domain: "partywings.fun",
6851
+ logo: {
6852
+ light: "https://partywings.fun/logos/partywings-full-light.svg",
6853
+ dark: "https://partywings.fun/logos/partywings-full-dark.svg",
6854
+ logoOnly: "https://partywings.fun/logos/partywings-icon-light.svg",
6855
+ darkLogoOnly: "https://partywings.fun/logos/partywings-icon-dark.svg",
6856
+ favicon: "https://partywings.fun/favicon.ico"
6857
+ },
6858
+ colors: {
6859
+ primary: "#EC4899",
6860
+ secondary: "#F472B6",
6861
+ accent: "#F9A8D4"
6862
+ },
6863
+ contact: {
6864
+ supportEmail: "support@partywings.fun"
6865
+ },
6866
+ social: {
6867
+ instagram: "https://instagram.com/partywingsfun",
6868
+ tiktok: "https://tiktok.com/@partywingsfun"
6869
+ },
6870
+ seo: {
6871
+ title: "PartyWings - Your Party, Your Rules",
6872
+ description: "Plan unforgettable parties and events. Your party, your rules with PartyWings.",
6873
+ keywords: ["party", "events", "celebration", "planning", "entertainment"]
6874
+ }
6875
+ },
6876
+ sibera: {
6877
+ id: "sibera",
6878
+ name: "Sibera",
6879
+ tagline: "Work Smarter, Together",
6880
+ domain: "sibera.work",
6881
+ logo: {
6882
+ light: "https://sibera.work/logos/sibera-full-light.svg",
6883
+ dark: "https://sibera.work/logos/sibera-full-dark.svg",
6884
+ logoOnly: "https://sibera.work/logos/sibera-icon-light.svg",
6885
+ darkLogoOnly: "https://sibera.work/logos/sibera-icon-dark.svg",
6886
+ favicon: "https://sibera.work/favicon.ico"
6887
+ },
6888
+ colors: {
6889
+ primary: "#10B981",
6890
+ secondary: "#34D399",
6891
+ accent: "#6EE7B7"
6892
+ },
6893
+ contact: {
6894
+ supportEmail: "support@sibera.work",
6895
+ salesEmail: "sales@sibera.work"
6896
+ },
6897
+ social: {
6898
+ twitter: "https://twitter.com/siberawork",
6899
+ linkedin: "https://linkedin.com/company/sibera"
6900
+ },
6901
+ seo: {
6902
+ title: "Sibera - Work Smarter, Together",
6903
+ description: "Streamline your workflow and collaborate efficiently with Sibera.",
6904
+ keywords: ["work management", "productivity", "team collaboration", "project management"]
6905
+ }
6906
+ },
6907
+ spentiva: {
6908
+ id: "spentiva",
6909
+ name: "Spentiva",
6910
+ tagline: "Smart Spending, Smart Living",
6911
+ domain: "spentiva.com",
6912
+ logo: {
6913
+ light: "https://spentiva.com/logos/spentiva-full-light.svg",
6914
+ dark: "https://spentiva.com/logos/spentiva-full-dark.svg",
6915
+ logoOnly: "https://spentiva.com/logos/spentiva-icon-light.svg",
6916
+ darkLogoOnly: "https://spentiva.com/logos/spentiva-icon-dark.svg",
6917
+ favicon: "https://spentiva.com/favicon.ico"
6918
+ },
6919
+ colors: {
6920
+ primary: "#F59E0B",
6921
+ secondary: "#FBBF24",
6922
+ accent: "#FCD34D"
6923
+ },
6924
+ contact: {
6925
+ supportEmail: "support@spentiva.com",
6926
+ salesEmail: "hello@spentiva.com"
6927
+ },
6928
+ social: {
6929
+ twitter: "https://twitter.com/spentiva",
6930
+ instagram: "https://instagram.com/spentiva"
6931
+ },
6932
+ seo: {
6933
+ title: "Spentiva - Smart Spending, Smart Living",
6934
+ description: "Take control of your finances with Spentiva. Smart spending for smart living.",
6935
+ keywords: ["finance", "budgeting", "expense tracking", "money management", "personal finance"]
6936
+ }
6937
+ }
6938
+ };
6939
+ var APPS = {
6940
+ BOTIFY: createAppConfig("botify"),
6941
+ EXYCONN: createAppConfig("exyconn"),
6942
+ PARTYWINGS: createAppConfig("partywings"),
6943
+ SIBERA: createAppConfig("sibera"),
6944
+ SPENTIVA: createAppConfig("spentiva")
6945
+ };
6946
+ function createAppConfig(brandId) {
6947
+ const brand = BRANDS[brandId.toLowerCase()];
6948
+ if (!brand) {
6949
+ throw new Error(`Brand "${brandId}" not found`);
6950
+ }
6951
+ return {
6952
+ name: brand.name,
6953
+ tagline: brand.tagline,
6954
+ domain: brand.domain,
6955
+ supportEmail: brand.contact.supportEmail,
6956
+ logo: brand.logo,
6957
+ colors: brand.colors
6958
+ };
6959
+ }
6960
+ function getBrandById(id) {
6961
+ return BRANDS[id.toLowerCase()];
6962
+ }
6963
+ function getBrandByDomain2(domain) {
6964
+ return Object.values(BRANDS).find((b) => b.domain === domain);
6965
+ }
6966
+ function getAllBrands2() {
6967
+ return Object.values(BRANDS);
6968
+ }
6969
+ function getAllBrandIds() {
6970
+ return Object.keys(BRANDS);
6971
+ }
6972
+ function getLogo2(brandId, variant) {
6973
+ const brand = getBrandById(brandId);
6974
+ return brand?.logo[variant];
6975
+ }
6976
+ function getThemedLogo(brandId, theme, iconOnly = false) {
6977
+ const brand = getBrandById(brandId);
6978
+ if (!brand) return void 0;
6979
+ if (iconOnly) {
6980
+ return theme === "light" ? brand.logo.logoOnly : brand.logo.darkLogoOnly;
6981
+ }
6982
+ return brand.logo[theme];
6983
+ }
6984
+ function getAppConfigByDomain(domain) {
6985
+ const brand = getBrandByDomain2(domain);
6986
+ if (!brand) return void 0;
6987
+ return createAppConfig(brand.id);
6988
+ }
6989
+ function detectCurrentBrand() {
6990
+ if (typeof window === "undefined") return void 0;
6991
+ const hostname = window.location.hostname;
6992
+ return Object.values(BRANDS).find(
6993
+ (b) => hostname === b.domain || hostname.endsWith(`.${b.domain}`)
6994
+ );
6995
+ }
6996
+
3790
6997
  export { client_exports as client, data_exports as data, server_exports as server, shared_exports as shared };
3791
6998
  //# sourceMappingURL=index.mjs.map
3792
6999
  //# sourceMappingURL=index.mjs.map