@cupcodev/ui 1.2.53 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -374,6 +374,7 @@ __export(src_exports, {
374
374
  parseAssetId: () => parseAssetId,
375
375
  reducer: () => reducer,
376
376
  resolveOidcEndpoints: () => resolveOidcEndpoints,
377
+ resolveTelescupImageURL: () => resolveTelescupImageURL,
377
378
  responsiveSizeClasses: () => responsiveSizeClasses,
378
379
  setCupcodeRuntimeEnv: () => setCupcodeRuntimeEnv,
379
380
  sonnerToast: () => import_sonner.toast,
@@ -478,7 +479,7 @@ var AvatarFallback = React2.forwardRef(({ className, ...props }, ref) => /* @__P
478
479
  ref,
479
480
  className: cn(
480
481
  "flex h-full w-full items-center justify-center rounded-full",
481
- "bg-gradient-to-br from-cupcode-pink to-cupcode-purple",
482
+ "bg-gradient-to-br from-cupcode-hover to-cupcode-purple",
482
483
  "text-white font-semibold",
483
484
  className
484
485
  ),
@@ -593,7 +594,7 @@ var BackgroundRainbow = () => {
593
594
  will-change: transform;
594
595
  }
595
596
 
596
- /* usa tuas globais #ed1e79 e #951ddb com ~0.4 de opacidade */
597
+ /* usa tuas globais #ed1e79 e #7c5bbb com ~0.4 de opacidade */
597
598
  .cc-a {
598
599
  background: radial-gradient(circle at center,
599
600
  color-mix(in srgb, var(--color-one) 40%, transparent) 0%,
@@ -684,11 +685,11 @@ function BackgroundStars() {
684
685
  const palette = [
685
686
  "#ffffff",
686
687
  "#d7c8ff",
687
- "#951ddb",
688
+ "#7c5bbb",
688
689
  // roxo Cupcode
689
690
  "#b146ea",
690
- "#ed1e79",
691
- // magenta Cupcode
691
+ "#975ab6",
692
+ // hover tone Cupcode
692
693
  "#ff8ad1"
693
694
  ];
694
695
  const starSprite = document.createElement("canvas");
@@ -857,7 +858,7 @@ function BackgroundStars() {
857
858
  const halo3 = size * 10.8 * k;
858
859
  drawHalo(starsCtx, 0, 0, halo1, "rgba(251,88,235,0.65)");
859
860
  drawHalo(starsCtx, 0, 0, halo2, "rgba(237,30,121,0.58)");
860
- drawHalo(starsCtx, 0, 0, halo3, "rgba(149,29,219,0.52)");
861
+ drawHalo(starsCtx, 0, 0, halo3, "rgba(124,91,187,0.52)");
861
862
  const gp = size * (1.8 + glow);
862
863
  drawHalo(starsCtx, 0, 0, gp, "rgba(233,12,211,0.28)");
863
864
  if (s.isHighlight) {
@@ -906,12 +907,12 @@ function BackgroundStars() {
906
907
  ctx.globalAlpha = 0.2 + 0.8 * ease;
907
908
  drawHalo(ctx, 0, 0, 0.85, "rgba(255,255,255,1)");
908
909
  drawHalo(ctx, 0, 0, 8, "rgba(237,30,121,0.75)");
909
- drawHalo(ctx, 0, 0, 14, "rgba(149,29,219,0.6)");
910
+ drawHalo(ctx, 0, 0, 14, "rgba(124,91,187,0.6)");
910
911
  const tailLen = c.len;
911
912
  const grd = ctx.createLinearGradient(0, 0, -tailLen, 0);
912
913
  grd.addColorStop(0, "rgba(255,255,255,0.95)");
913
914
  grd.addColorStop(0.4, "rgba(237,30,121,0.75)");
914
- grd.addColorStop(0.75, "rgba(149,29,219,0.55)");
915
+ grd.addColorStop(0.75, "rgba(124,91,187,0.55)");
915
916
  grd.addColorStop(1, "rgba(0,0,0,0)");
916
917
  ctx.fillStyle = grd;
917
918
  ctx.fillRect(-tailLen, -1, tailLen, 2);
@@ -1013,7 +1014,7 @@ var import_lucide_react2 = require("lucide-react");
1013
1014
  var import_jsx_runtime7 = require("react/jsx-runtime");
1014
1015
  var variantStyles = {
1015
1016
  default: "bg-muted text-cupcode-ink border-border dark:text-white dark:bg-cupcode-ink/40",
1016
- primary: "bg-gradient-to-r from-cupcode-pink to-cupcode-purple text-white border-transparent",
1017
+ primary: "bg-gradient-to-r from-cupcode-hover to-cupcode-purple text-white border-transparent",
1017
1018
  secondary: "bg-cupcode-purple/10 text-cupcode-purple border-cupcode-purple/20",
1018
1019
  outline: "bg-transparent text-cupcode-ink border-cupcode-purple dark:text-cupcode-purple"
1019
1020
  };
@@ -1099,10 +1100,10 @@ var Dock = ({ items, className }) => {
1099
1100
  const itemsRef = (0, import_react5.useRef)([]);
1100
1101
  const OVERSHOOT = 5;
1101
1102
  (0, import_react5.useEffect)(() => {
1102
- var _a65;
1103
+ var _a72;
1103
1104
  const activeItem = itemsRef.current[activeIndex];
1104
1105
  if (!activeItem) return;
1105
- const containerRect = (_a65 = activeItem.parentElement) == null ? void 0 : _a65.getBoundingClientRect();
1106
+ const containerRect = (_a72 = activeItem.parentElement) == null ? void 0 : _a72.getBoundingClientRect();
1106
1107
  const itemRect = activeItem.getBoundingClientRect();
1107
1108
  if (!containerRect) return;
1108
1109
  const relativeLeft = itemRect.left - containerRect.left;
@@ -1164,9 +1165,9 @@ var Dock = ({ items, className }) => {
1164
1165
  "button",
1165
1166
  {
1166
1167
  onClick: () => {
1167
- var _a65;
1168
+ var _a72;
1168
1169
  setActiveIndex(index);
1169
- (_a65 = item.onClick) == null ? void 0 : _a65.call(item);
1170
+ (_a72 = item.onClick) == null ? void 0 : _a72.call(item);
1170
1171
  },
1171
1172
  className: cn(
1172
1173
  "flex items-center justify-center w-12 h-12 rounded-xl",
@@ -1201,6 +1202,7 @@ var import_react7 = require("react");
1201
1202
  var import_react6 = require("react");
1202
1203
 
1203
1204
  // src/lib/runtimeEnv.ts
1205
+ var import_meta = {};
1204
1206
  var runtimeStore = {};
1205
1207
  var normalizeValue = (value) => {
1206
1208
  if (value === null || typeof value === "undefined") return void 0;
@@ -1211,9 +1213,9 @@ var normalizeValue = (value) => {
1211
1213
  return String(value);
1212
1214
  };
1213
1215
  var setCupcodeRuntimeEnv = (values) => {
1214
- var _a65;
1216
+ var _a72;
1215
1217
  const globalRef = globalThis;
1216
- const nextGlobalEnv = { ...(_a65 = globalRef.__CUPCODE_ENV__) != null ? _a65 : {} };
1218
+ const nextGlobalEnv = { ...(_a72 = globalRef.__CUPCODE_ENV__) != null ? _a72 : {} };
1217
1219
  Object.entries(values).forEach(([key, value]) => {
1218
1220
  const normalized = normalizeValue(value);
1219
1221
  runtimeStore[key] = normalized;
@@ -1222,37 +1224,72 @@ var setCupcodeRuntimeEnv = (values) => {
1222
1224
  globalRef.__CUPCODE_ENV__ = nextGlobalEnv;
1223
1225
  };
1224
1226
  var readFromProcessEnv = (key) => {
1225
- var _a65;
1226
- const processEnv = (_a65 = globalThis.process) == null ? void 0 : _a65.env;
1227
+ var _a72;
1228
+ const processEnv = (_a72 = globalThis.process) == null ? void 0 : _a72.env;
1227
1229
  return normalizeValue(processEnv == null ? void 0 : processEnv[key]);
1228
1230
  };
1231
+ var readFromImportMetaEnv = (key) => {
1232
+ try {
1233
+ const importMetaEnv = import_meta.env;
1234
+ return normalizeValue(importMetaEnv == null ? void 0 : importMetaEnv[key]);
1235
+ } catch (e) {
1236
+ return void 0;
1237
+ }
1238
+ };
1229
1239
  var getRuntimeEnv = (key) => {
1230
- var _a65;
1240
+ var _a72;
1231
1241
  const normalizedKey = key.trim();
1232
1242
  if (!normalizedKey) return void 0;
1233
1243
  const fromRuntimeStore = runtimeStore[normalizedKey];
1234
1244
  if (fromRuntimeStore) return fromRuntimeStore;
1235
- const fromGlobalStore = normalizeValue((_a65 = globalThis.__CUPCODE_ENV__) == null ? void 0 : _a65[normalizedKey]);
1245
+ const fromGlobalStore = normalizeValue((_a72 = globalThis.__CUPCODE_ENV__) == null ? void 0 : _a72[normalizedKey]);
1236
1246
  if (fromGlobalStore) return fromGlobalStore;
1237
1247
  const fromGlobalKey = normalizeValue(globalThis[normalizedKey]);
1238
1248
  if (fromGlobalKey) return fromGlobalKey;
1249
+ const fromImportMetaEnv = readFromImportMetaEnv(normalizedKey);
1250
+ if (fromImportMetaEnv) return fromImportMetaEnv;
1239
1251
  return readFromProcessEnv(normalizedKey);
1240
1252
  };
1241
1253
  var getRuntimeEnvOr = (key, fallback) => {
1242
- var _a65;
1243
- return (_a65 = getRuntimeEnv(key)) != null ? _a65 : fallback;
1254
+ var _a72;
1255
+ return (_a72 = getRuntimeEnv(key)) != null ? _a72 : fallback;
1244
1256
  };
1245
1257
  var isRuntimeDev = () => {
1246
- var _a65, _b5, _c;
1247
- const explicitDev = (_a65 = getRuntimeEnv("DEV")) != null ? _a65 : getRuntimeEnv("VITE_DEV");
1258
+ var _a72, _b6, _c;
1259
+ const explicitDev = (_a72 = getRuntimeEnv("DEV")) != null ? _a72 : getRuntimeEnv("VITE_DEV");
1248
1260
  if (explicitDev) {
1249
1261
  const normalized = explicitDev.toLowerCase();
1250
1262
  return normalized === "1" || normalized === "true";
1251
1263
  }
1252
- const mode = ((_c = (_b5 = getRuntimeEnv("MODE")) != null ? _b5 : getRuntimeEnv("NODE_ENV")) != null ? _c : "").toLowerCase();
1264
+ const mode = ((_c = (_b6 = getRuntimeEnv("MODE")) != null ? _b6 : getRuntimeEnv("NODE_ENV")) != null ? _c : "").toLowerCase();
1253
1265
  return mode === "development";
1254
1266
  };
1255
1267
 
1268
+ // src/utils/parseAssetId.ts
1269
+ var UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
1270
+ var UUID_IN_TEXT_REGEX = /[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/i;
1271
+ var isUuid = (value) => {
1272
+ if (typeof value !== "string") return false;
1273
+ return UUID_REGEX.test(value.trim());
1274
+ };
1275
+ function parseAssetId(input) {
1276
+ var _a72, _b6, _c, _d;
1277
+ const raw = input == null ? void 0 : input.trim();
1278
+ if (!raw) return void 0;
1279
+ if (UUID_REGEX.test(raw)) return raw;
1280
+ const matchFromRaw = (_a72 = raw.match(UUID_IN_TEXT_REGEX)) == null ? void 0 : _a72[0];
1281
+ if (isUuid(matchFromRaw)) return matchFromRaw;
1282
+ try {
1283
+ const url = new URL(raw);
1284
+ const queryParamId = (_c = (_b6 = url.searchParams.get("id")) != null ? _b6 : url.searchParams.get("asset_id")) != null ? _c : url.searchParams.get("assetId");
1285
+ if (isUuid(queryParamId)) return queryParamId;
1286
+ const matchFromPath = (_d = url.pathname.match(UUID_IN_TEXT_REGEX)) == null ? void 0 : _d[0];
1287
+ if (isUuid(matchFromPath)) return matchFromPath;
1288
+ } catch (e) {
1289
+ }
1290
+ return void 0;
1291
+ }
1292
+
1256
1293
  // src/hooks/useTelescupAsset.ts
1257
1294
  var getApiBase = () => getRuntimeEnvOr("VITE_TELESCUP_API_BASE", "https://cdn.cupcode.com.br").replace(/\/+$/, "");
1258
1295
  function buildTelescupImageURL(options) {
@@ -1265,6 +1302,25 @@ function buildTelescupImageURL(options) {
1265
1302
  params.set("q", quality.toString());
1266
1303
  return `${getApiBase()}/i?${params.toString()}`;
1267
1304
  }
1305
+ function resolveTelescupImageURL(value, options) {
1306
+ const raw = value == null ? void 0 : value.trim();
1307
+ if (!raw) return void 0;
1308
+ const parsedId = parseAssetId(raw);
1309
+ if (parsedId) {
1310
+ return buildTelescupImageURL({
1311
+ id: parsedId,
1312
+ width: options == null ? void 0 : options.width,
1313
+ height: options == null ? void 0 : options.height,
1314
+ fit: options == null ? void 0 : options.fit,
1315
+ format: options == null ? void 0 : options.format,
1316
+ quality: options == null ? void 0 : options.quality
1317
+ });
1318
+ }
1319
+ if (raw.startsWith("http://") || raw.startsWith("https://") || raw.startsWith("data:") || raw.startsWith("blob:")) {
1320
+ return raw;
1321
+ }
1322
+ return void 0;
1323
+ }
1268
1324
  function buildTelescupVideoURL(id) {
1269
1325
  return `${getApiBase()}/i/v?id=${id}`;
1270
1326
  }
@@ -1299,31 +1355,6 @@ function useTelescupImage(options, lang) {
1299
1355
  return { url, meta, loading };
1300
1356
  }
1301
1357
 
1302
- // src/utils/parseAssetId.ts
1303
- var UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
1304
- var UUID_IN_TEXT_REGEX = /[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/i;
1305
- var isUuid = (value) => {
1306
- if (typeof value !== "string") return false;
1307
- return UUID_REGEX.test(value.trim());
1308
- };
1309
- function parseAssetId(input) {
1310
- var _a65, _b5, _c, _d;
1311
- const raw = input == null ? void 0 : input.trim();
1312
- if (!raw) return void 0;
1313
- if (UUID_REGEX.test(raw)) return raw;
1314
- const matchFromRaw = (_a65 = raw.match(UUID_IN_TEXT_REGEX)) == null ? void 0 : _a65[0];
1315
- if (isUuid(matchFromRaw)) return matchFromRaw;
1316
- try {
1317
- const url = new URL(raw);
1318
- const queryParamId = (_c = (_b5 = url.searchParams.get("id")) != null ? _b5 : url.searchParams.get("asset_id")) != null ? _c : url.searchParams.get("assetId");
1319
- if (isUuid(queryParamId)) return queryParamId;
1320
- const matchFromPath = (_d = url.pathname.match(UUID_IN_TEXT_REGEX)) == null ? void 0 : _d[0];
1321
- if (isUuid(matchFromPath)) return matchFromPath;
1322
- } catch (e) {
1323
- }
1324
- return void 0;
1325
- }
1326
-
1327
1358
  // src/components/cupcode/DockWrapper.tsx
1328
1359
  var import_jsx_runtime10 = require("react/jsx-runtime");
1329
1360
  var getImageUrl = (rawId, width = 60, height = 60, format = "avif", quality = 60) => {
@@ -1382,7 +1413,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
1382
1413
  return void 0;
1383
1414
  }, [sortedCategories]);
1384
1415
  (0, import_react7.useEffect)(() => {
1385
- var _a65;
1416
+ var _a72;
1386
1417
  const root = rootRef.current;
1387
1418
  if (!root) return;
1388
1419
  const $ = (sel) => root.querySelector(sel);
@@ -1394,7 +1425,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
1394
1425
  const getDockItems = () => Array.from(root.querySelectorAll(INTERACTIVE_SELECTOR));
1395
1426
  const dockItems = getDockItems();
1396
1427
  if (!tabbar || !dock || !listMenuShow || !tabbarUl || dockItems.length === 0) return;
1397
- const persistentId = (_a65 = activeCategoryId != null ? activeCategoryId : lastInteractiveId) != null ? _a65 : null;
1428
+ const persistentId = (_a72 = activeCategoryId != null ? activeCategoryId : lastInteractiveId) != null ? _a72 : null;
1398
1429
  let openItem = null;
1399
1430
  let latestToggleToken = null;
1400
1431
  const persistentSelector = persistentId != null ? `${INTERACTIVE_SELECTOR}[data-cat-id="${persistentId}"]` : null;
@@ -1693,8 +1724,8 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
1693
1724
  }, total);
1694
1725
  }
1695
1726
  const hideBootstrapTooltip = (el) => {
1696
- var _a66, _b5;
1697
- const tooltip = ((_b5 = (_a66 = window.bootstrap) == null ? void 0 : _a66.Tooltip) == null ? void 0 : _b5.getInstance) ? window.bootstrap.Tooltip.getInstance(el) : null;
1727
+ var _a73, _b6;
1728
+ const tooltip = ((_b6 = (_a73 = window.bootstrap) == null ? void 0 : _a73.Tooltip) == null ? void 0 : _b6.getInstance) ? window.bootstrap.Tooltip.getInstance(el) : null;
1698
1729
  tooltip == null ? void 0 : tooltip.hide();
1699
1730
  };
1700
1731
  const openMenuForItem = (item, menu) => {
@@ -1712,14 +1743,14 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
1712
1743
  latestToggleToken = null;
1713
1744
  };
1714
1745
  const closeActiveMenu = (opts = {}) => {
1715
- var _a66;
1746
+ var _a73;
1716
1747
  if (!opts.onClosed) {
1717
1748
  latestToggleToken = null;
1718
1749
  }
1719
1750
  const itemToClose = openItem;
1720
1751
  if (!itemToClose) {
1721
1752
  if (!opts.preserveWrapper) ensurePersistentHighlight();
1722
- (_a66 = opts.onClosed) == null ? void 0 : _a66.call(opts);
1753
+ (_a73 = opts.onClosed) == null ? void 0 : _a73.call(opts);
1723
1754
  return;
1724
1755
  }
1725
1756
  const menu = getMenuFor(itemToClose);
@@ -1727,7 +1758,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
1727
1758
  itemToClose.classList.remove("active");
1728
1759
  delete itemToClose.dataset.menuOpen;
1729
1760
  const finalize = () => {
1730
- var _a67;
1761
+ var _a74;
1731
1762
  if (!opts.preserveWrapper) {
1732
1763
  listMenuShow.classList.remove("show");
1733
1764
  tabbar.classList.remove("is-active-menu");
@@ -1735,7 +1766,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
1735
1766
  setTabbarTheme(null);
1736
1767
  ensurePersistentHighlight();
1737
1768
  }
1738
- (_a67 = opts.onClosed) == null ? void 0 : _a67.call(opts);
1769
+ (_a74 = opts.onClosed) == null ? void 0 : _a74.call(opts);
1739
1770
  };
1740
1771
  closeMenu(menu, finalize);
1741
1772
  };
@@ -1838,7 +1869,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
1838
1869
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "glass-overlay" }),
1839
1870
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "glass-specular" }),
1840
1871
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("ul", { className: "flex-center", children: sortedCategories.map((cat) => {
1841
- var _a65;
1872
+ var _a72;
1842
1873
  if (cat.type === "divider") {
1843
1874
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1844
1875
  "li",
@@ -1850,7 +1881,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
1850
1881
  cat.id
1851
1882
  );
1852
1883
  }
1853
- const hasCards = (((_a65 = cat.cards) == null ? void 0 : _a65.length) || 0) > 0;
1884
+ const hasCards = (((_a72 = cat.cards) == null ? void 0 : _a72.length) || 0) > 0;
1854
1885
  const link = cat.href;
1855
1886
  const isCurrent = cat.id === activeCategoryId;
1856
1887
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
@@ -1884,12 +1915,12 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
1884
1915
  );
1885
1916
  }) }),
1886
1917
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "list-menu-mob-show", children: sortedCategories.filter((cat) => {
1887
- var _a65;
1888
- return cat.type !== "divider" && (((_a65 = cat.cards) == null ? void 0 : _a65.length) || 0) > 0;
1918
+ var _a72;
1919
+ return cat.type !== "divider" && (((_a72 = cat.cards) == null ? void 0 : _a72.length) || 0) > 0;
1889
1920
  }).map((cat) => {
1890
- var _a65;
1891
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "mob-list-menu hide", "data-tagget": cat.slug, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: `submenu-stack ${cat.slug}`, children: ((_a65 = cat.cards) != null ? _a65 : []).map((card, i) => {
1892
- var _a66;
1921
+ var _a72;
1922
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "mob-list-menu hide", "data-tagget": cat.slug, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: `submenu-stack ${cat.slug}`, children: ((_a72 = cat.cards) != null ? _a72 : []).map((card, i) => {
1923
+ var _a73;
1893
1924
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
1894
1925
  "div",
1895
1926
  {
@@ -1905,8 +1936,8 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
1905
1936
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "title", children: card.title }),
1906
1937
  card.description ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "description", children: card.description }) : null
1907
1938
  ] }),
1908
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "actions", children: ((_a66 = card.buttons) != null ? _a66 : []).slice(0, 2).map((btn, idx) => {
1909
- var _a67, _b5, _c, _d;
1939
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "actions", children: ((_a73 = card.buttons) != null ? _a73 : []).slice(0, 2).map((btn, idx) => {
1940
+ var _a74, _b6, _c, _d;
1910
1941
  const className = idx === 0 ? "saiba-mais" : "saiba-mais-1";
1911
1942
  if (btn.type === "popup") {
1912
1943
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
@@ -1921,7 +1952,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
1921
1952
  window.dispatchEvent(new Event(`qw:open:${btn.popupId}`));
1922
1953
  }
1923
1954
  },
1924
- children: (_a67 = btn.label) != null ? _a67 : "Abrir"
1955
+ children: (_a74 = btn.label) != null ? _a74 : "Abrir"
1925
1956
  },
1926
1957
  `${cat.id}-card-${i}-btn-${idx}`
1927
1958
  );
@@ -1931,7 +1962,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
1931
1962
  {
1932
1963
  href: btn.href || "#",
1933
1964
  className,
1934
- target: ((_b5 = btn.href) == null ? void 0 : _b5.startsWith("http")) ? "_blank" : void 0,
1965
+ target: ((_b6 = btn.href) == null ? void 0 : _b6.startsWith("http")) ? "_blank" : void 0,
1935
1966
  rel: ((_c = btn.href) == null ? void 0 : _c.startsWith("http")) ? "noopener noreferrer" : void 0,
1936
1967
  children: (_d = btn.label) != null ? _d : "Saiba mais >"
1937
1968
  },
@@ -2077,7 +2108,7 @@ var JellyButton = (0, import_react8.forwardRef)(
2077
2108
  };
2078
2109
  const variantStyles3 = {
2079
2110
  primary: {
2080
- base: "bg-gradient-to-r from-cupcode-purple via-[#7b2bff] to-cupcode-ink text-white shadow-[0_0_25px_rgba(149,29,219,0.35)]",
2111
+ base: "bg-gradient-to-r from-cupcode-purple via-[#6f4eb1] to-cupcode-ink text-white shadow-[0_0_25px_rgba(124,91,187,0.35)]",
2081
2112
  overlay: "bg-gradient-to-r from-white/20 via-transparent to-transparent"
2082
2113
  },
2083
2114
  secondary: {
@@ -2085,8 +2116,8 @@ var JellyButton = (0, import_react8.forwardRef)(
2085
2116
  overlay: "bg-gradient-to-r from-white/15 via-emerald-300/20 to-transparent"
2086
2117
  },
2087
2118
  half: {
2088
- base: "bg-gradient-to-r from-cupcode-ink via-[#1a0838] to-black text-cupcode-pink shadow-[0_0_30px_rgba(24,1,58,0.45)]",
2089
- overlay: "bg-gradient-to-br from-white/12 via-cupcode-pink/10 to-transparent"
2119
+ base: "bg-gradient-to-r from-cupcode-ink via-[#31224d] to-black text-cupcode-hover shadow-[0_0_30px_rgba(58,42,88,0.45)]",
2120
+ overlay: "bg-gradient-to-br from-white/12 via-cupcode-hover/10 to-transparent"
2090
2121
  },
2091
2122
  "original-pink": {
2092
2123
  base: "bg-[linear-gradient(90deg,#ff6caf,#ff4088)] text-white shadow-[0_0_10px_rgba(255,0,150,0.3),0_0_20px_rgba(255,0,150,0.5)]",
@@ -2218,7 +2249,7 @@ var Eyebrow = (0, import_react10.forwardRef)(
2218
2249
  const variantClasses = {
2219
2250
  galaxy: "cc-gradient-galaxy text-white shadow-[0_0_20px_rgba(193,27,150,0.4)]",
2220
2251
  pink: "bg-cupcode-pink text-white shadow-[0_0_20px_rgba(237,30,121,0.4)]",
2221
- purple: "bg-cupcode-purple text-white shadow-[0_0_20px_rgba(149,29,219,0.4)]",
2252
+ purple: "bg-cupcode-purple text-white shadow-[0_0_20px_rgba(124,91,187,0.4)]",
2222
2253
  outline: "border-2 border-cupcode-purple text-cupcode-purple bg-transparent"
2223
2254
  };
2224
2255
  return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
@@ -2497,7 +2528,7 @@ var LoadingSpinner = ({
2497
2528
  "div",
2498
2529
  {
2499
2530
  className: cn(
2500
- "animate-spin rounded-full border-transparent border-t-cupcode-pink border-r-cupcode-purple",
2531
+ "animate-spin rounded-full border-transparent border-t-cupcode-hover border-r-cupcode-purple",
2501
2532
  sizes[size],
2502
2533
  className
2503
2534
  ),
@@ -2546,7 +2577,7 @@ var LoadingScreen = ({
2546
2577
  return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: cn(containerClasses, "cc-gradient-galaxy"), children: /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "glass rounded-2xl p-8 flex flex-col items-center space-y-4 animate-scale-in", children: [
2547
2578
  /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "relative", children: [
2548
2579
  /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(LoadingSpinner, { size: "lg" }),
2549
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "absolute inset-0 blur-2xl bg-cupcode-pink/30 animate-pulse-scale" })
2580
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "absolute inset-0 blur-2xl bg-cupcode-hover/30 animate-pulse-scale" })
2550
2581
  ] }),
2551
2582
  message && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "text-white font-semibold text-lg animate-pulse", children: message })
2552
2583
  ] }) });
@@ -2559,9 +2590,9 @@ var LoadingScreen = ({
2559
2590
  message && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "text-center space-y-2", children: [
2560
2591
  /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "font-bold text-lg cc-text-gradient-galaxy", children: message }),
2561
2592
  /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex gap-1 justify-center", children: [
2562
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "w-2 h-2 rounded-full bg-cupcode-pink animate-bounce", style: { animationDelay: "0ms" } }),
2593
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "w-2 h-2 rounded-full bg-cupcode-hover animate-bounce", style: { animationDelay: "0ms" } }),
2563
2594
  /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "w-2 h-2 rounded-full bg-cupcode-purple animate-bounce", style: { animationDelay: "150ms" } }),
2564
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "w-2 h-2 rounded-full bg-cupcode-pink animate-bounce", style: { animationDelay: "300ms" } })
2595
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "w-2 h-2 rounded-full bg-cupcode-hover animate-bounce", style: { animationDelay: "300ms" } })
2565
2596
  ] })
2566
2597
  ] })
2567
2598
  ] }) });
