@cupcodev/ui 8.1.2 → 8.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +482 -515
- package/dist/index.d.cts +4 -11
- package/dist/index.d.ts +4 -11
- package/dist/index.js +482 -514
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1199,10 +1199,10 @@ var Dock = ({ items, className }) => {
|
|
|
1199
1199
|
const itemsRef = useRef3([]);
|
|
1200
1200
|
const OVERSHOOT = 5;
|
|
1201
1201
|
useEffect3(() => {
|
|
1202
|
-
var
|
|
1202
|
+
var _a25;
|
|
1203
1203
|
const activeItem = itemsRef.current[activeIndex];
|
|
1204
1204
|
if (!activeItem) return;
|
|
1205
|
-
const containerRect = (
|
|
1205
|
+
const containerRect = (_a25 = activeItem.parentElement) == null ? void 0 : _a25.getBoundingClientRect();
|
|
1206
1206
|
const itemRect = activeItem.getBoundingClientRect();
|
|
1207
1207
|
if (!containerRect) return;
|
|
1208
1208
|
const relativeLeft = itemRect.left - containerRect.left;
|
|
@@ -1264,9 +1264,9 @@ var Dock = ({ items, className }) => {
|
|
|
1264
1264
|
"button",
|
|
1265
1265
|
{
|
|
1266
1266
|
onClick: () => {
|
|
1267
|
-
var
|
|
1267
|
+
var _a25;
|
|
1268
1268
|
setActiveIndex(index);
|
|
1269
|
-
(
|
|
1269
|
+
(_a25 = item.onClick) == null ? void 0 : _a25.call(item);
|
|
1270
1270
|
},
|
|
1271
1271
|
className: cn(
|
|
1272
1272
|
"flex items-center justify-center w-12 h-12 rounded-xl",
|
|
@@ -1334,9 +1334,9 @@ var normalizeValue = (value) => {
|
|
|
1334
1334
|
return String(value);
|
|
1335
1335
|
};
|
|
1336
1336
|
var setCupcodeRuntimeEnv = (values) => {
|
|
1337
|
-
var
|
|
1337
|
+
var _a25;
|
|
1338
1338
|
const globalRef = globalThis;
|
|
1339
|
-
const nextGlobalEnv = { ...(
|
|
1339
|
+
const nextGlobalEnv = { ...(_a25 = globalRef.__CUPCODE_ENV__) != null ? _a25 : {} };
|
|
1340
1340
|
Object.entries(values).forEach(([key, value]) => {
|
|
1341
1341
|
const normalized = normalizeValue(value);
|
|
1342
1342
|
runtimeStore[key] = normalized;
|
|
@@ -1345,8 +1345,8 @@ var setCupcodeRuntimeEnv = (values) => {
|
|
|
1345
1345
|
globalRef.__CUPCODE_ENV__ = nextGlobalEnv;
|
|
1346
1346
|
};
|
|
1347
1347
|
var readFromProcessEnv = (key) => {
|
|
1348
|
-
var
|
|
1349
|
-
const processEnv = (
|
|
1348
|
+
var _a25;
|
|
1349
|
+
const processEnv = (_a25 = globalThis.process) == null ? void 0 : _a25.env;
|
|
1350
1350
|
return normalizeValue(processEnv == null ? void 0 : processEnv[key]);
|
|
1351
1351
|
};
|
|
1352
1352
|
var readFromImportMetaEnv = (key) => {
|
|
@@ -1358,12 +1358,12 @@ var readFromImportMetaEnv = (key) => {
|
|
|
1358
1358
|
}
|
|
1359
1359
|
};
|
|
1360
1360
|
var getRuntimeEnv = (key) => {
|
|
1361
|
-
var
|
|
1361
|
+
var _a25;
|
|
1362
1362
|
const normalizedKey = key.trim();
|
|
1363
1363
|
if (!normalizedKey) return void 0;
|
|
1364
1364
|
const fromRuntimeStore = runtimeStore[normalizedKey];
|
|
1365
1365
|
if (fromRuntimeStore) return fromRuntimeStore;
|
|
1366
|
-
const fromGlobalStore = normalizeValue((
|
|
1366
|
+
const fromGlobalStore = normalizeValue((_a25 = globalThis.__CUPCODE_ENV__) == null ? void 0 : _a25[normalizedKey]);
|
|
1367
1367
|
if (fromGlobalStore) return fromGlobalStore;
|
|
1368
1368
|
const fromGlobalKey = normalizeValue(globalThis[normalizedKey]);
|
|
1369
1369
|
if (fromGlobalKey) return fromGlobalKey;
|
|
@@ -1372,12 +1372,12 @@ var getRuntimeEnv = (key) => {
|
|
|
1372
1372
|
return readFromProcessEnv(normalizedKey);
|
|
1373
1373
|
};
|
|
1374
1374
|
var getRuntimeEnvOr = (key, fallback) => {
|
|
1375
|
-
var
|
|
1376
|
-
return (
|
|
1375
|
+
var _a25;
|
|
1376
|
+
return (_a25 = getRuntimeEnv(key)) != null ? _a25 : fallback;
|
|
1377
1377
|
};
|
|
1378
1378
|
var isRuntimeDev = () => {
|
|
1379
|
-
var
|
|
1380
|
-
const explicitDev = (
|
|
1379
|
+
var _a25, _b3, _c;
|
|
1380
|
+
const explicitDev = (_a25 = getRuntimeEnv("DEV")) != null ? _a25 : getRuntimeEnv("VITE_DEV");
|
|
1381
1381
|
if (explicitDev) {
|
|
1382
1382
|
const normalized = explicitDev.toLowerCase();
|
|
1383
1383
|
return normalized === "1" || normalized === "true";
|
|
@@ -1403,11 +1403,11 @@ var isUuid = (value) => {
|
|
|
1403
1403
|
return UUID_REGEX.test(value.trim());
|
|
1404
1404
|
};
|
|
1405
1405
|
function parseAssetId(input) {
|
|
1406
|
-
var
|
|
1406
|
+
var _a25, _b3, _c, _d;
|
|
1407
1407
|
const raw = input == null ? void 0 : input.trim();
|
|
1408
1408
|
if (!raw) return void 0;
|
|
1409
1409
|
if (UUID_REGEX.test(raw)) return raw;
|
|
1410
|
-
const matchFromRaw = (
|
|
1410
|
+
const matchFromRaw = (_a25 = raw.match(UUID_IN_TEXT_REGEX)) == null ? void 0 : _a25[0];
|
|
1411
1411
|
if (isUuid(matchFromRaw)) return matchFromRaw;
|
|
1412
1412
|
try {
|
|
1413
1413
|
const url = new URL(raw);
|
|
@@ -1450,7 +1450,7 @@ function buildTelescupImageURL(options) {
|
|
|
1450
1450
|
return `${getApiBase()}/i?${params.toString()}`;
|
|
1451
1451
|
}
|
|
1452
1452
|
function resolveTelescupImageURL(value, options) {
|
|
1453
|
-
var
|
|
1453
|
+
var _a25;
|
|
1454
1454
|
const raw = value == null ? void 0 : value.trim();
|
|
1455
1455
|
if (!raw) return void 0;
|
|
1456
1456
|
const parsedId = parseAssetId(raw);
|
|
@@ -1472,7 +1472,7 @@ function resolveTelescupImageURL(value, options) {
|
|
|
1472
1472
|
width: options == null ? void 0 : options.width,
|
|
1473
1473
|
height: options == null ? void 0 : options.height,
|
|
1474
1474
|
fit: options == null ? void 0 : options.fit,
|
|
1475
|
-
format: (
|
|
1475
|
+
format: (_a25 = options == null ? void 0 : options.format) != null ? _a25 : "webp",
|
|
1476
1476
|
quality: options == null ? void 0 : options.quality
|
|
1477
1477
|
});
|
|
1478
1478
|
}
|
|
@@ -1568,7 +1568,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
|
|
|
1568
1568
|
return void 0;
|
|
1569
1569
|
}, [sortedCategories]);
|
|
1570
1570
|
useEffect5(() => {
|
|
1571
|
-
var
|
|
1571
|
+
var _a25;
|
|
1572
1572
|
const root = rootRef.current;
|
|
1573
1573
|
if (!root) return;
|
|
1574
1574
|
const $ = (sel) => root.querySelector(sel);
|
|
@@ -1580,7 +1580,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
|
|
|
1580
1580
|
const getDockItems = () => Array.from(root.querySelectorAll(INTERACTIVE_SELECTOR));
|
|
1581
1581
|
const dockItems = getDockItems();
|
|
1582
1582
|
if (!tabbar || !dock || !listMenuShow || !tabbarUl || dockItems.length === 0) return;
|
|
1583
|
-
const persistentId = (
|
|
1583
|
+
const persistentId = (_a25 = activeCategoryId != null ? activeCategoryId : lastInteractiveId) != null ? _a25 : null;
|
|
1584
1584
|
let openItem = null;
|
|
1585
1585
|
let latestToggleToken = null;
|
|
1586
1586
|
const persistentSelector = persistentId != null ? `${INTERACTIVE_SELECTOR}[data-cat-id="${persistentId}"]` : null;
|
|
@@ -1879,8 +1879,8 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
|
|
|
1879
1879
|
}, total);
|
|
1880
1880
|
}
|
|
1881
1881
|
const hideBootstrapTooltip = (el) => {
|
|
1882
|
-
var
|
|
1883
|
-
const tooltip = ((_b3 = (
|
|
1882
|
+
var _a26, _b3;
|
|
1883
|
+
const tooltip = ((_b3 = (_a26 = window.bootstrap) == null ? void 0 : _a26.Tooltip) == null ? void 0 : _b3.getInstance) ? window.bootstrap.Tooltip.getInstance(el) : null;
|
|
1884
1884
|
tooltip == null ? void 0 : tooltip.hide();
|
|
1885
1885
|
};
|
|
1886
1886
|
const openMenuForItem = (item, menu) => {
|
|
@@ -1898,14 +1898,14 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
|
|
|
1898
1898
|
latestToggleToken = null;
|
|
1899
1899
|
};
|
|
1900
1900
|
const closeActiveMenu = (opts = {}) => {
|
|
1901
|
-
var
|
|
1901
|
+
var _a26;
|
|
1902
1902
|
if (!opts.onClosed) {
|
|
1903
1903
|
latestToggleToken = null;
|
|
1904
1904
|
}
|
|
1905
1905
|
const itemToClose = openItem;
|
|
1906
1906
|
if (!itemToClose) {
|
|
1907
1907
|
if (!opts.preserveWrapper) ensurePersistentHighlight();
|
|
1908
|
-
(
|
|
1908
|
+
(_a26 = opts.onClosed) == null ? void 0 : _a26.call(opts);
|
|
1909
1909
|
return;
|
|
1910
1910
|
}
|
|
1911
1911
|
const menu = getMenuFor(itemToClose);
|
|
@@ -1913,7 +1913,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
|
|
|
1913
1913
|
itemToClose.classList.remove("active");
|
|
1914
1914
|
delete itemToClose.dataset.menuOpen;
|
|
1915
1915
|
const finalize = () => {
|
|
1916
|
-
var
|
|
1916
|
+
var _a27;
|
|
1917
1917
|
if (!opts.preserveWrapper) {
|
|
1918
1918
|
listMenuShow.classList.remove("show");
|
|
1919
1919
|
tabbar.classList.remove("is-active-menu");
|
|
@@ -1921,7 +1921,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
|
|
|
1921
1921
|
setTabbarTheme(null);
|
|
1922
1922
|
ensurePersistentHighlight();
|
|
1923
1923
|
}
|
|
1924
|
-
(
|
|
1924
|
+
(_a27 = opts.onClosed) == null ? void 0 : _a27.call(opts);
|
|
1925
1925
|
};
|
|
1926
1926
|
closeMenu(menu, finalize);
|
|
1927
1927
|
};
|
|
@@ -2024,7 +2024,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
|
|
|
2024
2024
|
/* @__PURE__ */ jsx10("div", { className: "glass-overlay" }),
|
|
2025
2025
|
/* @__PURE__ */ jsx10("div", { className: "glass-specular" }),
|
|
2026
2026
|
/* @__PURE__ */ jsx10("ul", { className: "flex-center", children: sortedCategories.map((cat) => {
|
|
2027
|
-
var
|
|
2027
|
+
var _a25;
|
|
2028
2028
|
if (cat.type === "divider") {
|
|
2029
2029
|
return /* @__PURE__ */ jsx10(
|
|
2030
2030
|
"li",
|
|
@@ -2036,7 +2036,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
|
|
|
2036
2036
|
cat.id
|
|
2037
2037
|
);
|
|
2038
2038
|
}
|
|
2039
|
-
const hasCards = (((
|
|
2039
|
+
const hasCards = (((_a25 = cat.cards) == null ? void 0 : _a25.length) || 0) > 0;
|
|
2040
2040
|
const link = cat.href;
|
|
2041
2041
|
const isCurrent = cat.id === activeCategoryId;
|
|
2042
2042
|
return /* @__PURE__ */ jsxs8(
|
|
@@ -2070,12 +2070,12 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
|
|
|
2070
2070
|
);
|
|
2071
2071
|
}) }),
|
|
2072
2072
|
/* @__PURE__ */ jsx10("div", { className: "list-menu-mob-show", children: sortedCategories.filter((cat) => {
|
|
2073
|
-
var
|
|
2074
|
-
return cat.type !== "divider" && (((
|
|
2073
|
+
var _a25;
|
|
2074
|
+
return cat.type !== "divider" && (((_a25 = cat.cards) == null ? void 0 : _a25.length) || 0) > 0;
|
|
2075
2075
|
}).map((cat) => {
|
|
2076
|
-
var
|
|
2077
|
-
return /* @__PURE__ */ jsx10("div", { className: "mob-list-menu hide", "data-tagget": cat.slug, children: /* @__PURE__ */ jsx10("div", { className: `submenu-stack ${cat.slug}`, children: ((
|
|
2078
|
-
var
|
|
2076
|
+
var _a25;
|
|
2077
|
+
return /* @__PURE__ */ jsx10("div", { className: "mob-list-menu hide", "data-tagget": cat.slug, children: /* @__PURE__ */ jsx10("div", { className: `submenu-stack ${cat.slug}`, children: ((_a25 = cat.cards) != null ? _a25 : []).map((card, i) => {
|
|
2078
|
+
var _a26;
|
|
2079
2079
|
return /* @__PURE__ */ jsxs8(
|
|
2080
2080
|
"div",
|
|
2081
2081
|
{
|
|
@@ -2091,8 +2091,8 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
|
|
|
2091
2091
|
/* @__PURE__ */ jsx10("div", { className: "title", children: card.title }),
|
|
2092
2092
|
card.description ? /* @__PURE__ */ jsx10("div", { className: "description", children: card.description }) : null
|
|
2093
2093
|
] }),
|
|
2094
|
-
/* @__PURE__ */ jsx10("div", { className: "actions", children: ((
|
|
2095
|
-
var
|
|
2094
|
+
/* @__PURE__ */ jsx10("div", { className: "actions", children: ((_a26 = card.buttons) != null ? _a26 : []).slice(0, 2).map((btn, idx) => {
|
|
2095
|
+
var _a27, _b3, _c, _d;
|
|
2096
2096
|
const className = idx === 0 ? "saiba-mais" : "saiba-mais-1";
|
|
2097
2097
|
if (btn.type === "popup") {
|
|
2098
2098
|
return /* @__PURE__ */ jsx10(
|
|
@@ -2107,7 +2107,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
|
|
|
2107
2107
|
window.dispatchEvent(new Event(`qw:open:${btn.popupId}`));
|
|
2108
2108
|
}
|
|
2109
2109
|
},
|
|
2110
|
-
children: (
|
|
2110
|
+
children: (_a27 = btn.label) != null ? _a27 : "Abrir"
|
|
2111
2111
|
},
|
|
2112
2112
|
`${cat.id}-card-${i}-btn-${idx}`
|
|
2113
2113
|
);
|
|
@@ -2253,10 +2253,10 @@ var NavbarCupcode = ({
|
|
|
2253
2253
|
React5.useEffect(() => {
|
|
2254
2254
|
if (!hasItems || !isOpen) return;
|
|
2255
2255
|
const handlePointerDown = (event) => {
|
|
2256
|
-
var
|
|
2256
|
+
var _a25, _b3;
|
|
2257
2257
|
const target = event.target;
|
|
2258
2258
|
if (!(target instanceof Node)) return;
|
|
2259
|
-
if (!((
|
|
2259
|
+
if (!((_a25 = navRef.current) == null ? void 0 : _a25.contains(target)) && !((_b3 = mobileDrawerRef.current) == null ? void 0 : _b3.contains(target))) {
|
|
2260
2260
|
setIsOpen(false);
|
|
2261
2261
|
}
|
|
2262
2262
|
};
|
|
@@ -2325,9 +2325,9 @@ var NavbarCupcode = ({
|
|
|
2325
2325
|
isActive && "text-[hsl(var(--cc-navbar-link-active))] after:w-full after:bg-[hsl(var(--cc-navbar-link-active))]"
|
|
2326
2326
|
);
|
|
2327
2327
|
const handleClick = (event) => {
|
|
2328
|
-
var
|
|
2328
|
+
var _a25;
|
|
2329
2329
|
logNavClick("navbar-desktop", item);
|
|
2330
|
-
(
|
|
2330
|
+
(_a25 = item.onClick) == null ? void 0 : _a25.call(item, event);
|
|
2331
2331
|
};
|
|
2332
2332
|
if (item.href.startsWith("#")) {
|
|
2333
2333
|
return /* @__PURE__ */ jsxs9(
|
|
@@ -2428,9 +2428,9 @@ var NavbarCupcode = ({
|
|
|
2428
2428
|
isActive && "text-[hsl(var(--cc-navbar-link-active))]"
|
|
2429
2429
|
);
|
|
2430
2430
|
const handleClick = (event) => {
|
|
2431
|
-
var
|
|
2431
|
+
var _a25;
|
|
2432
2432
|
logNavClick("navbar-mobile", item);
|
|
2433
|
-
(
|
|
2433
|
+
(_a25 = item.onClick) == null ? void 0 : _a25.call(item, event);
|
|
2434
2434
|
setIsOpen(false);
|
|
2435
2435
|
};
|
|
2436
2436
|
if (item.href.startsWith("#")) {
|
|
@@ -2685,11 +2685,11 @@ JellyButton.displayName = "JellyButton";
|
|
|
2685
2685
|
// src/components/cupcode/JellyButtonOriginal.tsx
|
|
2686
2686
|
import { jsx as jsx16, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
2687
2687
|
var resolveResponsiveSize = (value, currentBp) => {
|
|
2688
|
-
var
|
|
2688
|
+
var _a25, _b3, _c, _d, _e;
|
|
2689
2689
|
if (typeof value === "string") {
|
|
2690
2690
|
return value;
|
|
2691
2691
|
}
|
|
2692
|
-
const fallback = (_e = (_d = (_c = (_b3 = (
|
|
2692
|
+
const fallback = (_e = (_d = (_c = (_b3 = (_a25 = value.base) != null ? _a25 : value.sm) != null ? _b3 : value.md) != null ? _c : value.lg) != null ? _d : value.xl) != null ? _e : "md";
|
|
2693
2693
|
if (!currentBp) {
|
|
2694
2694
|
return fallback;
|
|
2695
2695
|
}
|
|
@@ -3062,12 +3062,12 @@ var isAccountsOidcToken = (token) => {
|
|
|
3062
3062
|
return issuer.startsWith(ACCOUNTS_BASE_URL_NORMALIZED) || issuer.includes("accounts.cupcode.com.br");
|
|
3063
3063
|
};
|
|
3064
3064
|
var readStoredIdToken = () => {
|
|
3065
|
-
var
|
|
3065
|
+
var _a25;
|
|
3066
3066
|
if (typeof window === "undefined" || typeof window.sessionStorage === "undefined") {
|
|
3067
3067
|
return void 0;
|
|
3068
3068
|
}
|
|
3069
3069
|
for (const key of SESSION_ID_TOKEN_KEYS) {
|
|
3070
|
-
const value = (
|
|
3070
|
+
const value = (_a25 = window.sessionStorage.getItem(key)) == null ? void 0 : _a25.trim();
|
|
3071
3071
|
if (value) return value;
|
|
3072
3072
|
}
|
|
3073
3073
|
return void 0;
|
|
@@ -3161,11 +3161,11 @@ var readUsageContext = (value) => {
|
|
|
3161
3161
|
return void 0;
|
|
3162
3162
|
};
|
|
3163
3163
|
var getFileExtension = (filename) => {
|
|
3164
|
-
var
|
|
3164
|
+
var _a25;
|
|
3165
3165
|
if (!filename) return void 0;
|
|
3166
3166
|
const parts = filename.split(".");
|
|
3167
3167
|
if (parts.length < 2) return void 0;
|
|
3168
|
-
const candidate = (
|
|
3168
|
+
const candidate = (_a25 = parts[parts.length - 1]) == null ? void 0 : _a25.trim().toLowerCase();
|
|
3169
3169
|
return candidate || void 0;
|
|
3170
3170
|
};
|
|
3171
3171
|
var buildFacetsFromItems = (items) => {
|
|
@@ -3175,9 +3175,9 @@ var buildFacetsFromItems = (items) => {
|
|
|
3175
3175
|
const extensions = /* @__PURE__ */ new Map();
|
|
3176
3176
|
const tags = /* @__PURE__ */ new Map();
|
|
3177
3177
|
items.forEach((item) => {
|
|
3178
|
-
var
|
|
3178
|
+
var _a25, _b3, _c, _d, _e, _f, _g;
|
|
3179
3179
|
if (item.category) {
|
|
3180
|
-
categories.set(item.category, ((
|
|
3180
|
+
categories.set(item.category, ((_a25 = categories.get(item.category)) != null ? _a25 : 0) + 1);
|
|
3181
3181
|
}
|
|
3182
3182
|
if (item.folderId) {
|
|
3183
3183
|
const current = folders.get(item.folderId);
|
|
@@ -3193,16 +3193,16 @@ var buildFacetsFromItems = (items) => {
|
|
|
3193
3193
|
extensions.set(item.extension, ((_e = extensions.get(item.extension)) != null ? _e : 0) + 1);
|
|
3194
3194
|
}
|
|
3195
3195
|
(_g = (_f = item.meta) == null ? void 0 : _f.tags) == null ? void 0 : _g.forEach((tag) => {
|
|
3196
|
-
var
|
|
3196
|
+
var _a26;
|
|
3197
3197
|
const normalizedTag = tag.trim();
|
|
3198
3198
|
if (!normalizedTag) return;
|
|
3199
|
-
tags.set(normalizedTag, ((
|
|
3199
|
+
tags.set(normalizedTag, ((_a26 = tags.get(normalizedTag)) != null ? _a26 : 0) + 1);
|
|
3200
3200
|
});
|
|
3201
3201
|
});
|
|
3202
3202
|
const toFacetValues = (map) => Array.from(map.entries()).map(([value, count2]) => ({ value, count: count2 })).sort((a, b) => a.value.localeCompare(b.value));
|
|
3203
3203
|
const toFolderFacetValues = (map) => Array.from(map.entries()).map(([value, info]) => ({ value, label: info.label, count: info.count })).sort((a, b) => {
|
|
3204
|
-
var
|
|
3205
|
-
return ((
|
|
3204
|
+
var _a25, _b3;
|
|
3205
|
+
return ((_a25 = a.label) != null ? _a25 : a.value).localeCompare((_b3 = b.label) != null ? _b3 : b.value);
|
|
3206
3206
|
});
|
|
3207
3207
|
return {
|
|
3208
3208
|
categories: toFacetValues(categories),
|
|
@@ -3213,7 +3213,7 @@ var buildFacetsFromItems = (items) => {
|
|
|
3213
3213
|
};
|
|
3214
3214
|
};
|
|
3215
3215
|
async function request(config, path, options = {}) {
|
|
3216
|
-
var
|
|
3216
|
+
var _a25, _b3;
|
|
3217
3217
|
const token = await config.getAccessToken();
|
|
3218
3218
|
if (!token) {
|
|
3219
3219
|
throw new TelescupClientError("Token de acesso n\xE3o encontrado.");
|
|
@@ -3243,7 +3243,7 @@ async function request(config, path, options = {}) {
|
|
|
3243
3243
|
let response;
|
|
3244
3244
|
try {
|
|
3245
3245
|
response = await fetch(url, {
|
|
3246
|
-
method: (
|
|
3246
|
+
method: (_a25 = options.method) != null ? _a25 : "POST",
|
|
3247
3247
|
headers,
|
|
3248
3248
|
body
|
|
3249
3249
|
});
|
|
@@ -3273,8 +3273,8 @@ var normalizeFunctionLanguage = (value) => {
|
|
|
3273
3273
|
return normalized;
|
|
3274
3274
|
};
|
|
3275
3275
|
var toFunctionListPayload = (filters) => {
|
|
3276
|
-
var
|
|
3277
|
-
const page = toPositiveInt((
|
|
3276
|
+
var _a25, _b3, _c, _d, _e, _f;
|
|
3277
|
+
const page = toPositiveInt((_a25 = filters.cursor) != null ? _a25 : filters.page, 1);
|
|
3278
3278
|
const pageSize = Math.min(500, Math.max(1, toPositiveInt(filters.pageSize, 24)));
|
|
3279
3279
|
return {
|
|
3280
3280
|
query: (_b3 = filters.query) != null ? _b3 : "",
|
|
@@ -3295,8 +3295,8 @@ var toFunctionListPayload = (filters) => {
|
|
|
3295
3295
|
};
|
|
3296
3296
|
};
|
|
3297
3297
|
var mapGenericRowToAsset = (row) => {
|
|
3298
|
-
var
|
|
3299
|
-
const id = (
|
|
3298
|
+
var _a25, _b3;
|
|
3299
|
+
const id = (_a25 = readFirstString(row, ["asset_id", "id", "file_id", "uuid"])) != null ? _a25 : typeof row.id === "number" ? String(row.id) : void 0;
|
|
3300
3300
|
if (!id) return null;
|
|
3301
3301
|
const fileName = readFirstString(row, ["filename", "file_name", "name", "title", "original_name"]);
|
|
3302
3302
|
const mimeType = readFirstString(row, ["mime", "mime_type", "content_type", "file_mime"]);
|
|
@@ -3318,16 +3318,16 @@ var mapGenericRowToAsset = (row) => {
|
|
|
3318
3318
|
};
|
|
3319
3319
|
};
|
|
3320
3320
|
var normalizeListResponseFromFunctions = (response, filters) => {
|
|
3321
|
-
var
|
|
3321
|
+
var _a25, _b3, _c, _d, _e, _f;
|
|
3322
3322
|
const payload = response != null ? response : {};
|
|
3323
3323
|
const itemsRaw = Array.isArray(payload.items) ? payload.items : [];
|
|
3324
3324
|
const selectedLanguage = normalizeLanguageKey(filters.language);
|
|
3325
3325
|
const items = itemsRaw.map((row) => {
|
|
3326
|
-
var
|
|
3326
|
+
var _a26, _b4, _c2;
|
|
3327
3327
|
const mapped = mapGenericRowToAsset(row);
|
|
3328
3328
|
if (!mapped) return null;
|
|
3329
3329
|
const metaByLang = normalizeMetaByLanguage(row.meta);
|
|
3330
|
-
const activeMeta = (_b4 = (
|
|
3330
|
+
const activeMeta = (_b4 = (_a26 = metaByLang[selectedLanguage]) != null ? _a26 : metaByLang.pt) != null ? _b4 : {};
|
|
3331
3331
|
const usageFromObject = readUsageContext(row.usage);
|
|
3332
3332
|
const normalized = {
|
|
3333
3333
|
...mapped,
|
|
@@ -3339,7 +3339,7 @@ var normalizeListResponseFromFunctions = (response, filters) => {
|
|
|
3339
3339
|
};
|
|
3340
3340
|
return normalized;
|
|
3341
3341
|
}).filter((item) => item !== null);
|
|
3342
|
-
const total = (_c = (_b3 = (
|
|
3342
|
+
const total = (_c = (_b3 = (_a25 = readNumber(payload.total)) != null ? _a25 : readNumber(payload.totalCount)) != null ? _b3 : readNumber(payload.total_count)) != null ? _c : items.length;
|
|
3343
3343
|
const page = toPositiveInt((_e = (_d = payload.page) != null ? _d : filters.cursor) != null ? _e : filters.page, 1);
|
|
3344
3344
|
const pageSize = Math.min(100, Math.max(1, toPositiveInt((_f = payload.pageSize) != null ? _f : filters.pageSize, 24)));
|
|
3345
3345
|
const nextCursor = total > page * pageSize ? String(page + 1) : void 0;
|
|
@@ -3359,12 +3359,12 @@ var mapConflictForQueue = (value) => {
|
|
|
3359
3359
|
return "conflict";
|
|
3360
3360
|
};
|
|
3361
3361
|
var toInitPayloadForFunctions = (payload) => {
|
|
3362
|
-
var
|
|
3362
|
+
var _a25, _b3;
|
|
3363
3363
|
return {
|
|
3364
3364
|
filename: payload.fileName,
|
|
3365
3365
|
size: payload.size,
|
|
3366
3366
|
mime: payload.mimeType,
|
|
3367
|
-
folder_id: (
|
|
3367
|
+
folder_id: (_a25 = payload.folderId) != null ? _a25 : null,
|
|
3368
3368
|
overwritePolicy: (_b3 = payload.conflict) != null ? _b3 : "ask",
|
|
3369
3369
|
fileName: payload.fileName,
|
|
3370
3370
|
mimeType: payload.mimeType,
|
|
@@ -3373,9 +3373,9 @@ var toInitPayloadForFunctions = (payload) => {
|
|
|
3373
3373
|
};
|
|
3374
3374
|
};
|
|
3375
3375
|
var normalizeInitResponseFromFunctions = (response) => {
|
|
3376
|
-
var
|
|
3376
|
+
var _a25, _b3, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
3377
3377
|
const payload = response != null ? response : {};
|
|
3378
|
-
const existingRaw = (
|
|
3378
|
+
const existingRaw = (_a25 = payload.existingAsset) != null ? _a25 : payload.existing_asset;
|
|
3379
3379
|
const existingAsset = existingRaw ? (_b3 = mapGenericRowToAsset(existingRaw)) != null ? _b3 : void 0 : void 0;
|
|
3380
3380
|
const assetRaw = payload.asset;
|
|
3381
3381
|
const asset = assetRaw ? (_c = mapGenericRowToAsset(assetRaw)) != null ? _c : void 0 : void 0;
|
|
@@ -3452,10 +3452,10 @@ var uploadBinaryWithProgress = async (config, file, payload, onProgress) => {
|
|
|
3452
3452
|
});
|
|
3453
3453
|
};
|
|
3454
3454
|
var toCompletePayloadForFunctions = (payload) => {
|
|
3455
|
-
var
|
|
3455
|
+
var _a25, _b3, _c;
|
|
3456
3456
|
return {
|
|
3457
3457
|
uploadId: payload.uploadId,
|
|
3458
|
-
assetDraftId: (
|
|
3458
|
+
assetDraftId: (_a25 = payload.assetDraftId) != null ? _a25 : payload.assetId,
|
|
3459
3459
|
storageKey: payload.storageKey,
|
|
3460
3460
|
finalFilename: (_b3 = payload.finalFilename) != null ? _b3 : payload.fileName,
|
|
3461
3461
|
folder_id: (_c = payload.folderId) != null ? _c : null,
|
|
@@ -3465,9 +3465,9 @@ var toCompletePayloadForFunctions = (payload) => {
|
|
|
3465
3465
|
};
|
|
3466
3466
|
};
|
|
3467
3467
|
var normalizeCompleteResponseFromFunctions = (response) => {
|
|
3468
|
-
var
|
|
3468
|
+
var _a25, _b3, _c, _d, _e, _f;
|
|
3469
3469
|
const payload = response != null ? response : {};
|
|
3470
|
-
const assetRaw = (
|
|
3470
|
+
const assetRaw = (_a25 = payload.asset) != null ? _a25 : payload;
|
|
3471
3471
|
const mapped = mapGenericRowToAsset(assetRaw);
|
|
3472
3472
|
if (mapped) {
|
|
3473
3473
|
const title = readFirstString(assetRaw, ["title", "title_text"]);
|
|
@@ -3496,7 +3496,7 @@ var normalizeCompleteResponseFromFunctions = (response) => {
|
|
|
3496
3496
|
return { asset: { id: assetId } };
|
|
3497
3497
|
};
|
|
3498
3498
|
var toMetaPayloadForFunctions = (payload) => {
|
|
3499
|
-
var
|
|
3499
|
+
var _a25;
|
|
3500
3500
|
if (payload.action && payload.action !== "update") {
|
|
3501
3501
|
return payload;
|
|
3502
3502
|
}
|
|
@@ -3506,7 +3506,7 @@ var toMetaPayloadForFunctions = (payload) => {
|
|
|
3506
3506
|
en: {},
|
|
3507
3507
|
es: {}
|
|
3508
3508
|
};
|
|
3509
|
-
const target = (
|
|
3509
|
+
const target = (_a25 = byLanguage[language]) != null ? _a25 : byLanguage.pt;
|
|
3510
3510
|
if (payload.meta) {
|
|
3511
3511
|
if (typeof payload.meta.alt === "string") target.alt = payload.meta.alt;
|
|
3512
3512
|
if (typeof payload.meta.title === "string") target.title = payload.meta.title;
|
|
@@ -3536,7 +3536,7 @@ var createTelescupClient = (config) => ({
|
|
|
3536
3536
|
return normalizeListResponseFromFunctions(response, filters);
|
|
3537
3537
|
},
|
|
3538
3538
|
initUpload: async (payload) => {
|
|
3539
|
-
var
|
|
3539
|
+
var _a25;
|
|
3540
3540
|
try {
|
|
3541
3541
|
const response = await request(
|
|
3542
3542
|
config,
|
|
@@ -3549,7 +3549,7 @@ var createTelescupClient = (config) => ({
|
|
|
3549
3549
|
return normalizeInitResponseFromFunctions(response);
|
|
3550
3550
|
} catch (error) {
|
|
3551
3551
|
if (error instanceof TelescupClientError && error.status === 409) {
|
|
3552
|
-
const details = (
|
|
3552
|
+
const details = (_a25 = error.details) != null ? _a25 : {};
|
|
3553
3553
|
const hasConflictPayload = Boolean(
|
|
3554
3554
|
details.existingAsset || details.existing_asset || details.conflict || details.duplicate || details.suggestedName || details.suggested_name
|
|
3555
3555
|
);
|
|
@@ -3577,14 +3577,14 @@ var createTelescupClient = (config) => ({
|
|
|
3577
3577
|
body: toMetaPayloadForFunctions(payload)
|
|
3578
3578
|
}),
|
|
3579
3579
|
generateAlt: async (asset, language = "pt") => {
|
|
3580
|
-
var
|
|
3580
|
+
var _a25, _b3, _c;
|
|
3581
3581
|
const response = await request(config, "generate-alt", {
|
|
3582
3582
|
method: "POST",
|
|
3583
3583
|
body: {
|
|
3584
3584
|
items: [
|
|
3585
3585
|
{
|
|
3586
3586
|
id: asset.id,
|
|
3587
|
-
file_path: (
|
|
3587
|
+
file_path: (_a25 = asset.filePath) != null ? _a25 : asset.storageKey,
|
|
3588
3588
|
mime_type: asset.mimeType
|
|
3589
3589
|
}
|
|
3590
3590
|
],
|
|
@@ -3614,12 +3614,12 @@ var createTelescupClient = (config) => ({
|
|
|
3614
3614
|
});
|
|
3615
3615
|
const payload = response != null ? response : {};
|
|
3616
3616
|
const toMeta = (value) => {
|
|
3617
|
-
var
|
|
3617
|
+
var _a25;
|
|
3618
3618
|
if (!value || typeof value !== "object") return void 0;
|
|
3619
3619
|
const row = value;
|
|
3620
3620
|
const title = readString(row.title);
|
|
3621
3621
|
const alt = readString(row.alt);
|
|
3622
|
-
const description = (
|
|
3622
|
+
const description = (_a25 = readString(row.description)) != null ? _a25 : readString(row.desc);
|
|
3623
3623
|
if (!title && !alt && !description) return void 0;
|
|
3624
3624
|
return {
|
|
3625
3625
|
...title ? { title } : {},
|
|
@@ -3649,17 +3649,17 @@ var mergeFacetValues = (current, incoming) => {
|
|
|
3649
3649
|
const map = /* @__PURE__ */ new Map();
|
|
3650
3650
|
current == null ? void 0 : current.forEach((entry) => map.set(entry.value, entry));
|
|
3651
3651
|
incoming == null ? void 0 : incoming.forEach((entry) => {
|
|
3652
|
-
var
|
|
3652
|
+
var _a25, _b3, _c;
|
|
3653
3653
|
const previous = map.get(entry.value);
|
|
3654
3654
|
map.set(entry.value, {
|
|
3655
3655
|
value: entry.value,
|
|
3656
|
-
label: (_b3 = (
|
|
3656
|
+
label: (_b3 = (_a25 = entry.label) != null ? _a25 : previous == null ? void 0 : previous.label) != null ? _b3 : entry.value,
|
|
3657
3657
|
count: (_c = entry.count) != null ? _c : previous == null ? void 0 : previous.count
|
|
3658
3658
|
});
|
|
3659
3659
|
});
|
|
3660
3660
|
return Array.from(map.values()).sort((a, b) => {
|
|
3661
|
-
var
|
|
3662
|
-
return ((
|
|
3661
|
+
var _a25, _b3;
|
|
3662
|
+
return ((_a25 = a.label) != null ? _a25 : a.value).localeCompare((_b3 = b.label) != null ? _b3 : b.value);
|
|
3663
3663
|
});
|
|
3664
3664
|
};
|
|
3665
3665
|
var DEFAULT_CACHE_MS = 3e5;
|
|
@@ -3668,8 +3668,8 @@ var inFlight = /* @__PURE__ */ new Map();
|
|
|
3668
3668
|
var LIST_CACHE_STORAGE_PREFIX = "telescup:list:v4";
|
|
3669
3669
|
var canUseLocalStorage = () => typeof window !== "undefined" && typeof window.localStorage !== "undefined";
|
|
3670
3670
|
var isEmptyAssetsState = (data) => {
|
|
3671
|
-
var
|
|
3672
|
-
return !((
|
|
3671
|
+
var _a25, _b3;
|
|
3672
|
+
return !((_a25 = data == null ? void 0 : data.items) == null ? void 0 : _a25.length) && ((_b3 = data == null ? void 0 : data.total) != null ? _b3 : 0) === 0;
|
|
3673
3673
|
};
|
|
3674
3674
|
var isCacheableAssetsState = (data) => !isEmptyAssetsState(data);
|
|
3675
3675
|
var readPersistentCache = (key, cacheTimeMs) => {
|
|
@@ -3803,9 +3803,9 @@ function useTelescupAssets(options) {
|
|
|
3803
3803
|
...sanitizeFilters(filters),
|
|
3804
3804
|
pageSize
|
|
3805
3805
|
}).then((data) => {
|
|
3806
|
-
var
|
|
3806
|
+
var _a25;
|
|
3807
3807
|
return {
|
|
3808
|
-
items: (
|
|
3808
|
+
items: (_a25 = data.items) != null ? _a25 : [],
|
|
3809
3809
|
nextCursor: data.nextCursor,
|
|
3810
3810
|
total: data.total,
|
|
3811
3811
|
facets: data.facets
|
|
@@ -3833,7 +3833,7 @@ function useTelescupAssets(options) {
|
|
|
3833
3833
|
[cacheKey, cacheTimeMs, enabled, filters, pageSize, resolvedClient]
|
|
3834
3834
|
);
|
|
3835
3835
|
const loadMore = useCallback(async () => {
|
|
3836
|
-
var
|
|
3836
|
+
var _a25, _b3, _c, _d, _e, _f, _g;
|
|
3837
3837
|
if (!state.nextCursor || isLoadingMore || isLoading) return;
|
|
3838
3838
|
const requestSeq = requestSeqRef.current;
|
|
3839
3839
|
setIsLoadingMore(true);
|
|
@@ -3847,7 +3847,7 @@ function useTelescupAssets(options) {
|
|
|
3847
3847
|
});
|
|
3848
3848
|
if (!aliveRef.current || requestSeq !== requestSeqRef.current) return;
|
|
3849
3849
|
const merged = {
|
|
3850
|
-
items: [...state.items, ...(
|
|
3850
|
+
items: [...state.items, ...(_a25 = data.items) != null ? _a25 : []],
|
|
3851
3851
|
nextCursor: data.nextCursor,
|
|
3852
3852
|
total: (_b3 = data.total) != null ? _b3 : state.total,
|
|
3853
3853
|
facets: {
|
|
@@ -4149,8 +4149,8 @@ var IMAGE_EXTENSIONS = /* @__PURE__ */ new Set(["jpg", "jpeg", "png", "gif", "we
|
|
|
4149
4149
|
var VIDEO_EXTENSIONS = /* @__PURE__ */ new Set(["mp4", "mov", "webm", "mkv", "avi", "m4v", "wmv"]);
|
|
4150
4150
|
var AUDIO_EXTENSIONS = /* @__PURE__ */ new Set(["mp3", "wav", "aac", "ogg", "flac", "m4a"]);
|
|
4151
4151
|
var resolveAssetFamily = (asset) => {
|
|
4152
|
-
var
|
|
4153
|
-
const explicitType = (
|
|
4152
|
+
var _a25, _b3, _c;
|
|
4153
|
+
const explicitType = (_a25 = asset.type) == null ? void 0 : _a25.toLowerCase();
|
|
4154
4154
|
if (explicitType === "image" || explicitType === "video" || explicitType === "audio" || explicitType === "file") {
|
|
4155
4155
|
return explicitType;
|
|
4156
4156
|
}
|
|
@@ -4166,9 +4166,9 @@ var resolveAssetFamily = (asset) => {
|
|
|
4166
4166
|
return "file";
|
|
4167
4167
|
};
|
|
4168
4168
|
var matchesAllowedAsset = (asset, allowed) => {
|
|
4169
|
-
var
|
|
4169
|
+
var _a25, _b3, _c, _d;
|
|
4170
4170
|
if (!allowed || allowed.length === 0) return true;
|
|
4171
|
-
const mime = (_b3 = (
|
|
4171
|
+
const mime = (_b3 = (_a25 = asset.mimeType) == null ? void 0 : _a25.toLowerCase()) != null ? _b3 : "";
|
|
4172
4172
|
const ext = asset.extension ? `.${asset.extension.toLowerCase()}` : "";
|
|
4173
4173
|
const type = (_d = (_c = asset.type) == null ? void 0 : _c.toLowerCase()) != null ? _d : "";
|
|
4174
4174
|
const family = resolveAssetFamily(asset);
|
|
@@ -4224,10 +4224,10 @@ var UUID_REGEX2 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[
|
|
|
4224
4224
|
var ROOT_FOLDERS_TO_HIDE = /* @__PURE__ */ new Set(["images", "videos"]);
|
|
4225
4225
|
var normalizeFolderToken = (value) => value.trim().replace(/^\/+|\/+$/g, "").toLowerCase();
|
|
4226
4226
|
var getLeafName = (value) => {
|
|
4227
|
-
var
|
|
4227
|
+
var _a25;
|
|
4228
4228
|
const normalized = normalizeFolderToken(value);
|
|
4229
4229
|
const parts = normalized.split("/").filter(Boolean);
|
|
4230
|
-
return (
|
|
4230
|
+
return (_a25 = parts[parts.length - 1]) != null ? _a25 : normalized;
|
|
4231
4231
|
};
|
|
4232
4232
|
var scoreFolderValue = (value, label) => {
|
|
4233
4233
|
const normalizedValue = normalizeFolderToken(value);
|
|
@@ -4243,8 +4243,8 @@ var normalizeFacetOptions = (entries) => {
|
|
|
4243
4243
|
if (!entries || !entries.length) return [];
|
|
4244
4244
|
const byLabel = /* @__PURE__ */ new Map();
|
|
4245
4245
|
entries.forEach((entry) => {
|
|
4246
|
-
var
|
|
4247
|
-
const value = (
|
|
4246
|
+
var _a25, _b3, _c, _d;
|
|
4247
|
+
const value = (_a25 = entry.value) == null ? void 0 : _a25.trim();
|
|
4248
4248
|
if (!value) return;
|
|
4249
4249
|
const label = ((_b3 = entry.label) == null ? void 0 : _b3.trim()) || value;
|
|
4250
4250
|
const key = normalizeFolderToken(label);
|
|
@@ -4274,16 +4274,16 @@ var normalizeFacetOptions = (entries) => {
|
|
|
4274
4274
|
const options = Array.from(byLabel.values());
|
|
4275
4275
|
const groups = /* @__PURE__ */ new Map();
|
|
4276
4276
|
options.forEach((option) => {
|
|
4277
|
-
var
|
|
4277
|
+
var _a25;
|
|
4278
4278
|
const leaf = getLeafName(option.label || option.value);
|
|
4279
|
-
const list = (
|
|
4279
|
+
const list = (_a25 = groups.get(leaf)) != null ? _a25 : [];
|
|
4280
4280
|
list.push(option);
|
|
4281
4281
|
groups.set(leaf, list);
|
|
4282
4282
|
});
|
|
4283
4283
|
const collapsed = options.filter((option) => {
|
|
4284
|
-
var
|
|
4284
|
+
var _a25;
|
|
4285
4285
|
const leaf = getLeafName(option.label || option.value);
|
|
4286
|
-
const group = (
|
|
4286
|
+
const group = (_a25 = groups.get(leaf)) != null ? _a25 : [];
|
|
4287
4287
|
const hasPathVariant = group.some((entry) => normalizeFolderToken(entry.label).includes("/"));
|
|
4288
4288
|
if (!hasPathVariant) return true;
|
|
4289
4289
|
return normalizeFolderToken(option.label).includes("/");
|
|
@@ -4294,8 +4294,8 @@ var normalizeFacetOptions = (entries) => {
|
|
|
4294
4294
|
var collectFacetOptions = (items, pick, pickLabel) => {
|
|
4295
4295
|
const options = /* @__PURE__ */ new Map();
|
|
4296
4296
|
items.forEach((asset) => {
|
|
4297
|
-
var
|
|
4298
|
-
const value = (
|
|
4297
|
+
var _a25, _b3, _c, _d;
|
|
4298
|
+
const value = (_a25 = pick(asset)) == null ? void 0 : _a25.trim();
|
|
4299
4299
|
if (!value) return;
|
|
4300
4300
|
const current = options.get(value);
|
|
4301
4301
|
options.set(value, {
|
|
@@ -4377,21 +4377,21 @@ var TelescupAssetPicker = ({
|
|
|
4377
4377
|
return folderOptions.find((option) => option.value === folderFilter);
|
|
4378
4378
|
}, [folderFilter, folderOptions]);
|
|
4379
4379
|
const filteredItems = useMemo4(() => {
|
|
4380
|
-
var
|
|
4380
|
+
var _a25;
|
|
4381
4381
|
const selectedFolderAliases = new Set(
|
|
4382
|
-
((
|
|
4382
|
+
((_a25 = selectedFolderOption == null ? void 0 : selectedFolderOption.aliases) != null ? _a25 : folderFilter === "all" ? [] : [folderFilter]).map(
|
|
4383
4383
|
(entry) => normalizeFolderToken(entry)
|
|
4384
4384
|
)
|
|
4385
4385
|
);
|
|
4386
4386
|
return items.filter((asset) => {
|
|
4387
|
-
var
|
|
4387
|
+
var _a26, _b3;
|
|
4388
4388
|
if (!matchesAllowedAsset(asset, allowedTypes)) return false;
|
|
4389
4389
|
if (typeFilter !== "all") {
|
|
4390
4390
|
const family = resolveAssetFamily(asset);
|
|
4391
4391
|
if (family !== typeFilter) return false;
|
|
4392
4392
|
}
|
|
4393
4393
|
if (folderFilter !== "all") {
|
|
4394
|
-
const folderIdToken = normalizeFolderToken((
|
|
4394
|
+
const folderIdToken = normalizeFolderToken((_a26 = asset.folderId) != null ? _a26 : "");
|
|
4395
4395
|
const folderNameToken = normalizeFolderToken((_b3 = asset.folderName) != null ? _b3 : "");
|
|
4396
4396
|
if (!selectedFolderAliases.has(folderIdToken) && !selectedFolderAliases.has(folderNameToken)) {
|
|
4397
4397
|
return false;
|
|
@@ -4687,14 +4687,14 @@ function useTelescupUploadQueue(options) {
|
|
|
4687
4687
|
activeRef.current += 1;
|
|
4688
4688
|
updateItem(next.id, { status: "uploading", progress: 0, error: void 0 });
|
|
4689
4689
|
const run = async () => {
|
|
4690
|
-
var
|
|
4690
|
+
var _a25, _b3, _c;
|
|
4691
4691
|
try {
|
|
4692
4692
|
const init = await client.initUpload({
|
|
4693
4693
|
fileName: next.file.name,
|
|
4694
4694
|
size: next.file.size,
|
|
4695
4695
|
mimeType: next.file.type,
|
|
4696
4696
|
folderId,
|
|
4697
|
-
conflict: (
|
|
4697
|
+
conflict: (_a25 = next.conflictPolicy) != null ? _a25 : conflictPolicy
|
|
4698
4698
|
});
|
|
4699
4699
|
const conflictDetected = init.conflict === "ask" || init.conflict === "conflict" || init.conflict === "exists" || init.existingAsset && !init.uploadUrl;
|
|
4700
4700
|
if (conflictDetected) {
|
|
@@ -4893,8 +4893,8 @@ Progress.displayName = ProgressPrimitive.Root.displayName;
|
|
|
4893
4893
|
// src/components/cupcode/TelescupUploader.tsx
|
|
4894
4894
|
import { jsx as jsx29, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
4895
4895
|
var formatLabel = (template, values) => template.replace(/\{(\w+)\}/g, (_, key) => {
|
|
4896
|
-
var
|
|
4897
|
-
return (
|
|
4896
|
+
var _a25;
|
|
4897
|
+
return (_a25 = values[key]) != null ? _a25 : "";
|
|
4898
4898
|
});
|
|
4899
4899
|
var suggestRename = (filename) => {
|
|
4900
4900
|
const dot = filename.lastIndexOf(".");
|
|
@@ -5012,7 +5012,7 @@ var TelescupUploader = ({
|
|
|
5012
5012
|
queue.length > 0 ? /* @__PURE__ */ jsx29(Button, { variant: "ghost", size: "sm", onClick: clearFinished, children: labels.uploader.clearFinished }) : null
|
|
5013
5013
|
] }),
|
|
5014
5014
|
/* @__PURE__ */ jsx29("div", { className: "space-y-3", children: queue.length === 0 ? /* @__PURE__ */ jsx29("div", { className: "rounded-md border border-border bg-muted/30 p-4 text-sm text-muted-foreground", children: labels.uploader.ready }) : queue.map((item) => {
|
|
5015
|
-
var
|
|
5015
|
+
var _a25;
|
|
5016
5016
|
const suggestedName = item.suggestedName || suggestRename(item.file.name);
|
|
5017
5017
|
const conflictDescription = formatLabel(labels.conflict.descriptionWithSuggestion, {
|
|
5018
5018
|
filename: item.file.name,
|
|
@@ -5033,7 +5033,7 @@ var TelescupUploader = ({
|
|
|
5033
5033
|
item.status === "conflict" ? /* @__PURE__ */ jsxs18("div", { className: "mt-3 space-y-3 rounded-md border border-amber-500/30 bg-amber-500/5 p-3", children: [
|
|
5034
5034
|
/* @__PURE__ */ jsx29("p", { className: "text-sm text-foreground", children: conflictDescription }),
|
|
5035
5035
|
/* @__PURE__ */ jsx29("p", { className: "text-xs text-muted-foreground", children: formatLabel(labels.conflict.queueHint, { filename: item.file.name }) }),
|
|
5036
|
-
((
|
|
5036
|
+
((_a25 = item.existingAsset) == null ? void 0 : _a25.id) ? /* @__PURE__ */ jsxs18("div", { className: "rounded-md border border-border bg-muted/30 p-3", children: [
|
|
5037
5037
|
/* @__PURE__ */ jsx29("p", { className: "text-xs font-semibold text-muted-foreground", children: labels.conflict.existingLabel }),
|
|
5038
5038
|
/* @__PURE__ */ jsx29("p", { className: "mt-1 truncate text-xs text-foreground", children: item.existingAsset.name || item.existingAsset.fileName || item.existingAsset.id }),
|
|
5039
5039
|
/* @__PURE__ */ jsx29("div", { className: "mt-2 h-28 overflow-hidden rounded-md", children: /* @__PURE__ */ jsx29(
|
|
@@ -5281,7 +5281,7 @@ var DEFAULT_LABELS = {
|
|
|
5281
5281
|
}
|
|
5282
5282
|
};
|
|
5283
5283
|
var mergeLabels = (overrides) => {
|
|
5284
|
-
var
|
|
5284
|
+
var _a25;
|
|
5285
5285
|
if (!overrides) return DEFAULT_LABELS;
|
|
5286
5286
|
return {
|
|
5287
5287
|
...DEFAULT_LABELS,
|
|
@@ -5295,7 +5295,7 @@ var mergeLabels = (overrides) => {
|
|
|
5295
5295
|
meta: {
|
|
5296
5296
|
...DEFAULT_LABELS.meta,
|
|
5297
5297
|
...overrides.meta,
|
|
5298
|
-
fields: { ...DEFAULT_LABELS.meta.fields, ...(
|
|
5298
|
+
fields: { ...DEFAULT_LABELS.meta.fields, ...(_a25 = overrides.meta) == null ? void 0 : _a25.fields }
|
|
5299
5299
|
},
|
|
5300
5300
|
toasts: { ...DEFAULT_LABELS.toasts, ...overrides.toasts }
|
|
5301
5301
|
};
|
|
@@ -5314,9 +5314,9 @@ var normalizeApiLanguageKey = (value) => {
|
|
|
5314
5314
|
return "pt-BR";
|
|
5315
5315
|
};
|
|
5316
5316
|
var getAssetMeta = (asset, lang) => {
|
|
5317
|
-
var
|
|
5317
|
+
var _a25, _b3;
|
|
5318
5318
|
if (!asset) return {};
|
|
5319
|
-
if ((
|
|
5319
|
+
if ((_a25 = asset.metaByLang) == null ? void 0 : _a25[lang]) return asset.metaByLang[lang];
|
|
5320
5320
|
return (_b3 = asset.meta) != null ? _b3 : {};
|
|
5321
5321
|
};
|
|
5322
5322
|
var TelescupMetaEditor = ({
|
|
@@ -5327,8 +5327,8 @@ var TelescupMetaEditor = ({
|
|
|
5327
5327
|
labels,
|
|
5328
5328
|
onAssetUpdated
|
|
5329
5329
|
}) => {
|
|
5330
|
-
var
|
|
5331
|
-
const [activeAssetId, setActiveAssetId] = useState10((_b3 = (
|
|
5330
|
+
var _a25, _b3, _c, _d, _e, _f, _g, _h;
|
|
5331
|
+
const [activeAssetId, setActiveAssetId] = useState10((_b3 = (_a25 = assets[0]) == null ? void 0 : _a25.id) != null ? _b3 : "");
|
|
5332
5332
|
const [activeLang, setActiveLang] = useState10(
|
|
5333
5333
|
LANGUAGES.includes(defaultLanguage) ? defaultLanguage : "pt"
|
|
5334
5334
|
);
|
|
@@ -5346,18 +5346,18 @@ var TelescupMetaEditor = ({
|
|
|
5346
5346
|
}, [activeAssetId, assets]);
|
|
5347
5347
|
const asset = assets.find((item) => item.id === activeAssetId);
|
|
5348
5348
|
const currentDraft = useMemo7(() => {
|
|
5349
|
-
var
|
|
5350
|
-
const existing = (
|
|
5349
|
+
var _a26;
|
|
5350
|
+
const existing = (_a26 = drafts[activeAssetId]) == null ? void 0 : _a26[activeLang];
|
|
5351
5351
|
if (existing) return existing;
|
|
5352
5352
|
return getAssetMeta(asset, activeLang);
|
|
5353
5353
|
}, [activeAssetId, activeLang, asset, drafts]);
|
|
5354
5354
|
const updateDraft = (field, value) => {
|
|
5355
5355
|
setDrafts((prev) => {
|
|
5356
|
-
var
|
|
5356
|
+
var _a26;
|
|
5357
5357
|
return {
|
|
5358
5358
|
...prev,
|
|
5359
5359
|
[activeAssetId]: {
|
|
5360
|
-
...(
|
|
5360
|
+
...(_a26 = prev[activeAssetId]) != null ? _a26 : {},
|
|
5361
5361
|
[activeLang]: {
|
|
5362
5362
|
...currentDraft,
|
|
5363
5363
|
[field]: value
|
|
@@ -5425,11 +5425,11 @@ var TelescupMetaEditor = ({
|
|
|
5425
5425
|
onAssetUpdated == null ? void 0 : onAssetUpdated(updated);
|
|
5426
5426
|
const updatedMeta = getAssetMeta(updated, activeLang);
|
|
5427
5427
|
setDrafts((prev) => {
|
|
5428
|
-
var
|
|
5428
|
+
var _a26;
|
|
5429
5429
|
return {
|
|
5430
5430
|
...prev,
|
|
5431
5431
|
[asset.id]: {
|
|
5432
|
-
...(
|
|
5432
|
+
...(_a26 = prev[asset.id]) != null ? _a26 : {},
|
|
5433
5433
|
[activeLang]: updatedMeta
|
|
5434
5434
|
}
|
|
5435
5435
|
};
|
|
@@ -5595,9 +5595,9 @@ var TelescupUpload = ({
|
|
|
5595
5595
|
}, []);
|
|
5596
5596
|
const enrichUploadedAsset = useCallback4(
|
|
5597
5597
|
async (asset) => {
|
|
5598
|
-
var
|
|
5598
|
+
var _a25, _b3, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
5599
5599
|
if (!autoGenerateMetadataOnUpload) return asset;
|
|
5600
|
-
const mimeType = (_b3 = (
|
|
5600
|
+
const mimeType = (_b3 = (_a25 = asset.mimeType) == null ? void 0 : _a25.toLowerCase()) != null ? _b3 : "";
|
|
5601
5601
|
const assetType = (_d = (_c = asset.type) == null ? void 0 : _c.toLowerCase()) != null ? _d : "";
|
|
5602
5602
|
const isImage = assetType === "image" || mimeType.startsWith("image/");
|
|
5603
5603
|
if (!isImage) return asset;
|
|
@@ -5846,11 +5846,29 @@ var TelescupUpload = ({
|
|
|
5846
5846
|
] }) })
|
|
5847
5847
|
] });
|
|
5848
5848
|
}
|
|
5849
|
-
return mode === "drawer" ? /* @__PURE__ */ jsx33(Drawer, { open: Boolean(open), onOpenChange: (next) => !next ? handleClose() : void 0, children: /* @__PURE__ */ jsx33(DrawerContent, { className: "h-[90vh] p-6", children: content }) }) : /* @__PURE__ */ jsx33(
|
|
5850
|
-
|
|
5851
|
-
|
|
5852
|
-
|
|
5853
|
-
|
|
5849
|
+
return mode === "drawer" ? /* @__PURE__ */ jsx33(Drawer, { open: Boolean(open), onOpenChange: (next) => !next ? handleClose() : void 0, children: /* @__PURE__ */ jsx33(DrawerContent, { className: "h-[90vh] p-6", children: content }) }) : /* @__PURE__ */ jsx33(
|
|
5850
|
+
Dialog,
|
|
5851
|
+
{
|
|
5852
|
+
open: Boolean(open),
|
|
5853
|
+
onOpenChange: (next) => {
|
|
5854
|
+
if (!next) handleClose();
|
|
5855
|
+
},
|
|
5856
|
+
modal: true,
|
|
5857
|
+
children: /* @__PURE__ */ jsxs20(
|
|
5858
|
+
DialogContent,
|
|
5859
|
+
{
|
|
5860
|
+
className: "z-[4600] max-w-5xl rounded-md sm:rounded-md",
|
|
5861
|
+
onInteractOutside: (event) => event.preventDefault(),
|
|
5862
|
+
onPointerDownOutside: (event) => event.preventDefault(),
|
|
5863
|
+
children: [
|
|
5864
|
+
/* @__PURE__ */ jsx33(DialogTitle, { className: "sr-only", children: labels.title }),
|
|
5865
|
+
/* @__PURE__ */ jsx33(DialogDescription, { className: "sr-only", children: "Sele\xE7\xE3o e upload de assets com metadados do Telescup." }),
|
|
5866
|
+
content
|
|
5867
|
+
]
|
|
5868
|
+
}
|
|
5869
|
+
)
|
|
5870
|
+
}
|
|
5871
|
+
);
|
|
5854
5872
|
};
|
|
5855
5873
|
|
|
5856
5874
|
// src/lib/accountsLoginHistory.ts
|
|
@@ -5861,16 +5879,16 @@ var toStringOrUndefined = (value) => {
|
|
|
5861
5879
|
};
|
|
5862
5880
|
var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5863
5881
|
var resolveAccountsApiBaseUrl = () => {
|
|
5864
|
-
var
|
|
5865
|
-
const appsApiBase = ((_b3 = (
|
|
5882
|
+
var _a25, _b3, _c, _d;
|
|
5883
|
+
const appsApiBase = ((_b3 = (_a25 = getRuntimeEnv("VITE_APPS_API_BASE_URL")) != null ? _a25 : getRuntimeEnv("VITE_APPS_API_BASE")) != null ? _b3 : "").trim().replace(/\/+$/, "");
|
|
5866
5884
|
if (appsApiBase) return `${appsApiBase}/api/accounts`;
|
|
5867
5885
|
const accountsBase = ((_c = getRuntimeEnv("VITE_ACCOUNTS_BASE_URL")) != null ? _c : "https://accounts.cupcode.com.br").trim().replace(/\/+$/, "");
|
|
5868
5886
|
const accountsApi = ((_d = getRuntimeEnv("VITE_ACCOUNTS_API_BASE_URL")) != null ? _d : "").trim().replace(/\/+$/, "");
|
|
5869
5887
|
return accountsApi || accountsBase;
|
|
5870
5888
|
};
|
|
5871
5889
|
var parseBrowserFromUserAgent = (userAgent) => {
|
|
5872
|
-
var
|
|
5873
|
-
const ua = (
|
|
5890
|
+
var _a25;
|
|
5891
|
+
const ua = (_a25 = userAgent == null ? void 0 : userAgent.trim()) != null ? _a25 : "";
|
|
5874
5892
|
if (!ua) return "Desconhecido";
|
|
5875
5893
|
if (/Edg\//.test(ua)) return "Edge";
|
|
5876
5894
|
if (/Chrome\//.test(ua)) return "Chrome";
|
|
@@ -5880,8 +5898,8 @@ var parseBrowserFromUserAgent = (userAgent) => {
|
|
|
5880
5898
|
return ua.split(" ")[0] || "Desconhecido";
|
|
5881
5899
|
};
|
|
5882
5900
|
var parseOsFromUserAgent = (userAgent) => {
|
|
5883
|
-
var
|
|
5884
|
-
const ua = (
|
|
5901
|
+
var _a25;
|
|
5902
|
+
const ua = (_a25 = userAgent == null ? void 0 : userAgent.trim()) != null ? _a25 : "";
|
|
5885
5903
|
if (!ua) return null;
|
|
5886
5904
|
if (/Windows NT/.test(ua)) return "Windows";
|
|
5887
5905
|
if (/Mac OS X/.test(ua)) return "macOS";
|
|
@@ -5893,8 +5911,8 @@ var parseOsFromUserAgent = (userAgent) => {
|
|
|
5893
5911
|
var normalizeLoginHistorySessions = (value) => {
|
|
5894
5912
|
if (!Array.isArray(value)) return [];
|
|
5895
5913
|
return value.filter(isRecord).map((row, index) => {
|
|
5896
|
-
var
|
|
5897
|
-
const id = (
|
|
5914
|
+
var _a25, _b3, _c, _d, _e, _f;
|
|
5915
|
+
const id = (_a25 = toStringOrUndefined(row.id)) != null ? _a25 : `session-${index}`;
|
|
5898
5916
|
return {
|
|
5899
5917
|
id,
|
|
5900
5918
|
createdAt: (_b3 = toStringOrUndefined(row.created_at)) != null ? _b3 : toStringOrUndefined(row.createdAt),
|
|
@@ -5914,18 +5932,18 @@ var isLoginHistorySessionActive = (session, now = Date.now()) => {
|
|
|
5914
5932
|
return Boolean(session.active) && expiresAt2 > now;
|
|
5915
5933
|
};
|
|
5916
5934
|
var readStoredAccessToken = () => {
|
|
5917
|
-
var
|
|
5935
|
+
var _a25;
|
|
5918
5936
|
if (typeof window === "undefined") return null;
|
|
5919
5937
|
const keys = ["cc_access_token", "access_token"];
|
|
5920
5938
|
for (const key of keys) {
|
|
5921
|
-
const value = (
|
|
5939
|
+
const value = (_a25 = window.sessionStorage.getItem(key)) == null ? void 0 : _a25.trim();
|
|
5922
5940
|
if (value) return value;
|
|
5923
5941
|
}
|
|
5924
5942
|
return null;
|
|
5925
5943
|
};
|
|
5926
5944
|
async function fetchAccountsLoginHistory(options) {
|
|
5927
|
-
var
|
|
5928
|
-
const base = ((
|
|
5945
|
+
var _a25;
|
|
5946
|
+
const base = ((_a25 = options == null ? void 0 : options.accountsApiBaseUrl) != null ? _a25 : resolveAccountsApiBaseUrl()).replace(/\/+$/, "");
|
|
5929
5947
|
const resolveToken = async () => {
|
|
5930
5948
|
if (options == null ? void 0 : options.getAccessToken) {
|
|
5931
5949
|
try {
|
|
@@ -6017,13 +6035,13 @@ var LoginHistoryCupcode = ({
|
|
|
6017
6035
|
);
|
|
6018
6036
|
}
|
|
6019
6037
|
return /* @__PURE__ */ jsx34("div", { className: cn(isCompact ? "space-y-1.5" : "space-y-2", className), children: visibleSessions.map((session, index) => {
|
|
6020
|
-
var
|
|
6038
|
+
var _a25;
|
|
6021
6039
|
const browser = parseBrowserFromUserAgent(session.userAgent);
|
|
6022
6040
|
const os = parseOsFromUserAgent(session.userAgent);
|
|
6023
6041
|
const isActive = isLoginHistorySessionActive(session);
|
|
6024
6042
|
const loginLabel = formatDateTime(session.createdAt);
|
|
6025
6043
|
const lastSeenLabel = formatDateTime(session.lastSeen);
|
|
6026
|
-
const ip = ((
|
|
6044
|
+
const ip = ((_a25 = session.ip) == null ? void 0 : _a25.trim()) || "unknown";
|
|
6027
6045
|
return /* @__PURE__ */ jsxs21(
|
|
6028
6046
|
"div",
|
|
6029
6047
|
{
|
|
@@ -6110,14 +6128,14 @@ function parseStoredThemePreference(value) {
|
|
|
6110
6128
|
return value === "light" || value === "dark" || value === "system" ? value : null;
|
|
6111
6129
|
}
|
|
6112
6130
|
function normalizeStoredThemePreference(value) {
|
|
6113
|
-
var
|
|
6114
|
-
return (
|
|
6131
|
+
var _a25;
|
|
6132
|
+
return (_a25 = parseStoredThemePreference(value)) != null ? _a25 : "system";
|
|
6115
6133
|
}
|
|
6116
6134
|
function readStoredThemeMode() {
|
|
6117
|
-
var
|
|
6135
|
+
var _a25;
|
|
6118
6136
|
if (typeof window === "undefined") return null;
|
|
6119
6137
|
try {
|
|
6120
|
-
const storedTheme = (
|
|
6138
|
+
const storedTheme = (_a25 = window.localStorage.getItem(THEME_STORAGE_KEY)) != null ? _a25 : window.localStorage.getItem(LEGACY_THEME_STORAGE_KEY);
|
|
6121
6139
|
return isStoredThemeMode(storedTheme) ? storedTheme : null;
|
|
6122
6140
|
} catch (e) {
|
|
6123
6141
|
return null;
|
|
@@ -6173,7 +6191,7 @@ function persistThemePreferenceSelection(preference) {
|
|
|
6173
6191
|
);
|
|
6174
6192
|
}
|
|
6175
6193
|
function resolveStoredThemePreference(experienceSettingsTheme) {
|
|
6176
|
-
var
|
|
6194
|
+
var _a25;
|
|
6177
6195
|
if (typeof window === "undefined") {
|
|
6178
6196
|
return normalizeStoredThemePreference(experienceSettingsTheme);
|
|
6179
6197
|
}
|
|
@@ -6189,7 +6207,7 @@ function resolveStoredThemePreference(experienceSettingsTheme) {
|
|
|
6189
6207
|
if (parsedExperienceTheme === "system" && storedThemeMode) {
|
|
6190
6208
|
return storedThemeMode;
|
|
6191
6209
|
}
|
|
6192
|
-
return (
|
|
6210
|
+
return (_a25 = parsedExperienceTheme != null ? parsedExperienceTheme : storedThemeMode) != null ? _a25 : "system";
|
|
6193
6211
|
} catch (e) {
|
|
6194
6212
|
return normalizeStoredThemePreference(experienceSettingsTheme);
|
|
6195
6213
|
}
|
|
@@ -6263,9 +6281,9 @@ var applyThemePreference = (preference) => {
|
|
|
6263
6281
|
persistThemePreferenceSelection(preference);
|
|
6264
6282
|
};
|
|
6265
6283
|
var resolveTelescupImageUrl = (value, options) => {
|
|
6266
|
-
var
|
|
6284
|
+
var _a25, _b3, _c;
|
|
6267
6285
|
return resolveTelescupImageURL(value, {
|
|
6268
|
-
width: (
|
|
6286
|
+
width: (_a25 = options == null ? void 0 : options.width) != null ? _a25 : 96,
|
|
6269
6287
|
height: (_b3 = options == null ? void 0 : options.height) != null ? _b3 : 96,
|
|
6270
6288
|
fit: "cover",
|
|
6271
6289
|
format: "avif",
|
|
@@ -6273,8 +6291,8 @@ var resolveTelescupImageUrl = (value, options) => {
|
|
|
6273
6291
|
});
|
|
6274
6292
|
};
|
|
6275
6293
|
var resolveProfileAvatarFromTelescup = (asset, fallbackId) => {
|
|
6276
|
-
var
|
|
6277
|
-
return (_b3 = (
|
|
6294
|
+
var _a25, _b3;
|
|
6295
|
+
return (_b3 = (_a25 = resolveTelescupImageUrl(asset == null ? void 0 : asset.url, { width: 384, height: 384, quality: 80 })) != null ? _a25 : resolveTelescupImageUrl(asset == null ? void 0 : asset.id, { width: 384, height: 384, quality: 80 })) != null ? _b3 : resolveTelescupImageUrl(fallbackId, { width: 384, height: 384, quality: 80 });
|
|
6278
6296
|
};
|
|
6279
6297
|
var normalizeLanguage = (value) => {
|
|
6280
6298
|
const normalized = value == null ? void 0 : value.trim().toLowerCase();
|
|
@@ -6393,8 +6411,10 @@ var UserMenuCupcode = ({
|
|
|
6393
6411
|
if (!hasTelescupAvatarSupport || isTelescupAuthPending || isProfileAvatarSaving) return;
|
|
6394
6412
|
try {
|
|
6395
6413
|
await ensureTelescupAuth();
|
|
6414
|
+
setIsProfileImageDialogOpen(false);
|
|
6396
6415
|
setIsProfileAvatarUploadOpen(true);
|
|
6397
6416
|
} catch (error) {
|
|
6417
|
+
console.error("[UserMenuCupcode] telescup avatar auth failed", error);
|
|
6398
6418
|
toast({
|
|
6399
6419
|
title: "Falha ao autenticar no Telescup",
|
|
6400
6420
|
description: error instanceof Error ? error.message : "N\xE3o foi poss\xEDvel abrir a biblioteca agora.",
|
|
@@ -6499,9 +6519,9 @@ var UserMenuCupcode = ({
|
|
|
6499
6519
|
};
|
|
6500
6520
|
const handleProfileAvatarChange = useCallback5(
|
|
6501
6521
|
async (ids, assets) => {
|
|
6502
|
-
var
|
|
6522
|
+
var _a25, _b3, _c;
|
|
6503
6523
|
const selectedAsset = assets == null ? void 0 : assets[0];
|
|
6504
|
-
const selectedIdRaw = (
|
|
6524
|
+
const selectedIdRaw = (_a25 = ids[0]) == null ? void 0 : _a25.trim();
|
|
6505
6525
|
const selectedId = (_c = (_b3 = parseAssetId(selectedIdRaw)) != null ? _b3 : parseAssetId(selectedAsset == null ? void 0 : selectedAsset.id)) != null ? _c : parseAssetId(selectedAsset == null ? void 0 : selectedAsset.url);
|
|
6506
6526
|
if (!selectedId) {
|
|
6507
6527
|
toast({
|
|
@@ -6544,7 +6564,7 @@ var UserMenuCupcode = ({
|
|
|
6544
6564
|
[isProfileAvatarSaving, onProfileAvatarChange, resolvedProfileAvatarUrl]
|
|
6545
6565
|
);
|
|
6546
6566
|
const renderDefaultPanel = () => {
|
|
6547
|
-
var
|
|
6567
|
+
var _a25;
|
|
6548
6568
|
if (activeTab === "profile") {
|
|
6549
6569
|
return /* @__PURE__ */ jsxs22("div", { className: "space-y-4", children: [
|
|
6550
6570
|
/* @__PURE__ */ jsxs22("div", { className: "pt-1 text-center", children: [
|
|
@@ -6714,7 +6734,7 @@ var UserMenuCupcode = ({
|
|
|
6714
6734
|
"Idioma"
|
|
6715
6735
|
] }),
|
|
6716
6736
|
/* @__PURE__ */ jsx35("div", { className: "mt-2", children: /* @__PURE__ */ jsxs22(Select, { value: resolvedLanguage, onValueChange: (value) => changeLanguage(value), children: [
|
|
6717
|
-
/* @__PURE__ */ jsx35(SelectTrigger, { className: "h-9 rounded-md border-border/70 bg-background/55 text-[11px] text-foreground shadow-none", children: /* @__PURE__ */ jsx35("span", { className: "truncate", children: (
|
|
6737
|
+
/* @__PURE__ */ jsx35(SelectTrigger, { className: "h-9 rounded-md border-border/70 bg-background/55 text-[11px] text-foreground shadow-none", children: /* @__PURE__ */ jsx35("span", { className: "truncate", children: (_a25 = LANGUAGE_OPTIONS.find((option) => option.value === resolvedLanguage)) == null ? void 0 : _a25.label }) }),
|
|
6718
6738
|
/* @__PURE__ */ jsx35(SelectContent, { className: "z-[820] rounded-md border border-border/70 bg-background text-foreground shadow-none", children: LANGUAGE_OPTIONS.map((option) => /* @__PURE__ */ jsx35(SelectItem, { value: option.value, className: "text-xs", children: option.label }, option.value)) })
|
|
6719
6739
|
] }) })
|
|
6720
6740
|
] }) })
|
|
@@ -7501,10 +7521,10 @@ var ignoreLoopbackUrlOnPublicOrigin = (value) => {
|
|
|
7501
7521
|
return isLoopbackUrl(value) ? void 0 : value;
|
|
7502
7522
|
};
|
|
7503
7523
|
var getAppsApiBaseUrl = () => {
|
|
7504
|
-
var
|
|
7524
|
+
var _a25, _b3;
|
|
7505
7525
|
return normalizeBaseUrl2(
|
|
7506
7526
|
(_b3 = ignoreLoopbackUrlOnPublicOrigin(
|
|
7507
|
-
(
|
|
7527
|
+
(_a25 = getRuntimeEnv("VITE_APPS_API_BASE_URL")) != null ? _a25 : getRuntimeEnv("VITE_APPS_API_BASE")
|
|
7508
7528
|
)) != null ? _b3 : "https://api.apps.cupcode.com.br"
|
|
7509
7529
|
);
|
|
7510
7530
|
};
|
|
@@ -7537,15 +7557,15 @@ var fetchWithTimeout = async (input, init, timeoutMs = AUTH_REQUEST_TIMEOUT_MS)
|
|
|
7537
7557
|
}
|
|
7538
7558
|
};
|
|
7539
7559
|
var resolveIssuerBaseUrl = () => {
|
|
7540
|
-
var
|
|
7541
|
-
const issuer = (
|
|
7560
|
+
var _a25;
|
|
7561
|
+
const issuer = (_a25 = ignoreLoopbackUrlOnPublicOrigin(getRuntimeEnv("VITE_OIDC_ISSUER"))) != null ? _a25 : ignoreLoopbackUrlOnPublicOrigin(getRuntimeEnv("VITE_ACCOUNTS_BASE_URL"));
|
|
7542
7562
|
return issuer ? normalizeBaseUrl2(issuer) : void 0;
|
|
7543
7563
|
};
|
|
7544
7564
|
var getAccountsConfig = () => {
|
|
7545
|
-
var
|
|
7565
|
+
var _a25, _b3, _c, _d;
|
|
7546
7566
|
const issuerBaseUrl = resolveIssuerBaseUrl();
|
|
7547
7567
|
const baseUrl = normalizeBaseUrl2(
|
|
7548
|
-
(
|
|
7568
|
+
(_a25 = issuerBaseUrl != null ? issuerBaseUrl : getRuntimeEnv("VITE_ACCOUNTS_BASE_URL")) != null ? _a25 : "https://accounts.cupcode.com.br"
|
|
7549
7569
|
);
|
|
7550
7570
|
const clientId = getRuntimeEnv("VITE_ACCOUNTS_CLIENT_ID");
|
|
7551
7571
|
if (!clientId) {
|
|
@@ -7572,7 +7592,7 @@ var getAccountsConfig = () => {
|
|
|
7572
7592
|
};
|
|
7573
7593
|
var cachedDiscovery = null;
|
|
7574
7594
|
var resolveOidcEndpoints = async (config) => {
|
|
7575
|
-
var
|
|
7595
|
+
var _a25, _b3, _c, _d, _e, _f;
|
|
7576
7596
|
if (config.authUrl && config.tokenUrl) {
|
|
7577
7597
|
return {
|
|
7578
7598
|
authUrl: config.authUrl,
|
|
@@ -7582,7 +7602,7 @@ var resolveOidcEndpoints = async (config) => {
|
|
|
7582
7602
|
}
|
|
7583
7603
|
if (cachedDiscovery) {
|
|
7584
7604
|
return {
|
|
7585
|
-
authUrl: (
|
|
7605
|
+
authUrl: (_a25 = cachedDiscovery.authorization_endpoint) != null ? _a25 : config.authUrl,
|
|
7586
7606
|
tokenUrl: (_b3 = cachedDiscovery.token_endpoint) != null ? _b3 : config.tokenUrl,
|
|
7587
7607
|
logoutUrl: (_c = cachedDiscovery.end_session_endpoint) != null ? _c : config.logoutUrl
|
|
7588
7608
|
};
|
|
@@ -7792,10 +7812,10 @@ var resolveLocalTelescupRedirectUri = () => {
|
|
|
7792
7812
|
return `${window.location.protocol}//localhost:${port}/oidc/callback`;
|
|
7793
7813
|
};
|
|
7794
7814
|
var readStorageItem = (key) => {
|
|
7795
|
-
var
|
|
7815
|
+
var _a25;
|
|
7796
7816
|
if (!canUseWindow()) return null;
|
|
7797
7817
|
try {
|
|
7798
|
-
return (
|
|
7818
|
+
return (_a25 = window.sessionStorage.getItem(key)) != null ? _a25 : window.localStorage.getItem(key);
|
|
7799
7819
|
} catch (e) {
|
|
7800
7820
|
return null;
|
|
7801
7821
|
}
|
|
@@ -7811,6 +7831,13 @@ var writeTokenBundle = (bundle) => {
|
|
|
7811
7831
|
window.localStorage.setItem(TOKEN_STORAGE_KEY, serialized);
|
|
7812
7832
|
} catch (e) {
|
|
7813
7833
|
}
|
|
7834
|
+
try {
|
|
7835
|
+
window.sessionStorage.setItem("cc_id_token", bundle.idToken);
|
|
7836
|
+
if (bundle.accessToken) {
|
|
7837
|
+
window.sessionStorage.setItem("access_token", bundle.accessToken);
|
|
7838
|
+
}
|
|
7839
|
+
} catch (e) {
|
|
7840
|
+
}
|
|
7814
7841
|
};
|
|
7815
7842
|
var getFlowStorageKey = (state) => `${FLOW_STORAGE_KEY_PREFIX}${state}`;
|
|
7816
7843
|
var writeFlowState = (flow) => {
|
|
@@ -7905,10 +7932,10 @@ var getPopupOrigin = () => {
|
|
|
7905
7932
|
return window.location.origin;
|
|
7906
7933
|
};
|
|
7907
7934
|
var getTelescupAccountsConfig = () => {
|
|
7908
|
-
var
|
|
7935
|
+
var _a25, _b3, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
7909
7936
|
const primary = getAccountsConfig();
|
|
7910
7937
|
const runtimeRedirectUri = ignoreLoopbackUrlOnPublicOrigin2(
|
|
7911
|
-
(
|
|
7938
|
+
(_a25 = getRuntimeEnv("VITE_TELESCUP_ACCOUNTS_REDIRECT_URI")) != null ? _a25 : getRuntimeEnv("VITE_TELESCUP_OIDC_REDIRECT_URI")
|
|
7912
7939
|
);
|
|
7913
7940
|
const fallbackRedirectUri = canUseWindow() ? `${window.location.origin}/oidc/callback` : "http://localhost:8083/oidc/callback";
|
|
7914
7941
|
const redirectUri = isLocalBrowserOrigin2() && runtimeRedirectUri && !runtimeRedirectUri.includes("localhost") ? resolveLocalTelescupRedirectUri() : runtimeRedirectUri != null ? runtimeRedirectUri : fallbackRedirectUri;
|
|
@@ -7926,8 +7953,8 @@ var getTelescupAccountsConfig = () => {
|
|
|
7926
7953
|
};
|
|
7927
7954
|
};
|
|
7928
7955
|
var buildTokenBundle = (tokens, config, previous) => {
|
|
7929
|
-
var
|
|
7930
|
-
const idToken = ((
|
|
7956
|
+
var _a25, _b3, _c, _d, _e, _f;
|
|
7957
|
+
const idToken = ((_a25 = tokens.id_token) == null ? void 0 : _a25.trim()) || (previous == null ? void 0 : previous.idToken) || "";
|
|
7931
7958
|
if (!idToken) {
|
|
7932
7959
|
throw new Error("Token ID do Telescup n\xE3o retornado pelo Accounts.");
|
|
7933
7960
|
}
|
|
@@ -7974,10 +8001,10 @@ var centerPopupFeatures = () => {
|
|
|
7974
8001
|
return `popup,width=${width},height=${height},left=${left},top=${top},resizable=yes,scrollbars=yes`;
|
|
7975
8002
|
};
|
|
7976
8003
|
var notifyOpener = (result) => {
|
|
7977
|
-
var
|
|
8004
|
+
var _a25;
|
|
7978
8005
|
if (!canUseWindow()) return;
|
|
7979
8006
|
try {
|
|
7980
|
-
(
|
|
8007
|
+
(_a25 = window.opener) == null ? void 0 : _a25.postMessage(result, getPopupOrigin());
|
|
7981
8008
|
} catch (e) {
|
|
7982
8009
|
}
|
|
7983
8010
|
};
|
|
@@ -8003,8 +8030,9 @@ var ensureTelescupOidcToken = async () => {
|
|
|
8003
8030
|
throw new Error("Autentica\xE7\xE3o do Telescup indispon\xEDvel fora do navegador.");
|
|
8004
8031
|
}
|
|
8005
8032
|
if (pendingTokenPromise) return pendingTokenPromise;
|
|
8006
|
-
const
|
|
8007
|
-
|
|
8033
|
+
const popupWindowName = `${POPUP_WINDOW_NAME}-${Date.now()}`;
|
|
8034
|
+
const popup = window.open("about:blank", popupWindowName, centerPopupFeatures());
|
|
8035
|
+
if (!popup || popup.closed) {
|
|
8008
8036
|
throw new Error("N\xE3o foi poss\xEDvel abrir a autentica\xE7\xE3o do Telescup. Verifique o bloqueador de popups.");
|
|
8009
8037
|
}
|
|
8010
8038
|
pendingTokenPromise = new Promise((resolve, reject) => {
|
|
@@ -8086,7 +8114,7 @@ var ensureTelescupOidcToken = async () => {
|
|
|
8086
8114
|
return pendingTokenPromise;
|
|
8087
8115
|
};
|
|
8088
8116
|
var completeTelescupOidcCallback = async () => {
|
|
8089
|
-
var
|
|
8117
|
+
var _a25;
|
|
8090
8118
|
if (!canUseWindow()) {
|
|
8091
8119
|
return { ok: false, error: "Callback do Telescup indispon\xEDvel fora do navegador." };
|
|
8092
8120
|
}
|
|
@@ -8115,7 +8143,7 @@ var completeTelescupOidcCallback = async () => {
|
|
|
8115
8143
|
throw new Error("Token endpoint do Telescup n\xE3o encontrado.");
|
|
8116
8144
|
}
|
|
8117
8145
|
const tokens = await exchangeCodeForToken(config, tokenUrl, code, flow.verifier);
|
|
8118
|
-
const nonce = String(((
|
|
8146
|
+
const nonce = String(((_a25 = decodeJwt(tokens.id_token)) == null ? void 0 : _a25.nonce) || "").trim();
|
|
8119
8147
|
if (!nonce || nonce !== flow.nonce) {
|
|
8120
8148
|
throw new Error("Nonce inv\xE1lido no callback do Telescup.");
|
|
8121
8149
|
}
|
|
@@ -8140,8 +8168,8 @@ var TELESCUP_CDN_HOSTS = /* @__PURE__ */ new Set([
|
|
|
8140
8168
|
"cdn.cupcode.com.br"
|
|
8141
8169
|
]);
|
|
8142
8170
|
var resolveAppsApiBaseUrl = () => {
|
|
8143
|
-
var
|
|
8144
|
-
return ((_b3 = (
|
|
8171
|
+
var _a25, _b3;
|
|
8172
|
+
return ((_b3 = (_a25 = getRuntimeEnv("VITE_APPS_API_BASE_URL")) != null ? _a25 : getRuntimeEnv("VITE_APPS_API_BASE")) != null ? _b3 : "").trim().replace(/\/+$/, "");
|
|
8145
8173
|
};
|
|
8146
8174
|
var isTelescupCdnUrl = (value) => {
|
|
8147
8175
|
const normalized = value == null ? void 0 : value.trim();
|
|
@@ -8153,10 +8181,10 @@ var isTelescupCdnUrl = (value) => {
|
|
|
8153
8181
|
}
|
|
8154
8182
|
};
|
|
8155
8183
|
var resolveTelescupBaseUrl = () => {
|
|
8156
|
-
var
|
|
8184
|
+
var _a25;
|
|
8157
8185
|
const appsApiBase = resolveAppsApiBaseUrl();
|
|
8158
8186
|
const apiFromApps = appsApiBase ? `${appsApiBase}/api/telescup` : "";
|
|
8159
|
-
const explicitBase = (
|
|
8187
|
+
const explicitBase = (_a25 = getRuntimeEnv("VITE_TELESCUP_BASE_URL")) == null ? void 0 : _a25.trim();
|
|
8160
8188
|
if (explicitBase && !isTelescupCdnUrl(explicitBase)) {
|
|
8161
8189
|
return explicitBase.replace(/\/+$/, "");
|
|
8162
8190
|
}
|
|
@@ -8165,17 +8193,17 @@ var resolveTelescupBaseUrl = () => {
|
|
|
8165
8193
|
var ACCESS_TOKEN_STORAGE_KEY = "cc_access_token";
|
|
8166
8194
|
var ID_TOKEN_STORAGE_KEYS = ["cc_id_token", "id_token"];
|
|
8167
8195
|
var isJwtUsable = (token, skewMs = 5e3) => {
|
|
8168
|
-
var
|
|
8196
|
+
var _a25;
|
|
8169
8197
|
const claims = decodeJwt(token);
|
|
8170
|
-
const exp = Number((
|
|
8198
|
+
const exp = Number((_a25 = claims == null ? void 0 : claims.exp) != null ? _a25 : 0);
|
|
8171
8199
|
if (!Number.isFinite(exp) || exp <= 0) return true;
|
|
8172
8200
|
return exp * 1e3 > Date.now() + skewMs;
|
|
8173
8201
|
};
|
|
8174
8202
|
var readStoredIdToken2 = () => {
|
|
8175
|
-
var
|
|
8203
|
+
var _a25;
|
|
8176
8204
|
if (typeof window === "undefined") return null;
|
|
8177
8205
|
for (const key of ID_TOKEN_STORAGE_KEYS) {
|
|
8178
|
-
const value = (
|
|
8206
|
+
const value = (_a25 = sessionStorage.getItem(key)) == null ? void 0 : _a25.trim();
|
|
8179
8207
|
if (value) return value;
|
|
8180
8208
|
}
|
|
8181
8209
|
return null;
|
|
@@ -8209,25 +8237,25 @@ var resolveCurrentUserId = (user) => {
|
|
|
8209
8237
|
return null;
|
|
8210
8238
|
};
|
|
8211
8239
|
var resolveUserIdFromClaims = (claims) => {
|
|
8212
|
-
var
|
|
8213
|
-
return (_e = (_d = (_c = (_b3 = (
|
|
8240
|
+
var _a25, _b3, _c, _d, _e;
|
|
8241
|
+
return (_e = (_d = (_c = (_b3 = (_a25 = toStringOrUndefined2(claims.sub)) != null ? _a25 : toStringOrUndefined2(claims.user_id)) != null ? _b3 : toStringOrUndefined2(claims.userId)) != null ? _c : toStringOrUndefined2(claims.uid)) != null ? _d : toStringOrUndefined2(claims.id)) != null ? _e : toStringOrUndefined2(claims["https://cupcode.com/user_id"]);
|
|
8214
8242
|
};
|
|
8215
8243
|
var resolveEmailFromClaims = (claims) => {
|
|
8216
|
-
var
|
|
8217
|
-
const candidate = (_b3 = (
|
|
8244
|
+
var _a25, _b3;
|
|
8245
|
+
const candidate = (_b3 = (_a25 = toStringOrUndefined2(claims.email)) != null ? _a25 : toStringOrUndefined2(claims["https://cupcode.com/email"])) != null ? _b3 : toStringOrUndefined2(claims.preferred_username);
|
|
8218
8246
|
if (!candidate || !candidate.includes("@")) return void 0;
|
|
8219
8247
|
return candidate.toLowerCase();
|
|
8220
8248
|
};
|
|
8221
8249
|
var normalizeTenantId = (value) => {
|
|
8222
|
-
var
|
|
8223
|
-
const normalized = (
|
|
8250
|
+
var _a25;
|
|
8251
|
+
const normalized = (_a25 = toStringOrUndefined2(value)) == null ? void 0 : _a25.toLowerCase();
|
|
8224
8252
|
if (!normalized) return void 0;
|
|
8225
8253
|
return normalized.replace(/^@/, "");
|
|
8226
8254
|
};
|
|
8227
8255
|
var resolveTenantIdFromClaims = (claims) => {
|
|
8228
|
-
var
|
|
8256
|
+
var _a25, _b3, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
8229
8257
|
return normalizeTenantId(
|
|
8230
|
-
(_j = (_i = (_h = (_g = (_f = (_e = (_d = (_c = (_b3 = (
|
|
8258
|
+
(_j = (_i = (_h = (_g = (_f = (_e = (_d = (_c = (_b3 = (_a25 = toStringOrUndefined2(claims.tenant_id)) != null ? _a25 : toStringOrUndefined2(claims.tenantId)) != null ? _b3 : toStringOrUndefined2(claims.tenant_slug)) != null ? _c : toStringOrUndefined2(claims.tenantSlug)) != null ? _d : toStringOrUndefined2(claims.company_slug)) != null ? _e : toStringOrUndefined2(claims.companySlug)) != null ? _f : toStringOrUndefined2(claims.company)) != null ? _g : toStringOrUndefined2(claims.org_slug)) != null ? _h : toStringOrUndefined2(claims.orgSlug)) != null ? _i : toStringOrUndefined2(claims["https://cupcode.com/tenant_id"])) != null ? _j : toStringOrUndefined2(claims["https://cupcode.com/tenant_slug"])
|
|
8231
8259
|
);
|
|
8232
8260
|
};
|
|
8233
8261
|
var AVATAR_IMAGE_OPTIONS = {
|
|
@@ -8238,8 +8266,8 @@ var AVATAR_IMAGE_OPTIONS = {
|
|
|
8238
8266
|
quality: 80
|
|
8239
8267
|
};
|
|
8240
8268
|
var resolveAvatarPreviewUrl = (asset, fallback) => {
|
|
8241
|
-
var
|
|
8242
|
-
return (_c = (_b3 = (
|
|
8269
|
+
var _a25, _b3, _c;
|
|
8270
|
+
return (_c = (_b3 = (_a25 = resolveTelescupImageURL(asset == null ? void 0 : asset.thumb_url, AVATAR_IMAGE_OPTIONS)) != null ? _a25 : resolveTelescupImageURL(asset == null ? void 0 : asset.preview_url, AVATAR_IMAGE_OPTIONS)) != null ? _b3 : resolveTelescupImageURL(asset == null ? void 0 : asset.url, AVATAR_IMAGE_OPTIONS)) != null ? _c : resolveTelescupImageURL(fallback, AVATAR_IMAGE_OPTIONS);
|
|
8243
8271
|
};
|
|
8244
8272
|
var isGenericRecord = (value) => typeof value === "object" && value !== null;
|
|
8245
8273
|
var buildExternalUrl = (baseUrl, target) => {
|
|
@@ -8272,11 +8300,11 @@ var normalizeMenuLanguage = (value) => {
|
|
|
8272
8300
|
return "pt-BR";
|
|
8273
8301
|
};
|
|
8274
8302
|
var resolveMenuLanguageFromRecord = (record) => {
|
|
8275
|
-
var
|
|
8303
|
+
var _a25, _b3, _c, _d, _e;
|
|
8276
8304
|
if (!record) return void 0;
|
|
8277
8305
|
const profile = isGenericRecord(record.profile) ? record.profile : null;
|
|
8278
8306
|
const preferences = isGenericRecord(record.preferences) ? record.preferences : null;
|
|
8279
|
-
const rawLanguage = (_e = (_d = (_c = (_b3 = (
|
|
8307
|
+
const rawLanguage = (_e = (_d = (_c = (_b3 = (_a25 = record.language) != null ? _a25 : record.locale) != null ? _b3 : profile == null ? void 0 : profile.language) != null ? _c : profile == null ? void 0 : profile.locale) != null ? _d : preferences == null ? void 0 : preferences.language) != null ? _e : preferences == null ? void 0 : preferences.locale;
|
|
8280
8308
|
if (typeof rawLanguage !== "string" || !rawLanguage.trim()) return void 0;
|
|
8281
8309
|
return normalizeMenuLanguage(rawLanguage);
|
|
8282
8310
|
};
|
|
@@ -8317,8 +8345,8 @@ var parseRecentActivityItems = (payload) => {
|
|
|
8317
8345
|
return [];
|
|
8318
8346
|
};
|
|
8319
8347
|
return toRows(payload).map((item, index) => {
|
|
8320
|
-
var
|
|
8321
|
-
const id = (_b3 = (
|
|
8348
|
+
var _a25, _b3, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
8349
|
+
const id = (_b3 = (_a25 = toStringOrUndefined2(item.id)) != null ? _a25 : toStringOrUndefined2(item.event_id)) != null ? _b3 : `accounts-activity-${index}`;
|
|
8322
8350
|
const title = (_e = (_d = (_c = toStringOrUndefined2(item.title)) != null ? _c : toStringOrUndefined2(item.action)) != null ? _d : toStringOrUndefined2(item.event)) != null ? _e : toStringOrUndefined2(item.type);
|
|
8323
8351
|
if (!title) return null;
|
|
8324
8352
|
const description = (_h = (_g = (_f = toStringOrUndefined2(item.description)) != null ? _f : toStringOrUndefined2(item.details)) != null ? _g : toStringOrUndefined2(item.message)) != null ? _h : toStringOrUndefined2(item.summary);
|
|
@@ -8387,7 +8415,7 @@ var MainNavbar = ({
|
|
|
8387
8415
|
getAccessToken,
|
|
8388
8416
|
appVersion
|
|
8389
8417
|
}) => {
|
|
8390
|
-
var
|
|
8418
|
+
var _a25, _b3, _c;
|
|
8391
8419
|
const [tokenDerivedUserId, setTokenDerivedUserId] = useState13(null);
|
|
8392
8420
|
const [tokenDerivedEmail, setTokenDerivedEmail] = useState13(void 0);
|
|
8393
8421
|
const [tokenDerivedTenantId, setTokenDerivedTenantId] = useState13(void 0);
|
|
@@ -8405,13 +8433,13 @@ var MainNavbar = ({
|
|
|
8405
8433
|
return "/";
|
|
8406
8434
|
}, [pathname]);
|
|
8407
8435
|
const currentUserId = useMemo10(() => {
|
|
8408
|
-
var
|
|
8409
|
-
return (
|
|
8436
|
+
var _a26;
|
|
8437
|
+
return (_a26 = resolveCurrentUserId(authUser)) != null ? _a26 : tokenDerivedUserId;
|
|
8410
8438
|
}, [authUser, tokenDerivedUserId]);
|
|
8411
8439
|
const resolvedTenantId = useMemo10(() => {
|
|
8412
|
-
var
|
|
8440
|
+
var _a26, _b4, _c2, _d, _e, _f;
|
|
8413
8441
|
const candidate = normalizeTenantId(
|
|
8414
|
-
(_f = (_e = (_d = (_c2 = (_b4 = (
|
|
8442
|
+
(_f = (_e = (_d = (_c2 = (_b4 = (_a26 = authUser == null ? void 0 : authUser.tenantSlug) != null ? _a26 : authUser == null ? void 0 : authUser.tenantId) != null ? _b4 : authUser == null ? void 0 : authUser.tenant_id) != null ? _c2 : authUser == null ? void 0 : authUser.companySlug) != null ? _d : authUser == null ? void 0 : authUser.company) != null ? _e : authUser == null ? void 0 : authUser.orgSlug) != null ? _f : tokenDerivedTenantId
|
|
8415
8443
|
);
|
|
8416
8444
|
if (!candidate || !currentUserId) return candidate;
|
|
8417
8445
|
if (candidate === currentUserId) return void 0;
|
|
@@ -8429,7 +8457,7 @@ var MainNavbar = ({
|
|
|
8429
8457
|
const resolvedTelescupBaseUrl = useMemo10(() => {
|
|
8430
8458
|
return resolveTelescupBaseUrl();
|
|
8431
8459
|
}, []);
|
|
8432
|
-
const resolvedProfileAvatarUrl = (
|
|
8460
|
+
const resolvedProfileAvatarUrl = (_a25 = resolveAvatarPreviewUrl({ url: persistedProfileAvatarValue != null ? persistedProfileAvatarValue : authUser == null ? void 0 : authUser.picture })) != null ? _a25 : void 0;
|
|
8433
8461
|
const hasStoredAccessToken = (() => {
|
|
8434
8462
|
if (typeof window === "undefined") return false;
|
|
8435
8463
|
try {
|
|
@@ -8467,7 +8495,7 @@ var MainNavbar = ({
|
|
|
8467
8495
|
}
|
|
8468
8496
|
let canceled = false;
|
|
8469
8497
|
const resolveIdentityFromToken = async () => {
|
|
8470
|
-
var
|
|
8498
|
+
var _a26, _b4;
|
|
8471
8499
|
try {
|
|
8472
8500
|
let token = null;
|
|
8473
8501
|
if (typeof window !== "undefined") {
|
|
@@ -8488,7 +8516,7 @@ var MainNavbar = ({
|
|
|
8488
8516
|
}
|
|
8489
8517
|
return;
|
|
8490
8518
|
}
|
|
8491
|
-
const claims = (
|
|
8519
|
+
const claims = (_a26 = decodeJwt(token)) != null ? _a26 : {};
|
|
8492
8520
|
if (canceled) return;
|
|
8493
8521
|
setTokenDerivedUserId((_b4 = resolveUserIdFromClaims(claims)) != null ? _b4 : null);
|
|
8494
8522
|
setTokenDerivedEmail(resolveEmailFromClaims(claims));
|
|
@@ -8548,7 +8576,7 @@ var MainNavbar = ({
|
|
|
8548
8576
|
});
|
|
8549
8577
|
};
|
|
8550
8578
|
const loadAccountsContext = async () => {
|
|
8551
|
-
var
|
|
8579
|
+
var _a26;
|
|
8552
8580
|
setIsAccountsActivityLoading(true);
|
|
8553
8581
|
setIsAccountsLoginHistoryLoading(true);
|
|
8554
8582
|
setIsTwoFactorStatusLoading(true);
|
|
@@ -8561,7 +8589,7 @@ var MainNavbar = ({
|
|
|
8561
8589
|
}
|
|
8562
8590
|
return;
|
|
8563
8591
|
}
|
|
8564
|
-
const claims = (
|
|
8592
|
+
const claims = (_a26 = decodeJwt(token)) != null ? _a26 : {};
|
|
8565
8593
|
const twoFactorFromToken = resolveTwoFactorEnabledFromClaims(claims);
|
|
8566
8594
|
if (!canceled) {
|
|
8567
8595
|
setAccountsRecentActivity(buildActivityFromTokenClaims(claims));
|
|
@@ -8630,7 +8658,7 @@ var MainNavbar = ({
|
|
|
8630
8658
|
};
|
|
8631
8659
|
}, [getAccessToken, isAuthenticated, currentUserId]);
|
|
8632
8660
|
const items = useMemo10(() => {
|
|
8633
|
-
var
|
|
8661
|
+
var _a26;
|
|
8634
8662
|
if (!showNavItems) return [];
|
|
8635
8663
|
const normalizedPathname = currentPathname === "" ? "/" : currentPathname;
|
|
8636
8664
|
const navItems = getMainNavItems({ includePrivate: resolvedAuthStatus === "authenticated" });
|
|
@@ -8640,7 +8668,7 @@ var MainNavbar = ({
|
|
|
8640
8668
|
if (normalizedPathname.startsWith(`${href}/`)) return href.length;
|
|
8641
8669
|
return -1;
|
|
8642
8670
|
};
|
|
8643
|
-
const bestMatchHref = (
|
|
8671
|
+
const bestMatchHref = (_a26 = navItems.filter((item) => !item.href.startsWith("#")).map((item) => ({ href: item.href, score: scoreRouteMatch(item.href) })).filter((candidate) => candidate.score >= 0).sort((left, right) => right.score - left.score)[0]) == null ? void 0 : _a26.href;
|
|
8644
8672
|
return navItems.map((item) => {
|
|
8645
8673
|
const isAnchor = item.href.startsWith("#");
|
|
8646
8674
|
const isActive = !isAnchor ? item.href === bestMatchHref : false;
|
|
@@ -8648,8 +8676,8 @@ var MainNavbar = ({
|
|
|
8648
8676
|
...item,
|
|
8649
8677
|
isActive,
|
|
8650
8678
|
onClick: isAnchor ? item.onClick : (event) => {
|
|
8651
|
-
var
|
|
8652
|
-
(
|
|
8679
|
+
var _a27;
|
|
8680
|
+
(_a27 = item.onClick) == null ? void 0 : _a27.call(item, event);
|
|
8653
8681
|
if (!onNavigate || event.defaultPrevented) return;
|
|
8654
8682
|
event.preventDefault();
|
|
8655
8683
|
onNavigate(item.href);
|
|
@@ -8707,11 +8735,11 @@ var MainNavbar = ({
|
|
|
8707
8735
|
}, [getAccessToken]);
|
|
8708
8736
|
const handleLanguageChange = useCallback6(
|
|
8709
8737
|
async (nextLanguage) => {
|
|
8710
|
-
var
|
|
8738
|
+
var _a26;
|
|
8711
8739
|
setAccountsLanguage(nextLanguage);
|
|
8712
8740
|
if (typeof window === "undefined") return;
|
|
8713
8741
|
try {
|
|
8714
|
-
const token = getAccessToken ? await getAccessToken() : (
|
|
8742
|
+
const token = getAccessToken ? await getAccessToken() : (_a26 = sessionStorage.getItem(ACCESS_TOKEN_STORAGE_KEY)) != null ? _a26 : readStoredIdToken2();
|
|
8715
8743
|
if (!token || !isJwtUsable(token)) return;
|
|
8716
8744
|
const response = await fetch(buildExternalUrl(resolveAccountsApiBaseUrl2(), ACCOUNTS_ME_ENDPOINT), {
|
|
8717
8745
|
method: "PATCH",
|
|
@@ -8734,8 +8762,8 @@ var MainNavbar = ({
|
|
|
8734
8762
|
);
|
|
8735
8763
|
const handleProfileAvatarChange = useCallback6(
|
|
8736
8764
|
async ({ avatarId, avatarUrl }) => {
|
|
8737
|
-
var
|
|
8738
|
-
const normalizedAvatarId = (
|
|
8765
|
+
var _a26, _b4, _c2, _d;
|
|
8766
|
+
const normalizedAvatarId = (_a26 = parseAssetId(avatarId)) != null ? _a26 : parseAssetId(avatarUrl);
|
|
8739
8767
|
if (!normalizedAvatarId) {
|
|
8740
8768
|
throw new Error("ID da imagem inv\xE1lido.");
|
|
8741
8769
|
}
|
|
@@ -9437,7 +9465,7 @@ var DocumentationSearchDialog = ({ open, onOpenChange }) => {
|
|
|
9437
9465
|
const totalSections = map.sections.length;
|
|
9438
9466
|
const mapMatches = normalizedQuery.length === 0 || normalizeText([map.title, map.subtitle, map.searchLabel].join(" ")).includes(normalizedQuery);
|
|
9439
9467
|
const sections = map.sections.filter((section) => {
|
|
9440
|
-
var
|
|
9468
|
+
var _a25, _b3, _c;
|
|
9441
9469
|
if (mapMatches) return true;
|
|
9442
9470
|
const parent = section.parentId ? parents.get(section.parentId) : null;
|
|
9443
9471
|
const haystack = normalizeText(
|
|
@@ -9446,7 +9474,7 @@ var DocumentationSearchDialog = ({ open, onOpenChange }) => {
|
|
|
9446
9474
|
map.searchLabel,
|
|
9447
9475
|
section.label,
|
|
9448
9476
|
section.group,
|
|
9449
|
-
(
|
|
9477
|
+
(_a25 = section.description) != null ? _a25 : "",
|
|
9450
9478
|
(_b3 = parent == null ? void 0 : parent.label) != null ? _b3 : "",
|
|
9451
9479
|
...(_c = section.keywords) != null ? _c : []
|
|
9452
9480
|
].join(" ")
|
|
@@ -9566,9 +9594,9 @@ var DocumentationSearchDialog = ({ open, onOpenChange }) => {
|
|
|
9566
9594
|
// src/components/layout/sidebar-groups.tsx
|
|
9567
9595
|
var toStableId = (value) => value.toLowerCase().normalize("NFD").replace(/\p{Diacritic}+/gu, "").replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)+/g, "");
|
|
9568
9596
|
var getGroupMetadata = (item) => {
|
|
9569
|
-
var
|
|
9597
|
+
var _a25, _b3;
|
|
9570
9598
|
return {
|
|
9571
|
-
id: ((
|
|
9599
|
+
id: ((_a25 = item.groupId) == null ? void 0 : _a25.trim()) || "",
|
|
9572
9600
|
label: ((_b3 = item.groupLabel) == null ? void 0 : _b3.trim()) || "",
|
|
9573
9601
|
icon: item.groupIcon
|
|
9574
9602
|
};
|
|
@@ -9584,7 +9612,7 @@ var buildSidebarGroupsFromNavItems = (items, defaultGroupLabel = "Principal") =>
|
|
|
9584
9612
|
if (navItems.length === 0) return [];
|
|
9585
9613
|
const groupsMap = /* @__PURE__ */ new Map();
|
|
9586
9614
|
navItems.forEach((item) => {
|
|
9587
|
-
var
|
|
9615
|
+
var _a25;
|
|
9588
9616
|
const groupId = item.group.id || toStableId(item.group.label || defaultGroupLabel);
|
|
9589
9617
|
const groupLabel = item.group.label || defaultGroupLabel;
|
|
9590
9618
|
const existing = groupsMap.get(groupId);
|
|
@@ -9592,7 +9620,7 @@ var buildSidebarGroupsFromNavItems = (items, defaultGroupLabel = "Principal") =>
|
|
|
9592
9620
|
groupsMap.set(groupId, {
|
|
9593
9621
|
id: groupId,
|
|
9594
9622
|
label: groupLabel,
|
|
9595
|
-
icon: (
|
|
9623
|
+
icon: (_a25 = item.group.icon) != null ? _a25 : item.icon,
|
|
9596
9624
|
items: [{ id: item.id, label: item.label, icon: item.icon, route: item.route }]
|
|
9597
9625
|
});
|
|
9598
9626
|
return;
|
|
@@ -9609,8 +9637,8 @@ var defaultSidebarGroups = buildSidebarGroupsFromNavItems(getMainNavItems());
|
|
|
9609
9637
|
// src/components/layout/sidebar.tsx
|
|
9610
9638
|
import { jsx as jsx40, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
9611
9639
|
var findGroupByRoute = (groups, pathname) => {
|
|
9612
|
-
var
|
|
9613
|
-
return (_b3 = (
|
|
9640
|
+
var _a25, _b3;
|
|
9641
|
+
return (_b3 = (_a25 = groups.find((group) => group.items.some((item) => item.route === pathname))) == null ? void 0 : _a25.label) != null ? _b3 : null;
|
|
9614
9642
|
};
|
|
9615
9643
|
var IconFallback = () => /* @__PURE__ */ jsx40(Circle2, { className: "h-3 w-3 opacity-80", "aria-hidden": "true" });
|
|
9616
9644
|
var DEFAULT_EXPANDED_LOGO_SLOT = /* @__PURE__ */ jsx40("div", { className: "h-10 w-[175px] shrink-0", "aria-hidden": "true" });
|
|
@@ -10064,12 +10092,12 @@ var FOOTER_LAYOUT_AREAS = {
|
|
|
10064
10092
|
legal: "Barra legal"
|
|
10065
10093
|
};
|
|
10066
10094
|
var groupLinksBySection = (links) => {
|
|
10067
|
-
var
|
|
10095
|
+
var _a25;
|
|
10068
10096
|
const groups = /* @__PURE__ */ new Map();
|
|
10069
10097
|
for (const link of links) {
|
|
10070
10098
|
const section = link.section.trim();
|
|
10071
10099
|
if (!section) continue;
|
|
10072
|
-
const bucket = (
|
|
10100
|
+
const bucket = (_a25 = groups.get(section)) != null ? _a25 : [];
|
|
10073
10101
|
bucket.push({ label: link.label, href: link.href });
|
|
10074
10102
|
groups.set(section, bucket);
|
|
10075
10103
|
}
|
|
@@ -10079,18 +10107,18 @@ var groupLinksBySection = (links) => {
|
|
|
10079
10107
|
}));
|
|
10080
10108
|
};
|
|
10081
10109
|
var buildFooterLayout = (links) => {
|
|
10082
|
-
var
|
|
10110
|
+
var _a25;
|
|
10083
10111
|
const byArea = /* @__PURE__ */ new Map();
|
|
10084
10112
|
for (const link of links) {
|
|
10085
10113
|
const area = link.area.trim();
|
|
10086
10114
|
if (!area) continue;
|
|
10087
|
-
const bucket = (
|
|
10115
|
+
const bucket = (_a25 = byArea.get(area)) != null ? _a25 : [];
|
|
10088
10116
|
bucket.push(link);
|
|
10089
10117
|
byArea.set(area, bucket);
|
|
10090
10118
|
}
|
|
10091
10119
|
const pickArea = (area) => {
|
|
10092
|
-
var
|
|
10093
|
-
return (
|
|
10120
|
+
var _a26;
|
|
10121
|
+
return (_a26 = byArea.get(area)) != null ? _a26 : [];
|
|
10094
10122
|
};
|
|
10095
10123
|
const footerLeftGroups = groupLinksBySection(pickArea(FOOTER_LAYOUT_AREAS.left));
|
|
10096
10124
|
const footerServiceGroups = [
|
|
@@ -10142,9 +10170,9 @@ var requestJson = async (path, init) => {
|
|
|
10142
10170
|
return payload;
|
|
10143
10171
|
};
|
|
10144
10172
|
var loadFooterLinks = async () => {
|
|
10145
|
-
var
|
|
10173
|
+
var _a25;
|
|
10146
10174
|
const data = await requestJson("/api/ds/footer-links");
|
|
10147
|
-
return ((
|
|
10175
|
+
return ((_a25 = data.links) != null ? _a25 : []).map(toLink);
|
|
10148
10176
|
};
|
|
10149
10177
|
|
|
10150
10178
|
// src/hooks/useFooterLinks.ts
|
|
@@ -11184,10 +11212,10 @@ function isThemeMode(value) {
|
|
|
11184
11212
|
return value === "light" || value === "dark";
|
|
11185
11213
|
}
|
|
11186
11214
|
function readStoredTheme() {
|
|
11187
|
-
var
|
|
11215
|
+
var _a25;
|
|
11188
11216
|
if (typeof window === "undefined") return null;
|
|
11189
11217
|
try {
|
|
11190
|
-
const storedTheme = (
|
|
11218
|
+
const storedTheme = (_a25 = window.localStorage.getItem(THEME_STORAGE_KEY2)) != null ? _a25 : window.localStorage.getItem("theme");
|
|
11191
11219
|
return isThemeMode(storedTheme) ? storedTheme : null;
|
|
11192
11220
|
} catch (e) {
|
|
11193
11221
|
return null;
|
|
@@ -11210,10 +11238,10 @@ function applyThemeClass(theme) {
|
|
|
11210
11238
|
root.style.colorScheme = theme;
|
|
11211
11239
|
}
|
|
11212
11240
|
function readThemeFromRoot() {
|
|
11213
|
-
var
|
|
11241
|
+
var _a25;
|
|
11214
11242
|
if (typeof document === "undefined") return null;
|
|
11215
11243
|
const root = document.documentElement;
|
|
11216
|
-
const datasetTheme = (
|
|
11244
|
+
const datasetTheme = (_a25 = root.dataset.theme) != null ? _a25 : null;
|
|
11217
11245
|
if (isThemeMode(datasetTheme)) return datasetTheme;
|
|
11218
11246
|
if (root.classList.contains("dark")) return "dark";
|
|
11219
11247
|
if (root.classList.contains("light")) return "light";
|
|
@@ -11236,13 +11264,13 @@ var ThemeToggle2 = ({
|
|
|
11236
11264
|
defaultTheme = "light",
|
|
11237
11265
|
onThemeChange
|
|
11238
11266
|
}) => {
|
|
11239
|
-
var
|
|
11267
|
+
var _a25;
|
|
11240
11268
|
const themeContext = React31.useContext(ThemeContext);
|
|
11241
11269
|
const [mounted, setMounted] = React31.useState(false);
|
|
11242
11270
|
const [internalTheme, setInternalTheme] = React31.useState(defaultTheme);
|
|
11243
11271
|
const isControlled = typeof theme !== "undefined";
|
|
11244
11272
|
const usesProviderTheme = !isControlled && themeContext !== null;
|
|
11245
|
-
const activeTheme = (
|
|
11273
|
+
const activeTheme = (_a25 = isControlled ? theme : usesProviderTheme ? themeContext.theme : internalTheme) != null ? _a25 : defaultTheme;
|
|
11246
11274
|
React31.useEffect(() => {
|
|
11247
11275
|
if (!isControlled && !usesProviderTheme) {
|
|
11248
11276
|
setInternalTheme(resolveTheme(defaultTheme));
|
|
@@ -11267,8 +11295,8 @@ var ThemeToggle2 = ({
|
|
|
11267
11295
|
return /* @__PURE__ */ jsx59("div", { className: cn("w-10 h-10 rounded-lg bg-muted", className) });
|
|
11268
11296
|
}
|
|
11269
11297
|
const handleToggle = (event) => {
|
|
11270
|
-
var
|
|
11271
|
-
const currentTheme = (
|
|
11298
|
+
var _a26;
|
|
11299
|
+
const currentTheme = (_a26 = readThemeFromRoot()) != null ? _a26 : activeTheme;
|
|
11272
11300
|
const nextTheme = currentTheme === "dark" ? "light" : "dark";
|
|
11273
11301
|
if (usesProviderTheme) {
|
|
11274
11302
|
themeContext.toggleTheme({
|
|
@@ -11322,11 +11350,11 @@ function getPreferredTheme() {
|
|
|
11322
11350
|
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
11323
11351
|
}
|
|
11324
11352
|
function getStoredTheme() {
|
|
11325
|
-
var
|
|
11353
|
+
var _a25;
|
|
11326
11354
|
if (typeof window === "undefined") {
|
|
11327
11355
|
return null;
|
|
11328
11356
|
}
|
|
11329
|
-
const storedTheme = (
|
|
11357
|
+
const storedTheme = (_a25 = window.localStorage.getItem(STORAGE_KEY)) != null ? _a25 : window.localStorage.getItem(LEGACY_STORAGE_KEY);
|
|
11330
11358
|
return storedTheme === "light" || storedTheme === "dark" ? storedTheme : null;
|
|
11331
11359
|
}
|
|
11332
11360
|
function getThemeFromRoot() {
|
|
@@ -11347,8 +11375,8 @@ function getThemeFromRoot() {
|
|
|
11347
11375
|
return null;
|
|
11348
11376
|
}
|
|
11349
11377
|
function resolveTheme2() {
|
|
11350
|
-
var
|
|
11351
|
-
return (_b3 = (
|
|
11378
|
+
var _a25, _b3;
|
|
11379
|
+
return (_b3 = (_a25 = getThemeFromRoot()) != null ? _a25 : getStoredTheme()) != null ? _b3 : getPreferredTheme();
|
|
11352
11380
|
}
|
|
11353
11381
|
function applyThemeToRoot(theme) {
|
|
11354
11382
|
const root = document.documentElement;
|
|
@@ -11418,7 +11446,7 @@ function ThemeProvider({ children }) {
|
|
|
11418
11446
|
return () => observer.disconnect();
|
|
11419
11447
|
}, []);
|
|
11420
11448
|
const applyThemeSelection = useCallback8((nextTheme, coords) => {
|
|
11421
|
-
var
|
|
11449
|
+
var _a25;
|
|
11422
11450
|
const documentWithTransition = document;
|
|
11423
11451
|
const root = document.documentElement;
|
|
11424
11452
|
const prefersReducedMotion = window.matchMedia(
|
|
@@ -11443,7 +11471,7 @@ function ThemeProvider({ children }) {
|
|
|
11443
11471
|
root.style.setProperty("--theme-x", "50%");
|
|
11444
11472
|
root.style.setProperty("--theme-y", "50%");
|
|
11445
11473
|
}
|
|
11446
|
-
(
|
|
11474
|
+
(_a25 = documentWithTransition.startViewTransition) == null ? void 0 : _a25.call(documentWithTransition, () => {
|
|
11447
11475
|
flushSync(() => {
|
|
11448
11476
|
commitTheme();
|
|
11449
11477
|
});
|
|
@@ -11453,8 +11481,8 @@ function ThemeProvider({ children }) {
|
|
|
11453
11481
|
applyThemeSelection(nextTheme);
|
|
11454
11482
|
}, [applyThemeSelection]);
|
|
11455
11483
|
const toggleTheme = useCallback8((coords) => {
|
|
11456
|
-
var
|
|
11457
|
-
const currentTheme = (
|
|
11484
|
+
var _a25;
|
|
11485
|
+
const currentTheme = (_a25 = getThemeFromRoot()) != null ? _a25 : theme;
|
|
11458
11486
|
const nextTheme = currentTheme === "light" ? "dark" : "light";
|
|
11459
11487
|
applyThemeSelection(nextTheme, coords);
|
|
11460
11488
|
}, [applyThemeSelection, theme]);
|
|
@@ -12161,8 +12189,8 @@ var ChartStyle = ({ id, config }) => {
|
|
|
12161
12189
|
([theme, prefix]) => `
|
|
12162
12190
|
${prefix} [data-chart=${id}] {
|
|
12163
12191
|
${colorConfig.map(([key, itemConfig]) => {
|
|
12164
|
-
var
|
|
12165
|
-
const color = ((
|
|
12192
|
+
var _a25;
|
|
12193
|
+
const color = ((_a25 = itemConfig.theme) == null ? void 0 : _a25[theme]) || itemConfig.color;
|
|
12166
12194
|
return color ? ` --color-${key}: ${color};` : null;
|
|
12167
12195
|
}).join("\n")}
|
|
12168
12196
|
}
|
|
@@ -12191,14 +12219,14 @@ var ChartTooltipContent = React40.forwardRef(
|
|
|
12191
12219
|
}, ref) => {
|
|
12192
12220
|
const { config } = useChart();
|
|
12193
12221
|
const tooltipLabel = React40.useMemo(() => {
|
|
12194
|
-
var
|
|
12222
|
+
var _a25;
|
|
12195
12223
|
if (hideLabel || !(payload == null ? void 0 : payload.length)) {
|
|
12196
12224
|
return null;
|
|
12197
12225
|
}
|
|
12198
12226
|
const [item] = payload;
|
|
12199
12227
|
const key = `${labelKey || item.dataKey || item.name || "value"}`;
|
|
12200
12228
|
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
12201
|
-
const value = !labelKey && typeof label === "string" ? ((
|
|
12229
|
+
const value = !labelKey && typeof label === "string" ? ((_a25 = config[label]) == null ? void 0 : _a25.label) || label : itemConfig == null ? void 0 : itemConfig.label;
|
|
12202
12230
|
if (labelFormatter) {
|
|
12203
12231
|
return /* @__PURE__ */ jsx72("div", { className: cn("font-medium", labelClassName), children: labelFormatter(value, payload) });
|
|
12204
12232
|
}
|
|
@@ -13918,9 +13946,9 @@ ToggleGroupItem.displayName = ToggleGroupPrimitive.Item.displayName;
|
|
|
13918
13946
|
// src/hooks/useActiveSection.ts
|
|
13919
13947
|
import { useEffect as useEffect26, useState as useState23 } from "react";
|
|
13920
13948
|
var resolveActiveFromOffsets = (sectionIds, topById, offset, scrollY) => {
|
|
13921
|
-
var
|
|
13949
|
+
var _a25;
|
|
13922
13950
|
const line = scrollY + offset;
|
|
13923
|
-
let nextActive = (
|
|
13951
|
+
let nextActive = (_a25 = sectionIds[0]) != null ? _a25 : "";
|
|
13924
13952
|
for (const id of sectionIds) {
|
|
13925
13953
|
const top = topById.get(id);
|
|
13926
13954
|
if (typeof top !== "number") continue;
|
|
@@ -13933,10 +13961,10 @@ var resolveActiveFromOffsets = (sectionIds, topById, offset, scrollY) => {
|
|
|
13933
13961
|
return nextActive;
|
|
13934
13962
|
};
|
|
13935
13963
|
var useActiveSection = (sectionIds, offset = 180) => {
|
|
13936
|
-
var
|
|
13937
|
-
const [activeId, setActiveId] = useState23((
|
|
13964
|
+
var _a25;
|
|
13965
|
+
const [activeId, setActiveId] = useState23((_a25 = sectionIds[0]) != null ? _a25 : "");
|
|
13938
13966
|
useEffect26(() => {
|
|
13939
|
-
var
|
|
13967
|
+
var _a26;
|
|
13940
13968
|
if (!sectionIds.length || typeof window === "undefined") return;
|
|
13941
13969
|
const sections = sectionIds.map((id) => {
|
|
13942
13970
|
const element = document.getElementById(id);
|
|
@@ -13944,7 +13972,7 @@ var useActiveSection = (sectionIds, offset = 180) => {
|
|
|
13944
13972
|
return { id, element };
|
|
13945
13973
|
}).filter((section) => section !== null);
|
|
13946
13974
|
if (!sections.length) {
|
|
13947
|
-
setActiveId((
|
|
13975
|
+
setActiveId((_a26 = sectionIds[0]) != null ? _a26 : "");
|
|
13948
13976
|
return;
|
|
13949
13977
|
}
|
|
13950
13978
|
const topById = /* @__PURE__ */ new Map();
|
|
@@ -14079,9 +14107,9 @@ var useLayoutMode = () => {
|
|
|
14079
14107
|
setMode(normalizeLayoutMode(event.newValue));
|
|
14080
14108
|
};
|
|
14081
14109
|
const handleModeChange = (event) => {
|
|
14082
|
-
var
|
|
14110
|
+
var _a25;
|
|
14083
14111
|
const customEvent = event;
|
|
14084
|
-
setMode((
|
|
14112
|
+
setMode((_a25 = customEvent.detail) != null ? _a25 : readStoredLayoutMode());
|
|
14085
14113
|
};
|
|
14086
14114
|
window.addEventListener("storage", handleStorage);
|
|
14087
14115
|
window.addEventListener(LAYOUT_MODE_CHANGE_EVENT, handleModeChange);
|
|
@@ -14238,7 +14266,7 @@ var FunctionsClient = class {
|
|
|
14238
14266
|
*/
|
|
14239
14267
|
invoke(functionName_1) {
|
|
14240
14268
|
return __awaiter(this, arguments, void 0, function* (functionName, options = {}) {
|
|
14241
|
-
var
|
|
14269
|
+
var _a25;
|
|
14242
14270
|
let timeoutId;
|
|
14243
14271
|
let timeoutController;
|
|
14244
14272
|
try {
|
|
@@ -14304,7 +14332,7 @@ var FunctionsClient = class {
|
|
|
14304
14332
|
if (!response.ok) {
|
|
14305
14333
|
throw new FunctionsHttpError(response);
|
|
14306
14334
|
}
|
|
14307
|
-
let responseType = ((
|
|
14335
|
+
let responseType = ((_a25 = response.headers.get("Content-Type")) !== null && _a25 !== void 0 ? _a25 : "text/plain").split(";")[0].trim();
|
|
14308
14336
|
let data;
|
|
14309
14337
|
if (responseType === "application/json") {
|
|
14310
14338
|
data = yield response.json();
|
|
@@ -15653,7 +15681,7 @@ var WebSocketFactory = class {
|
|
|
15653
15681
|
constructor() {
|
|
15654
15682
|
}
|
|
15655
15683
|
static detectEnvironment() {
|
|
15656
|
-
var
|
|
15684
|
+
var _a25;
|
|
15657
15685
|
if (typeof WebSocket !== "undefined") {
|
|
15658
15686
|
return { type: "native", constructor: WebSocket };
|
|
15659
15687
|
}
|
|
@@ -15670,7 +15698,7 @@ var WebSocketFactory = class {
|
|
|
15670
15698
|
workaround: "Use Cloudflare Workers WebSocket API for server-side WebSocket handling, or deploy to a different runtime."
|
|
15671
15699
|
};
|
|
15672
15700
|
}
|
|
15673
|
-
if (typeof globalThis !== "undefined" && globalThis.EdgeRuntime || typeof navigator !== "undefined" && ((
|
|
15701
|
+
if (typeof globalThis !== "undefined" && globalThis.EdgeRuntime || typeof navigator !== "undefined" && ((_a25 = navigator.userAgent) === null || _a25 === void 0 ? void 0 : _a25.includes("Vercel-Edge"))) {
|
|
15674
15702
|
return {
|
|
15675
15703
|
type: "unsupported",
|
|
15676
15704
|
error: "Edge runtime detected (Vercel Edge/Netlify Edge). WebSockets are not supported in edge functions.",
|
|
@@ -15754,7 +15782,7 @@ Suggested solution: ${env.workaround}`;
|
|
|
15754
15782
|
try {
|
|
15755
15783
|
const env = this.detectEnvironment();
|
|
15756
15784
|
return env.type === "native" || env.type === "ws";
|
|
15757
|
-
} catch (
|
|
15785
|
+
} catch (_a25) {
|
|
15758
15786
|
return false;
|
|
15759
15787
|
}
|
|
15760
15788
|
}
|
|
@@ -15828,29 +15856,29 @@ var Serializer = class {
|
|
|
15828
15856
|
return callback(JSON.stringify(payload));
|
|
15829
15857
|
}
|
|
15830
15858
|
_binaryEncodeUserBroadcastPush(message) {
|
|
15831
|
-
var
|
|
15832
|
-
if (this._isArrayBuffer((
|
|
15859
|
+
var _a25;
|
|
15860
|
+
if (this._isArrayBuffer((_a25 = message.payload) === null || _a25 === void 0 ? void 0 : _a25.payload)) {
|
|
15833
15861
|
return this._encodeBinaryUserBroadcastPush(message);
|
|
15834
15862
|
} else {
|
|
15835
15863
|
return this._encodeJsonUserBroadcastPush(message);
|
|
15836
15864
|
}
|
|
15837
15865
|
}
|
|
15838
15866
|
_encodeBinaryUserBroadcastPush(message) {
|
|
15839
|
-
var
|
|
15840
|
-
const userPayload = (_b3 = (
|
|
15867
|
+
var _a25, _b3;
|
|
15868
|
+
const userPayload = (_b3 = (_a25 = message.payload) === null || _a25 === void 0 ? void 0 : _a25.payload) !== null && _b3 !== void 0 ? _b3 : new ArrayBuffer(0);
|
|
15841
15869
|
return this._encodeUserBroadcastPush(message, this.BINARY_ENCODING, userPayload);
|
|
15842
15870
|
}
|
|
15843
15871
|
_encodeJsonUserBroadcastPush(message) {
|
|
15844
|
-
var
|
|
15845
|
-
const userPayload = (_b3 = (
|
|
15872
|
+
var _a25, _b3;
|
|
15873
|
+
const userPayload = (_b3 = (_a25 = message.payload) === null || _a25 === void 0 ? void 0 : _a25.payload) !== null && _b3 !== void 0 ? _b3 : {};
|
|
15846
15874
|
const encoder = new TextEncoder();
|
|
15847
15875
|
const encodedUserPayload = encoder.encode(JSON.stringify(userPayload)).buffer;
|
|
15848
15876
|
return this._encodeUserBroadcastPush(message, this.JSON_ENCODING, encodedUserPayload);
|
|
15849
15877
|
}
|
|
15850
15878
|
_encodeUserBroadcastPush(message, encodingType, encodedPayload) {
|
|
15851
|
-
var
|
|
15879
|
+
var _a25, _b3;
|
|
15852
15880
|
const topic = message.topic;
|
|
15853
|
-
const ref = (
|
|
15881
|
+
const ref = (_a25 = message.ref) !== null && _a25 !== void 0 ? _a25 : "";
|
|
15854
15882
|
const joinRef = (_b3 = message.join_ref) !== null && _b3 !== void 0 ? _b3 : "";
|
|
15855
15883
|
const userEvent = message.payload.event;
|
|
15856
15884
|
const rest = this.allowedMetadataKeys ? this._pick(message.payload, this.allowedMetadataKeys) : {};
|
|
@@ -15937,8 +15965,8 @@ var Serializer = class {
|
|
|
15937
15965
|
return { join_ref: null, ref: null, topic, event: this.BROADCAST_EVENT, payload: data };
|
|
15938
15966
|
}
|
|
15939
15967
|
_isArrayBuffer(buffer) {
|
|
15940
|
-
var
|
|
15941
|
-
return buffer instanceof ArrayBuffer || ((
|
|
15968
|
+
var _a25;
|
|
15969
|
+
return buffer instanceof ArrayBuffer || ((_a25 = buffer === null || buffer === void 0 ? void 0 : buffer.constructor) === null || _a25 === void 0 ? void 0 : _a25.name) === "ArrayBuffer";
|
|
15942
15970
|
}
|
|
15943
15971
|
_pick(obj, keys) {
|
|
15944
15972
|
if (!obj || typeof obj !== "object") {
|
|
@@ -16002,8 +16030,8 @@ var PostgresTypes;
|
|
|
16002
16030
|
PostgresTypes2["tstzrange"] = "tstzrange";
|
|
16003
16031
|
})(PostgresTypes || (PostgresTypes = {}));
|
|
16004
16032
|
var convertChangeData = (columns, record, options = {}) => {
|
|
16005
|
-
var
|
|
16006
|
-
const skipTypes = (
|
|
16033
|
+
var _a25;
|
|
16034
|
+
const skipTypes = (_a25 = options.skipTypes) !== null && _a25 !== void 0 ? _a25 : [];
|
|
16007
16035
|
if (!record) {
|
|
16008
16036
|
return {};
|
|
16009
16037
|
}
|
|
@@ -16093,7 +16121,7 @@ var toJson = (value) => {
|
|
|
16093
16121
|
if (typeof value === "string") {
|
|
16094
16122
|
try {
|
|
16095
16123
|
return JSON.parse(value);
|
|
16096
|
-
} catch (
|
|
16124
|
+
} catch (_a25) {
|
|
16097
16125
|
return value;
|
|
16098
16126
|
}
|
|
16099
16127
|
}
|
|
@@ -16185,9 +16213,9 @@ var Push = class {
|
|
|
16185
16213
|
this.payload = Object.assign(Object.assign({}, this.payload), payload);
|
|
16186
16214
|
}
|
|
16187
16215
|
receive(status, callback) {
|
|
16188
|
-
var
|
|
16216
|
+
var _a25;
|
|
16189
16217
|
if (this._hasReceived(status)) {
|
|
16190
|
-
callback((
|
|
16218
|
+
callback((_a25 = this.receivedResp) === null || _a25 === void 0 ? void 0 : _a25.response);
|
|
16191
16219
|
}
|
|
16192
16220
|
this.recHooks.push({ status, callback });
|
|
16193
16221
|
return this;
|
|
@@ -16378,8 +16406,8 @@ var RealtimePresence = class _RealtimePresence {
|
|
|
16378
16406
|
};
|
|
16379
16407
|
}
|
|
16380
16408
|
this.map(joins, (key, newPresences) => {
|
|
16381
|
-
var
|
|
16382
|
-
const currentPresences = (
|
|
16409
|
+
var _a25;
|
|
16410
|
+
const currentPresences = (_a25 = state[key]) !== null && _a25 !== void 0 ? _a25 : [];
|
|
16383
16411
|
state[key] = this.cloneDeep(newPresences);
|
|
16384
16412
|
if (currentPresences.length > 0) {
|
|
16385
16413
|
const joinedPresenceRefs = state[key].map((m) => m.presence_ref);
|
|
@@ -16507,7 +16535,7 @@ var RealtimeChannel = class _RealtimeChannel {
|
|
|
16507
16535
|
* ```
|
|
16508
16536
|
*/
|
|
16509
16537
|
constructor(topic, params = { config: {} }, socket) {
|
|
16510
|
-
var
|
|
16538
|
+
var _a25, _b3;
|
|
16511
16539
|
this.topic = topic;
|
|
16512
16540
|
this.params = params;
|
|
16513
16541
|
this.socket = socket;
|
|
@@ -16566,19 +16594,19 @@ var RealtimeChannel = class _RealtimeChannel {
|
|
|
16566
16594
|
this.presence = new RealtimePresence(this);
|
|
16567
16595
|
this.broadcastEndpointURL = httpEndpointURL(this.socket.endPoint);
|
|
16568
16596
|
this.private = this.params.config.private || false;
|
|
16569
|
-
if (!this.private && ((_b3 = (
|
|
16597
|
+
if (!this.private && ((_b3 = (_a25 = this.params.config) === null || _a25 === void 0 ? void 0 : _a25.broadcast) === null || _b3 === void 0 ? void 0 : _b3.replay)) {
|
|
16570
16598
|
throw `tried to use replay on public channel '${this.topic}'. It must be a private channel.`;
|
|
16571
16599
|
}
|
|
16572
16600
|
}
|
|
16573
16601
|
/** Subscribe registers your client with the server */
|
|
16574
16602
|
subscribe(callback, timeout = this.timeout) {
|
|
16575
|
-
var
|
|
16603
|
+
var _a25, _b3, _c;
|
|
16576
16604
|
if (!this.socket.isConnected()) {
|
|
16577
16605
|
this.socket.connect();
|
|
16578
16606
|
}
|
|
16579
16607
|
if (this.state == CHANNEL_STATES.closed) {
|
|
16580
16608
|
const { config: { broadcast, presence, private: isPrivate } } = this.params;
|
|
16581
|
-
const postgres_changes = (_b3 = (
|
|
16609
|
+
const postgres_changes = (_b3 = (_a25 = this.bindings.postgres_changes) === null || _a25 === void 0 ? void 0 : _a25.map((r) => r.filter)) !== null && _b3 !== void 0 ? _b3 : [];
|
|
16582
16610
|
const presence_enabled = !!this.bindings[REALTIME_LISTEN_TYPES.PRESENCE] && this.bindings[REALTIME_LISTEN_TYPES.PRESENCE].length > 0 || ((_c = this.params.config.presence) === null || _c === void 0 ? void 0 : _c.enabled) === true;
|
|
16583
16611
|
const accessTokenPayload = {};
|
|
16584
16612
|
const config = {
|
|
@@ -16596,7 +16624,7 @@ var RealtimeChannel = class _RealtimeChannel {
|
|
|
16596
16624
|
this.joinedOnce = true;
|
|
16597
16625
|
this._rejoin(timeout);
|
|
16598
16626
|
this.joinPush.receive("ok", async ({ postgres_changes: postgres_changes2 }) => {
|
|
16599
|
-
var
|
|
16627
|
+
var _a26;
|
|
16600
16628
|
if (!this.socket._isManualToken()) {
|
|
16601
16629
|
this.socket.setAuth();
|
|
16602
16630
|
}
|
|
@@ -16605,7 +16633,7 @@ var RealtimeChannel = class _RealtimeChannel {
|
|
|
16605
16633
|
return;
|
|
16606
16634
|
} else {
|
|
16607
16635
|
const clientPostgresBindings = this.bindings.postgres_changes;
|
|
16608
|
-
const bindingsLen = (
|
|
16636
|
+
const bindingsLen = (_a26 = clientPostgresBindings === null || clientPostgresBindings === void 0 ? void 0 : clientPostgresBindings.length) !== null && _a26 !== void 0 ? _a26 : 0;
|
|
16609
16637
|
const newPostgresBindings = [];
|
|
16610
16638
|
for (let i = 0; i < bindingsLen; i++) {
|
|
16611
16639
|
const clientPostgresBinding = clientPostgresBindings[i];
|
|
@@ -16683,7 +16711,7 @@ var RealtimeChannel = class _RealtimeChannel {
|
|
|
16683
16711
|
* @returns Promise resolving to object with success status, and error details if failed
|
|
16684
16712
|
*/
|
|
16685
16713
|
async httpSend(event, payload, opts = {}) {
|
|
16686
|
-
var
|
|
16714
|
+
var _a25;
|
|
16687
16715
|
if (payload === void 0 || payload === null) {
|
|
16688
16716
|
return Promise.reject("Payload is required for httpSend()");
|
|
16689
16717
|
}
|
|
@@ -16708,7 +16736,7 @@ var RealtimeChannel = class _RealtimeChannel {
|
|
|
16708
16736
|
]
|
|
16709
16737
|
})
|
|
16710
16738
|
};
|
|
16711
|
-
const response = await this._fetchWithTimeout(this.broadcastEndpointURL, options, (
|
|
16739
|
+
const response = await this._fetchWithTimeout(this.broadcastEndpointURL, options, (_a25 = opts.timeout) !== null && _a25 !== void 0 ? _a25 : this.timeout);
|
|
16712
16740
|
if (response.status === 202) {
|
|
16713
16741
|
return { success: true };
|
|
16714
16742
|
}
|
|
@@ -16730,7 +16758,7 @@ var RealtimeChannel = class _RealtimeChannel {
|
|
|
16730
16758
|
* @param opts Options to be used during the send process
|
|
16731
16759
|
*/
|
|
16732
16760
|
async send(args, opts = {}) {
|
|
16733
|
-
var
|
|
16761
|
+
var _a25, _b3;
|
|
16734
16762
|
if (!this._canPush() && args.type === "broadcast") {
|
|
16735
16763
|
console.warn("Realtime send() is automatically falling back to REST API. This behavior will be deprecated in the future. Please use httpSend() explicitly for REST delivery.");
|
|
16736
16764
|
const { event, payload: endpoint_payload } = args;
|
|
@@ -16756,7 +16784,7 @@ var RealtimeChannel = class _RealtimeChannel {
|
|
|
16756
16784
|
})
|
|
16757
16785
|
};
|
|
16758
16786
|
try {
|
|
16759
|
-
const response = await this._fetchWithTimeout(this.broadcastEndpointURL, options, (
|
|
16787
|
+
const response = await this._fetchWithTimeout(this.broadcastEndpointURL, options, (_a25 = opts.timeout) !== null && _a25 !== void 0 ? _a25 : this.timeout);
|
|
16760
16788
|
await ((_b3 = response.body) === null || _b3 === void 0 ? void 0 : _b3.cancel());
|
|
16761
16789
|
return response.ok ? "ok" : "error";
|
|
16762
16790
|
} catch (error) {
|
|
@@ -16768,9 +16796,9 @@ var RealtimeChannel = class _RealtimeChannel {
|
|
|
16768
16796
|
}
|
|
16769
16797
|
} else {
|
|
16770
16798
|
return new Promise((resolve) => {
|
|
16771
|
-
var
|
|
16799
|
+
var _a26, _b4, _c;
|
|
16772
16800
|
const push = this._push(args.type, args, opts.timeout || this.timeout);
|
|
16773
|
-
if (args.type === "broadcast" && !((_c = (_b4 = (
|
|
16801
|
+
if (args.type === "broadcast" && !((_c = (_b4 = (_a26 = this.params) === null || _a26 === void 0 ? void 0 : _a26.config) === null || _b4 === void 0 ? void 0 : _b4.broadcast) === null || _c === void 0 ? void 0 : _c.ack)) {
|
|
16774
16802
|
resolve("ok");
|
|
16775
16803
|
}
|
|
16776
16804
|
push.receive("ok", () => resolve("ok"));
|
|
@@ -16889,7 +16917,7 @@ var RealtimeChannel = class _RealtimeChannel {
|
|
|
16889
16917
|
}
|
|
16890
16918
|
/** @internal */
|
|
16891
16919
|
_trigger(type, payload, ref) {
|
|
16892
|
-
var
|
|
16920
|
+
var _a25, _b3;
|
|
16893
16921
|
const typeLower = type.toLocaleLowerCase();
|
|
16894
16922
|
const { close, error, leave, join } = CHANNEL_EVENTS;
|
|
16895
16923
|
const events = [close, error, leave, join];
|
|
@@ -16901,17 +16929,17 @@ var RealtimeChannel = class _RealtimeChannel {
|
|
|
16901
16929
|
throw "channel onMessage callbacks must return the payload, modified or unmodified";
|
|
16902
16930
|
}
|
|
16903
16931
|
if (["insert", "update", "delete"].includes(typeLower)) {
|
|
16904
|
-
(
|
|
16905
|
-
var
|
|
16906
|
-
return ((
|
|
16932
|
+
(_a25 = this.bindings.postgres_changes) === null || _a25 === void 0 ? void 0 : _a25.filter((bind) => {
|
|
16933
|
+
var _a26, _b4, _c;
|
|
16934
|
+
return ((_a26 = bind.filter) === null || _a26 === void 0 ? void 0 : _a26.event) === "*" || ((_c = (_b4 = bind.filter) === null || _b4 === void 0 ? void 0 : _b4.event) === null || _c === void 0 ? void 0 : _c.toLocaleLowerCase()) === typeLower;
|
|
16907
16935
|
}).map((bind) => bind.callback(handledPayload, ref));
|
|
16908
16936
|
} else {
|
|
16909
16937
|
(_b3 = this.bindings[typeLower]) === null || _b3 === void 0 ? void 0 : _b3.filter((bind) => {
|
|
16910
|
-
var
|
|
16938
|
+
var _a26, _b4, _c, _d, _e, _f;
|
|
16911
16939
|
if (["broadcast", "presence", "postgres_changes"].includes(typeLower)) {
|
|
16912
16940
|
if ("id" in bind) {
|
|
16913
16941
|
const bindId = bind.id;
|
|
16914
|
-
const bindEvent = (
|
|
16942
|
+
const bindEvent = (_a26 = bind.filter) === null || _a26 === void 0 ? void 0 : _a26.event;
|
|
16915
16943
|
return bindId && ((_b4 = payload.ids) === null || _b4 === void 0 ? void 0 : _b4.includes(bindId)) && (bindEvent === "*" || (bindEvent === null || bindEvent === void 0 ? void 0 : bindEvent.toLocaleLowerCase()) === ((_c = payload.data) === null || _c === void 0 ? void 0 : _c.type.toLocaleLowerCase()));
|
|
16916
16944
|
} else {
|
|
16917
16945
|
const bindEvent = (_e = (_d = bind === null || bind === void 0 ? void 0 : bind.filter) === null || _d === void 0 ? void 0 : _d.event) === null || _e === void 0 ? void 0 : _e.toLocaleLowerCase();
|
|
@@ -16979,8 +17007,8 @@ var RealtimeChannel = class _RealtimeChannel {
|
|
|
16979
17007
|
const typeLower = type.toLocaleLowerCase();
|
|
16980
17008
|
if (this.bindings[typeLower]) {
|
|
16981
17009
|
this.bindings[typeLower] = this.bindings[typeLower].filter((bind) => {
|
|
16982
|
-
var
|
|
16983
|
-
return !(((
|
|
17010
|
+
var _a25;
|
|
17011
|
+
return !(((_a25 = bind.type) === null || _a25 === void 0 ? void 0 : _a25.toLocaleLowerCase()) === typeLower && _RealtimeChannel.isEqual(bind.filter, filter));
|
|
16984
17012
|
});
|
|
16985
17013
|
}
|
|
16986
17014
|
return this;
|
|
@@ -17110,7 +17138,7 @@ var RealtimeClient = class {
|
|
|
17110
17138
|
* ```
|
|
17111
17139
|
*/
|
|
17112
17140
|
constructor(endPoint, options) {
|
|
17113
|
-
var
|
|
17141
|
+
var _a25;
|
|
17114
17142
|
this.accessTokenValue = null;
|
|
17115
17143
|
this.apiKey = null;
|
|
17116
17144
|
this._manuallySetToken = false;
|
|
@@ -17149,7 +17177,7 @@ var RealtimeClient = class {
|
|
|
17149
17177
|
}
|
|
17150
17178
|
return (...args) => fetch(...args);
|
|
17151
17179
|
};
|
|
17152
|
-
if (!((
|
|
17180
|
+
if (!((_a25 = options === null || options === void 0 ? void 0 : options.params) === null || _a25 === void 0 ? void 0 : _a25.apikey)) {
|
|
17153
17181
|
throw new Error("API key is required to connect to Realtime");
|
|
17154
17182
|
}
|
|
17155
17183
|
this.apiKey = options.params.apikey;
|
|
@@ -17334,8 +17362,8 @@ Option 2: Install and provide the "ws" package:
|
|
|
17334
17362
|
const { topic, event, payload, ref } = data;
|
|
17335
17363
|
const callback = () => {
|
|
17336
17364
|
this.encode(data, (result) => {
|
|
17337
|
-
var
|
|
17338
|
-
(
|
|
17365
|
+
var _a25;
|
|
17366
|
+
(_a25 = this.conn) === null || _a25 === void 0 ? void 0 : _a25.send(result);
|
|
17339
17367
|
});
|
|
17340
17368
|
};
|
|
17341
17369
|
this.log("push", `${topic} ${event} (${ref})`, payload);
|
|
@@ -17385,7 +17413,7 @@ Option 2: Install and provide the "ws" package:
|
|
|
17385
17413
|
* Sends a heartbeat message if the socket is connected.
|
|
17386
17414
|
*/
|
|
17387
17415
|
async sendHeartbeat() {
|
|
17388
|
-
var
|
|
17416
|
+
var _a25;
|
|
17389
17417
|
if (!this.isConnected()) {
|
|
17390
17418
|
try {
|
|
17391
17419
|
this.heartbeatCallback("disconnected");
|
|
@@ -17404,11 +17432,11 @@ Option 2: Install and provide the "ws" package:
|
|
|
17404
17432
|
this.log("error", "error in heartbeat callback", e);
|
|
17405
17433
|
}
|
|
17406
17434
|
this._wasManualDisconnect = false;
|
|
17407
|
-
(
|
|
17435
|
+
(_a25 = this.conn) === null || _a25 === void 0 ? void 0 : _a25.close(WS_CLOSE_NORMAL, "heartbeat timeout");
|
|
17408
17436
|
setTimeout(() => {
|
|
17409
|
-
var
|
|
17437
|
+
var _a26;
|
|
17410
17438
|
if (!this.isConnected()) {
|
|
17411
|
-
(
|
|
17439
|
+
(_a26 = this.reconnectTimer) === null || _a26 === void 0 ? void 0 : _a26.scheduleTimeout();
|
|
17412
17440
|
}
|
|
17413
17441
|
}, CONNECTION_TIMEOUTS.HEARTBEAT_TIMEOUT_FALLBACK);
|
|
17414
17442
|
return;
|
|
@@ -17506,12 +17534,12 @@ Option 2: Install and provide the "ws" package:
|
|
|
17506
17534
|
* @internal
|
|
17507
17535
|
*/
|
|
17508
17536
|
_clearTimer(timer) {
|
|
17509
|
-
var
|
|
17537
|
+
var _a25;
|
|
17510
17538
|
if (timer === "heartbeat" && this.heartbeatTimer) {
|
|
17511
17539
|
clearInterval(this.heartbeatTimer);
|
|
17512
17540
|
this.heartbeatTimer = void 0;
|
|
17513
17541
|
} else if (timer === "reconnect") {
|
|
17514
|
-
(
|
|
17542
|
+
(_a25 = this.reconnectTimer) === null || _a25 === void 0 ? void 0 : _a25.reset();
|
|
17515
17543
|
}
|
|
17516
17544
|
}
|
|
17517
17545
|
/**
|
|
@@ -17626,13 +17654,13 @@ Option 2: Install and provide the "ws" package:
|
|
|
17626
17654
|
}
|
|
17627
17655
|
/** @internal */
|
|
17628
17656
|
_onConnClose(event) {
|
|
17629
|
-
var
|
|
17657
|
+
var _a25;
|
|
17630
17658
|
this._setConnectionState("disconnected");
|
|
17631
17659
|
this.log("transport", "close", event);
|
|
17632
17660
|
this._triggerChanError();
|
|
17633
17661
|
this._clearTimer("heartbeat");
|
|
17634
17662
|
if (!this._wasManualDisconnect) {
|
|
17635
|
-
(
|
|
17663
|
+
(_a25 = this.reconnectTimer) === null || _a25 === void 0 ? void 0 : _a25.scheduleTimeout();
|
|
17636
17664
|
}
|
|
17637
17665
|
this._triggerStateCallbacks("close", event);
|
|
17638
17666
|
}
|
|
@@ -17780,8 +17808,8 @@ Option 2: Install and provide the "ws" package:
|
|
|
17780
17808
|
* @internal
|
|
17781
17809
|
*/
|
|
17782
17810
|
_initializeOptions(options) {
|
|
17783
|
-
var
|
|
17784
|
-
this.transport = (
|
|
17811
|
+
var _a25, _b3, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
17812
|
+
this.transport = (_a25 = options === null || options === void 0 ? void 0 : options.transport) !== null && _a25 !== void 0 ? _a25 : null;
|
|
17785
17813
|
this.timeout = (_b3 = options === null || options === void 0 ? void 0 : options.timeout) !== null && _b3 !== void 0 ? _b3 : DEFAULT_TIMEOUT;
|
|
17786
17814
|
this.heartbeatIntervalMs = (_c = options === null || options === void 0 ? void 0 : options.heartbeatIntervalMs) !== null && _c !== void 0 ? _c : CONNECTION_TIMEOUTS.HEARTBEAT_INTERVAL;
|
|
17787
17815
|
this.worker = (_d = options === null || options === void 0 ? void 0 : options.worker) !== null && _d !== void 0 ? _d : false;
|
|
@@ -17827,14 +17855,14 @@ Option 2: Install and provide the "ws" package:
|
|
|
17827
17855
|
// node_modules/.pnpm/iceberg-js@0.8.1/node_modules/iceberg-js/dist/index.mjs
|
|
17828
17856
|
var IcebergError = class extends Error {
|
|
17829
17857
|
constructor(message, opts) {
|
|
17830
|
-
var
|
|
17858
|
+
var _a25;
|
|
17831
17859
|
super(message);
|
|
17832
17860
|
this.name = "IcebergError";
|
|
17833
17861
|
this.status = opts.status;
|
|
17834
17862
|
this.icebergType = opts.icebergType;
|
|
17835
17863
|
this.icebergCode = opts.icebergCode;
|
|
17836
17864
|
this.details = opts.details;
|
|
17837
|
-
this.isCommitStateUnknown = opts.icebergType === "CommitStateUnknownException" || [500, 502, 504].includes(opts.status) && ((
|
|
17865
|
+
this.isCommitStateUnknown = opts.icebergType === "CommitStateUnknownException" || [500, 502, 504].includes(opts.status) && ((_a25 = opts.icebergType) == null ? void 0 : _a25.includes("CommitState")) === true;
|
|
17838
17866
|
}
|
|
17839
17867
|
/**
|
|
17840
17868
|
* Returns true if the error is a 404 Not Found error.
|
|
@@ -17882,8 +17910,8 @@ async function buildAuthHeaders(auth) {
|
|
|
17882
17910
|
return {};
|
|
17883
17911
|
}
|
|
17884
17912
|
function createFetchClient(options) {
|
|
17885
|
-
var
|
|
17886
|
-
const fetchFn = (
|
|
17913
|
+
var _a25;
|
|
17914
|
+
const fetchFn = (_a25 = options.fetchImpl) != null ? _a25 : globalThis.fetch;
|
|
17887
17915
|
return {
|
|
17888
17916
|
async request({
|
|
17889
17917
|
method,
|
|
@@ -17892,7 +17920,7 @@ function createFetchClient(options) {
|
|
|
17892
17920
|
body,
|
|
17893
17921
|
headers
|
|
17894
17922
|
}) {
|
|
17895
|
-
var
|
|
17923
|
+
var _a26;
|
|
17896
17924
|
const url = buildUrl(options.baseUrl, path, query);
|
|
17897
17925
|
const authHeaders = await buildAuthHeaders(options.auth);
|
|
17898
17926
|
const res = await fetchFn(url, {
|
|
@@ -17911,7 +17939,7 @@ function createFetchClient(options) {
|
|
|
17911
17939
|
const errBody = isJson ? data : void 0;
|
|
17912
17940
|
const errorDetail = errBody == null ? void 0 : errBody.error;
|
|
17913
17941
|
throw new IcebergError(
|
|
17914
|
-
(
|
|
17942
|
+
(_a26 = errorDetail == null ? void 0 : errorDetail.message) != null ? _a26 : `Request failed with status ${res.status}`,
|
|
17915
17943
|
{
|
|
17916
17944
|
status: res.status,
|
|
17917
17945
|
icebergType: errorDetail == null ? void 0 : errorDetail.type,
|
|
@@ -18034,11 +18062,11 @@ var TableOperations = class {
|
|
|
18034
18062
|
};
|
|
18035
18063
|
}
|
|
18036
18064
|
async dropTable(id, options) {
|
|
18037
|
-
var
|
|
18065
|
+
var _a25;
|
|
18038
18066
|
await this.client.request({
|
|
18039
18067
|
method: "DELETE",
|
|
18040
18068
|
path: `${this.prefix}/namespaces/${namespaceToPath2(id.namespace)}/tables/${id.name}`,
|
|
18041
|
-
query: { purgeRequested: String((
|
|
18069
|
+
query: { purgeRequested: String((_a25 = options == null ? void 0 : options.purge) != null ? _a25 : false) }
|
|
18042
18070
|
});
|
|
18043
18071
|
}
|
|
18044
18072
|
async loadTable(id) {
|
|
@@ -18090,7 +18118,7 @@ var IcebergRestCatalog = class {
|
|
|
18090
18118
|
* @param options - Configuration options for the catalog client
|
|
18091
18119
|
*/
|
|
18092
18120
|
constructor(options) {
|
|
18093
|
-
var
|
|
18121
|
+
var _a25;
|
|
18094
18122
|
let prefix = "v1";
|
|
18095
18123
|
if (options.catalogName) {
|
|
18096
18124
|
prefix += `/${options.catalogName}`;
|
|
@@ -18101,7 +18129,7 @@ var IcebergRestCatalog = class {
|
|
|
18101
18129
|
auth: options.auth,
|
|
18102
18130
|
fetchImpl: options.fetch
|
|
18103
18131
|
});
|
|
18104
|
-
this.accessDelegation = (
|
|
18132
|
+
this.accessDelegation = (_a25 = options.accessDelegation) == null ? void 0 : _a25.join(",");
|
|
18105
18133
|
this.namespaceOps = new NamespaceOperations(this.client, prefix);
|
|
18106
18134
|
this.tableOps = new TableOperations(this.client, prefix, this.accessDelegation);
|
|
18107
18135
|
}
|
|
@@ -21074,7 +21102,7 @@ var getItemAsync = async (storage, key) => {
|
|
|
21074
21102
|
}
|
|
21075
21103
|
try {
|
|
21076
21104
|
return JSON.parse(value);
|
|
21077
|
-
} catch (
|
|
21105
|
+
} catch (_a25) {
|
|
21078
21106
|
return value;
|
|
21079
21107
|
}
|
|
21080
21108
|
};
|
|
@@ -21285,7 +21313,7 @@ function deepClone(obj) {
|
|
|
21285
21313
|
var _getErrorMessage2 = (err) => err.msg || err.message || err.error_description || err.error || JSON.stringify(err);
|
|
21286
21314
|
var NETWORK_ERROR_CODES = [502, 503, 504];
|
|
21287
21315
|
async function handleError2(error) {
|
|
21288
|
-
var
|
|
21316
|
+
var _a25;
|
|
21289
21317
|
if (!looksLikeFetchResponse(error)) {
|
|
21290
21318
|
throw new AuthRetryableFetchError(_getErrorMessage2(error), 0);
|
|
21291
21319
|
}
|
|
@@ -21310,7 +21338,7 @@ async function handleError2(error) {
|
|
|
21310
21338
|
throw new AuthWeakPasswordError(_getErrorMessage2(data), error.status, data.weak_password.reasons);
|
|
21311
21339
|
}
|
|
21312
21340
|
} else if (errorCode === "weak_password") {
|
|
21313
|
-
throw new AuthWeakPasswordError(_getErrorMessage2(data), error.status, ((
|
|
21341
|
+
throw new AuthWeakPasswordError(_getErrorMessage2(data), error.status, ((_a25 = data.weak_password) === null || _a25 === void 0 ? void 0 : _a25.reasons) || []);
|
|
21314
21342
|
} else if (errorCode === "session_not_found") {
|
|
21315
21343
|
throw new AuthSessionMissingError();
|
|
21316
21344
|
}
|
|
@@ -21326,7 +21354,7 @@ var _getRequestParams2 = (method, options, parameters, body) => {
|
|
|
21326
21354
|
return Object.assign(Object.assign({}, params), parameters);
|
|
21327
21355
|
};
|
|
21328
21356
|
async function _request(fetcher, method, url, options) {
|
|
21329
|
-
var
|
|
21357
|
+
var _a25;
|
|
21330
21358
|
const headers = Object.assign({}, options === null || options === void 0 ? void 0 : options.headers);
|
|
21331
21359
|
if (!headers[API_VERSION_HEADER_NAME]) {
|
|
21332
21360
|
headers[API_VERSION_HEADER_NAME] = API_VERSIONS["2024-01-01"].name;
|
|
@@ -21334,7 +21362,7 @@ async function _request(fetcher, method, url, options) {
|
|
|
21334
21362
|
if (options === null || options === void 0 ? void 0 : options.jwt) {
|
|
21335
21363
|
headers["Authorization"] = `Bearer ${options.jwt}`;
|
|
21336
21364
|
}
|
|
21337
|
-
const qs = (
|
|
21365
|
+
const qs = (_a25 = options === null || options === void 0 ? void 0 : options.query) !== null && _a25 !== void 0 ? _a25 : {};
|
|
21338
21366
|
if (options === null || options === void 0 ? void 0 : options.redirectTo) {
|
|
21339
21367
|
qs["redirect_to"] = options.redirectTo;
|
|
21340
21368
|
}
|
|
@@ -21367,7 +21395,7 @@ async function _handleRequest2(fetcher, method, url, options, parameters, body)
|
|
|
21367
21395
|
}
|
|
21368
21396
|
}
|
|
21369
21397
|
function _sessionResponse(data) {
|
|
21370
|
-
var
|
|
21398
|
+
var _a25;
|
|
21371
21399
|
let session = null;
|
|
21372
21400
|
if (hasSession(data)) {
|
|
21373
21401
|
session = Object.assign({}, data);
|
|
@@ -21375,7 +21403,7 @@ function _sessionResponse(data) {
|
|
|
21375
21403
|
session.expires_at = expiresAt(data.expires_in);
|
|
21376
21404
|
}
|
|
21377
21405
|
}
|
|
21378
|
-
const user = (
|
|
21406
|
+
const user = (_a25 = data.user) !== null && _a25 !== void 0 ? _a25 : data;
|
|
21379
21407
|
return { data: { session, user }, error: null };
|
|
21380
21408
|
}
|
|
21381
21409
|
function _sessionResponsePassword(data) {
|
|
@@ -21386,8 +21414,8 @@ function _sessionResponsePassword(data) {
|
|
|
21386
21414
|
return response;
|
|
21387
21415
|
}
|
|
21388
21416
|
function _userResponse(data) {
|
|
21389
|
-
var
|
|
21390
|
-
const user = (
|
|
21417
|
+
var _a25;
|
|
21418
|
+
const user = (_a25 = data.user) !== null && _a25 !== void 0 ? _a25 : data;
|
|
21391
21419
|
return { data: { user }, error: null };
|
|
21392
21420
|
}
|
|
21393
21421
|
function _ssoResponse(data) {
|
|
@@ -21556,14 +21584,14 @@ var GoTrueAdminApi = class {
|
|
|
21556
21584
|
* @param params An object which supports `page` and `perPage` as numbers, to alter the paginated results.
|
|
21557
21585
|
*/
|
|
21558
21586
|
async listUsers(params) {
|
|
21559
|
-
var
|
|
21587
|
+
var _a25, _b3, _c, _d, _e, _f, _g;
|
|
21560
21588
|
try {
|
|
21561
21589
|
const pagination = { nextPage: null, lastPage: 0, total: 0 };
|
|
21562
21590
|
const response = await _request(this.fetch, "GET", `${this.url}/admin/users`, {
|
|
21563
21591
|
headers: this.headers,
|
|
21564
21592
|
noResolveJson: true,
|
|
21565
21593
|
query: {
|
|
21566
|
-
page: (_b3 = (
|
|
21594
|
+
page: (_b3 = (_a25 = params === null || params === void 0 ? void 0 : params.page) === null || _a25 === void 0 ? void 0 : _a25.toString()) !== null && _b3 !== void 0 ? _b3 : "",
|
|
21567
21595
|
per_page: (_d = (_c = params === null || params === void 0 ? void 0 : params.perPage) === null || _c === void 0 ? void 0 : _c.toString()) !== null && _d !== void 0 ? _d : ""
|
|
21568
21596
|
},
|
|
21569
21597
|
xform: _noResolveJsonResponse
|
|
@@ -21697,14 +21725,14 @@ var GoTrueAdminApi = class {
|
|
|
21697
21725
|
* This function should only be called on a server. Never expose your `service_role` key in the browser.
|
|
21698
21726
|
*/
|
|
21699
21727
|
async _listOAuthClients(params) {
|
|
21700
|
-
var
|
|
21728
|
+
var _a25, _b3, _c, _d, _e, _f, _g;
|
|
21701
21729
|
try {
|
|
21702
21730
|
const pagination = { nextPage: null, lastPage: 0, total: 0 };
|
|
21703
21731
|
const response = await _request(this.fetch, "GET", `${this.url}/admin/oauth/clients`, {
|
|
21704
21732
|
headers: this.headers,
|
|
21705
21733
|
noResolveJson: true,
|
|
21706
21734
|
query: {
|
|
21707
|
-
page: (_b3 = (
|
|
21735
|
+
page: (_b3 = (_a25 = params === null || params === void 0 ? void 0 : params.page) === null || _a25 === void 0 ? void 0 : _a25.toString()) !== null && _b3 !== void 0 ? _b3 : "",
|
|
21708
21736
|
per_page: (_d = (_c = params === null || params === void 0 ? void 0 : params.perPage) === null || _c === void 0 ? void 0 : _c.toString()) !== null && _d !== void 0 ? _d : ""
|
|
21709
21737
|
},
|
|
21710
21738
|
xform: _noResolveJsonResponse
|
|
@@ -21957,7 +21985,7 @@ function toHex(value) {
|
|
|
21957
21985
|
return "0x" + hex;
|
|
21958
21986
|
}
|
|
21959
21987
|
function createSiweMessage(parameters) {
|
|
21960
|
-
var
|
|
21988
|
+
var _a25;
|
|
21961
21989
|
const { chainId, domain, expirationTime, issuedAt = /* @__PURE__ */ new Date(), nonce, notBefore, requestId, resources, scheme, uri, version: version5 } = parameters;
|
|
21962
21990
|
{
|
|
21963
21991
|
if (!Number.isInteger(chainId))
|
|
@@ -21970,7 +21998,7 @@ function createSiweMessage(parameters) {
|
|
|
21970
21998
|
throw new Error(`@supabase/auth-js: Invalid SIWE message field "uri". URI must be provided.`);
|
|
21971
21999
|
if (version5 !== "1")
|
|
21972
22000
|
throw new Error(`@supabase/auth-js: Invalid SIWE message field "version". Version must be '1'. Provided value: ${version5}`);
|
|
21973
|
-
if ((
|
|
22001
|
+
if ((_a25 = parameters.statement) === null || _a25 === void 0 ? void 0 : _a25.includes("\n"))
|
|
21974
22002
|
throw new Error(`@supabase/auth-js: Invalid SIWE message field "statement". Statement must not include '\\n'. Provided value: ${parameters.statement}`);
|
|
21975
22003
|
}
|
|
21976
22004
|
const address = getAddress(parameters.address);
|
|
@@ -22012,10 +22040,10 @@ ${suffix}`;
|
|
|
22012
22040
|
// node_modules/.pnpm/@supabase+auth-js@2.95.1/node_modules/@supabase/auth-js/dist/module/lib/webauthn.errors.js
|
|
22013
22041
|
var WebAuthnError = class extends Error {
|
|
22014
22042
|
constructor({ message, code, cause, name }) {
|
|
22015
|
-
var
|
|
22043
|
+
var _a25;
|
|
22016
22044
|
super(message, { cause });
|
|
22017
22045
|
this.__isWebAuthnError = true;
|
|
22018
|
-
this.name = (
|
|
22046
|
+
this.name = (_a25 = name !== null && name !== void 0 ? name : cause instanceof Error ? cause.name : void 0) !== null && _a25 !== void 0 ? _a25 : "Unknown Error";
|
|
22019
22047
|
this.code = code;
|
|
22020
22048
|
}
|
|
22021
22049
|
};
|
|
@@ -22031,7 +22059,7 @@ var WebAuthnUnknownError = class extends WebAuthnError {
|
|
|
22031
22059
|
}
|
|
22032
22060
|
};
|
|
22033
22061
|
function identifyRegistrationError({ error, options }) {
|
|
22034
|
-
var
|
|
22062
|
+
var _a25, _b3, _c;
|
|
22035
22063
|
const { publicKey } = options;
|
|
22036
22064
|
if (!publicKey) {
|
|
22037
22065
|
throw Error("options was missing required publicKey property");
|
|
@@ -22045,7 +22073,7 @@ function identifyRegistrationError({ error, options }) {
|
|
|
22045
22073
|
});
|
|
22046
22074
|
}
|
|
22047
22075
|
} else if (error.name === "ConstraintError") {
|
|
22048
|
-
if (((
|
|
22076
|
+
if (((_a25 = publicKey.authenticatorSelection) === null || _a25 === void 0 ? void 0 : _a25.requireResidentKey) === true) {
|
|
22049
22077
|
return new WebAuthnError({
|
|
22050
22078
|
message: "Discoverable credentials were required but no available authenticator supported it",
|
|
22051
22079
|
code: "ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",
|
|
@@ -22274,7 +22302,7 @@ function deserializeCredentialRequestOptions(options) {
|
|
|
22274
22302
|
return result;
|
|
22275
22303
|
}
|
|
22276
22304
|
function serializeCredentialCreationResponse(credential) {
|
|
22277
|
-
var
|
|
22305
|
+
var _a25;
|
|
22278
22306
|
if ("toJSON" in credential && typeof credential.toJSON === "function") {
|
|
22279
22307
|
return credential.toJSON();
|
|
22280
22308
|
}
|
|
@@ -22289,11 +22317,11 @@ function serializeCredentialCreationResponse(credential) {
|
|
|
22289
22317
|
type: "public-key",
|
|
22290
22318
|
clientExtensionResults: credential.getClientExtensionResults(),
|
|
22291
22319
|
// Convert null to undefined and cast to AuthenticatorAttachment type
|
|
22292
|
-
authenticatorAttachment: (
|
|
22320
|
+
authenticatorAttachment: (_a25 = credentialWithAttachment.authenticatorAttachment) !== null && _a25 !== void 0 ? _a25 : void 0
|
|
22293
22321
|
};
|
|
22294
22322
|
}
|
|
22295
22323
|
function serializeCredentialRequestResponse(credential) {
|
|
22296
|
-
var
|
|
22324
|
+
var _a25;
|
|
22297
22325
|
if ("toJSON" in credential && typeof credential.toJSON === "function") {
|
|
22298
22326
|
return credential.toJSON();
|
|
22299
22327
|
}
|
|
@@ -22313,7 +22341,7 @@ function serializeCredentialRequestResponse(credential) {
|
|
|
22313
22341
|
type: "public-key",
|
|
22314
22342
|
clientExtensionResults,
|
|
22315
22343
|
// Convert null to undefined and cast to AuthenticatorAttachment type
|
|
22316
|
-
authenticatorAttachment: (
|
|
22344
|
+
authenticatorAttachment: (_a25 = credentialWithAttachment.authenticatorAttachment) !== null && _a25 !== void 0 ? _a25 : void 0
|
|
22317
22345
|
};
|
|
22318
22346
|
}
|
|
22319
22347
|
function isValidDomain(hostname) {
|
|
@@ -22323,8 +22351,8 @@ function isValidDomain(hostname) {
|
|
|
22323
22351
|
);
|
|
22324
22352
|
}
|
|
22325
22353
|
function browserSupportsWebAuthn() {
|
|
22326
|
-
var
|
|
22327
|
-
return !!(isBrowser() && "PublicKeyCredential" in window && window.PublicKeyCredential && "credentials" in navigator && typeof ((
|
|
22354
|
+
var _a25, _b3;
|
|
22355
|
+
return !!(isBrowser() && "PublicKeyCredential" in window && window.PublicKeyCredential && "credentials" in navigator && typeof ((_a25 = navigator === null || navigator === void 0 ? void 0 : navigator.credentials) === null || _a25 === void 0 ? void 0 : _a25.create) === "function" && typeof ((_b3 = navigator === null || navigator === void 0 ? void 0 : navigator.credentials) === null || _b3 === void 0 ? void 0 : _b3.get) === "function");
|
|
22328
22356
|
}
|
|
22329
22357
|
async function createCredential(options) {
|
|
22330
22358
|
try {
|
|
@@ -22472,7 +22500,7 @@ var WebAuthnApi = class {
|
|
|
22472
22500
|
* @see {@link https://w3c.github.io/webauthn/#sctn-verifying-assertion W3C WebAuthn Spec - Verifying Assertion}
|
|
22473
22501
|
*/
|
|
22474
22502
|
async _challenge({ factorId, webauthn, friendlyName, signal }, overrides) {
|
|
22475
|
-
var
|
|
22503
|
+
var _a25;
|
|
22476
22504
|
try {
|
|
22477
22505
|
const { data: challengeResponse, error: challengeError } = await this.client.mfa.challenge({
|
|
22478
22506
|
factorId,
|
|
@@ -22489,7 +22517,7 @@ var WebAuthnApi = class {
|
|
|
22489
22517
|
if (!nameToUse) {
|
|
22490
22518
|
const currentUser = await this.client.getUser();
|
|
22491
22519
|
const userData = currentUser.data.user;
|
|
22492
|
-
const fallbackName = ((
|
|
22520
|
+
const fallbackName = ((_a25 = userData === null || userData === void 0 ? void 0 : userData.user_metadata) === null || _a25 === void 0 ? void 0 : _a25.name) || (userData === null || userData === void 0 ? void 0 : userData.email) || (userData === null || userData === void 0 ? void 0 : userData.id) || "User";
|
|
22493
22521
|
user.name = `${user.id}:${fallbackName}`;
|
|
22494
22522
|
} else {
|
|
22495
22523
|
user.name = `${user.id}:${nameToUse}`;
|
|
@@ -22662,8 +22690,8 @@ var WebAuthnApi = class {
|
|
|
22662
22690
|
});
|
|
22663
22691
|
if (!factor) {
|
|
22664
22692
|
await this.client.mfa.listFactors().then((factors) => {
|
|
22665
|
-
var
|
|
22666
|
-
return (
|
|
22693
|
+
var _a25;
|
|
22694
|
+
return (_a25 = factors.data) === null || _a25 === void 0 ? void 0 : _a25.all.find((v) => v.factor_type === "webauthn" && v.friendly_name === friendlyName && v.status !== "unverified");
|
|
22667
22695
|
}).then((factor2) => factor2 ? this.client.mfa.unenroll({ factorId: factor2 === null || factor2 === void 0 ? void 0 : factor2.id }) : void 0);
|
|
22668
22696
|
return { data: null, error: enrollError };
|
|
22669
22697
|
}
|
|
@@ -22725,15 +22753,15 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
22725
22753
|
* The JWKS used for verifying asymmetric JWTs
|
|
22726
22754
|
*/
|
|
22727
22755
|
get jwks() {
|
|
22728
|
-
var
|
|
22729
|
-
return (_b3 = (
|
|
22756
|
+
var _a25, _b3;
|
|
22757
|
+
return (_b3 = (_a25 = GLOBAL_JWKS[this.storageKey]) === null || _a25 === void 0 ? void 0 : _a25.jwks) !== null && _b3 !== void 0 ? _b3 : { keys: [] };
|
|
22730
22758
|
}
|
|
22731
22759
|
set jwks(value) {
|
|
22732
22760
|
GLOBAL_JWKS[this.storageKey] = Object.assign(Object.assign({}, GLOBAL_JWKS[this.storageKey]), { jwks: value });
|
|
22733
22761
|
}
|
|
22734
22762
|
get jwks_cached_at() {
|
|
22735
|
-
var
|
|
22736
|
-
return (_b3 = (
|
|
22763
|
+
var _a25, _b3;
|
|
22764
|
+
return (_b3 = (_a25 = GLOBAL_JWKS[this.storageKey]) === null || _a25 === void 0 ? void 0 : _a25.cachedAt) !== null && _b3 !== void 0 ? _b3 : Number.MIN_SAFE_INTEGER;
|
|
22737
22765
|
}
|
|
22738
22766
|
set jwks_cached_at(value) {
|
|
22739
22767
|
GLOBAL_JWKS[this.storageKey] = Object.assign(Object.assign({}, GLOBAL_JWKS[this.storageKey]), { cachedAt: value });
|
|
@@ -22753,7 +22781,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
22753
22781
|
* ```
|
|
22754
22782
|
*/
|
|
22755
22783
|
constructor(options) {
|
|
22756
|
-
var
|
|
22784
|
+
var _a25, _b3, _c;
|
|
22757
22785
|
this.userStorage = null;
|
|
22758
22786
|
this.memoryStorage = null;
|
|
22759
22787
|
this.stateChangeEmitters = /* @__PURE__ */ new Map();
|
|
@@ -22771,7 +22799,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
22771
22799
|
this.logger = console.log;
|
|
22772
22800
|
const settings = Object.assign(Object.assign({}, DEFAULT_OPTIONS), options);
|
|
22773
22801
|
this.storageKey = settings.storageKey;
|
|
22774
|
-
this.instanceID = (
|
|
22802
|
+
this.instanceID = (_a25 = _GoTrueClient.nextInstanceID[this.storageKey]) !== null && _a25 !== void 0 ? _a25 : 0;
|
|
22775
22803
|
_GoTrueClient.nextInstanceID[this.storageKey] = this.instanceID + 1;
|
|
22776
22804
|
this.logDebugMessages = !!settings.debug;
|
|
22777
22805
|
if (typeof settings.debug === "function") {
|
|
@@ -22914,7 +22942,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
22914
22942
|
* the whole lifetime of the client
|
|
22915
22943
|
*/
|
|
22916
22944
|
async _initialize() {
|
|
22917
|
-
var
|
|
22945
|
+
var _a25;
|
|
22918
22946
|
try {
|
|
22919
22947
|
let params = {};
|
|
22920
22948
|
let callbackUrlType = "none";
|
|
@@ -22931,7 +22959,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
22931
22959
|
if (error) {
|
|
22932
22960
|
this._debug("#_initialize()", "error detecting session from URL", error);
|
|
22933
22961
|
if (isAuthImplicitGrantRedirectError(error)) {
|
|
22934
|
-
const errorCode = (
|
|
22962
|
+
const errorCode = (_a25 = error.details) === null || _a25 === void 0 ? void 0 : _a25.code;
|
|
22935
22963
|
if (errorCode === "identity_already_exists" || errorCode === "identity_not_found" || errorCode === "single_identity_not_deletable") {
|
|
22936
22964
|
return { error };
|
|
22937
22965
|
}
|
|
@@ -22970,12 +22998,12 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
22970
22998
|
* @returns A session where the is_anonymous claim in the access token JWT set to true
|
|
22971
22999
|
*/
|
|
22972
23000
|
async signInAnonymously(credentials) {
|
|
22973
|
-
var
|
|
23001
|
+
var _a25, _b3, _c;
|
|
22974
23002
|
try {
|
|
22975
23003
|
const res = await _request(this.fetch, "POST", `${this.url}/signup`, {
|
|
22976
23004
|
headers: this.headers,
|
|
22977
23005
|
body: {
|
|
22978
|
-
data: (_b3 = (
|
|
23006
|
+
data: (_b3 = (_a25 = credentials === null || credentials === void 0 ? void 0 : credentials.options) === null || _a25 === void 0 ? void 0 : _a25.data) !== null && _b3 !== void 0 ? _b3 : {},
|
|
22979
23007
|
gotrue_meta_security: { captcha_token: (_c = credentials === null || credentials === void 0 ? void 0 : credentials.options) === null || _c === void 0 ? void 0 : _c.captchaToken }
|
|
22980
23008
|
},
|
|
22981
23009
|
xform: _sessionResponse
|
|
@@ -23009,7 +23037,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
23009
23037
|
* @returns A user if the server has "autoconfirm" OFF
|
|
23010
23038
|
*/
|
|
23011
23039
|
async signUp(credentials) {
|
|
23012
|
-
var
|
|
23040
|
+
var _a25, _b3, _c;
|
|
23013
23041
|
try {
|
|
23014
23042
|
let res;
|
|
23015
23043
|
if ("email" in credentials) {
|
|
@@ -23026,7 +23054,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
23026
23054
|
body: {
|
|
23027
23055
|
email,
|
|
23028
23056
|
password,
|
|
23029
|
-
data: (
|
|
23057
|
+
data: (_a25 = options === null || options === void 0 ? void 0 : options.data) !== null && _a25 !== void 0 ? _a25 : {},
|
|
23030
23058
|
gotrue_meta_security: { captcha_token: options === null || options === void 0 ? void 0 : options.captchaToken },
|
|
23031
23059
|
code_challenge: codeChallenge,
|
|
23032
23060
|
code_challenge_method: codeChallengeMethod
|
|
@@ -23132,9 +23160,9 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
23132
23160
|
* This method supports the PKCE flow.
|
|
23133
23161
|
*/
|
|
23134
23162
|
async signInWithOAuth(credentials) {
|
|
23135
|
-
var
|
|
23163
|
+
var _a25, _b3, _c, _d;
|
|
23136
23164
|
return await this._handleProviderSignIn(credentials.provider, {
|
|
23137
|
-
redirectTo: (
|
|
23165
|
+
redirectTo: (_a25 = credentials.options) === null || _a25 === void 0 ? void 0 : _a25.redirectTo,
|
|
23138
23166
|
scopes: (_b3 = credentials.options) === null || _b3 === void 0 ? void 0 : _b3.scopes,
|
|
23139
23167
|
queryParams: (_c = credentials.options) === null || _c === void 0 ? void 0 : _c.queryParams,
|
|
23140
23168
|
skipBrowserRedirect: (_d = credentials.options) === null || _d === void 0 ? void 0 : _d.skipBrowserRedirect
|
|
@@ -23168,7 +23196,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
23168
23196
|
}
|
|
23169
23197
|
}
|
|
23170
23198
|
async signInWithEthereum(credentials) {
|
|
23171
|
-
var
|
|
23199
|
+
var _a25, _b3, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
23172
23200
|
let message;
|
|
23173
23201
|
let signature;
|
|
23174
23202
|
if ("message" in credentials) {
|
|
@@ -23192,7 +23220,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
23192
23220
|
throw new Error(`@supabase/auth-js: No compatible Ethereum wallet interface on the window object (window.ethereum) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'ethereum', wallet: resolvedUserWallet }) instead.`);
|
|
23193
23221
|
}
|
|
23194
23222
|
}
|
|
23195
|
-
const url = new URL((
|
|
23223
|
+
const url = new URL((_a25 = options === null || options === void 0 ? void 0 : options.url) !== null && _a25 !== void 0 ? _a25 : window.location.href);
|
|
23196
23224
|
const accounts = await resolvedWallet.request({
|
|
23197
23225
|
method: "eth_requestAccounts"
|
|
23198
23226
|
}).then((accs) => accs).catch(() => {
|
|
@@ -23259,7 +23287,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
23259
23287
|
}
|
|
23260
23288
|
}
|
|
23261
23289
|
async signInWithSolana(credentials) {
|
|
23262
|
-
var
|
|
23290
|
+
var _a25, _b3, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
23263
23291
|
let message;
|
|
23264
23292
|
let signature;
|
|
23265
23293
|
if ("message" in credentials) {
|
|
@@ -23283,7 +23311,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
23283
23311
|
throw new Error(`@supabase/auth-js: No compatible Solana wallet interface on the window object (window.solana) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'solana', wallet: resolvedUserWallet }) instead.`);
|
|
23284
23312
|
}
|
|
23285
23313
|
}
|
|
23286
|
-
const url = new URL((
|
|
23314
|
+
const url = new URL((_a25 = options === null || options === void 0 ? void 0 : options.url) !== null && _a25 !== void 0 ? _a25 : window.location.href);
|
|
23287
23315
|
if ("signIn" in resolvedWallet && resolvedWallet.signIn) {
|
|
23288
23316
|
const output = await resolvedWallet.signIn(Object.assign(Object.assign(Object.assign({ issuedAt: (/* @__PURE__ */ new Date()).toISOString() }, options === null || options === void 0 ? void 0 : options.signInWithSolana), {
|
|
23289
23317
|
// non-overridable properties
|
|
@@ -23455,7 +23483,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
23455
23483
|
* This method supports PKCE when an email is passed.
|
|
23456
23484
|
*/
|
|
23457
23485
|
async signInWithOtp(credentials) {
|
|
23458
|
-
var
|
|
23486
|
+
var _a25, _b3, _c, _d, _e;
|
|
23459
23487
|
try {
|
|
23460
23488
|
if ("email" in credentials) {
|
|
23461
23489
|
const { email, options } = credentials;
|
|
@@ -23469,7 +23497,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
23469
23497
|
headers: this.headers,
|
|
23470
23498
|
body: {
|
|
23471
23499
|
email,
|
|
23472
|
-
data: (
|
|
23500
|
+
data: (_a25 = options === null || options === void 0 ? void 0 : options.data) !== null && _a25 !== void 0 ? _a25 : {},
|
|
23473
23501
|
create_user: (_b3 = options === null || options === void 0 ? void 0 : options.shouldCreateUser) !== null && _b3 !== void 0 ? _b3 : true,
|
|
23474
23502
|
gotrue_meta_security: { captcha_token: options === null || options === void 0 ? void 0 : options.captchaToken },
|
|
23475
23503
|
code_challenge: codeChallenge,
|
|
@@ -23509,12 +23537,12 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
23509
23537
|
* Log in a user given a User supplied OTP or TokenHash received through mobile or email.
|
|
23510
23538
|
*/
|
|
23511
23539
|
async verifyOtp(params) {
|
|
23512
|
-
var
|
|
23540
|
+
var _a25, _b3;
|
|
23513
23541
|
try {
|
|
23514
23542
|
let redirectTo = void 0;
|
|
23515
23543
|
let captchaToken = void 0;
|
|
23516
23544
|
if ("options" in params) {
|
|
23517
|
-
redirectTo = (
|
|
23545
|
+
redirectTo = (_a25 = params.options) === null || _a25 === void 0 ? void 0 : _a25.redirectTo;
|
|
23518
23546
|
captchaToken = (_b3 = params.options) === null || _b3 === void 0 ? void 0 : _b3.captchaToken;
|
|
23519
23547
|
}
|
|
23520
23548
|
const { data, error } = await _request(this.fetch, "POST", `${this.url}/verify`, {
|
|
@@ -23559,7 +23587,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
23559
23587
|
* organization's SSO Identity Provider UUID directly instead.
|
|
23560
23588
|
*/
|
|
23561
23589
|
async signInWithSSO(params) {
|
|
23562
|
-
var
|
|
23590
|
+
var _a25, _b3, _c, _d, _e;
|
|
23563
23591
|
try {
|
|
23564
23592
|
let codeChallenge = null;
|
|
23565
23593
|
let codeChallengeMethod = null;
|
|
@@ -23568,7 +23596,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
23568
23596
|
[codeChallenge, codeChallengeMethod] = await getCodeChallengeAndMethod(this.storage, this.storageKey);
|
|
23569
23597
|
}
|
|
23570
23598
|
const result = await _request(this.fetch, "POST", `${this.url}/sso`, {
|
|
23571
|
-
body: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, "providerId" in params ? { provider_id: params.providerId } : null), "domain" in params ? { domain: params.domain } : null), { redirect_to: (_b3 = (
|
|
23599
|
+
body: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, "providerId" in params ? { provider_id: params.providerId } : null), "domain" in params ? { domain: params.domain } : null), { redirect_to: (_b3 = (_a25 = params.options) === null || _a25 === void 0 ? void 0 : _a25.redirectTo) !== null && _b3 !== void 0 ? _b3 : void 0 }), ((_c = params === null || params === void 0 ? void 0 : params.options) === null || _c === void 0 ? void 0 : _c.captchaToken) ? { gotrue_meta_security: { captcha_token: params.options.captchaToken } } : null), { skip_http_redirect: true, code_challenge: codeChallenge, code_challenge_method: codeChallengeMethod }),
|
|
23572
23600
|
headers: this.headers,
|
|
23573
23601
|
xform: _ssoResponse
|
|
23574
23602
|
});
|
|
@@ -23822,12 +23850,12 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
23822
23850
|
});
|
|
23823
23851
|
}
|
|
23824
23852
|
return await this._useSession(async (result) => {
|
|
23825
|
-
var
|
|
23853
|
+
var _a25, _b3, _c;
|
|
23826
23854
|
const { data, error } = result;
|
|
23827
23855
|
if (error) {
|
|
23828
23856
|
throw error;
|
|
23829
23857
|
}
|
|
23830
|
-
if (!((
|
|
23858
|
+
if (!((_a25 = data.session) === null || _a25 === void 0 ? void 0 : _a25.access_token) && !this.hasCustomAuthorizationHeader) {
|
|
23831
23859
|
return { data: { user: null }, error: new AuthSessionMissingError() };
|
|
23832
23860
|
}
|
|
23833
23861
|
return await _request(this.fetch, "GET", `${this.url}/user`, {
|
|
@@ -23969,13 +23997,13 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
23969
23997
|
async _refreshSession(currentSession) {
|
|
23970
23998
|
try {
|
|
23971
23999
|
return await this._useSession(async (result) => {
|
|
23972
|
-
var
|
|
24000
|
+
var _a25;
|
|
23973
24001
|
if (!currentSession) {
|
|
23974
24002
|
const { data, error: error2 } = result;
|
|
23975
24003
|
if (error2) {
|
|
23976
24004
|
throw error2;
|
|
23977
24005
|
}
|
|
23978
|
-
currentSession = (
|
|
24006
|
+
currentSession = (_a25 = data.session) !== null && _a25 !== void 0 ? _a25 : void 0;
|
|
23979
24007
|
}
|
|
23980
24008
|
if (!(currentSession === null || currentSession === void 0 ? void 0 : currentSession.refresh_token)) {
|
|
23981
24009
|
throw new AuthSessionMissingError();
|
|
@@ -24113,12 +24141,12 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
24113
24141
|
}
|
|
24114
24142
|
async _signOut({ scope } = { scope: "global" }) {
|
|
24115
24143
|
return await this._useSession(async (result) => {
|
|
24116
|
-
var
|
|
24144
|
+
var _a25;
|
|
24117
24145
|
const { data, error: sessionError } = result;
|
|
24118
24146
|
if (sessionError && !isAuthSessionMissingError(sessionError)) {
|
|
24119
24147
|
return this._returnResult({ error: sessionError });
|
|
24120
24148
|
}
|
|
24121
|
-
const accessToken = (
|
|
24149
|
+
const accessToken = (_a25 = data.session) === null || _a25 === void 0 ? void 0 : _a25.access_token;
|
|
24122
24150
|
if (accessToken) {
|
|
24123
24151
|
const { error } = await this.admin.signOut(accessToken, scope);
|
|
24124
24152
|
if (error) {
|
|
@@ -24156,12 +24184,12 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
24156
24184
|
}
|
|
24157
24185
|
async _emitInitialSession(id) {
|
|
24158
24186
|
return await this._useSession(async (result) => {
|
|
24159
|
-
var
|
|
24187
|
+
var _a25, _b3;
|
|
24160
24188
|
try {
|
|
24161
24189
|
const { data: { session }, error } = result;
|
|
24162
24190
|
if (error)
|
|
24163
24191
|
throw error;
|
|
24164
|
-
await ((
|
|
24192
|
+
await ((_a25 = this.stateChangeEmitters.get(id)) === null || _a25 === void 0 ? void 0 : _a25.callback("INITIAL_SESSION", session));
|
|
24165
24193
|
this._debug("INITIAL_SESSION", "callback id", id, "session", session);
|
|
24166
24194
|
} catch (err) {
|
|
24167
24195
|
await ((_b3 = this.stateChangeEmitters.get(id)) === null || _b3 === void 0 ? void 0 : _b3.callback("INITIAL_SESSION", null));
|
|
@@ -24212,12 +24240,12 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
24212
24240
|
* Gets all the identities linked to a user.
|
|
24213
24241
|
*/
|
|
24214
24242
|
async getUserIdentities() {
|
|
24215
|
-
var
|
|
24243
|
+
var _a25;
|
|
24216
24244
|
try {
|
|
24217
24245
|
const { data, error } = await this.getUser();
|
|
24218
24246
|
if (error)
|
|
24219
24247
|
throw error;
|
|
24220
|
-
return this._returnResult({ data: { identities: (
|
|
24248
|
+
return this._returnResult({ data: { identities: (_a25 = data.user.identities) !== null && _a25 !== void 0 ? _a25 : [] }, error: null });
|
|
24221
24249
|
} catch (error) {
|
|
24222
24250
|
if (isAuthError(error)) {
|
|
24223
24251
|
return this._returnResult({ data: null, error });
|
|
@@ -24232,15 +24260,15 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
24232
24260
|
return this.linkIdentityOAuth(credentials);
|
|
24233
24261
|
}
|
|
24234
24262
|
async linkIdentityOAuth(credentials) {
|
|
24235
|
-
var
|
|
24263
|
+
var _a25;
|
|
24236
24264
|
try {
|
|
24237
24265
|
const { data, error } = await this._useSession(async (result) => {
|
|
24238
|
-
var
|
|
24266
|
+
var _a26, _b3, _c, _d, _e;
|
|
24239
24267
|
const { data: data2, error: error2 } = result;
|
|
24240
24268
|
if (error2)
|
|
24241
24269
|
throw error2;
|
|
24242
24270
|
const url = await this._getUrlForProvider(`${this.url}/user/identities/authorize`, credentials.provider, {
|
|
24243
|
-
redirectTo: (
|
|
24271
|
+
redirectTo: (_a26 = credentials.options) === null || _a26 === void 0 ? void 0 : _a26.redirectTo,
|
|
24244
24272
|
scopes: (_b3 = credentials.options) === null || _b3 === void 0 ? void 0 : _b3.scopes,
|
|
24245
24273
|
queryParams: (_c = credentials.options) === null || _c === void 0 ? void 0 : _c.queryParams,
|
|
24246
24274
|
skipBrowserRedirect: true
|
|
@@ -24252,7 +24280,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
24252
24280
|
});
|
|
24253
24281
|
if (error)
|
|
24254
24282
|
throw error;
|
|
24255
|
-
if (isBrowser() && !((
|
|
24283
|
+
if (isBrowser() && !((_a25 = credentials.options) === null || _a25 === void 0 ? void 0 : _a25.skipBrowserRedirect)) {
|
|
24256
24284
|
window.location.assign(data === null || data === void 0 ? void 0 : data.url);
|
|
24257
24285
|
}
|
|
24258
24286
|
return this._returnResult({
|
|
@@ -24268,7 +24296,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
24268
24296
|
}
|
|
24269
24297
|
async linkIdentityIdToken(credentials) {
|
|
24270
24298
|
return await this._useSession(async (result) => {
|
|
24271
|
-
var
|
|
24299
|
+
var _a25;
|
|
24272
24300
|
try {
|
|
24273
24301
|
const { error: sessionError, data: { session } } = result;
|
|
24274
24302
|
if (sessionError)
|
|
@@ -24276,7 +24304,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
24276
24304
|
const { options, provider, token, access_token, nonce } = credentials;
|
|
24277
24305
|
const res = await _request(this.fetch, "POST", `${this.url}/token?grant_type=id_token`, {
|
|
24278
24306
|
headers: this.headers,
|
|
24279
|
-
jwt: (
|
|
24307
|
+
jwt: (_a25 = session === null || session === void 0 ? void 0 : session.access_token) !== null && _a25 !== void 0 ? _a25 : void 0,
|
|
24280
24308
|
body: {
|
|
24281
24309
|
provider,
|
|
24282
24310
|
id_token: token,
|
|
@@ -24316,14 +24344,14 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
24316
24344
|
async unlinkIdentity(identity) {
|
|
24317
24345
|
try {
|
|
24318
24346
|
return await this._useSession(async (result) => {
|
|
24319
|
-
var
|
|
24347
|
+
var _a25, _b3;
|
|
24320
24348
|
const { data, error } = result;
|
|
24321
24349
|
if (error) {
|
|
24322
24350
|
throw error;
|
|
24323
24351
|
}
|
|
24324
24352
|
return await _request(this.fetch, "DELETE", `${this.url}/user/identities/${identity.identity_id}`, {
|
|
24325
24353
|
headers: this.headers,
|
|
24326
|
-
jwt: (_b3 = (
|
|
24354
|
+
jwt: (_b3 = (_a25 = data.session) === null || _a25 === void 0 ? void 0 : _a25.access_token) !== null && _b3 !== void 0 ? _b3 : void 0
|
|
24327
24355
|
});
|
|
24328
24356
|
});
|
|
24329
24357
|
} catch (error) {
|
|
@@ -24388,7 +24416,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
24388
24416
|
* Note: this method is async to accommodate for AsyncStorage e.g. in React native.
|
|
24389
24417
|
*/
|
|
24390
24418
|
async _recoverAndRefresh() {
|
|
24391
|
-
var
|
|
24419
|
+
var _a25, _b3;
|
|
24392
24420
|
const debugName = "#_recoverAndRefresh()";
|
|
24393
24421
|
this._debug(debugName, "begin");
|
|
24394
24422
|
try {
|
|
@@ -24399,7 +24427,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
24399
24427
|
maybeUser = { user: currentSession.user };
|
|
24400
24428
|
await setItemAsync(this.userStorage, this.storageKey + "-user", maybeUser);
|
|
24401
24429
|
}
|
|
24402
|
-
currentSession.user = (
|
|
24430
|
+
currentSession.user = (_a25 = maybeUser === null || maybeUser === void 0 ? void 0 : maybeUser.user) !== null && _a25 !== void 0 ? _a25 : userNotAvailableProxy();
|
|
24403
24431
|
} else if (currentSession && !currentSession.user) {
|
|
24404
24432
|
if (!currentSession.user) {
|
|
24405
24433
|
const separateUser = await getItemAsync(this.storage, this.storageKey + "-user");
|
|
@@ -24459,7 +24487,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
24459
24487
|
}
|
|
24460
24488
|
}
|
|
24461
24489
|
async _callRefreshToken(refreshToken) {
|
|
24462
|
-
var
|
|
24490
|
+
var _a25, _b3;
|
|
24463
24491
|
if (!refreshToken) {
|
|
24464
24492
|
throw new AuthSessionMissingError();
|
|
24465
24493
|
}
|
|
@@ -24487,7 +24515,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
24487
24515
|
if (!isAuthRetryableFetchError(error)) {
|
|
24488
24516
|
await this._removeSession();
|
|
24489
24517
|
}
|
|
24490
|
-
(
|
|
24518
|
+
(_a25 = this.refreshingDeferred) === null || _a25 === void 0 ? void 0 : _a25.resolve(result);
|
|
24491
24519
|
return result;
|
|
24492
24520
|
}
|
|
24493
24521
|
(_b3 = this.refreshingDeferred) === null || _b3 === void 0 ? void 0 : _b3.reject(error);
|
|
@@ -24782,14 +24810,14 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
24782
24810
|
async _unenroll(params) {
|
|
24783
24811
|
try {
|
|
24784
24812
|
return await this._useSession(async (result) => {
|
|
24785
|
-
var
|
|
24813
|
+
var _a25;
|
|
24786
24814
|
const { data: sessionData, error: sessionError } = result;
|
|
24787
24815
|
if (sessionError) {
|
|
24788
24816
|
return this._returnResult({ data: null, error: sessionError });
|
|
24789
24817
|
}
|
|
24790
24818
|
return await _request(this.fetch, "DELETE", `${this.url}/factors/${params.factorId}`, {
|
|
24791
24819
|
headers: this.headers,
|
|
24792
|
-
jwt: (
|
|
24820
|
+
jwt: (_a25 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a25 === void 0 ? void 0 : _a25.access_token
|
|
24793
24821
|
});
|
|
24794
24822
|
});
|
|
24795
24823
|
} catch (error) {
|
|
@@ -24802,7 +24830,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
24802
24830
|
async _enroll(params) {
|
|
24803
24831
|
try {
|
|
24804
24832
|
return await this._useSession(async (result) => {
|
|
24805
|
-
var
|
|
24833
|
+
var _a25, _b3;
|
|
24806
24834
|
const { data: sessionData, error: sessionError } = result;
|
|
24807
24835
|
if (sessionError) {
|
|
24808
24836
|
return this._returnResult({ data: null, error: sessionError });
|
|
@@ -24811,7 +24839,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
24811
24839
|
const { data, error } = await _request(this.fetch, "POST", `${this.url}/factors`, {
|
|
24812
24840
|
body,
|
|
24813
24841
|
headers: this.headers,
|
|
24814
|
-
jwt: (
|
|
24842
|
+
jwt: (_a25 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a25 === void 0 ? void 0 : _a25.access_token
|
|
24815
24843
|
});
|
|
24816
24844
|
if (error) {
|
|
24817
24845
|
return this._returnResult({ data: null, error });
|
|
@@ -24832,7 +24860,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
24832
24860
|
return this._acquireLock(this.lockAcquireTimeout, async () => {
|
|
24833
24861
|
try {
|
|
24834
24862
|
return await this._useSession(async (result) => {
|
|
24835
|
-
var
|
|
24863
|
+
var _a25;
|
|
24836
24864
|
const { data: sessionData, error: sessionError } = result;
|
|
24837
24865
|
if (sessionError) {
|
|
24838
24866
|
return this._returnResult({ data: null, error: sessionError });
|
|
@@ -24843,7 +24871,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
24843
24871
|
const { data, error } = await _request(this.fetch, "POST", `${this.url}/factors/${params.factorId}/verify`, {
|
|
24844
24872
|
body,
|
|
24845
24873
|
headers: this.headers,
|
|
24846
|
-
jwt: (
|
|
24874
|
+
jwt: (_a25 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a25 === void 0 ? void 0 : _a25.access_token
|
|
24847
24875
|
});
|
|
24848
24876
|
if (error) {
|
|
24849
24877
|
return this._returnResult({ data: null, error });
|
|
@@ -24864,7 +24892,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
24864
24892
|
return this._acquireLock(this.lockAcquireTimeout, async () => {
|
|
24865
24893
|
try {
|
|
24866
24894
|
return await this._useSession(async (result) => {
|
|
24867
|
-
var
|
|
24895
|
+
var _a25;
|
|
24868
24896
|
const { data: sessionData, error: sessionError } = result;
|
|
24869
24897
|
if (sessionError) {
|
|
24870
24898
|
return this._returnResult({ data: null, error: sessionError });
|
|
@@ -24872,7 +24900,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
24872
24900
|
const response = await _request(this.fetch, "POST", `${this.url}/factors/${params.factorId}/challenge`, {
|
|
24873
24901
|
body: params,
|
|
24874
24902
|
headers: this.headers,
|
|
24875
|
-
jwt: (
|
|
24903
|
+
jwt: (_a25 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a25 === void 0 ? void 0 : _a25.access_token
|
|
24876
24904
|
});
|
|
24877
24905
|
if (response.error) {
|
|
24878
24906
|
return response;
|
|
@@ -24922,7 +24950,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
24922
24950
|
* {@see GoTrueMFAApi#listFactors}
|
|
24923
24951
|
*/
|
|
24924
24952
|
async _listFactors() {
|
|
24925
|
-
var
|
|
24953
|
+
var _a25;
|
|
24926
24954
|
const { data: { user }, error: userError } = await this.getUser();
|
|
24927
24955
|
if (userError) {
|
|
24928
24956
|
return { data: null, error: userError };
|
|
@@ -24933,7 +24961,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
24933
24961
|
totp: [],
|
|
24934
24962
|
webauthn: []
|
|
24935
24963
|
};
|
|
24936
|
-
for (const factor of (
|
|
24964
|
+
for (const factor of (_a25 = user === null || user === void 0 ? void 0 : user.factors) !== null && _a25 !== void 0 ? _a25 : []) {
|
|
24937
24965
|
data.all.push(factor);
|
|
24938
24966
|
if (factor.status === "verified") {
|
|
24939
24967
|
;
|
|
@@ -24949,7 +24977,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
24949
24977
|
* {@see GoTrueMFAApi#getAuthenticatorAssuranceLevel}
|
|
24950
24978
|
*/
|
|
24951
24979
|
async _getAuthenticatorAssuranceLevel(jwt) {
|
|
24952
|
-
var
|
|
24980
|
+
var _a25, _b3, _c, _d;
|
|
24953
24981
|
if (jwt) {
|
|
24954
24982
|
try {
|
|
24955
24983
|
const { payload: payload2 } = decodeJWT(jwt);
|
|
@@ -24962,7 +24990,7 @@ var GoTrueClient = class _GoTrueClient {
|
|
|
24962
24990
|
if (userError) {
|
|
24963
24991
|
return this._returnResult({ data: null, error: userError });
|
|
24964
24992
|
}
|
|
24965
|
-
const verifiedFactors2 = (_b3 = (
|
|
24993
|
+
const verifiedFactors2 = (_b3 = (_a25 = user === null || user === void 0 ? void 0 : user.factors) === null || _a25 === void 0 ? void 0 : _a25.filter((factor) => factor.status === "verified")) !== null && _b3 !== void 0 ? _b3 : [];
|
|
24966
24994
|
if (verifiedFactors2.length > 0) {
|
|
24967
24995
|
nextLevel2 = "aal2";
|
|
24968
24996
|
}
|
|
@@ -25599,10 +25627,10 @@ if (shouldShowDeprecationWarning()) console.warn("\u26A0\uFE0F Node.js 18 and b
|
|
|
25599
25627
|
var cachedStargate = null;
|
|
25600
25628
|
var cachedPublic = null;
|
|
25601
25629
|
function getSupabase() {
|
|
25602
|
-
var
|
|
25630
|
+
var _a25;
|
|
25603
25631
|
if (cachedStargate) return cachedStargate;
|
|
25604
25632
|
const url = getRuntimeEnv("VITE_SUPABASE_URL");
|
|
25605
|
-
const anon = (
|
|
25633
|
+
const anon = (_a25 = getRuntimeEnv("VITE_SUPABASE_ANON_KEY")) != null ? _a25 : getRuntimeEnv("VITE_SUPABASE_PUBLISHABLE_KEY");
|
|
25606
25634
|
const schema = getRuntimeEnvOr("VITE_SUPABASE_SCHEMA", "public");
|
|
25607
25635
|
if (!url || !anon) {
|
|
25608
25636
|
return null;
|
|
@@ -25617,10 +25645,10 @@ function getSupabase() {
|
|
|
25617
25645
|
return cachedStargate;
|
|
25618
25646
|
}
|
|
25619
25647
|
function getSupabasePublic() {
|
|
25620
|
-
var
|
|
25648
|
+
var _a25;
|
|
25621
25649
|
if (cachedPublic) return cachedPublic;
|
|
25622
25650
|
const url = getRuntimeEnv("VITE_SUPABASE_URL");
|
|
25623
|
-
const anon = (
|
|
25651
|
+
const anon = (_a25 = getRuntimeEnv("VITE_SUPABASE_ANON_KEY")) != null ? _a25 : getRuntimeEnv("VITE_SUPABASE_PUBLISHABLE_KEY");
|
|
25624
25652
|
if (!url || !anon) {
|
|
25625
25653
|
return null;
|
|
25626
25654
|
}
|
|
@@ -25836,13 +25864,13 @@ var toTimestampMs = (value) => {
|
|
|
25836
25864
|
return Number.isNaN(parsed) ? void 0 : parsed;
|
|
25837
25865
|
};
|
|
25838
25866
|
var readStoredProfileAvatar = () => {
|
|
25839
|
-
var
|
|
25867
|
+
var _a25;
|
|
25840
25868
|
if (typeof window === "undefined") return void 0;
|
|
25841
25869
|
const raw = localStorage.getItem(STORAGE_KEYS.profileAvatar) || sessionStorage.getItem(STORAGE_KEYS.profileAvatar);
|
|
25842
25870
|
if (!raw) return void 0;
|
|
25843
25871
|
try {
|
|
25844
25872
|
const parsed = JSON.parse(raw);
|
|
25845
|
-
return (
|
|
25873
|
+
return (_a25 = toNonEmptyString(parsed.avatarUrl)) != null ? _a25 : toNonEmptyString(parsed.avatarId);
|
|
25846
25874
|
} catch (e) {
|
|
25847
25875
|
return toNonEmptyString(raw);
|
|
25848
25876
|
}
|
|
@@ -25873,8 +25901,8 @@ var readPresenceRow = (payload) => {
|
|
|
25873
25901
|
return null;
|
|
25874
25902
|
};
|
|
25875
25903
|
var isMissingColumnError = (error, column) => {
|
|
25876
|
-
var
|
|
25877
|
-
const message = ((
|
|
25904
|
+
var _a25;
|
|
25905
|
+
const message = ((_a25 = error == null ? void 0 : error.message) != null ? _a25 : "").toLowerCase();
|
|
25878
25906
|
const code = error == null ? void 0 : error.code;
|
|
25879
25907
|
const token = column.trim().toLowerCase();
|
|
25880
25908
|
if (!token) return false;
|
|
@@ -25896,8 +25924,8 @@ var readStoredPresence = () => {
|
|
|
25896
25924
|
return isUserPresenceStatus(stored) ? stored : DEFAULT_PRESENCE_STATUS;
|
|
25897
25925
|
};
|
|
25898
25926
|
var readStoredPresenceSource = () => {
|
|
25899
|
-
var
|
|
25900
|
-
const stored = (
|
|
25927
|
+
var _a25;
|
|
25928
|
+
const stored = (_a25 = sessionStorage.getItem(STORAGE_KEYS.presenceSource)) != null ? _a25 : localStorage.getItem(LOCAL_STORAGE_KEYS.presenceSource);
|
|
25901
25929
|
if (isPresenceSource(stored)) return stored;
|
|
25902
25930
|
return "auto";
|
|
25903
25931
|
};
|
|
@@ -25944,9 +25972,9 @@ var readClaimValue = (claims, keys) => {
|
|
|
25944
25972
|
return void 0;
|
|
25945
25973
|
};
|
|
25946
25974
|
var readClaimRole = (claims) => {
|
|
25947
|
-
var
|
|
25975
|
+
var _a25, _b3, _c;
|
|
25948
25976
|
if (!claims) return void 0;
|
|
25949
|
-
const roleClaim = (_c = (_b3 = (
|
|
25977
|
+
const roleClaim = (_c = (_b3 = (_a25 = claims.role) != null ? _a25 : claims.roles) != null ? _b3 : claims["https://cupcode.com/role"]) != null ? _c : claims["https://cupcode.com/roles"];
|
|
25950
25978
|
if (typeof roleClaim === "string") return toNonEmptyString(roleClaim);
|
|
25951
25979
|
if (Array.isArray(roleClaim)) {
|
|
25952
25980
|
return roleClaim.find((entry) => typeof entry === "string" && entry.trim() !== "");
|
|
@@ -25957,7 +25985,7 @@ var buildUserFromTokens = ({
|
|
|
25957
25985
|
idToken,
|
|
25958
25986
|
accessToken
|
|
25959
25987
|
}) => {
|
|
25960
|
-
var
|
|
25988
|
+
var _a25;
|
|
25961
25989
|
const idClaims = decodeJwt(idToken != null ? idToken : void 0);
|
|
25962
25990
|
const accessClaims = decodeJwt(accessToken != null ? accessToken : void 0);
|
|
25963
25991
|
if (!idClaims && !accessClaims) return null;
|
|
@@ -25984,7 +26012,7 @@ var buildUserFromTokens = ({
|
|
|
25984
26012
|
"id",
|
|
25985
26013
|
"sub"
|
|
25986
26014
|
]);
|
|
25987
|
-
const resolvedSub = (
|
|
26015
|
+
const resolvedSub = (_a25 = readFromClaims(["sub"])) != null ? _a25 : resolvedId;
|
|
25988
26016
|
const preferredUsername = readFromClaims([
|
|
25989
26017
|
"preferred_username",
|
|
25990
26018
|
"preferredUsername",
|
|
@@ -26063,11 +26091,11 @@ var AuthProvider = ({ children }) => {
|
|
|
26063
26091
|
}
|
|
26064
26092
|
}, []);
|
|
26065
26093
|
const resolvePresenceUserId = useCallback12(async (targetUser) => {
|
|
26066
|
-
var
|
|
26094
|
+
var _a25, _b3, _c, _d;
|
|
26067
26095
|
const sub = toNonEmptyString(targetUser == null ? void 0 : targetUser.sub);
|
|
26068
26096
|
const id = toNonEmptyString(targetUser == null ? void 0 : targetUser.id);
|
|
26069
26097
|
const userId = toNonEmptyString(targetUser == null ? void 0 : targetUser.userId);
|
|
26070
|
-
const email = (
|
|
26098
|
+
const email = (_a25 = toNonEmptyString(targetUser == null ? void 0 : targetUser.email)) == null ? void 0 : _a25.toLowerCase();
|
|
26071
26099
|
const identityKey = [sub != null ? sub : "", id != null ? id : "", userId != null ? userId : "", email != null ? email : ""].join("|");
|
|
26072
26100
|
if (resolvedPresenceIdentityKeyRef.current === identityKey && resolvedPresenceUserIdRef.current) {
|
|
26073
26101
|
return resolvedPresenceUserIdRef.current;
|
|
@@ -26102,9 +26130,9 @@ var AuthProvider = ({ children }) => {
|
|
|
26102
26130
|
}, []);
|
|
26103
26131
|
const syncPresenceFromRecord = useCallback12(
|
|
26104
26132
|
(rawRow) => {
|
|
26105
|
-
var
|
|
26133
|
+
var _a25, _b3, _c;
|
|
26106
26134
|
if (!rawRow) return;
|
|
26107
|
-
const statusValue = toNonEmptyString((
|
|
26135
|
+
const statusValue = toNonEmptyString((_a25 = rawRow[USER_PRESENCE_STATUS_COLUMN]) != null ? _a25 : rawRow.status);
|
|
26108
26136
|
if (!isUserPresenceStatus(statusValue)) return;
|
|
26109
26137
|
const sourceValue = normalizePresenceSource((_b3 = rawRow[USER_PRESENCE_SOURCE_COLUMN]) != null ? _b3 : rawRow.status_source);
|
|
26110
26138
|
const lastActiveTimestamp = toTimestampMs((_c = rawRow[USER_PRESENCE_LAST_ACTIVE_COLUMN]) != null ? _c : rawRow.last_active_at);
|
|
@@ -26180,8 +26208,8 @@ var AuthProvider = ({ children }) => {
|
|
|
26180
26208
|
);
|
|
26181
26209
|
const touchPresence = useCallback12(
|
|
26182
26210
|
async (options) => {
|
|
26183
|
-
var
|
|
26184
|
-
const targetUser = (
|
|
26211
|
+
var _a25;
|
|
26212
|
+
const targetUser = (_a25 = options == null ? void 0 : options.targetUser) != null ? _a25 : user;
|
|
26185
26213
|
const userId = await resolvePresenceUserId(targetUser);
|
|
26186
26214
|
if (!userId) return;
|
|
26187
26215
|
const now = Date.now();
|
|
@@ -26306,7 +26334,7 @@ var AuthProvider = ({ children }) => {
|
|
|
26306
26334
|
}, []);
|
|
26307
26335
|
const startAuthorization = useCallback12(
|
|
26308
26336
|
async (options) => {
|
|
26309
|
-
var
|
|
26337
|
+
var _a25, _b3;
|
|
26310
26338
|
const config = getAccountsConfig();
|
|
26311
26339
|
const { authUrl } = await resolveOidcEndpoints(config);
|
|
26312
26340
|
if (!authUrl) {
|
|
@@ -26316,7 +26344,7 @@ var AuthProvider = ({ children }) => {
|
|
|
26316
26344
|
const challenge = await generateCodeChallenge(verifier);
|
|
26317
26345
|
const state = generateState();
|
|
26318
26346
|
const nonce = generateNonce();
|
|
26319
|
-
const redirectTo = (
|
|
26347
|
+
const redirectTo = (_a25 = options == null ? void 0 : options.redirectTo) != null ? _a25 : window.location.pathname + window.location.search + window.location.hash;
|
|
26320
26348
|
const mode = (_b3 = options == null ? void 0 : options.mode) != null ? _b3 : "interactive";
|
|
26321
26349
|
if (mode === "interactive") {
|
|
26322
26350
|
clearLogoutIntent();
|
|
@@ -26351,14 +26379,14 @@ var AuthProvider = ({ children }) => {
|
|
|
26351
26379
|
useEffect28(() => {
|
|
26352
26380
|
let cancelled = false;
|
|
26353
26381
|
const initializeAuth = async () => {
|
|
26354
|
-
var
|
|
26382
|
+
var _a25;
|
|
26355
26383
|
const stored = readStoredToken();
|
|
26356
26384
|
const storedPresence = readStoredPresence();
|
|
26357
26385
|
setPresenceStatusState(storedPresence);
|
|
26358
26386
|
if (stored == null ? void 0 : stored.accessToken) {
|
|
26359
26387
|
if (cancelled) return;
|
|
26360
26388
|
const hydratedUser = buildUserFromTokens({
|
|
26361
|
-
idToken: (
|
|
26389
|
+
idToken: (_a25 = stored.idToken) != null ? _a25 : void 0,
|
|
26362
26390
|
accessToken: stored.accessToken
|
|
26363
26391
|
});
|
|
26364
26392
|
setAccessToken(stored.accessToken);
|
|
@@ -26394,13 +26422,13 @@ var AuthProvider = ({ children }) => {
|
|
|
26394
26422
|
};
|
|
26395
26423
|
}, [attemptSilentLogin]);
|
|
26396
26424
|
useEffect28(() => {
|
|
26397
|
-
var
|
|
26425
|
+
var _a25;
|
|
26398
26426
|
if (status !== "authenticated") return;
|
|
26399
26427
|
if (user) return;
|
|
26400
26428
|
const stored = readStoredToken();
|
|
26401
26429
|
if (!(stored == null ? void 0 : stored.accessToken)) return;
|
|
26402
26430
|
const hydratedUser = buildUserFromTokens({
|
|
26403
|
-
idToken: (
|
|
26431
|
+
idToken: (_a25 = stored.idToken) != null ? _a25 : void 0,
|
|
26404
26432
|
accessToken: stored.accessToken
|
|
26405
26433
|
});
|
|
26406
26434
|
if (!hydratedUser) return;
|
|
@@ -26446,9 +26474,9 @@ var AuthProvider = ({ children }) => {
|
|
|
26446
26474
|
table: USER_PRESENCE_TABLE
|
|
26447
26475
|
},
|
|
26448
26476
|
(payload) => {
|
|
26449
|
-
var
|
|
26477
|
+
var _a25, _b3;
|
|
26450
26478
|
const row = payload.new || payload.old;
|
|
26451
|
-
const rowUserId = toNonEmptyString((_b3 = (
|
|
26479
|
+
const rowUserId = toNonEmptyString((_b3 = (_a25 = row == null ? void 0 : row[USER_PRESENCE_USER_ID_COLUMN]) != null ? _a25 : row == null ? void 0 : row.user_id) != null ? _b3 : row == null ? void 0 : row.id);
|
|
26452
26480
|
if (!rowUserId || rowUserId !== currentUserId) return;
|
|
26453
26481
|
if (payload.eventType === "DELETE") {
|
|
26454
26482
|
storePresenceStatus("offline", "system");
|
|
@@ -26522,9 +26550,9 @@ var AuthProvider = ({ children }) => {
|
|
|
26522
26550
|
});
|
|
26523
26551
|
}, [startAuthorization]);
|
|
26524
26552
|
const completeLogin = useCallback12(async () => {
|
|
26525
|
-
var
|
|
26553
|
+
var _a25;
|
|
26526
26554
|
const params = new URLSearchParams(window.location.search);
|
|
26527
|
-
const redirectTo = (
|
|
26555
|
+
const redirectTo = (_a25 = sessionStorage.getItem(STORAGE_KEYS.redirect)) != null ? _a25 : "/";
|
|
26528
26556
|
const authMode = sessionStorage.getItem(STORAGE_KEYS.authMode);
|
|
26529
26557
|
const isSilentAuth = authMode === "silent";
|
|
26530
26558
|
const error = params.get("error");
|
|
@@ -26596,10 +26624,10 @@ var AuthProvider = ({ children }) => {
|
|
|
26596
26624
|
}
|
|
26597
26625
|
}, [clearAuthFlowState]);
|
|
26598
26626
|
const logout = useCallback12(async () => {
|
|
26599
|
-
var
|
|
26627
|
+
var _a25, _b3;
|
|
26600
26628
|
const config = getAccountsConfig();
|
|
26601
26629
|
const { logoutUrl } = await resolveOidcEndpoints(config);
|
|
26602
|
-
const idToken = (
|
|
26630
|
+
const idToken = (_a25 = sessionStorage.getItem(STORAGE_KEYS.idToken)) != null ? _a25 : void 0;
|
|
26603
26631
|
const refreshToken = (_b3 = sessionStorage.getItem(STORAGE_KEYS.refreshToken)) != null ? _b3 : void 0;
|
|
26604
26632
|
const currentUser = user;
|
|
26605
26633
|
await setPresenceNetworkStatus("offline", "system", currentUser);
|
|
@@ -26623,8 +26651,8 @@ var AuthProvider = ({ children }) => {
|
|
|
26623
26651
|
return refreshInFlightRef.current;
|
|
26624
26652
|
}
|
|
26625
26653
|
const run = (async () => {
|
|
26626
|
-
var
|
|
26627
|
-
const refreshToken = (
|
|
26654
|
+
var _a25, _b3, _c;
|
|
26655
|
+
const refreshToken = (_a25 = sessionStorage.getItem(STORAGE_KEYS.refreshToken)) == null ? void 0 : _a25.trim();
|
|
26628
26656
|
if (!refreshToken) {
|
|
26629
26657
|
throw new Error("Sess\xE3o expirada. Fa\xE7a login novamente.");
|
|
26630
26658
|
}
|
|
@@ -26657,11 +26685,11 @@ var AuthProvider = ({ children }) => {
|
|
|
26657
26685
|
}
|
|
26658
26686
|
}, []);
|
|
26659
26687
|
const getAccessToken = useCallback12(async () => {
|
|
26660
|
-
var
|
|
26688
|
+
var _a25;
|
|
26661
26689
|
const stored = readStoredToken();
|
|
26662
26690
|
if (stored == null ? void 0 : stored.accessToken) return stored.accessToken;
|
|
26663
26691
|
if (accessToken) return accessToken;
|
|
26664
|
-
const hasRefreshToken = Boolean((
|
|
26692
|
+
const hasRefreshToken = Boolean((_a25 = sessionStorage.getItem(STORAGE_KEYS.refreshToken)) == null ? void 0 : _a25.trim());
|
|
26665
26693
|
if (hasRefreshToken) {
|
|
26666
26694
|
return refreshAccessToken();
|
|
26667
26695
|
}
|
|
@@ -26701,65 +26729,6 @@ var useAuth = () => {
|
|
|
26701
26729
|
}
|
|
26702
26730
|
return ctx;
|
|
26703
26731
|
};
|
|
26704
|
-
|
|
26705
|
-
// src/lib/cupcodeRuntimeEnv.ts
|
|
26706
|
-
var import_meta2 = {};
|
|
26707
|
-
var TELESCUP_CDN_HOSTS2 = /* @__PURE__ */ new Set([
|
|
26708
|
-
"cdn.telescup.com.br",
|
|
26709
|
-
"telescup.cupcode.dev",
|
|
26710
|
-
"cdn.cupcode.com.br"
|
|
26711
|
-
]);
|
|
26712
|
-
var normalize = (value) => {
|
|
26713
|
-
if (value === null || typeof value === "undefined") return void 0;
|
|
26714
|
-
const normalized = String(value).trim();
|
|
26715
|
-
return normalized.length > 0 ? normalized : void 0;
|
|
26716
|
-
};
|
|
26717
|
-
var isTelescupCdnUrl2 = (value) => {
|
|
26718
|
-
if (!value) return false;
|
|
26719
|
-
try {
|
|
26720
|
-
return TELESCUP_CDN_HOSTS2.has(new URL(value).hostname);
|
|
26721
|
-
} catch (e) {
|
|
26722
|
-
return false;
|
|
26723
|
-
}
|
|
26724
|
-
};
|
|
26725
|
-
var deriveAppsApiBaseUrl = () => {
|
|
26726
|
-
const explicit = normalize(import_meta2.env.VITE_APPS_API_BASE_URL) || normalize(import_meta2.env.VITE_APPS_API_BASE);
|
|
26727
|
-
if (explicit) return explicit.replace(/\/+$/, "");
|
|
26728
|
-
return void 0;
|
|
26729
|
-
};
|
|
26730
|
-
var resolveTelescupFunctionsBase = (appsApiBaseUrl) => {
|
|
26731
|
-
const explicit = normalize(import_meta2.env.VITE_TELESCUP_BASE_URL);
|
|
26732
|
-
if (explicit && !isTelescupCdnUrl2(explicit)) {
|
|
26733
|
-
return explicit.replace(/\/+$/, "");
|
|
26734
|
-
}
|
|
26735
|
-
if (appsApiBaseUrl) {
|
|
26736
|
-
return `${appsApiBaseUrl}/api/telescup`;
|
|
26737
|
-
}
|
|
26738
|
-
return void 0;
|
|
26739
|
-
};
|
|
26740
|
-
var runtimeSupabaseUrl = normalize(import_meta2.env.VITE_SUPABASE_URL);
|
|
26741
|
-
var runtimeSupabaseAnonKey = normalize(import_meta2.env.VITE_SUPABASE_ANON_KEY) || normalize(import_meta2.env.VITE_SUPABASE_PUBLISHABLE_KEY);
|
|
26742
|
-
var runtimeSupabasePublishableKey = normalize(import_meta2.env.VITE_SUPABASE_PUBLISHABLE_KEY) || runtimeSupabaseAnonKey;
|
|
26743
|
-
var runtimeAppsApiBaseUrl = deriveAppsApiBaseUrl();
|
|
26744
|
-
var runtimeTelescupCdnBase = normalize(import_meta2.env.VITE_TELESCUP_CDN_BASE) || normalize(import_meta2.env.VITE_TELESCUP_API_BASE) || "https://cdn.telescup.com.br";
|
|
26745
|
-
var runtimeTelescupFunctionsBase = resolveTelescupFunctionsBase(runtimeAppsApiBaseUrl);
|
|
26746
|
-
var runtimeAccountsBaseUrl = normalize(import_meta2.env.VITE_ACCOUNTS_BASE_URL) || normalize(import_meta2.env.VITE_OIDC_ISSUER);
|
|
26747
|
-
var cupcodeRuntimeEnv = {
|
|
26748
|
-
VITE_SUPABASE_URL: runtimeSupabaseUrl,
|
|
26749
|
-
VITE_SUPABASE_ANON_KEY: runtimeSupabaseAnonKey,
|
|
26750
|
-
VITE_SUPABASE_PUBLISHABLE_KEY: runtimeSupabasePublishableKey,
|
|
26751
|
-
VITE_APPS_API_BASE_URL: runtimeAppsApiBaseUrl,
|
|
26752
|
-
VITE_APPS_API_BASE: runtimeAppsApiBaseUrl,
|
|
26753
|
-
VITE_TELESCUP_BASE_URL: runtimeTelescupFunctionsBase,
|
|
26754
|
-
VITE_TELESCUP_API_BASE: runtimeTelescupCdnBase,
|
|
26755
|
-
VITE_ACCOUNTS_BASE_URL: runtimeAccountsBaseUrl
|
|
26756
|
-
};
|
|
26757
|
-
var globalWithCupcodeEnv = globalThis;
|
|
26758
|
-
var _a25;
|
|
26759
|
-
globalWithCupcodeEnv.__CUPCODE_ENV__ = {
|
|
26760
|
-
...(_a25 = globalWithCupcodeEnv.__CUPCODE_ENV__) != null ? _a25 : {},
|
|
26761
|
-
...cupcodeRuntimeEnv
|
|
26762
|
-
};
|
|
26763
26732
|
export {
|
|
26764
26733
|
Accordion,
|
|
26765
26734
|
AccordionContent2 as AccordionContent,
|
|
@@ -27125,7 +27094,6 @@ export {
|
|
|
27125
27094
|
cn,
|
|
27126
27095
|
completeTelescupOidcCallback,
|
|
27127
27096
|
createTelescupClient,
|
|
27128
|
-
cupcodeRuntimeEnv,
|
|
27129
27097
|
decodeJwt,
|
|
27130
27098
|
defaultSidebarGroups,
|
|
27131
27099
|
ensureTelescupOidcToken,
|