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