@@ -2680,10 +2711,10 @@ var NavbarCupcode = ({
2680
2711
  React10.useEffect(() => {
2681
2712
  if (!isOpen) return;
2682
2713
  const handlePointerDown = (event) => {
2683
- var _a65;
2714
+ var _a72;
2684
2715
  const target = event.target;
2685
2716
  if (!(target instanceof Node)) return;
2686
- if (!((_a65 = navRef.current) == null ? void 0 : _a65.contains(target))) {
2717
+ if (!((_a72 = navRef.current) == null ? void 0 : _a72.contains(target))) {
2687
2718
  setIsOpen(false);
2688
2719
  }
2689
2720
  };
@@ -2724,8 +2755,8 @@ var NavbarCupcode = ({
2724
2755
  {
2725
2756
  ref: navRef,
2726
2757
  className: cn(
2727
- "fixed top-0 left-0 right-0 z-[200] pointer-events-auto",
2728
- "glass border-b border-border",
2758
+ "fixed left-2 right-2 top-[max(env(safe-area-inset-top),0.75rem)] z-[200] overflow-hidden rounded-2xl",
2759
+ "glass border-border/70 shadow-[var(--elevation-3)] md:left-4 md:right-4",
2729
2760
  className
2730
2761
  ),
2731
2762
  children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "cc-container", children: [
@@ -2743,8 +2774,8 @@ var NavbarCupcode = ({
2743
2774
  isActive && "text-primary after:w-full"
2744
2775
  );
2745
2776
  const handleClick = (event) => {
2746
- var _a65;
2747
- (_a65 = item.onClick) == null ? void 0 : _a65.call(item, event);
2777
+ var _a72;
2778
+ (_a72 = item.onClick) == null ? void 0 : _a72.call(item, event);
2748
2779
  };
2749
2780
  if (item.href.startsWith("#")) {
2750
2781
  return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
@@ -2795,7 +2826,7 @@ var NavbarCupcode = ({
2795
2826
  "div",
2796
2827
  {
2797
2828
  id: mobileMenuId,
2798
- className: "md:hidden max-h-[calc(100dvh-4rem)] space-y-3 overflow-y-auto border-t border-border/60 py-4 animate-slide-up",
2829
+ className: "md:hidden max-h-[calc(100dvh-5rem)] space-y-3 overflow-y-auto border-t border-border/60 py-4 animate-slide-up",
2799
2830
  children: [
2800
2831
  items.map((item, index) => {
2801
2832
  const key = `${item.label}-${index}`;
@@ -2805,8 +2836,8 @@ var NavbarCupcode = ({
2805
2836
  isActive && "text-primary"
2806
2837
  );
2807
2838
  const handleClick = (event) => {
2808
- var _a65;
2809
- (_a65 = item.onClick) == null ? void 0 : _a65.call(item, event);
2839
+ var _a72;
2840
+ (_a72 = item.onClick) == null ? void 0 : _a72.call(item, event);
2810
2841
  setIsOpen(false);
2811
2842
  };
2812
2843
  if (item.href.startsWith("#")) {
@@ -3563,12 +3594,12 @@ var rpcPreferredSchema = TELESCUP_RPC_SCHEMA;
3563
3594
  var RPC_MISSING_SCHEMAS_BY_PATH = /* @__PURE__ */ new Map();
3564
3595
  var FUNCTION_NOT_FOUND_CACHE = /* @__PURE__ */ new Set();
3565
3596
  var buildRestHeaders = (token, options) => {
3566
- var _a65;
3597
+ var _a72;
3567
3598
  const headers = {};
3568
3599
  if (SUPABASE_ANON_KEY) {
3569
3600
  headers.apikey = SUPABASE_ANON_KEY;
3570
3601
  }
3571
- const authorizationToken = (_a65 = resolveRpcAuthorizationToken(token)) != null ? _a65 : token;
3602
+ const authorizationToken = (_a72 = resolveRpcAuthorizationToken(token)) != null ? _a72 : token;
3572
3603
  if (authorizationToken) {
3573
3604
  headers.Authorization = `Bearer ${authorizationToken}`;
3574
3605
  }
@@ -3703,22 +3734,22 @@ var parseAssetSize = (value) => {
3703
3734
  return Number.isFinite(parsed) ? parsed : void 0;
3704
3735
  };
3705
3736
  var getFileExtension = (filename) => {
3706
- var _a65;
3737
+ var _a72;
3707
3738
  if (!filename) return void 0;
3708
3739
  const parts = filename.split(".");
3709
3740
  if (parts.length < 2) return void 0;
3710
- const candidate = (_a65 = parts[parts.length - 1]) == null ? void 0 : _a65.trim().toLowerCase();
3741
+ const candidate = (_a72 = parts[parts.length - 1]) == null ? void 0 : _a72.trim().toLowerCase();
3711
3742
  return candidate || void 0;
3712
3743
  };
3713
3744
  var resolveCategory = (row, activeMeta) => {
3714
- var _a65;
3715
- return (_a65 = readString(row.category)) != null ? _a65 : readString(activeMeta.category);
3745
+ var _a72;
3746
+ return (_a72 = readString(row.category)) != null ? _a72 : readString(activeMeta.category);
3716
3747
  };
3717
3748
  var resolveFolderName = (row) => readString(row.folder_name);
3718
3749
  var toTelescupAsset = (row, selectedLanguage) => {
3719
- var _a65, _b5, _c, _d, _e;
3750
+ var _a72, _b6, _c, _d, _e;
3720
3751
  const metaByLang = normalizeMetaByLanguage(row.meta);
3721
- const activeMeta = (_b5 = (_a65 = metaByLang[selectedLanguage]) != null ? _a65 : metaByLang.pt) != null ? _b5 : {};
3752
+ const activeMeta = (_b6 = (_a72 = metaByLang[selectedLanguage]) != null ? _a72 : metaByLang.pt) != null ? _b6 : {};
3722
3753
  return {
3723
3754
  id: (_c = row.id) != null ? _c : "",
3724
3755
  name: row.filename,
@@ -3744,14 +3775,14 @@ var buildFacetsFromItems = (items) => {
3744
3775
  const extensions = /* @__PURE__ */ new Map();
3745
3776
  const tags = /* @__PURE__ */ new Map();
3746
3777
  items.forEach((item) => {
3747
- var _a65, _b5, _c, _d, _e, _f, _g;
3778
+ var _a72, _b6, _c, _d, _e, _f, _g;
3748
3779
  if (item.category) {
3749
- categories.set(item.category, ((_a65 = categories.get(item.category)) != null ? _a65 : 0) + 1);
3780
+ categories.set(item.category, ((_a72 = categories.get(item.category)) != null ? _a72 : 0) + 1);
3750
3781
  }
3751
3782
  if (item.folderId) {
3752
3783
  const current = folders.get(item.folderId);
3753
3784
  folders.set(item.folderId, {
3754
- label: (_b5 = item.folderName) != null ? _b5 : current == null ? void 0 : current.label,
3785
+ label: (_b6 = item.folderName) != null ? _b6 : current == null ? void 0 : current.label,
3755
3786
  count: ((_c = current == null ? void 0 : current.count) != null ? _c : 0) + 1
3756
3787
  });
3757
3788
  }
@@ -3762,16 +3793,16 @@ var buildFacetsFromItems = (items) => {
3762
3793
  extensions.set(item.extension, ((_e = extensions.get(item.extension)) != null ? _e : 0) + 1);
3763
3794
  }
3764
3795
  (_g = (_f = item.meta) == null ? void 0 : _f.tags) == null ? void 0 : _g.forEach((tag) => {
3765
- var _a66;
3796
+ var _a73;
3766
3797
  const normalizedTag = tag.trim();
3767
3798
  if (!normalizedTag) return;
3768
- tags.set(normalizedTag, ((_a66 = tags.get(normalizedTag)) != null ? _a66 : 0) + 1);
3799
+ tags.set(normalizedTag, ((_a73 = tags.get(normalizedTag)) != null ? _a73 : 0) + 1);
3769
3800
  });
3770
3801
  });
3771
3802
  const toFacetValues = (map) => Array.from(map.entries()).map(([value, count2]) => ({ value, count: count2 })).sort((a, b) => a.value.localeCompare(b.value));
3772
3803
  const toFolderFacetValues = (map) => Array.from(map.entries()).map(([value, info]) => ({ value, label: info.label, count: info.count })).sort((a, b) => {
3773
- var _a65, _b5;
3774
- return ((_a65 = a.label) != null ? _a65 : a.value).localeCompare((_b5 = b.label) != null ? _b5 : b.value);
3804
+ var _a72, _b6;
3805
+ return ((_a72 = a.label) != null ? _a72 : a.value).localeCompare((_b6 = b.label) != null ? _b6 : b.value);
3775
3806
  });
3776
3807
  return {
3777
3808
  categories: toFacetValues(categories),
@@ -3789,7 +3820,7 @@ var isManagerScopeRetryable = (error) => {
3789
3820
  return /permission|not allowed|wrong key type|insufficient|unauthorized/i.test(detailsText);
3790
3821
  };
3791
3822
  async function listAssetsViaRpc(config, filters) {
3792
- var _a65, _b5, _c, _d, _e, _f, _g, _h, _i;
3823
+ var _a72, _b6, _c, _d, _e, _f, _g, _h, _i;
3793
3824
  if (!SUPABASE_ANON_KEY) {
3794
3825
  throw new TelescupClientError(
3795
3826
  "VITE_SUPABASE_ANON_KEY (ou VITE_SUPABASE_PUBLISHABLE_KEY) n\xE3o encontrado para fallback RPC do Telescup."
@@ -3809,11 +3840,11 @@ async function listAssetsViaRpc(config, filters) {
3809
3840
  }
3810
3841
  const shouldLoadFacetTables = isSupabaseAccessToken(token);
3811
3842
  const pageSize = Math.min(100, Math.max(1, toPositiveInt(filters.pageSize, 24)));
3812
- const page = toPositiveInt((_a65 = filters.cursor) != null ? _a65 : filters.page, 1);
3843
+ const page = toPositiveInt((_a72 = filters.cursor) != null ? _a72 : filters.page, 1);
3813
3844
  const selectedLanguage = normalizeLanguageKey(filters.language);
3814
3845
  const bodyBase = {
3815
3846
  p_user_id: userId,
3816
- p_query: (_b5 = filters.query) != null ? _b5 : null,
3847
+ p_query: (_b6 = filters.query) != null ? _b6 : null,
3817
3848
  p_page: page,
3818
3849
  p_page_size: pageSize,
3819
3850
  p_type: filters.type && filters.type !== "all" ? filters.type : null,
@@ -3909,13 +3940,13 @@ var getRpcSchemaCandidates = (rpcPath) => {
3909
3940
  return filtered.length ? filtered : ordered;
3910
3941
  };
3911
3942
  var markRpcSchemaMissing = (rpcPath, schema) => {
3912
- var _a65;
3913
- const set = (_a65 = RPC_MISSING_SCHEMAS_BY_PATH.get(rpcPath)) != null ? _a65 : /* @__PURE__ */ new Set();
3943
+ var _a72;
3944
+ const set = (_a72 = RPC_MISSING_SCHEMAS_BY_PATH.get(rpcPath)) != null ? _a72 : /* @__PURE__ */ new Set();
3914
3945
  set.add(schema);
3915
3946
  RPC_MISSING_SCHEMAS_BY_PATH.set(rpcPath, set);
3916
3947
  };
3917
3948
  async function requestRpc(config, rpcPath, payload) {
3918
- var _a65, _b5;
3949
+ var _a72, _b6;
3919
3950
  if (!SUPABASE_ANON_KEY) {
3920
3951
  throw new TelescupClientError(
3921
3952
  "VITE_SUPABASE_ANON_KEY (ou VITE_SUPABASE_PUBLISHABLE_KEY) n\xE3o encontrado para fallback RPC do Telescup."
@@ -3958,7 +3989,7 @@ async function requestRpc(config, rpcPath, payload) {
3958
3989
  throw new TelescupClientError(`Falha de rede ao chamar RPC ${rpcPath}.`, { details: error });
3959
3990
  }
3960
3991
  if (response.ok) {
3961
- const contentType = (_a65 = response.headers.get("content-type")) != null ? _a65 : "";
3992
+ const contentType = (_a72 = response.headers.get("content-type")) != null ? _a72 : "";
3962
3993
  if (!contentType.includes("application/json")) {
3963
3994
  const text = await response.text();
3964
3995
  if (!text) return {};
@@ -3980,7 +4011,7 @@ async function requestRpc(config, rpcPath, payload) {
3980
4011
  responsePayload = await response.text();
3981
4012
  }
3982
4013
  const payloadObject = responsePayload != null ? responsePayload : {};
3983
- const message = typeof responsePayload === "string" ? responsePayload : (_b5 = payloadObject.message) != null ? _b5 : `Erro ao chamar RPC ${schema}.${rpcPath} (${response.status}).`;
4014
+ const message = typeof responsePayload === "string" ? responsePayload : (_b6 = payloadObject.message) != null ? _b6 : `Erro ao chamar RPC ${schema}.${rpcPath} (${response.status}).`;
3984
4015
  const rpcError = new TelescupClientError(message, {
3985
4016
  status: response.status,
3986
4017
  code: payloadObject.code,
@@ -4010,7 +4041,7 @@ async function requestRpc(config, rpcPath, payload) {
4010
4041
  throw new TelescupClientError(`Falha ao chamar RPC ${rpcPath}.`);
4011
4042
  }
4012
4043
  var toTelescupError = async (response, fallbackMessage) => {
4013
- var _a65;
4044
+ var _a72;
4014
4045
  let payload = void 0;
4015
4046
  try {
4016
4047
  payload = await response.json();
@@ -4018,7 +4049,7 @@ var toTelescupError = async (response, fallbackMessage) => {
4018
4049
  payload = await response.text();
4019
4050
  }
4020
4051
  const payloadObject = payload != null ? payload : {};
4021
- const message = typeof payload === "string" ? payload : (_a65 = payloadObject.message) != null ? _a65 : `${fallbackMessage} (${response.status}).`;
4052
+ const message = typeof payload === "string" ? payload : (_a72 = payloadObject.message) != null ? _a72 : `${fallbackMessage} (${response.status}).`;
4022
4053
  return new TelescupClientError(message, {
4023
4054
  status: response.status,
4024
4055
  code: payloadObject.code,
@@ -4066,11 +4097,11 @@ var mergeFacetEntries = (current, incoming) => {
4066
4097
  const map = /* @__PURE__ */ new Map();
4067
4098
  current == null ? void 0 : current.forEach((entry) => map.set(entry.value, entry));
4068
4099
  incoming == null ? void 0 : incoming.forEach((entry) => {
4069
- var _a65, _b5, _c;
4100
+ var _a72, _b6, _c;
4070
4101
  const previous = map.get(entry.value);
4071
4102
  map.set(entry.value, {
4072
4103
  value: entry.value,
4073
- label: (_b5 = (_a65 = entry.label) != null ? _a65 : previous == null ? void 0 : previous.label) != null ? _b5 : entry.value,
4104
+ label: (_b6 = (_a72 = entry.label) != null ? _a72 : previous == null ? void 0 : previous.label) != null ? _b6 : entry.value,
4074
4105
  count: (_c = entry.count) != null ? _c : previous == null ? void 0 : previous.count
4075
4106
  });
4076
4107
  });
@@ -4090,10 +4121,10 @@ var mergeFacets = (base, incoming) => {
4090
4121
  var toFacetEntriesFromRows = (rows, valueKeys, labelKeys) => {
4091
4122
  const result = /* @__PURE__ */ new Map();
4092
4123
  rows.forEach((row) => {
4093
- var _a65;
4124
+ var _a72;
4094
4125
  const value = readFirstString(row, valueKeys);
4095
4126
  if (!value) return;
4096
- const label = (_a65 = readFirstString(row, labelKeys)) != null ? _a65 : value;
4127
+ const label = (_a72 = readFirstString(row, labelKeys)) != null ? _a72 : value;
4097
4128
  result.set(value, { value, label });
4098
4129
  });
4099
4130
  return Array.from(result.values()).sort((a, b) => a.label.localeCompare(b.label));
@@ -4152,7 +4183,7 @@ async function loadFacetsFromTelescupTables(config) {
4152
4183
  };
4153
4184
  }
4154
4185
  async function request(config, path, options = {}) {
4155
- var _a65, _b5, _c;
4186
+ var _a72, _b6, _c;
4156
4187
  const token = await config.getAccessToken();
4157
4188
  if (!token) {
4158
4189
  throw new TelescupClientError("Token de acesso n\xE3o encontrado.");
@@ -4160,7 +4191,7 @@ async function request(config, path, options = {}) {
4160
4191
  const functionsBaseUrl = resolveFunctionsBaseUrl(config.baseUrl);
4161
4192
  const url = joinUrl(functionsBaseUrl, path);
4162
4193
  const isAssetApiRoute = path.startsWith("asset-api/");
4163
- const authorizationToken = isAssetApiRoute ? (_a65 = resolveRpcAuthorizationToken(token)) != null ? _a65 : token : token;
4194
+ const authorizationToken = isAssetApiRoute ? (_a72 = resolveRpcAuthorizationToken(token)) != null ? _a72 : token : token;
4164
4195
  const headers = {
4165
4196
  Authorization: `Bearer ${authorizationToken}`,
4166
4197
  ...options.headers
@@ -4176,7 +4207,7 @@ async function request(config, path, options = {}) {
4176
4207
  let response;
4177
4208
  try {
4178
4209
  response = await fetch(url, {
4179
- method: (_b5 = options.method) != null ? _b5 : "POST",
4210
+ method: (_b6 = options.method) != null ? _b6 : "POST",
4180
4211
  headers,
4181
4212
  body
4182
4213
  });
@@ -4210,11 +4241,11 @@ var normalizeFunctionLanguage = (value) => {
4210
4241
  return normalized;
4211
4242
  };
4212
4243
  var toFunctionListPayload = (filters) => {
4213
- var _a65, _b5, _c, _d, _e, _f;
4214
- const page = toPositiveInt((_a65 = filters.cursor) != null ? _a65 : filters.page, 1);
4244
+ var _a72, _b6, _c, _d, _e, _f;
4245
+ const page = toPositiveInt((_a72 = filters.cursor) != null ? _a72 : filters.page, 1);
4215
4246
  const pageSize = Math.min(500, Math.max(1, toPositiveInt(filters.pageSize, 24)));
4216
4247
  return {
4217
- query: (_b5 = filters.query) != null ? _b5 : "",
4248
+ query: (_b6 = filters.query) != null ? _b6 : "",
4218
4249
  page,
4219
4250
  pageSize,
4220
4251
  sort: `${normalizeSortBy(filters.sort)}:${filters.order === "asc" ? "asc" : "desc"}`,
@@ -4249,8 +4280,8 @@ var toFolderPath = (value) => {
4249
4280
  return normalized.slice(0, lastSlash);
4250
4281
  };
4251
4282
  var normalizeFilterText = (value) => {
4252
- var _a65;
4253
- return (_a65 = value == null ? void 0 : value.trim().toLowerCase()) != null ? _a65 : "";
4283
+ var _a72;
4284
+ return (_a72 = value == null ? void 0 : value.trim().toLowerCase()) != null ? _a72 : "";
4254
4285
  };
4255
4286
  var normalizeExtensionFilter = (value) => {
4256
4287
  const normalized = normalizeFilterText(value);
@@ -4264,16 +4295,16 @@ var normalizeFolderFilter = (value) => {
4264
4295
  var sortAssets = (items, sort, order) => {
4265
4296
  const direction = order === "asc" ? 1 : -1;
4266
4297
  const byName = (a, b) => {
4267
- var _a65, _b5, _c, _d;
4268
- return ((_b5 = (_a65 = a.fileName) != null ? _a65 : a.name) != null ? _b5 : "").localeCompare((_d = (_c = b.fileName) != null ? _c : b.name) != null ? _d : "");
4298
+ var _a72, _b6, _c, _d;
4299
+ return ((_b6 = (_a72 = a.fileName) != null ? _a72 : a.name) != null ? _b6 : "").localeCompare((_d = (_c = b.fileName) != null ? _c : b.name) != null ? _d : "");
4269
4300
  };
4270
4301
  const byDate = (a, b, key) => {
4271
- var _a65, _b5;
4272
- return (Date.parse((_a65 = a[key]) != null ? _a65 : "") || 0) - (Date.parse((_b5 = b[key]) != null ? _b5 : "") || 0);
4302
+ var _a72, _b6;
4303
+ return (Date.parse((_a72 = a[key]) != null ? _a72 : "") || 0) - (Date.parse((_b6 = b[key]) != null ? _b6 : "") || 0);
4273
4304
  };
4274
4305
  const bySize = (a, b) => {
4275
- var _a65, _b5;
4276
- return ((_a65 = a.size) != null ? _a65 : 0) - ((_b5 = b.size) != null ? _b5 : 0);
4306
+ var _a72, _b6;
4307
+ return ((_a72 = a.size) != null ? _a72 : 0) - ((_b6 = b.size) != null ? _b6 : 0);
4277
4308
  };
4278
4309
  const sorted = [...items];
4279
4310
  sorted.sort((a, b) => {
@@ -4308,7 +4339,7 @@ var applyAssetApiSearchFilters = (items, filters) => {
4308
4339
  const folderFilter = normalizeFolderFilter(filters.folderId);
4309
4340
  const requireAlt = filters.hasAlt === true;
4310
4341
  return items.filter((asset) => {
4311
- var _a65, _b5, _c, _d, _e, _f, _g, _h, _i;
4342
+ var _a72, _b6, _c, _d, _e, _f, _g, _h, _i;
4312
4343
  const haystack = [
4313
4344
  asset.id,
4314
4345
  asset.name,
@@ -4317,8 +4348,8 @@ var applyAssetApiSearchFilters = (items, filters) => {
4317
4348
  asset.folderName,
4318
4349
  asset.category,
4319
4350
  asset.usage,
4320
- (_a65 = asset.meta) == null ? void 0 : _a65.title,
4321
- (_b5 = asset.meta) == null ? void 0 : _b5.description,
4351
+ (_a72 = asset.meta) == null ? void 0 : _a72.title,
4352
+ (_b6 = asset.meta) == null ? void 0 : _b6.description,
4322
4353
  (_c = asset.meta) == null ? void 0 : _c.alt,
4323
4354
  ...Array.isArray((_d = asset.meta) == null ? void 0 : _d.tags) ? asset.meta.tags : []
4324
4355
  ].filter((value) => typeof value === "string" && value.trim() !== "").join(" ").toLowerCase();
@@ -4337,15 +4368,15 @@ var applyAssetApiSearchFilters = (items, filters) => {
4337
4368
  });
4338
4369
  };
4339
4370
  var mapAssetApiSearchRowToAsset = (row) => {
4340
- var _a65, _b5, _c, _d;
4371
+ var _a72, _b6, _c, _d;
4341
4372
  const id = readFirstString(row, ["asset_id", "id"]);
4342
4373
  if (!id) return null;
4343
- const fileName = (_a65 = readFirstString(row, ["original_filename", "filename", "title"])) != null ? _a65 : readFirstString(row, ["file_path"]);
4374
+ const fileName = (_a72 = readFirstString(row, ["original_filename", "filename", "title"])) != null ? _a72 : readFirstString(row, ["file_path"]);
4344
4375
  const mimeType = readFirstString(row, ["mime_type", "mime"]);
4345
4376
  const extension = getFileExtension(readFirstString(row, ["file_path", "filename", "original_filename"]));
4346
4377
  const tags = Array.isArray(row.tags) ? row.tags.filter((item) => typeof item === "string") : void 0;
4347
4378
  const categories = readStringArray(row.categories);
4348
- const category = (_b5 = readFirstString(row, ["category"])) != null ? _b5 : categories[0];
4379
+ const category = (_b6 = readFirstString(row, ["category"])) != null ? _b6 : categories[0];
4349
4380
  const alt = readFirstString(row, ["alt_text"]);
4350
4381
  const title = readFirstString(row, ["title"]);
4351
4382
  const description = readFirstString(row, ["description"]);
@@ -4388,14 +4419,14 @@ var mapAssetApiSearchRowToAsset = (row) => {
4388
4419
  };
4389
4420
  };
4390
4421
  async function listAssetsViaAssetApiSearch(config, filters) {
4391
- var _a65, _b5;
4422
+ var _a72, _b6;
4392
4423
  const pageSize = Math.min(500, Math.max(1, toPositiveInt(filters.pageSize, 24)));
4393
- const page = toPositiveInt((_a65 = filters.cursor) != null ? _a65 : filters.page, 1);
4424
+ const page = toPositiveInt((_a72 = filters.cursor) != null ? _a72 : filters.page, 1);
4394
4425
  const hasActiveFacetFilter = Boolean(filters.type && filters.type !== "all") || Boolean(filters.extension) || Boolean(filters.category) || Boolean(filters.folderId) || Boolean(filters.usage) || filters.hasAlt === true;
4395
4426
  const baseLimit = page * pageSize + 1;
4396
4427
  const seedLimit = hasActiveFacetFilter ? baseLimit : Math.max(baseLimit, TELESCUP_ASSET_API_FACET_SEED_LIMIT);
4397
4428
  const limit = Math.min(500, seedLimit);
4398
- const query = ((_b5 = filters.query) != null ? _b5 : "").trim() || TELESCUP_SEARCH_DEFAULT_QUERY;
4429
+ const query = ((_b6 = filters.query) != null ? _b6 : "").trim() || TELESCUP_SEARCH_DEFAULT_QUERY;
4399
4430
  const [pathBase, rawQuery] = TELESCUP_LIST_FUNCTION.split("?");
4400
4431
  const params = new URLSearchParams(rawQuery != null ? rawQuery : "");
4401
4432
  params.set("q", query);
@@ -4419,12 +4450,12 @@ async function listAssetsViaAssetApiSearch(config, filters) {
4419
4450
  };
4420
4451
  }
4421
4452
  var mapGenericRowToAsset = (row) => {
4422
- var _a65, _b5;
4423
- const id = (_a65 = readFirstString(row, ["asset_id", "id", "file_id", "uuid"])) != null ? _a65 : typeof row.id === "number" ? String(row.id) : void 0;
4453
+ var _a72, _b6;
4454
+ const id = (_a72 = readFirstString(row, ["asset_id", "id", "file_id", "uuid"])) != null ? _a72 : typeof row.id === "number" ? String(row.id) : void 0;
4424
4455
  if (!id) return null;
4425
4456
  const fileName = readFirstString(row, ["filename", "file_name", "name", "title", "original_name"]);
4426
4457
  const mimeType = readFirstString(row, ["mime", "mime_type", "content_type", "file_mime"]);
4427
- const extension = (_b5 = readFirstString(row, ["extension", "ext"])) != null ? _b5 : getFileExtension(fileName);
4458
+ const extension = (_b6 = readFirstString(row, ["extension", "ext"])) != null ? _b6 : getFileExtension(fileName);
4428
4459
  return {
4429
4460
  id,
4430
4461
  name: fileName,
@@ -4442,16 +4473,16 @@ var mapGenericRowToAsset = (row) => {
4442
4473
  };
4443
4474
  };
4444
4475
  var normalizeListResponseFromFunctions = (response, filters) => {
4445
- var _a65, _b5, _c, _d, _e, _f;
4476
+ var _a72, _b6, _c, _d, _e, _f;
4446
4477
  const payload = response != null ? response : {};
4447
4478
  const itemsRaw = Array.isArray(payload.items) ? payload.items : [];
4448
4479
  const selectedLanguage = normalizeLanguageKey(filters.language);
4449
4480
  const items = itemsRaw.map((row) => {
4450
- var _a66, _b6, _c2;
4481
+ var _a73, _b7, _c2;
4451
4482
  const mapped = mapGenericRowToAsset(row);
4452
4483
  if (!mapped) return null;
4453
4484
  const metaByLang = normalizeMetaByLanguage(row.meta);
4454
- const activeMeta = (_b6 = (_a66 = metaByLang[selectedLanguage]) != null ? _a66 : metaByLang.pt) != null ? _b6 : {};
4485
+ const activeMeta = (_b7 = (_a73 = metaByLang[selectedLanguage]) != null ? _a73 : metaByLang.pt) != null ? _b7 : {};
4455
4486
  const usageFromObject = readUsageContext(row.usage);
4456
4487
  const normalized = {
4457
4488
  ...mapped,
@@ -4463,7 +4494,7 @@ var normalizeListResponseFromFunctions = (response, filters) => {
4463
4494
  };
4464
4495
  return normalized;
4465
4496
  }).filter((item) => item !== null);
4466
- const total = (_c = (_b5 = (_a65 = readNumber(payload.total)) != null ? _a65 : readNumber(payload.totalCount)) != null ? _b5 : readNumber(payload.total_count)) != null ? _c : items.length;
4497
+ const total = (_c = (_b6 = (_a72 = readNumber(payload.total)) != null ? _a72 : readNumber(payload.totalCount)) != null ? _b6 : readNumber(payload.total_count)) != null ? _c : items.length;
4467
4498
  const page = toPositiveInt((_e = (_d = payload.page) != null ? _d : filters.cursor) != null ? _e : filters.page, 1);
4468
4499
  const pageSize = Math.min(100, Math.max(1, toPositiveInt((_f = payload.pageSize) != null ? _f : filters.pageSize, 24)));
4469
4500
  const nextCursor = total > page * pageSize ? String(page + 1) : void 0;
@@ -4483,13 +4514,13 @@ var mapConflictForQueue = (value) => {
4483
4514
  return "conflict";
4484
4515
  };
4485
4516
  var toInitPayloadForFunctions = (payload) => {
4486
- var _a65, _b5;
4517
+ var _a72, _b6;
4487
4518
  return {
4488
4519
  filename: payload.fileName,
4489
4520
  size: payload.size,
4490
4521
  mime: payload.mimeType,
4491
- folder_id: (_a65 = payload.folderId) != null ? _a65 : null,
4492
- overwritePolicy: (_b5 = payload.conflict) != null ? _b5 : "ask",
4522
+ folder_id: (_a72 = payload.folderId) != null ? _a72 : null,
4523
+ overwritePolicy: (_b6 = payload.conflict) != null ? _b6 : "ask",
4493
4524
  fileName: payload.fileName,
4494
4525
  mimeType: payload.mimeType,
4495
4526
  folderId: payload.folderId,
@@ -4497,10 +4528,10 @@ var toInitPayloadForFunctions = (payload) => {
4497
4528
  };
4498
4529
  };
4499
4530
  var normalizeInitResponseFromFunctions = (response) => {
4500
- var _a65, _b5, _c, _d, _e, _f, _g;
4531
+ var _a72, _b6, _c, _d, _e, _f, _g;
4501
4532
  const payload = response != null ? response : {};
4502
- const existingRaw = (_a65 = payload.existingAsset) != null ? _a65 : payload.existing_asset;
4503
- const existingAsset = existingRaw ? (_b5 = mapGenericRowToAsset(existingRaw)) != null ? _b5 : void 0 : void 0;
4533
+ const existingRaw = (_a72 = payload.existingAsset) != null ? _a72 : payload.existing_asset;
4534
+ const existingAsset = existingRaw ? (_b6 = mapGenericRowToAsset(existingRaw)) != null ? _b6 : void 0 : void 0;
4504
4535
  const assetRaw = payload.asset;
4505
4536
  const asset = assetRaw ? (_c = mapGenericRowToAsset(assetRaw)) != null ? _c : void 0 : void 0;
4506
4537
  const conflictSource = (_e = readString(payload.conflict)) != null ? _e : readString((_d = payload.conflict) == null ? void 0 : _d.type);
@@ -4521,12 +4552,12 @@ var normalizeInitResponseFromFunctions = (response) => {
4521
4552
  };
4522
4553
  };
4523
4554
  var toCompletePayloadForFunctions = (payload) => {
4524
- var _a65, _b5, _c;
4555
+ var _a72, _b6, _c;
4525
4556
  return {
4526
4557
  uploadId: payload.uploadId,
4527
- assetDraftId: (_a65 = payload.assetDraftId) != null ? _a65 : payload.assetId,
4558
+ assetDraftId: (_a72 = payload.assetDraftId) != null ? _a72 : payload.assetId,
4528
4559
  storageKey: payload.storageKey,
4529
- finalFilename: (_b5 = payload.finalFilename) != null ? _b5 : payload.fileName,
4560
+ finalFilename: (_b6 = payload.finalFilename) != null ? _b6 : payload.fileName,
4530
4561
  folder_id: (_c = payload.folderId) != null ? _c : null,
4531
4562
  upload_id: payload.uploadId,
4532
4563
  asset_id: payload.assetId,
@@ -4534,21 +4565,21 @@ var toCompletePayloadForFunctions = (payload) => {
4534
4565
  };
4535
4566
  };
4536
4567
  var normalizeCompleteResponseFromFunctions = (response) => {
4537
- var _a65, _b5;
4568
+ var _a72, _b6;
4538
4569
  const payload = response != null ? response : {};
4539
- const assetRaw = (_a65 = payload.asset) != null ? _a65 : payload;
4570
+ const assetRaw = (_a72 = payload.asset) != null ? _a72 : payload;
4540
4571
  const mapped = mapGenericRowToAsset(assetRaw);
4541
4572
  if (mapped) return { asset: mapped };
4542
- const assetId = (_b5 = readFirstString(assetRaw, ["id", "asset_id"])) != null ? _b5 : readFirstString(payload, ["assetId", "asset_id"]);
4573
+ const assetId = (_b6 = readFirstString(assetRaw, ["id", "asset_id"])) != null ? _b6 : readFirstString(payload, ["assetId", "asset_id"]);
4543
4574
  if (!assetId) {
4544
4575
  throw new TelescupClientError("Resposta inv\xE1lida ao finalizar upload no Telescup.");
4545
4576
  }
4546
4577
  return { asset: { id: assetId } };
4547
4578
  };
4548
4579
  var toMetaPayloadForFunctions = (payload) => {
4549
- var _a65, _b5;
4580
+ var _a72, _b6;
4550
4581
  if (TELESCUP_UPDATE_META_FUNCTION === "update-asset-meta") {
4551
- const categories = ((_a65 = payload.meta) == null ? void 0 : _a65.category) ? [payload.meta.category] : [];
4582
+ const categories = ((_a72 = payload.meta) == null ? void 0 : _a72.category) ? [payload.meta.category] : [];
4552
4583
  return {
4553
4584
  asset_id: payload.assetId,
4554
4585
  categories
@@ -4563,7 +4594,7 @@ var toMetaPayloadForFunctions = (payload) => {
4563
4594
  en: {},
4564
4595
  es: {}
4565
4596
  };
4566
- const target = (_b5 = byLanguage[language]) != null ? _b5 : byLanguage.pt;
4597
+ const target = (_b6 = byLanguage[language]) != null ? _b6 : byLanguage.pt;
4567
4598
  if (payload.meta) {
4568
4599
  if (typeof payload.meta.alt === "string") target.alt = payload.meta.alt;
4569
4600
  if (typeof payload.meta.title === "string") target.title = payload.meta.title;
@@ -4659,7 +4690,7 @@ var createTelescupClient = (config) => ({
4659
4690
  body: toMetaPayloadForFunctions(payload)
4660
4691
  }),
4661
4692
  uploadDirect: async (file) => {
4662
- var _a65;
4693
+ var _a72;
4663
4694
  const token = await config.getAccessToken();
4664
4695
  const userId = resolveUserIdFromToken(token);
4665
4696
  if (!userId) {
@@ -4687,7 +4718,7 @@ var createTelescupClient = (config) => ({
4687
4718
  }
4688
4719
  });
4689
4720
  const payload = response != null ? response : {};
4690
- const asset = mapAssetApiSearchRowToAsset((_a65 = payload.asset) != null ? _a65 : {});
4721
+ const asset = mapAssetApiSearchRowToAsset((_a72 = payload.asset) != null ? _a72 : {});
4691
4722
  if (!asset) {
4692
4723
  throw new TelescupClientError("Resposta inv\xE1lida do upload direto (asset-api).");
4693
4724
  }
@@ -4759,9 +4790,9 @@ function useTelescupAssets(options) {
4759
4790
  ...sanitizeFilters(filters),
4760
4791
  pageSize
4761
4792
  }).then((data) => {
4762
- var _a65;
4793
+ var _a72;
4763
4794
  return {
4764
- items: (_a65 = data.items) != null ? _a65 : [],
4795
+ items: (_a72 = data.items) != null ? _a72 : [],
4765
4796
  nextCursor: data.nextCursor,
4766
4797
  total: data.total,
4767
4798
  facets: data.facets
@@ -4784,7 +4815,7 @@ function useTelescupAssets(options) {
4784
4815
  [cacheKey, cacheTimeMs, enabled, filters, pageSize, resolvedClient]
4785
4816
  );
4786
4817
  const loadMore = (0, import_react13.useCallback)(async () => {
4787
- var _a65, _b5, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
4818
+ var _a72, _b6, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
4788
4819
  if (!state.nextCursor || isLoadingMore || isLoading) return;
4789
4820
  const requestSeq = requestSeqRef.current;
4790
4821
  setIsLoadingMore(true);
@@ -4798,9 +4829,9 @@ function useTelescupAssets(options) {
4798
4829
  });
4799
4830
  if (!aliveRef.current || requestSeq !== requestSeqRef.current) return;
4800
4831
  const merged = {
4801
- items: [...state.items, ...(_a65 = data.items) != null ? _a65 : []],
4832
+ items: [...state.items, ...(_a72 = data.items) != null ? _a72 : []],
4802
4833
  nextCursor: data.nextCursor,
4803
- total: (_b5 = data.total) != null ? _b5 : state.total,
4834
+ total: (_b6 = data.total) != null ? _b6 : state.total,
4804
4835
  facets: {
4805
4836
  categories: (_d = (_c = data.facets) == null ? void 0 : _c.categories) != null ? _d : previousFacets == null ? void 0 : previousFacets.categories,
4806
4837
  folders: (_f = (_e = data.facets) == null ? void 0 : _e.folders) != null ? _f : previousFacets == null ? void 0 : previousFacets.folders,
@@ -4949,12 +4980,12 @@ var IMAGE_EXTENSIONS = /* @__PURE__ */ new Set(["jpg", "jpeg", "png", "gif", "we
4949
4980
  var VIDEO_EXTENSIONS = /* @__PURE__ */ new Set(["mp4", "mov", "webm", "mkv", "avi", "m4v", "wmv"]);
4950
4981
  var AUDIO_EXTENSIONS = /* @__PURE__ */ new Set(["mp3", "wav", "aac", "ogg", "flac", "m4a"]);
4951
4982
  var resolveAssetFamily = (asset) => {
4952
- var _a65, _b5, _c;
4953
- const explicitType = (_a65 = asset.type) == null ? void 0 : _a65.toLowerCase();
4983
+ var _a72, _b6, _c;
4984
+ const explicitType = (_a72 = asset.type) == null ? void 0 : _a72.toLowerCase();
4954
4985
  if (explicitType === "image" || explicitType === "video" || explicitType === "audio" || explicitType === "file") {
4955
4986
  return explicitType;
4956
4987
  }
4957
- const mime = (_b5 = asset.mimeType) == null ? void 0 : _b5.toLowerCase();
4988
+ const mime = (_b6 = asset.mimeType) == null ? void 0 : _b6.toLowerCase();
4958
4989
  if (mime == null ? void 0 : mime.startsWith("image/")) return "image";
4959
4990
  if (mime == null ? void 0 : mime.startsWith("video/")) return "video";
4960
4991
  if (mime == null ? void 0 : mime.startsWith("audio/")) return "audio";
@@ -4966,9 +4997,9 @@ var resolveAssetFamily = (asset) => {
4966
4997
  return "file";
4967
4998
  };
4968
4999
  var matchesAllowedAsset = (asset, allowed) => {
4969
- var _a65, _b5, _c, _d;
5000
+ var _a72, _b6, _c, _d;
4970
5001
  if (!allowed || allowed.length === 0) return true;
4971
- const mime = (_b5 = (_a65 = asset.mimeType) == null ? void 0 : _a65.toLowerCase()) != null ? _b5 : "";
5002
+ const mime = (_b6 = (_a72 = asset.mimeType) == null ? void 0 : _a72.toLowerCase()) != null ? _b6 : "";
4972
5003
  const ext = asset.extension ? `.${asset.extension.toLowerCase()}` : "";
4973
5004
  const type = (_d = (_c = asset.type) == null ? void 0 : _c.toLowerCase()) != null ? _d : "";
4974
5005
  const family = resolveAssetFamily(asset);
@@ -5014,12 +5045,12 @@ var getPreview = (asset) => {
5014
5045
  var normalizeFacetOptions = (entries) => {
5015
5046
  if (!entries || !entries.length) return [];
5016
5047
  return entries.reduce((acc, entry) => {
5017
- var _a65, _b5;
5018
- const value = (_a65 = entry.value) == null ? void 0 : _a65.trim();
5048
+ var _a72, _b6;
5049
+ const value = (_a72 = entry.value) == null ? void 0 : _a72.trim();
5019
5050
  if (!value) return acc;
5020
5051
  acc.push({
5021
5052
  value,
5022
- label: ((_b5 = entry.label) == null ? void 0 : _b5.trim()) || value,
5053
+ label: ((_b6 = entry.label) == null ? void 0 : _b6.trim()) || value,
5023
5054
  count: typeof entry.count === "number" ? entry.count : void 0
5024
5055
  });
5025
5056
  return acc;
@@ -5028,13 +5059,13 @@ var normalizeFacetOptions = (entries) => {
5028
5059
  var collectFacetOptions = (items, pick, pickLabel) => {
5029
5060
  const options = /* @__PURE__ */ new Map();
5030
5061
  items.forEach((asset) => {
5031
- var _a65, _b5, _c;
5032
- const value = (_a65 = pick(asset)) == null ? void 0 : _a65.trim();
5062
+ var _a72, _b6, _c;
5063
+ const value = (_a72 = pick(asset)) == null ? void 0 : _a72.trim();
5033
5064
  if (!value) return;
5034
5065
  const current = options.get(value);
5035
5066
  options.set(value, {
5036
5067
  value,
5037
- label: ((_b5 = pickLabel == null ? void 0 : pickLabel(asset)) == null ? void 0 : _b5.trim()) || (current == null ? void 0 : current.label) || value,
5068
+ label: ((_b6 = pickLabel == null ? void 0 : pickLabel(asset)) == null ? void 0 : _b6.trim()) || (current == null ? void 0 : current.label) || value,
5038
5069
  count: ((_c = current == null ? void 0 : current.count) != null ? _c : 0) + 1
5039
5070
  });
5040
5071
  });
@@ -5289,7 +5320,7 @@ function useTelescupUploadQueue(options) {
5289
5320
  activeRef.current += 1;
5290
5321
  updateItem(next.id, { status: "uploading", progress: 0, error: void 0 });
5291
5322
  const run = async () => {
5292
- var _a65, _b5, _c;
5323
+ var _a72, _b6, _c;
5293
5324
  try {
5294
5325
  if (TELESCUP_UPLOAD_MODE === "direct") {
5295
5326
  const completed2 = await client.uploadDirect(next.file);
@@ -5308,7 +5339,7 @@ function useTelescupUploadQueue(options) {
5308
5339
  size: next.file.size,
5309
5340
  mimeType: next.file.type,
5310
5341
  folderId,
5311
- conflict: (_a65 = next.conflictPolicy) != null ? _a65 : conflictPolicy
5342
+ conflict: (_a72 = next.conflictPolicy) != null ? _a72 : conflictPolicy
5312
5343
  });
5313
5344
  const conflictDetected = init.conflict === "ask" || init.conflict === "conflict" || init.conflict === "exists" || init.existingAsset && !init.uploadUrl;
5314
5345
  if (conflictDetected) {
@@ -5347,7 +5378,7 @@ function useTelescupUploadQueue(options) {
5347
5378
  storageKey: init.storageKey,
5348
5379
  finalFilename: init.finalFilename,
5349
5380
  folderId,
5350
- assetId: (_b5 = init.asset) == null ? void 0 : _b5.id,
5381
+ assetId: (_b6 = init.asset) == null ? void 0 : _b6.id,
5351
5382
  fileName: (_c = init.resolvedName) != null ? _c : next.file.name
5352
5383
  });
5353
5384
  updateItem(next.id, {
@@ -5446,7 +5477,7 @@ var TelescupUploader = ({
5446
5477
  className,
5447
5478
  onAssetUploaded
5448
5479
  }) => {
5449
- var _a65;
5480
+ var _a72;
5450
5481
  const inputRef = (0, import_react16.useRef)(null);
5451
5482
  const [dragActive, setDragActive] = (0, import_react16.useState)(false);
5452
5483
  const {
@@ -5513,8 +5544,8 @@ var TelescupUploader = ({
5513
5544
  size: "sm",
5514
5545
  variant: "secondary",
5515
5546
  onClick: () => {
5516
- var _a66;
5517
- return (_a66 = inputRef.current) == null ? void 0 : _a66.click();
5547
+ var _a73;
5548
+ return (_a73 = inputRef.current) == null ? void 0 : _a73.click();
5518
5549
  },
5519
5550
  children: labels.uploader.browse
5520
5551
  }
@@ -5528,8 +5559,8 @@ var TelescupUploader = ({
5528
5559
  accept,
5529
5560
  multiple,
5530
5561
  onChange: (event) => {
5531
- var _a66;
5532
- if ((_a66 = event.target.files) == null ? void 0 : _a66.length) {
5562
+ var _a73;
5563
+ if ((_a73 = event.target.files) == null ? void 0 : _a73.length) {
5533
5564
  handleFiles(event.target.files);
5534
5565
  event.currentTarget.value = "";
5535
5566
  }
@@ -5564,7 +5595,7 @@ var TelescupUploader = ({
5564
5595
  /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(AlertDialogTitle, { children: labels.conflict.title }),
5565
5596
  /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(AlertDialogDescription, { children: labels.conflict.description })
5566
5597
  ] }),
5567
- ((_a65 = conflictItem == null ? void 0 : conflictItem.existingAsset) == null ? void 0 : _a65.id) ? /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "mt-3 rounded-lg border border-border bg-muted/30 p-3", children: [
5598
+ ((_a72 = conflictItem == null ? void 0 : conflictItem.existingAsset) == null ? void 0 : _a72.id) ? /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "mt-3 rounded-lg border border-border bg-muted/30 p-3", children: [
5568
5599
  /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("p", { className: "text-xs font-semibold text-muted-foreground", children: "Asset existente" }),
5569
5600
  /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: "mt-2 h-28 overflow-hidden rounded-md", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
5570
5601
  TelescupImage,
@@ -5787,7 +5818,7 @@ var DEFAULT_LABELS = {
5787
5818
  }
5788
5819
  };
5789
5820
  var mergeLabels = (overrides) => {
5790
- var _a65;
5821
+ var _a72;
5791
5822
  if (!overrides) return DEFAULT_LABELS;
5792
5823
  return {
5793
5824
  ...DEFAULT_LABELS,
@@ -5801,17 +5832,17 @@ var mergeLabels = (overrides) => {
5801
5832
  meta: {
5802
5833
  ...DEFAULT_LABELS.meta,
5803
5834
  ...overrides.meta,
5804
- fields: { ...DEFAULT_LABELS.meta.fields, ...(_a65 = overrides.meta) == null ? void 0 : _a65.fields }
5835
+ fields: { ...DEFAULT_LABELS.meta.fields, ...(_a72 = overrides.meta) == null ? void 0 : _a72.fields }
5805
5836
  },
5806
5837
  toasts: { ...DEFAULT_LABELS.toasts, ...overrides.toasts }
5807
5838
  };
5808
5839
  };
5809
5840
  var LANGUAGES = ["pt", "en", "es"];
5810
5841
  var getAssetMeta = (asset, lang) => {
5811
- var _a65, _b5;
5842
+ var _a72, _b6;
5812
5843
  if (!asset) return {};
5813
- if ((_a65 = asset.metaByLang) == null ? void 0 : _a65[lang]) return asset.metaByLang[lang];
5814
- return (_b5 = asset.meta) != null ? _b5 : {};
5844
+ if ((_a72 = asset.metaByLang) == null ? void 0 : _a72[lang]) return asset.metaByLang[lang];
5845
+ return (_b6 = asset.meta) != null ? _b6 : {};
5815
5846
  };
5816
5847
  var TelescupMetaEditor = ({
5817
5848
  client,
@@ -5821,8 +5852,8 @@ var TelescupMetaEditor = ({
5821
5852
  labels,
5822
5853
  onAssetUpdated
5823
5854
  }) => {
5824
- var _a65, _b5, _c, _d, _e, _f, _g, _h;
5825
- const [activeAssetId, setActiveAssetId] = (0, import_react17.useState)((_b5 = (_a65 = assets[0]) == null ? void 0 : _a65.id) != null ? _b5 : "");
5855
+ var _a72, _b6, _c, _d, _e, _f, _g, _h;
5856
+ const [activeAssetId, setActiveAssetId] = (0, import_react17.useState)((_b6 = (_a72 = assets[0]) == null ? void 0 : _a72.id) != null ? _b6 : "");
5826
5857
  const [activeLang, setActiveLang] = (0, import_react17.useState)(
5827
5858
  LANGUAGES.includes(defaultLanguage) ? defaultLanguage : "pt"
5828
5859
  );
@@ -5840,18 +5871,18 @@ var TelescupMetaEditor = ({
5840
5871
  }, [activeAssetId, assets]);
5841
5872
  const asset = assets.find((item) => item.id === activeAssetId);
5842
5873
  const currentDraft = (0, import_react17.useMemo)(() => {
5843
- var _a66;
5844
- const existing = (_a66 = drafts[activeAssetId]) == null ? void 0 : _a66[activeLang];
5874
+ var _a73;
5875
+ const existing = (_a73 = drafts[activeAssetId]) == null ? void 0 : _a73[activeLang];
5845
5876
  if (existing) return existing;
5846
5877
  return getAssetMeta(asset, activeLang);
5847
5878
  }, [activeAssetId, activeLang, asset, drafts]);
5848
5879
  const updateDraft = (field, value) => {
5849
5880
  setDrafts((prev) => {
5850
- var _a66;
5881
+ var _a73;
5851
5882
  return {
5852
5883
  ...prev,
5853
5884
  [activeAssetId]: {
5854
- ...(_a66 = prev[activeAssetId]) != null ? _a66 : {},
5885
+ ...(_a73 = prev[activeAssetId]) != null ? _a73 : {},
5855
5886
  [activeLang]: {
5856
5887
  ...currentDraft,
5857
5888
  [field]: value
@@ -5919,11 +5950,11 @@ var TelescupMetaEditor = ({
5919
5950
  onAssetUpdated == null ? void 0 : onAssetUpdated(updated);
5920
5951
  const updatedMeta = getAssetMeta(updated, activeLang);
5921
5952
  setDrafts((prev) => {
5922
- var _a66;
5953
+ var _a73;
5923
5954
  return {
5924
5955
  ...prev,
5925
5956
  [asset.id]: {
5926
- ...(_a66 = prev[asset.id]) != null ? _a66 : {},
5957
+ ...(_a73 = prev[asset.id]) != null ? _a73 : {},
5927
5958
  [activeLang]: updatedMeta
5928
5959
  }
5929
5960
  };
@@ -6499,16 +6530,16 @@ var normalizeContrastMode = (value) => {
6499
6530
  return (value == null ? void 0 : value.trim().toLowerCase()) === "high" ? "high" : "normal";
6500
6531
  };
6501
6532
  var readStoredExperienceSettings = () => {
6502
- var _a65, _b5, _c;
6533
+ var _a72, _b6, _c;
6503
6534
  const fallback = defaultExperienceSettings();
6504
6535
  if (typeof window === "undefined") return fallback;
6505
6536
  try {
6506
6537
  const raw = window.localStorage.getItem(EXPERIENCE_SETTINGS_STORAGE_KEY);
6507
6538
  const parsed = raw ? JSON.parse(raw) : null;
6508
6539
  const storedThemePreference = window.localStorage.getItem(THEME_PREFERENCE_STORAGE_KEY);
6509
- const legacyTheme = (_a65 = window.localStorage.getItem(THEME_STORAGE_KEY)) != null ? _a65 : window.localStorage.getItem(LEGACY_THEME_STORAGE_KEY);
6540
+ const legacyTheme = (_a72 = window.localStorage.getItem(THEME_STORAGE_KEY)) != null ? _a72 : window.localStorage.getItem(LEGACY_THEME_STORAGE_KEY);
6510
6541
  return {
6511
- theme: normalizeThemePreference((_c = (_b5 = parsed == null ? void 0 : parsed.theme) != null ? _b5 : storedThemePreference) != null ? _c : legacyTheme),
6542
+ theme: normalizeThemePreference((_c = (_b6 = parsed == null ? void 0 : parsed.theme) != null ? _b6 : storedThemePreference) != null ? _c : legacyTheme),
6512
6543
  density: normalizeDensityMode(parsed == null ? void 0 : parsed.density),
6513
6544
  contrast: normalizeContrastMode(parsed == null ? void 0 : parsed.contrast),
6514
6545
  showEmailPublicly: typeof (parsed == null ? void 0 : parsed.showEmailPublicly) === "boolean" ? parsed.showEmailPublicly : fallback.showEmailPublicly
@@ -6650,7 +6681,7 @@ var getNotificationTimestamp = (notification) => {
6650
6681
  return Number.isNaN(parsed) ? 0 : parsed;
6651
6682
  };
6652
6683
  var formatNotificationDateTime = (notification) => {
6653
- var _a65;
6684
+ var _a72;
6654
6685
  if (notification.createdAt) {
6655
6686
  const parsed = new Date(notification.createdAt);
6656
6687
  if (!Number.isNaN(parsed.getTime())) {
@@ -6662,7 +6693,7 @@ var formatNotificationDateTime = (notification) => {
6662
6693
  });
6663
6694
  }
6664
6695
  }
6665
- return ((_a65 = notification.timeLabel) == null ? void 0 : _a65.trim()) || "Agora";
6696
+ return ((_a72 = notification.timeLabel) == null ? void 0 : _a72.trim()) || "Agora";
6666
6697
  };
6667
6698
  var getNotificationDayKey = (notification) => {
6668
6699
  const timestamp = getNotificationTimestamp(notification);
@@ -6735,30 +6766,22 @@ var extractSharedFilesFromMessages = (messages) => {
6735
6766
  return files;
6736
6767
  };
6737
6768
  var resolveTelescupImageUrl = (value, options) => {
6738
- var _a65, _b5, _c;
6739
- const width = (_a65 = options == null ? void 0 : options.width) != null ? _a65 : 96;
6740
- const height = (_b5 = options == null ? void 0 : options.height) != null ? _b5 : 96;
6741
- const quality = (_c = options == null ? void 0 : options.quality) != null ? _c : 72;
6742
- const raw = value == null ? void 0 : value.trim();
6743
- if (!raw) return void 0;
6744
- if (raw.startsWith("http://") || raw.startsWith("https://") || raw.startsWith("data:") || raw.startsWith("blob:")) {
6745
- const parsedId2 = parseAssetId(raw);
6746
- if (parsedId2) {
6747
- return buildTelescupImageURL({ id: parsedId2, width, height, fit: "cover", format: "avif", quality });
6748
- }
6749
- return raw;
6750
- }
6751
- const parsedId = parseAssetId(raw);
6752
- if (!parsedId) return void 0;
6753
- return buildTelescupImageURL({ id: parsedId, width, height, fit: "cover", format: "avif", quality });
6769
+ var _a72, _b6, _c;
6770
+ return resolveTelescupImageURL(value, {
6771
+ width: (_a72 = options == null ? void 0 : options.width) != null ? _a72 : 96,
6772
+ height: (_b6 = options == null ? void 0 : options.height) != null ? _b6 : 96,
6773
+ fit: "cover",
6774
+ format: "avif",
6775
+ quality: (_c = options == null ? void 0 : options.quality) != null ? _c : 72
6776
+ });
6754
6777
  };
6755
6778
  var resolveGroupAvatarFromTelescup = (asset, fallbackId) => {
6756
- var _a65, _b5;
6757
- return (_b5 = (_a65 = resolveTelescupImageUrl(asset == null ? void 0 : asset.url)) != null ? _a65 : resolveTelescupImageUrl(asset == null ? void 0 : asset.id)) != null ? _b5 : resolveTelescupImageUrl(fallbackId);
6779
+ var _a72, _b6;
6780
+ return (_b6 = (_a72 = resolveTelescupImageUrl(asset == null ? void 0 : asset.url)) != null ? _a72 : resolveTelescupImageUrl(asset == null ? void 0 : asset.id)) != null ? _b6 : resolveTelescupImageUrl(fallbackId);
6758
6781
  };
6759
6782
  var resolveProfileAvatarFromTelescup = (asset, fallbackId) => {
6760
- var _a65, _b5;
6761
- return (_b5 = (_a65 = resolveTelescupImageUrl(asset == null ? void 0 : asset.url, { width: 384, height: 384, quality: 80 })) != null ? _a65 : resolveTelescupImageUrl(asset == null ? void 0 : asset.id, { width: 384, height: 384, quality: 80 })) != null ? _b5 : resolveTelescupImageUrl(fallbackId, { width: 384, height: 384, quality: 80 });
6783
+ var _a72, _b6;
6784
+ return (_b6 = (_a72 = resolveTelescupImageUrl(asset == null ? void 0 : asset.url, { width: 384, height: 384, quality: 80 })) != null ? _a72 : resolveTelescupImageUrl(asset == null ? void 0 : asset.id, { width: 384, height: 384, quality: 80 })) != null ? _b6 : resolveTelescupImageUrl(fallbackId, { width: 384, height: 384, quality: 80 });
6762
6785
  };
6763
6786
  var playIncomingMessageSound = () => {
6764
6787
  if (typeof window === "undefined") return;
@@ -6891,7 +6914,7 @@ var UserMenuCupcode = ({
6891
6914
  panels,
6892
6915
  className
6893
6916
  }) => {
6894
- var _a65;
6917
+ var _a72;
6895
6918
  const [open, setOpen] = (0, import_react18.useState)(false);
6896
6919
  const [activeTab, setActiveTab] = (0, import_react18.useState)("profile");
6897
6920
  const [isLoggingOut, setIsLoggingOut] = (0, import_react18.useState)(false);
@@ -6993,12 +7016,12 @@ var UserMenuCupcode = ({
6993
7016
  );
6994
7017
  const normalizedNotificationFeed = (0, import_react18.useMemo)(
6995
7018
  () => resolvedNotificationFeed.map((notification) => {
6996
- var _a66;
7019
+ var _a73;
6997
7020
  const kind = normalizeNotificationKind(notification.kind);
6998
7021
  return {
6999
7022
  ...notification,
7000
7023
  kind,
7001
- topic: (_a66 = notification.topic) != null ? _a66 : NOTIFICATION_KIND_META[kind].topicFallback
7024
+ topic: (_a73 = notification.topic) != null ? _a73 : NOTIFICATION_KIND_META[kind].topicFallback
7002
7025
  };
7003
7026
  }),
7004
7027
  [resolvedNotificationFeed]
@@ -7033,10 +7056,10 @@ var UserMenuCupcode = ({
7033
7056
  const groupedNotifications = (0, import_react18.useMemo)(() => {
7034
7057
  const groups = /* @__PURE__ */ new Map();
7035
7058
  filteredNotifications.forEach((notification) => {
7036
- var _a66, _b5;
7059
+ var _a73, _b6;
7037
7060
  const kind = normalizeNotificationKind(notification.kind);
7038
- const key = notificationPreferences.grouping === "topic" ? (_a66 = notification.topic) != null ? _a66 : NOTIFICATION_KIND_META[kind].topicFallback : getNotificationDayKey(notification);
7039
- const current = (_b5 = groups.get(key)) != null ? _b5 : [];
7061
+ const key = notificationPreferences.grouping === "topic" ? (_a73 = notification.topic) != null ? _a73 : NOTIFICATION_KIND_META[kind].topicFallback : getNotificationDayKey(notification);
7062
+ const current = (_b6 = groups.get(key)) != null ? _b6 : [];
7040
7063
  current.push(notification);
7041
7064
  groups.set(key, current);
7042
7065
  });
@@ -7123,7 +7146,7 @@ var UserMenuCupcode = ({
7123
7146
  }).slice(0, 6);
7124
7147
  }, [recentActivity]);
7125
7148
  const isSendingChatMessage = isChatSending || isSendingInternalChatMessage;
7126
- const activeReactionPickerMessageId = (_a65 = activeReactionPicker == null ? void 0 : activeReactionPicker.messageId) != null ? _a65 : null;
7149
+ const activeReactionPickerMessageId = (_a72 = activeReactionPicker == null ? void 0 : activeReactionPicker.messageId) != null ? _a72 : null;
7127
7150
  const isChatSidebarOpen = isChatSidebarExpanded || isChatSidebarPinned;
7128
7151
  const hasTelescupAvatarSupport = Boolean(telescupBaseUrl && getTelescupAccessToken);
7129
7152
  const hasTelescupGroupAvatarSupport = hasTelescupAvatarSupport;
@@ -7137,8 +7160,8 @@ var UserMenuCupcode = ({
7137
7160
  meta.set(user.id, { lastMessage: null, lastTimestamp: 0, unreadCount: 0 });
7138
7161
  });
7139
7162
  resolvedAllChatMessages.forEach((message) => {
7140
- var _a66;
7141
- const current = (_a66 = meta.get(message.contactId)) != null ? _a66 : { lastMessage: null, lastTimestamp: 0, unreadCount: 0 };
7163
+ var _a73;
7164
+ const current = (_a73 = meta.get(message.contactId)) != null ? _a73 : { lastMessage: null, lastTimestamp: 0, unreadCount: 0 };
7142
7165
  const timestamp = getChatMessageTimestamp(message);
7143
7166
  if (timestamp >= current.lastTimestamp) {
7144
7167
  current.lastTimestamp = timestamp;
@@ -7158,11 +7181,11 @@ var UserMenuCupcode = ({
7158
7181
  return haystack.includes(query);
7159
7182
  });
7160
7183
  return filtered.sort((left, right) => {
7161
- var _a66, _b5, _c, _d;
7184
+ var _a73, _b6, _c, _d;
7162
7185
  const leftMeta = conversationMetaByUserId.get(left.id);
7163
7186
  const rightMeta = conversationMetaByUserId.get(right.id);
7164
- const leftUnread = (_a66 = leftMeta == null ? void 0 : leftMeta.unreadCount) != null ? _a66 : 0;
7165
- const rightUnread = (_b5 = rightMeta == null ? void 0 : rightMeta.unreadCount) != null ? _b5 : 0;
7187
+ const leftUnread = (_a73 = leftMeta == null ? void 0 : leftMeta.unreadCount) != null ? _a73 : 0;
7188
+ const rightUnread = (_b6 = rightMeta == null ? void 0 : rightMeta.unreadCount) != null ? _b6 : 0;
7166
7189
  if (leftUnread !== rightUnread) return rightUnread - leftUnread;
7167
7190
  const leftTimestamp = (_c = leftMeta == null ? void 0 : leftMeta.lastTimestamp) != null ? _c : 0;
7168
7191
  const rightTimestamp = (_d = rightMeta == null ? void 0 : rightMeta.lastTimestamp) != null ? _d : 0;
@@ -7211,11 +7234,11 @@ var UserMenuCupcode = ({
7211
7234
  let changed = false;
7212
7235
  const next = { ...current };
7213
7236
  normalizedNotificationFeed.forEach((notification) => {
7214
- var _a66;
7237
+ var _a73;
7215
7238
  if (normalizeNotificationKind(notification.kind) !== "chat") return;
7216
7239
  const contactId = notification.actionChatUserId;
7217
7240
  if (!contactId) return;
7218
- if (((_a66 = resolvedChatUnreadByUser[contactId]) != null ? _a66 : 0) > 0) return;
7241
+ if (((_a73 = resolvedChatUnreadByUser[contactId]) != null ? _a73 : 0) > 0) return;
7219
7242
  if (next[notification.id] === true) return;
7220
7243
  next[notification.id] = true;
7221
7244
  changed = true;
@@ -7229,11 +7252,11 @@ var UserMenuCupcode = ({
7229
7252
  const visibleChatUnreadCount = resolvedChatUnreadCount;
7230
7253
  const firstUnreadChatUserId = (0, import_react18.useMemo)(
7231
7254
  () => {
7232
- var _a66, _b5;
7233
- return (_b5 = (_a66 = filteredAndSortedChatUsers.find((user) => {
7234
- var _a67;
7235
- return ((_a67 = resolvedChatUnreadByUser[user.id]) != null ? _a67 : 0) > 0;
7236
- })) == null ? void 0 : _a66.id) != null ? _b5 : null;
7255
+ var _a73, _b6;
7256
+ return (_b6 = (_a73 = filteredAndSortedChatUsers.find((user) => {
7257
+ var _a74;
7258
+ return ((_a74 = resolvedChatUnreadByUser[user.id]) != null ? _a74 : 0) > 0;
7259
+ })) == null ? void 0 : _a73.id) != null ? _b6 : null;
7237
7260
  },
7238
7261
  [filteredAndSortedChatUsers, resolvedChatUnreadByUser]
7239
7262
  );
@@ -7292,11 +7315,11 @@ var UserMenuCupcode = ({
7292
7315
  );
7293
7316
  const openChatPanel = (0, import_react18.useCallback)(
7294
7317
  (contactId) => {
7295
- var _a66, _b5, _c, _d, _e;
7318
+ var _a73, _b6, _c, _d, _e;
7296
7319
  setIsLogoutConfirmOpen(false);
7297
7320
  setOpen(true);
7298
7321
  setActiveTab("chat");
7299
- const targetContactId = (_e = (_d = (_b5 = contactId != null ? contactId : firstUnreadChatUserId) != null ? _b5 : (_a66 = filteredAndSortedChatUsers[0]) == null ? void 0 : _a66.id) != null ? _d : (_c = chatUsersList[0]) == null ? void 0 : _c.id) != null ? _e : "";
7322
+ const targetContactId = (_e = (_d = (_b6 = contactId != null ? contactId : firstUnreadChatUserId) != null ? _b6 : (_a73 = filteredAndSortedChatUsers[0]) == null ? void 0 : _a73.id) != null ? _d : (_c = chatUsersList[0]) == null ? void 0 : _c.id) != null ? _e : "";
7300
7323
  if (!targetContactId) return;
7301
7324
  setActiveChatUserId(targetContactId);
7302
7325
  markConversationRead(targetContactId);
@@ -7330,9 +7353,9 @@ var UserMenuCupcode = ({
7330
7353
  const reactionsByMessageId = (0, import_react18.useMemo)(() => {
7331
7354
  const grouped = /* @__PURE__ */ new Map();
7332
7355
  resolvedAllChatReactions.forEach((reaction) => {
7333
- var _a66, _b5;
7334
- const byEmoji = (_a66 = grouped.get(reaction.messageId)) != null ? _a66 : /* @__PURE__ */ new Map();
7335
- const current = (_b5 = byEmoji.get(reaction.emoji)) != null ? _b5 : { emoji: reaction.emoji, count: 0, reactedByMe: false };
7356
+ var _a73, _b6;
7357
+ const byEmoji = (_a73 = grouped.get(reaction.messageId)) != null ? _a73 : /* @__PURE__ */ new Map();
7358
+ const current = (_b6 = byEmoji.get(reaction.emoji)) != null ? _b6 : { emoji: reaction.emoji, count: 0, reactedByMe: false };
7336
7359
  current.count += 1;
7337
7360
  if (resolvedCurrentChatUserId && reaction.userId === resolvedCurrentChatUserId) {
7338
7361
  current.reactedByMe = true;
@@ -7529,9 +7552,9 @@ var UserMenuCupcode = ({
7529
7552
  const wasFocusModeActive = wasFocusModeActiveRef.current;
7530
7553
  if (wasFocusModeActive && !isFocusModeActive && suppressedFocusNotifications.length) {
7531
7554
  const byType = suppressedFocusNotifications.reduce((acc, notification) => {
7532
- var _a66;
7555
+ var _a73;
7533
7556
  const kind = normalizeNotificationKind(notification.kind);
7534
- acc[kind] = ((_a66 = acc[kind]) != null ? _a66 : 0) + 1;
7557
+ acc[kind] = ((_a73 = acc[kind]) != null ? _a73 : 0) + 1;
7535
7558
  return acc;
7536
7559
  }, { system: 0, comment: 0, access: 0, billing: 0, chat: 0, security: 0 });
7537
7560
  const summaryParts = NOTIFICATION_KIND_ORDER.filter((kind) => byType[kind] > 0).map(
@@ -7561,9 +7584,9 @@ var UserMenuCupcode = ({
7561
7584
  return;
7562
7585
  }
7563
7586
  setActiveChatUserId((current) => {
7564
- var _a66, _b5;
7587
+ var _a73, _b6;
7565
7588
  if (current && chatUsersList.some((user) => user.id === current)) return current;
7566
- return (_b5 = (_a66 = filteredAndSortedChatUsers[0]) == null ? void 0 : _a66.id) != null ? _b5 : chatUsersList[0].id;
7589
+ return (_b6 = (_a73 = filteredAndSortedChatUsers[0]) == null ? void 0 : _a73.id) != null ? _b6 : chatUsersList[0].id;
7567
7590
  });
7568
7591
  }, [chatUsersList, filteredAndSortedChatUsers]);
7569
7592
  (0, import_react18.useEffect)(() => {
@@ -7605,7 +7628,7 @@ var UserMenuCupcode = ({
7605
7628
  };
7606
7629
  }, [activeReactionPickerMessageId]);
7607
7630
  (0, import_react18.useEffect)(() => {
7608
- var _a66;
7631
+ var _a73;
7609
7632
  if (!hasBootstrappedIncomingMessagesRef.current && isChatLoading) return;
7610
7633
  const knownIncomingIds = seenIncomingMessageIdsRef.current;
7611
7634
  const incomingMessages = resolvedAllChatMessages.filter((message) => message.sender === "them" && !message.readAt);
@@ -7627,14 +7650,14 @@ var UserMenuCupcode = ({
7627
7650
  return;
7628
7651
  }
7629
7652
  const generatedNotifications = relevantIncomingMessages.map((message) => {
7630
- var _a67, _b5, _c;
7653
+ var _a74, _b6, _c;
7631
7654
  const contact = chatUsersList.find((user) => user.id === message.contactId);
7632
- const createdAt = (_a67 = message.createdAt) != null ? _a67 : (/* @__PURE__ */ new Date()).toISOString();
7655
+ const createdAt = (_a74 = message.createdAt) != null ? _a74 : (/* @__PURE__ */ new Date()).toISOString();
7633
7656
  const previewText = chatSettings.showMessagePreview ? summarizeChatText(message.text, 100) : "Nova mensagem no chat.";
7634
7657
  return {
7635
7658
  id: `chat-notification-${message.id}`,
7636
7659
  kind: "chat",
7637
- title: `Mensagem de ${(_b5 = contact == null ? void 0 : contact.name) != null ? _b5 : "usu\xE1rio"}`,
7660
+ title: `Mensagem de ${(_b6 = contact == null ? void 0 : contact.name) != null ? _b6 : "usu\xE1rio"}`,
7638
7661
  description: previewText,
7639
7662
  createdAt,
7640
7663
  timeLabel: formatChatTime({ ...message, createdAt }),
@@ -7651,7 +7674,7 @@ var UserMenuCupcode = ({
7651
7674
  )[0];
7652
7675
  if (latestRelevantMessage) {
7653
7676
  const latestContact = chatUsersList.find((user) => user.id === latestRelevantMessage.contactId);
7654
- const senderName = (_a66 = latestContact == null ? void 0 : latestContact.name) != null ? _a66 : "usu\xE1rio";
7677
+ const senderName = (_a73 = latestContact == null ? void 0 : latestContact.name) != null ? _a73 : "usu\xE1rio";
7655
7678
  const latestPreview = chatSettings.showMessagePreview ? summarizeChatText(latestRelevantMessage.text, 96) : "Nova mensagem";
7656
7679
  const messageCount = relevantIncomingMessages.length;
7657
7680
  const messageCountLabel = messageCount > 99 ? "99+" : String(messageCount);
@@ -7700,10 +7723,10 @@ var UserMenuCupcode = ({
7700
7723
  return;
7701
7724
  }
7702
7725
  generatedNotifications.forEach((chatNotification) => {
7703
- var _a67;
7726
+ var _a74;
7704
7727
  const notification = new Notification(chatNotification.title, {
7705
7728
  body: chatSettings.showMessagePreview ? chatNotification.description : "Voc\xEA recebeu uma nova mensagem.",
7706
- tag: `cc-chat-${(_a67 = chatNotification.actionChatUserId) != null ? _a67 : chatNotification.id}`
7729
+ tag: `cc-chat-${(_a74 = chatNotification.actionChatUserId) != null ? _a74 : chatNotification.id}`
7707
7730
  });
7708
7731
  notification.onclick = () => {
7709
7732
  window.focus();
@@ -7730,14 +7753,14 @@ var UserMenuCupcode = ({
7730
7753
  ]);
7731
7754
  const activeChatUser = (0, import_react18.useMemo)(
7732
7755
  () => {
7733
- var _a66;
7734
- return (_a66 = chatUsersList.find((user) => user.id === activeChatUserId)) != null ? _a66 : null;
7756
+ var _a73;
7757
+ return (_a73 = chatUsersList.find((user) => user.id === activeChatUserId)) != null ? _a73 : null;
7735
7758
  },
7736
7759
  [activeChatUserId, chatUsersList]
7737
7760
  );
7738
7761
  const activeGroupMembers = (0, import_react18.useMemo)(() => {
7739
- var _a66;
7740
- if (!(activeChatUser == null ? void 0 : activeChatUser.isGroup) || !((_a66 = activeChatUser.memberIds) == null ? void 0 : _a66.length)) return [];
7762
+ var _a73;
7763
+ if (!(activeChatUser == null ? void 0 : activeChatUser.isGroup) || !((_a73 = activeChatUser.memberIds) == null ? void 0 : _a73.length)) return [];
7741
7764
  const members = activeChatUser.memberIds.map((memberId) => baseChatUsersList.find((user) => user.id === memberId)).filter((member) => Boolean(member));
7742
7765
  return members;
7743
7766
  }, [activeChatUser, baseChatUsersList]);
@@ -7776,8 +7799,8 @@ var UserMenuCupcode = ({
7776
7799
  return items;
7777
7800
  }, [activeChatMessages]);
7778
7801
  (0, import_react18.useEffect)(() => {
7779
- var _a66;
7780
- const conversationId = (_a66 = activeChatUser == null ? void 0 : activeChatUser.id) != null ? _a66 : null;
7802
+ var _a73;
7803
+ const conversationId = (_a73 = activeChatUser == null ? void 0 : activeChatUser.id) != null ? _a73 : null;
7781
7804
  if (!conversationId) {
7782
7805
  activeConversationIdRef.current = null;
7783
7806
  activeConversationMessageIdsRef.current = /* @__PURE__ */ new Set();
@@ -7830,9 +7853,9 @@ var UserMenuCupcode = ({
7830
7853
  });
7831
7854
  }, [activeChatUser, resolvedChatLogs]);
7832
7855
  const replyToMessage = (0, import_react18.useMemo)(() => {
7833
- var _a66;
7856
+ var _a73;
7834
7857
  if (!replyToMessageId) return null;
7835
- return (_a66 = activeChatMessagesMap.get(replyToMessageId)) != null ? _a66 : null;
7858
+ return (_a73 = activeChatMessagesMap.get(replyToMessageId)) != null ? _a73 : null;
7836
7859
  }, [activeChatMessagesMap, replyToMessageId]);
7837
7860
  (0, import_react18.useEffect)(() => {
7838
7861
  if (!replyToMessageId) return;
@@ -7859,9 +7882,9 @@ var UserMenuCupcode = ({
7859
7882
  }
7860
7883
  }, [activeChatUser]);
7861
7884
  (0, import_react18.useEffect)(() => {
7862
- var _a66;
7885
+ var _a73;
7863
7886
  if (!open || activeTab !== "chat" || !activeChatUser || activeChatUser.isGroup) return;
7864
- const unreadCount = (_a66 = resolvedChatUnreadByUser[activeChatUser.id]) != null ? _a66 : 0;
7887
+ const unreadCount = (_a73 = resolvedChatUnreadByUser[activeChatUser.id]) != null ? _a73 : 0;
7865
7888
  if (unreadCount <= 0) return;
7866
7889
  const contactId = activeChatUser.id;
7867
7890
  if (pendingReadRequestsRef.current.has(contactId)) return;
@@ -7937,13 +7960,13 @@ var UserMenuCupcode = ({
7937
7960
  openAccountsPath("/security#sessions");
7938
7961
  };
7939
7962
  const runOpenIntegrations = (provider) => {
7940
- var _a66;
7963
+ var _a73;
7941
7964
  if (!provider) {
7942
7965
  openAccountsPath("/integrations");
7943
7966
  return;
7944
7967
  }
7945
7968
  const option = INTEGRATION_OPTIONS.find((integration) => integration.id === provider);
7946
- openAccountsPath((_a66 = option == null ? void 0 : option.accountPath) != null ? _a66 : "/integrations");
7969
+ openAccountsPath((_a73 = option == null ? void 0 : option.accountPath) != null ? _a73 : "/integrations");
7947
7970
  };
7948
7971
  const changeStatus = (nextStatus) => {
7949
7972
  if (nextStatus === "offline") return;
@@ -7952,6 +7975,18 @@ var UserMenuCupcode = ({
7952
7975
  }
7953
7976
  void (onStatusChange == null ? void 0 : onStatusChange(nextStatus));
7954
7977
  };
7978
+ const renderPresenceStatusOptions = () => {
7979
+ return PRESENCE_OPTIONS.map((option) => {
7980
+ const isCurrent = option === currentStatus;
7981
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(DropdownMenuItem, { onSelect: () => changeStatus(option), className: "text-xs", children: /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("span", { className: "flex w-full items-center justify-between gap-2", children: [
7982
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("span", { className: "flex items-center gap-2", children: [
7983
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(PresenceBadge, { status: option, size: "md" }),
7984
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("span", { children: PRESENCE_META[option].label })
7985
+ ] }),
7986
+ isCurrent ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_lucide_react9.Check, { className: "h-3.5 w-3.5 text-primary" }) : null
7987
+ ] }) }, option);
7988
+ });
7989
+ };
7955
7990
  const markNotificationAsRead = (notificationId) => {
7956
7991
  if (!notificationId) return;
7957
7992
  setNotificationReadMap((current) => ({
@@ -8298,10 +8333,10 @@ var UserMenuCupcode = ({
8298
8333
  };
8299
8334
  const handleProfileAvatarChange = (0, import_react18.useCallback)(
8300
8335
  async (ids, assets) => {
8301
- var _a66, _b5, _c;
8336
+ var _a73, _b6, _c;
8302
8337
  const selectedAsset = assets == null ? void 0 : assets[0];
8303
- const selectedIdRaw = (_a66 = ids[0]) == null ? void 0 : _a66.trim();
8304
- const selectedId = (_c = (_b5 = parseAssetId(selectedIdRaw)) != null ? _b5 : parseAssetId(selectedAsset == null ? void 0 : selectedAsset.id)) != null ? _c : parseAssetId(selectedAsset == null ? void 0 : selectedAsset.url);
8338
+ const selectedIdRaw = (_a73 = ids[0]) == null ? void 0 : _a73.trim();
8339
+ const selectedId = (_c = (_b6 = parseAssetId(selectedIdRaw)) != null ? _b6 : parseAssetId(selectedAsset == null ? void 0 : selectedAsset.id)) != null ? _c : parseAssetId(selectedAsset == null ? void 0 : selectedAsset.url);
8305
8340
  if (!selectedId) {
8306
8341
  toast({
8307
8342
  title: "Imagem inv\xE1lida",
@@ -8343,7 +8378,7 @@ var UserMenuCupcode = ({
8343
8378
  [isProfileAvatarSaving, onProfileAvatarChange, resolvedProfileAvatarUrl]
8344
8379
  );
8345
8380
  const sendChatMessage = async () => {
8346
- var _a66, _b5;
8381
+ var _a73, _b6;
8347
8382
  if (!activeChatUser) return;
8348
8383
  const text = chatDraft.trim();
8349
8384
  if (!text || isSendingChatMessage) return;
@@ -8355,7 +8390,7 @@ var UserMenuCupcode = ({
8355
8390
  await onChatSendMessage({
8356
8391
  recipientId: activeChatUser.id,
8357
8392
  text,
8358
- replyToMessageId: (_a66 = replyToMessage == null ? void 0 : replyToMessage.id) != null ? _a66 : null
8393
+ replyToMessageId: (_a73 = replyToMessage == null ? void 0 : replyToMessage.id) != null ? _a73 : null
8359
8394
  });
8360
8395
  setChatDraft("");
8361
8396
  setShowEmojiPicker(false);
@@ -8382,7 +8417,7 @@ var UserMenuCupcode = ({
8382
8417
  timeLabel,
8383
8418
  createdAt,
8384
8419
  readAt: null,
8385
- replyToMessageId: (_b5 = replyToMessage == null ? void 0 : replyToMessage.id) != null ? _b5 : null
8420
+ replyToMessageId: (_b6 = replyToMessage == null ? void 0 : replyToMessage.id) != null ? _b6 : null
8386
8421
  };
8387
8422
  if (isLocalGroupConversation) {
8388
8423
  setInternalGroupMessages((current) => [...current, message]);
@@ -8397,7 +8432,7 @@ var UserMenuCupcode = ({
8397
8432
  });
8398
8433
  };
8399
8434
  const renderDefaultPanel = () => {
8400
- var _a66, _b5, _c, _d;
8435
+ var _a73, _b6, _c, _d;
8401
8436
  if (activeTab === "profile") {
8402
8437
  return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: "space-y-4", children: [
8403
8438
  /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: "pt-1 text-center", children: [
@@ -8407,7 +8442,7 @@ var UserMenuCupcode = ({
8407
8442
  {
8408
8443
  type: "button",
8409
8444
  onClick: () => setIsProfileImageDialogOpen(true),
8410
- className: "block h-20 w-20 rounded-full transition-all hover:shadow-[0_0_0_2px_rgba(237,30,121,0.25),0_18px_24px_-22px_rgba(237,30,121,0.95)]",
8445
+ className: "block h-20 w-20 rounded-full transition-all hover:shadow-[0_0_0_2px_rgba(151,90,182,0.3),0_18px_24px_-22px_rgba(151,90,182,0.3)]",
8411
8446
  "aria-label": "Abrir foto de perfil",
8412
8447
  title: "Abrir foto de perfil",
8413
8448
  children: /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(Avatar2, { className: "h-20 w-20 border border-border/70 shadow-[var(--elevation-2)]", children: [
@@ -8421,22 +8456,13 @@ var UserMenuCupcode = ({
8421
8456
  "button",
8422
8457
  {
8423
8458
  type: "button",
8424
- className: "absolute -bottom-0.5 -right-0.5 inline-flex h-6 w-6 items-center justify-center rounded-full border border-border/70 bg-background/85 transition-all hover:bg-background",
8459
+ className: "absolute bottom-0 -right-0.5 inline-flex items-center justify-center rounded-full p-0.5 transition-transform hover:scale-110 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40",
8425
8460
  "aria-label": "Alterar status",
8426
8461
  title: "Alterar status",
8427
8462
  children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(PresenceBadge, { status: currentStatus, size: "lg" })
8428
8463
  }
8429
8464
  ) }),
8430
- /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(DropdownMenuContent, { align: "end", sideOffset: 8, className: "z-[1800] w-44", children: PRESENCE_OPTIONS.map((option) => {
8431
- const isCurrent = option === currentStatus;
8432
- return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(DropdownMenuItem, { onSelect: () => changeStatus(option), className: "text-xs", children: /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("span", { className: "flex w-full items-center justify-between gap-2", children: [
8433
- /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("span", { className: "flex items-center gap-2", children: [
8434
- /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(PresenceBadge, { status: option, size: "md" }),
8435
- /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("span", { children: PRESENCE_META[option].label })
8436
- ] }),
8437
- isCurrent ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_lucide_react9.Check, { className: "h-3.5 w-3.5 text-primary" }) : null
8438
- ] }) }, option);
8439
- }) })
8465
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(DropdownMenuContent, { align: "end", sideOffset: 8, className: "z-[1800] w-44", children: renderPresenceStatusOptions() })
8440
8466
  ] })
8441
8467
  ] }),
8442
8468
  /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("h3", { className: "mt-3 text-xl font-bold leading-tight text-foreground", children: resolvedName }),
@@ -8677,7 +8703,7 @@ var UserMenuCupcode = ({
8677
8703
  visibleGroupedNotifications.length ? visibleGroupedNotifications.map((group) => /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("section", { className: "space-y-1.5", children: [
8678
8704
  /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("p", { className: "px-0.5 text-[11px] font-semibold uppercase tracking-[0.08em] text-muted-foreground", children: group.label }),
8679
8705
  /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: "space-y-1.5", children: group.items.map((notification) => {
8680
- var _a67;
8706
+ var _a74;
8681
8707
  const kind = normalizeNotificationKind(notification.kind);
8682
8708
  const meta = NOTIFICATION_KIND_META[kind];
8683
8709
  const Icon3 = meta.icon;
@@ -8706,7 +8732,7 @@ var UserMenuCupcode = ({
8706
8732
  className: "inline-flex h-6 items-center gap-1 rounded-md border border-border/70 px-1.5 text-[11px] font-semibold text-foreground transition-all hover:bg-muted/45",
8707
8733
  children: [
8708
8734
  /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_lucide_react9.ExternalLink, { className: "h-3 w-3" }),
8709
- (_a67 = notification.actionLabel) != null ? _a67 : "Abrir"
8735
+ (_a74 = notification.actionLabel) != null ? _a74 : "Abrir"
8710
8736
  ]
8711
8737
  }
8712
8738
  ),
@@ -8934,7 +8960,7 @@ var UserMenuCupcode = ({
8934
8960
  }
8935
8961
  if (activeTab === "chat") {
8936
8962
  const canSendChatMessage = Boolean(activeChatUser) && chatDraft.trim() !== "" && !isSendingChatMessage && !isChatLoading;
8937
- const activeConversationUnreadCount = activeChatUser ? (_a66 = resolvedChatUnreadByUser[activeChatUser.id]) != null ? _a66 : 0 : 0;
8963
+ const activeConversationUnreadCount = activeChatUser ? (_a73 = resolvedChatUnreadByUser[activeChatUser.id]) != null ? _a73 : 0 : 0;
8938
8964
  return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: "h-full", children: /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
8939
8965
  "div",
8940
8966
  {
@@ -9013,12 +9039,12 @@ var UserMenuCupcode = ({
9013
9039
  }
9014
9040
  ),
9015
9041
  /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: "space-y-1", children: users.map((user) => {
9016
- var _a67, _b6, _c2;
9042
+ var _a74, _b7, _c2;
9017
9043
  const userInitials = buildInitials(user.name, user.username);
9018
9044
  const isCurrent = user.id === activeChatUserId;
9019
- const unreadCount = (_a67 = resolvedChatUnreadByUser[user.id]) != null ? _a67 : 0;
9045
+ const unreadCount = (_a74 = resolvedChatUnreadByUser[user.id]) != null ? _a74 : 0;
9020
9046
  const hasUnread = unreadCount > 0;
9021
- const lastMessage = (_b6 = conversationMetaByUserId.get(user.id)) == null ? void 0 : _b6.lastMessage;
9047
+ const lastMessage = (_b7 = conversationMetaByUserId.get(user.id)) == null ? void 0 : _b7.lastMessage;
9022
9048
  return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
9023
9049
  "button",
9024
9050
  {
@@ -9233,13 +9259,13 @@ var UserMenuCupcode = ({
9233
9259
  className: "cc-scrollbar cc-scrollbar-pink relative flex-1 space-y-2 overflow-y-auto px-3 py-2.5",
9234
9260
  children: [
9235
9261
  isChatLoading ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("p", { className: "rounded-xl border border-dashed border-border/70 bg-background/35 px-3 py-3 text-[11px] text-muted-foreground", children: "Carregando conversa..." }) : activeChatMessages.length ? activeChatTimeline.map((item) => {
9236
- var _a67, _b6;
9262
+ var _a74, _b7;
9237
9263
  if (item.type === "day") {
9238
9264
  return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: "flex justify-center py-1", children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("span", { className: "inline-flex items-center rounded-full border border-border/70 bg-background/85 px-2.5 py-0.5 text-[10px] font-medium text-muted-foreground shadow-[var(--elevation-2)]", children: item.label }) }, item.key);
9239
9265
  }
9240
9266
  const { message } = item;
9241
- const replyMessage = message.replyToMessageId ? (_a67 = activeChatMessagesMap.get(message.replyToMessageId)) != null ? _a67 : null : null;
9242
- const reactions = (_b6 = reactionsByMessageId.get(message.id)) != null ? _b6 : [];
9267
+ const replyMessage = message.replyToMessageId ? (_a74 = activeChatMessagesMap.get(message.replyToMessageId)) != null ? _a74 : null : null;
9268
+ const reactions = (_b7 = reactionsByMessageId.get(message.id)) != null ? _b7 : [];
9243
9269
  const hasReadReceipt = Boolean(message.readAt);
9244
9270
  const isEditing = editingMessageId === message.id;
9245
9271
  const canEditOrDelete = message.sender === "me";
@@ -9412,7 +9438,7 @@ var UserMenuCupcode = ({
9412
9438
  "div",
9413
9439
  {
9414
9440
  ref: reactionPickerRef,
9415
- style: { top: `${(_b5 = activeReactionPicker == null ? void 0 : activeReactionPicker.top) != null ? _b5 : 0}px`, left: `${(_c = activeReactionPicker == null ? void 0 : activeReactionPicker.left) != null ? _c : 0}px` },
9441
+ style: { top: `${(_b6 = activeReactionPicker == null ? void 0 : activeReactionPicker.top) != null ? _b6 : 0}px`, left: `${(_c = activeReactionPicker == null ? void 0 : activeReactionPicker.left) != null ? _c : 0}px` },
9416
9442
  className: "absolute z-[1900] flex w-[14.35rem] items-center gap-1 whitespace-nowrap rounded-xl border border-border/70 bg-background/95 p-1.5 shadow-[var(--elevation-4)]",
9417
9443
  children: MESSAGE_REACTION_OPTIONS.map((emoji) => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
9418
9444
  "button",
@@ -9568,8 +9594,8 @@ var UserMenuCupcode = ({
9568
9594
  ] })
9569
9595
  ] }),
9570
9596
  isChatSuperAdmin ? activeConversationLogs.length ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: "space-y-2", children: activeConversationLogs.map((entry) => {
9571
- var _a67;
9572
- const actorName = entry.actorId && entry.actorId === resolvedCurrentChatUserId ? "Voc\xEA" : (_a67 = entry.actorId) != null ? _a67 : "Usu\xE1rio";
9597
+ var _a74;
9598
+ const actorName = entry.actorId && entry.actorId === resolvedCurrentChatUserId ? "Voc\xEA" : (_a74 = entry.actorId) != null ? _a74 : "Usu\xE1rio";
9573
9599
  return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
9574
9600
  "article",
9575
9601
  {
@@ -10166,7 +10192,7 @@ var UserMenuCupcode = ({
10166
10192
  }
10167
10193
  },
10168
10194
  children: [
10169
- /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: cn("relative inline-flex items-center gap-2", className), children: [
10195
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: cn("relative inline-flex items-center", className), children: [
10170
10196
  isChatIndicatorMounted ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(TooltipProvider, { delayDuration: 100, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(Tooltip, { children: [
10171
10197
  /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
10172
10198
  "button",
@@ -10219,21 +10245,33 @@ var UserMenuCupcode = ({
10219
10245
  ")"
10220
10246
  ] })
10221
10247
  ] }) }) : null,
10222
- /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(DialogPrimitive3.Trigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
10223
- "button",
10224
- {
10225
- type: "button",
10226
- className: "relative z-10 inline-flex h-11 w-11 items-center justify-center rounded-full border border-border/70 bg-background/35 shadow-[var(--elevation-3)] transition-all hover:bg-background/55 hover:shadow-[0_0_0_2px_rgba(237,30,121,0.22),0_14px_28px_-18px_rgba(237,30,121,0.75)]",
10227
- "aria-label": "Abrir menu do usu\xE1rio",
10228
- children: [
10229
- /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(Avatar2, { className: "h-full w-full border-none", children: [
10248
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: "relative", children: [
10249
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(DialogPrimitive3.Trigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10250
+ "button",
10251
+ {
10252
+ type: "button",
10253
+ className: "relative z-10 inline-flex h-11 w-11 items-center justify-center rounded-full border border-border/70 bg-background/35 shadow-[var(--elevation-3)] transition-all hover:bg-background/55 hover:shadow-[0_0_0_2px_rgba(151,90,182,0.3),0_14px_28px_-18px_rgba(151,90,182,0.3)]",
10254
+ "aria-label": "Abrir menu do usu\xE1rio",
10255
+ children: /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(Avatar2, { className: "h-full w-full border-none", children: [
10230
10256
  /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(AvatarImage2, { src: resolvedProfileAvatarUrl, alt: resolvedName }),
10231
10257
  /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(AvatarFallback2, { className: "bg-muted text-sm font-semibold text-foreground", children: initials })
10232
- ] }),
10233
- /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("span", { className: "absolute -bottom-0.5 -right-0.5", children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(PresenceBadge, { status: currentStatus }) })
10234
- ]
10235
- }
10236
- ) })
10258
+ ] })
10259
+ }
10260
+ ) }),
10261
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(DropdownMenu, { children: [
10262
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10263
+ "button",
10264
+ {
10265
+ type: "button",
10266
+ className: "absolute bottom-0 -right-0.5 z-20 inline-flex items-center justify-center rounded-full p-0.5 text-foreground transition-transform hover:scale-110 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40",
10267
+ "aria-label": "Alterar status",
10268
+ title: `Status: ${PRESENCE_META[currentStatus].label}`,
10269
+ children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(PresenceBadge, { status: currentStatus, size: "md" })
10270
+ }
10271
+ ) }),
10272
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(DropdownMenuContent, { align: "end", sideOffset: 8, className: "z-[1800] w-44", children: renderPresenceStatusOptions() })
10273
+ ] })
10274
+ ] })
10237
10275
  ] }),
10238
10276
  /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(DialogPrimitive3.Portal, { children: [
10239
10277
  /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(DialogPrimitive3.Overlay, { className: "fixed inset-0 z-[650] bg-black/45 backdrop-blur-[2px] data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0" }),
@@ -10510,7 +10548,7 @@ var FunctionsClient = class {
10510
10548
  */
10511
10549
  invoke(functionName_1) {
10512
10550
  return __awaiter(this, arguments, void 0, function* (functionName, options = {}) {
10513
- var _a65;
10551
+ var _a72;
10514
10552
  let timeoutId;
10515
10553
  let timeoutController;
10516
10554
  try {
@@ -10576,7 +10614,7 @@ var FunctionsClient = class {
10576
10614
  if (!response.ok) {
10577
10615
  throw new FunctionsHttpError(response);
10578
10616
  }
10579
- let responseType = ((_a65 = response.headers.get("Content-Type")) !== null && _a65 !== void 0 ? _a65 : "text/plain").split(";")[0].trim();
10617
+ let responseType = ((_a72 = response.headers.get("Content-Type")) !== null && _a72 !== void 0 ? _a72 : "text/plain").split(";")[0].trim();
10580
10618
  let data;
10581
10619
  if (responseType === "application/json") {
10582
10620
  data = yield response.json();
@@ -11822,7 +11860,7 @@ var WebSocketFactory = class {
11822
11860
  constructor() {
11823
11861
  }
11824
11862
  static detectEnvironment() {
11825
- var _a65;
11863
+ var _a72;
11826
11864
  if (typeof WebSocket !== "undefined") {
11827
11865
  return { type: "native", constructor: WebSocket };
11828
11866
  }
@@ -11839,7 +11877,7 @@ var WebSocketFactory = class {
11839
11877
  workaround: "Use Cloudflare Workers WebSocket API for server-side WebSocket handling, or deploy to a different runtime."
11840
11878
  };
11841
11879
  }
11842
- if (typeof globalThis !== "undefined" && globalThis.EdgeRuntime || typeof navigator !== "undefined" && ((_a65 = navigator.userAgent) === null || _a65 === void 0 ? void 0 : _a65.includes("Vercel-Edge"))) {
11880
+ if (typeof globalThis !== "undefined" && globalThis.EdgeRuntime || typeof navigator !== "undefined" && ((_a72 = navigator.userAgent) === null || _a72 === void 0 ? void 0 : _a72.includes("Vercel-Edge"))) {
11843
11881
  return {
11844
11882
  type: "unsupported",
11845
11883
  error: "Edge runtime detected (Vercel Edge/Netlify Edge). WebSockets are not supported in edge functions.",
@@ -11923,7 +11961,7 @@ Suggested solution: ${env.workaround}`;
11923
11961
  try {
11924
11962
  const env = this.detectEnvironment();
11925
11963
  return env.type === "native" || env.type === "ws";
11926
- } catch (_a65) {
11964
+ } catch (_a72) {
11927
11965
  return false;
11928
11966
  }
11929
11967
  }
@@ -11997,30 +12035,30 @@ var Serializer = class {
11997
12035
  return callback(JSON.stringify(payload));
11998
12036
  }
11999
12037
  _binaryEncodeUserBroadcastPush(message) {
12000
- var _a65;
12001
- if (this._isArrayBuffer((_a65 = message.payload) === null || _a65 === void 0 ? void 0 : _a65.payload)) {
12038
+ var _a72;
12039
+ if (this._isArrayBuffer((_a72 = message.payload) === null || _a72 === void 0 ? void 0 : _a72.payload)) {
12002
12040
  return this._encodeBinaryUserBroadcastPush(message);
12003
12041
  } else {
12004
12042
  return this._encodeJsonUserBroadcastPush(message);
12005
12043
  }
12006
12044
  }
12007
12045
  _encodeBinaryUserBroadcastPush(message) {
12008
- var _a65, _b5;
12009
- const userPayload = (_b5 = (_a65 = message.payload) === null || _a65 === void 0 ? void 0 : _a65.payload) !== null && _b5 !== void 0 ? _b5 : new ArrayBuffer(0);
12046
+ var _a72, _b6;
12047
+ const userPayload = (_b6 = (_a72 = message.payload) === null || _a72 === void 0 ? void 0 : _a72.payload) !== null && _b6 !== void 0 ? _b6 : new ArrayBuffer(0);
12010
12048
  return this._encodeUserBroadcastPush(message, this.BINARY_ENCODING, userPayload);
12011
12049
  }
12012
12050
  _encodeJsonUserBroadcastPush(message) {
12013
- var _a65, _b5;
12014
- const userPayload = (_b5 = (_a65 = message.payload) === null || _a65 === void 0 ? void 0 : _a65.payload) !== null && _b5 !== void 0 ? _b5 : {};
12051
+ var _a72, _b6;
12052
+ const userPayload = (_b6 = (_a72 = message.payload) === null || _a72 === void 0 ? void 0 : _a72.payload) !== null && _b6 !== void 0 ? _b6 : {};
12015
12053
  const encoder = new TextEncoder();
12016
12054
  const encodedUserPayload = encoder.encode(JSON.stringify(userPayload)).buffer;
12017
12055
  return this._encodeUserBroadcastPush(message, this.JSON_ENCODING, encodedUserPayload);
12018
12056
  }
12019
12057
  _encodeUserBroadcastPush(message, encodingType, encodedPayload) {
12020
- var _a65, _b5;
12058
+ var _a72, _b6;
12021
12059
  const topic = message.topic;
12022
- const ref = (_a65 = message.ref) !== null && _a65 !== void 0 ? _a65 : "";
12023
- const joinRef = (_b5 = message.join_ref) !== null && _b5 !== void 0 ? _b5 : "";
12060
+ const ref = (_a72 = message.ref) !== null && _a72 !== void 0 ? _a72 : "";
12061
+ const joinRef = (_b6 = message.join_ref) !== null && _b6 !== void 0 ? _b6 : "";
12024
12062
  const userEvent = message.payload.event;
12025
12063
  const rest = this.allowedMetadataKeys ? this._pick(message.payload, this.allowedMetadataKeys) : {};
12026
12064
  const metadata = Object.keys(rest).length === 0 ? "" : JSON.stringify(rest);
@@ -12106,8 +12144,8 @@ var Serializer = class {
12106
12144
  return { join_ref: null, ref: null, topic, event: this.BROADCAST_EVENT, payload: data };
12107
12145
  }
12108
12146
  _isArrayBuffer(buffer) {
12109
- var _a65;
12110
- return buffer instanceof ArrayBuffer || ((_a65 = buffer === null || buffer === void 0 ? void 0 : buffer.constructor) === null || _a65 === void 0 ? void 0 : _a65.name) === "ArrayBuffer";
12147
+ var _a72;
12148
+ return buffer instanceof ArrayBuffer || ((_a72 = buffer === null || buffer === void 0 ? void 0 : buffer.constructor) === null || _a72 === void 0 ? void 0 : _a72.name) === "ArrayBuffer";
12111
12149
  }
12112
12150
  _pick(obj, keys) {
12113
12151
  if (!obj || typeof obj !== "object") {
@@ -12171,8 +12209,8 @@ var PostgresTypes;
12171
12209
  PostgresTypes2["tstzrange"] = "tstzrange";
12172
12210
  })(PostgresTypes || (PostgresTypes = {}));
12173
12211
  var convertChangeData = (columns, record, options = {}) => {
12174
- var _a65;
12175
- const skipTypes = (_a65 = options.skipTypes) !== null && _a65 !== void 0 ? _a65 : [];
12212
+ var _a72;
12213
+ const skipTypes = (_a72 = options.skipTypes) !== null && _a72 !== void 0 ? _a72 : [];
12176
12214
  if (!record) {
12177
12215
  return {};
12178
12216
  }
@@ -12262,7 +12300,7 @@ var toJson = (value) => {
12262
12300
  if (typeof value === "string") {
12263
12301
  try {
12264
12302
  return JSON.parse(value);
12265
- } catch (_a65) {
12303
+ } catch (_a72) {
12266
12304
  return value;
12267
12305
  }
12268
12306
  }
@@ -12354,9 +12392,9 @@ var Push = class {
12354
12392
  this.payload = Object.assign(Object.assign({}, this.payload), payload);
12355
12393
  }
12356
12394
  receive(status, callback) {
12357
- var _a65;
12395
+ var _a72;
12358
12396
  if (this._hasReceived(status)) {
12359
- callback((_a65 = this.receivedResp) === null || _a65 === void 0 ? void 0 : _a65.response);
12397
+ callback((_a72 = this.receivedResp) === null || _a72 === void 0 ? void 0 : _a72.response);
12360
12398
  }
12361
12399
  this.recHooks.push({ status, callback });
12362
12400
  return this;
@@ -12547,8 +12585,8 @@ var RealtimePresence = class _RealtimePresence {
12547
12585
  };
12548
12586
  }
12549
12587
  this.map(joins, (key, newPresences) => {
12550
- var _a65;
12551
- const currentPresences = (_a65 = state[key]) !== null && _a65 !== void 0 ? _a65 : [];
12588
+ var _a72;
12589
+ const currentPresences = (_a72 = state[key]) !== null && _a72 !== void 0 ? _a72 : [];
12552
12590
  state[key] = this.cloneDeep(newPresences);
12553
12591
  if (currentPresences.length > 0) {
12554
12592
  const joinedPresenceRefs = state[key].map((m) => m.presence_ref);
@@ -12676,7 +12714,7 @@ var RealtimeChannel = class _RealtimeChannel {
12676
12714
  * ```
12677
12715
  */
12678
12716
  constructor(topic, params = { config: {} }, socket) {
12679
- var _a65, _b5;
12717
+ var _a72, _b6;
12680
12718
  this.topic = topic;
12681
12719
  this.params = params;
12682
12720
  this.socket = socket;
@@ -12735,19 +12773,19 @@ var RealtimeChannel = class _RealtimeChannel {
12735
12773
  this.presence = new RealtimePresence(this);
12736
12774
  this.broadcastEndpointURL = httpEndpointURL(this.socket.endPoint);
12737
12775
  this.private = this.params.config.private || false;
12738
- if (!this.private && ((_b5 = (_a65 = this.params.config) === null || _a65 === void 0 ? void 0 : _a65.broadcast) === null || _b5 === void 0 ? void 0 : _b5.replay)) {
12776
+ if (!this.private && ((_b6 = (_a72 = this.params.config) === null || _a72 === void 0 ? void 0 : _a72.broadcast) === null || _b6 === void 0 ? void 0 : _b6.replay)) {
12739
12777
  throw `tried to use replay on public channel '${this.topic}'. It must be a private channel.`;
12740
12778
  }
12741
12779
  }
12742
12780
  /** Subscribe registers your client with the server */
12743
12781
  subscribe(callback, timeout = this.timeout) {
12744
- var _a65, _b5, _c;
12782
+ var _a72, _b6, _c;
12745
12783
  if (!this.socket.isConnected()) {
12746
12784
  this.socket.connect();
12747
12785
  }
12748
12786
  if (this.state == CHANNEL_STATES.closed) {
12749
12787
  const { config: { broadcast, presence, private: isPrivate } } = this.params;
12750
- const postgres_changes = (_b5 = (_a65 = this.bindings.postgres_changes) === null || _a65 === void 0 ? void 0 : _a65.map((r) => r.filter)) !== null && _b5 !== void 0 ? _b5 : [];
12788
+ const postgres_changes = (_b6 = (_a72 = this.bindings.postgres_changes) === null || _a72 === void 0 ? void 0 : _a72.map((r) => r.filter)) !== null && _b6 !== void 0 ? _b6 : [];
12751
12789
  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;
12752
12790
  const accessTokenPayload = {};
12753
12791
  const config = {
@@ -12765,7 +12803,7 @@ var RealtimeChannel = class _RealtimeChannel {
12765
12803
  this.joinedOnce = true;
12766
12804
  this._rejoin(timeout);
12767
12805
  this.joinPush.receive("ok", async ({ postgres_changes: postgres_changes2 }) => {
12768
- var _a66;
12806
+ var _a73;
12769
12807
  if (!this.socket._isManualToken()) {
12770
12808
  this.socket.setAuth();
12771
12809
  }
@@ -12774,7 +12812,7 @@ var RealtimeChannel = class _RealtimeChannel {
12774
12812
  return;
12775
12813
  } else {
12776
12814
  const clientPostgresBindings = this.bindings.postgres_changes;
12777
- const bindingsLen = (_a66 = clientPostgresBindings === null || clientPostgresBindings === void 0 ? void 0 : clientPostgresBindings.length) !== null && _a66 !== void 0 ? _a66 : 0;
12815
+ const bindingsLen = (_a73 = clientPostgresBindings === null || clientPostgresBindings === void 0 ? void 0 : clientPostgresBindings.length) !== null && _a73 !== void 0 ? _a73 : 0;
12778
12816
  const newPostgresBindings = [];
12779
12817
  for (let i = 0; i < bindingsLen; i++) {
12780
12818
  const clientPostgresBinding = clientPostgresBindings[i];
@@ -12852,7 +12890,7 @@ var RealtimeChannel = class _RealtimeChannel {
12852
12890
  * @returns Promise resolving to object with success status, and error details if failed
12853
12891
  */
12854
12892
  async httpSend(event, payload, opts = {}) {
12855
- var _a65;
12893
+ var _a72;
12856
12894
  if (payload === void 0 || payload === null) {
12857
12895
  return Promise.reject("Payload is required for httpSend()");
12858
12896
  }
@@ -12877,7 +12915,7 @@ var RealtimeChannel = class _RealtimeChannel {
12877
12915
  ]
12878
12916
  })
12879
12917
  };
12880
- const response = await this._fetchWithTimeout(this.broadcastEndpointURL, options, (_a65 = opts.timeout) !== null && _a65 !== void 0 ? _a65 : this.timeout);
12918
+ const response = await this._fetchWithTimeout(this.broadcastEndpointURL, options, (_a72 = opts.timeout) !== null && _a72 !== void 0 ? _a72 : this.timeout);
12881
12919
  if (response.status === 202) {
12882
12920
  return { success: true };
12883
12921
  }
@@ -12885,7 +12923,7 @@ var RealtimeChannel = class _RealtimeChannel {
12885
12923
  try {
12886
12924
  const errorBody = await response.json();
12887
12925
  errorMessage = errorBody.error || errorBody.message || errorMessage;
12888
- } catch (_b5) {
12926
+ } catch (_b6) {
12889
12927
  }
12890
12928
  return Promise.reject(new Error(errorMessage));
12891
12929
  }
@@ -12899,7 +12937,7 @@ var RealtimeChannel = class _RealtimeChannel {
12899
12937
  * @param opts Options to be used during the send process
12900
12938
  */
12901
12939
  async send(args, opts = {}) {
12902
- var _a65, _b5;
12940
+ var _a72, _b6;
12903
12941
  if (!this._canPush() && args.type === "broadcast") {
12904
12942
  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.");
12905
12943
  const { event, payload: endpoint_payload } = args;
@@ -12925,8 +12963,8 @@ var RealtimeChannel = class _RealtimeChannel {
12925
12963
  })
12926
12964
  };
12927
12965
  try {
12928
- const response = await this._fetchWithTimeout(this.broadcastEndpointURL, options, (_a65 = opts.timeout) !== null && _a65 !== void 0 ? _a65 : this.timeout);
12929
- await ((_b5 = response.body) === null || _b5 === void 0 ? void 0 : _b5.cancel());
12966
+ const response = await this._fetchWithTimeout(this.broadcastEndpointURL, options, (_a72 = opts.timeout) !== null && _a72 !== void 0 ? _a72 : this.timeout);
12967
+ await ((_b6 = response.body) === null || _b6 === void 0 ? void 0 : _b6.cancel());
12930
12968
  return response.ok ? "ok" : "error";
12931
12969
  } catch (error) {
12932
12970
  if (error.name === "AbortError") {
@@ -12937,9 +12975,9 @@ var RealtimeChannel = class _RealtimeChannel {
12937
12975
  }
12938
12976
  } else {
12939
12977
  return new Promise((resolve) => {
12940
- var _a66, _b6, _c;
12978
+ var _a73, _b7, _c;
12941
12979
  const push = this._push(args.type, args, opts.timeout || this.timeout);
12942
- if (args.type === "broadcast" && !((_c = (_b6 = (_a66 = this.params) === null || _a66 === void 0 ? void 0 : _a66.config) === null || _b6 === void 0 ? void 0 : _b6.broadcast) === null || _c === void 0 ? void 0 : _c.ack)) {
12980
+ if (args.type === "broadcast" && !((_c = (_b7 = (_a73 = this.params) === null || _a73 === void 0 ? void 0 : _a73.config) === null || _b7 === void 0 ? void 0 : _b7.broadcast) === null || _c === void 0 ? void 0 : _c.ack)) {
12943
12981
  resolve("ok");
12944
12982
  }
12945
12983
  push.receive("ok", () => resolve("ok"));
@@ -13058,7 +13096,7 @@ var RealtimeChannel = class _RealtimeChannel {
13058
13096
  }
13059
13097
  /** @internal */
13060
13098
  _trigger(type, payload, ref) {
13061
- var _a65, _b5;
13099
+ var _a72, _b6;
13062
13100
  const typeLower = type.toLocaleLowerCase();
13063
13101
  const { close, error, leave, join } = CHANNEL_EVENTS;
13064
13102
  const events = [close, error, leave, join];
@@ -13070,18 +13108,18 @@ var RealtimeChannel = class _RealtimeChannel {
13070
13108
  throw "channel onMessage callbacks must return the payload, modified or unmodified";
13071
13109
  }
13072
13110
  if (["insert", "update", "delete"].includes(typeLower)) {
13073
- (_a65 = this.bindings.postgres_changes) === null || _a65 === void 0 ? void 0 : _a65.filter((bind) => {
13074
- var _a66, _b6, _c;
13075
- return ((_a66 = bind.filter) === null || _a66 === void 0 ? void 0 : _a66.event) === "*" || ((_c = (_b6 = bind.filter) === null || _b6 === void 0 ? void 0 : _b6.event) === null || _c === void 0 ? void 0 : _c.toLocaleLowerCase()) === typeLower;
13111
+ (_a72 = this.bindings.postgres_changes) === null || _a72 === void 0 ? void 0 : _a72.filter((bind) => {
13112
+ var _a73, _b7, _c;
13113
+ return ((_a73 = bind.filter) === null || _a73 === void 0 ? void 0 : _a73.event) === "*" || ((_c = (_b7 = bind.filter) === null || _b7 === void 0 ? void 0 : _b7.event) === null || _c === void 0 ? void 0 : _c.toLocaleLowerCase()) === typeLower;
13076
13114
  }).map((bind) => bind.callback(handledPayload, ref));
13077
13115
  } else {
13078
- (_b5 = this.bindings[typeLower]) === null || _b5 === void 0 ? void 0 : _b5.filter((bind) => {
13079
- var _a66, _b6, _c, _d, _e, _f, _g, _h;
13116
+ (_b6 = this.bindings[typeLower]) === null || _b6 === void 0 ? void 0 : _b6.filter((bind) => {
13117
+ var _a73, _b7, _c, _d, _e, _f, _g, _h;
13080
13118
  if (["broadcast", "presence", "postgres_changes"].includes(typeLower)) {
13081
13119
  if ("id" in bind) {
13082
13120
  const bindId = bind.id;
13083
- const bindEvent = (_a66 = bind.filter) === null || _a66 === void 0 ? void 0 : _a66.event;
13084
- return bindId && ((_b6 = payload.ids) === null || _b6 === void 0 ? void 0 : _b6.includes(bindId)) && (bindEvent === "*" || (bindEvent === null || bindEvent === void 0 ? void 0 : bindEvent.toLocaleLowerCase()) === ((_c = payload.data) === null || _c === void 0 ? void 0 : _c.type.toLocaleLowerCase())) && (!((_d = bind.filter) === null || _d === void 0 ? void 0 : _d.table) || bind.filter.table === ((_e = payload.data) === null || _e === void 0 ? void 0 : _e.table));
13121
+ const bindEvent = (_a73 = bind.filter) === null || _a73 === void 0 ? void 0 : _a73.event;
13122
+ return bindId && ((_b7 = payload.ids) === null || _b7 === void 0 ? void 0 : _b7.includes(bindId)) && (bindEvent === "*" || (bindEvent === null || bindEvent === void 0 ? void 0 : bindEvent.toLocaleLowerCase()) === ((_c = payload.data) === null || _c === void 0 ? void 0 : _c.type.toLocaleLowerCase())) && (!((_d = bind.filter) === null || _d === void 0 ? void 0 : _d.table) || bind.filter.table === ((_e = payload.data) === null || _e === void 0 ? void 0 : _e.table));
13085
13123
  } else {
13086
13124
  const bindEvent = (_g = (_f = bind === null || bind === void 0 ? void 0 : bind.filter) === null || _f === void 0 ? void 0 : _f.event) === null || _g === void 0 ? void 0 : _g.toLocaleLowerCase();
13087
13125
  return bindEvent === "*" || bindEvent === ((_h = payload === null || payload === void 0 ? void 0 : payload.event) === null || _h === void 0 ? void 0 : _h.toLocaleLowerCase());
@@ -13148,8 +13186,8 @@ var RealtimeChannel = class _RealtimeChannel {
13148
13186
  const typeLower = type.toLocaleLowerCase();
13149
13187
  if (this.bindings[typeLower]) {
13150
13188
  this.bindings[typeLower] = this.bindings[typeLower].filter((bind) => {
13151
- var _a65;
13152
- return !(((_a65 = bind.type) === null || _a65 === void 0 ? void 0 : _a65.toLocaleLowerCase()) === typeLower && _RealtimeChannel.isEqual(bind.filter, filter));
13189
+ var _a72;
13190
+ return !(((_a72 = bind.type) === null || _a72 === void 0 ? void 0 : _a72.toLocaleLowerCase()) === typeLower && _RealtimeChannel.isEqual(bind.filter, filter));
13153
13191
  });
13154
13192
  }
13155
13193
  return this;
@@ -13279,7 +13317,7 @@ var RealtimeClient = class {
13279
13317
  * ```
13280
13318
  */
13281
13319
  constructor(endPoint, options) {
13282
- var _a65;
13320
+ var _a72;
13283
13321
  this.accessTokenValue = null;
13284
13322
  this.apiKey = null;
13285
13323
  this._manuallySetToken = false;
@@ -13318,7 +13356,7 @@ var RealtimeClient = class {
13318
13356
  }
13319
13357
  return (...args) => fetch(...args);
13320
13358
  };
13321
- if (!((_a65 = options === null || options === void 0 ? void 0 : options.params) === null || _a65 === void 0 ? void 0 : _a65.apikey)) {
13359
+ if (!((_a72 = options === null || options === void 0 ? void 0 : options.params) === null || _a72 === void 0 ? void 0 : _a72.apikey)) {
13322
13360
  throw new Error("API key is required to connect to Realtime");
13323
13361
  }
13324
13362
  this.apiKey = options.params.apikey;
@@ -13500,8 +13538,8 @@ Option 2: Install and provide the "ws" package:
13500
13538
  const { topic, event, payload, ref } = data;
13501
13539
  const callback = () => {
13502
13540
  this.encode(data, (result) => {
13503
- var _a65;
13504
- (_a65 = this.conn) === null || _a65 === void 0 ? void 0 : _a65.send(result);
13541
+ var _a72;
13542
+ (_a72 = this.conn) === null || _a72 === void 0 ? void 0 : _a72.send(result);
13505
13543
  });
13506
13544
  };
13507
13545
  this.log("push", `${topic} ${event} (${ref})`, payload);
@@ -13551,7 +13589,7 @@ Option 2: Install and provide the "ws" package:
13551
13589
  * Sends a heartbeat message if the socket is connected.
13552
13590
  */
13553
13591
  async sendHeartbeat() {
13554
- var _a65;
13592
+ var _a72;
13555
13593
  if (!this.isConnected()) {
13556
13594
  try {
13557
13595
  this.heartbeatCallback("disconnected");
@@ -13570,11 +13608,11 @@ Option 2: Install and provide the "ws" package:
13570
13608
  this.log("error", "error in heartbeat callback", e);
13571
13609
  }
13572
13610
  this._wasManualDisconnect = false;
13573
- (_a65 = this.conn) === null || _a65 === void 0 ? void 0 : _a65.close(WS_CLOSE_NORMAL, "heartbeat timeout");
13611
+ (_a72 = this.conn) === null || _a72 === void 0 ? void 0 : _a72.close(WS_CLOSE_NORMAL, "heartbeat timeout");
13574
13612
  setTimeout(() => {
13575
- var _a66;
13613
+ var _a73;
13576
13614
  if (!this.isConnected()) {
13577
- (_a66 = this.reconnectTimer) === null || _a66 === void 0 ? void 0 : _a66.scheduleTimeout();
13615
+ (_a73 = this.reconnectTimer) === null || _a73 === void 0 ? void 0 : _a73.scheduleTimeout();
13578
13616
  }
13579
13617
  }, CONNECTION_TIMEOUTS.HEARTBEAT_TIMEOUT_FALLBACK);
13580
13618
  return;
@@ -13672,12 +13710,12 @@ Option 2: Install and provide the "ws" package:
13672
13710
  * @internal
13673
13711
  */
13674
13712
  _clearTimer(timer) {
13675
- var _a65;
13713
+ var _a72;
13676
13714
  if (timer === "heartbeat" && this.heartbeatTimer) {
13677
13715
  clearInterval(this.heartbeatTimer);
13678
13716
  this.heartbeatTimer = void 0;
13679
13717
  } else if (timer === "reconnect") {
13680
- (_a65 = this.reconnectTimer) === null || _a65 === void 0 ? void 0 : _a65.reset();
13718
+ (_a72 = this.reconnectTimer) === null || _a72 === void 0 ? void 0 : _a72.reset();
13681
13719
  }
13682
13720
  }
13683
13721
  /**
@@ -13792,13 +13830,13 @@ Option 2: Install and provide the "ws" package:
13792
13830
  }
13793
13831
  /** @internal */
13794
13832
  _onConnClose(event) {
13795
- var _a65;
13833
+ var _a72;
13796
13834
  this._setConnectionState("disconnected");
13797
13835
  this.log("transport", "close", event);
13798
13836
  this._triggerChanError();
13799
13837
  this._clearTimer("heartbeat");
13800
13838
  if (!this._wasManualDisconnect) {
13801
- (_a65 = this.reconnectTimer) === null || _a65 === void 0 ? void 0 : _a65.scheduleTimeout();
13839
+ (_a72 = this.reconnectTimer) === null || _a72 === void 0 ? void 0 : _a72.scheduleTimeout();
13802
13840
  }
13803
13841
  this._triggerStateCallbacks("close", event);
13804
13842
  }
@@ -13941,9 +13979,9 @@ Option 2: Install and provide the "ws" package:
13941
13979
  * @internal
13942
13980
  */
13943
13981
  _initializeOptions(options) {
13944
- var _a65, _b5, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
13945
- this.transport = (_a65 = options === null || options === void 0 ? void 0 : options.transport) !== null && _a65 !== void 0 ? _a65 : null;
13946
- this.timeout = (_b5 = options === null || options === void 0 ? void 0 : options.timeout) !== null && _b5 !== void 0 ? _b5 : DEFAULT_TIMEOUT;
13982
+ var _a72, _b6, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
13983
+ this.transport = (_a72 = options === null || options === void 0 ? void 0 : options.transport) !== null && _a72 !== void 0 ? _a72 : null;
13984
+ this.timeout = (_b6 = options === null || options === void 0 ? void 0 : options.timeout) !== null && _b6 !== void 0 ? _b6 : DEFAULT_TIMEOUT;
13947
13985
  this.heartbeatIntervalMs = (_c = options === null || options === void 0 ? void 0 : options.heartbeatIntervalMs) !== null && _c !== void 0 ? _c : CONNECTION_TIMEOUTS.HEARTBEAT_INTERVAL;
13948
13986
  this.worker = (_d = options === null || options === void 0 ? void 0 : options.worker) !== null && _d !== void 0 ? _d : false;
13949
13987
  this.accessToken = (_e = options === null || options === void 0 ? void 0 : options.accessToken) !== null && _e !== void 0 ? _e : null;
@@ -13988,14 +14026,14 @@ Option 2: Install and provide the "ws" package:
13988
14026
  // node_modules/iceberg-js/dist/index.mjs
13989
14027
  var IcebergError = class extends Error {
13990
14028
  constructor(message, opts) {
13991
- var _a65;
14029
+ var _a72;
13992
14030
  super(message);
13993
14031
  this.name = "IcebergError";
13994
14032
  this.status = opts.status;
13995
14033
  this.icebergType = opts.icebergType;
13996
14034
  this.icebergCode = opts.icebergCode;
13997
14035
  this.details = opts.details;
13998
- this.isCommitStateUnknown = opts.icebergType === "CommitStateUnknownException" || [500, 502, 504].includes(opts.status) && ((_a65 = opts.icebergType) == null ? void 0 : _a65.includes("CommitState")) === true;
14036
+ this.isCommitStateUnknown = opts.icebergType === "CommitStateUnknownException" || [500, 502, 504].includes(opts.status) && ((_a72 = opts.icebergType) == null ? void 0 : _a72.includes("CommitState")) === true;
13999
14037
  }
14000
14038
  /**
14001
14039
  * Returns true if the error is a 404 Not Found error.
@@ -14043,8 +14081,8 @@ async function buildAuthHeaders(auth) {
14043
14081
  return {};
14044
14082
  }
14045
14083
  function createFetchClient(options) {
14046
- var _a65;
14047
- const fetchFn = (_a65 = options.fetchImpl) != null ? _a65 : globalThis.fetch;
14084
+ var _a72;
14085
+ const fetchFn = (_a72 = options.fetchImpl) != null ? _a72 : globalThis.fetch;
14048
14086
  return {
14049
14087
  async request({
14050
14088
  method,
@@ -14053,7 +14091,7 @@ function createFetchClient(options) {
14053
14091
  body,
14054
14092
  headers
14055
14093
  }) {
14056
- var _a66;
14094
+ var _a73;
14057
14095
  const url = buildUrl(options.baseUrl, path, query);
14058
14096
  const authHeaders = await buildAuthHeaders(options.auth);
14059
14097
  const res = await fetchFn(url, {
@@ -14072,7 +14110,7 @@ function createFetchClient(options) {
14072
14110
  const errBody = isJson ? data : void 0;
14073
14111
  const errorDetail = errBody == null ? void 0 : errBody.error;
14074
14112
  throw new IcebergError(
14075
- (_a66 = errorDetail == null ? void 0 : errorDetail.message) != null ? _a66 : `Request failed with status ${res.status}`,
14113
+ (_a73 = errorDetail == null ? void 0 : errorDetail.message) != null ? _a73 : `Request failed with status ${res.status}`,
14076
14114
  {
14077
14115
  status: res.status,
14078
14116
  icebergType: errorDetail == null ? void 0 : errorDetail.type,
@@ -14195,11 +14233,11 @@ var TableOperations = class {
14195
14233
  };
14196
14234
  }
14197
14235
  async dropTable(id, options) {
14198
- var _a65;
14236
+ var _a72;
14199
14237
  await this.client.request({
14200
14238
  method: "DELETE",
14201
14239
  path: `${this.prefix}/namespaces/${namespaceToPath2(id.namespace)}/tables/${id.name}`,
14202
- query: { purgeRequested: String((_a65 = options == null ? void 0 : options.purge) != null ? _a65 : false) }
14240
+ query: { purgeRequested: String((_a72 = options == null ? void 0 : options.purge) != null ? _a72 : false) }
14203
14241
  });
14204
14242
  }
14205
14243
  async loadTable(id) {
@@ -14251,7 +14289,7 @@ var IcebergRestCatalog = class {
14251
14289
  * @param options - Configuration options for the catalog client
14252
14290
  */
14253
14291
  constructor(options) {
14254
- var _a65;
14292
+ var _a72;
14255
14293
  let prefix = "v1";
14256
14294
  if (options.catalogName) {
14257
14295
  prefix += `/${options.catalogName}`;
@@ -14262,7 +14300,7 @@ var IcebergRestCatalog = class {
14262
14300
  auth: options.auth,
14263
14301
  fetchImpl: options.fetch
14264
14302
  });
14265
- this.accessDelegation = (_a65 = options.accessDelegation) == null ? void 0 : _a65.join(",");
14303
+ this.accessDelegation = (_a72 = options.accessDelegation) == null ? void 0 : _a72.join(",");
14266
14304
  this.namespaceOps = new NamespaceOperations(this.client, prefix);
14267
14305
  this.tableOps = new TableOperations(this.client, prefix, this.accessDelegation);
14268
14306
  }
@@ -17601,7 +17639,7 @@ var getItemAsync = async (storage, key) => {
17601
17639
  }
17602
17640
  try {
17603
17641
  return JSON.parse(value);
17604
- } catch (_a65) {
17642
+ } catch (_a72) {
17605
17643
  return value;
17606
17644
  }
17607
17645
  };
@@ -17812,7 +17850,7 @@ function deepClone(obj) {
17812
17850
  var _getErrorMessage2 = (err) => err.msg || err.message || err.error_description || err.error || JSON.stringify(err);
17813
17851
  var NETWORK_ERROR_CODES = [502, 503, 504];
17814
17852
  async function handleError2(error) {
17815
- var _a65;
17853
+ var _a72;
17816
17854
  if (!looksLikeFetchResponse(error)) {
17817
17855
  throw new AuthRetryableFetchError(_getErrorMessage2(error), 0);
17818
17856
  }
@@ -17837,7 +17875,7 @@ async function handleError2(error) {
17837
17875
  throw new AuthWeakPasswordError(_getErrorMessage2(data), error.status, data.weak_password.reasons);
17838
17876
  }
17839
17877
  } else if (errorCode === "weak_password") {
17840
- throw new AuthWeakPasswordError(_getErrorMessage2(data), error.status, ((_a65 = data.weak_password) === null || _a65 === void 0 ? void 0 : _a65.reasons) || []);
17878
+ throw new AuthWeakPasswordError(_getErrorMessage2(data), error.status, ((_a72 = data.weak_password) === null || _a72 === void 0 ? void 0 : _a72.reasons) || []);
17841
17879
  } else if (errorCode === "session_not_found") {
17842
17880
  throw new AuthSessionMissingError();
17843
17881
  }
@@ -17853,7 +17891,7 @@ var _getRequestParams2 = (method, options, parameters, body) => {
17853
17891
  return Object.assign(Object.assign({}, params), parameters);
17854
17892
  };
17855
17893
  async function _request(fetcher, method, url, options) {
17856
- var _a65;
17894
+ var _a72;
17857
17895
  const headers = Object.assign({}, options === null || options === void 0 ? void 0 : options.headers);
17858
17896
  if (!headers[API_VERSION_HEADER_NAME]) {
17859
17897
  headers[API_VERSION_HEADER_NAME] = API_VERSIONS["2024-01-01"].name;
@@ -17861,7 +17899,7 @@ async function _request(fetcher, method, url, options) {
17861
17899
  if (options === null || options === void 0 ? void 0 : options.jwt) {
17862
17900
  headers["Authorization"] = `Bearer ${options.jwt}`;
17863
17901
  }
17864
- const qs = (_a65 = options === null || options === void 0 ? void 0 : options.query) !== null && _a65 !== void 0 ? _a65 : {};
17902
+ const qs = (_a72 = options === null || options === void 0 ? void 0 : options.query) !== null && _a72 !== void 0 ? _a72 : {};
17865
17903
  if (options === null || options === void 0 ? void 0 : options.redirectTo) {
17866
17904
  qs["redirect_to"] = options.redirectTo;
17867
17905
  }
@@ -17894,7 +17932,7 @@ async function _handleRequest2(fetcher, method, url, options, parameters, body)
17894
17932
  }
17895
17933
  }
17896
17934
  function _sessionResponse(data) {
17897
- var _a65;
17935
+ var _a72;
17898
17936
  let session = null;
17899
17937
  if (hasSession(data)) {
17900
17938
  session = Object.assign({}, data);
@@ -17902,7 +17940,7 @@ function _sessionResponse(data) {
17902
17940
  session.expires_at = expiresAt(data.expires_in);
17903
17941
  }
17904
17942
  }
17905
- const user = (_a65 = data.user) !== null && _a65 !== void 0 ? _a65 : data;
17943
+ const user = (_a72 = data.user) !== null && _a72 !== void 0 ? _a72 : data;
17906
17944
  return { data: { session, user }, error: null };
17907
17945
  }
17908
17946
  function _sessionResponsePassword(data) {
@@ -17913,8 +17951,8 @@ function _sessionResponsePassword(data) {
17913
17951
  return response;
17914
17952
  }
17915
17953
  function _userResponse(data) {
17916
- var _a65;
17917
- const user = (_a65 = data.user) !== null && _a65 !== void 0 ? _a65 : data;
17954
+ var _a72;
17955
+ const user = (_a72 = data.user) !== null && _a72 !== void 0 ? _a72 : data;
17918
17956
  return { data: { user }, error: null };
17919
17957
  }
17920
17958
  function _ssoResponse(data) {
@@ -18083,14 +18121,14 @@ var GoTrueAdminApi = class {
18083
18121
  * @param params An object which supports `page` and `perPage` as numbers, to alter the paginated results.
18084
18122
  */
18085
18123
  async listUsers(params) {
18086
- var _a65, _b5, _c, _d, _e, _f, _g;
18124
+ var _a72, _b6, _c, _d, _e, _f, _g;
18087
18125
  try {
18088
18126
  const pagination = { nextPage: null, lastPage: 0, total: 0 };
18089
18127
  const response = await _request(this.fetch, "GET", `${this.url}/admin/users`, {
18090
18128
  headers: this.headers,
18091
18129
  noResolveJson: true,
18092
18130
  query: {
18093
- page: (_b5 = (_a65 = params === null || params === void 0 ? void 0 : params.page) === null || _a65 === void 0 ? void 0 : _a65.toString()) !== null && _b5 !== void 0 ? _b5 : "",
18131
+ page: (_b6 = (_a72 = params === null || params === void 0 ? void 0 : params.page) === null || _a72 === void 0 ? void 0 : _a72.toString()) !== null && _b6 !== void 0 ? _b6 : "",
18094
18132
  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 : ""
18095
18133
  },
18096
18134
  xform: _noResolveJsonResponse
@@ -18224,14 +18262,14 @@ var GoTrueAdminApi = class {
18224
18262
  * This function should only be called on a server. Never expose your `service_role` key in the browser.
18225
18263
  */
18226
18264
  async _listOAuthClients(params) {
18227
- var _a65, _b5, _c, _d, _e, _f, _g;
18265
+ var _a72, _b6, _c, _d, _e, _f, _g;
18228
18266
  try {
18229
18267
  const pagination = { nextPage: null, lastPage: 0, total: 0 };
18230
18268
  const response = await _request(this.fetch, "GET", `${this.url}/admin/oauth/clients`, {
18231
18269
  headers: this.headers,
18232
18270
  noResolveJson: true,
18233
18271
  query: {
18234
- page: (_b5 = (_a65 = params === null || params === void 0 ? void 0 : params.page) === null || _a65 === void 0 ? void 0 : _a65.toString()) !== null && _b5 !== void 0 ? _b5 : "",
18272
+ page: (_b6 = (_a72 = params === null || params === void 0 ? void 0 : params.page) === null || _a72 === void 0 ? void 0 : _a72.toString()) !== null && _b6 !== void 0 ? _b6 : "",
18235
18273
  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 : ""
18236
18274
  },
18237
18275
  xform: _noResolveJsonResponse
@@ -18484,7 +18522,7 @@ function toHex(value) {
18484
18522
  return "0x" + hex;
18485
18523
  }
18486
18524
  function createSiweMessage(parameters) {
18487
- var _a65;
18525
+ var _a72;
18488
18526
  const { chainId, domain, expirationTime, issuedAt = /* @__PURE__ */ new Date(), nonce, notBefore, requestId, resources, scheme, uri, version: version5 } = parameters;
18489
18527
  {
18490
18528
  if (!Number.isInteger(chainId))
@@ -18497,7 +18535,7 @@ function createSiweMessage(parameters) {
18497
18535
  throw new Error(`@supabase/auth-js: Invalid SIWE message field "uri". URI must be provided.`);
18498
18536
  if (version5 !== "1")
18499
18537
  throw new Error(`@supabase/auth-js: Invalid SIWE message field "version". Version must be '1'. Provided value: ${version5}`);
18500
- if ((_a65 = parameters.statement) === null || _a65 === void 0 ? void 0 : _a65.includes("\n"))
18538
+ if ((_a72 = parameters.statement) === null || _a72 === void 0 ? void 0 : _a72.includes("\n"))
18501
18539
  throw new Error(`@supabase/auth-js: Invalid SIWE message field "statement". Statement must not include '\\n'. Provided value: ${parameters.statement}`);
18502
18540
  }
18503
18541
  const address = getAddress(parameters.address);
@@ -18539,10 +18577,10 @@ ${suffix}`;
18539
18577
  // node_modules/@supabase/auth-js/dist/module/lib/webauthn.errors.js
18540
18578
  var WebAuthnError = class extends Error {
18541
18579
  constructor({ message, code, cause, name }) {
18542
- var _a65;
18580
+ var _a72;
18543
18581
  super(message, { cause });
18544
18582
  this.__isWebAuthnError = true;
18545
- this.name = (_a65 = name !== null && name !== void 0 ? name : cause instanceof Error ? cause.name : void 0) !== null && _a65 !== void 0 ? _a65 : "Unknown Error";
18583
+ this.name = (_a72 = name !== null && name !== void 0 ? name : cause instanceof Error ? cause.name : void 0) !== null && _a72 !== void 0 ? _a72 : "Unknown Error";
18546
18584
  this.code = code;
18547
18585
  }
18548
18586
  };
@@ -18558,7 +18596,7 @@ var WebAuthnUnknownError = class extends WebAuthnError {
18558
18596
  }
18559
18597
  };
18560
18598
  function identifyRegistrationError({ error, options }) {
18561
- var _a65, _b5, _c;
18599
+ var _a72, _b6, _c;
18562
18600
  const { publicKey } = options;
18563
18601
  if (!publicKey) {
18564
18602
  throw Error("options was missing required publicKey property");
@@ -18572,7 +18610,7 @@ function identifyRegistrationError({ error, options }) {
18572
18610
  });
18573
18611
  }
18574
18612
  } else if (error.name === "ConstraintError") {
18575
- if (((_a65 = publicKey.authenticatorSelection) === null || _a65 === void 0 ? void 0 : _a65.requireResidentKey) === true) {
18613
+ if (((_a72 = publicKey.authenticatorSelection) === null || _a72 === void 0 ? void 0 : _a72.requireResidentKey) === true) {
18576
18614
  return new WebAuthnError({
18577
18615
  message: "Discoverable credentials were required but no available authenticator supported it",
18578
18616
  code: "ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",
@@ -18580,7 +18618,7 @@ function identifyRegistrationError({ error, options }) {
18580
18618
  });
18581
18619
  } else if (
18582
18620
  // @ts-ignore: `mediation` doesn't yet exist on CredentialCreationOptions but it's possible as of Sept 2024
18583
- options.mediation === "conditional" && ((_b5 = publicKey.authenticatorSelection) === null || _b5 === void 0 ? void 0 : _b5.userVerification) === "required"
18621
+ options.mediation === "conditional" && ((_b6 = publicKey.authenticatorSelection) === null || _b6 === void 0 ? void 0 : _b6.userVerification) === "required"
18584
18622
  ) {
18585
18623
  return new WebAuthnError({
18586
18624
  message: "User verification was required during automatic registration but it could not be performed",
@@ -18801,7 +18839,7 @@ function deserializeCredentialRequestOptions(options) {
18801
18839
  return result;
18802
18840
  }
18803
18841
  function serializeCredentialCreationResponse(credential) {
18804
- var _a65;
18842
+ var _a72;
18805
18843
  if ("toJSON" in credential && typeof credential.toJSON === "function") {
18806
18844
  return credential.toJSON();
18807
18845
  }
@@ -18816,11 +18854,11 @@ function serializeCredentialCreationResponse(credential) {
18816
18854
  type: "public-key",
18817
18855
  clientExtensionResults: credential.getClientExtensionResults(),
18818
18856
  // Convert null to undefined and cast to AuthenticatorAttachment type
18819
- authenticatorAttachment: (_a65 = credentialWithAttachment.authenticatorAttachment) !== null && _a65 !== void 0 ? _a65 : void 0
18857
+ authenticatorAttachment: (_a72 = credentialWithAttachment.authenticatorAttachment) !== null && _a72 !== void 0 ? _a72 : void 0
18820
18858
  };
18821
18859
  }
18822
18860
  function serializeCredentialRequestResponse(credential) {
18823
- var _a65;
18861
+ var _a72;
18824
18862
  if ("toJSON" in credential && typeof credential.toJSON === "function") {
18825
18863
  return credential.toJSON();
18826
18864
  }
@@ -18840,7 +18878,7 @@ function serializeCredentialRequestResponse(credential) {
18840
18878
  type: "public-key",
18841
18879
  clientExtensionResults,
18842
18880
  // Convert null to undefined and cast to AuthenticatorAttachment type
18843
- authenticatorAttachment: (_a65 = credentialWithAttachment.authenticatorAttachment) !== null && _a65 !== void 0 ? _a65 : void 0
18881
+ authenticatorAttachment: (_a72 = credentialWithAttachment.authenticatorAttachment) !== null && _a72 !== void 0 ? _a72 : void 0
18844
18882
  };
18845
18883
  }
18846
18884
  function isValidDomain(hostname) {
@@ -18850,8 +18888,8 @@ function isValidDomain(hostname) {
18850
18888
  );
18851
18889
  }
18852
18890
  function browserSupportsWebAuthn() {
18853
- var _a65, _b5;
18854
- return !!(isBrowser() && "PublicKeyCredential" in window && window.PublicKeyCredential && "credentials" in navigator && typeof ((_a65 = navigator === null || navigator === void 0 ? void 0 : navigator.credentials) === null || _a65 === void 0 ? void 0 : _a65.create) === "function" && typeof ((_b5 = navigator === null || navigator === void 0 ? void 0 : navigator.credentials) === null || _b5 === void 0 ? void 0 : _b5.get) === "function");
18891
+ var _a72, _b6;
18892
+ return !!(isBrowser() && "PublicKeyCredential" in window && window.PublicKeyCredential && "credentials" in navigator && typeof ((_a72 = navigator === null || navigator === void 0 ? void 0 : navigator.credentials) === null || _a72 === void 0 ? void 0 : _a72.create) === "function" && typeof ((_b6 = navigator === null || navigator === void 0 ? void 0 : navigator.credentials) === null || _b6 === void 0 ? void 0 : _b6.get) === "function");
18855
18893
  }
18856
18894
  async function createCredential(options) {
18857
18895
  try {
@@ -19180,8 +19218,8 @@ var WebAuthnApi = class {
19180
19218
  });
19181
19219
  if (!factor) {
19182
19220
  await this.client.mfa.listFactors().then((factors) => {
19183
- var _a65;
19184
- return (_a65 = factors.data) === null || _a65 === void 0 ? void 0 : _a65.all.find((v) => v.factor_type === "webauthn" && v.friendly_name === friendlyName && v.status !== "unverified");
19221
+ var _a72;
19222
+ return (_a72 = factors.data) === null || _a72 === void 0 ? void 0 : _a72.all.find((v) => v.factor_type === "webauthn" && v.friendly_name === friendlyName && v.status !== "unverified");
19185
19223
  }).then((factor2) => factor2 ? this.client.mfa.unenroll({ factorId: factor2 === null || factor2 === void 0 ? void 0 : factor2.id }) : void 0);
19186
19224
  return { data: null, error: enrollError };
19187
19225
  }
@@ -19243,15 +19281,15 @@ var GoTrueClient = class _GoTrueClient {
19243
19281
  * The JWKS used for verifying asymmetric JWTs
19244
19282
  */
19245
19283
  get jwks() {
19246
- var _a65, _b5;
19247
- return (_b5 = (_a65 = GLOBAL_JWKS[this.storageKey]) === null || _a65 === void 0 ? void 0 : _a65.jwks) !== null && _b5 !== void 0 ? _b5 : { keys: [] };
19284
+ var _a72, _b6;
19285
+ return (_b6 = (_a72 = GLOBAL_JWKS[this.storageKey]) === null || _a72 === void 0 ? void 0 : _a72.jwks) !== null && _b6 !== void 0 ? _b6 : { keys: [] };
19248
19286
  }
19249
19287
  set jwks(value) {
19250
19288
  GLOBAL_JWKS[this.storageKey] = Object.assign(Object.assign({}, GLOBAL_JWKS[this.storageKey]), { jwks: value });
19251
19289
  }
19252
19290
  get jwks_cached_at() {
19253
- var _a65, _b5;
19254
- return (_b5 = (_a65 = GLOBAL_JWKS[this.storageKey]) === null || _a65 === void 0 ? void 0 : _a65.cachedAt) !== null && _b5 !== void 0 ? _b5 : Number.MIN_SAFE_INTEGER;
19291
+ var _a72, _b6;
19292
+ return (_b6 = (_a72 = GLOBAL_JWKS[this.storageKey]) === null || _a72 === void 0 ? void 0 : _a72.cachedAt) !== null && _b6 !== void 0 ? _b6 : Number.MIN_SAFE_INTEGER;
19255
19293
  }
19256
19294
  set jwks_cached_at(value) {
19257
19295
  GLOBAL_JWKS[this.storageKey] = Object.assign(Object.assign({}, GLOBAL_JWKS[this.storageKey]), { cachedAt: value });
@@ -19271,7 +19309,7 @@ var GoTrueClient = class _GoTrueClient {
19271
19309
  * ```
19272
19310
  */
19273
19311
  constructor(options) {
19274
- var _a65, _b5, _c;
19312
+ var _a72, _b6, _c;
19275
19313
  this.userStorage = null;
19276
19314
  this.memoryStorage = null;
19277
19315
  this.stateChangeEmitters = /* @__PURE__ */ new Map();
@@ -19289,7 +19327,7 @@ var GoTrueClient = class _GoTrueClient {
19289
19327
  this.logger = console.log;
19290
19328
  const settings = Object.assign(Object.assign({}, DEFAULT_OPTIONS), options);
19291
19329
  this.storageKey = settings.storageKey;
19292
- this.instanceID = (_a65 = _GoTrueClient.nextInstanceID[this.storageKey]) !== null && _a65 !== void 0 ? _a65 : 0;
19330
+ this.instanceID = (_a72 = _GoTrueClient.nextInstanceID[this.storageKey]) !== null && _a72 !== void 0 ? _a72 : 0;
19293
19331
  _GoTrueClient.nextInstanceID[this.storageKey] = this.instanceID + 1;
19294
19332
  this.logDebugMessages = !!settings.debug;
19295
19333
  if (typeof settings.debug === "function") {
@@ -19320,7 +19358,7 @@ var GoTrueClient = class _GoTrueClient {
19320
19358
  this.lockAcquireTimeout = settings.lockAcquireTimeout;
19321
19359
  if (settings.lock) {
19322
19360
  this.lock = settings.lock;
19323
- } else if (this.persistSession && isBrowser() && ((_b5 = globalThis === null || globalThis === void 0 ? void 0 : globalThis.navigator) === null || _b5 === void 0 ? void 0 : _b5.locks)) {
19361
+ } else if (this.persistSession && isBrowser() && ((_b6 = globalThis === null || globalThis === void 0 ? void 0 : globalThis.navigator) === null || _b6 === void 0 ? void 0 : _b6.locks)) {
19324
19362
  this.lock = navigatorLock;
19325
19363
  } else {
19326
19364
  this.lock = lockNoOp;
@@ -19426,7 +19464,7 @@ var GoTrueClient = class _GoTrueClient {
19426
19464
  * the whole lifetime of the client
19427
19465
  */
19428
19466
  async _initialize() {
19429
- var _a65;
19467
+ var _a72;
19430
19468
  try {
19431
19469
  let params = {};
19432
19470
  let callbackUrlType = "none";
@@ -19443,7 +19481,7 @@ var GoTrueClient = class _GoTrueClient {
19443
19481
  if (error) {
19444
19482
  this._debug("#_initialize()", "error detecting session from URL", error);
19445
19483
  if (isAuthImplicitGrantRedirectError(error)) {
19446
- const errorCode = (_a65 = error.details) === null || _a65 === void 0 ? void 0 : _a65.code;
19484
+ const errorCode = (_a72 = error.details) === null || _a72 === void 0 ? void 0 : _a72.code;
19447
19485
  if (errorCode === "identity_already_exists" || errorCode === "identity_not_found" || errorCode === "single_identity_not_deletable") {
19448
19486
  return { error };
19449
19487
  }
@@ -19482,12 +19520,12 @@ var GoTrueClient = class _GoTrueClient {
19482
19520
  * @returns A session where the is_anonymous claim in the access token JWT set to true
19483
19521
  */
19484
19522
  async signInAnonymously(credentials) {
19485
- var _a65, _b5, _c;
19523
+ var _a72, _b6, _c;
19486
19524
  try {
19487
19525
  const res = await _request(this.fetch, "POST", `${this.url}/signup`, {
19488
19526
  headers: this.headers,
19489
19527
  body: {
19490
- data: (_b5 = (_a65 = credentials === null || credentials === void 0 ? void 0 : credentials.options) === null || _a65 === void 0 ? void 0 : _a65.data) !== null && _b5 !== void 0 ? _b5 : {},
19528
+ data: (_b6 = (_a72 = credentials === null || credentials === void 0 ? void 0 : credentials.options) === null || _a72 === void 0 ? void 0 : _a72.data) !== null && _b6 !== void 0 ? _b6 : {},
19491
19529
  gotrue_meta_security: { captcha_token: (_c = credentials === null || credentials === void 0 ? void 0 : credentials.options) === null || _c === void 0 ? void 0 : _c.captchaToken }
19492
19530
  },
19493
19531
  xform: _sessionResponse
@@ -19521,7 +19559,7 @@ var GoTrueClient = class _GoTrueClient {
19521
19559
  * @returns A user if the server has "autoconfirm" OFF
19522
19560
  */
19523
19561
  async signUp(credentials) {
19524
- var _a65, _b5, _c;
19562
+ var _a72, _b6, _c;
19525
19563
  try {
19526
19564
  let res;
19527
19565
  if ("email" in credentials) {
@@ -19538,7 +19576,7 @@ var GoTrueClient = class _GoTrueClient {
19538
19576
  body: {
19539
19577
  email,
19540
19578
  password,
19541
- data: (_a65 = options === null || options === void 0 ? void 0 : options.data) !== null && _a65 !== void 0 ? _a65 : {},
19579
+ data: (_a72 = options === null || options === void 0 ? void 0 : options.data) !== null && _a72 !== void 0 ? _a72 : {},
19542
19580
  gotrue_meta_security: { captcha_token: options === null || options === void 0 ? void 0 : options.captchaToken },
19543
19581
  code_challenge: codeChallenge,
19544
19582
  code_challenge_method: codeChallengeMethod
@@ -19552,7 +19590,7 @@ var GoTrueClient = class _GoTrueClient {
19552
19590
  body: {
19553
19591
  phone,
19554
19592
  password,
19555
- data: (_b5 = options === null || options === void 0 ? void 0 : options.data) !== null && _b5 !== void 0 ? _b5 : {},
19593
+ data: (_b6 = options === null || options === void 0 ? void 0 : options.data) !== null && _b6 !== void 0 ? _b6 : {},
19556
19594
  channel: (_c = options === null || options === void 0 ? void 0 : options.channel) !== null && _c !== void 0 ? _c : "sms",
19557
19595
  gotrue_meta_security: { captcha_token: options === null || options === void 0 ? void 0 : options.captchaToken }
19558
19596
  },
@@ -19644,10 +19682,10 @@ var GoTrueClient = class _GoTrueClient {
19644
19682
  * This method supports the PKCE flow.
19645
19683
  */
19646
19684
  async signInWithOAuth(credentials) {
19647
- var _a65, _b5, _c, _d;
19685
+ var _a72, _b6, _c, _d;
19648
19686
  return await this._handleProviderSignIn(credentials.provider, {
19649
- redirectTo: (_a65 = credentials.options) === null || _a65 === void 0 ? void 0 : _a65.redirectTo,
19650
- scopes: (_b5 = credentials.options) === null || _b5 === void 0 ? void 0 : _b5.scopes,
19687
+ redirectTo: (_a72 = credentials.options) === null || _a72 === void 0 ? void 0 : _a72.redirectTo,
19688
+ scopes: (_b6 = credentials.options) === null || _b6 === void 0 ? void 0 : _b6.scopes,
19651
19689
  queryParams: (_c = credentials.options) === null || _c === void 0 ? void 0 : _c.queryParams,
19652
19690
  skipBrowserRedirect: (_d = credentials.options) === null || _d === void 0 ? void 0 : _d.skipBrowserRedirect
19653
19691
  });
@@ -19680,7 +19718,7 @@ var GoTrueClient = class _GoTrueClient {
19680
19718
  }
19681
19719
  }
19682
19720
  async signInWithEthereum(credentials) {
19683
- var _a65, _b5, _c, _d, _e, _f, _g, _h, _j, _k, _l;
19721
+ var _a72, _b6, _c, _d, _e, _f, _g, _h, _j, _k, _l;
19684
19722
  let message;
19685
19723
  let signature;
19686
19724
  if ("message" in credentials) {
@@ -19704,7 +19742,7 @@ var GoTrueClient = class _GoTrueClient {
19704
19742
  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.`);
19705
19743
  }
19706
19744
  }
19707
- const url = new URL((_a65 = options === null || options === void 0 ? void 0 : options.url) !== null && _a65 !== void 0 ? _a65 : window.location.href);
19745
+ const url = new URL((_a72 = options === null || options === void 0 ? void 0 : options.url) !== null && _a72 !== void 0 ? _a72 : window.location.href);
19708
19746
  const accounts = await resolvedWallet.request({
19709
19747
  method: "eth_requestAccounts"
19710
19748
  }).then((accs) => accs).catch(() => {
@@ -19714,7 +19752,7 @@ var GoTrueClient = class _GoTrueClient {
19714
19752
  throw new Error(`@supabase/auth-js: No accounts available. Please ensure the wallet is connected.`);
19715
19753
  }
19716
19754
  const address = getAddress(accounts[0]);
19717
- let chainId = (_b5 = options === null || options === void 0 ? void 0 : options.signInWithEthereum) === null || _b5 === void 0 ? void 0 : _b5.chainId;
19755
+ let chainId = (_b6 = options === null || options === void 0 ? void 0 : options.signInWithEthereum) === null || _b6 === void 0 ? void 0 : _b6.chainId;
19718
19756
  if (!chainId) {
19719
19757
  const chainIdHex = await resolvedWallet.request({
19720
19758
  method: "eth_chainId"
@@ -19771,7 +19809,7 @@ var GoTrueClient = class _GoTrueClient {
19771
19809
  }
19772
19810
  }
19773
19811
  async signInWithSolana(credentials) {
19774
- var _a65, _b5, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
19812
+ var _a72, _b6, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
19775
19813
  let message;
19776
19814
  let signature;
19777
19815
  if ("message" in credentials) {
@@ -19795,7 +19833,7 @@ var GoTrueClient = class _GoTrueClient {
19795
19833
  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.`);
19796
19834
  }
19797
19835
  }
19798
- const url = new URL((_a65 = options === null || options === void 0 ? void 0 : options.url) !== null && _a65 !== void 0 ? _a65 : window.location.href);
19836
+ const url = new URL((_a72 = options === null || options === void 0 ? void 0 : options.url) !== null && _a72 !== void 0 ? _a72 : window.location.href);
19799
19837
  if ("signIn" in resolvedWallet && resolvedWallet.signIn) {
19800
19838
  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), {
19801
19839
  // non-overridable properties
@@ -19827,7 +19865,7 @@ var GoTrueClient = class _GoTrueClient {
19827
19865
  ...statement ? ["", statement, ""] : [""],
19828
19866
  "Version: 1",
19829
19867
  `URI: ${url.href}`,
19830
- `Issued At: ${(_c = (_b5 = options === null || options === void 0 ? void 0 : options.signInWithSolana) === null || _b5 === void 0 ? void 0 : _b5.issuedAt) !== null && _c !== void 0 ? _c : (/* @__PURE__ */ new Date()).toISOString()}`,
19868
+ `Issued At: ${(_c = (_b6 = options === null || options === void 0 ? void 0 : options.signInWithSolana) === null || _b6 === void 0 ? void 0 : _b6.issuedAt) !== null && _c !== void 0 ? _c : (/* @__PURE__ */ new Date()).toISOString()}`,
19831
19869
  ...((_d = options === null || options === void 0 ? void 0 : options.signInWithSolana) === null || _d === void 0 ? void 0 : _d.notBefore) ? [`Not Before: ${options.signInWithSolana.notBefore}`] : [],
19832
19870
  ...((_e = options === null || options === void 0 ? void 0 : options.signInWithSolana) === null || _e === void 0 ? void 0 : _e.expirationTime) ? [`Expiration Time: ${options.signInWithSolana.expirationTime}`] : [],
19833
19871
  ...((_f = options === null || options === void 0 ? void 0 : options.signInWithSolana) === null || _f === void 0 ? void 0 : _f.chainId) ? [`Chain ID: ${options.signInWithSolana.chainId}`] : [],
@@ -19969,7 +20007,7 @@ var GoTrueClient = class _GoTrueClient {
19969
20007
  * This method supports PKCE when an email is passed.
19970
20008
  */
19971
20009
  async signInWithOtp(credentials) {
19972
- var _a65, _b5, _c, _d, _e;
20010
+ var _a72, _b6, _c, _d, _e;
19973
20011
  try {
19974
20012
  if ("email" in credentials) {
19975
20013
  const { email, options } = credentials;
@@ -19983,8 +20021,8 @@ var GoTrueClient = class _GoTrueClient {
19983
20021
  headers: this.headers,
19984
20022
  body: {
19985
20023
  email,
19986
- data: (_a65 = options === null || options === void 0 ? void 0 : options.data) !== null && _a65 !== void 0 ? _a65 : {},
19987
- create_user: (_b5 = options === null || options === void 0 ? void 0 : options.shouldCreateUser) !== null && _b5 !== void 0 ? _b5 : true,
20024
+ data: (_a72 = options === null || options === void 0 ? void 0 : options.data) !== null && _a72 !== void 0 ? _a72 : {},
20025
+ create_user: (_b6 = options === null || options === void 0 ? void 0 : options.shouldCreateUser) !== null && _b6 !== void 0 ? _b6 : true,
19988
20026
  gotrue_meta_security: { captcha_token: options === null || options === void 0 ? void 0 : options.captchaToken },
19989
20027
  code_challenge: codeChallenge,
19990
20028
  code_challenge_method: codeChallengeMethod
@@ -20023,13 +20061,13 @@ var GoTrueClient = class _GoTrueClient {
20023
20061
  * Log in a user given a User supplied OTP or TokenHash received through mobile or email.
20024
20062
  */
20025
20063
  async verifyOtp(params) {
20026
- var _a65, _b5;
20064
+ var _a72, _b6;
20027
20065
  try {
20028
20066
  let redirectTo = void 0;
20029
20067
  let captchaToken = void 0;
20030
20068
  if ("options" in params) {
20031
- redirectTo = (_a65 = params.options) === null || _a65 === void 0 ? void 0 : _a65.redirectTo;
20032
- captchaToken = (_b5 = params.options) === null || _b5 === void 0 ? void 0 : _b5.captchaToken;
20069
+ redirectTo = (_a72 = params.options) === null || _a72 === void 0 ? void 0 : _a72.redirectTo;
20070
+ captchaToken = (_b6 = params.options) === null || _b6 === void 0 ? void 0 : _b6.captchaToken;
20033
20071
  }
20034
20072
  const { data, error } = await _request(this.fetch, "POST", `${this.url}/verify`, {
20035
20073
  headers: this.headers,
@@ -20073,7 +20111,7 @@ var GoTrueClient = class _GoTrueClient {
20073
20111
  * organization's SSO Identity Provider UUID directly instead.
20074
20112
  */
20075
20113
  async signInWithSSO(params) {
20076
- var _a65, _b5, _c, _d, _e;
20114
+ var _a72, _b6, _c, _d, _e;
20077
20115
  try {
20078
20116
  let codeChallenge = null;
20079
20117
  let codeChallengeMethod = null;
@@ -20082,7 +20120,7 @@ var GoTrueClient = class _GoTrueClient {
20082
20120
  [codeChallenge, codeChallengeMethod] = await getCodeChallengeAndMethod(this.storage, this.storageKey);
20083
20121
  }
20084
20122
  const result = await _request(this.fetch, "POST", `${this.url}/sso`, {
20085
- 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: (_b5 = (_a65 = params.options) === null || _a65 === void 0 ? void 0 : _a65.redirectTo) !== null && _b5 !== void 0 ? _b5 : 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 }),
20123
+ 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: (_b6 = (_a72 = params.options) === null || _a72 === void 0 ? void 0 : _a72.redirectTo) !== null && _b6 !== void 0 ? _b6 : 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 }),
20086
20124
  headers: this.headers,
20087
20125
  xform: _ssoResponse
20088
20126
  });
@@ -20336,17 +20374,17 @@ var GoTrueClient = class _GoTrueClient {
20336
20374
  });
20337
20375
  }
20338
20376
  return await this._useSession(async (result) => {
20339
- var _a65, _b5, _c;
20377
+ var _a72, _b6, _c;
20340
20378
  const { data, error } = result;
20341
20379
  if (error) {
20342
20380
  throw error;
20343
20381
  }
20344
- if (!((_a65 = data.session) === null || _a65 === void 0 ? void 0 : _a65.access_token) && !this.hasCustomAuthorizationHeader) {
20382
+ if (!((_a72 = data.session) === null || _a72 === void 0 ? void 0 : _a72.access_token) && !this.hasCustomAuthorizationHeader) {
20345
20383
  return { data: { user: null }, error: new AuthSessionMissingError() };
20346
20384
  }
20347
20385
  return await _request(this.fetch, "GET", `${this.url}/user`, {
20348
20386
  headers: this.headers,
20349
- jwt: (_c = (_b5 = data.session) === null || _b5 === void 0 ? void 0 : _b5.access_token) !== null && _c !== void 0 ? _c : void 0,
20387
+ jwt: (_c = (_b6 = data.session) === null || _b6 === void 0 ? void 0 : _b6.access_token) !== null && _c !== void 0 ? _c : void 0,
20350
20388
  xform: _userResponse
20351
20389
  });
20352
20390
  });
@@ -20483,13 +20521,13 @@ var GoTrueClient = class _GoTrueClient {
20483
20521
  async _refreshSession(currentSession) {
20484
20522
  try {
20485
20523
  return await this._useSession(async (result) => {
20486
- var _a65;
20524
+ var _a72;
20487
20525
  if (!currentSession) {
20488
20526
  const { data, error: error2 } = result;
20489
20527
  if (error2) {
20490
20528
  throw error2;
20491
20529
  }
20492
- currentSession = (_a65 = data.session) !== null && _a65 !== void 0 ? _a65 : void 0;
20530
+ currentSession = (_a72 = data.session) !== null && _a72 !== void 0 ? _a72 : void 0;
20493
20531
  }
20494
20532
  if (!(currentSession === null || currentSession === void 0 ? void 0 : currentSession.refresh_token)) {
20495
20533
  throw new AuthSessionMissingError();
@@ -20627,12 +20665,12 @@ var GoTrueClient = class _GoTrueClient {
20627
20665
  }
20628
20666
  async _signOut({ scope } = { scope: "global" }) {
20629
20667
  return await this._useSession(async (result) => {
20630
- var _a65;
20668
+ var _a72;
20631
20669
  const { data, error: sessionError } = result;
20632
20670
  if (sessionError) {
20633
20671
  return this._returnResult({ error: sessionError });
20634
20672
  }
20635
- const accessToken = (_a65 = data.session) === null || _a65 === void 0 ? void 0 : _a65.access_token;
20673
+ const accessToken = (_a72 = data.session) === null || _a72 === void 0 ? void 0 : _a72.access_token;
20636
20674
  if (accessToken) {
20637
20675
  const { error } = await this.admin.signOut(accessToken, scope);
20638
20676
  if (error) {
@@ -20670,15 +20708,15 @@ var GoTrueClient = class _GoTrueClient {
20670
20708
  }
20671
20709
  async _emitInitialSession(id) {
20672
20710
  return await this._useSession(async (result) => {
20673
- var _a65, _b5;
20711
+ var _a72, _b6;
20674
20712
  try {
20675
20713
  const { data: { session }, error } = result;
20676
20714
  if (error)
20677
20715
  throw error;
20678
- await ((_a65 = this.stateChangeEmitters.get(id)) === null || _a65 === void 0 ? void 0 : _a65.callback("INITIAL_SESSION", session));
20716
+ await ((_a72 = this.stateChangeEmitters.get(id)) === null || _a72 === void 0 ? void 0 : _a72.callback("INITIAL_SESSION", session));
20679
20717
  this._debug("INITIAL_SESSION", "callback id", id, "session", session);
20680
20718
  } catch (err) {
20681
- await ((_b5 = this.stateChangeEmitters.get(id)) === null || _b5 === void 0 ? void 0 : _b5.callback("INITIAL_SESSION", null));
20719
+ await ((_b6 = this.stateChangeEmitters.get(id)) === null || _b6 === void 0 ? void 0 : _b6.callback("INITIAL_SESSION", null));
20682
20720
  this._debug("INITIAL_SESSION", "callback id", id, "error", err);
20683
20721
  console.error(err);
20684
20722
  }
@@ -20726,12 +20764,12 @@ var GoTrueClient = class _GoTrueClient {
20726
20764
  * Gets all the identities linked to a user.
20727
20765
  */
20728
20766
  async getUserIdentities() {
20729
- var _a65;
20767
+ var _a72;
20730
20768
  try {
20731
20769
  const { data, error } = await this.getUser();
20732
20770
  if (error)
20733
20771
  throw error;
20734
- return this._returnResult({ data: { identities: (_a65 = data.user.identities) !== null && _a65 !== void 0 ? _a65 : [] }, error: null });
20772
+ return this._returnResult({ data: { identities: (_a72 = data.user.identities) !== null && _a72 !== void 0 ? _a72 : [] }, error: null });
20735
20773
  } catch (error) {
20736
20774
  if (isAuthError(error)) {
20737
20775
  return this._returnResult({ data: null, error });
@@ -20746,16 +20784,16 @@ var GoTrueClient = class _GoTrueClient {
20746
20784
  return this.linkIdentityOAuth(credentials);
20747
20785
  }
20748
20786
  async linkIdentityOAuth(credentials) {
20749
- var _a65;
20787
+ var _a72;
20750
20788
  try {
20751
20789
  const { data, error } = await this._useSession(async (result) => {
20752
- var _a66, _b5, _c, _d, _e;
20790
+ var _a73, _b6, _c, _d, _e;
20753
20791
  const { data: data2, error: error2 } = result;
20754
20792
  if (error2)
20755
20793
  throw error2;
20756
20794
  const url = await this._getUrlForProvider(`${this.url}/user/identities/authorize`, credentials.provider, {
20757
- redirectTo: (_a66 = credentials.options) === null || _a66 === void 0 ? void 0 : _a66.redirectTo,
20758
- scopes: (_b5 = credentials.options) === null || _b5 === void 0 ? void 0 : _b5.scopes,
20795
+ redirectTo: (_a73 = credentials.options) === null || _a73 === void 0 ? void 0 : _a73.redirectTo,
20796
+ scopes: (_b6 = credentials.options) === null || _b6 === void 0 ? void 0 : _b6.scopes,
20759
20797
  queryParams: (_c = credentials.options) === null || _c === void 0 ? void 0 : _c.queryParams,
20760
20798
  skipBrowserRedirect: true
20761
20799
  });
@@ -20766,7 +20804,7 @@ var GoTrueClient = class _GoTrueClient {
20766
20804
  });
20767
20805
  if (error)
20768
20806
  throw error;
20769
- if (isBrowser() && !((_a65 = credentials.options) === null || _a65 === void 0 ? void 0 : _a65.skipBrowserRedirect)) {
20807
+ if (isBrowser() && !((_a72 = credentials.options) === null || _a72 === void 0 ? void 0 : _a72.skipBrowserRedirect)) {
20770
20808
  window.location.assign(data === null || data === void 0 ? void 0 : data.url);
20771
20809
  }
20772
20810
  return this._returnResult({
@@ -20782,7 +20820,7 @@ var GoTrueClient = class _GoTrueClient {
20782
20820
  }
20783
20821
  async linkIdentityIdToken(credentials) {
20784
20822
  return await this._useSession(async (result) => {
20785
- var _a65;
20823
+ var _a72;
20786
20824
  try {
20787
20825
  const { error: sessionError, data: { session } } = result;
20788
20826
  if (sessionError)
@@ -20790,7 +20828,7 @@ var GoTrueClient = class _GoTrueClient {
20790
20828
  const { options, provider, token, access_token, nonce } = credentials;
20791
20829
  const res = await _request(this.fetch, "POST", `${this.url}/token?grant_type=id_token`, {
20792
20830
  headers: this.headers,
20793
- jwt: (_a65 = session === null || session === void 0 ? void 0 : session.access_token) !== null && _a65 !== void 0 ? _a65 : void 0,
20831
+ jwt: (_a72 = session === null || session === void 0 ? void 0 : session.access_token) !== null && _a72 !== void 0 ? _a72 : void 0,
20794
20832
  body: {
20795
20833
  provider,
20796
20834
  id_token: token,
@@ -20830,14 +20868,14 @@ var GoTrueClient = class _GoTrueClient {
20830
20868
  async unlinkIdentity(identity) {
20831
20869
  try {
20832
20870
  return await this._useSession(async (result) => {
20833
- var _a65, _b5;
20871
+ var _a72, _b6;
20834
20872
  const { data, error } = result;
20835
20873
  if (error) {
20836
20874
  throw error;
20837
20875
  }
20838
20876
  return await _request(this.fetch, "DELETE", `${this.url}/user/identities/${identity.identity_id}`, {
20839
20877
  headers: this.headers,
20840
- jwt: (_b5 = (_a65 = data.session) === null || _a65 === void 0 ? void 0 : _a65.access_token) !== null && _b5 !== void 0 ? _b5 : void 0
20878
+ jwt: (_b6 = (_a72 = data.session) === null || _a72 === void 0 ? void 0 : _a72.access_token) !== null && _b6 !== void 0 ? _b6 : void 0
20841
20879
  });
20842
20880
  });
20843
20881
  } catch (error) {
@@ -20902,7 +20940,7 @@ var GoTrueClient = class _GoTrueClient {
20902
20940
  * Note: this method is async to accommodate for AsyncStorage e.g. in React native.
20903
20941
  */
20904
20942
  async _recoverAndRefresh() {
20905
- var _a65, _b5;
20943
+ var _a72, _b6;
20906
20944
  const debugName = "#_recoverAndRefresh()";
20907
20945
  this._debug(debugName, "begin");
20908
20946
  try {
@@ -20913,7 +20951,7 @@ var GoTrueClient = class _GoTrueClient {
20913
20951
  maybeUser = { user: currentSession.user };
20914
20952
  await setItemAsync(this.userStorage, this.storageKey + "-user", maybeUser);
20915
20953
  }
20916
- currentSession.user = (_a65 = maybeUser === null || maybeUser === void 0 ? void 0 : maybeUser.user) !== null && _a65 !== void 0 ? _a65 : userNotAvailableProxy();
20954
+ currentSession.user = (_a72 = maybeUser === null || maybeUser === void 0 ? void 0 : maybeUser.user) !== null && _a72 !== void 0 ? _a72 : userNotAvailableProxy();
20917
20955
  } else if (currentSession && !currentSession.user) {
20918
20956
  if (!currentSession.user) {
20919
20957
  const separateUser = await getItemAsync(this.storage, this.storageKey + "-user");
@@ -20934,7 +20972,7 @@ var GoTrueClient = class _GoTrueClient {
20934
20972
  }
20935
20973
  return;
20936
20974
  }
20937
- const expiresWithMargin = ((_b5 = currentSession.expires_at) !== null && _b5 !== void 0 ? _b5 : Infinity) * 1e3 - Date.now() < EXPIRY_MARGIN_MS;
20975
+ const expiresWithMargin = ((_b6 = currentSession.expires_at) !== null && _b6 !== void 0 ? _b6 : Infinity) * 1e3 - Date.now() < EXPIRY_MARGIN_MS;
20938
20976
  this._debug(debugName, `session has${expiresWithMargin ? "" : " not"} expired with margin of ${EXPIRY_MARGIN_MS}s`);
20939
20977
  if (expiresWithMargin) {
20940
20978
  if (this.autoRefreshToken && currentSession.refresh_token) {
@@ -20973,7 +21011,7 @@ var GoTrueClient = class _GoTrueClient {
20973
21011
  }
20974
21012
  }
20975
21013
  async _callRefreshToken(refreshToken) {
20976
- var _a65, _b5;
21014
+ var _a72, _b6;
20977
21015
  if (!refreshToken) {
20978
21016
  throw new AuthSessionMissingError();
20979
21017
  }
@@ -21001,10 +21039,10 @@ var GoTrueClient = class _GoTrueClient {
21001
21039
  if (!isAuthRetryableFetchError(error)) {
21002
21040
  await this._removeSession();
21003
21041
  }
21004
- (_a65 = this.refreshingDeferred) === null || _a65 === void 0 ? void 0 : _a65.resolve(result);
21042
+ (_a72 = this.refreshingDeferred) === null || _a72 === void 0 ? void 0 : _a72.resolve(result);
21005
21043
  return result;
21006
21044
  }
21007
- (_b5 = this.refreshingDeferred) === null || _b5 === void 0 ? void 0 : _b5.reject(error);
21045
+ (_b6 = this.refreshingDeferred) === null || _b6 === void 0 ? void 0 : _b6.reject(error);
21008
21046
  throw error;
21009
21047
  } finally {
21010
21048
  this.refreshingDeferred = null;
@@ -21290,14 +21328,14 @@ var GoTrueClient = class _GoTrueClient {
21290
21328
  async _unenroll(params) {
21291
21329
  try {
21292
21330
  return await this._useSession(async (result) => {
21293
- var _a65;
21331
+ var _a72;
21294
21332
  const { data: sessionData, error: sessionError } = result;
21295
21333
  if (sessionError) {
21296
21334
  return this._returnResult({ data: null, error: sessionError });
21297
21335
  }
21298
21336
  return await _request(this.fetch, "DELETE", `${this.url}/factors/${params.factorId}`, {
21299
21337
  headers: this.headers,
21300
- jwt: (_a65 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a65 === void 0 ? void 0 : _a65.access_token
21338
+ jwt: (_a72 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a72 === void 0 ? void 0 : _a72.access_token
21301
21339
  });
21302
21340
  });
21303
21341
  } catch (error) {
@@ -21310,7 +21348,7 @@ var GoTrueClient = class _GoTrueClient {
21310
21348
  async _enroll(params) {
21311
21349
  try {
21312
21350
  return await this._useSession(async (result) => {
21313
- var _a65, _b5;
21351
+ var _a72, _b6;
21314
21352
  const { data: sessionData, error: sessionError } = result;
21315
21353
  if (sessionError) {
21316
21354
  return this._returnResult({ data: null, error: sessionError });
@@ -21319,12 +21357,12 @@ var GoTrueClient = class _GoTrueClient {
21319
21357
  const { data, error } = await _request(this.fetch, "POST", `${this.url}/factors`, {
21320
21358
  body,
21321
21359
  headers: this.headers,
21322
- jwt: (_a65 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a65 === void 0 ? void 0 : _a65.access_token
21360
+ jwt: (_a72 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a72 === void 0 ? void 0 : _a72.access_token
21323
21361
  });
21324
21362
  if (error) {
21325
21363
  return this._returnResult({ data: null, error });
21326
21364
  }
21327
- if (params.factorType === "totp" && data.type === "totp" && ((_b5 = data === null || data === void 0 ? void 0 : data.totp) === null || _b5 === void 0 ? void 0 : _b5.qr_code)) {
21365
+ if (params.factorType === "totp" && data.type === "totp" && ((_b6 = data === null || data === void 0 ? void 0 : data.totp) === null || _b6 === void 0 ? void 0 : _b6.qr_code)) {
21328
21366
  data.totp.qr_code = `data:image/svg+xml;utf-8,${data.totp.qr_code}`;
21329
21367
  }
21330
21368
  return this._returnResult({ data, error: null });
@@ -21340,7 +21378,7 @@ var GoTrueClient = class _GoTrueClient {
21340
21378
  return this._acquireLock(this.lockAcquireTimeout, async () => {
21341
21379
  try {
21342
21380
  return await this._useSession(async (result) => {
21343
- var _a65;
21381
+ var _a72;
21344
21382
  const { data: sessionData, error: sessionError } = result;
21345
21383
  if (sessionError) {
21346
21384
  return this._returnResult({ data: null, error: sessionError });
@@ -21351,7 +21389,7 @@ var GoTrueClient = class _GoTrueClient {
21351
21389
  const { data, error } = await _request(this.fetch, "POST", `${this.url}/factors/${params.factorId}/verify`, {
21352
21390
  body,
21353
21391
  headers: this.headers,
21354
- jwt: (_a65 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a65 === void 0 ? void 0 : _a65.access_token
21392
+ jwt: (_a72 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a72 === void 0 ? void 0 : _a72.access_token
21355
21393
  });
21356
21394
  if (error) {
21357
21395
  return this._returnResult({ data: null, error });
@@ -21372,7 +21410,7 @@ var GoTrueClient = class _GoTrueClient {
21372
21410
  return this._acquireLock(this.lockAcquireTimeout, async () => {
21373
21411
  try {
21374
21412
  return await this._useSession(async (result) => {
21375
- var _a65;
21413
+ var _a72;
21376
21414
  const { data: sessionData, error: sessionError } = result;
21377
21415
  if (sessionError) {
21378
21416
  return this._returnResult({ data: null, error: sessionError });
@@ -21380,7 +21418,7 @@ var GoTrueClient = class _GoTrueClient {
21380
21418
  const response = await _request(this.fetch, "POST", `${this.url}/factors/${params.factorId}/challenge`, {
21381
21419
  body: params,
21382
21420
  headers: this.headers,
21383
- jwt: (_a65 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a65 === void 0 ? void 0 : _a65.access_token
21421
+ jwt: (_a72 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a72 === void 0 ? void 0 : _a72.access_token
21384
21422
  });
21385
21423
  if (response.error) {
21386
21424
  return response;
@@ -21430,7 +21468,7 @@ var GoTrueClient = class _GoTrueClient {
21430
21468
  * {@see GoTrueMFAApi#listFactors}
21431
21469
  */
21432
21470
  async _listFactors() {
21433
- var _a65;
21471
+ var _a72;
21434
21472
  const { data: { user }, error: userError } = await this.getUser();
21435
21473
  if (userError) {
21436
21474
  return { data: null, error: userError };
@@ -21441,7 +21479,7 @@ var GoTrueClient = class _GoTrueClient {
21441
21479
  totp: [],
21442
21480
  webauthn: []
21443
21481
  };
21444
- for (const factor of (_a65 = user === null || user === void 0 ? void 0 : user.factors) !== null && _a65 !== void 0 ? _a65 : []) {
21482
+ for (const factor of (_a72 = user === null || user === void 0 ? void 0 : user.factors) !== null && _a72 !== void 0 ? _a72 : []) {
21445
21483
  data.all.push(factor);
21446
21484
  if (factor.status === "verified") {
21447
21485
  ;
@@ -21457,7 +21495,7 @@ var GoTrueClient = class _GoTrueClient {
21457
21495
  * {@see GoTrueMFAApi#getAuthenticatorAssuranceLevel}
21458
21496
  */
21459
21497
  async _getAuthenticatorAssuranceLevel() {
21460
- var _a65, _b5;
21498
+ var _a72, _b6;
21461
21499
  const { data: { session }, error: sessionError } = await this.getSession();
21462
21500
  if (sessionError) {
21463
21501
  return this._returnResult({ data: null, error: sessionError });
@@ -21474,7 +21512,7 @@ var GoTrueClient = class _GoTrueClient {
21474
21512
  currentLevel = payload.aal;
21475
21513
  }
21476
21514
  let nextLevel = currentLevel;
21477
- const verifiedFactors = (_b5 = (_a65 = session.user.factors) === null || _a65 === void 0 ? void 0 : _a65.filter((factor) => factor.status === "verified")) !== null && _b5 !== void 0 ? _b5 : [];
21515
+ const verifiedFactors = (_b6 = (_a72 = session.user.factors) === null || _a72 === void 0 ? void 0 : _a72.filter((factor) => factor.status === "verified")) !== null && _b6 !== void 0 ? _b6 : [];
21478
21516
  if (verifiedFactors.length > 0) {
21479
21517
  nextLevel = "aal2";
21480
21518
  }
@@ -22080,10 +22118,10 @@ if (shouldShowDeprecationWarning()) console.warn("\u26A0\uFE0F Node.js 18 and b
22080
22118
  var cachedStargate = null;
22081
22119
  var cachedPublic = null;
22082
22120
  function getSupabase() {
22083
- var _a65;
22121
+ var _a72;
22084
22122
  if (cachedStargate) return cachedStargate;
22085
22123
  const url = getRuntimeEnv("VITE_SUPABASE_URL");
22086
- const anon = (_a65 = getRuntimeEnv("VITE_SUPABASE_ANON_KEY")) != null ? _a65 : getRuntimeEnv("VITE_SUPABASE_PUBLISHABLE_KEY");
22124
+ const anon = (_a72 = getRuntimeEnv("VITE_SUPABASE_ANON_KEY")) != null ? _a72 : getRuntimeEnv("VITE_SUPABASE_PUBLISHABLE_KEY");
22087
22125
  const schema = getRuntimeEnvOr("VITE_SUPABASE_SCHEMA", "public");
22088
22126
  if (!url || !anon) {
22089
22127
  if (isRuntimeDev()) {
@@ -22101,10 +22139,10 @@ function getSupabase() {
22101
22139
  return cachedStargate;
22102
22140
  }
22103
22141
  function getSupabasePublic() {
22104
- var _a65;
22142
+ var _a72;
22105
22143
  if (cachedPublic) return cachedPublic;
22106
22144
  const url = getRuntimeEnv("VITE_SUPABASE_URL");
22107
- const anon = (_a65 = getRuntimeEnv("VITE_SUPABASE_ANON_KEY")) != null ? _a65 : getRuntimeEnv("VITE_SUPABASE_PUBLISHABLE_KEY");
22145
+ const anon = (_a72 = getRuntimeEnv("VITE_SUPABASE_ANON_KEY")) != null ? _a72 : getRuntimeEnv("VITE_SUPABASE_PUBLISHABLE_KEY");
22108
22146
  if (!url || !anon) {
22109
22147
  if (isRuntimeDev()) {
22110
22148
  console.log("[supabase] getSupabasePublic: env faltando", { hasUrl: !!url, hasAnon: !!anon });
@@ -22179,15 +22217,15 @@ var Toaster = ({ theme, ...props }) => {
22179
22217
  // src/lib/accountsAuth.ts
22180
22218
  var normalizeBaseUrl2 = (value) => value.replace(/\/+$/, "");
22181
22219
  var getAccountsConfig = () => {
22182
- var _a65, _b5, _c;
22220
+ var _a72, _b6, _c;
22183
22221
  const baseUrl = normalizeBaseUrl2(
22184
- (_a65 = getRuntimeEnv("VITE_ACCOUNTS_BASE_URL")) != null ? _a65 : "https://accounts.cupcode.com.br"
22222
+ (_a72 = getRuntimeEnv("VITE_ACCOUNTS_BASE_URL")) != null ? _a72 : "https://accounts.cupcode.com.br"
22185
22223
  );
22186
22224
  const clientId = getRuntimeEnv("VITE_ACCOUNTS_CLIENT_ID");
22187
22225
  if (!clientId) {
22188
22226
  throw new Error("VITE_ACCOUNTS_CLIENT_ID \xE9 obrigat\xF3rio para login.");
22189
22227
  }
22190
- const redirectUri = (_b5 = getRuntimeEnv("VITE_ACCOUNTS_REDIRECT_URI")) != null ? _b5 : `${window.location.origin}/auth/callback`;
22228
+ const redirectUri = (_b6 = getRuntimeEnv("VITE_ACCOUNTS_REDIRECT_URI")) != null ? _b6 : `${window.location.origin}/auth/callback`;
22191
22229
  return {
22192
22230
  baseUrl,
22193
22231
  clientId,
@@ -22202,7 +22240,7 @@ var getAccountsConfig = () => {
22202
22240
  };
22203
22241
  var cachedDiscovery = null;
22204
22242
  var resolveOidcEndpoints = async (config) => {
22205
- var _a65, _b5, _c, _d, _e, _f;
22243
+ var _a72, _b6, _c, _d, _e, _f;
22206
22244
  if (config.authUrl && config.tokenUrl) {
22207
22245
  return {
22208
22246
  authUrl: config.authUrl,
@@ -22212,8 +22250,8 @@ var resolveOidcEndpoints = async (config) => {
22212
22250
  }
22213
22251
  if (cachedDiscovery) {
22214
22252
  return {
22215
- authUrl: (_a65 = cachedDiscovery.authorization_endpoint) != null ? _a65 : config.authUrl,
22216
- tokenUrl: (_b5 = cachedDiscovery.token_endpoint) != null ? _b5 : config.tokenUrl,
22253
+ authUrl: (_a72 = cachedDiscovery.authorization_endpoint) != null ? _a72 : config.authUrl,
22254
+ tokenUrl: (_b6 = cachedDiscovery.token_endpoint) != null ? _b6 : config.tokenUrl,
22217
22255
  logoutUrl: (_c = cachedDiscovery.end_session_endpoint) != null ? _c : config.logoutUrl
22218
22256
  };
22219
22257
  }
@@ -22570,12 +22608,12 @@ var resolveCurrentUserId = (user) => {
22570
22608
  return null;
22571
22609
  };
22572
22610
  var resolveUserIdFromClaims = (claims) => {
22573
- var _a65, _b5, _c, _d, _e;
22574
- return (_e = (_d = (_c = (_b5 = (_a65 = toStringOrUndefined(claims.sub)) != null ? _a65 : toStringOrUndefined(claims.user_id)) != null ? _b5 : toStringOrUndefined(claims.userId)) != null ? _c : toStringOrUndefined(claims.uid)) != null ? _d : toStringOrUndefined(claims.id)) != null ? _e : toStringOrUndefined(claims["https://cupcode.com/user_id"]);
22611
+ var _a72, _b6, _c, _d, _e;
22612
+ return (_e = (_d = (_c = (_b6 = (_a72 = toStringOrUndefined(claims.sub)) != null ? _a72 : toStringOrUndefined(claims.user_id)) != null ? _b6 : toStringOrUndefined(claims.userId)) != null ? _c : toStringOrUndefined(claims.uid)) != null ? _d : toStringOrUndefined(claims.id)) != null ? _e : toStringOrUndefined(claims["https://cupcode.com/user_id"]);
22575
22613
  };
22576
22614
  var resolveEmailFromClaims = (claims) => {
22577
- var _a65, _b5;
22578
- const candidate = (_b5 = (_a65 = toStringOrUndefined(claims.email)) != null ? _a65 : toStringOrUndefined(claims["https://cupcode.com/email"])) != null ? _b5 : toStringOrUndefined(claims.preferred_username);
22615
+ var _a72, _b6;
22616
+ const candidate = (_b6 = (_a72 = toStringOrUndefined(claims.email)) != null ? _a72 : toStringOrUndefined(claims["https://cupcode.com/email"])) != null ? _b6 : toStringOrUndefined(claims.preferred_username);
22579
22617
  if (!candidate || !candidate.includes("@")) return void 0;
22580
22618
  return candidate.toLowerCase();
22581
22619
  };
@@ -22586,18 +22624,7 @@ var formatMessageTime = (rawTimestamp) => {
22586
22624
  return parsed.toLocaleTimeString("pt-BR", { hour: "2-digit", minute: "2-digit" });
22587
22625
  };
22588
22626
  var resolveChatAvatarUrl = (value) => {
22589
- const raw = toStringOrUndefined(value);
22590
- if (!raw) return void 0;
22591
- if (raw.startsWith("http://") || raw.startsWith("https://") || raw.startsWith("data:") || raw.startsWith("blob:")) {
22592
- const parsedId2 = parseAssetId(raw);
22593
- if (parsedId2) {
22594
- return buildTelescupImageURL({ id: parsedId2, width: 72, height: 72, fit: "cover", format: "avif", quality: 70 });
22595
- }
22596
- return raw;
22597
- }
22598
- const parsedId = parseAssetId(raw);
22599
- if (!parsedId) return void 0;
22600
- return buildTelescupImageURL({ id: parsedId, width: 72, height: 72, fit: "cover", format: "avif", quality: 70 });
22627
+ return resolveTelescupImageURL(value, { width: 72, height: 72, fit: "cover", format: "avif", quality: 70 });
22601
22628
  };
22602
22629
  var isGenericRecord = (value) => typeof value === "object" && value !== null;
22603
22630
  var buildExternalUrl = (baseUrl, target) => {
@@ -22651,8 +22678,8 @@ var parseRecentActivityItems = (payload) => {
22651
22678
  return [];
22652
22679
  };
22653
22680
  return toRows(payload).map((item, index) => {
22654
- var _a65, _b5, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
22655
- const id = (_b5 = (_a65 = toStringOrUndefined(item.id)) != null ? _a65 : toStringOrUndefined(item.event_id)) != null ? _b5 : `accounts-activity-${index}`;
22681
+ var _a72, _b6, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
22682
+ const id = (_b6 = (_a72 = toStringOrUndefined(item.id)) != null ? _a72 : toStringOrUndefined(item.event_id)) != null ? _b6 : `accounts-activity-${index}`;
22656
22683
  const title = (_e = (_d = (_c = toStringOrUndefined(item.title)) != null ? _c : toStringOrUndefined(item.action)) != null ? _d : toStringOrUndefined(item.event)) != null ? _e : toStringOrUndefined(item.type);
22657
22684
  if (!title) return null;
22658
22685
  const description = (_h = (_g = (_f = toStringOrUndefined(item.description)) != null ? _f : toStringOrUndefined(item.details)) != null ? _g : toStringOrUndefined(item.message)) != null ? _h : toStringOrUndefined(item.summary);
@@ -22735,9 +22762,9 @@ var dedupeAndSortReactions = (reactions) => {
22735
22762
  });
22736
22763
  };
22737
22764
  var getErrorText = (error) => {
22738
- var _a65, _b5, _c;
22765
+ var _a72, _b6, _c;
22739
22766
  const typed = error;
22740
- return `${(_a65 = typed == null ? void 0 : typed.message) != null ? _a65 : ""} ${(_b5 = typed == null ? void 0 : typed.details) != null ? _b5 : ""} ${(_c = typed == null ? void 0 : typed.hint) != null ? _c : ""}`.toLowerCase();
22767
+ return `${(_a72 = typed == null ? void 0 : typed.message) != null ? _a72 : ""} ${(_b6 = typed == null ? void 0 : typed.details) != null ? _b6 : ""} ${(_c = typed == null ? void 0 : typed.hint) != null ? _c : ""}`.toLowerCase();
22741
22768
  };
22742
22769
  var isMissingColumnError = (error, column) => {
22743
22770
  const normalized = getErrorText(error);
@@ -22763,13 +22790,13 @@ var isRecoverableLookupError = (error, relationName) => {
22763
22790
  return normalized.includes("schema cache") || normalized.includes("permission denied") || normalized.includes("does not exist") || normalized.includes("could not find");
22764
22791
  };
22765
22792
  var toChatMessage = (row, currentUserId) => {
22766
- var _a65, _b5, _c, _d, _e, _f;
22767
- const id = (_a65 = toStringOrUndefined(row[CHAT_MESSAGES_ID_COLUMN])) != null ? _a65 : `${toStringOrUndefined(row[CHAT_MESSAGES_SENDER_COLUMN])}-${toStringOrUndefined(row[CHAT_MESSAGES_RECIPIENT_COLUMN])}-${toStringOrUndefined(row[CHAT_MESSAGES_CREATED_AT_COLUMN])}`;
22793
+ var _a72, _b6, _c, _d, _e, _f;
22794
+ const id = (_a72 = toStringOrUndefined(row[CHAT_MESSAGES_ID_COLUMN])) != null ? _a72 : `${toStringOrUndefined(row[CHAT_MESSAGES_SENDER_COLUMN])}-${toStringOrUndefined(row[CHAT_MESSAGES_RECIPIENT_COLUMN])}-${toStringOrUndefined(row[CHAT_MESSAGES_CREATED_AT_COLUMN])}`;
22768
22795
  const senderId = toStringOrUndefined(row[CHAT_MESSAGES_SENDER_COLUMN]);
22769
22796
  const recipientId = toStringOrUndefined(row[CHAT_MESSAGES_RECIPIENT_COLUMN]);
22770
22797
  const text = toStringOrUndefined(row[CHAT_MESSAGES_TEXT_COLUMN]);
22771
22798
  const createdAt = toStringOrUndefined(row[CHAT_MESSAGES_CREATED_AT_COLUMN]);
22772
- const editedAt = (_b5 = toStringOrUndefined(row[CHAT_MESSAGES_EDITED_AT_COLUMN])) != null ? _b5 : null;
22799
+ const editedAt = (_b6 = toStringOrUndefined(row[CHAT_MESSAGES_EDITED_AT_COLUMN])) != null ? _b6 : null;
22773
22800
  const readAt = (_c = toStringOrUndefined(row[CHAT_MESSAGES_READ_AT_COLUMN])) != null ? _c : null;
22774
22801
  const replyToMessageId = (_d = toStringOrUndefined(row[CHAT_MESSAGES_REPLY_TO_COLUMN])) != null ? _d : null;
22775
22802
  const deletedAt = (_e = toStringOrUndefined(row[CHAT_MESSAGES_DELETED_AT_COLUMN])) != null ? _e : null;
@@ -22804,13 +22831,13 @@ var toChatReaction = (row) => {
22804
22831
  return { id, messageId, userId, emoji, createdAt };
22805
22832
  };
22806
22833
  var toChatMessageLog = (row, messagesById) => {
22807
- var _a65, _b5;
22834
+ var _a72, _b6;
22808
22835
  const id = toStringOrUndefined(row[CHAT_LOGS_ID_COLUMN]);
22809
22836
  const messageId = toStringOrUndefined(row[CHAT_LOGS_MESSAGE_ID_COLUMN]);
22810
22837
  const actorId = toStringOrUndefined(row[CHAT_LOGS_ACTOR_ID_COLUMN]);
22811
22838
  const action = toStringOrUndefined(row[CHAT_LOGS_ACTION_COLUMN]);
22812
- const previousText = (_a65 = toStringOrUndefined(row[CHAT_LOGS_PREVIOUS_TEXT_COLUMN])) != null ? _a65 : null;
22813
- const nextText = (_b5 = toStringOrUndefined(row[CHAT_LOGS_NEXT_TEXT_COLUMN])) != null ? _b5 : null;
22839
+ const previousText = (_a72 = toStringOrUndefined(row[CHAT_LOGS_PREVIOUS_TEXT_COLUMN])) != null ? _a72 : null;
22840
+ const nextText = (_b6 = toStringOrUndefined(row[CHAT_LOGS_NEXT_TEXT_COLUMN])) != null ? _b6 : null;
22814
22841
  const createdAt = toStringOrUndefined(row[CHAT_LOGS_CREATED_AT_COLUMN]);
22815
22842
  if (!id || !messageId || !action || action !== "edit" && action !== "delete") return null;
22816
22843
  const relatedMessage = messagesById.get(messageId);
@@ -22851,7 +22878,7 @@ var MainNavbar = ({
22851
22878
  onOpenAccountClick,
22852
22879
  getAccessToken
22853
22880
  }) => {
22854
- var _a65, _b5, _c;
22881
+ var _a72, _b6, _c;
22855
22882
  const [chatUsers, setChatUsers] = (0, import_react19.useState)([]);
22856
22883
  const [chatMessages, setChatMessages] = (0, import_react19.useState)([]);
22857
22884
  const [chatMessageLogs, setChatMessageLogs] = (0, import_react19.useState)([]);
@@ -22882,19 +22909,19 @@ var MainNavbar = ({
22882
22909
  return "/";
22883
22910
  }, [pathname]);
22884
22911
  const currentUserId = (0, import_react19.useMemo)(() => {
22885
- var _a66;
22886
- return (_a66 = resolveCurrentUserId(authUser)) != null ? _a66 : tokenDerivedUserId;
22912
+ var _a73;
22913
+ return (_a73 = resolveCurrentUserId(authUser)) != null ? _a73 : tokenDerivedUserId;
22887
22914
  }, [authUser, tokenDerivedUserId]);
22888
22915
  const authEmail = (0, import_react19.useMemo)(
22889
22916
  () => {
22890
- var _a66, _b6;
22891
- return (_b6 = (_a66 = toStringOrUndefined(authUser == null ? void 0 : authUser.email)) == null ? void 0 : _a66.toLowerCase()) != null ? _b6 : tokenDerivedEmail;
22917
+ var _a73, _b7;
22918
+ return (_b7 = (_a73 = toStringOrUndefined(authUser == null ? void 0 : authUser.email)) == null ? void 0 : _a73.toLowerCase()) != null ? _b7 : tokenDerivedEmail;
22892
22919
  },
22893
22920
  [authUser == null ? void 0 : authUser.email, tokenDerivedEmail]
22894
22921
  );
22895
22922
  const isChatSuperAdmin = (0, import_react19.useMemo)(() => {
22896
- var _a66, _b6;
22897
- const roleTokens = `${(_a66 = authUser == null ? void 0 : authUser.role) != null ? _a66 : ""} ${(_b6 = authUser == null ? void 0 : authUser.jobTitle) != null ? _b6 : ""}`.toLowerCase();
22923
+ var _a73, _b7;
22924
+ const roleTokens = `${(_a73 = authUser == null ? void 0 : authUser.role) != null ? _a73 : ""} ${(_b7 = authUser == null ? void 0 : authUser.jobTitle) != null ? _b7 : ""}`.toLowerCase();
22898
22925
  return roleTokens.includes("superadmin") || roleTokens.includes("super admin");
22899
22926
  }, [authUser == null ? void 0 : authUser.jobTitle, authUser == null ? void 0 : authUser.role]);
22900
22927
  const resolvedTelescupBaseUrl = (0, import_react19.useMemo)(() => {
@@ -22903,7 +22930,7 @@ var MainNavbar = ({
22903
22930
  }
22904
22931
  return TELESCUP_BASE_URL_FALLBACK;
22905
22932
  }, []);
22906
- const resolvedProfileAvatarUrl = (_b5 = (_a65 = resolveChatAvatarUrl(persistedProfileAvatarValue)) != null ? _a65 : authUser == null ? void 0 : authUser.picture) != null ? _b5 : void 0;
22933
+ const resolvedProfileAvatarUrl = (_b6 = (_a72 = resolveChatAvatarUrl(persistedProfileAvatarValue)) != null ? _a72 : authUser == null ? void 0 : authUser.picture) != null ? _b6 : void 0;
22907
22934
  const effectiveCurrentUserId = resolvedSenderId != null ? resolvedSenderId : currentUserId;
22908
22935
  const hasStoredAccessToken = (() => {
22909
22936
  if (typeof window === "undefined") return false;
@@ -22941,7 +22968,7 @@ var MainNavbar = ({
22941
22968
  }
22942
22969
  let canceled = false;
22943
22970
  const resolveIdentityFromToken = async () => {
22944
- var _a66, _b6;
22971
+ var _a73, _b7;
22945
22972
  try {
22946
22973
  let token = null;
22947
22974
  if (typeof window !== "undefined") {
@@ -22961,9 +22988,9 @@ var MainNavbar = ({
22961
22988
  }
22962
22989
  return;
22963
22990
  }
22964
- const claims = (_a66 = decodeJwt(token)) != null ? _a66 : {};
22991
+ const claims = (_a73 = decodeJwt(token)) != null ? _a73 : {};
22965
22992
  if (canceled) return;
22966
- setTokenDerivedUserId((_b6 = resolveUserIdFromClaims(claims)) != null ? _b6 : null);
22993
+ setTokenDerivedUserId((_b7 = resolveUserIdFromClaims(claims)) != null ? _b7 : null);
22967
22994
  setTokenDerivedEmail(resolveEmailFromClaims(claims));
22968
22995
  } catch (error) {
22969
22996
  if (isRuntimeDev()) {
@@ -23006,7 +23033,7 @@ var MainNavbar = ({
23006
23033
  );
23007
23034
  const warnings = [];
23008
23035
  const runLookup = async (kind, value, columns) => {
23009
- var _a66, _b6, _c2;
23036
+ var _a73, _b7, _c2;
23010
23037
  for (const tableName of CHAT_USERS_LOOKUP_TABLES) {
23011
23038
  for (const columnName of columns) {
23012
23039
  if (!columnName) continue;
@@ -23015,10 +23042,10 @@ var MainNavbar = ({
23015
23042
  const lookupError = response.error;
23016
23043
  if (lookupError) {
23017
23044
  if (isRecoverableLookupError(lookupError, tableName)) {
23018
- warnings.push(`${tableName}.${columnName}: ${(_a66 = lookupError.message) != null ? _a66 : "falha de lookup"}`);
23045
+ warnings.push(`${tableName}.${columnName}: ${(_a73 = lookupError.message) != null ? _a73 : "falha de lookup"}`);
23019
23046
  continue;
23020
23047
  }
23021
- warnings.push(`${tableName}.${columnName}: ${(_b6 = lookupError.message) != null ? _b6 : "falha de lookup"}`);
23048
+ warnings.push(`${tableName}.${columnName}: ${(_b7 = lookupError.message) != null ? _b7 : "falha de lookup"}`);
23022
23049
  continue;
23023
23050
  }
23024
23051
  const row2 = (_c2 = response.data) == null ? void 0 : _c2[0];
@@ -23067,7 +23094,7 @@ var MainNavbar = ({
23067
23094
  return sessionStorage.getItem(ACCESS_TOKEN_STORAGE_KEY);
23068
23095
  };
23069
23096
  const loadAccountsContext = async () => {
23070
- var _a66, _b6, _c2, _d, _e, _f, _g;
23097
+ var _a73, _b7, _c2, _d, _e, _f, _g;
23071
23098
  setIsAccountsActivityLoading(true);
23072
23099
  try {
23073
23100
  const token = await resolveAccountsToken();
@@ -23077,9 +23104,9 @@ var MainNavbar = ({
23077
23104
  }
23078
23105
  return;
23079
23106
  }
23080
- const claims = (_a66 = decodeJwt(token)) != null ? _a66 : {};
23107
+ const claims = (_a73 = decodeJwt(token)) != null ? _a73 : {};
23081
23108
  const languageFromToken = normalizeMenuLanguage(
23082
- (_d = (_c2 = (_b6 = claims.locale) != null ? _b6 : claims.lang) != null ? _c2 : claims.language) != null ? _d : claims["https://cupcode.com/locale"]
23109
+ (_d = (_c2 = (_b7 = claims.locale) != null ? _b7 : claims.lang) != null ? _c2 : claims.language) != null ? _d : claims["https://cupcode.com/locale"]
23083
23110
  );
23084
23111
  if (!canceled) {
23085
23112
  setAccountsLanguage(languageFromToken);
@@ -23165,11 +23192,11 @@ var MainNavbar = ({
23165
23192
  }
23166
23193
  let canceled = false;
23167
23194
  const loadChatData = async () => {
23168
- var _a66, _b6, _c2, _d, _e, _f, _g, _h, _i;
23195
+ var _a73, _b7, _c2, _d, _e, _f, _g, _h, _i;
23169
23196
  setIsChatLoading(true);
23170
23197
  setChatError(null);
23171
23198
  const fetchFirstAvailableTable = async (tableNames) => {
23172
- var _a67;
23199
+ var _a74;
23173
23200
  let lastError = null;
23174
23201
  for (const tableName of tableNames) {
23175
23202
  const response = await supabase.from(tableName).select("*");
@@ -23191,7 +23218,7 @@ var MainNavbar = ({
23191
23218
  }
23192
23219
  }
23193
23220
  return {
23194
- tableName: (_a67 = tableNames[0]) != null ? _a67 : null,
23221
+ tableName: (_a74 = tableNames[0]) != null ? _a74 : null,
23195
23222
  data: null,
23196
23223
  error: lastError
23197
23224
  };
@@ -23293,7 +23320,7 @@ var MainNavbar = ({
23293
23320
  console.warn("[chat] Falha ao carregar presen\xE7a:", presenceResponse.error.message);
23294
23321
  }
23295
23322
  } else {
23296
- (_a66 = presenceResponse.data) == null ? void 0 : _a66.forEach((row) => {
23323
+ (_a73 = presenceResponse.data) == null ? void 0 : _a73.forEach((row) => {
23297
23324
  const userId = readFirstRecordString(row, [USER_PRESENCE_USER_ID_COLUMN, "user_id", "id"]);
23298
23325
  if (!userId) return;
23299
23326
  const statusValue = readFirstRecordString(row, [USER_PRESENCE_STATUS_COLUMN, "status", "presence_status"]);
@@ -23307,7 +23334,7 @@ var MainNavbar = ({
23307
23334
  console.warn("[chat] Falha ao carregar profiles para enriquecimento:", profilesResponse.error.message);
23308
23335
  }
23309
23336
  } else {
23310
- (_b6 = profilesResponse.data) == null ? void 0 : _b6.forEach((row) => {
23337
+ (_b7 = profilesResponse.data) == null ? void 0 : _b7.forEach((row) => {
23311
23338
  const id = readFirstRecordString(row, [...CHAT_USERS_LOOKUP_ID_COLUMNS, "id", "user_id"]);
23312
23339
  const email = readFirstRecordString(row, [...CHAT_USERS_LOOKUP_EMAIL_COLUMNS, "email"]);
23313
23340
  if (id) profileById.set(id, row);
@@ -23335,13 +23362,13 @@ var MainNavbar = ({
23335
23362
  }
23336
23363
  } else {
23337
23364
  (_e = usersResponse.data) == null ? void 0 : _e.forEach((row) => {
23338
- var _a67, _b7, _c3, _d2, _e2, _f2, _g2, _h2;
23365
+ var _a74, _b8, _c3, _d2, _e2, _f2, _g2, _h2;
23339
23366
  const id = readFirstRecordString(row, [...CHAT_USERS_LOOKUP_ID_COLUMNS, "id", "user_id"]);
23340
23367
  if (!id || id === effectiveCurrentUserId) return;
23341
23368
  const rowEmail = readFirstRecordString(row, [...CHAT_USERS_LOOKUP_EMAIL_COLUMNS, "email"]);
23342
- const profile = (_a67 = profileById.get(id)) != null ? _a67 : rowEmail ? profileByEmail.get(rowEmail.toLowerCase()) : void 0;
23369
+ const profile = (_a74 = profileById.get(id)) != null ? _a74 : rowEmail ? profileByEmail.get(rowEmail.toLowerCase()) : void 0;
23343
23370
  const email = rowEmail != null ? rowEmail : readFirstRecordString(profile, [CHAT_USERS_UPDATE_EMAIL_COLUMN, CHAT_USERS_EMAIL_COLUMN, "email"]);
23344
- const rawUsername = (_b7 = readFirstRecordString(row, [CHAT_USERS_USERNAME_COLUMN, "username", "user_name"])) != null ? _b7 : readFirstRecordString(profile, [CHAT_USERS_USERNAME_COLUMN, "username", "user_name"]);
23371
+ const rawUsername = (_b8 = readFirstRecordString(row, [CHAT_USERS_USERNAME_COLUMN, "username", "user_name"])) != null ? _b8 : readFirstRecordString(profile, [CHAT_USERS_USERNAME_COLUMN, "username", "user_name"]);
23345
23372
  const username = buildHandle2(rawUsername, email);
23346
23373
  const rawName = (_c3 = readFirstRecordString(row, [CHAT_USERS_NAME_COLUMN, "full_name", "display_name", "name", "username"])) != null ? _c3 : readFirstRecordString(profile, [CHAT_USERS_NAME_COLUMN, "full_name", "display_name", "name", "username"]);
23347
23374
  const name = resolveReadableUserLabel(rawName, rawUsername, email, id);
@@ -23359,7 +23386,7 @@ var MainNavbar = ({
23359
23386
  });
23360
23387
  }
23361
23388
  profileById.forEach((profile, id) => {
23362
- var _a67, _b7;
23389
+ var _a74, _b8;
23363
23390
  if (!id || id === effectiveCurrentUserId || usersMap.has(id)) return;
23364
23391
  const email = readFirstRecordString(profile, [CHAT_USERS_UPDATE_EMAIL_COLUMN, CHAT_USERS_EMAIL_COLUMN, "email"]);
23365
23392
  const rawUsername = readFirstRecordString(profile, [CHAT_USERS_USERNAME_COLUMN, "username", "user_name"]);
@@ -23380,7 +23407,7 @@ var MainNavbar = ({
23380
23407
  email,
23381
23408
  avatarUrl: resolveChatAvatarUrl(avatarValue),
23382
23409
  roleLabel,
23383
- status: (_b7 = (_a67 = presenceMap.get(id)) != null ? _a67 : readPresenceStatusFromRecord(profile)) != null ? _b7 : "offline"
23410
+ status: (_b8 = (_a74 = presenceMap.get(id)) != null ? _a74 : readPresenceStatusFromRecord(profile)) != null ? _b8 : "offline"
23384
23411
  });
23385
23412
  });
23386
23413
  presenceMap.forEach((statusValue, id) => {
@@ -23422,7 +23449,7 @@ var MainNavbar = ({
23422
23449
  );
23423
23450
  setChatMessages(resolvedMessages);
23424
23451
  resolvedMessages.forEach((message) => {
23425
- var _a67, _b7;
23452
+ var _a74, _b8;
23426
23453
  const contactId = message.contactId;
23427
23454
  if (!contactId || contactId === effectiveCurrentUserId || usersMap.has(contactId)) return;
23428
23455
  const profile = profileById.get(contactId);
@@ -23445,7 +23472,7 @@ var MainNavbar = ({
23445
23472
  email,
23446
23473
  avatarUrl: resolveChatAvatarUrl(avatarValue),
23447
23474
  roleLabel,
23448
- status: (_b7 = (_a67 = presenceMap.get(contactId)) != null ? _a67 : readPresenceStatusFromRecord(profile)) != null ? _b7 : "offline"
23475
+ status: (_b8 = (_a74 = presenceMap.get(contactId)) != null ? _a74 : readPresenceStatusFromRecord(profile)) != null ? _b8 : "offline"
23449
23476
  });
23450
23477
  });
23451
23478
  const resolvedUsers = [...usersMap.values()].sort((left, right) => left.name.localeCompare(right.name, "pt-BR"));
@@ -23630,10 +23657,10 @@ var MainNavbar = ({
23630
23657
  const chatUnreadByUser = (0, import_react19.useMemo)(() => {
23631
23658
  const counters = {};
23632
23659
  chatMessages.forEach((message) => {
23633
- var _a66;
23660
+ var _a73;
23634
23661
  if (message.sender !== "them") return;
23635
23662
  if (message.readAt) return;
23636
- counters[message.contactId] = ((_a66 = counters[message.contactId]) != null ? _a66 : 0) + 1;
23663
+ counters[message.contactId] = ((_a73 = counters[message.contactId]) != null ? _a73 : 0) + 1;
23637
23664
  });
23638
23665
  return counters;
23639
23666
  }, [chatMessages]);
@@ -23681,9 +23708,9 @@ var MainNavbar = ({
23681
23708
  }
23682
23709
  const persistedReadAtByMessageId = /* @__PURE__ */ new Map();
23683
23710
  (data != null ? data : []).forEach((row) => {
23684
- var _a66;
23711
+ var _a73;
23685
23712
  const messageId = toStringOrUndefined(row[CHAT_MESSAGES_ID_COLUMN]);
23686
- const persistedReadAt = (_a66 = toStringOrUndefined(row[CHAT_MESSAGES_READ_AT_COLUMN])) != null ? _a66 : readAt;
23713
+ const persistedReadAt = (_a73 = toStringOrUndefined(row[CHAT_MESSAGES_READ_AT_COLUMN])) != null ? _a73 : readAt;
23687
23714
  if (!messageId) return;
23688
23715
  persistedReadAtByMessageId.set(messageId, persistedReadAt);
23689
23716
  });
@@ -23852,8 +23879,8 @@ var MainNavbar = ({
23852
23879
  (current) => dedupeAndSortMessages(
23853
23880
  current.map(
23854
23881
  (message) => {
23855
- var _a66;
23856
- return message.id === messageId ? { ...message, text: previousText, editedAt: (_a66 = targetMessage.editedAt) != null ? _a66 : null } : message;
23882
+ var _a73;
23883
+ return message.id === messageId ? { ...message, text: previousText, editedAt: (_a73 = targetMessage.editedAt) != null ? _a73 : null } : message;
23857
23884
  }
23858
23885
  )
23859
23886
  )
@@ -23884,13 +23911,13 @@ var MainNavbar = ({
23884
23911
  (current) => dedupeAndSortMessages(
23885
23912
  current.map(
23886
23913
  (message) => {
23887
- var _a66;
23914
+ var _a73;
23888
23915
  return message.id === messageId ? {
23889
23916
  ...message,
23890
23917
  text: CHAT_DELETED_PLACEHOLDER_TEXT2,
23891
23918
  deletedAt,
23892
23919
  deletedBy: effectiveCurrentUserId,
23893
- editedAt: (_a66 = message.editedAt) != null ? _a66 : deletedAt
23920
+ editedAt: (_a73 = message.editedAt) != null ? _a73 : deletedAt
23894
23921
  } : message;
23895
23922
  }
23896
23923
  )
@@ -24074,8 +24101,8 @@ var MainNavbar = ({
24074
24101
  ...item,
24075
24102
  isActive,
24076
24103
  onClick: isAnchor ? item.onClick : (event) => {
24077
- var _a66;
24078
- (_a66 = item.onClick) == null ? void 0 : _a66.call(item, event);
24104
+ var _a73;
24105
+ (_a73 = item.onClick) == null ? void 0 : _a73.call(item, event);
24079
24106
  if (!onNavigate || event.defaultPrevented) return;
24080
24107
  event.preventDefault();
24081
24108
  onNavigate(item.href);
@@ -24117,9 +24144,9 @@ var MainNavbar = ({
24117
24144
  window.open(`${MC_BASE_URL2}/tasks`, "_blank", "noopener,noreferrer");
24118
24145
  };
24119
24146
  const handleChatOpenUserProfile = (0, import_react19.useCallback)(({ userId }) => {
24120
- var _a66;
24147
+ var _a73;
24121
24148
  if (!userId || typeof window === "undefined") return;
24122
- const baseUrl = ((_a66 = getRuntimeEnv("VITE_ACCOUNTS_BASE_URL")) != null ? _a66 : "https://accounts.cupcode.com.br").replace(
24149
+ const baseUrl = ((_a73 = getRuntimeEnv("VITE_ACCOUNTS_BASE_URL")) != null ? _a73 : "https://accounts.cupcode.com.br").replace(
24123
24150
  /\/+$/,
24124
24151
  ""
24125
24152
  );
@@ -24189,8 +24216,8 @@ var MainNavbar = ({
24189
24216
  );
24190
24217
  const handleProfileAvatarChange = (0, import_react19.useCallback)(
24191
24218
  async ({ avatarId, avatarUrl }) => {
24192
- var _a66;
24193
- const normalizedAvatarId = (_a66 = parseAssetId(avatarId)) != null ? _a66 : parseAssetId(avatarUrl);
24219
+ var _a73;
24220
+ const normalizedAvatarId = (_a73 = parseAssetId(avatarId)) != null ? _a73 : parseAssetId(avatarUrl);
24194
24221
  if (!normalizedAvatarId) {
24195
24222
  throw new Error("ID da imagem inv\xE1lido.");
24196
24223
  }
@@ -24206,27 +24233,27 @@ var MainNavbar = ({
24206
24233
  );
24207
24234
  const updateErrors = [];
24208
24235
  const isRecoverableUpdateError = (error) => {
24209
- var _a67;
24210
- const message = ((_a67 = error.message) != null ? _a67 : "").toLowerCase();
24236
+ var _a74;
24237
+ const message = ((_a74 = error.message) != null ? _a74 : "").toLowerCase();
24211
24238
  return error.code === "55000" || error.code === "42P01" || error.code === "42703" || error.code === "42501" || error.code === "22P02" || message.includes("cannot update view") || message.includes("not automatically updatable") || message.includes("permission denied") || message.includes("invalid input syntax") || message.includes("relation") && message.includes("does not exist") || message.includes("column") && message.includes("does not exist");
24212
24239
  };
24213
24240
  const isRecoverableLookupError2 = (error) => {
24214
- var _a67;
24215
- const message = ((_a67 = error.message) != null ? _a67 : "").toLowerCase();
24241
+ var _a74;
24242
+ const message = ((_a74 = error.message) != null ? _a74 : "").toLowerCase();
24216
24243
  return error.code === "42P01" || error.code === "42703" || error.code === "42501" || message.includes("relation") && message.includes("does not exist") || message.includes("column") && message.includes("does not exist") || message.includes("permission denied");
24217
24244
  };
24218
24245
  const isPermissionDeniedError2 = (error) => {
24219
- var _a67;
24220
- const message = ((_a67 = error.message) != null ? _a67 : "").toLowerCase();
24246
+ var _a74;
24247
+ const message = ((_a74 = error.message) != null ? _a74 : "").toLowerCase();
24221
24248
  return error.code === "42501" || message.includes("permission denied");
24222
24249
  };
24223
24250
  const updateAvatarByUserId = async (userId) => {
24224
- var _a67, _b6, _c2, _d, _e;
24251
+ var _a74, _b7, _c2, _d, _e;
24225
24252
  for (const tableName of updateTargets) {
24226
24253
  const updateWithSelect = await supabase.from(tableName).update({ [CHAT_USERS_UPDATE_AVATAR_COLUMN]: normalizedAvatarId }).eq(CHAT_USERS_UPDATE_ID_COLUMN, userId).select(CHAT_USERS_UPDATE_ID_COLUMN).limit(1);
24227
24254
  if (!updateWithSelect.error) {
24228
24255
  const rows = updateWithSelect.data;
24229
- const row = (_a67 = rows == null ? void 0 : rows[0]) != null ? _a67 : null;
24256
+ const row = (_a74 = rows == null ? void 0 : rows[0]) != null ? _a74 : null;
24230
24257
  if (row) {
24231
24258
  return row;
24232
24259
  }
@@ -24246,7 +24273,7 @@ var MainNavbar = ({
24246
24273
  throw new Error(`Falha ao atualizar avatar em "${tableName}": ${withoutSelectError.message}`);
24247
24274
  }
24248
24275
  updateErrors.push(
24249
- `${tableName}: ${(_b6 = withoutSelectError.code) != null ? _b6 : "erro"} ${(_c2 = withoutSelectError.message) != null ? _c2 : "falha desconhecida"}`
24276
+ `${tableName}: ${(_b7 = withoutSelectError.code) != null ? _b7 : "erro"} ${(_c2 = withoutSelectError.message) != null ? _c2 : "falha desconhecida"}`
24250
24277
  );
24251
24278
  continue;
24252
24279
  }
@@ -24258,13 +24285,13 @@ var MainNavbar = ({
24258
24285
  return null;
24259
24286
  };
24260
24287
  const resolveUserIdByEmail = async (emailValue) => {
24261
- var _a67;
24288
+ var _a74;
24262
24289
  let lastRecoverableError = null;
24263
24290
  for (const tableName of lookupTargets) {
24264
24291
  const { data, error } = await supabase.from(tableName).select(CHAT_USERS_UPDATE_ID_COLUMN).ilike(CHAT_USERS_UPDATE_EMAIL_COLUMN, emailValue).limit(1);
24265
24292
  if (!error) {
24266
24293
  const rows = data;
24267
- const resolvedId = toStringOrUndefined((_a67 = rows == null ? void 0 : rows[0]) == null ? void 0 : _a67[CHAT_USERS_UPDATE_ID_COLUMN]);
24294
+ const resolvedId = toStringOrUndefined((_a74 = rows == null ? void 0 : rows[0]) == null ? void 0 : _a74[CHAT_USERS_UPDATE_ID_COLUMN]);
24268
24295
  if (resolvedId) {
24269
24296
  return resolvedId;
24270
24297
  }
@@ -24427,7 +24454,7 @@ function ParticleSystem({
24427
24454
  if (particle.y < 0) particle.y = canvas.height;
24428
24455
  if (particle.y > canvas.height) particle.y = 0;
24429
24456
  if (variant === "stars") {
24430
- ctx.fillStyle = `rgba(237, 30, 121, ${particle.opacity})`;
24457
+ ctx.fillStyle = `rgba(151, 90, 182, ${particle.opacity})`;
24431
24458
  ctx.beginPath();
24432
24459
  ctx.arc(particle.x, particle.y, particle.size, 0, Math.PI * 2);
24433
24460
  ctx.fill();
@@ -24438,8 +24465,8 @@ function ParticleSystem({
24438
24465
  particle.x - particle.speedX * 10,
24439
24466
  particle.y - particle.speedY * 10
24440
24467
  );
24441
- gradient.addColorStop(0, `rgba(149, 29, 219, ${particle.opacity})`);
24442
- gradient.addColorStop(1, "rgba(149, 29, 219, 0)");
24468
+ gradient.addColorStop(0, `rgba(124,91,187, ${particle.opacity})`);
24469
+ gradient.addColorStop(1, "rgba(124,91,187, 0)");
24443
24470
  ctx.strokeStyle = gradient;
24444
24471
  ctx.lineWidth = particle.size;
24445
24472
  ctx.beginPath();
@@ -24757,7 +24784,7 @@ var Switch2 = React32.forwardRef(({ className, ...props }, ref) => /* @__PURE__
24757
24784
  "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-cupcode-purple focus-visible:ring-offset-2",
24758
24785
  "focus-visible:ring-offset-background",
24759
24786
  "disabled:cursor-not-allowed disabled:opacity-50",
24760
- "data-[state=checked]:bg-gradient-to-r data-[state=checked]:from-cupcode-pink data-[state=checked]:to-cupcode-purple",
24787
+ "data-[state=checked]:bg-gradient-to-r data-[state=checked]:from-cupcode-hover data-[state=checked]:to-cupcode-purple",
24761
24788
  "data-[state=unchecked]:bg-border",
24762
24789
  className
24763
24790
  ),
@@ -24820,7 +24847,7 @@ var TabsTrigger2 = React33.forwardRef(({ className, ...props }, ref) => /* @__PU
24820
24847
  "relative",
24821
24848
  "data-[state=active]:after:absolute data-[state=active]:after:bottom-0 data-[state=active]:after:left-0",
24822
24849
  "data-[state=active]:after:h-0.5 data-[state=active]:after:w-full",
24823
- "data-[state=active]:after:bg-gradient-to-r data-[state=active]:after:from-cupcode-pink data-[state=active]:after:to-cupcode-purple",
24850
+ "data-[state=active]:after:bg-gradient-to-r data-[state=active]:after:from-cupcode-hover data-[state=active]:after:to-cupcode-purple",
24824
24851
  "data-[state=active]:after:animate-scale-in",
24825
24852
  className
24826
24853
  ),
@@ -24885,10 +24912,10 @@ function isThemeMode(value) {
24885
24912
  return value === "light" || value === "dark";
24886
24913
  }
24887
24914
  function readStoredTheme() {
24888
- var _a65;
24915
+ var _a72;
24889
24916
  if (typeof window === "undefined") return null;
24890
24917
  try {
24891
- const storedTheme = (_a65 = window.localStorage.getItem(THEME_STORAGE_KEY2)) != null ? _a65 : window.localStorage.getItem("theme");
24918
+ const storedTheme = (_a72 = window.localStorage.getItem(THEME_STORAGE_KEY2)) != null ? _a72 : window.localStorage.getItem("theme");
24892
24919
  return isThemeMode(storedTheme) ? storedTheme : null;
24893
24920
  } catch (e) {
24894
24921
  return null;
@@ -24925,11 +24952,11 @@ var ThemeToggle = ({
24925
24952
  defaultTheme = "light",
24926
24953
  onThemeChange
24927
24954
  }) => {
24928
- var _a65;
24955
+ var _a72;
24929
24956
  const [mounted, setMounted] = React35.useState(false);
24930
24957
  const [internalTheme, setInternalTheme] = React35.useState(defaultTheme);
24931
24958
  const isControlled = typeof theme !== "undefined";
24932
- const activeTheme = (_a65 = isControlled ? theme : internalTheme) != null ? _a65 : defaultTheme;
24959
+ const activeTheme = (_a72 = isControlled ? theme : internalTheme) != null ? _a72 : defaultTheme;
24933
24960
  React35.useEffect(() => {
24934
24961
  if (!isControlled) {
24935
24962
  setInternalTheme(resolveTheme(defaultTheme));
@@ -24974,7 +25001,7 @@ var ThemeToggle = ({
24974
25001
  "aria-label": "Toggle theme",
24975
25002
  children: [
24976
25003
  /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_lucide_react13.Sun, { className: "h-5 w-5 text-cupcode-purple rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0" }),
24977
- /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_lucide_react13.Moon, { className: "absolute h-5 w-5 text-cupcode-pink rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100" }),
25004
+ /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_lucide_react13.Moon, { className: "absolute h-5 w-5 text-cupcode-hover rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100" }),
24978
25005
  /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("span", { className: "sr-only", children: [
24979
25006
  "Current theme: ",
24980
25007
  activeTheme
@@ -25567,8 +25594,8 @@ var ChartStyle = ({ id, config }) => {
25567
25594
  ([theme, prefix]) => `
25568
25595
  ${prefix} [data-chart=${id}] {
25569
25596
  ${colorConfig.map(([key, itemConfig]) => {
25570
- var _a65;
25571
- const color = ((_a65 = itemConfig.theme) == null ? void 0 : _a65[theme]) || itemConfig.color;
25597
+ var _a72;
25598
+ const color = ((_a72 = itemConfig.theme) == null ? void 0 : _a72[theme]) || itemConfig.color;
25572
25599
  return color ? ` --color-${key}: ${color};` : null;
25573
25600
  }).join("\n")}
25574
25601
  }
@@ -25597,14 +25624,14 @@ var ChartTooltipContent = React42.forwardRef(
25597
25624
  }, ref) => {
25598
25625
  const { config } = useChart();
25599
25626
  const tooltipLabel = React42.useMemo(() => {
25600
- var _a65;
25627
+ var _a72;
25601
25628
  if (hideLabel || !(payload == null ? void 0 : payload.length)) {
25602
25629
  return null;
25603
25630
  }
25604
25631
  const [item] = payload;
25605
25632
  const key = `${labelKey || item.dataKey || item.name || "value"}`;
25606
25633
  const itemConfig = getPayloadConfigFromPayload(config, item, key);
25607
- const value = !labelKey && typeof label === "string" ? ((_a65 = config[label]) == null ? void 0 : _a65.label) || label : itemConfig == null ? void 0 : itemConfig.label;
25634
+ const value = !labelKey && typeof label === "string" ? ((_a72 = config[label]) == null ? void 0 : _a72.label) || label : itemConfig == null ? void 0 : itemConfig.label;
25608
25635
  if (labelFormatter) {
25609
25636
  return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { className: cn("font-medium", labelClassName), children: labelFormatter(value, payload) });
25610
25637
  }
@@ -27289,8 +27316,8 @@ ToggleGroupItem.displayName = ToggleGroupPrimitive.Item.displayName;
27289
27316
  // src/hooks/useActiveSection.ts
27290
27317
  var import_react21 = require("react");
27291
27318
  var useActiveSection = (sectionIds, offset = 180) => {
27292
- var _a65;
27293
- const [activeId, setActiveId] = (0, import_react21.useState)((_a65 = sectionIds[0]) != null ? _a65 : "");
27319
+ var _a72;
27320
+ const [activeId, setActiveId] = (0, import_react21.useState)((_a72 = sectionIds[0]) != null ? _a72 : "");
27294
27321
  (0, import_react21.useEffect)(() => {
27295
27322
  if (!sectionIds.length || typeof window === "undefined") return;
27296
27323
  const update = () => {
@@ -27344,6 +27371,35 @@ var _a63;
27344
27371
  var USER_PRESENCE_USER_ID_COLUMN2 = ((_a63 = getRuntimeEnv("VITE_USER_PRESENCE_USER_ID_COLUMN")) != null ? _a63 : "user_id").trim();
27345
27372
  var _a64;
27346
27373
  var USER_PRESENCE_STATUS_COLUMN2 = ((_a64 = getRuntimeEnv("VITE_USER_PRESENCE_STATUS_COLUMN")) != null ? _a64 : "status").trim();
27374
+ var _a65, _b5;
27375
+ var SUPABASE_CHAT_SCHEMA = ((_b5 = (_a65 = getRuntimeEnv("VITE_CHAT_SCHEMA")) != null ? _a65 : getRuntimeEnv("VITE_SUPABASE_SCHEMA")) != null ? _b5 : "public").trim();
27376
+ var _a66;
27377
+ var CHAT_USERS_TABLE2 = ((_a66 = getRuntimeEnv("VITE_CHAT_USERS_TABLE")) != null ? _a66 : "chat_users").trim();
27378
+ var _a67;
27379
+ var CHAT_USERS_ID_COLUMN2 = ((_a67 = getRuntimeEnv("VITE_CHAT_USERS_ID_COLUMN")) != null ? _a67 : "id").trim();
27380
+ var _a68;
27381
+ var CHAT_USERS_EMAIL_COLUMN2 = ((_a68 = getRuntimeEnv("VITE_CHAT_USERS_EMAIL_COLUMN")) != null ? _a68 : "email").trim();
27382
+ var _a69;
27383
+ var CHAT_USERS_UPDATE_TABLE2 = ((_a69 = getRuntimeEnv("VITE_CHAT_USERS_UPDATE_TABLE")) != null ? _a69 : "profiles").trim();
27384
+ var _a70;
27385
+ var CHAT_USERS_UPDATE_ID_COLUMN2 = ((_a70 = getRuntimeEnv("VITE_CHAT_USERS_UPDATE_ID_COLUMN")) != null ? _a70 : "id").trim();
27386
+ var _a71;
27387
+ var CHAT_USERS_UPDATE_EMAIL_COLUMN2 = ((_a71 = getRuntimeEnv("VITE_CHAT_USERS_UPDATE_EMAIL_COLUMN")) != null ? _a71 : "email").trim();
27388
+ var PRESENCE_USER_LOOKUP_TABLES = Array.from(
27389
+ new Set(
27390
+ [CHAT_USERS_UPDATE_TABLE2, CHAT_USERS_TABLE2, "profiles", "chat_users"].map((entry) => entry.trim()).filter((entry) => entry.length > 0)
27391
+ )
27392
+ );
27393
+ var PRESENCE_USER_LOOKUP_ID_COLUMNS = Array.from(
27394
+ new Set(
27395
+ [CHAT_USERS_UPDATE_ID_COLUMN2, CHAT_USERS_ID_COLUMN2, "id", "user_id"].map((entry) => entry.trim()).filter((entry) => entry.length > 0)
27396
+ )
27397
+ );
27398
+ var PRESENCE_USER_LOOKUP_EMAIL_COLUMNS = Array.from(
27399
+ new Set(
27400
+ [CHAT_USERS_UPDATE_EMAIL_COLUMN2, CHAT_USERS_EMAIL_COLUMN2, "email"].map((entry) => entry.trim()).filter((entry) => entry.length > 0)
27401
+ )
27402
+ );
27347
27403
  var AWAY_AFTER_MS = 10 * 60 * 1e3;
27348
27404
  var ACTIVITY_BROADCAST_THROTTLE_MS = 5e3;
27349
27405
  var INACTIVITY_CHECK_INTERVAL_MS = 3e4;
@@ -27362,14 +27418,27 @@ var PRESENCE_STATUS_VALUES2 = [
27362
27418
  var isUserPresenceStatus = (value) => {
27363
27419
  return typeof value === "string" && PRESENCE_STATUS_VALUES2.includes(value);
27364
27420
  };
27421
+ var toNonEmptyString = (value) => {
27422
+ if (typeof value !== "string") return void 0;
27423
+ const trimmed = value.trim();
27424
+ return trimmed === "" ? void 0 : trimmed;
27425
+ };
27426
+ var readFirstRecordString2 = (row, keys) => {
27427
+ if (!row) return void 0;
27428
+ for (const key of keys) {
27429
+ const value = toNonEmptyString(row[key]);
27430
+ if (value) return value;
27431
+ }
27432
+ return void 0;
27433
+ };
27365
27434
  var readStoredPresence = () => {
27366
27435
  const stored = sessionStorage.getItem(STORAGE_KEYS.presence);
27367
27436
  if (!stored) return DEFAULT_PRESENCE_STATUS;
27368
27437
  return isUserPresenceStatus(stored) ? stored : DEFAULT_PRESENCE_STATUS;
27369
27438
  };
27370
27439
  var readStoredPresenceSource = () => {
27371
- var _a65;
27372
- const stored = (_a65 = sessionStorage.getItem(STORAGE_KEYS.presenceSource)) != null ? _a65 : localStorage.getItem(LOCAL_STORAGE_KEYS.presenceSource);
27440
+ var _a72;
27441
+ const stored = (_a72 = sessionStorage.getItem(STORAGE_KEYS.presenceSource)) != null ? _a72 : localStorage.getItem(LOCAL_STORAGE_KEYS.presenceSource);
27373
27442
  return stored === "system" ? "system" : "manual";
27374
27443
  };
27375
27444
  var AuthContext = (0, import_react22.createContext)(void 0);
@@ -27387,30 +27456,33 @@ var readStoredToken = () => {
27387
27456
  return { accessToken, idToken };
27388
27457
  };
27389
27458
  var storeTokens = (tokens) => {
27390
- var _a65;
27459
+ var _a72;
27391
27460
  sessionStorage.setItem(STORAGE_KEYS.accessToken, tokens.accessToken);
27392
27461
  if (tokens.idToken) sessionStorage.setItem(STORAGE_KEYS.idToken, tokens.idToken);
27393
27462
  if (tokens.refreshToken) sessionStorage.setItem(STORAGE_KEYS.refreshToken, tokens.refreshToken);
27394
- const expiresAt2 = Date.now() + ((_a65 = tokens.expiresIn) != null ? _a65 : 3600) * 1e3;
27463
+ const expiresAt2 = Date.now() + ((_a72 = tokens.expiresIn) != null ? _a72 : 3600) * 1e3;
27395
27464
  sessionStorage.setItem(STORAGE_KEYS.expiresAt, String(expiresAt2));
27396
27465
  };
27397
27466
  var clearTokens = () => {
27398
27467
  Object.values(STORAGE_KEYS).forEach((key) => sessionStorage.removeItem(key));
27399
27468
  };
27400
27469
  var buildUserFromToken = (idToken) => {
27401
- var _a65, _b5, _c, _d;
27470
+ var _a72, _b6, _c, _d, _e, _f, _g, _h;
27402
27471
  const payload = decodeJwt(idToken);
27403
27472
  if (!payload) return null;
27404
- const roleClaim = (_a65 = payload.role) != null ? _a65 : payload.roles;
27473
+ const resolvedId = (_d = (_c = (_b6 = (_a72 = toNonEmptyString(payload["https://cupcode.com/user_id"])) != null ? _a72 : toNonEmptyString(payload.user_id)) != null ? _b6 : toNonEmptyString(payload.userId)) != null ? _c : toNonEmptyString(payload.uid)) != null ? _d : toNonEmptyString(payload.id);
27474
+ const roleClaim = (_e = payload.role) != null ? _e : payload.roles;
27405
27475
  const resolvedRole = typeof roleClaim === "string" ? roleClaim : Array.isArray(roleClaim) ? roleClaim.find((entry) => typeof entry === "string") : void 0;
27406
- const jobTitleClaim = (_c = (_b5 = payload.job_title) != null ? _b5 : payload.jobTitle) != null ? _c : payload.title;
27476
+ const jobTitleClaim = (_g = (_f = payload.job_title) != null ? _f : payload.jobTitle) != null ? _g : payload.title;
27407
27477
  const resolvedJobTitle = typeof jobTitleClaim === "string" ? jobTitleClaim : void 0;
27408
27478
  return {
27409
27479
  sub: payload.sub,
27480
+ id: resolvedId,
27481
+ userId: resolvedId,
27410
27482
  name: payload.name,
27411
27483
  email: payload.email,
27412
27484
  picture: payload.picture,
27413
- preferredUsername: (_d = payload.preferred_username) != null ? _d : payload.preferredUsername,
27485
+ preferredUsername: (_h = payload.preferred_username) != null ? _h : payload.preferredUsername,
27414
27486
  nickname: payload.nickname,
27415
27487
  role: resolvedRole,
27416
27488
  jobTitle: resolvedJobTitle
@@ -27428,22 +27500,54 @@ var AuthProvider = ({ children }) => {
27428
27500
  );
27429
27501
  const lastActivityAtRef = (0, import_react22.useRef)(Date.now());
27430
27502
  const lastActivityBroadcastAtRef = (0, import_react22.useRef)(0);
27503
+ const resolvedPresenceIdentityKeyRef = (0, import_react22.useRef)(null);
27504
+ const resolvedPresenceUserIdRef = (0, import_react22.useRef)(null);
27431
27505
  const storePresenceStatus = (0, import_react22.useCallback)((nextStatus) => {
27432
27506
  setPresenceStatusState(nextStatus);
27433
27507
  presenceStatusRef.current = nextStatus;
27434
27508
  sessionStorage.setItem(STORAGE_KEYS.presence, nextStatus);
27435
27509
  }, []);
27436
- const resolvePresenceUserId = (0, import_react22.useCallback)((targetUser) => {
27437
- var _a65, _b5;
27438
- const sub = (_a65 = targetUser == null ? void 0 : targetUser.sub) == null ? void 0 : _a65.trim();
27439
- if (sub) return sub;
27440
- const email = (_b5 = targetUser == null ? void 0 : targetUser.email) == null ? void 0 : _b5.trim();
27441
- if (email) return email;
27442
- return null;
27510
+ const resolvePresenceUserId = (0, import_react22.useCallback)(async (targetUser) => {
27511
+ var _a72, _b6, _c, _d;
27512
+ const sub = toNonEmptyString(targetUser == null ? void 0 : targetUser.sub);
27513
+ const id = toNonEmptyString(targetUser == null ? void 0 : targetUser.id);
27514
+ const userId = toNonEmptyString(targetUser == null ? void 0 : targetUser.userId);
27515
+ const email = (_a72 = toNonEmptyString(targetUser == null ? void 0 : targetUser.email)) == null ? void 0 : _a72.toLowerCase();
27516
+ const identityKey = [sub != null ? sub : "", id != null ? id : "", userId != null ? userId : "", email != null ? email : ""].join("|");
27517
+ if (resolvedPresenceIdentityKeyRef.current === identityKey && resolvedPresenceUserIdRef.current) {
27518
+ return resolvedPresenceUserIdRef.current;
27519
+ }
27520
+ const fallbackUserId = (_d = (_c = (_b6 = sub != null ? sub : id) != null ? _b6 : userId) != null ? _c : email) != null ? _d : null;
27521
+ if (!email) {
27522
+ resolvedPresenceIdentityKeyRef.current = identityKey;
27523
+ resolvedPresenceUserIdRef.current = fallbackUserId;
27524
+ return fallbackUserId;
27525
+ }
27526
+ const supabase = getSupabase();
27527
+ if (!supabase) {
27528
+ resolvedPresenceIdentityKeyRef.current = identityKey;
27529
+ resolvedPresenceUserIdRef.current = fallbackUserId;
27530
+ return fallbackUserId;
27531
+ }
27532
+ for (const tableName of PRESENCE_USER_LOOKUP_TABLES) {
27533
+ for (const emailColumn of PRESENCE_USER_LOOKUP_EMAIL_COLUMNS) {
27534
+ const { data, error } = await supabase.from(tableName).select("*").ilike(emailColumn, email).limit(1);
27535
+ if (error) continue;
27536
+ const row = data == null ? void 0 : data[0];
27537
+ const mappedId = readFirstRecordString2(row, PRESENCE_USER_LOOKUP_ID_COLUMNS);
27538
+ if (!mappedId) continue;
27539
+ resolvedPresenceIdentityKeyRef.current = identityKey;
27540
+ resolvedPresenceUserIdRef.current = mappedId;
27541
+ return mappedId;
27542
+ }
27543
+ }
27544
+ resolvedPresenceIdentityKeyRef.current = identityKey;
27545
+ resolvedPresenceUserIdRef.current = fallbackUserId;
27546
+ return fallbackUserId;
27443
27547
  }, []);
27444
27548
  const persistPresenceStatus = (0, import_react22.useCallback)(
27445
27549
  async (nextStatus, targetUser) => {
27446
- const userId = resolvePresenceUserId(targetUser != null ? targetUser : user);
27550
+ const userId = await resolvePresenceUserId(targetUser != null ? targetUser : user);
27447
27551
  if (!userId) return;
27448
27552
  const supabase = getSupabase();
27449
27553
  if (!supabase) return;
@@ -27472,9 +27576,23 @@ var AuthProvider = ({ children }) => {
27472
27576
  },
27473
27577
  [persistPresenceStatus, storePresenceStatus]
27474
27578
  );
27579
+ const syncPresenceFromDatabase = (0, import_react22.useCallback)(
27580
+ (nextStatus) => {
27581
+ storePresenceStatus(nextStatus);
27582
+ const storedSource = readStoredPresenceSource();
27583
+ const sourceFromDatabase = nextStatus === "away" ? storedSource : nextStatus === "offline" ? "system" : "manual";
27584
+ presenceSourceRef.current = sourceFromDatabase;
27585
+ sessionStorage.setItem(STORAGE_KEYS.presenceSource, sourceFromDatabase);
27586
+ localStorage.setItem(LOCAL_STORAGE_KEYS.presenceSource, sourceFromDatabase);
27587
+ if (nextStatus !== "offline") {
27588
+ lastManualPresenceRef.current = nextStatus;
27589
+ }
27590
+ },
27591
+ [storePresenceStatus]
27592
+ );
27475
27593
  const loadPresenceFromDatabase = (0, import_react22.useCallback)(
27476
27594
  async (targetUser) => {
27477
- const userId = resolvePresenceUserId(targetUser);
27595
+ const userId = await resolvePresenceUserId(targetUser);
27478
27596
  if (!userId) return;
27479
27597
  const supabase = getSupabase();
27480
27598
  if (!supabase) return;
@@ -27487,18 +27605,13 @@ var AuthProvider = ({ children }) => {
27487
27605
  }
27488
27606
  const row = data;
27489
27607
  const rawStatus = row == null ? void 0 : row[USER_PRESENCE_STATUS_COLUMN2];
27490
- if (!isUserPresenceStatus(rawStatus)) return;
27491
- storePresenceStatus(rawStatus);
27492
- const storedSource = readStoredPresenceSource();
27493
- const sourceFromDatabase = rawStatus === "away" ? storedSource : rawStatus === "offline" ? "system" : "manual";
27494
- presenceSourceRef.current = sourceFromDatabase;
27495
- sessionStorage.setItem(STORAGE_KEYS.presenceSource, sourceFromDatabase);
27496
- localStorage.setItem(LOCAL_STORAGE_KEYS.presenceSource, sourceFromDatabase);
27497
- if (rawStatus !== "offline") {
27498
- lastManualPresenceRef.current = rawStatus;
27608
+ if (!isUserPresenceStatus(rawStatus)) {
27609
+ await persistPresenceStatus(presenceStatusRef.current, targetUser);
27610
+ return;
27499
27611
  }
27612
+ syncPresenceFromDatabase(rawStatus);
27500
27613
  },
27501
- [resolvePresenceUserId, storePresenceStatus]
27614
+ [persistPresenceStatus, resolvePresenceUserId, syncPresenceFromDatabase]
27502
27615
  );
27503
27616
  const clearAuthFlowState = (0, import_react22.useCallback)((options) => {
27504
27617
  sessionStorage.removeItem(STORAGE_KEYS.state);
@@ -27512,7 +27625,7 @@ var AuthProvider = ({ children }) => {
27512
27625
  }, []);
27513
27626
  const startAuthorization = (0, import_react22.useCallback)(
27514
27627
  async (options) => {
27515
- var _a65, _b5;
27628
+ var _a72, _b6;
27516
27629
  const config = getAccountsConfig();
27517
27630
  const { authUrl } = await resolveOidcEndpoints(config);
27518
27631
  if (!authUrl) {
@@ -27522,8 +27635,8 @@ var AuthProvider = ({ children }) => {
27522
27635
  const challenge = await generateCodeChallenge(verifier);
27523
27636
  const state = generateState();
27524
27637
  const nonce = generateNonce();
27525
- const redirectTo = (_a65 = options == null ? void 0 : options.redirectTo) != null ? _a65 : window.location.pathname + window.location.search + window.location.hash;
27526
- const mode = (_b5 = options == null ? void 0 : options.mode) != null ? _b5 : "interactive";
27638
+ const redirectTo = (_a72 = options == null ? void 0 : options.redirectTo) != null ? _a72 : window.location.pathname + window.location.search + window.location.hash;
27639
+ const mode = (_b6 = options == null ? void 0 : options.mode) != null ? _b6 : "interactive";
27527
27640
  sessionStorage.setItem(STORAGE_KEYS.verifier, verifier);
27528
27641
  sessionStorage.setItem(STORAGE_KEYS.state, state);
27529
27642
  sessionStorage.setItem(STORAGE_KEYS.nonce, nonce);
@@ -27550,14 +27663,14 @@ var AuthProvider = ({ children }) => {
27550
27663
  (0, import_react22.useEffect)(() => {
27551
27664
  let cancelled = false;
27552
27665
  const initializeAuth = async () => {
27553
- var _a65;
27666
+ var _a72;
27554
27667
  const stored = readStoredToken();
27555
27668
  const storedPresence = readStoredPresence();
27556
27669
  setPresenceStatusState(storedPresence);
27557
27670
  if (stored == null ? void 0 : stored.accessToken) {
27558
27671
  if (cancelled) return;
27559
27672
  setAccessToken(stored.accessToken);
27560
- setUser(buildUserFromToken((_a65 = stored.idToken) != null ? _a65 : void 0));
27673
+ setUser(buildUserFromToken((_a72 = stored.idToken) != null ? _a72 : void 0));
27561
27674
  setStatus("authenticated");
27562
27675
  return;
27563
27676
  }
@@ -27584,14 +27697,56 @@ var AuthProvider = ({ children }) => {
27584
27697
  cancelled = true;
27585
27698
  };
27586
27699
  }, [attemptSilentLogin]);
27700
+ (0, import_react22.useEffect)(() => {
27701
+ resolvedPresenceIdentityKeyRef.current = null;
27702
+ resolvedPresenceUserIdRef.current = null;
27703
+ }, [user == null ? void 0 : user.email, user == null ? void 0 : user.id, user == null ? void 0 : user.sub, user == null ? void 0 : user.userId]);
27587
27704
  (0, import_react22.useEffect)(() => {
27588
27705
  if (status !== "authenticated") return;
27589
27706
  void loadPresenceFromDatabase(user);
27590
27707
  }, [loadPresenceFromDatabase, status, user]);
27591
27708
  (0, import_react22.useEffect)(() => {
27592
- var _a65;
27593
27709
  if (status !== "authenticated") return;
27594
- const initialFromStorage = Number((_a65 = localStorage.getItem(LOCAL_STORAGE_KEYS.lastActivityAt)) != null ? _a65 : "0");
27710
+ const supabase = getSupabase();
27711
+ if (!supabase) return;
27712
+ let cancelled = false;
27713
+ let presenceChannel = null;
27714
+ const startPresenceSync = async () => {
27715
+ const currentUserId = await resolvePresenceUserId(user);
27716
+ if (!currentUserId || cancelled) return;
27717
+ presenceChannel = supabase.channel(`cc-auth-presence-${currentUserId}`).on(
27718
+ "postgres_changes",
27719
+ {
27720
+ event: "*",
27721
+ schema: SUPABASE_CHAT_SCHEMA,
27722
+ table: USER_PRESENCE_TABLE2
27723
+ },
27724
+ (payload) => {
27725
+ const row = payload.new || payload.old;
27726
+ const rowUserId = toNonEmptyString(row == null ? void 0 : row[USER_PRESENCE_USER_ID_COLUMN2]);
27727
+ if (!rowUserId || rowUserId !== currentUserId) return;
27728
+ if (payload.eventType === "DELETE") {
27729
+ syncPresenceFromDatabase("offline");
27730
+ return;
27731
+ }
27732
+ const nextStatus = row == null ? void 0 : row[USER_PRESENCE_STATUS_COLUMN2];
27733
+ if (!isUserPresenceStatus(nextStatus)) return;
27734
+ syncPresenceFromDatabase(nextStatus);
27735
+ }
27736
+ ).subscribe();
27737
+ };
27738
+ void startPresenceSync();
27739
+ return () => {
27740
+ cancelled = true;
27741
+ if (presenceChannel) {
27742
+ void supabase.removeChannel(presenceChannel);
27743
+ }
27744
+ };
27745
+ }, [resolvePresenceUserId, status, syncPresenceFromDatabase, user]);
27746
+ (0, import_react22.useEffect)(() => {
27747
+ var _a72;
27748
+ if (status !== "authenticated") return;
27749
+ const initialFromStorage = Number((_a72 = localStorage.getItem(LOCAL_STORAGE_KEYS.lastActivityAt)) != null ? _a72 : "0");
27595
27750
  if (Number.isFinite(initialFromStorage) && initialFromStorage > 0) {
27596
27751
  lastActivityAtRef.current = Math.max(lastActivityAtRef.current, initialFromStorage);
27597
27752
  } else {
@@ -27666,9 +27821,9 @@ var AuthProvider = ({ children }) => {
27666
27821
  });
27667
27822
  }, [startAuthorization]);
27668
27823
  const completeLogin = (0, import_react22.useCallback)(async () => {
27669
- var _a65;
27824
+ var _a72;
27670
27825
  const params = new URLSearchParams(window.location.search);
27671
- const redirectTo = (_a65 = sessionStorage.getItem(STORAGE_KEYS.redirect)) != null ? _a65 : "/";
27826
+ const redirectTo = (_a72 = sessionStorage.getItem(STORAGE_KEYS.redirect)) != null ? _a72 : "/";
27672
27827
  const authMode = sessionStorage.getItem(STORAGE_KEYS.authMode);
27673
27828
  const isSilentAuth = authMode === "silent";
27674
27829
  const error = params.get("error");
@@ -27732,10 +27887,10 @@ var AuthProvider = ({ children }) => {
27732
27887
  }
27733
27888
  }, [clearAuthFlowState]);
27734
27889
  const logout = (0, import_react22.useCallback)(async () => {
27735
- var _a65;
27890
+ var _a72;
27736
27891
  const config = getAccountsConfig();
27737
27892
  const { logoutUrl } = await resolveOidcEndpoints(config);
27738
- const idToken = (_a65 = sessionStorage.getItem(STORAGE_KEYS.idToken)) != null ? _a65 : void 0;
27893
+ const idToken = (_a72 = sessionStorage.getItem(STORAGE_KEYS.idToken)) != null ? _a72 : void 0;
27739
27894
  const currentUser = user;
27740
27895
  await persistPresenceStatus("offline", currentUser);
27741
27896
  clearTokens();
@@ -28136,6 +28291,7 @@ var useAuth = () => {
28136
28291
  parseAssetId,
28137
28292
  reducer,
28138
28293
  resolveOidcEndpoints,
28294
+ resolveTelescupImageURL,
28139
28295
  responsiveSizeClasses,
28140
28296
  setCupcodeRuntimeEnv,
28141
28297
  sonnerToast,