@cupcodev/ui 1.2.52 → 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.js CHANGED
@@ -87,7 +87,7 @@ var AvatarFallback = React2.forwardRef(({ className, ...props }, ref) => /* @__P
87
87
  ref,
88
88
  className: cn(
89
89
  "flex h-full w-full items-center justify-center rounded-full",
90
- "bg-gradient-to-br from-cupcode-pink to-cupcode-purple",
90
+ "bg-gradient-to-br from-cupcode-hover to-cupcode-purple",
91
91
  "text-white font-semibold",
92
92
  className
93
93
  ),
@@ -202,7 +202,7 @@ var BackgroundRainbow = () => {
202
202
  will-change: transform;
203
203
  }
204
204
 
205
- /* usa tuas globais #ed1e79 e #951ddb com ~0.4 de opacidade */
205
+ /* usa tuas globais #ed1e79 e #7c5bbb com ~0.4 de opacidade */
206
206
  .cc-a {
207
207
  background: radial-gradient(circle at center,
208
208
  color-mix(in srgb, var(--color-one) 40%, transparent) 0%,
@@ -293,11 +293,11 @@ function BackgroundStars() {
293
293
  const palette = [
294
294
  "#ffffff",
295
295
  "#d7c8ff",
296
- "#951ddb",
296
+ "#7c5bbb",
297
297
  // roxo Cupcode
298
298
  "#b146ea",
299
- "#ed1e79",
300
- // magenta Cupcode
299
+ "#975ab6",
300
+ // hover tone Cupcode
301
301
  "#ff8ad1"
302
302
  ];
303
303
  const starSprite = document.createElement("canvas");
@@ -466,7 +466,7 @@ function BackgroundStars() {
466
466
  const halo3 = size * 10.8 * k;
467
467
  drawHalo(starsCtx, 0, 0, halo1, "rgba(251,88,235,0.65)");
468
468
  drawHalo(starsCtx, 0, 0, halo2, "rgba(237,30,121,0.58)");
469
- drawHalo(starsCtx, 0, 0, halo3, "rgba(149,29,219,0.52)");
469
+ drawHalo(starsCtx, 0, 0, halo3, "rgba(124,91,187,0.52)");
470
470
  const gp = size * (1.8 + glow);
471
471
  drawHalo(starsCtx, 0, 0, gp, "rgba(233,12,211,0.28)");
472
472
  if (s.isHighlight) {
@@ -515,12 +515,12 @@ function BackgroundStars() {
515
515
  ctx.globalAlpha = 0.2 + 0.8 * ease;
516
516
  drawHalo(ctx, 0, 0, 0.85, "rgba(255,255,255,1)");
517
517
  drawHalo(ctx, 0, 0, 8, "rgba(237,30,121,0.75)");
518
- drawHalo(ctx, 0, 0, 14, "rgba(149,29,219,0.6)");
518
+ drawHalo(ctx, 0, 0, 14, "rgba(124,91,187,0.6)");
519
519
  const tailLen = c.len;
520
520
  const grd = ctx.createLinearGradient(0, 0, -tailLen, 0);
521
521
  grd.addColorStop(0, "rgba(255,255,255,0.95)");
522
522
  grd.addColorStop(0.4, "rgba(237,30,121,0.75)");
523
- grd.addColorStop(0.75, "rgba(149,29,219,0.55)");
523
+ grd.addColorStop(0.75, "rgba(124,91,187,0.55)");
524
524
  grd.addColorStop(1, "rgba(0,0,0,0)");
525
525
  ctx.fillStyle = grd;
526
526
  ctx.fillRect(-tailLen, -1, tailLen, 2);
@@ -622,7 +622,7 @@ import { X } from "lucide-react";
622
622
  import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
623
623
  var variantStyles = {
624
624
  default: "bg-muted text-cupcode-ink border-border dark:text-white dark:bg-cupcode-ink/40",
625
- primary: "bg-gradient-to-r from-cupcode-pink to-cupcode-purple text-white border-transparent",
625
+ primary: "bg-gradient-to-r from-cupcode-hover to-cupcode-purple text-white border-transparent",
626
626
  secondary: "bg-cupcode-purple/10 text-cupcode-purple border-cupcode-purple/20",
627
627
  outline: "bg-transparent text-cupcode-ink border-cupcode-purple dark:text-cupcode-purple"
628
628
  };
@@ -708,10 +708,10 @@ var Dock = ({ items, className }) => {
708
708
  const itemsRef = useRef3([]);
709
709
  const OVERSHOOT = 5;
710
710
  useEffect3(() => {
711
- var _a65;
711
+ var _a72;
712
712
  const activeItem = itemsRef.current[activeIndex];
713
713
  if (!activeItem) return;
714
- const containerRect = (_a65 = activeItem.parentElement) == null ? void 0 : _a65.getBoundingClientRect();
714
+ const containerRect = (_a72 = activeItem.parentElement) == null ? void 0 : _a72.getBoundingClientRect();
715
715
  const itemRect = activeItem.getBoundingClientRect();
716
716
  if (!containerRect) return;
717
717
  const relativeLeft = itemRect.left - containerRect.left;
@@ -773,9 +773,9 @@ var Dock = ({ items, className }) => {
773
773
  "button",
774
774
  {
775
775
  onClick: () => {
776
- var _a65;
776
+ var _a72;
777
777
  setActiveIndex(index);
778
- (_a65 = item.onClick) == null ? void 0 : _a65.call(item);
778
+ (_a72 = item.onClick) == null ? void 0 : _a72.call(item);
779
779
  },
780
780
  className: cn(
781
781
  "flex items-center justify-center w-12 h-12 rounded-xl",
@@ -810,6 +810,7 @@ import { useEffect as useEffect5, useRef as useRef4, useMemo } from "react";
810
810
  import { useState as useState2, useEffect as useEffect4 } from "react";
811
811
 
812
812
  // src/lib/runtimeEnv.ts
813
+ var import_meta = {};
813
814
  var runtimeStore = {};
814
815
  var normalizeValue = (value) => {
815
816
  if (value === null || typeof value === "undefined") return void 0;
@@ -820,9 +821,9 @@ var normalizeValue = (value) => {
820
821
  return String(value);
821
822
  };
822
823
  var setCupcodeRuntimeEnv = (values) => {
823
- var _a65;
824
+ var _a72;
824
825
  const globalRef = globalThis;
825
- const nextGlobalEnv = { ...(_a65 = globalRef.__CUPCODE_ENV__) != null ? _a65 : {} };
826
+ const nextGlobalEnv = { ...(_a72 = globalRef.__CUPCODE_ENV__) != null ? _a72 : {} };
826
827
  Object.entries(values).forEach(([key, value]) => {
827
828
  const normalized = normalizeValue(value);
828
829
  runtimeStore[key] = normalized;
@@ -831,37 +832,72 @@ var setCupcodeRuntimeEnv = (values) => {
831
832
  globalRef.__CUPCODE_ENV__ = nextGlobalEnv;
832
833
  };
833
834
  var readFromProcessEnv = (key) => {
834
- var _a65;
835
- const processEnv = (_a65 = globalThis.process) == null ? void 0 : _a65.env;
835
+ var _a72;
836
+ const processEnv = (_a72 = globalThis.process) == null ? void 0 : _a72.env;
836
837
  return normalizeValue(processEnv == null ? void 0 : processEnv[key]);
837
838
  };
839
+ var readFromImportMetaEnv = (key) => {
840
+ try {
841
+ const importMetaEnv = import_meta.env;
842
+ return normalizeValue(importMetaEnv == null ? void 0 : importMetaEnv[key]);
843
+ } catch (e) {
844
+ return void 0;
845
+ }
846
+ };
838
847
  var getRuntimeEnv = (key) => {
839
- var _a65;
848
+ var _a72;
840
849
  const normalizedKey = key.trim();
841
850
  if (!normalizedKey) return void 0;
842
851
  const fromRuntimeStore = runtimeStore[normalizedKey];
843
852
  if (fromRuntimeStore) return fromRuntimeStore;
844
- const fromGlobalStore = normalizeValue((_a65 = globalThis.__CUPCODE_ENV__) == null ? void 0 : _a65[normalizedKey]);
853
+ const fromGlobalStore = normalizeValue((_a72 = globalThis.__CUPCODE_ENV__) == null ? void 0 : _a72[normalizedKey]);
845
854
  if (fromGlobalStore) return fromGlobalStore;
846
855
  const fromGlobalKey = normalizeValue(globalThis[normalizedKey]);
847
856
  if (fromGlobalKey) return fromGlobalKey;
857
+ const fromImportMetaEnv = readFromImportMetaEnv(normalizedKey);
858
+ if (fromImportMetaEnv) return fromImportMetaEnv;
848
859
  return readFromProcessEnv(normalizedKey);
849
860
  };
850
861
  var getRuntimeEnvOr = (key, fallback) => {
851
- var _a65;
852
- return (_a65 = getRuntimeEnv(key)) != null ? _a65 : fallback;
862
+ var _a72;
863
+ return (_a72 = getRuntimeEnv(key)) != null ? _a72 : fallback;
853
864
  };
854
865
  var isRuntimeDev = () => {
855
- var _a65, _b5, _c;
856
- const explicitDev = (_a65 = getRuntimeEnv("DEV")) != null ? _a65 : getRuntimeEnv("VITE_DEV");
866
+ var _a72, _b6, _c;
867
+ const explicitDev = (_a72 = getRuntimeEnv("DEV")) != null ? _a72 : getRuntimeEnv("VITE_DEV");
857
868
  if (explicitDev) {
858
869
  const normalized = explicitDev.toLowerCase();
859
870
  return normalized === "1" || normalized === "true";
860
871
  }
861
- const mode = ((_c = (_b5 = getRuntimeEnv("MODE")) != null ? _b5 : getRuntimeEnv("NODE_ENV")) != null ? _c : "").toLowerCase();
872
+ const mode = ((_c = (_b6 = getRuntimeEnv("MODE")) != null ? _b6 : getRuntimeEnv("NODE_ENV")) != null ? _c : "").toLowerCase();
862
873
  return mode === "development";
863
874
  };
864
875
 
876
+ // src/utils/parseAssetId.ts
877
+ 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;
878
+ 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;
879
+ var isUuid = (value) => {
880
+ if (typeof value !== "string") return false;
881
+ return UUID_REGEX.test(value.trim());
882
+ };
883
+ function parseAssetId(input) {
884
+ var _a72, _b6, _c, _d;
885
+ const raw = input == null ? void 0 : input.trim();
886
+ if (!raw) return void 0;
887
+ if (UUID_REGEX.test(raw)) return raw;
888
+ const matchFromRaw = (_a72 = raw.match(UUID_IN_TEXT_REGEX)) == null ? void 0 : _a72[0];
889
+ if (isUuid(matchFromRaw)) return matchFromRaw;
890
+ try {
891
+ const url = new URL(raw);
892
+ const queryParamId = (_c = (_b6 = url.searchParams.get("id")) != null ? _b6 : url.searchParams.get("asset_id")) != null ? _c : url.searchParams.get("assetId");
893
+ if (isUuid(queryParamId)) return queryParamId;
894
+ const matchFromPath = (_d = url.pathname.match(UUID_IN_TEXT_REGEX)) == null ? void 0 : _d[0];
895
+ if (isUuid(matchFromPath)) return matchFromPath;
896
+ } catch (e) {
897
+ }
898
+ return void 0;
899
+ }
900
+
865
901
  // src/hooks/useTelescupAsset.ts
866
902
  var getApiBase = () => getRuntimeEnvOr("VITE_TELESCUP_API_BASE", "https://cdn.cupcode.com.br").replace(/\/+$/, "");
867
903
  function buildTelescupImageURL(options) {
@@ -874,6 +910,25 @@ function buildTelescupImageURL(options) {
874
910
  params.set("q", quality.toString());
875
911
  return `${getApiBase()}/i?${params.toString()}`;
876
912
  }
913
+ function resolveTelescupImageURL(value, options) {
914
+ const raw = value == null ? void 0 : value.trim();
915
+ if (!raw) return void 0;
916
+ const parsedId = parseAssetId(raw);
917
+ if (parsedId) {
918
+ return buildTelescupImageURL({
919
+ id: parsedId,
920
+ width: options == null ? void 0 : options.width,
921
+ height: options == null ? void 0 : options.height,
922
+ fit: options == null ? void 0 : options.fit,
923
+ format: options == null ? void 0 : options.format,
924
+ quality: options == null ? void 0 : options.quality
925
+ });
926
+ }
927
+ if (raw.startsWith("http://") || raw.startsWith("https://") || raw.startsWith("data:") || raw.startsWith("blob:")) {
928
+ return raw;
929
+ }
930
+ return void 0;
931
+ }
877
932
  function buildTelescupVideoURL(id) {
878
933
  return `${getApiBase()}/i/v?id=${id}`;
879
934
  }
@@ -908,31 +963,6 @@ function useTelescupImage(options, lang) {
908
963
  return { url, meta, loading };
909
964
  }
910
965
 
911
- // src/utils/parseAssetId.ts
912
- 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;
913
- 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;
914
- var isUuid = (value) => {
915
- if (typeof value !== "string") return false;
916
- return UUID_REGEX.test(value.trim());
917
- };
918
- function parseAssetId(input) {
919
- var _a65, _b5, _c, _d;
920
- const raw = input == null ? void 0 : input.trim();
921
- if (!raw) return void 0;
922
- if (UUID_REGEX.test(raw)) return raw;
923
- const matchFromRaw = (_a65 = raw.match(UUID_IN_TEXT_REGEX)) == null ? void 0 : _a65[0];
924
- if (isUuid(matchFromRaw)) return matchFromRaw;
925
- try {
926
- const url = new URL(raw);
927
- const queryParamId = (_c = (_b5 = url.searchParams.get("id")) != null ? _b5 : url.searchParams.get("asset_id")) != null ? _c : url.searchParams.get("assetId");
928
- if (isUuid(queryParamId)) return queryParamId;
929
- const matchFromPath = (_d = url.pathname.match(UUID_IN_TEXT_REGEX)) == null ? void 0 : _d[0];
930
- if (isUuid(matchFromPath)) return matchFromPath;
931
- } catch (e) {
932
- }
933
- return void 0;
934
- }
935
-
936
966
  // src/components/cupcode/DockWrapper.tsx
937
967
  import { jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
938
968
  var getImageUrl = (rawId, width = 60, height = 60, format = "avif", quality = 60) => {
@@ -991,7 +1021,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
991
1021
  return void 0;
992
1022
  }, [sortedCategories]);
993
1023
  useEffect5(() => {
994
- var _a65;
1024
+ var _a72;
995
1025
  const root = rootRef.current;
996
1026
  if (!root) return;
997
1027
  const $ = (sel) => root.querySelector(sel);
@@ -1003,7 +1033,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
1003
1033
  const getDockItems = () => Array.from(root.querySelectorAll(INTERACTIVE_SELECTOR));
1004
1034
  const dockItems = getDockItems();
1005
1035
  if (!tabbar || !dock || !listMenuShow || !tabbarUl || dockItems.length === 0) return;
1006
- const persistentId = (_a65 = activeCategoryId != null ? activeCategoryId : lastInteractiveId) != null ? _a65 : null;
1036
+ const persistentId = (_a72 = activeCategoryId != null ? activeCategoryId : lastInteractiveId) != null ? _a72 : null;
1007
1037
  let openItem = null;
1008
1038
  let latestToggleToken = null;
1009
1039
  const persistentSelector = persistentId != null ? `${INTERACTIVE_SELECTOR}[data-cat-id="${persistentId}"]` : null;
@@ -1302,8 +1332,8 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
1302
1332
  }, total);
1303
1333
  }
1304
1334
  const hideBootstrapTooltip = (el) => {
1305
- var _a66, _b5;
1306
- const tooltip = ((_b5 = (_a66 = window.bootstrap) == null ? void 0 : _a66.Tooltip) == null ? void 0 : _b5.getInstance) ? window.bootstrap.Tooltip.getInstance(el) : null;
1335
+ var _a73, _b6;
1336
+ const tooltip = ((_b6 = (_a73 = window.bootstrap) == null ? void 0 : _a73.Tooltip) == null ? void 0 : _b6.getInstance) ? window.bootstrap.Tooltip.getInstance(el) : null;
1307
1337
  tooltip == null ? void 0 : tooltip.hide();
1308
1338
  };
1309
1339
  const openMenuForItem = (item, menu) => {
@@ -1321,14 +1351,14 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
1321
1351
  latestToggleToken = null;
1322
1352
  };
1323
1353
  const closeActiveMenu = (opts = {}) => {
1324
- var _a66;
1354
+ var _a73;
1325
1355
  if (!opts.onClosed) {
1326
1356
  latestToggleToken = null;
1327
1357
  }
1328
1358
  const itemToClose = openItem;
1329
1359
  if (!itemToClose) {
1330
1360
  if (!opts.preserveWrapper) ensurePersistentHighlight();
1331
- (_a66 = opts.onClosed) == null ? void 0 : _a66.call(opts);
1361
+ (_a73 = opts.onClosed) == null ? void 0 : _a73.call(opts);
1332
1362
  return;
1333
1363
  }
1334
1364
  const menu = getMenuFor(itemToClose);
@@ -1336,7 +1366,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
1336
1366
  itemToClose.classList.remove("active");
1337
1367
  delete itemToClose.dataset.menuOpen;
1338
1368
  const finalize = () => {
1339
- var _a67;
1369
+ var _a74;
1340
1370
  if (!opts.preserveWrapper) {
1341
1371
  listMenuShow.classList.remove("show");
1342
1372
  tabbar.classList.remove("is-active-menu");
@@ -1344,7 +1374,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
1344
1374
  setTabbarTheme(null);
1345
1375
  ensurePersistentHighlight();
1346
1376
  }
1347
- (_a67 = opts.onClosed) == null ? void 0 : _a67.call(opts);
1377
+ (_a74 = opts.onClosed) == null ? void 0 : _a74.call(opts);
1348
1378
  };
1349
1379
  closeMenu(menu, finalize);
1350
1380
  };
@@ -1447,7 +1477,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
1447
1477
  /* @__PURE__ */ jsx10("div", { className: "glass-overlay" }),
1448
1478
  /* @__PURE__ */ jsx10("div", { className: "glass-specular" }),
1449
1479
  /* @__PURE__ */ jsx10("ul", { className: "flex-center", children: sortedCategories.map((cat) => {
1450
- var _a65;
1480
+ var _a72;
1451
1481
  if (cat.type === "divider") {
1452
1482
  return /* @__PURE__ */ jsx10(
1453
1483
  "li",
@@ -1459,7 +1489,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
1459
1489
  cat.id
1460
1490
  );
1461
1491
  }
1462
- const hasCards = (((_a65 = cat.cards) == null ? void 0 : _a65.length) || 0) > 0;
1492
+ const hasCards = (((_a72 = cat.cards) == null ? void 0 : _a72.length) || 0) > 0;
1463
1493
  const link = cat.href;
1464
1494
  const isCurrent = cat.id === activeCategoryId;
1465
1495
  return /* @__PURE__ */ jsxs8(
@@ -1493,12 +1523,12 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
1493
1523
  );
1494
1524
  }) }),
1495
1525
  /* @__PURE__ */ jsx10("div", { className: "list-menu-mob-show", children: sortedCategories.filter((cat) => {
1496
- var _a65;
1497
- return cat.type !== "divider" && (((_a65 = cat.cards) == null ? void 0 : _a65.length) || 0) > 0;
1526
+ var _a72;
1527
+ return cat.type !== "divider" && (((_a72 = cat.cards) == null ? void 0 : _a72.length) || 0) > 0;
1498
1528
  }).map((cat) => {
1499
- var _a65;
1500
- return /* @__PURE__ */ jsx10("div", { className: "mob-list-menu hide", "data-tagget": cat.slug, children: /* @__PURE__ */ jsx10("div", { className: `submenu-stack ${cat.slug}`, children: ((_a65 = cat.cards) != null ? _a65 : []).map((card, i) => {
1501
- var _a66;
1529
+ var _a72;
1530
+ return /* @__PURE__ */ jsx10("div", { className: "mob-list-menu hide", "data-tagget": cat.slug, children: /* @__PURE__ */ jsx10("div", { className: `submenu-stack ${cat.slug}`, children: ((_a72 = cat.cards) != null ? _a72 : []).map((card, i) => {
1531
+ var _a73;
1502
1532
  return /* @__PURE__ */ jsxs8(
1503
1533
  "div",
1504
1534
  {
@@ -1514,8 +1544,8 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
1514
1544
  /* @__PURE__ */ jsx10("div", { className: "title", children: card.title }),
1515
1545
  card.description ? /* @__PURE__ */ jsx10("div", { className: "description", children: card.description }) : null
1516
1546
  ] }),
1517
- /* @__PURE__ */ jsx10("div", { className: "actions", children: ((_a66 = card.buttons) != null ? _a66 : []).slice(0, 2).map((btn, idx) => {
1518
- var _a67, _b5, _c, _d;
1547
+ /* @__PURE__ */ jsx10("div", { className: "actions", children: ((_a73 = card.buttons) != null ? _a73 : []).slice(0, 2).map((btn, idx) => {
1548
+ var _a74, _b6, _c, _d;
1519
1549
  const className = idx === 0 ? "saiba-mais" : "saiba-mais-1";
1520
1550
  if (btn.type === "popup") {
1521
1551
  return /* @__PURE__ */ jsx10(
@@ -1530,7 +1560,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
1530
1560
  window.dispatchEvent(new Event(`qw:open:${btn.popupId}`));
1531
1561
  }
1532
1562
  },
1533
- children: (_a67 = btn.label) != null ? _a67 : "Abrir"
1563
+ children: (_a74 = btn.label) != null ? _a74 : "Abrir"
1534
1564
  },
1535
1565
  `${cat.id}-card-${i}-btn-${idx}`
1536
1566
  );
@@ -1540,7 +1570,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
1540
1570
  {
1541
1571
  href: btn.href || "#",
1542
1572
  className,
1543
- target: ((_b5 = btn.href) == null ? void 0 : _b5.startsWith("http")) ? "_blank" : void 0,
1573
+ target: ((_b6 = btn.href) == null ? void 0 : _b6.startsWith("http")) ? "_blank" : void 0,
1544
1574
  rel: ((_c = btn.href) == null ? void 0 : _c.startsWith("http")) ? "noopener noreferrer" : void 0,
1545
1575
  children: (_d = btn.label) != null ? _d : "Saiba mais >"
1546
1576
  },
@@ -1686,7 +1716,7 @@ var JellyButton = forwardRef6(
1686
1716
  };
1687
1717
  const variantStyles3 = {
1688
1718
  primary: {
1689
- 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)]",
1719
+ 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)]",
1690
1720
  overlay: "bg-gradient-to-r from-white/20 via-transparent to-transparent"
1691
1721
  },
1692
1722
  secondary: {
@@ -1694,8 +1724,8 @@ var JellyButton = forwardRef6(
1694
1724
  overlay: "bg-gradient-to-r from-white/15 via-emerald-300/20 to-transparent"
1695
1725
  },
1696
1726
  half: {
1697
- 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)]",
1698
- overlay: "bg-gradient-to-br from-white/12 via-cupcode-pink/10 to-transparent"
1727
+ 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)]",
1728
+ overlay: "bg-gradient-to-br from-white/12 via-cupcode-hover/10 to-transparent"
1699
1729
  },
1700
1730
  "original-pink": {
1701
1731
  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)]",
@@ -1827,7 +1857,7 @@ var Eyebrow = forwardRef7(
1827
1857
  const variantClasses = {
1828
1858
  galaxy: "cc-gradient-galaxy text-white shadow-[0_0_20px_rgba(193,27,150,0.4)]",
1829
1859
  pink: "bg-cupcode-pink text-white shadow-[0_0_20px_rgba(237,30,121,0.4)]",
1830
- purple: "bg-cupcode-purple text-white shadow-[0_0_20px_rgba(149,29,219,0.4)]",
1860
+ purple: "bg-cupcode-purple text-white shadow-[0_0_20px_rgba(124,91,187,0.4)]",
1831
1861
  outline: "border-2 border-cupcode-purple text-cupcode-purple bg-transparent"
1832
1862
  };
1833
1863
  return /* @__PURE__ */ jsx14(
@@ -2106,7 +2136,7 @@ var LoadingSpinner = ({
2106
2136
  "div",
2107
2137
  {
2108
2138
  className: cn(
2109
- "animate-spin rounded-full border-transparent border-t-cupcode-pink border-r-cupcode-purple",
2139
+ "animate-spin rounded-full border-transparent border-t-cupcode-hover border-r-cupcode-purple",
2110
2140
  sizes[size],
2111
2141
  className
2112
2142
  ),
@@ -2155,7 +2185,7 @@ var LoadingScreen = ({
2155
2185
  return /* @__PURE__ */ jsx19("div", { className: cn(containerClasses, "cc-gradient-galaxy"), children: /* @__PURE__ */ jsxs15("div", { className: "glass rounded-2xl p-8 flex flex-col items-center space-y-4 animate-scale-in", children: [
2156
2186
  /* @__PURE__ */ jsxs15("div", { className: "relative", children: [
2157
2187
  /* @__PURE__ */ jsx19(LoadingSpinner, { size: "lg" }),
2158
- /* @__PURE__ */ jsx19("div", { className: "absolute inset-0 blur-2xl bg-cupcode-pink/30 animate-pulse-scale" })
2188
+ /* @__PURE__ */ jsx19("div", { className: "absolute inset-0 blur-2xl bg-cupcode-hover/30 animate-pulse-scale" })
2159
2189
  ] }),
2160
2190
  message && /* @__PURE__ */ jsx19("p", { className: "text-white font-semibold text-lg animate-pulse", children: message })
2161
2191
  ] }) });
@@ -2168,9 +2198,9 @@ var LoadingScreen = ({
2168
2198
  message && /* @__PURE__ */ jsxs15("div", { className: "text-center space-y-2", children: [
2169
2199
  /* @__PURE__ */ jsx19("p", { className: "font-bold text-lg cc-text-gradient-galaxy", children: message }),
2170
2200
  /* @__PURE__ */ jsxs15("div", { className: "flex gap-1 justify-center", children: [
2171
- /* @__PURE__ */ jsx19("div", { className: "w-2 h-2 rounded-full bg-cupcode-pink animate-bounce", style: { animationDelay: "0ms" } }),
2201
+ /* @__PURE__ */ jsx19("div", { className: "w-2 h-2 rounded-full bg-cupcode-hover animate-bounce", style: { animationDelay: "0ms" } }),
2172
2202
  /* @__PURE__ */ jsx19("div", { className: "w-2 h-2 rounded-full bg-cupcode-purple animate-bounce", style: { animationDelay: "150ms" } }),
2173
- /* @__PURE__ */ jsx19("div", { className: "w-2 h-2 rounded-full bg-cupcode-pink animate-bounce", style: { animationDelay: "300ms" } })
2203
+ /* @__PURE__ */ jsx19("div", { className: "w-2 h-2 rounded-full bg-cupcode-hover animate-bounce", style: { animationDelay: "300ms" } })
2174
2204
  ] })
2175
2205
  ] })
2176
2206
  ] }) });
@@ -2289,10 +2319,10 @@ var NavbarCupcode = ({
2289
2319
  React10.useEffect(() => {
2290
2320
  if (!isOpen) return;
2291
2321
  const handlePointerDown = (event) => {
2292
- var _a65;
2322
+ var _a72;
2293
2323
  const target = event.target;
2294
2324
  if (!(target instanceof Node)) return;
2295
- if (!((_a65 = navRef.current) == null ? void 0 : _a65.contains(target))) {
2325
+ if (!((_a72 = navRef.current) == null ? void 0 : _a72.contains(target))) {
2296
2326
  setIsOpen(false);
2297
2327
  }
2298
2328
  };
@@ -2333,8 +2363,8 @@ var NavbarCupcode = ({
2333
2363
  {
2334
2364
  ref: navRef,
2335
2365
  className: cn(
2336
- "fixed top-0 left-0 right-0 z-[200] pointer-events-auto",
2337
- "glass border-b border-border",
2366
+ "fixed left-2 right-2 top-[max(env(safe-area-inset-top),0.75rem)] z-[200] overflow-hidden rounded-2xl",
2367
+ "glass border-border/70 shadow-[var(--elevation-3)] md:left-4 md:right-4",
2338
2368
  className
2339
2369
  ),
2340
2370
  children: /* @__PURE__ */ jsxs17("div", { className: "cc-container", children: [
@@ -2352,8 +2382,8 @@ var NavbarCupcode = ({
2352
2382
  isActive && "text-primary after:w-full"
2353
2383
  );
2354
2384
  const handleClick = (event) => {
2355
- var _a65;
2356
- (_a65 = item.onClick) == null ? void 0 : _a65.call(item, event);
2385
+ var _a72;
2386
+ (_a72 = item.onClick) == null ? void 0 : _a72.call(item, event);
2357
2387
  };
2358
2388
  if (item.href.startsWith("#")) {
2359
2389
  return /* @__PURE__ */ jsxs17(
@@ -2404,7 +2434,7 @@ var NavbarCupcode = ({
2404
2434
  "div",
2405
2435
  {
2406
2436
  id: mobileMenuId,
2407
- className: "md:hidden max-h-[calc(100dvh-4rem)] space-y-3 overflow-y-auto border-t border-border/60 py-4 animate-slide-up",
2437
+ className: "md:hidden max-h-[calc(100dvh-5rem)] space-y-3 overflow-y-auto border-t border-border/60 py-4 animate-slide-up",
2408
2438
  children: [
2409
2439
  items.map((item, index) => {
2410
2440
  const key = `${item.label}-${index}`;
@@ -2414,8 +2444,8 @@ var NavbarCupcode = ({
2414
2444
  isActive && "text-primary"
2415
2445
  );
2416
2446
  const handleClick = (event) => {
2417
- var _a65;
2418
- (_a65 = item.onClick) == null ? void 0 : _a65.call(item, event);
2447
+ var _a72;
2448
+ (_a72 = item.onClick) == null ? void 0 : _a72.call(item, event);
2419
2449
  setIsOpen(false);
2420
2450
  };
2421
2451
  if (item.href.startsWith("#")) {
@@ -3222,12 +3252,12 @@ var rpcPreferredSchema = TELESCUP_RPC_SCHEMA;
3222
3252
  var RPC_MISSING_SCHEMAS_BY_PATH = /* @__PURE__ */ new Map();
3223
3253
  var FUNCTION_NOT_FOUND_CACHE = /* @__PURE__ */ new Set();
3224
3254
  var buildRestHeaders = (token, options) => {
3225
- var _a65;
3255
+ var _a72;
3226
3256
  const headers = {};
3227
3257
  if (SUPABASE_ANON_KEY) {
3228
3258
  headers.apikey = SUPABASE_ANON_KEY;
3229
3259
  }
3230
- const authorizationToken = (_a65 = resolveRpcAuthorizationToken(token)) != null ? _a65 : token;
3260
+ const authorizationToken = (_a72 = resolveRpcAuthorizationToken(token)) != null ? _a72 : token;
3231
3261
  if (authorizationToken) {
3232
3262
  headers.Authorization = `Bearer ${authorizationToken}`;
3233
3263
  }
@@ -3362,22 +3392,22 @@ var parseAssetSize = (value) => {
3362
3392
  return Number.isFinite(parsed) ? parsed : void 0;
3363
3393
  };
3364
3394
  var getFileExtension = (filename) => {
3365
- var _a65;
3395
+ var _a72;
3366
3396
  if (!filename) return void 0;
3367
3397
  const parts = filename.split(".");
3368
3398
  if (parts.length < 2) return void 0;
3369
- const candidate = (_a65 = parts[parts.length - 1]) == null ? void 0 : _a65.trim().toLowerCase();
3399
+ const candidate = (_a72 = parts[parts.length - 1]) == null ? void 0 : _a72.trim().toLowerCase();
3370
3400
  return candidate || void 0;
3371
3401
  };
3372
3402
  var resolveCategory = (row, activeMeta) => {
3373
- var _a65;
3374
- return (_a65 = readString(row.category)) != null ? _a65 : readString(activeMeta.category);
3403
+ var _a72;
3404
+ return (_a72 = readString(row.category)) != null ? _a72 : readString(activeMeta.category);
3375
3405
  };
3376
3406
  var resolveFolderName = (row) => readString(row.folder_name);
3377
3407
  var toTelescupAsset = (row, selectedLanguage) => {
3378
- var _a65, _b5, _c, _d, _e;
3408
+ var _a72, _b6, _c, _d, _e;
3379
3409
  const metaByLang = normalizeMetaByLanguage(row.meta);
3380
- const activeMeta = (_b5 = (_a65 = metaByLang[selectedLanguage]) != null ? _a65 : metaByLang.pt) != null ? _b5 : {};
3410
+ const activeMeta = (_b6 = (_a72 = metaByLang[selectedLanguage]) != null ? _a72 : metaByLang.pt) != null ? _b6 : {};
3381
3411
  return {
3382
3412
  id: (_c = row.id) != null ? _c : "",
3383
3413
  name: row.filename,
@@ -3403,14 +3433,14 @@ var buildFacetsFromItems = (items) => {
3403
3433
  const extensions = /* @__PURE__ */ new Map();
3404
3434
  const tags = /* @__PURE__ */ new Map();
3405
3435
  items.forEach((item) => {
3406
- var _a65, _b5, _c, _d, _e, _f, _g;
3436
+ var _a72, _b6, _c, _d, _e, _f, _g;
3407
3437
  if (item.category) {
3408
- categories.set(item.category, ((_a65 = categories.get(item.category)) != null ? _a65 : 0) + 1);
3438
+ categories.set(item.category, ((_a72 = categories.get(item.category)) != null ? _a72 : 0) + 1);
3409
3439
  }
3410
3440
  if (item.folderId) {
3411
3441
  const current = folders.get(item.folderId);
3412
3442
  folders.set(item.folderId, {
3413
- label: (_b5 = item.folderName) != null ? _b5 : current == null ? void 0 : current.label,
3443
+ label: (_b6 = item.folderName) != null ? _b6 : current == null ? void 0 : current.label,
3414
3444
  count: ((_c = current == null ? void 0 : current.count) != null ? _c : 0) + 1
3415
3445
  });
3416
3446
  }
@@ -3421,16 +3451,16 @@ var buildFacetsFromItems = (items) => {
3421
3451
  extensions.set(item.extension, ((_e = extensions.get(item.extension)) != null ? _e : 0) + 1);
3422
3452
  }
3423
3453
  (_g = (_f = item.meta) == null ? void 0 : _f.tags) == null ? void 0 : _g.forEach((tag) => {
3424
- var _a66;
3454
+ var _a73;
3425
3455
  const normalizedTag = tag.trim();
3426
3456
  if (!normalizedTag) return;
3427
- tags.set(normalizedTag, ((_a66 = tags.get(normalizedTag)) != null ? _a66 : 0) + 1);
3457
+ tags.set(normalizedTag, ((_a73 = tags.get(normalizedTag)) != null ? _a73 : 0) + 1);
3428
3458
  });
3429
3459
  });
3430
3460
  const toFacetValues = (map) => Array.from(map.entries()).map(([value, count2]) => ({ value, count: count2 })).sort((a, b) => a.value.localeCompare(b.value));
3431
3461
  const toFolderFacetValues = (map) => Array.from(map.entries()).map(([value, info]) => ({ value, label: info.label, count: info.count })).sort((a, b) => {
3432
- var _a65, _b5;
3433
- return ((_a65 = a.label) != null ? _a65 : a.value).localeCompare((_b5 = b.label) != null ? _b5 : b.value);
3462
+ var _a72, _b6;
3463
+ return ((_a72 = a.label) != null ? _a72 : a.value).localeCompare((_b6 = b.label) != null ? _b6 : b.value);
3434
3464
  });
3435
3465
  return {
3436
3466
  categories: toFacetValues(categories),
@@ -3448,7 +3478,7 @@ var isManagerScopeRetryable = (error) => {
3448
3478
  return /permission|not allowed|wrong key type|insufficient|unauthorized/i.test(detailsText);
3449
3479
  };
3450
3480
  async function listAssetsViaRpc(config, filters) {
3451
- var _a65, _b5, _c, _d, _e, _f, _g, _h, _i;
3481
+ var _a72, _b6, _c, _d, _e, _f, _g, _h, _i;
3452
3482
  if (!SUPABASE_ANON_KEY) {
3453
3483
  throw new TelescupClientError(
3454
3484
  "VITE_SUPABASE_ANON_KEY (ou VITE_SUPABASE_PUBLISHABLE_KEY) n\xE3o encontrado para fallback RPC do Telescup."
@@ -3468,11 +3498,11 @@ async function listAssetsViaRpc(config, filters) {
3468
3498
  }
3469
3499
  const shouldLoadFacetTables = isSupabaseAccessToken(token);
3470
3500
  const pageSize = Math.min(100, Math.max(1, toPositiveInt(filters.pageSize, 24)));
3471
- const page = toPositiveInt((_a65 = filters.cursor) != null ? _a65 : filters.page, 1);
3501
+ const page = toPositiveInt((_a72 = filters.cursor) != null ? _a72 : filters.page, 1);
3472
3502
  const selectedLanguage = normalizeLanguageKey(filters.language);
3473
3503
  const bodyBase = {
3474
3504
  p_user_id: userId,
3475
- p_query: (_b5 = filters.query) != null ? _b5 : null,
3505
+ p_query: (_b6 = filters.query) != null ? _b6 : null,
3476
3506
  p_page: page,
3477
3507
  p_page_size: pageSize,
3478
3508
  p_type: filters.type && filters.type !== "all" ? filters.type : null,
@@ -3568,13 +3598,13 @@ var getRpcSchemaCandidates = (rpcPath) => {
3568
3598
  return filtered.length ? filtered : ordered;
3569
3599
  };
3570
3600
  var markRpcSchemaMissing = (rpcPath, schema) => {
3571
- var _a65;
3572
- const set = (_a65 = RPC_MISSING_SCHEMAS_BY_PATH.get(rpcPath)) != null ? _a65 : /* @__PURE__ */ new Set();
3601
+ var _a72;
3602
+ const set = (_a72 = RPC_MISSING_SCHEMAS_BY_PATH.get(rpcPath)) != null ? _a72 : /* @__PURE__ */ new Set();
3573
3603
  set.add(schema);
3574
3604
  RPC_MISSING_SCHEMAS_BY_PATH.set(rpcPath, set);
3575
3605
  };
3576
3606
  async function requestRpc(config, rpcPath, payload) {
3577
- var _a65, _b5;
3607
+ var _a72, _b6;
3578
3608
  if (!SUPABASE_ANON_KEY) {
3579
3609
  throw new TelescupClientError(
3580
3610
  "VITE_SUPABASE_ANON_KEY (ou VITE_SUPABASE_PUBLISHABLE_KEY) n\xE3o encontrado para fallback RPC do Telescup."
@@ -3617,7 +3647,7 @@ async function requestRpc(config, rpcPath, payload) {
3617
3647
  throw new TelescupClientError(`Falha de rede ao chamar RPC ${rpcPath}.`, { details: error });
3618
3648
  }
3619
3649
  if (response.ok) {
3620
- const contentType = (_a65 = response.headers.get("content-type")) != null ? _a65 : "";
3650
+ const contentType = (_a72 = response.headers.get("content-type")) != null ? _a72 : "";
3621
3651
  if (!contentType.includes("application/json")) {
3622
3652
  const text = await response.text();
3623
3653
  if (!text) return {};
@@ -3639,7 +3669,7 @@ async function requestRpc(config, rpcPath, payload) {
3639
3669
  responsePayload = await response.text();
3640
3670
  }
3641
3671
  const payloadObject = responsePayload != null ? responsePayload : {};
3642
- const message = typeof responsePayload === "string" ? responsePayload : (_b5 = payloadObject.message) != null ? _b5 : `Erro ao chamar RPC ${schema}.${rpcPath} (${response.status}).`;
3672
+ const message = typeof responsePayload === "string" ? responsePayload : (_b6 = payloadObject.message) != null ? _b6 : `Erro ao chamar RPC ${schema}.${rpcPath} (${response.status}).`;
3643
3673
  const rpcError = new TelescupClientError(message, {
3644
3674
  status: response.status,
3645
3675
  code: payloadObject.code,
@@ -3669,7 +3699,7 @@ async function requestRpc(config, rpcPath, payload) {
3669
3699
  throw new TelescupClientError(`Falha ao chamar RPC ${rpcPath}.`);
3670
3700
  }
3671
3701
  var toTelescupError = async (response, fallbackMessage) => {
3672
- var _a65;
3702
+ var _a72;
3673
3703
  let payload = void 0;
3674
3704
  try {
3675
3705
  payload = await response.json();
@@ -3677,7 +3707,7 @@ var toTelescupError = async (response, fallbackMessage) => {
3677
3707
  payload = await response.text();
3678
3708
  }
3679
3709
  const payloadObject = payload != null ? payload : {};
3680
- const message = typeof payload === "string" ? payload : (_a65 = payloadObject.message) != null ? _a65 : `${fallbackMessage} (${response.status}).`;
3710
+ const message = typeof payload === "string" ? payload : (_a72 = payloadObject.message) != null ? _a72 : `${fallbackMessage} (${response.status}).`;
3681
3711
  return new TelescupClientError(message, {
3682
3712
  status: response.status,
3683
3713
  code: payloadObject.code,
@@ -3725,11 +3755,11 @@ var mergeFacetEntries = (current, incoming) => {
3725
3755
  const map = /* @__PURE__ */ new Map();
3726
3756
  current == null ? void 0 : current.forEach((entry) => map.set(entry.value, entry));
3727
3757
  incoming == null ? void 0 : incoming.forEach((entry) => {
3728
- var _a65, _b5, _c;
3758
+ var _a72, _b6, _c;
3729
3759
  const previous = map.get(entry.value);
3730
3760
  map.set(entry.value, {
3731
3761
  value: entry.value,
3732
- label: (_b5 = (_a65 = entry.label) != null ? _a65 : previous == null ? void 0 : previous.label) != null ? _b5 : entry.value,
3762
+ label: (_b6 = (_a72 = entry.label) != null ? _a72 : previous == null ? void 0 : previous.label) != null ? _b6 : entry.value,
3733
3763
  count: (_c = entry.count) != null ? _c : previous == null ? void 0 : previous.count
3734
3764
  });
3735
3765
  });
@@ -3749,10 +3779,10 @@ var mergeFacets = (base, incoming) => {
3749
3779
  var toFacetEntriesFromRows = (rows, valueKeys, labelKeys) => {
3750
3780
  const result = /* @__PURE__ */ new Map();
3751
3781
  rows.forEach((row) => {
3752
- var _a65;
3782
+ var _a72;
3753
3783
  const value = readFirstString(row, valueKeys);
3754
3784
  if (!value) return;
3755
- const label = (_a65 = readFirstString(row, labelKeys)) != null ? _a65 : value;
3785
+ const label = (_a72 = readFirstString(row, labelKeys)) != null ? _a72 : value;
3756
3786
  result.set(value, { value, label });
3757
3787
  });
3758
3788
  return Array.from(result.values()).sort((a, b) => a.label.localeCompare(b.label));
@@ -3811,7 +3841,7 @@ async function loadFacetsFromTelescupTables(config) {
3811
3841
  };
3812
3842
  }
3813
3843
  async function request(config, path, options = {}) {
3814
- var _a65, _b5, _c;
3844
+ var _a72, _b6, _c;
3815
3845
  const token = await config.getAccessToken();
3816
3846
  if (!token) {
3817
3847
  throw new TelescupClientError("Token de acesso n\xE3o encontrado.");
@@ -3819,7 +3849,7 @@ async function request(config, path, options = {}) {
3819
3849
  const functionsBaseUrl = resolveFunctionsBaseUrl(config.baseUrl);
3820
3850
  const url = joinUrl(functionsBaseUrl, path);
3821
3851
  const isAssetApiRoute = path.startsWith("asset-api/");
3822
- const authorizationToken = isAssetApiRoute ? (_a65 = resolveRpcAuthorizationToken(token)) != null ? _a65 : token : token;
3852
+ const authorizationToken = isAssetApiRoute ? (_a72 = resolveRpcAuthorizationToken(token)) != null ? _a72 : token : token;
3823
3853
  const headers = {
3824
3854
  Authorization: `Bearer ${authorizationToken}`,
3825
3855
  ...options.headers
@@ -3835,7 +3865,7 @@ async function request(config, path, options = {}) {
3835
3865
  let response;
3836
3866
  try {
3837
3867
  response = await fetch(url, {
3838
- method: (_b5 = options.method) != null ? _b5 : "POST",
3868
+ method: (_b6 = options.method) != null ? _b6 : "POST",
3839
3869
  headers,
3840
3870
  body
3841
3871
  });
@@ -3869,11 +3899,11 @@ var normalizeFunctionLanguage = (value) => {
3869
3899
  return normalized;
3870
3900
  };
3871
3901
  var toFunctionListPayload = (filters) => {
3872
- var _a65, _b5, _c, _d, _e, _f;
3873
- const page = toPositiveInt((_a65 = filters.cursor) != null ? _a65 : filters.page, 1);
3902
+ var _a72, _b6, _c, _d, _e, _f;
3903
+ const page = toPositiveInt((_a72 = filters.cursor) != null ? _a72 : filters.page, 1);
3874
3904
  const pageSize = Math.min(500, Math.max(1, toPositiveInt(filters.pageSize, 24)));
3875
3905
  return {
3876
- query: (_b5 = filters.query) != null ? _b5 : "",
3906
+ query: (_b6 = filters.query) != null ? _b6 : "",
3877
3907
  page,
3878
3908
  pageSize,
3879
3909
  sort: `${normalizeSortBy(filters.sort)}:${filters.order === "asc" ? "asc" : "desc"}`,
@@ -3908,8 +3938,8 @@ var toFolderPath = (value) => {
3908
3938
  return normalized.slice(0, lastSlash);
3909
3939
  };
3910
3940
  var normalizeFilterText = (value) => {
3911
- var _a65;
3912
- return (_a65 = value == null ? void 0 : value.trim().toLowerCase()) != null ? _a65 : "";
3941
+ var _a72;
3942
+ return (_a72 = value == null ? void 0 : value.trim().toLowerCase()) != null ? _a72 : "";
3913
3943
  };
3914
3944
  var normalizeExtensionFilter = (value) => {
3915
3945
  const normalized = normalizeFilterText(value);
@@ -3923,16 +3953,16 @@ var normalizeFolderFilter = (value) => {
3923
3953
  var sortAssets = (items, sort, order) => {
3924
3954
  const direction = order === "asc" ? 1 : -1;
3925
3955
  const byName = (a, b) => {
3926
- var _a65, _b5, _c, _d;
3927
- return ((_b5 = (_a65 = a.fileName) != null ? _a65 : a.name) != null ? _b5 : "").localeCompare((_d = (_c = b.fileName) != null ? _c : b.name) != null ? _d : "");
3956
+ var _a72, _b6, _c, _d;
3957
+ return ((_b6 = (_a72 = a.fileName) != null ? _a72 : a.name) != null ? _b6 : "").localeCompare((_d = (_c = b.fileName) != null ? _c : b.name) != null ? _d : "");
3928
3958
  };
3929
3959
  const byDate = (a, b, key) => {
3930
- var _a65, _b5;
3931
- return (Date.parse((_a65 = a[key]) != null ? _a65 : "") || 0) - (Date.parse((_b5 = b[key]) != null ? _b5 : "") || 0);
3960
+ var _a72, _b6;
3961
+ return (Date.parse((_a72 = a[key]) != null ? _a72 : "") || 0) - (Date.parse((_b6 = b[key]) != null ? _b6 : "") || 0);
3932
3962
  };
3933
3963
  const bySize = (a, b) => {
3934
- var _a65, _b5;
3935
- return ((_a65 = a.size) != null ? _a65 : 0) - ((_b5 = b.size) != null ? _b5 : 0);
3964
+ var _a72, _b6;
3965
+ return ((_a72 = a.size) != null ? _a72 : 0) - ((_b6 = b.size) != null ? _b6 : 0);
3936
3966
  };
3937
3967
  const sorted = [...items];
3938
3968
  sorted.sort((a, b) => {
@@ -3967,7 +3997,7 @@ var applyAssetApiSearchFilters = (items, filters) => {
3967
3997
  const folderFilter = normalizeFolderFilter(filters.folderId);
3968
3998
  const requireAlt = filters.hasAlt === true;
3969
3999
  return items.filter((asset) => {
3970
- var _a65, _b5, _c, _d, _e, _f, _g, _h, _i;
4000
+ var _a72, _b6, _c, _d, _e, _f, _g, _h, _i;
3971
4001
  const haystack = [
3972
4002
  asset.id,
3973
4003
  asset.name,
@@ -3976,8 +4006,8 @@ var applyAssetApiSearchFilters = (items, filters) => {
3976
4006
  asset.folderName,
3977
4007
  asset.category,
3978
4008
  asset.usage,
3979
- (_a65 = asset.meta) == null ? void 0 : _a65.title,
3980
- (_b5 = asset.meta) == null ? void 0 : _b5.description,
4009
+ (_a72 = asset.meta) == null ? void 0 : _a72.title,
4010
+ (_b6 = asset.meta) == null ? void 0 : _b6.description,
3981
4011
  (_c = asset.meta) == null ? void 0 : _c.alt,
3982
4012
  ...Array.isArray((_d = asset.meta) == null ? void 0 : _d.tags) ? asset.meta.tags : []
3983
4013
  ].filter((value) => typeof value === "string" && value.trim() !== "").join(" ").toLowerCase();
@@ -3996,15 +4026,15 @@ var applyAssetApiSearchFilters = (items, filters) => {
3996
4026
  });
3997
4027
  };
3998
4028
  var mapAssetApiSearchRowToAsset = (row) => {
3999
- var _a65, _b5, _c, _d;
4029
+ var _a72, _b6, _c, _d;
4000
4030
  const id = readFirstString(row, ["asset_id", "id"]);
4001
4031
  if (!id) return null;
4002
- const fileName = (_a65 = readFirstString(row, ["original_filename", "filename", "title"])) != null ? _a65 : readFirstString(row, ["file_path"]);
4032
+ const fileName = (_a72 = readFirstString(row, ["original_filename", "filename", "title"])) != null ? _a72 : readFirstString(row, ["file_path"]);
4003
4033
  const mimeType = readFirstString(row, ["mime_type", "mime"]);
4004
4034
  const extension = getFileExtension(readFirstString(row, ["file_path", "filename", "original_filename"]));
4005
4035
  const tags = Array.isArray(row.tags) ? row.tags.filter((item) => typeof item === "string") : void 0;
4006
4036
  const categories = readStringArray(row.categories);
4007
- const category = (_b5 = readFirstString(row, ["category"])) != null ? _b5 : categories[0];
4037
+ const category = (_b6 = readFirstString(row, ["category"])) != null ? _b6 : categories[0];
4008
4038
  const alt = readFirstString(row, ["alt_text"]);
4009
4039
  const title = readFirstString(row, ["title"]);
4010
4040
  const description = readFirstString(row, ["description"]);
@@ -4047,14 +4077,14 @@ var mapAssetApiSearchRowToAsset = (row) => {
4047
4077
  };
4048
4078
  };
4049
4079
  async function listAssetsViaAssetApiSearch(config, filters) {
4050
- var _a65, _b5;
4080
+ var _a72, _b6;
4051
4081
  const pageSize = Math.min(500, Math.max(1, toPositiveInt(filters.pageSize, 24)));
4052
- const page = toPositiveInt((_a65 = filters.cursor) != null ? _a65 : filters.page, 1);
4082
+ const page = toPositiveInt((_a72 = filters.cursor) != null ? _a72 : filters.page, 1);
4053
4083
  const hasActiveFacetFilter = Boolean(filters.type && filters.type !== "all") || Boolean(filters.extension) || Boolean(filters.category) || Boolean(filters.folderId) || Boolean(filters.usage) || filters.hasAlt === true;
4054
4084
  const baseLimit = page * pageSize + 1;
4055
4085
  const seedLimit = hasActiveFacetFilter ? baseLimit : Math.max(baseLimit, TELESCUP_ASSET_API_FACET_SEED_LIMIT);
4056
4086
  const limit = Math.min(500, seedLimit);
4057
- const query = ((_b5 = filters.query) != null ? _b5 : "").trim() || TELESCUP_SEARCH_DEFAULT_QUERY;
4087
+ const query = ((_b6 = filters.query) != null ? _b6 : "").trim() || TELESCUP_SEARCH_DEFAULT_QUERY;
4058
4088
  const [pathBase, rawQuery] = TELESCUP_LIST_FUNCTION.split("?");
4059
4089
  const params = new URLSearchParams(rawQuery != null ? rawQuery : "");
4060
4090
  params.set("q", query);
@@ -4078,12 +4108,12 @@ async function listAssetsViaAssetApiSearch(config, filters) {
4078
4108
  };
4079
4109
  }
4080
4110
  var mapGenericRowToAsset = (row) => {
4081
- var _a65, _b5;
4082
- const id = (_a65 = readFirstString(row, ["asset_id", "id", "file_id", "uuid"])) != null ? _a65 : typeof row.id === "number" ? String(row.id) : void 0;
4111
+ var _a72, _b6;
4112
+ const id = (_a72 = readFirstString(row, ["asset_id", "id", "file_id", "uuid"])) != null ? _a72 : typeof row.id === "number" ? String(row.id) : void 0;
4083
4113
  if (!id) return null;
4084
4114
  const fileName = readFirstString(row, ["filename", "file_name", "name", "title", "original_name"]);
4085
4115
  const mimeType = readFirstString(row, ["mime", "mime_type", "content_type", "file_mime"]);
4086
- const extension = (_b5 = readFirstString(row, ["extension", "ext"])) != null ? _b5 : getFileExtension(fileName);
4116
+ const extension = (_b6 = readFirstString(row, ["extension", "ext"])) != null ? _b6 : getFileExtension(fileName);
4087
4117
  return {
4088
4118
  id,
4089
4119
  name: fileName,
@@ -4101,16 +4131,16 @@ var mapGenericRowToAsset = (row) => {
4101
4131
  };
4102
4132
  };
4103
4133
  var normalizeListResponseFromFunctions = (response, filters) => {
4104
- var _a65, _b5, _c, _d, _e, _f;
4134
+ var _a72, _b6, _c, _d, _e, _f;
4105
4135
  const payload = response != null ? response : {};
4106
4136
  const itemsRaw = Array.isArray(payload.items) ? payload.items : [];
4107
4137
  const selectedLanguage = normalizeLanguageKey(filters.language);
4108
4138
  const items = itemsRaw.map((row) => {
4109
- var _a66, _b6, _c2;
4139
+ var _a73, _b7, _c2;
4110
4140
  const mapped = mapGenericRowToAsset(row);
4111
4141
  if (!mapped) return null;
4112
4142
  const metaByLang = normalizeMetaByLanguage(row.meta);
4113
- const activeMeta = (_b6 = (_a66 = metaByLang[selectedLanguage]) != null ? _a66 : metaByLang.pt) != null ? _b6 : {};
4143
+ const activeMeta = (_b7 = (_a73 = metaByLang[selectedLanguage]) != null ? _a73 : metaByLang.pt) != null ? _b7 : {};
4114
4144
  const usageFromObject = readUsageContext(row.usage);
4115
4145
  const normalized = {
4116
4146
  ...mapped,
@@ -4122,7 +4152,7 @@ var normalizeListResponseFromFunctions = (response, filters) => {
4122
4152
  };
4123
4153
  return normalized;
4124
4154
  }).filter((item) => item !== null);
4125
- const total = (_c = (_b5 = (_a65 = readNumber(payload.total)) != null ? _a65 : readNumber(payload.totalCount)) != null ? _b5 : readNumber(payload.total_count)) != null ? _c : items.length;
4155
+ const total = (_c = (_b6 = (_a72 = readNumber(payload.total)) != null ? _a72 : readNumber(payload.totalCount)) != null ? _b6 : readNumber(payload.total_count)) != null ? _c : items.length;
4126
4156
  const page = toPositiveInt((_e = (_d = payload.page) != null ? _d : filters.cursor) != null ? _e : filters.page, 1);
4127
4157
  const pageSize = Math.min(100, Math.max(1, toPositiveInt((_f = payload.pageSize) != null ? _f : filters.pageSize, 24)));
4128
4158
  const nextCursor = total > page * pageSize ? String(page + 1) : void 0;
@@ -4142,13 +4172,13 @@ var mapConflictForQueue = (value) => {
4142
4172
  return "conflict";
4143
4173
  };
4144
4174
  var toInitPayloadForFunctions = (payload) => {
4145
- var _a65, _b5;
4175
+ var _a72, _b6;
4146
4176
  return {
4147
4177
  filename: payload.fileName,
4148
4178
  size: payload.size,
4149
4179
  mime: payload.mimeType,
4150
- folder_id: (_a65 = payload.folderId) != null ? _a65 : null,
4151
- overwritePolicy: (_b5 = payload.conflict) != null ? _b5 : "ask",
4180
+ folder_id: (_a72 = payload.folderId) != null ? _a72 : null,
4181
+ overwritePolicy: (_b6 = payload.conflict) != null ? _b6 : "ask",
4152
4182
  fileName: payload.fileName,
4153
4183
  mimeType: payload.mimeType,
4154
4184
  folderId: payload.folderId,
@@ -4156,10 +4186,10 @@ var toInitPayloadForFunctions = (payload) => {
4156
4186
  };
4157
4187
  };
4158
4188
  var normalizeInitResponseFromFunctions = (response) => {
4159
- var _a65, _b5, _c, _d, _e, _f, _g;
4189
+ var _a72, _b6, _c, _d, _e, _f, _g;
4160
4190
  const payload = response != null ? response : {};
4161
- const existingRaw = (_a65 = payload.existingAsset) != null ? _a65 : payload.existing_asset;
4162
- const existingAsset = existingRaw ? (_b5 = mapGenericRowToAsset(existingRaw)) != null ? _b5 : void 0 : void 0;
4191
+ const existingRaw = (_a72 = payload.existingAsset) != null ? _a72 : payload.existing_asset;
4192
+ const existingAsset = existingRaw ? (_b6 = mapGenericRowToAsset(existingRaw)) != null ? _b6 : void 0 : void 0;
4163
4193
  const assetRaw = payload.asset;
4164
4194
  const asset = assetRaw ? (_c = mapGenericRowToAsset(assetRaw)) != null ? _c : void 0 : void 0;
4165
4195
  const conflictSource = (_e = readString(payload.conflict)) != null ? _e : readString((_d = payload.conflict) == null ? void 0 : _d.type);
@@ -4180,12 +4210,12 @@ var normalizeInitResponseFromFunctions = (response) => {
4180
4210
  };
4181
4211
  };
4182
4212
  var toCompletePayloadForFunctions = (payload) => {
4183
- var _a65, _b5, _c;
4213
+ var _a72, _b6, _c;
4184
4214
  return {
4185
4215
  uploadId: payload.uploadId,
4186
- assetDraftId: (_a65 = payload.assetDraftId) != null ? _a65 : payload.assetId,
4216
+ assetDraftId: (_a72 = payload.assetDraftId) != null ? _a72 : payload.assetId,
4187
4217
  storageKey: payload.storageKey,
4188
- finalFilename: (_b5 = payload.finalFilename) != null ? _b5 : payload.fileName,
4218
+ finalFilename: (_b6 = payload.finalFilename) != null ? _b6 : payload.fileName,
4189
4219
  folder_id: (_c = payload.folderId) != null ? _c : null,
4190
4220
  upload_id: payload.uploadId,
4191
4221
  asset_id: payload.assetId,
@@ -4193,21 +4223,21 @@ var toCompletePayloadForFunctions = (payload) => {
4193
4223
  };
4194
4224
  };
4195
4225
  var normalizeCompleteResponseFromFunctions = (response) => {
4196
- var _a65, _b5;
4226
+ var _a72, _b6;
4197
4227
  const payload = response != null ? response : {};
4198
- const assetRaw = (_a65 = payload.asset) != null ? _a65 : payload;
4228
+ const assetRaw = (_a72 = payload.asset) != null ? _a72 : payload;
4199
4229
  const mapped = mapGenericRowToAsset(assetRaw);
4200
4230
  if (mapped) return { asset: mapped };
4201
- const assetId = (_b5 = readFirstString(assetRaw, ["id", "asset_id"])) != null ? _b5 : readFirstString(payload, ["assetId", "asset_id"]);
4231
+ const assetId = (_b6 = readFirstString(assetRaw, ["id", "asset_id"])) != null ? _b6 : readFirstString(payload, ["assetId", "asset_id"]);
4202
4232
  if (!assetId) {
4203
4233
  throw new TelescupClientError("Resposta inv\xE1lida ao finalizar upload no Telescup.");
4204
4234
  }
4205
4235
  return { asset: { id: assetId } };
4206
4236
  };
4207
4237
  var toMetaPayloadForFunctions = (payload) => {
4208
- var _a65, _b5;
4238
+ var _a72, _b6;
4209
4239
  if (TELESCUP_UPDATE_META_FUNCTION === "update-asset-meta") {
4210
- const categories = ((_a65 = payload.meta) == null ? void 0 : _a65.category) ? [payload.meta.category] : [];
4240
+ const categories = ((_a72 = payload.meta) == null ? void 0 : _a72.category) ? [payload.meta.category] : [];
4211
4241
  return {
4212
4242
  asset_id: payload.assetId,
4213
4243
  categories
@@ -4222,7 +4252,7 @@ var toMetaPayloadForFunctions = (payload) => {
4222
4252
  en: {},
4223
4253
  es: {}
4224
4254
  };
4225
- const target = (_b5 = byLanguage[language]) != null ? _b5 : byLanguage.pt;
4255
+ const target = (_b6 = byLanguage[language]) != null ? _b6 : byLanguage.pt;
4226
4256
  if (payload.meta) {
4227
4257
  if (typeof payload.meta.alt === "string") target.alt = payload.meta.alt;
4228
4258
  if (typeof payload.meta.title === "string") target.title = payload.meta.title;
@@ -4318,7 +4348,7 @@ var createTelescupClient = (config) => ({
4318
4348
  body: toMetaPayloadForFunctions(payload)
4319
4349
  }),
4320
4350
  uploadDirect: async (file) => {
4321
- var _a65;
4351
+ var _a72;
4322
4352
  const token = await config.getAccessToken();
4323
4353
  const userId = resolveUserIdFromToken(token);
4324
4354
  if (!userId) {
@@ -4346,7 +4376,7 @@ var createTelescupClient = (config) => ({
4346
4376
  }
4347
4377
  });
4348
4378
  const payload = response != null ? response : {};
4349
- const asset = mapAssetApiSearchRowToAsset((_a65 = payload.asset) != null ? _a65 : {});
4379
+ const asset = mapAssetApiSearchRowToAsset((_a72 = payload.asset) != null ? _a72 : {});
4350
4380
  if (!asset) {
4351
4381
  throw new TelescupClientError("Resposta inv\xE1lida do upload direto (asset-api).");
4352
4382
  }
@@ -4418,9 +4448,9 @@ function useTelescupAssets(options) {
4418
4448
  ...sanitizeFilters(filters),
4419
4449
  pageSize
4420
4450
  }).then((data) => {
4421
- var _a65;
4451
+ var _a72;
4422
4452
  return {
4423
- items: (_a65 = data.items) != null ? _a65 : [],
4453
+ items: (_a72 = data.items) != null ? _a72 : [],
4424
4454
  nextCursor: data.nextCursor,
4425
4455
  total: data.total,
4426
4456
  facets: data.facets
@@ -4443,7 +4473,7 @@ function useTelescupAssets(options) {
4443
4473
  [cacheKey, cacheTimeMs, enabled, filters, pageSize, resolvedClient]
4444
4474
  );
4445
4475
  const loadMore = useCallback(async () => {
4446
- var _a65, _b5, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
4476
+ var _a72, _b6, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
4447
4477
  if (!state.nextCursor || isLoadingMore || isLoading) return;
4448
4478
  const requestSeq = requestSeqRef.current;
4449
4479
  setIsLoadingMore(true);
@@ -4457,9 +4487,9 @@ function useTelescupAssets(options) {
4457
4487
  });
4458
4488
  if (!aliveRef.current || requestSeq !== requestSeqRef.current) return;
4459
4489
  const merged = {
4460
- items: [...state.items, ...(_a65 = data.items) != null ? _a65 : []],
4490
+ items: [...state.items, ...(_a72 = data.items) != null ? _a72 : []],
4461
4491
  nextCursor: data.nextCursor,
4462
- total: (_b5 = data.total) != null ? _b5 : state.total,
4492
+ total: (_b6 = data.total) != null ? _b6 : state.total,
4463
4493
  facets: {
4464
4494
  categories: (_d = (_c = data.facets) == null ? void 0 : _c.categories) != null ? _d : previousFacets == null ? void 0 : previousFacets.categories,
4465
4495
  folders: (_f = (_e = data.facets) == null ? void 0 : _e.folders) != null ? _f : previousFacets == null ? void 0 : previousFacets.folders,
@@ -4608,12 +4638,12 @@ var IMAGE_EXTENSIONS = /* @__PURE__ */ new Set(["jpg", "jpeg", "png", "gif", "we
4608
4638
  var VIDEO_EXTENSIONS = /* @__PURE__ */ new Set(["mp4", "mov", "webm", "mkv", "avi", "m4v", "wmv"]);
4609
4639
  var AUDIO_EXTENSIONS = /* @__PURE__ */ new Set(["mp3", "wav", "aac", "ogg", "flac", "m4a"]);
4610
4640
  var resolveAssetFamily = (asset) => {
4611
- var _a65, _b5, _c;
4612
- const explicitType = (_a65 = asset.type) == null ? void 0 : _a65.toLowerCase();
4641
+ var _a72, _b6, _c;
4642
+ const explicitType = (_a72 = asset.type) == null ? void 0 : _a72.toLowerCase();
4613
4643
  if (explicitType === "image" || explicitType === "video" || explicitType === "audio" || explicitType === "file") {
4614
4644
  return explicitType;
4615
4645
  }
4616
- const mime = (_b5 = asset.mimeType) == null ? void 0 : _b5.toLowerCase();
4646
+ const mime = (_b6 = asset.mimeType) == null ? void 0 : _b6.toLowerCase();
4617
4647
  if (mime == null ? void 0 : mime.startsWith("image/")) return "image";
4618
4648
  if (mime == null ? void 0 : mime.startsWith("video/")) return "video";
4619
4649
  if (mime == null ? void 0 : mime.startsWith("audio/")) return "audio";
@@ -4625,9 +4655,9 @@ var resolveAssetFamily = (asset) => {
4625
4655
  return "file";
4626
4656
  };
4627
4657
  var matchesAllowedAsset = (asset, allowed) => {
4628
- var _a65, _b5, _c, _d;
4658
+ var _a72, _b6, _c, _d;
4629
4659
  if (!allowed || allowed.length === 0) return true;
4630
- const mime = (_b5 = (_a65 = asset.mimeType) == null ? void 0 : _a65.toLowerCase()) != null ? _b5 : "";
4660
+ const mime = (_b6 = (_a72 = asset.mimeType) == null ? void 0 : _a72.toLowerCase()) != null ? _b6 : "";
4631
4661
  const ext = asset.extension ? `.${asset.extension.toLowerCase()}` : "";
4632
4662
  const type = (_d = (_c = asset.type) == null ? void 0 : _c.toLowerCase()) != null ? _d : "";
4633
4663
  const family = resolveAssetFamily(asset);
@@ -4673,12 +4703,12 @@ var getPreview = (asset) => {
4673
4703
  var normalizeFacetOptions = (entries) => {
4674
4704
  if (!entries || !entries.length) return [];
4675
4705
  return entries.reduce((acc, entry) => {
4676
- var _a65, _b5;
4677
- const value = (_a65 = entry.value) == null ? void 0 : _a65.trim();
4706
+ var _a72, _b6;
4707
+ const value = (_a72 = entry.value) == null ? void 0 : _a72.trim();
4678
4708
  if (!value) return acc;
4679
4709
  acc.push({
4680
4710
  value,
4681
- label: ((_b5 = entry.label) == null ? void 0 : _b5.trim()) || value,
4711
+ label: ((_b6 = entry.label) == null ? void 0 : _b6.trim()) || value,
4682
4712
  count: typeof entry.count === "number" ? entry.count : void 0
4683
4713
  });
4684
4714
  return acc;
@@ -4687,13 +4717,13 @@ var normalizeFacetOptions = (entries) => {
4687
4717
  var collectFacetOptions = (items, pick, pickLabel) => {
4688
4718
  const options = /* @__PURE__ */ new Map();
4689
4719
  items.forEach((asset) => {
4690
- var _a65, _b5, _c;
4691
- const value = (_a65 = pick(asset)) == null ? void 0 : _a65.trim();
4720
+ var _a72, _b6, _c;
4721
+ const value = (_a72 = pick(asset)) == null ? void 0 : _a72.trim();
4692
4722
  if (!value) return;
4693
4723
  const current = options.get(value);
4694
4724
  options.set(value, {
4695
4725
  value,
4696
- label: ((_b5 = pickLabel == null ? void 0 : pickLabel(asset)) == null ? void 0 : _b5.trim()) || (current == null ? void 0 : current.label) || value,
4726
+ label: ((_b6 = pickLabel == null ? void 0 : pickLabel(asset)) == null ? void 0 : _b6.trim()) || (current == null ? void 0 : current.label) || value,
4697
4727
  count: ((_c = current == null ? void 0 : current.count) != null ? _c : 0) + 1
4698
4728
  });
4699
4729
  });
@@ -4948,7 +4978,7 @@ function useTelescupUploadQueue(options) {
4948
4978
  activeRef.current += 1;
4949
4979
  updateItem(next.id, { status: "uploading", progress: 0, error: void 0 });
4950
4980
  const run = async () => {
4951
- var _a65, _b5, _c;
4981
+ var _a72, _b6, _c;
4952
4982
  try {
4953
4983
  if (TELESCUP_UPLOAD_MODE === "direct") {
4954
4984
  const completed2 = await client.uploadDirect(next.file);
@@ -4967,7 +4997,7 @@ function useTelescupUploadQueue(options) {
4967
4997
  size: next.file.size,
4968
4998
  mimeType: next.file.type,
4969
4999
  folderId,
4970
- conflict: (_a65 = next.conflictPolicy) != null ? _a65 : conflictPolicy
5000
+ conflict: (_a72 = next.conflictPolicy) != null ? _a72 : conflictPolicy
4971
5001
  });
4972
5002
  const conflictDetected = init.conflict === "ask" || init.conflict === "conflict" || init.conflict === "exists" || init.existingAsset && !init.uploadUrl;
4973
5003
  if (conflictDetected) {
@@ -5006,7 +5036,7 @@ function useTelescupUploadQueue(options) {
5006
5036
  storageKey: init.storageKey,
5007
5037
  finalFilename: init.finalFilename,
5008
5038
  folderId,
5009
- assetId: (_b5 = init.asset) == null ? void 0 : _b5.id,
5039
+ assetId: (_b6 = init.asset) == null ? void 0 : _b6.id,
5010
5040
  fileName: (_c = init.resolvedName) != null ? _c : next.file.name
5011
5041
  });
5012
5042
  updateItem(next.id, {
@@ -5105,7 +5135,7 @@ var TelescupUploader = ({
5105
5135
  className,
5106
5136
  onAssetUploaded
5107
5137
  }) => {
5108
- var _a65;
5138
+ var _a72;
5109
5139
  const inputRef = useRef10(null);
5110
5140
  const [dragActive, setDragActive] = useState9(false);
5111
5141
  const {
@@ -5172,8 +5202,8 @@ var TelescupUploader = ({
5172
5202
  size: "sm",
5173
5203
  variant: "secondary",
5174
5204
  onClick: () => {
5175
- var _a66;
5176
- return (_a66 = inputRef.current) == null ? void 0 : _a66.click();
5205
+ var _a73;
5206
+ return (_a73 = inputRef.current) == null ? void 0 : _a73.click();
5177
5207
  },
5178
5208
  children: labels.uploader.browse
5179
5209
  }
@@ -5187,8 +5217,8 @@ var TelescupUploader = ({
5187
5217
  accept,
5188
5218
  multiple,
5189
5219
  onChange: (event) => {
5190
- var _a66;
5191
- if ((_a66 = event.target.files) == null ? void 0 : _a66.length) {
5220
+ var _a73;
5221
+ if ((_a73 = event.target.files) == null ? void 0 : _a73.length) {
5192
5222
  handleFiles(event.target.files);
5193
5223
  event.currentTarget.value = "";
5194
5224
  }
@@ -5223,7 +5253,7 @@ var TelescupUploader = ({
5223
5253
  /* @__PURE__ */ jsx37(AlertDialogTitle, { children: labels.conflict.title }),
5224
5254
  /* @__PURE__ */ jsx37(AlertDialogDescription, { children: labels.conflict.description })
5225
5255
  ] }),
5226
- ((_a65 = conflictItem == null ? void 0 : conflictItem.existingAsset) == null ? void 0 : _a65.id) ? /* @__PURE__ */ jsxs24("div", { className: "mt-3 rounded-lg border border-border bg-muted/30 p-3", children: [
5256
+ ((_a72 = conflictItem == null ? void 0 : conflictItem.existingAsset) == null ? void 0 : _a72.id) ? /* @__PURE__ */ jsxs24("div", { className: "mt-3 rounded-lg border border-border bg-muted/30 p-3", children: [
5227
5257
  /* @__PURE__ */ jsx37("p", { className: "text-xs font-semibold text-muted-foreground", children: "Asset existente" }),
5228
5258
  /* @__PURE__ */ jsx37("div", { className: "mt-2 h-28 overflow-hidden rounded-md", children: /* @__PURE__ */ jsx37(
5229
5259
  TelescupImage,
@@ -5446,7 +5476,7 @@ var DEFAULT_LABELS = {
5446
5476
  }
5447
5477
  };
5448
5478
  var mergeLabels = (overrides) => {
5449
- var _a65;
5479
+ var _a72;
5450
5480
  if (!overrides) return DEFAULT_LABELS;
5451
5481
  return {
5452
5482
  ...DEFAULT_LABELS,
@@ -5460,17 +5490,17 @@ var mergeLabels = (overrides) => {
5460
5490
  meta: {
5461
5491
  ...DEFAULT_LABELS.meta,
5462
5492
  ...overrides.meta,
5463
- fields: { ...DEFAULT_LABELS.meta.fields, ...(_a65 = overrides.meta) == null ? void 0 : _a65.fields }
5493
+ fields: { ...DEFAULT_LABELS.meta.fields, ...(_a72 = overrides.meta) == null ? void 0 : _a72.fields }
5464
5494
  },
5465
5495
  toasts: { ...DEFAULT_LABELS.toasts, ...overrides.toasts }
5466
5496
  };
5467
5497
  };
5468
5498
  var LANGUAGES = ["pt", "en", "es"];
5469
5499
  var getAssetMeta = (asset, lang) => {
5470
- var _a65, _b5;
5500
+ var _a72, _b6;
5471
5501
  if (!asset) return {};
5472
- if ((_a65 = asset.metaByLang) == null ? void 0 : _a65[lang]) return asset.metaByLang[lang];
5473
- return (_b5 = asset.meta) != null ? _b5 : {};
5502
+ if ((_a72 = asset.metaByLang) == null ? void 0 : _a72[lang]) return asset.metaByLang[lang];
5503
+ return (_b6 = asset.meta) != null ? _b6 : {};
5474
5504
  };
5475
5505
  var TelescupMetaEditor = ({
5476
5506
  client,
@@ -5480,8 +5510,8 @@ var TelescupMetaEditor = ({
5480
5510
  labels,
5481
5511
  onAssetUpdated
5482
5512
  }) => {
5483
- var _a65, _b5, _c, _d, _e, _f, _g, _h;
5484
- const [activeAssetId, setActiveAssetId] = useState10((_b5 = (_a65 = assets[0]) == null ? void 0 : _a65.id) != null ? _b5 : "");
5513
+ var _a72, _b6, _c, _d, _e, _f, _g, _h;
5514
+ const [activeAssetId, setActiveAssetId] = useState10((_b6 = (_a72 = assets[0]) == null ? void 0 : _a72.id) != null ? _b6 : "");
5485
5515
  const [activeLang, setActiveLang] = useState10(
5486
5516
  LANGUAGES.includes(defaultLanguage) ? defaultLanguage : "pt"
5487
5517
  );
@@ -5499,18 +5529,18 @@ var TelescupMetaEditor = ({
5499
5529
  }, [activeAssetId, assets]);
5500
5530
  const asset = assets.find((item) => item.id === activeAssetId);
5501
5531
  const currentDraft = useMemo6(() => {
5502
- var _a66;
5503
- const existing = (_a66 = drafts[activeAssetId]) == null ? void 0 : _a66[activeLang];
5532
+ var _a73;
5533
+ const existing = (_a73 = drafts[activeAssetId]) == null ? void 0 : _a73[activeLang];
5504
5534
  if (existing) return existing;
5505
5535
  return getAssetMeta(asset, activeLang);
5506
5536
  }, [activeAssetId, activeLang, asset, drafts]);
5507
5537
  const updateDraft = (field, value) => {
5508
5538
  setDrafts((prev) => {
5509
- var _a66;
5539
+ var _a73;
5510
5540
  return {
5511
5541
  ...prev,
5512
5542
  [activeAssetId]: {
5513
- ...(_a66 = prev[activeAssetId]) != null ? _a66 : {},
5543
+ ...(_a73 = prev[activeAssetId]) != null ? _a73 : {},
5514
5544
  [activeLang]: {
5515
5545
  ...currentDraft,
5516
5546
  [field]: value
@@ -5578,11 +5608,11 @@ var TelescupMetaEditor = ({
5578
5608
  onAssetUpdated == null ? void 0 : onAssetUpdated(updated);
5579
5609
  const updatedMeta = getAssetMeta(updated, activeLang);
5580
5610
  setDrafts((prev) => {
5581
- var _a66;
5611
+ var _a73;
5582
5612
  return {
5583
5613
  ...prev,
5584
5614
  [asset.id]: {
5585
- ...(_a66 = prev[asset.id]) != null ? _a66 : {},
5615
+ ...(_a73 = prev[asset.id]) != null ? _a73 : {},
5586
5616
  [activeLang]: updatedMeta
5587
5617
  }
5588
5618
  };
@@ -6158,16 +6188,16 @@ var normalizeContrastMode = (value) => {
6158
6188
  return (value == null ? void 0 : value.trim().toLowerCase()) === "high" ? "high" : "normal";
6159
6189
  };
6160
6190
  var readStoredExperienceSettings = () => {
6161
- var _a65, _b5, _c;
6191
+ var _a72, _b6, _c;
6162
6192
  const fallback = defaultExperienceSettings();
6163
6193
  if (typeof window === "undefined") return fallback;
6164
6194
  try {
6165
6195
  const raw = window.localStorage.getItem(EXPERIENCE_SETTINGS_STORAGE_KEY);
6166
6196
  const parsed = raw ? JSON.parse(raw) : null;
6167
6197
  const storedThemePreference = window.localStorage.getItem(THEME_PREFERENCE_STORAGE_KEY);
6168
- const legacyTheme = (_a65 = window.localStorage.getItem(THEME_STORAGE_KEY)) != null ? _a65 : window.localStorage.getItem(LEGACY_THEME_STORAGE_KEY);
6198
+ const legacyTheme = (_a72 = window.localStorage.getItem(THEME_STORAGE_KEY)) != null ? _a72 : window.localStorage.getItem(LEGACY_THEME_STORAGE_KEY);
6169
6199
  return {
6170
- theme: normalizeThemePreference((_c = (_b5 = parsed == null ? void 0 : parsed.theme) != null ? _b5 : storedThemePreference) != null ? _c : legacyTheme),
6200
+ theme: normalizeThemePreference((_c = (_b6 = parsed == null ? void 0 : parsed.theme) != null ? _b6 : storedThemePreference) != null ? _c : legacyTheme),
6171
6201
  density: normalizeDensityMode(parsed == null ? void 0 : parsed.density),
6172
6202
  contrast: normalizeContrastMode(parsed == null ? void 0 : parsed.contrast),
6173
6203
  showEmailPublicly: typeof (parsed == null ? void 0 : parsed.showEmailPublicly) === "boolean" ? parsed.showEmailPublicly : fallback.showEmailPublicly
@@ -6309,7 +6339,7 @@ var getNotificationTimestamp = (notification) => {
6309
6339
  return Number.isNaN(parsed) ? 0 : parsed;
6310
6340
  };
6311
6341
  var formatNotificationDateTime = (notification) => {
6312
- var _a65;
6342
+ var _a72;
6313
6343
  if (notification.createdAt) {
6314
6344
  const parsed = new Date(notification.createdAt);
6315
6345
  if (!Number.isNaN(parsed.getTime())) {
@@ -6321,7 +6351,7 @@ var formatNotificationDateTime = (notification) => {
6321
6351
  });
6322
6352
  }
6323
6353
  }
6324
- return ((_a65 = notification.timeLabel) == null ? void 0 : _a65.trim()) || "Agora";
6354
+ return ((_a72 = notification.timeLabel) == null ? void 0 : _a72.trim()) || "Agora";
6325
6355
  };
6326
6356
  var getNotificationDayKey = (notification) => {
6327
6357
  const timestamp = getNotificationTimestamp(notification);
@@ -6394,30 +6424,22 @@ var extractSharedFilesFromMessages = (messages) => {
6394
6424
  return files;
6395
6425
  };
6396
6426
  var resolveTelescupImageUrl = (value, options) => {
6397
- var _a65, _b5, _c;
6398
- const width = (_a65 = options == null ? void 0 : options.width) != null ? _a65 : 96;
6399
- const height = (_b5 = options == null ? void 0 : options.height) != null ? _b5 : 96;
6400
- const quality = (_c = options == null ? void 0 : options.quality) != null ? _c : 72;
6401
- const raw = value == null ? void 0 : value.trim();
6402
- if (!raw) return void 0;
6403
- if (raw.startsWith("http://") || raw.startsWith("https://") || raw.startsWith("data:") || raw.startsWith("blob:")) {
6404
- const parsedId2 = parseAssetId(raw);
6405
- if (parsedId2) {
6406
- return buildTelescupImageURL({ id: parsedId2, width, height, fit: "cover", format: "avif", quality });
6407
- }
6408
- return raw;
6409
- }
6410
- const parsedId = parseAssetId(raw);
6411
- if (!parsedId) return void 0;
6412
- return buildTelescupImageURL({ id: parsedId, width, height, fit: "cover", format: "avif", quality });
6427
+ var _a72, _b6, _c;
6428
+ return resolveTelescupImageURL(value, {
6429
+ width: (_a72 = options == null ? void 0 : options.width) != null ? _a72 : 96,
6430
+ height: (_b6 = options == null ? void 0 : options.height) != null ? _b6 : 96,
6431
+ fit: "cover",
6432
+ format: "avif",
6433
+ quality: (_c = options == null ? void 0 : options.quality) != null ? _c : 72
6434
+ });
6413
6435
  };
6414
6436
  var resolveGroupAvatarFromTelescup = (asset, fallbackId) => {
6415
- var _a65, _b5;
6416
- return (_b5 = (_a65 = resolveTelescupImageUrl(asset == null ? void 0 : asset.url)) != null ? _a65 : resolveTelescupImageUrl(asset == null ? void 0 : asset.id)) != null ? _b5 : resolveTelescupImageUrl(fallbackId);
6437
+ var _a72, _b6;
6438
+ return (_b6 = (_a72 = resolveTelescupImageUrl(asset == null ? void 0 : asset.url)) != null ? _a72 : resolveTelescupImageUrl(asset == null ? void 0 : asset.id)) != null ? _b6 : resolveTelescupImageUrl(fallbackId);
6417
6439
  };
6418
6440
  var resolveProfileAvatarFromTelescup = (asset, fallbackId) => {
6419
- var _a65, _b5;
6420
- 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 });
6441
+ var _a72, _b6;
6442
+ 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 });
6421
6443
  };
6422
6444
  var playIncomingMessageSound = () => {
6423
6445
  if (typeof window === "undefined") return;
@@ -6550,7 +6572,7 @@ var UserMenuCupcode = ({
6550
6572
  panels,
6551
6573
  className
6552
6574
  }) => {
6553
- var _a65;
6575
+ var _a72;
6554
6576
  const [open, setOpen] = useState11(false);
6555
6577
  const [activeTab, setActiveTab] = useState11("profile");
6556
6578
  const [isLoggingOut, setIsLoggingOut] = useState11(false);
@@ -6652,12 +6674,12 @@ var UserMenuCupcode = ({
6652
6674
  );
6653
6675
  const normalizedNotificationFeed = useMemo7(
6654
6676
  () => resolvedNotificationFeed.map((notification) => {
6655
- var _a66;
6677
+ var _a73;
6656
6678
  const kind = normalizeNotificationKind(notification.kind);
6657
6679
  return {
6658
6680
  ...notification,
6659
6681
  kind,
6660
- topic: (_a66 = notification.topic) != null ? _a66 : NOTIFICATION_KIND_META[kind].topicFallback
6682
+ topic: (_a73 = notification.topic) != null ? _a73 : NOTIFICATION_KIND_META[kind].topicFallback
6661
6683
  };
6662
6684
  }),
6663
6685
  [resolvedNotificationFeed]
@@ -6692,10 +6714,10 @@ var UserMenuCupcode = ({
6692
6714
  const groupedNotifications = useMemo7(() => {
6693
6715
  const groups = /* @__PURE__ */ new Map();
6694
6716
  filteredNotifications.forEach((notification) => {
6695
- var _a66, _b5;
6717
+ var _a73, _b6;
6696
6718
  const kind = normalizeNotificationKind(notification.kind);
6697
- const key = notificationPreferences.grouping === "topic" ? (_a66 = notification.topic) != null ? _a66 : NOTIFICATION_KIND_META[kind].topicFallback : getNotificationDayKey(notification);
6698
- const current = (_b5 = groups.get(key)) != null ? _b5 : [];
6719
+ const key = notificationPreferences.grouping === "topic" ? (_a73 = notification.topic) != null ? _a73 : NOTIFICATION_KIND_META[kind].topicFallback : getNotificationDayKey(notification);
6720
+ const current = (_b6 = groups.get(key)) != null ? _b6 : [];
6699
6721
  current.push(notification);
6700
6722
  groups.set(key, current);
6701
6723
  });
@@ -6782,7 +6804,7 @@ var UserMenuCupcode = ({
6782
6804
  }).slice(0, 6);
6783
6805
  }, [recentActivity]);
6784
6806
  const isSendingChatMessage = isChatSending || isSendingInternalChatMessage;
6785
- const activeReactionPickerMessageId = (_a65 = activeReactionPicker == null ? void 0 : activeReactionPicker.messageId) != null ? _a65 : null;
6807
+ const activeReactionPickerMessageId = (_a72 = activeReactionPicker == null ? void 0 : activeReactionPicker.messageId) != null ? _a72 : null;
6786
6808
  const isChatSidebarOpen = isChatSidebarExpanded || isChatSidebarPinned;
6787
6809
  const hasTelescupAvatarSupport = Boolean(telescupBaseUrl && getTelescupAccessToken);
6788
6810
  const hasTelescupGroupAvatarSupport = hasTelescupAvatarSupport;
@@ -6796,8 +6818,8 @@ var UserMenuCupcode = ({
6796
6818
  meta.set(user.id, { lastMessage: null, lastTimestamp: 0, unreadCount: 0 });
6797
6819
  });
6798
6820
  resolvedAllChatMessages.forEach((message) => {
6799
- var _a66;
6800
- const current = (_a66 = meta.get(message.contactId)) != null ? _a66 : { lastMessage: null, lastTimestamp: 0, unreadCount: 0 };
6821
+ var _a73;
6822
+ const current = (_a73 = meta.get(message.contactId)) != null ? _a73 : { lastMessage: null, lastTimestamp: 0, unreadCount: 0 };
6801
6823
  const timestamp = getChatMessageTimestamp(message);
6802
6824
  if (timestamp >= current.lastTimestamp) {
6803
6825
  current.lastTimestamp = timestamp;
@@ -6817,11 +6839,11 @@ var UserMenuCupcode = ({
6817
6839
  return haystack.includes(query);
6818
6840
  });
6819
6841
  return filtered.sort((left, right) => {
6820
- var _a66, _b5, _c, _d;
6842
+ var _a73, _b6, _c, _d;
6821
6843
  const leftMeta = conversationMetaByUserId.get(left.id);
6822
6844
  const rightMeta = conversationMetaByUserId.get(right.id);
6823
- const leftUnread = (_a66 = leftMeta == null ? void 0 : leftMeta.unreadCount) != null ? _a66 : 0;
6824
- const rightUnread = (_b5 = rightMeta == null ? void 0 : rightMeta.unreadCount) != null ? _b5 : 0;
6845
+ const leftUnread = (_a73 = leftMeta == null ? void 0 : leftMeta.unreadCount) != null ? _a73 : 0;
6846
+ const rightUnread = (_b6 = rightMeta == null ? void 0 : rightMeta.unreadCount) != null ? _b6 : 0;
6825
6847
  if (leftUnread !== rightUnread) return rightUnread - leftUnread;
6826
6848
  const leftTimestamp = (_c = leftMeta == null ? void 0 : leftMeta.lastTimestamp) != null ? _c : 0;
6827
6849
  const rightTimestamp = (_d = rightMeta == null ? void 0 : rightMeta.lastTimestamp) != null ? _d : 0;
@@ -6870,11 +6892,11 @@ var UserMenuCupcode = ({
6870
6892
  let changed = false;
6871
6893
  const next = { ...current };
6872
6894
  normalizedNotificationFeed.forEach((notification) => {
6873
- var _a66;
6895
+ var _a73;
6874
6896
  if (normalizeNotificationKind(notification.kind) !== "chat") return;
6875
6897
  const contactId = notification.actionChatUserId;
6876
6898
  if (!contactId) return;
6877
- if (((_a66 = resolvedChatUnreadByUser[contactId]) != null ? _a66 : 0) > 0) return;
6899
+ if (((_a73 = resolvedChatUnreadByUser[contactId]) != null ? _a73 : 0) > 0) return;
6878
6900
  if (next[notification.id] === true) return;
6879
6901
  next[notification.id] = true;
6880
6902
  changed = true;
@@ -6888,11 +6910,11 @@ var UserMenuCupcode = ({
6888
6910
  const visibleChatUnreadCount = resolvedChatUnreadCount;
6889
6911
  const firstUnreadChatUserId = useMemo7(
6890
6912
  () => {
6891
- var _a66, _b5;
6892
- return (_b5 = (_a66 = filteredAndSortedChatUsers.find((user) => {
6893
- var _a67;
6894
- return ((_a67 = resolvedChatUnreadByUser[user.id]) != null ? _a67 : 0) > 0;
6895
- })) == null ? void 0 : _a66.id) != null ? _b5 : null;
6913
+ var _a73, _b6;
6914
+ return (_b6 = (_a73 = filteredAndSortedChatUsers.find((user) => {
6915
+ var _a74;
6916
+ return ((_a74 = resolvedChatUnreadByUser[user.id]) != null ? _a74 : 0) > 0;
6917
+ })) == null ? void 0 : _a73.id) != null ? _b6 : null;
6896
6918
  },
6897
6919
  [filteredAndSortedChatUsers, resolvedChatUnreadByUser]
6898
6920
  );
@@ -6951,11 +6973,11 @@ var UserMenuCupcode = ({
6951
6973
  );
6952
6974
  const openChatPanel = useCallback5(
6953
6975
  (contactId) => {
6954
- var _a66, _b5, _c, _d, _e;
6976
+ var _a73, _b6, _c, _d, _e;
6955
6977
  setIsLogoutConfirmOpen(false);
6956
6978
  setOpen(true);
6957
6979
  setActiveTab("chat");
6958
- 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 : "";
6980
+ 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 : "";
6959
6981
  if (!targetContactId) return;
6960
6982
  setActiveChatUserId(targetContactId);
6961
6983
  markConversationRead(targetContactId);
@@ -6989,9 +7011,9 @@ var UserMenuCupcode = ({
6989
7011
  const reactionsByMessageId = useMemo7(() => {
6990
7012
  const grouped = /* @__PURE__ */ new Map();
6991
7013
  resolvedAllChatReactions.forEach((reaction) => {
6992
- var _a66, _b5;
6993
- const byEmoji = (_a66 = grouped.get(reaction.messageId)) != null ? _a66 : /* @__PURE__ */ new Map();
6994
- const current = (_b5 = byEmoji.get(reaction.emoji)) != null ? _b5 : { emoji: reaction.emoji, count: 0, reactedByMe: false };
7014
+ var _a73, _b6;
7015
+ const byEmoji = (_a73 = grouped.get(reaction.messageId)) != null ? _a73 : /* @__PURE__ */ new Map();
7016
+ const current = (_b6 = byEmoji.get(reaction.emoji)) != null ? _b6 : { emoji: reaction.emoji, count: 0, reactedByMe: false };
6995
7017
  current.count += 1;
6996
7018
  if (resolvedCurrentChatUserId && reaction.userId === resolvedCurrentChatUserId) {
6997
7019
  current.reactedByMe = true;
@@ -7188,9 +7210,9 @@ var UserMenuCupcode = ({
7188
7210
  const wasFocusModeActive = wasFocusModeActiveRef.current;
7189
7211
  if (wasFocusModeActive && !isFocusModeActive && suppressedFocusNotifications.length) {
7190
7212
  const byType = suppressedFocusNotifications.reduce((acc, notification) => {
7191
- var _a66;
7213
+ var _a73;
7192
7214
  const kind = normalizeNotificationKind(notification.kind);
7193
- acc[kind] = ((_a66 = acc[kind]) != null ? _a66 : 0) + 1;
7215
+ acc[kind] = ((_a73 = acc[kind]) != null ? _a73 : 0) + 1;
7194
7216
  return acc;
7195
7217
  }, { system: 0, comment: 0, access: 0, billing: 0, chat: 0, security: 0 });
7196
7218
  const summaryParts = NOTIFICATION_KIND_ORDER.filter((kind) => byType[kind] > 0).map(
@@ -7220,9 +7242,9 @@ var UserMenuCupcode = ({
7220
7242
  return;
7221
7243
  }
7222
7244
  setActiveChatUserId((current) => {
7223
- var _a66, _b5;
7245
+ var _a73, _b6;
7224
7246
  if (current && chatUsersList.some((user) => user.id === current)) return current;
7225
- return (_b5 = (_a66 = filteredAndSortedChatUsers[0]) == null ? void 0 : _a66.id) != null ? _b5 : chatUsersList[0].id;
7247
+ return (_b6 = (_a73 = filteredAndSortedChatUsers[0]) == null ? void 0 : _a73.id) != null ? _b6 : chatUsersList[0].id;
7226
7248
  });
7227
7249
  }, [chatUsersList, filteredAndSortedChatUsers]);
7228
7250
  useEffect14(() => {
@@ -7264,7 +7286,7 @@ var UserMenuCupcode = ({
7264
7286
  };
7265
7287
  }, [activeReactionPickerMessageId]);
7266
7288
  useEffect14(() => {
7267
- var _a66;
7289
+ var _a73;
7268
7290
  if (!hasBootstrappedIncomingMessagesRef.current && isChatLoading) return;
7269
7291
  const knownIncomingIds = seenIncomingMessageIdsRef.current;
7270
7292
  const incomingMessages = resolvedAllChatMessages.filter((message) => message.sender === "them" && !message.readAt);
@@ -7286,14 +7308,14 @@ var UserMenuCupcode = ({
7286
7308
  return;
7287
7309
  }
7288
7310
  const generatedNotifications = relevantIncomingMessages.map((message) => {
7289
- var _a67, _b5, _c;
7311
+ var _a74, _b6, _c;
7290
7312
  const contact = chatUsersList.find((user) => user.id === message.contactId);
7291
- const createdAt = (_a67 = message.createdAt) != null ? _a67 : (/* @__PURE__ */ new Date()).toISOString();
7313
+ const createdAt = (_a74 = message.createdAt) != null ? _a74 : (/* @__PURE__ */ new Date()).toISOString();
7292
7314
  const previewText = chatSettings.showMessagePreview ? summarizeChatText(message.text, 100) : "Nova mensagem no chat.";
7293
7315
  return {
7294
7316
  id: `chat-notification-${message.id}`,
7295
7317
  kind: "chat",
7296
- title: `Mensagem de ${(_b5 = contact == null ? void 0 : contact.name) != null ? _b5 : "usu\xE1rio"}`,
7318
+ title: `Mensagem de ${(_b6 = contact == null ? void 0 : contact.name) != null ? _b6 : "usu\xE1rio"}`,
7297
7319
  description: previewText,
7298
7320
  createdAt,
7299
7321
  timeLabel: formatChatTime({ ...message, createdAt }),
@@ -7310,7 +7332,7 @@ var UserMenuCupcode = ({
7310
7332
  )[0];
7311
7333
  if (latestRelevantMessage) {
7312
7334
  const latestContact = chatUsersList.find((user) => user.id === latestRelevantMessage.contactId);
7313
- const senderName = (_a66 = latestContact == null ? void 0 : latestContact.name) != null ? _a66 : "usu\xE1rio";
7335
+ const senderName = (_a73 = latestContact == null ? void 0 : latestContact.name) != null ? _a73 : "usu\xE1rio";
7314
7336
  const latestPreview = chatSettings.showMessagePreview ? summarizeChatText(latestRelevantMessage.text, 96) : "Nova mensagem";
7315
7337
  const messageCount = relevantIncomingMessages.length;
7316
7338
  const messageCountLabel = messageCount > 99 ? "99+" : String(messageCount);
@@ -7359,10 +7381,10 @@ var UserMenuCupcode = ({
7359
7381
  return;
7360
7382
  }
7361
7383
  generatedNotifications.forEach((chatNotification) => {
7362
- var _a67;
7384
+ var _a74;
7363
7385
  const notification = new Notification(chatNotification.title, {
7364
7386
  body: chatSettings.showMessagePreview ? chatNotification.description : "Voc\xEA recebeu uma nova mensagem.",
7365
- tag: `cc-chat-${(_a67 = chatNotification.actionChatUserId) != null ? _a67 : chatNotification.id}`
7387
+ tag: `cc-chat-${(_a74 = chatNotification.actionChatUserId) != null ? _a74 : chatNotification.id}`
7366
7388
  });
7367
7389
  notification.onclick = () => {
7368
7390
  window.focus();
@@ -7389,14 +7411,14 @@ var UserMenuCupcode = ({
7389
7411
  ]);
7390
7412
  const activeChatUser = useMemo7(
7391
7413
  () => {
7392
- var _a66;
7393
- return (_a66 = chatUsersList.find((user) => user.id === activeChatUserId)) != null ? _a66 : null;
7414
+ var _a73;
7415
+ return (_a73 = chatUsersList.find((user) => user.id === activeChatUserId)) != null ? _a73 : null;
7394
7416
  },
7395
7417
  [activeChatUserId, chatUsersList]
7396
7418
  );
7397
7419
  const activeGroupMembers = useMemo7(() => {
7398
- var _a66;
7399
- if (!(activeChatUser == null ? void 0 : activeChatUser.isGroup) || !((_a66 = activeChatUser.memberIds) == null ? void 0 : _a66.length)) return [];
7420
+ var _a73;
7421
+ if (!(activeChatUser == null ? void 0 : activeChatUser.isGroup) || !((_a73 = activeChatUser.memberIds) == null ? void 0 : _a73.length)) return [];
7400
7422
  const members = activeChatUser.memberIds.map((memberId) => baseChatUsersList.find((user) => user.id === memberId)).filter((member) => Boolean(member));
7401
7423
  return members;
7402
7424
  }, [activeChatUser, baseChatUsersList]);
@@ -7435,8 +7457,8 @@ var UserMenuCupcode = ({
7435
7457
  return items;
7436
7458
  }, [activeChatMessages]);
7437
7459
  useEffect14(() => {
7438
- var _a66;
7439
- const conversationId = (_a66 = activeChatUser == null ? void 0 : activeChatUser.id) != null ? _a66 : null;
7460
+ var _a73;
7461
+ const conversationId = (_a73 = activeChatUser == null ? void 0 : activeChatUser.id) != null ? _a73 : null;
7440
7462
  if (!conversationId) {
7441
7463
  activeConversationIdRef.current = null;
7442
7464
  activeConversationMessageIdsRef.current = /* @__PURE__ */ new Set();
@@ -7489,9 +7511,9 @@ var UserMenuCupcode = ({
7489
7511
  });
7490
7512
  }, [activeChatUser, resolvedChatLogs]);
7491
7513
  const replyToMessage = useMemo7(() => {
7492
- var _a66;
7514
+ var _a73;
7493
7515
  if (!replyToMessageId) return null;
7494
- return (_a66 = activeChatMessagesMap.get(replyToMessageId)) != null ? _a66 : null;
7516
+ return (_a73 = activeChatMessagesMap.get(replyToMessageId)) != null ? _a73 : null;
7495
7517
  }, [activeChatMessagesMap, replyToMessageId]);
7496
7518
  useEffect14(() => {
7497
7519
  if (!replyToMessageId) return;
@@ -7518,9 +7540,9 @@ var UserMenuCupcode = ({
7518
7540
  }
7519
7541
  }, [activeChatUser]);
7520
7542
  useEffect14(() => {
7521
- var _a66;
7543
+ var _a73;
7522
7544
  if (!open || activeTab !== "chat" || !activeChatUser || activeChatUser.isGroup) return;
7523
- const unreadCount = (_a66 = resolvedChatUnreadByUser[activeChatUser.id]) != null ? _a66 : 0;
7545
+ const unreadCount = (_a73 = resolvedChatUnreadByUser[activeChatUser.id]) != null ? _a73 : 0;
7524
7546
  if (unreadCount <= 0) return;
7525
7547
  const contactId = activeChatUser.id;
7526
7548
  if (pendingReadRequestsRef.current.has(contactId)) return;
@@ -7596,13 +7618,13 @@ var UserMenuCupcode = ({
7596
7618
  openAccountsPath("/security#sessions");
7597
7619
  };
7598
7620
  const runOpenIntegrations = (provider) => {
7599
- var _a66;
7621
+ var _a73;
7600
7622
  if (!provider) {
7601
7623
  openAccountsPath("/integrations");
7602
7624
  return;
7603
7625
  }
7604
7626
  const option = INTEGRATION_OPTIONS.find((integration) => integration.id === provider);
7605
- openAccountsPath((_a66 = option == null ? void 0 : option.accountPath) != null ? _a66 : "/integrations");
7627
+ openAccountsPath((_a73 = option == null ? void 0 : option.accountPath) != null ? _a73 : "/integrations");
7606
7628
  };
7607
7629
  const changeStatus = (nextStatus) => {
7608
7630
  if (nextStatus === "offline") return;
@@ -7611,6 +7633,18 @@ var UserMenuCupcode = ({
7611
7633
  }
7612
7634
  void (onStatusChange == null ? void 0 : onStatusChange(nextStatus));
7613
7635
  };
7636
+ const renderPresenceStatusOptions = () => {
7637
+ return PRESENCE_OPTIONS.map((option) => {
7638
+ const isCurrent = option === currentStatus;
7639
+ return /* @__PURE__ */ jsx42(DropdownMenuItem, { onSelect: () => changeStatus(option), className: "text-xs", children: /* @__PURE__ */ jsxs27("span", { className: "flex w-full items-center justify-between gap-2", children: [
7640
+ /* @__PURE__ */ jsxs27("span", { className: "flex items-center gap-2", children: [
7641
+ /* @__PURE__ */ jsx42(PresenceBadge, { status: option, size: "md" }),
7642
+ /* @__PURE__ */ jsx42("span", { children: PRESENCE_META[option].label })
7643
+ ] }),
7644
+ isCurrent ? /* @__PURE__ */ jsx42(Check3, { className: "h-3.5 w-3.5 text-primary" }) : null
7645
+ ] }) }, option);
7646
+ });
7647
+ };
7614
7648
  const markNotificationAsRead = (notificationId) => {
7615
7649
  if (!notificationId) return;
7616
7650
  setNotificationReadMap((current) => ({
@@ -7957,10 +7991,10 @@ var UserMenuCupcode = ({
7957
7991
  };
7958
7992
  const handleProfileAvatarChange = useCallback5(
7959
7993
  async (ids, assets) => {
7960
- var _a66, _b5, _c;
7994
+ var _a73, _b6, _c;
7961
7995
  const selectedAsset = assets == null ? void 0 : assets[0];
7962
- const selectedIdRaw = (_a66 = ids[0]) == null ? void 0 : _a66.trim();
7963
- const selectedId = (_c = (_b5 = parseAssetId(selectedIdRaw)) != null ? _b5 : parseAssetId(selectedAsset == null ? void 0 : selectedAsset.id)) != null ? _c : parseAssetId(selectedAsset == null ? void 0 : selectedAsset.url);
7996
+ const selectedIdRaw = (_a73 = ids[0]) == null ? void 0 : _a73.trim();
7997
+ const selectedId = (_c = (_b6 = parseAssetId(selectedIdRaw)) != null ? _b6 : parseAssetId(selectedAsset == null ? void 0 : selectedAsset.id)) != null ? _c : parseAssetId(selectedAsset == null ? void 0 : selectedAsset.url);
7964
7998
  if (!selectedId) {
7965
7999
  toast({
7966
8000
  title: "Imagem inv\xE1lida",
@@ -8002,7 +8036,7 @@ var UserMenuCupcode = ({
8002
8036
  [isProfileAvatarSaving, onProfileAvatarChange, resolvedProfileAvatarUrl]
8003
8037
  );
8004
8038
  const sendChatMessage = async () => {
8005
- var _a66, _b5;
8039
+ var _a73, _b6;
8006
8040
  if (!activeChatUser) return;
8007
8041
  const text = chatDraft.trim();
8008
8042
  if (!text || isSendingChatMessage) return;
@@ -8014,7 +8048,7 @@ var UserMenuCupcode = ({
8014
8048
  await onChatSendMessage({
8015
8049
  recipientId: activeChatUser.id,
8016
8050
  text,
8017
- replyToMessageId: (_a66 = replyToMessage == null ? void 0 : replyToMessage.id) != null ? _a66 : null
8051
+ replyToMessageId: (_a73 = replyToMessage == null ? void 0 : replyToMessage.id) != null ? _a73 : null
8018
8052
  });
8019
8053
  setChatDraft("");
8020
8054
  setShowEmojiPicker(false);
@@ -8041,7 +8075,7 @@ var UserMenuCupcode = ({
8041
8075
  timeLabel,
8042
8076
  createdAt,
8043
8077
  readAt: null,
8044
- replyToMessageId: (_b5 = replyToMessage == null ? void 0 : replyToMessage.id) != null ? _b5 : null
8078
+ replyToMessageId: (_b6 = replyToMessage == null ? void 0 : replyToMessage.id) != null ? _b6 : null
8045
8079
  };
8046
8080
  if (isLocalGroupConversation) {
8047
8081
  setInternalGroupMessages((current) => [...current, message]);
@@ -8056,7 +8090,7 @@ var UserMenuCupcode = ({
8056
8090
  });
8057
8091
  };
8058
8092
  const renderDefaultPanel = () => {
8059
- var _a66, _b5, _c, _d;
8093
+ var _a73, _b6, _c, _d;
8060
8094
  if (activeTab === "profile") {
8061
8095
  return /* @__PURE__ */ jsxs27("div", { className: "space-y-4", children: [
8062
8096
  /* @__PURE__ */ jsxs27("div", { className: "pt-1 text-center", children: [
@@ -8066,7 +8100,7 @@ var UserMenuCupcode = ({
8066
8100
  {
8067
8101
  type: "button",
8068
8102
  onClick: () => setIsProfileImageDialogOpen(true),
8069
- 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)]",
8103
+ 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)]",
8070
8104
  "aria-label": "Abrir foto de perfil",
8071
8105
  title: "Abrir foto de perfil",
8072
8106
  children: /* @__PURE__ */ jsxs27(Avatar2, { className: "h-20 w-20 border border-border/70 shadow-[var(--elevation-2)]", children: [
@@ -8080,22 +8114,13 @@ var UserMenuCupcode = ({
8080
8114
  "button",
8081
8115
  {
8082
8116
  type: "button",
8083
- 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",
8117
+ 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",
8084
8118
  "aria-label": "Alterar status",
8085
8119
  title: "Alterar status",
8086
8120
  children: /* @__PURE__ */ jsx42(PresenceBadge, { status: currentStatus, size: "lg" })
8087
8121
  }
8088
8122
  ) }),
8089
- /* @__PURE__ */ jsx42(DropdownMenuContent, { align: "end", sideOffset: 8, className: "z-[1800] w-44", children: PRESENCE_OPTIONS.map((option) => {
8090
- const isCurrent = option === currentStatus;
8091
- return /* @__PURE__ */ jsx42(DropdownMenuItem, { onSelect: () => changeStatus(option), className: "text-xs", children: /* @__PURE__ */ jsxs27("span", { className: "flex w-full items-center justify-between gap-2", children: [
8092
- /* @__PURE__ */ jsxs27("span", { className: "flex items-center gap-2", children: [
8093
- /* @__PURE__ */ jsx42(PresenceBadge, { status: option, size: "md" }),
8094
- /* @__PURE__ */ jsx42("span", { children: PRESENCE_META[option].label })
8095
- ] }),
8096
- isCurrent ? /* @__PURE__ */ jsx42(Check3, { className: "h-3.5 w-3.5 text-primary" }) : null
8097
- ] }) }, option);
8098
- }) })
8123
+ /* @__PURE__ */ jsx42(DropdownMenuContent, { align: "end", sideOffset: 8, className: "z-[1800] w-44", children: renderPresenceStatusOptions() })
8099
8124
  ] })
8100
8125
  ] }),
8101
8126
  /* @__PURE__ */ jsx42("h3", { className: "mt-3 text-xl font-bold leading-tight text-foreground", children: resolvedName }),
@@ -8336,7 +8361,7 @@ var UserMenuCupcode = ({
8336
8361
  visibleGroupedNotifications.length ? visibleGroupedNotifications.map((group) => /* @__PURE__ */ jsxs27("section", { className: "space-y-1.5", children: [
8337
8362
  /* @__PURE__ */ jsx42("p", { className: "px-0.5 text-[11px] font-semibold uppercase tracking-[0.08em] text-muted-foreground", children: group.label }),
8338
8363
  /* @__PURE__ */ jsx42("div", { className: "space-y-1.5", children: group.items.map((notification) => {
8339
- var _a67;
8364
+ var _a74;
8340
8365
  const kind = normalizeNotificationKind(notification.kind);
8341
8366
  const meta = NOTIFICATION_KIND_META[kind];
8342
8367
  const Icon3 = meta.icon;
@@ -8365,7 +8390,7 @@ var UserMenuCupcode = ({
8365
8390
  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",
8366
8391
  children: [
8367
8392
  /* @__PURE__ */ jsx42(ExternalLink, { className: "h-3 w-3" }),
8368
- (_a67 = notification.actionLabel) != null ? _a67 : "Abrir"
8393
+ (_a74 = notification.actionLabel) != null ? _a74 : "Abrir"
8369
8394
  ]
8370
8395
  }
8371
8396
  ),
@@ -8593,7 +8618,7 @@ var UserMenuCupcode = ({
8593
8618
  }
8594
8619
  if (activeTab === "chat") {
8595
8620
  const canSendChatMessage = Boolean(activeChatUser) && chatDraft.trim() !== "" && !isSendingChatMessage && !isChatLoading;
8596
- const activeConversationUnreadCount = activeChatUser ? (_a66 = resolvedChatUnreadByUser[activeChatUser.id]) != null ? _a66 : 0 : 0;
8621
+ const activeConversationUnreadCount = activeChatUser ? (_a73 = resolvedChatUnreadByUser[activeChatUser.id]) != null ? _a73 : 0 : 0;
8597
8622
  return /* @__PURE__ */ jsx42("div", { className: "h-full", children: /* @__PURE__ */ jsxs27(
8598
8623
  "div",
8599
8624
  {
@@ -8672,12 +8697,12 @@ var UserMenuCupcode = ({
8672
8697
  }
8673
8698
  ),
8674
8699
  /* @__PURE__ */ jsx42("div", { className: "space-y-1", children: users.map((user) => {
8675
- var _a67, _b6, _c2;
8700
+ var _a74, _b7, _c2;
8676
8701
  const userInitials = buildInitials(user.name, user.username);
8677
8702
  const isCurrent = user.id === activeChatUserId;
8678
- const unreadCount = (_a67 = resolvedChatUnreadByUser[user.id]) != null ? _a67 : 0;
8703
+ const unreadCount = (_a74 = resolvedChatUnreadByUser[user.id]) != null ? _a74 : 0;
8679
8704
  const hasUnread = unreadCount > 0;
8680
- const lastMessage = (_b6 = conversationMetaByUserId.get(user.id)) == null ? void 0 : _b6.lastMessage;
8705
+ const lastMessage = (_b7 = conversationMetaByUserId.get(user.id)) == null ? void 0 : _b7.lastMessage;
8681
8706
  return /* @__PURE__ */ jsxs27(
8682
8707
  "button",
8683
8708
  {
@@ -8892,13 +8917,13 @@ var UserMenuCupcode = ({
8892
8917
  className: "cc-scrollbar cc-scrollbar-pink relative flex-1 space-y-2 overflow-y-auto px-3 py-2.5",
8893
8918
  children: [
8894
8919
  isChatLoading ? /* @__PURE__ */ jsx42("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) => {
8895
- var _a67, _b6;
8920
+ var _a74, _b7;
8896
8921
  if (item.type === "day") {
8897
8922
  return /* @__PURE__ */ jsx42("div", { className: "flex justify-center py-1", children: /* @__PURE__ */ jsx42("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);
8898
8923
  }
8899
8924
  const { message } = item;
8900
- const replyMessage = message.replyToMessageId ? (_a67 = activeChatMessagesMap.get(message.replyToMessageId)) != null ? _a67 : null : null;
8901
- const reactions = (_b6 = reactionsByMessageId.get(message.id)) != null ? _b6 : [];
8925
+ const replyMessage = message.replyToMessageId ? (_a74 = activeChatMessagesMap.get(message.replyToMessageId)) != null ? _a74 : null : null;
8926
+ const reactions = (_b7 = reactionsByMessageId.get(message.id)) != null ? _b7 : [];
8902
8927
  const hasReadReceipt = Boolean(message.readAt);
8903
8928
  const isEditing = editingMessageId === message.id;
8904
8929
  const canEditOrDelete = message.sender === "me";
@@ -9071,7 +9096,7 @@ var UserMenuCupcode = ({
9071
9096
  "div",
9072
9097
  {
9073
9098
  ref: reactionPickerRef,
9074
- 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` },
9099
+ 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` },
9075
9100
  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)]",
9076
9101
  children: MESSAGE_REACTION_OPTIONS.map((emoji) => /* @__PURE__ */ jsx42(
9077
9102
  "button",
@@ -9227,8 +9252,8 @@ var UserMenuCupcode = ({
9227
9252
  ] })
9228
9253
  ] }),
9229
9254
  isChatSuperAdmin ? activeConversationLogs.length ? /* @__PURE__ */ jsx42("div", { className: "space-y-2", children: activeConversationLogs.map((entry) => {
9230
- var _a67;
9231
- const actorName = entry.actorId && entry.actorId === resolvedCurrentChatUserId ? "Voc\xEA" : (_a67 = entry.actorId) != null ? _a67 : "Usu\xE1rio";
9255
+ var _a74;
9256
+ const actorName = entry.actorId && entry.actorId === resolvedCurrentChatUserId ? "Voc\xEA" : (_a74 = entry.actorId) != null ? _a74 : "Usu\xE1rio";
9232
9257
  return /* @__PURE__ */ jsxs27(
9233
9258
  "article",
9234
9259
  {
@@ -9825,7 +9850,7 @@ var UserMenuCupcode = ({
9825
9850
  }
9826
9851
  },
9827
9852
  children: [
9828
- /* @__PURE__ */ jsxs27("div", { className: cn("relative inline-flex items-center gap-2", className), children: [
9853
+ /* @__PURE__ */ jsxs27("div", { className: cn("relative inline-flex items-center", className), children: [
9829
9854
  isChatIndicatorMounted ? /* @__PURE__ */ jsx42(TooltipProvider, { delayDuration: 100, children: /* @__PURE__ */ jsxs27(Tooltip, { children: [
9830
9855
  /* @__PURE__ */ jsx42(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxs27(
9831
9856
  "button",
@@ -9878,21 +9903,33 @@ var UserMenuCupcode = ({
9878
9903
  ")"
9879
9904
  ] })
9880
9905
  ] }) }) : null,
9881
- /* @__PURE__ */ jsx42(DialogPrimitive3.Trigger, { asChild: true, children: /* @__PURE__ */ jsxs27(
9882
- "button",
9883
- {
9884
- type: "button",
9885
- 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)]",
9886
- "aria-label": "Abrir menu do usu\xE1rio",
9887
- children: [
9888
- /* @__PURE__ */ jsxs27(Avatar2, { className: "h-full w-full border-none", children: [
9906
+ /* @__PURE__ */ jsxs27("div", { className: "relative", children: [
9907
+ /* @__PURE__ */ jsx42(DialogPrimitive3.Trigger, { asChild: true, children: /* @__PURE__ */ jsx42(
9908
+ "button",
9909
+ {
9910
+ type: "button",
9911
+ 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)]",
9912
+ "aria-label": "Abrir menu do usu\xE1rio",
9913
+ children: /* @__PURE__ */ jsxs27(Avatar2, { className: "h-full w-full border-none", children: [
9889
9914
  /* @__PURE__ */ jsx42(AvatarImage2, { src: resolvedProfileAvatarUrl, alt: resolvedName }),
9890
9915
  /* @__PURE__ */ jsx42(AvatarFallback2, { className: "bg-muted text-sm font-semibold text-foreground", children: initials })
9891
- ] }),
9892
- /* @__PURE__ */ jsx42("span", { className: "absolute -bottom-0.5 -right-0.5", children: /* @__PURE__ */ jsx42(PresenceBadge, { status: currentStatus }) })
9893
- ]
9894
- }
9895
- ) })
9916
+ ] })
9917
+ }
9918
+ ) }),
9919
+ /* @__PURE__ */ jsxs27(DropdownMenu, { children: [
9920
+ /* @__PURE__ */ jsx42(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsx42(
9921
+ "button",
9922
+ {
9923
+ type: "button",
9924
+ 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",
9925
+ "aria-label": "Alterar status",
9926
+ title: `Status: ${PRESENCE_META[currentStatus].label}`,
9927
+ children: /* @__PURE__ */ jsx42(PresenceBadge, { status: currentStatus, size: "md" })
9928
+ }
9929
+ ) }),
9930
+ /* @__PURE__ */ jsx42(DropdownMenuContent, { align: "end", sideOffset: 8, className: "z-[1800] w-44", children: renderPresenceStatusOptions() })
9931
+ ] })
9932
+ ] })
9896
9933
  ] }),
9897
9934
  /* @__PURE__ */ jsxs27(DialogPrimitive3.Portal, { children: [
9898
9935
  /* @__PURE__ */ jsx42(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" }),
@@ -10169,7 +10206,7 @@ var FunctionsClient = class {
10169
10206
  */
10170
10207
  invoke(functionName_1) {
10171
10208
  return __awaiter(this, arguments, void 0, function* (functionName, options = {}) {
10172
- var _a65;
10209
+ var _a72;
10173
10210
  let timeoutId;
10174
10211
  let timeoutController;
10175
10212
  try {
@@ -10235,7 +10272,7 @@ var FunctionsClient = class {
10235
10272
  if (!response.ok) {
10236
10273
  throw new FunctionsHttpError(response);
10237
10274
  }
10238
- let responseType = ((_a65 = response.headers.get("Content-Type")) !== null && _a65 !== void 0 ? _a65 : "text/plain").split(";")[0].trim();
10275
+ let responseType = ((_a72 = response.headers.get("Content-Type")) !== null && _a72 !== void 0 ? _a72 : "text/plain").split(";")[0].trim();
10239
10276
  let data;
10240
10277
  if (responseType === "application/json") {
10241
10278
  data = yield response.json();
@@ -11481,7 +11518,7 @@ var WebSocketFactory = class {
11481
11518
  constructor() {
11482
11519
  }
11483
11520
  static detectEnvironment() {
11484
- var _a65;
11521
+ var _a72;
11485
11522
  if (typeof WebSocket !== "undefined") {
11486
11523
  return { type: "native", constructor: WebSocket };
11487
11524
  }
@@ -11498,7 +11535,7 @@ var WebSocketFactory = class {
11498
11535
  workaround: "Use Cloudflare Workers WebSocket API for server-side WebSocket handling, or deploy to a different runtime."
11499
11536
  };
11500
11537
  }
11501
- if (typeof globalThis !== "undefined" && globalThis.EdgeRuntime || typeof navigator !== "undefined" && ((_a65 = navigator.userAgent) === null || _a65 === void 0 ? void 0 : _a65.includes("Vercel-Edge"))) {
11538
+ if (typeof globalThis !== "undefined" && globalThis.EdgeRuntime || typeof navigator !== "undefined" && ((_a72 = navigator.userAgent) === null || _a72 === void 0 ? void 0 : _a72.includes("Vercel-Edge"))) {
11502
11539
  return {
11503
11540
  type: "unsupported",
11504
11541
  error: "Edge runtime detected (Vercel Edge/Netlify Edge). WebSockets are not supported in edge functions.",
@@ -11582,7 +11619,7 @@ Suggested solution: ${env.workaround}`;
11582
11619
  try {
11583
11620
  const env = this.detectEnvironment();
11584
11621
  return env.type === "native" || env.type === "ws";
11585
- } catch (_a65) {
11622
+ } catch (_a72) {
11586
11623
  return false;
11587
11624
  }
11588
11625
  }
@@ -11656,30 +11693,30 @@ var Serializer = class {
11656
11693
  return callback(JSON.stringify(payload));
11657
11694
  }
11658
11695
  _binaryEncodeUserBroadcastPush(message) {
11659
- var _a65;
11660
- if (this._isArrayBuffer((_a65 = message.payload) === null || _a65 === void 0 ? void 0 : _a65.payload)) {
11696
+ var _a72;
11697
+ if (this._isArrayBuffer((_a72 = message.payload) === null || _a72 === void 0 ? void 0 : _a72.payload)) {
11661
11698
  return this._encodeBinaryUserBroadcastPush(message);
11662
11699
  } else {
11663
11700
  return this._encodeJsonUserBroadcastPush(message);
11664
11701
  }
11665
11702
  }
11666
11703
  _encodeBinaryUserBroadcastPush(message) {
11667
- var _a65, _b5;
11668
- const userPayload = (_b5 = (_a65 = message.payload) === null || _a65 === void 0 ? void 0 : _a65.payload) !== null && _b5 !== void 0 ? _b5 : new ArrayBuffer(0);
11704
+ var _a72, _b6;
11705
+ const userPayload = (_b6 = (_a72 = message.payload) === null || _a72 === void 0 ? void 0 : _a72.payload) !== null && _b6 !== void 0 ? _b6 : new ArrayBuffer(0);
11669
11706
  return this._encodeUserBroadcastPush(message, this.BINARY_ENCODING, userPayload);
11670
11707
  }
11671
11708
  _encodeJsonUserBroadcastPush(message) {
11672
- var _a65, _b5;
11673
- const userPayload = (_b5 = (_a65 = message.payload) === null || _a65 === void 0 ? void 0 : _a65.payload) !== null && _b5 !== void 0 ? _b5 : {};
11709
+ var _a72, _b6;
11710
+ const userPayload = (_b6 = (_a72 = message.payload) === null || _a72 === void 0 ? void 0 : _a72.payload) !== null && _b6 !== void 0 ? _b6 : {};
11674
11711
  const encoder = new TextEncoder();
11675
11712
  const encodedUserPayload = encoder.encode(JSON.stringify(userPayload)).buffer;
11676
11713
  return this._encodeUserBroadcastPush(message, this.JSON_ENCODING, encodedUserPayload);
11677
11714
  }
11678
11715
  _encodeUserBroadcastPush(message, encodingType, encodedPayload) {
11679
- var _a65, _b5;
11716
+ var _a72, _b6;
11680
11717
  const topic = message.topic;
11681
- const ref = (_a65 = message.ref) !== null && _a65 !== void 0 ? _a65 : "";
11682
- const joinRef = (_b5 = message.join_ref) !== null && _b5 !== void 0 ? _b5 : "";
11718
+ const ref = (_a72 = message.ref) !== null && _a72 !== void 0 ? _a72 : "";
11719
+ const joinRef = (_b6 = message.join_ref) !== null && _b6 !== void 0 ? _b6 : "";
11683
11720
  const userEvent = message.payload.event;
11684
11721
  const rest = this.allowedMetadataKeys ? this._pick(message.payload, this.allowedMetadataKeys) : {};
11685
11722
  const metadata = Object.keys(rest).length === 0 ? "" : JSON.stringify(rest);
@@ -11765,8 +11802,8 @@ var Serializer = class {
11765
11802
  return { join_ref: null, ref: null, topic, event: this.BROADCAST_EVENT, payload: data };
11766
11803
  }
11767
11804
  _isArrayBuffer(buffer) {
11768
- var _a65;
11769
- return buffer instanceof ArrayBuffer || ((_a65 = buffer === null || buffer === void 0 ? void 0 : buffer.constructor) === null || _a65 === void 0 ? void 0 : _a65.name) === "ArrayBuffer";
11805
+ var _a72;
11806
+ return buffer instanceof ArrayBuffer || ((_a72 = buffer === null || buffer === void 0 ? void 0 : buffer.constructor) === null || _a72 === void 0 ? void 0 : _a72.name) === "ArrayBuffer";
11770
11807
  }
11771
11808
  _pick(obj, keys) {
11772
11809
  if (!obj || typeof obj !== "object") {
@@ -11830,8 +11867,8 @@ var PostgresTypes;
11830
11867
  PostgresTypes2["tstzrange"] = "tstzrange";
11831
11868
  })(PostgresTypes || (PostgresTypes = {}));
11832
11869
  var convertChangeData = (columns, record, options = {}) => {
11833
- var _a65;
11834
- const skipTypes = (_a65 = options.skipTypes) !== null && _a65 !== void 0 ? _a65 : [];
11870
+ var _a72;
11871
+ const skipTypes = (_a72 = options.skipTypes) !== null && _a72 !== void 0 ? _a72 : [];
11835
11872
  if (!record) {
11836
11873
  return {};
11837
11874
  }
@@ -11921,7 +11958,7 @@ var toJson = (value) => {
11921
11958
  if (typeof value === "string") {
11922
11959
  try {
11923
11960
  return JSON.parse(value);
11924
- } catch (_a65) {
11961
+ } catch (_a72) {
11925
11962
  return value;
11926
11963
  }
11927
11964
  }
@@ -12013,9 +12050,9 @@ var Push = class {
12013
12050
  this.payload = Object.assign(Object.assign({}, this.payload), payload);
12014
12051
  }
12015
12052
  receive(status, callback) {
12016
- var _a65;
12053
+ var _a72;
12017
12054
  if (this._hasReceived(status)) {
12018
- callback((_a65 = this.receivedResp) === null || _a65 === void 0 ? void 0 : _a65.response);
12055
+ callback((_a72 = this.receivedResp) === null || _a72 === void 0 ? void 0 : _a72.response);
12019
12056
  }
12020
12057
  this.recHooks.push({ status, callback });
12021
12058
  return this;
@@ -12206,8 +12243,8 @@ var RealtimePresence = class _RealtimePresence {
12206
12243
  };
12207
12244
  }
12208
12245
  this.map(joins, (key, newPresences) => {
12209
- var _a65;
12210
- const currentPresences = (_a65 = state[key]) !== null && _a65 !== void 0 ? _a65 : [];
12246
+ var _a72;
12247
+ const currentPresences = (_a72 = state[key]) !== null && _a72 !== void 0 ? _a72 : [];
12211
12248
  state[key] = this.cloneDeep(newPresences);
12212
12249
  if (currentPresences.length > 0) {
12213
12250
  const joinedPresenceRefs = state[key].map((m) => m.presence_ref);
@@ -12335,7 +12372,7 @@ var RealtimeChannel = class _RealtimeChannel {
12335
12372
  * ```
12336
12373
  */
12337
12374
  constructor(topic, params = { config: {} }, socket) {
12338
- var _a65, _b5;
12375
+ var _a72, _b6;
12339
12376
  this.topic = topic;
12340
12377
  this.params = params;
12341
12378
  this.socket = socket;
@@ -12394,19 +12431,19 @@ var RealtimeChannel = class _RealtimeChannel {
12394
12431
  this.presence = new RealtimePresence(this);
12395
12432
  this.broadcastEndpointURL = httpEndpointURL(this.socket.endPoint);
12396
12433
  this.private = this.params.config.private || false;
12397
- if (!this.private && ((_b5 = (_a65 = this.params.config) === null || _a65 === void 0 ? void 0 : _a65.broadcast) === null || _b5 === void 0 ? void 0 : _b5.replay)) {
12434
+ if (!this.private && ((_b6 = (_a72 = this.params.config) === null || _a72 === void 0 ? void 0 : _a72.broadcast) === null || _b6 === void 0 ? void 0 : _b6.replay)) {
12398
12435
  throw `tried to use replay on public channel '${this.topic}'. It must be a private channel.`;
12399
12436
  }
12400
12437
  }
12401
12438
  /** Subscribe registers your client with the server */
12402
12439
  subscribe(callback, timeout = this.timeout) {
12403
- var _a65, _b5, _c;
12440
+ var _a72, _b6, _c;
12404
12441
  if (!this.socket.isConnected()) {
12405
12442
  this.socket.connect();
12406
12443
  }
12407
12444
  if (this.state == CHANNEL_STATES.closed) {
12408
12445
  const { config: { broadcast, presence, private: isPrivate } } = this.params;
12409
- 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 : [];
12446
+ 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 : [];
12410
12447
  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;
12411
12448
  const accessTokenPayload = {};
12412
12449
  const config = {
@@ -12424,7 +12461,7 @@ var RealtimeChannel = class _RealtimeChannel {
12424
12461
  this.joinedOnce = true;
12425
12462
  this._rejoin(timeout);
12426
12463
  this.joinPush.receive("ok", async ({ postgres_changes: postgres_changes2 }) => {
12427
- var _a66;
12464
+ var _a73;
12428
12465
  if (!this.socket._isManualToken()) {
12429
12466
  this.socket.setAuth();
12430
12467
  }
@@ -12433,7 +12470,7 @@ var RealtimeChannel = class _RealtimeChannel {
12433
12470
  return;
12434
12471
  } else {
12435
12472
  const clientPostgresBindings = this.bindings.postgres_changes;
12436
- const bindingsLen = (_a66 = clientPostgresBindings === null || clientPostgresBindings === void 0 ? void 0 : clientPostgresBindings.length) !== null && _a66 !== void 0 ? _a66 : 0;
12473
+ const bindingsLen = (_a73 = clientPostgresBindings === null || clientPostgresBindings === void 0 ? void 0 : clientPostgresBindings.length) !== null && _a73 !== void 0 ? _a73 : 0;
12437
12474
  const newPostgresBindings = [];
12438
12475
  for (let i = 0; i < bindingsLen; i++) {
12439
12476
  const clientPostgresBinding = clientPostgresBindings[i];
@@ -12511,7 +12548,7 @@ var RealtimeChannel = class _RealtimeChannel {
12511
12548
  * @returns Promise resolving to object with success status, and error details if failed
12512
12549
  */
12513
12550
  async httpSend(event, payload, opts = {}) {
12514
- var _a65;
12551
+ var _a72;
12515
12552
  if (payload === void 0 || payload === null) {
12516
12553
  return Promise.reject("Payload is required for httpSend()");
12517
12554
  }
@@ -12536,7 +12573,7 @@ var RealtimeChannel = class _RealtimeChannel {
12536
12573
  ]
12537
12574
  })
12538
12575
  };
12539
- const response = await this._fetchWithTimeout(this.broadcastEndpointURL, options, (_a65 = opts.timeout) !== null && _a65 !== void 0 ? _a65 : this.timeout);
12576
+ const response = await this._fetchWithTimeout(this.broadcastEndpointURL, options, (_a72 = opts.timeout) !== null && _a72 !== void 0 ? _a72 : this.timeout);
12540
12577
  if (response.status === 202) {
12541
12578
  return { success: true };
12542
12579
  }
@@ -12544,7 +12581,7 @@ var RealtimeChannel = class _RealtimeChannel {
12544
12581
  try {
12545
12582
  const errorBody = await response.json();
12546
12583
  errorMessage = errorBody.error || errorBody.message || errorMessage;
12547
- } catch (_b5) {
12584
+ } catch (_b6) {
12548
12585
  }
12549
12586
  return Promise.reject(new Error(errorMessage));
12550
12587
  }
@@ -12558,7 +12595,7 @@ var RealtimeChannel = class _RealtimeChannel {
12558
12595
  * @param opts Options to be used during the send process
12559
12596
  */
12560
12597
  async send(args, opts = {}) {
12561
- var _a65, _b5;
12598
+ var _a72, _b6;
12562
12599
  if (!this._canPush() && args.type === "broadcast") {
12563
12600
  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.");
12564
12601
  const { event, payload: endpoint_payload } = args;
@@ -12584,8 +12621,8 @@ var RealtimeChannel = class _RealtimeChannel {
12584
12621
  })
12585
12622
  };
12586
12623
  try {
12587
- const response = await this._fetchWithTimeout(this.broadcastEndpointURL, options, (_a65 = opts.timeout) !== null && _a65 !== void 0 ? _a65 : this.timeout);
12588
- await ((_b5 = response.body) === null || _b5 === void 0 ? void 0 : _b5.cancel());
12624
+ const response = await this._fetchWithTimeout(this.broadcastEndpointURL, options, (_a72 = opts.timeout) !== null && _a72 !== void 0 ? _a72 : this.timeout);
12625
+ await ((_b6 = response.body) === null || _b6 === void 0 ? void 0 : _b6.cancel());
12589
12626
  return response.ok ? "ok" : "error";
12590
12627
  } catch (error) {
12591
12628
  if (error.name === "AbortError") {
@@ -12596,9 +12633,9 @@ var RealtimeChannel = class _RealtimeChannel {
12596
12633
  }
12597
12634
  } else {
12598
12635
  return new Promise((resolve) => {
12599
- var _a66, _b6, _c;
12636
+ var _a73, _b7, _c;
12600
12637
  const push = this._push(args.type, args, opts.timeout || this.timeout);
12601
- 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)) {
12638
+ 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)) {
12602
12639
  resolve("ok");
12603
12640
  }
12604
12641
  push.receive("ok", () => resolve("ok"));
@@ -12717,7 +12754,7 @@ var RealtimeChannel = class _RealtimeChannel {
12717
12754
  }
12718
12755
  /** @internal */
12719
12756
  _trigger(type, payload, ref) {
12720
- var _a65, _b5;
12757
+ var _a72, _b6;
12721
12758
  const typeLower = type.toLocaleLowerCase();
12722
12759
  const { close, error, leave, join } = CHANNEL_EVENTS;
12723
12760
  const events = [close, error, leave, join];
@@ -12729,18 +12766,18 @@ var RealtimeChannel = class _RealtimeChannel {
12729
12766
  throw "channel onMessage callbacks must return the payload, modified or unmodified";
12730
12767
  }
12731
12768
  if (["insert", "update", "delete"].includes(typeLower)) {
12732
- (_a65 = this.bindings.postgres_changes) === null || _a65 === void 0 ? void 0 : _a65.filter((bind) => {
12733
- var _a66, _b6, _c;
12734
- 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;
12769
+ (_a72 = this.bindings.postgres_changes) === null || _a72 === void 0 ? void 0 : _a72.filter((bind) => {
12770
+ var _a73, _b7, _c;
12771
+ 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;
12735
12772
  }).map((bind) => bind.callback(handledPayload, ref));
12736
12773
  } else {
12737
- (_b5 = this.bindings[typeLower]) === null || _b5 === void 0 ? void 0 : _b5.filter((bind) => {
12738
- var _a66, _b6, _c, _d, _e, _f, _g, _h;
12774
+ (_b6 = this.bindings[typeLower]) === null || _b6 === void 0 ? void 0 : _b6.filter((bind) => {
12775
+ var _a73, _b7, _c, _d, _e, _f, _g, _h;
12739
12776
  if (["broadcast", "presence", "postgres_changes"].includes(typeLower)) {
12740
12777
  if ("id" in bind) {
12741
12778
  const bindId = bind.id;
12742
- const bindEvent = (_a66 = bind.filter) === null || _a66 === void 0 ? void 0 : _a66.event;
12743
- 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));
12779
+ const bindEvent = (_a73 = bind.filter) === null || _a73 === void 0 ? void 0 : _a73.event;
12780
+ 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));
12744
12781
  } else {
12745
12782
  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();
12746
12783
  return bindEvent === "*" || bindEvent === ((_h = payload === null || payload === void 0 ? void 0 : payload.event) === null || _h === void 0 ? void 0 : _h.toLocaleLowerCase());
@@ -12807,8 +12844,8 @@ var RealtimeChannel = class _RealtimeChannel {
12807
12844
  const typeLower = type.toLocaleLowerCase();
12808
12845
  if (this.bindings[typeLower]) {
12809
12846
  this.bindings[typeLower] = this.bindings[typeLower].filter((bind) => {
12810
- var _a65;
12811
- return !(((_a65 = bind.type) === null || _a65 === void 0 ? void 0 : _a65.toLocaleLowerCase()) === typeLower && _RealtimeChannel.isEqual(bind.filter, filter));
12847
+ var _a72;
12848
+ return !(((_a72 = bind.type) === null || _a72 === void 0 ? void 0 : _a72.toLocaleLowerCase()) === typeLower && _RealtimeChannel.isEqual(bind.filter, filter));
12812
12849
  });
12813
12850
  }
12814
12851
  return this;
@@ -12938,7 +12975,7 @@ var RealtimeClient = class {
12938
12975
  * ```
12939
12976
  */
12940
12977
  constructor(endPoint, options) {
12941
- var _a65;
12978
+ var _a72;
12942
12979
  this.accessTokenValue = null;
12943
12980
  this.apiKey = null;
12944
12981
  this._manuallySetToken = false;
@@ -12977,7 +13014,7 @@ var RealtimeClient = class {
12977
13014
  }
12978
13015
  return (...args) => fetch(...args);
12979
13016
  };
12980
- if (!((_a65 = options === null || options === void 0 ? void 0 : options.params) === null || _a65 === void 0 ? void 0 : _a65.apikey)) {
13017
+ if (!((_a72 = options === null || options === void 0 ? void 0 : options.params) === null || _a72 === void 0 ? void 0 : _a72.apikey)) {
12981
13018
  throw new Error("API key is required to connect to Realtime");
12982
13019
  }
12983
13020
  this.apiKey = options.params.apikey;
@@ -13159,8 +13196,8 @@ Option 2: Install and provide the "ws" package:
13159
13196
  const { topic, event, payload, ref } = data;
13160
13197
  const callback = () => {
13161
13198
  this.encode(data, (result) => {
13162
- var _a65;
13163
- (_a65 = this.conn) === null || _a65 === void 0 ? void 0 : _a65.send(result);
13199
+ var _a72;
13200
+ (_a72 = this.conn) === null || _a72 === void 0 ? void 0 : _a72.send(result);
13164
13201
  });
13165
13202
  };
13166
13203
  this.log("push", `${topic} ${event} (${ref})`, payload);
@@ -13210,7 +13247,7 @@ Option 2: Install and provide the "ws" package:
13210
13247
  * Sends a heartbeat message if the socket is connected.
13211
13248
  */
13212
13249
  async sendHeartbeat() {
13213
- var _a65;
13250
+ var _a72;
13214
13251
  if (!this.isConnected()) {
13215
13252
  try {
13216
13253
  this.heartbeatCallback("disconnected");
@@ -13229,11 +13266,11 @@ Option 2: Install and provide the "ws" package:
13229
13266
  this.log("error", "error in heartbeat callback", e);
13230
13267
  }
13231
13268
  this._wasManualDisconnect = false;
13232
- (_a65 = this.conn) === null || _a65 === void 0 ? void 0 : _a65.close(WS_CLOSE_NORMAL, "heartbeat timeout");
13269
+ (_a72 = this.conn) === null || _a72 === void 0 ? void 0 : _a72.close(WS_CLOSE_NORMAL, "heartbeat timeout");
13233
13270
  setTimeout(() => {
13234
- var _a66;
13271
+ var _a73;
13235
13272
  if (!this.isConnected()) {
13236
- (_a66 = this.reconnectTimer) === null || _a66 === void 0 ? void 0 : _a66.scheduleTimeout();
13273
+ (_a73 = this.reconnectTimer) === null || _a73 === void 0 ? void 0 : _a73.scheduleTimeout();
13237
13274
  }
13238
13275
  }, CONNECTION_TIMEOUTS.HEARTBEAT_TIMEOUT_FALLBACK);
13239
13276
  return;
@@ -13331,12 +13368,12 @@ Option 2: Install and provide the "ws" package:
13331
13368
  * @internal
13332
13369
  */
13333
13370
  _clearTimer(timer) {
13334
- var _a65;
13371
+ var _a72;
13335
13372
  if (timer === "heartbeat" && this.heartbeatTimer) {
13336
13373
  clearInterval(this.heartbeatTimer);
13337
13374
  this.heartbeatTimer = void 0;
13338
13375
  } else if (timer === "reconnect") {
13339
- (_a65 = this.reconnectTimer) === null || _a65 === void 0 ? void 0 : _a65.reset();
13376
+ (_a72 = this.reconnectTimer) === null || _a72 === void 0 ? void 0 : _a72.reset();
13340
13377
  }
13341
13378
  }
13342
13379
  /**
@@ -13451,13 +13488,13 @@ Option 2: Install and provide the "ws" package:
13451
13488
  }
13452
13489
  /** @internal */
13453
13490
  _onConnClose(event) {
13454
- var _a65;
13491
+ var _a72;
13455
13492
  this._setConnectionState("disconnected");
13456
13493
  this.log("transport", "close", event);
13457
13494
  this._triggerChanError();
13458
13495
  this._clearTimer("heartbeat");
13459
13496
  if (!this._wasManualDisconnect) {
13460
- (_a65 = this.reconnectTimer) === null || _a65 === void 0 ? void 0 : _a65.scheduleTimeout();
13497
+ (_a72 = this.reconnectTimer) === null || _a72 === void 0 ? void 0 : _a72.scheduleTimeout();
13461
13498
  }
13462
13499
  this._triggerStateCallbacks("close", event);
13463
13500
  }
@@ -13600,9 +13637,9 @@ Option 2: Install and provide the "ws" package:
13600
13637
  * @internal
13601
13638
  */
13602
13639
  _initializeOptions(options) {
13603
- var _a65, _b5, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
13604
- this.transport = (_a65 = options === null || options === void 0 ? void 0 : options.transport) !== null && _a65 !== void 0 ? _a65 : null;
13605
- this.timeout = (_b5 = options === null || options === void 0 ? void 0 : options.timeout) !== null && _b5 !== void 0 ? _b5 : DEFAULT_TIMEOUT;
13640
+ var _a72, _b6, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
13641
+ this.transport = (_a72 = options === null || options === void 0 ? void 0 : options.transport) !== null && _a72 !== void 0 ? _a72 : null;
13642
+ this.timeout = (_b6 = options === null || options === void 0 ? void 0 : options.timeout) !== null && _b6 !== void 0 ? _b6 : DEFAULT_TIMEOUT;
13606
13643
  this.heartbeatIntervalMs = (_c = options === null || options === void 0 ? void 0 : options.heartbeatIntervalMs) !== null && _c !== void 0 ? _c : CONNECTION_TIMEOUTS.HEARTBEAT_INTERVAL;
13607
13644
  this.worker = (_d = options === null || options === void 0 ? void 0 : options.worker) !== null && _d !== void 0 ? _d : false;
13608
13645
  this.accessToken = (_e = options === null || options === void 0 ? void 0 : options.accessToken) !== null && _e !== void 0 ? _e : null;
@@ -13647,14 +13684,14 @@ Option 2: Install and provide the "ws" package:
13647
13684
  // node_modules/iceberg-js/dist/index.mjs
13648
13685
  var IcebergError = class extends Error {
13649
13686
  constructor(message, opts) {
13650
- var _a65;
13687
+ var _a72;
13651
13688
  super(message);
13652
13689
  this.name = "IcebergError";
13653
13690
  this.status = opts.status;
13654
13691
  this.icebergType = opts.icebergType;
13655
13692
  this.icebergCode = opts.icebergCode;
13656
13693
  this.details = opts.details;
13657
- this.isCommitStateUnknown = opts.icebergType === "CommitStateUnknownException" || [500, 502, 504].includes(opts.status) && ((_a65 = opts.icebergType) == null ? void 0 : _a65.includes("CommitState")) === true;
13694
+ this.isCommitStateUnknown = opts.icebergType === "CommitStateUnknownException" || [500, 502, 504].includes(opts.status) && ((_a72 = opts.icebergType) == null ? void 0 : _a72.includes("CommitState")) === true;
13658
13695
  }
13659
13696
  /**
13660
13697
  * Returns true if the error is a 404 Not Found error.
@@ -13702,8 +13739,8 @@ async function buildAuthHeaders(auth) {
13702
13739
  return {};
13703
13740
  }
13704
13741
  function createFetchClient(options) {
13705
- var _a65;
13706
- const fetchFn = (_a65 = options.fetchImpl) != null ? _a65 : globalThis.fetch;
13742
+ var _a72;
13743
+ const fetchFn = (_a72 = options.fetchImpl) != null ? _a72 : globalThis.fetch;
13707
13744
  return {
13708
13745
  async request({
13709
13746
  method,
@@ -13712,7 +13749,7 @@ function createFetchClient(options) {
13712
13749
  body,
13713
13750
  headers
13714
13751
  }) {
13715
- var _a66;
13752
+ var _a73;
13716
13753
  const url = buildUrl(options.baseUrl, path, query);
13717
13754
  const authHeaders = await buildAuthHeaders(options.auth);
13718
13755
  const res = await fetchFn(url, {
@@ -13731,7 +13768,7 @@ function createFetchClient(options) {
13731
13768
  const errBody = isJson ? data : void 0;
13732
13769
  const errorDetail = errBody == null ? void 0 : errBody.error;
13733
13770
  throw new IcebergError(
13734
- (_a66 = errorDetail == null ? void 0 : errorDetail.message) != null ? _a66 : `Request failed with status ${res.status}`,
13771
+ (_a73 = errorDetail == null ? void 0 : errorDetail.message) != null ? _a73 : `Request failed with status ${res.status}`,
13735
13772
  {
13736
13773
  status: res.status,
13737
13774
  icebergType: errorDetail == null ? void 0 : errorDetail.type,
@@ -13854,11 +13891,11 @@ var TableOperations = class {
13854
13891
  };
13855
13892
  }
13856
13893
  async dropTable(id, options) {
13857
- var _a65;
13894
+ var _a72;
13858
13895
  await this.client.request({
13859
13896
  method: "DELETE",
13860
13897
  path: `${this.prefix}/namespaces/${namespaceToPath2(id.namespace)}/tables/${id.name}`,
13861
- query: { purgeRequested: String((_a65 = options == null ? void 0 : options.purge) != null ? _a65 : false) }
13898
+ query: { purgeRequested: String((_a72 = options == null ? void 0 : options.purge) != null ? _a72 : false) }
13862
13899
  });
13863
13900
  }
13864
13901
  async loadTable(id) {
@@ -13910,7 +13947,7 @@ var IcebergRestCatalog = class {
13910
13947
  * @param options - Configuration options for the catalog client
13911
13948
  */
13912
13949
  constructor(options) {
13913
- var _a65;
13950
+ var _a72;
13914
13951
  let prefix = "v1";
13915
13952
  if (options.catalogName) {
13916
13953
  prefix += `/${options.catalogName}`;
@@ -13921,7 +13958,7 @@ var IcebergRestCatalog = class {
13921
13958
  auth: options.auth,
13922
13959
  fetchImpl: options.fetch
13923
13960
  });
13924
- this.accessDelegation = (_a65 = options.accessDelegation) == null ? void 0 : _a65.join(",");
13961
+ this.accessDelegation = (_a72 = options.accessDelegation) == null ? void 0 : _a72.join(",");
13925
13962
  this.namespaceOps = new NamespaceOperations(this.client, prefix);
13926
13963
  this.tableOps = new TableOperations(this.client, prefix, this.accessDelegation);
13927
13964
  }
@@ -17260,7 +17297,7 @@ var getItemAsync = async (storage, key) => {
17260
17297
  }
17261
17298
  try {
17262
17299
  return JSON.parse(value);
17263
- } catch (_a65) {
17300
+ } catch (_a72) {
17264
17301
  return value;
17265
17302
  }
17266
17303
  };
@@ -17471,7 +17508,7 @@ function deepClone(obj) {
17471
17508
  var _getErrorMessage2 = (err) => err.msg || err.message || err.error_description || err.error || JSON.stringify(err);
17472
17509
  var NETWORK_ERROR_CODES = [502, 503, 504];
17473
17510
  async function handleError2(error) {
17474
- var _a65;
17511
+ var _a72;
17475
17512
  if (!looksLikeFetchResponse(error)) {
17476
17513
  throw new AuthRetryableFetchError(_getErrorMessage2(error), 0);
17477
17514
  }
@@ -17496,7 +17533,7 @@ async function handleError2(error) {
17496
17533
  throw new AuthWeakPasswordError(_getErrorMessage2(data), error.status, data.weak_password.reasons);
17497
17534
  }
17498
17535
  } else if (errorCode === "weak_password") {
17499
- throw new AuthWeakPasswordError(_getErrorMessage2(data), error.status, ((_a65 = data.weak_password) === null || _a65 === void 0 ? void 0 : _a65.reasons) || []);
17536
+ throw new AuthWeakPasswordError(_getErrorMessage2(data), error.status, ((_a72 = data.weak_password) === null || _a72 === void 0 ? void 0 : _a72.reasons) || []);
17500
17537
  } else if (errorCode === "session_not_found") {
17501
17538
  throw new AuthSessionMissingError();
17502
17539
  }
@@ -17512,7 +17549,7 @@ var _getRequestParams2 = (method, options, parameters, body) => {
17512
17549
  return Object.assign(Object.assign({}, params), parameters);
17513
17550
  };
17514
17551
  async function _request(fetcher, method, url, options) {
17515
- var _a65;
17552
+ var _a72;
17516
17553
  const headers = Object.assign({}, options === null || options === void 0 ? void 0 : options.headers);
17517
17554
  if (!headers[API_VERSION_HEADER_NAME]) {
17518
17555
  headers[API_VERSION_HEADER_NAME] = API_VERSIONS["2024-01-01"].name;
@@ -17520,7 +17557,7 @@ async function _request(fetcher, method, url, options) {
17520
17557
  if (options === null || options === void 0 ? void 0 : options.jwt) {
17521
17558
  headers["Authorization"] = `Bearer ${options.jwt}`;
17522
17559
  }
17523
- const qs = (_a65 = options === null || options === void 0 ? void 0 : options.query) !== null && _a65 !== void 0 ? _a65 : {};
17560
+ const qs = (_a72 = options === null || options === void 0 ? void 0 : options.query) !== null && _a72 !== void 0 ? _a72 : {};
17524
17561
  if (options === null || options === void 0 ? void 0 : options.redirectTo) {
17525
17562
  qs["redirect_to"] = options.redirectTo;
17526
17563
  }
@@ -17553,7 +17590,7 @@ async function _handleRequest2(fetcher, method, url, options, parameters, body)
17553
17590
  }
17554
17591
  }
17555
17592
  function _sessionResponse(data) {
17556
- var _a65;
17593
+ var _a72;
17557
17594
  let session = null;
17558
17595
  if (hasSession(data)) {
17559
17596
  session = Object.assign({}, data);
@@ -17561,7 +17598,7 @@ function _sessionResponse(data) {
17561
17598
  session.expires_at = expiresAt(data.expires_in);
17562
17599
  }
17563
17600
  }
17564
- const user = (_a65 = data.user) !== null && _a65 !== void 0 ? _a65 : data;
17601
+ const user = (_a72 = data.user) !== null && _a72 !== void 0 ? _a72 : data;
17565
17602
  return { data: { session, user }, error: null };
17566
17603
  }
17567
17604
  function _sessionResponsePassword(data) {
@@ -17572,8 +17609,8 @@ function _sessionResponsePassword(data) {
17572
17609
  return response;
17573
17610
  }
17574
17611
  function _userResponse(data) {
17575
- var _a65;
17576
- const user = (_a65 = data.user) !== null && _a65 !== void 0 ? _a65 : data;
17612
+ var _a72;
17613
+ const user = (_a72 = data.user) !== null && _a72 !== void 0 ? _a72 : data;
17577
17614
  return { data: { user }, error: null };
17578
17615
  }
17579
17616
  function _ssoResponse(data) {
@@ -17742,14 +17779,14 @@ var GoTrueAdminApi = class {
17742
17779
  * @param params An object which supports `page` and `perPage` as numbers, to alter the paginated results.
17743
17780
  */
17744
17781
  async listUsers(params) {
17745
- var _a65, _b5, _c, _d, _e, _f, _g;
17782
+ var _a72, _b6, _c, _d, _e, _f, _g;
17746
17783
  try {
17747
17784
  const pagination = { nextPage: null, lastPage: 0, total: 0 };
17748
17785
  const response = await _request(this.fetch, "GET", `${this.url}/admin/users`, {
17749
17786
  headers: this.headers,
17750
17787
  noResolveJson: true,
17751
17788
  query: {
17752
- 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 : "",
17789
+ 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 : "",
17753
17790
  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 : ""
17754
17791
  },
17755
17792
  xform: _noResolveJsonResponse
@@ -17883,14 +17920,14 @@ var GoTrueAdminApi = class {
17883
17920
  * This function should only be called on a server. Never expose your `service_role` key in the browser.
17884
17921
  */
17885
17922
  async _listOAuthClients(params) {
17886
- var _a65, _b5, _c, _d, _e, _f, _g;
17923
+ var _a72, _b6, _c, _d, _e, _f, _g;
17887
17924
  try {
17888
17925
  const pagination = { nextPage: null, lastPage: 0, total: 0 };
17889
17926
  const response = await _request(this.fetch, "GET", `${this.url}/admin/oauth/clients`, {
17890
17927
  headers: this.headers,
17891
17928
  noResolveJson: true,
17892
17929
  query: {
17893
- 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 : "",
17930
+ 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 : "",
17894
17931
  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 : ""
17895
17932
  },
17896
17933
  xform: _noResolveJsonResponse
@@ -18143,7 +18180,7 @@ function toHex(value) {
18143
18180
  return "0x" + hex;
18144
18181
  }
18145
18182
  function createSiweMessage(parameters) {
18146
- var _a65;
18183
+ var _a72;
18147
18184
  const { chainId, domain, expirationTime, issuedAt = /* @__PURE__ */ new Date(), nonce, notBefore, requestId, resources, scheme, uri, version: version5 } = parameters;
18148
18185
  {
18149
18186
  if (!Number.isInteger(chainId))
@@ -18156,7 +18193,7 @@ function createSiweMessage(parameters) {
18156
18193
  throw new Error(`@supabase/auth-js: Invalid SIWE message field "uri". URI must be provided.`);
18157
18194
  if (version5 !== "1")
18158
18195
  throw new Error(`@supabase/auth-js: Invalid SIWE message field "version". Version must be '1'. Provided value: ${version5}`);
18159
- if ((_a65 = parameters.statement) === null || _a65 === void 0 ? void 0 : _a65.includes("\n"))
18196
+ if ((_a72 = parameters.statement) === null || _a72 === void 0 ? void 0 : _a72.includes("\n"))
18160
18197
  throw new Error(`@supabase/auth-js: Invalid SIWE message field "statement". Statement must not include '\\n'. Provided value: ${parameters.statement}`);
18161
18198
  }
18162
18199
  const address = getAddress(parameters.address);
@@ -18198,10 +18235,10 @@ ${suffix}`;
18198
18235
  // node_modules/@supabase/auth-js/dist/module/lib/webauthn.errors.js
18199
18236
  var WebAuthnError = class extends Error {
18200
18237
  constructor({ message, code, cause, name }) {
18201
- var _a65;
18238
+ var _a72;
18202
18239
  super(message, { cause });
18203
18240
  this.__isWebAuthnError = true;
18204
- this.name = (_a65 = name !== null && name !== void 0 ? name : cause instanceof Error ? cause.name : void 0) !== null && _a65 !== void 0 ? _a65 : "Unknown Error";
18241
+ this.name = (_a72 = name !== null && name !== void 0 ? name : cause instanceof Error ? cause.name : void 0) !== null && _a72 !== void 0 ? _a72 : "Unknown Error";
18205
18242
  this.code = code;
18206
18243
  }
18207
18244
  };
@@ -18217,7 +18254,7 @@ var WebAuthnUnknownError = class extends WebAuthnError {
18217
18254
  }
18218
18255
  };
18219
18256
  function identifyRegistrationError({ error, options }) {
18220
- var _a65, _b5, _c;
18257
+ var _a72, _b6, _c;
18221
18258
  const { publicKey } = options;
18222
18259
  if (!publicKey) {
18223
18260
  throw Error("options was missing required publicKey property");
@@ -18231,7 +18268,7 @@ function identifyRegistrationError({ error, options }) {
18231
18268
  });
18232
18269
  }
18233
18270
  } else if (error.name === "ConstraintError") {
18234
- if (((_a65 = publicKey.authenticatorSelection) === null || _a65 === void 0 ? void 0 : _a65.requireResidentKey) === true) {
18271
+ if (((_a72 = publicKey.authenticatorSelection) === null || _a72 === void 0 ? void 0 : _a72.requireResidentKey) === true) {
18235
18272
  return new WebAuthnError({
18236
18273
  message: "Discoverable credentials were required but no available authenticator supported it",
18237
18274
  code: "ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",
@@ -18239,7 +18276,7 @@ function identifyRegistrationError({ error, options }) {
18239
18276
  });
18240
18277
  } else if (
18241
18278
  // @ts-ignore: `mediation` doesn't yet exist on CredentialCreationOptions but it's possible as of Sept 2024
18242
- options.mediation === "conditional" && ((_b5 = publicKey.authenticatorSelection) === null || _b5 === void 0 ? void 0 : _b5.userVerification) === "required"
18279
+ options.mediation === "conditional" && ((_b6 = publicKey.authenticatorSelection) === null || _b6 === void 0 ? void 0 : _b6.userVerification) === "required"
18243
18280
  ) {
18244
18281
  return new WebAuthnError({
18245
18282
  message: "User verification was required during automatic registration but it could not be performed",
@@ -18460,7 +18497,7 @@ function deserializeCredentialRequestOptions(options) {
18460
18497
  return result;
18461
18498
  }
18462
18499
  function serializeCredentialCreationResponse(credential) {
18463
- var _a65;
18500
+ var _a72;
18464
18501
  if ("toJSON" in credential && typeof credential.toJSON === "function") {
18465
18502
  return credential.toJSON();
18466
18503
  }
@@ -18475,11 +18512,11 @@ function serializeCredentialCreationResponse(credential) {
18475
18512
  type: "public-key",
18476
18513
  clientExtensionResults: credential.getClientExtensionResults(),
18477
18514
  // Convert null to undefined and cast to AuthenticatorAttachment type
18478
- authenticatorAttachment: (_a65 = credentialWithAttachment.authenticatorAttachment) !== null && _a65 !== void 0 ? _a65 : void 0
18515
+ authenticatorAttachment: (_a72 = credentialWithAttachment.authenticatorAttachment) !== null && _a72 !== void 0 ? _a72 : void 0
18479
18516
  };
18480
18517
  }
18481
18518
  function serializeCredentialRequestResponse(credential) {
18482
- var _a65;
18519
+ var _a72;
18483
18520
  if ("toJSON" in credential && typeof credential.toJSON === "function") {
18484
18521
  return credential.toJSON();
18485
18522
  }
@@ -18499,7 +18536,7 @@ function serializeCredentialRequestResponse(credential) {
18499
18536
  type: "public-key",
18500
18537
  clientExtensionResults,
18501
18538
  // Convert null to undefined and cast to AuthenticatorAttachment type
18502
- authenticatorAttachment: (_a65 = credentialWithAttachment.authenticatorAttachment) !== null && _a65 !== void 0 ? _a65 : void 0
18539
+ authenticatorAttachment: (_a72 = credentialWithAttachment.authenticatorAttachment) !== null && _a72 !== void 0 ? _a72 : void 0
18503
18540
  };
18504
18541
  }
18505
18542
  function isValidDomain(hostname) {
@@ -18509,8 +18546,8 @@ function isValidDomain(hostname) {
18509
18546
  );
18510
18547
  }
18511
18548
  function browserSupportsWebAuthn() {
18512
- var _a65, _b5;
18513
- 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");
18549
+ var _a72, _b6;
18550
+ 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");
18514
18551
  }
18515
18552
  async function createCredential(options) {
18516
18553
  try {
@@ -18839,8 +18876,8 @@ var WebAuthnApi = class {
18839
18876
  });
18840
18877
  if (!factor) {
18841
18878
  await this.client.mfa.listFactors().then((factors) => {
18842
- var _a65;
18843
- 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");
18879
+ var _a72;
18880
+ 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");
18844
18881
  }).then((factor2) => factor2 ? this.client.mfa.unenroll({ factorId: factor2 === null || factor2 === void 0 ? void 0 : factor2.id }) : void 0);
18845
18882
  return { data: null, error: enrollError };
18846
18883
  }
@@ -18902,15 +18939,15 @@ var GoTrueClient = class _GoTrueClient {
18902
18939
  * The JWKS used for verifying asymmetric JWTs
18903
18940
  */
18904
18941
  get jwks() {
18905
- var _a65, _b5;
18906
- return (_b5 = (_a65 = GLOBAL_JWKS[this.storageKey]) === null || _a65 === void 0 ? void 0 : _a65.jwks) !== null && _b5 !== void 0 ? _b5 : { keys: [] };
18942
+ var _a72, _b6;
18943
+ return (_b6 = (_a72 = GLOBAL_JWKS[this.storageKey]) === null || _a72 === void 0 ? void 0 : _a72.jwks) !== null && _b6 !== void 0 ? _b6 : { keys: [] };
18907
18944
  }
18908
18945
  set jwks(value) {
18909
18946
  GLOBAL_JWKS[this.storageKey] = Object.assign(Object.assign({}, GLOBAL_JWKS[this.storageKey]), { jwks: value });
18910
18947
  }
18911
18948
  get jwks_cached_at() {
18912
- var _a65, _b5;
18913
- return (_b5 = (_a65 = GLOBAL_JWKS[this.storageKey]) === null || _a65 === void 0 ? void 0 : _a65.cachedAt) !== null && _b5 !== void 0 ? _b5 : Number.MIN_SAFE_INTEGER;
18949
+ var _a72, _b6;
18950
+ return (_b6 = (_a72 = GLOBAL_JWKS[this.storageKey]) === null || _a72 === void 0 ? void 0 : _a72.cachedAt) !== null && _b6 !== void 0 ? _b6 : Number.MIN_SAFE_INTEGER;
18914
18951
  }
18915
18952
  set jwks_cached_at(value) {
18916
18953
  GLOBAL_JWKS[this.storageKey] = Object.assign(Object.assign({}, GLOBAL_JWKS[this.storageKey]), { cachedAt: value });
@@ -18930,7 +18967,7 @@ var GoTrueClient = class _GoTrueClient {
18930
18967
  * ```
18931
18968
  */
18932
18969
  constructor(options) {
18933
- var _a65, _b5, _c;
18970
+ var _a72, _b6, _c;
18934
18971
  this.userStorage = null;
18935
18972
  this.memoryStorage = null;
18936
18973
  this.stateChangeEmitters = /* @__PURE__ */ new Map();
@@ -18948,7 +18985,7 @@ var GoTrueClient = class _GoTrueClient {
18948
18985
  this.logger = console.log;
18949
18986
  const settings = Object.assign(Object.assign({}, DEFAULT_OPTIONS), options);
18950
18987
  this.storageKey = settings.storageKey;
18951
- this.instanceID = (_a65 = _GoTrueClient.nextInstanceID[this.storageKey]) !== null && _a65 !== void 0 ? _a65 : 0;
18988
+ this.instanceID = (_a72 = _GoTrueClient.nextInstanceID[this.storageKey]) !== null && _a72 !== void 0 ? _a72 : 0;
18952
18989
  _GoTrueClient.nextInstanceID[this.storageKey] = this.instanceID + 1;
18953
18990
  this.logDebugMessages = !!settings.debug;
18954
18991
  if (typeof settings.debug === "function") {
@@ -18979,7 +19016,7 @@ var GoTrueClient = class _GoTrueClient {
18979
19016
  this.lockAcquireTimeout = settings.lockAcquireTimeout;
18980
19017
  if (settings.lock) {
18981
19018
  this.lock = settings.lock;
18982
- } else if (this.persistSession && isBrowser() && ((_b5 = globalThis === null || globalThis === void 0 ? void 0 : globalThis.navigator) === null || _b5 === void 0 ? void 0 : _b5.locks)) {
19019
+ } else if (this.persistSession && isBrowser() && ((_b6 = globalThis === null || globalThis === void 0 ? void 0 : globalThis.navigator) === null || _b6 === void 0 ? void 0 : _b6.locks)) {
18983
19020
  this.lock = navigatorLock;
18984
19021
  } else {
18985
19022
  this.lock = lockNoOp;
@@ -19085,7 +19122,7 @@ var GoTrueClient = class _GoTrueClient {
19085
19122
  * the whole lifetime of the client
19086
19123
  */
19087
19124
  async _initialize() {
19088
- var _a65;
19125
+ var _a72;
19089
19126
  try {
19090
19127
  let params = {};
19091
19128
  let callbackUrlType = "none";
@@ -19102,7 +19139,7 @@ var GoTrueClient = class _GoTrueClient {
19102
19139
  if (error) {
19103
19140
  this._debug("#_initialize()", "error detecting session from URL", error);
19104
19141
  if (isAuthImplicitGrantRedirectError(error)) {
19105
- const errorCode = (_a65 = error.details) === null || _a65 === void 0 ? void 0 : _a65.code;
19142
+ const errorCode = (_a72 = error.details) === null || _a72 === void 0 ? void 0 : _a72.code;
19106
19143
  if (errorCode === "identity_already_exists" || errorCode === "identity_not_found" || errorCode === "single_identity_not_deletable") {
19107
19144
  return { error };
19108
19145
  }
@@ -19141,12 +19178,12 @@ var GoTrueClient = class _GoTrueClient {
19141
19178
  * @returns A session where the is_anonymous claim in the access token JWT set to true
19142
19179
  */
19143
19180
  async signInAnonymously(credentials) {
19144
- var _a65, _b5, _c;
19181
+ var _a72, _b6, _c;
19145
19182
  try {
19146
19183
  const res = await _request(this.fetch, "POST", `${this.url}/signup`, {
19147
19184
  headers: this.headers,
19148
19185
  body: {
19149
- 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 : {},
19186
+ 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 : {},
19150
19187
  gotrue_meta_security: { captcha_token: (_c = credentials === null || credentials === void 0 ? void 0 : credentials.options) === null || _c === void 0 ? void 0 : _c.captchaToken }
19151
19188
  },
19152
19189
  xform: _sessionResponse
@@ -19180,7 +19217,7 @@ var GoTrueClient = class _GoTrueClient {
19180
19217
  * @returns A user if the server has "autoconfirm" OFF
19181
19218
  */
19182
19219
  async signUp(credentials) {
19183
- var _a65, _b5, _c;
19220
+ var _a72, _b6, _c;
19184
19221
  try {
19185
19222
  let res;
19186
19223
  if ("email" in credentials) {
@@ -19197,7 +19234,7 @@ var GoTrueClient = class _GoTrueClient {
19197
19234
  body: {
19198
19235
  email,
19199
19236
  password,
19200
- data: (_a65 = options === null || options === void 0 ? void 0 : options.data) !== null && _a65 !== void 0 ? _a65 : {},
19237
+ data: (_a72 = options === null || options === void 0 ? void 0 : options.data) !== null && _a72 !== void 0 ? _a72 : {},
19201
19238
  gotrue_meta_security: { captcha_token: options === null || options === void 0 ? void 0 : options.captchaToken },
19202
19239
  code_challenge: codeChallenge,
19203
19240
  code_challenge_method: codeChallengeMethod
@@ -19211,7 +19248,7 @@ var GoTrueClient = class _GoTrueClient {
19211
19248
  body: {
19212
19249
  phone,
19213
19250
  password,
19214
- data: (_b5 = options === null || options === void 0 ? void 0 : options.data) !== null && _b5 !== void 0 ? _b5 : {},
19251
+ data: (_b6 = options === null || options === void 0 ? void 0 : options.data) !== null && _b6 !== void 0 ? _b6 : {},
19215
19252
  channel: (_c = options === null || options === void 0 ? void 0 : options.channel) !== null && _c !== void 0 ? _c : "sms",
19216
19253
  gotrue_meta_security: { captcha_token: options === null || options === void 0 ? void 0 : options.captchaToken }
19217
19254
  },
@@ -19303,10 +19340,10 @@ var GoTrueClient = class _GoTrueClient {
19303
19340
  * This method supports the PKCE flow.
19304
19341
  */
19305
19342
  async signInWithOAuth(credentials) {
19306
- var _a65, _b5, _c, _d;
19343
+ var _a72, _b6, _c, _d;
19307
19344
  return await this._handleProviderSignIn(credentials.provider, {
19308
- redirectTo: (_a65 = credentials.options) === null || _a65 === void 0 ? void 0 : _a65.redirectTo,
19309
- scopes: (_b5 = credentials.options) === null || _b5 === void 0 ? void 0 : _b5.scopes,
19345
+ redirectTo: (_a72 = credentials.options) === null || _a72 === void 0 ? void 0 : _a72.redirectTo,
19346
+ scopes: (_b6 = credentials.options) === null || _b6 === void 0 ? void 0 : _b6.scopes,
19310
19347
  queryParams: (_c = credentials.options) === null || _c === void 0 ? void 0 : _c.queryParams,
19311
19348
  skipBrowserRedirect: (_d = credentials.options) === null || _d === void 0 ? void 0 : _d.skipBrowserRedirect
19312
19349
  });
@@ -19339,7 +19376,7 @@ var GoTrueClient = class _GoTrueClient {
19339
19376
  }
19340
19377
  }
19341
19378
  async signInWithEthereum(credentials) {
19342
- var _a65, _b5, _c, _d, _e, _f, _g, _h, _j, _k, _l;
19379
+ var _a72, _b6, _c, _d, _e, _f, _g, _h, _j, _k, _l;
19343
19380
  let message;
19344
19381
  let signature;
19345
19382
  if ("message" in credentials) {
@@ -19363,7 +19400,7 @@ var GoTrueClient = class _GoTrueClient {
19363
19400
  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.`);
19364
19401
  }
19365
19402
  }
19366
- const url = new URL((_a65 = options === null || options === void 0 ? void 0 : options.url) !== null && _a65 !== void 0 ? _a65 : window.location.href);
19403
+ const url = new URL((_a72 = options === null || options === void 0 ? void 0 : options.url) !== null && _a72 !== void 0 ? _a72 : window.location.href);
19367
19404
  const accounts = await resolvedWallet.request({
19368
19405
  method: "eth_requestAccounts"
19369
19406
  }).then((accs) => accs).catch(() => {
@@ -19373,7 +19410,7 @@ var GoTrueClient = class _GoTrueClient {
19373
19410
  throw new Error(`@supabase/auth-js: No accounts available. Please ensure the wallet is connected.`);
19374
19411
  }
19375
19412
  const address = getAddress(accounts[0]);
19376
- let chainId = (_b5 = options === null || options === void 0 ? void 0 : options.signInWithEthereum) === null || _b5 === void 0 ? void 0 : _b5.chainId;
19413
+ let chainId = (_b6 = options === null || options === void 0 ? void 0 : options.signInWithEthereum) === null || _b6 === void 0 ? void 0 : _b6.chainId;
19377
19414
  if (!chainId) {
19378
19415
  const chainIdHex = await resolvedWallet.request({
19379
19416
  method: "eth_chainId"
@@ -19430,7 +19467,7 @@ var GoTrueClient = class _GoTrueClient {
19430
19467
  }
19431
19468
  }
19432
19469
  async signInWithSolana(credentials) {
19433
- var _a65, _b5, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
19470
+ var _a72, _b6, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
19434
19471
  let message;
19435
19472
  let signature;
19436
19473
  if ("message" in credentials) {
@@ -19454,7 +19491,7 @@ var GoTrueClient = class _GoTrueClient {
19454
19491
  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.`);
19455
19492
  }
19456
19493
  }
19457
- const url = new URL((_a65 = options === null || options === void 0 ? void 0 : options.url) !== null && _a65 !== void 0 ? _a65 : window.location.href);
19494
+ const url = new URL((_a72 = options === null || options === void 0 ? void 0 : options.url) !== null && _a72 !== void 0 ? _a72 : window.location.href);
19458
19495
  if ("signIn" in resolvedWallet && resolvedWallet.signIn) {
19459
19496
  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), {
19460
19497
  // non-overridable properties
@@ -19486,7 +19523,7 @@ var GoTrueClient = class _GoTrueClient {
19486
19523
  ...statement ? ["", statement, ""] : [""],
19487
19524
  "Version: 1",
19488
19525
  `URI: ${url.href}`,
19489
- `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()}`,
19526
+ `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()}`,
19490
19527
  ...((_d = options === null || options === void 0 ? void 0 : options.signInWithSolana) === null || _d === void 0 ? void 0 : _d.notBefore) ? [`Not Before: ${options.signInWithSolana.notBefore}`] : [],
19491
19528
  ...((_e = options === null || options === void 0 ? void 0 : options.signInWithSolana) === null || _e === void 0 ? void 0 : _e.expirationTime) ? [`Expiration Time: ${options.signInWithSolana.expirationTime}`] : [],
19492
19529
  ...((_f = options === null || options === void 0 ? void 0 : options.signInWithSolana) === null || _f === void 0 ? void 0 : _f.chainId) ? [`Chain ID: ${options.signInWithSolana.chainId}`] : [],
@@ -19628,7 +19665,7 @@ var GoTrueClient = class _GoTrueClient {
19628
19665
  * This method supports PKCE when an email is passed.
19629
19666
  */
19630
19667
  async signInWithOtp(credentials) {
19631
- var _a65, _b5, _c, _d, _e;
19668
+ var _a72, _b6, _c, _d, _e;
19632
19669
  try {
19633
19670
  if ("email" in credentials) {
19634
19671
  const { email, options } = credentials;
@@ -19642,8 +19679,8 @@ var GoTrueClient = class _GoTrueClient {
19642
19679
  headers: this.headers,
19643
19680
  body: {
19644
19681
  email,
19645
- data: (_a65 = options === null || options === void 0 ? void 0 : options.data) !== null && _a65 !== void 0 ? _a65 : {},
19646
- create_user: (_b5 = options === null || options === void 0 ? void 0 : options.shouldCreateUser) !== null && _b5 !== void 0 ? _b5 : true,
19682
+ data: (_a72 = options === null || options === void 0 ? void 0 : options.data) !== null && _a72 !== void 0 ? _a72 : {},
19683
+ create_user: (_b6 = options === null || options === void 0 ? void 0 : options.shouldCreateUser) !== null && _b6 !== void 0 ? _b6 : true,
19647
19684
  gotrue_meta_security: { captcha_token: options === null || options === void 0 ? void 0 : options.captchaToken },
19648
19685
  code_challenge: codeChallenge,
19649
19686
  code_challenge_method: codeChallengeMethod
@@ -19682,13 +19719,13 @@ var GoTrueClient = class _GoTrueClient {
19682
19719
  * Log in a user given a User supplied OTP or TokenHash received through mobile or email.
19683
19720
  */
19684
19721
  async verifyOtp(params) {
19685
- var _a65, _b5;
19722
+ var _a72, _b6;
19686
19723
  try {
19687
19724
  let redirectTo = void 0;
19688
19725
  let captchaToken = void 0;
19689
19726
  if ("options" in params) {
19690
- redirectTo = (_a65 = params.options) === null || _a65 === void 0 ? void 0 : _a65.redirectTo;
19691
- captchaToken = (_b5 = params.options) === null || _b5 === void 0 ? void 0 : _b5.captchaToken;
19727
+ redirectTo = (_a72 = params.options) === null || _a72 === void 0 ? void 0 : _a72.redirectTo;
19728
+ captchaToken = (_b6 = params.options) === null || _b6 === void 0 ? void 0 : _b6.captchaToken;
19692
19729
  }
19693
19730
  const { data, error } = await _request(this.fetch, "POST", `${this.url}/verify`, {
19694
19731
  headers: this.headers,
@@ -19732,7 +19769,7 @@ var GoTrueClient = class _GoTrueClient {
19732
19769
  * organization's SSO Identity Provider UUID directly instead.
19733
19770
  */
19734
19771
  async signInWithSSO(params) {
19735
- var _a65, _b5, _c, _d, _e;
19772
+ var _a72, _b6, _c, _d, _e;
19736
19773
  try {
19737
19774
  let codeChallenge = null;
19738
19775
  let codeChallengeMethod = null;
@@ -19741,7 +19778,7 @@ var GoTrueClient = class _GoTrueClient {
19741
19778
  [codeChallenge, codeChallengeMethod] = await getCodeChallengeAndMethod(this.storage, this.storageKey);
19742
19779
  }
19743
19780
  const result = await _request(this.fetch, "POST", `${this.url}/sso`, {
19744
- 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 }),
19781
+ 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 }),
19745
19782
  headers: this.headers,
19746
19783
  xform: _ssoResponse
19747
19784
  });
@@ -19995,17 +20032,17 @@ var GoTrueClient = class _GoTrueClient {
19995
20032
  });
19996
20033
  }
19997
20034
  return await this._useSession(async (result) => {
19998
- var _a65, _b5, _c;
20035
+ var _a72, _b6, _c;
19999
20036
  const { data, error } = result;
20000
20037
  if (error) {
20001
20038
  throw error;
20002
20039
  }
20003
- if (!((_a65 = data.session) === null || _a65 === void 0 ? void 0 : _a65.access_token) && !this.hasCustomAuthorizationHeader) {
20040
+ if (!((_a72 = data.session) === null || _a72 === void 0 ? void 0 : _a72.access_token) && !this.hasCustomAuthorizationHeader) {
20004
20041
  return { data: { user: null }, error: new AuthSessionMissingError() };
20005
20042
  }
20006
20043
  return await _request(this.fetch, "GET", `${this.url}/user`, {
20007
20044
  headers: this.headers,
20008
- jwt: (_c = (_b5 = data.session) === null || _b5 === void 0 ? void 0 : _b5.access_token) !== null && _c !== void 0 ? _c : void 0,
20045
+ jwt: (_c = (_b6 = data.session) === null || _b6 === void 0 ? void 0 : _b6.access_token) !== null && _c !== void 0 ? _c : void 0,
20009
20046
  xform: _userResponse
20010
20047
  });
20011
20048
  });
@@ -20142,13 +20179,13 @@ var GoTrueClient = class _GoTrueClient {
20142
20179
  async _refreshSession(currentSession) {
20143
20180
  try {
20144
20181
  return await this._useSession(async (result) => {
20145
- var _a65;
20182
+ var _a72;
20146
20183
  if (!currentSession) {
20147
20184
  const { data, error: error2 } = result;
20148
20185
  if (error2) {
20149
20186
  throw error2;
20150
20187
  }
20151
- currentSession = (_a65 = data.session) !== null && _a65 !== void 0 ? _a65 : void 0;
20188
+ currentSession = (_a72 = data.session) !== null && _a72 !== void 0 ? _a72 : void 0;
20152
20189
  }
20153
20190
  if (!(currentSession === null || currentSession === void 0 ? void 0 : currentSession.refresh_token)) {
20154
20191
  throw new AuthSessionMissingError();
@@ -20286,12 +20323,12 @@ var GoTrueClient = class _GoTrueClient {
20286
20323
  }
20287
20324
  async _signOut({ scope } = { scope: "global" }) {
20288
20325
  return await this._useSession(async (result) => {
20289
- var _a65;
20326
+ var _a72;
20290
20327
  const { data, error: sessionError } = result;
20291
20328
  if (sessionError) {
20292
20329
  return this._returnResult({ error: sessionError });
20293
20330
  }
20294
- const accessToken = (_a65 = data.session) === null || _a65 === void 0 ? void 0 : _a65.access_token;
20331
+ const accessToken = (_a72 = data.session) === null || _a72 === void 0 ? void 0 : _a72.access_token;
20295
20332
  if (accessToken) {
20296
20333
  const { error } = await this.admin.signOut(accessToken, scope);
20297
20334
  if (error) {
@@ -20329,15 +20366,15 @@ var GoTrueClient = class _GoTrueClient {
20329
20366
  }
20330
20367
  async _emitInitialSession(id) {
20331
20368
  return await this._useSession(async (result) => {
20332
- var _a65, _b5;
20369
+ var _a72, _b6;
20333
20370
  try {
20334
20371
  const { data: { session }, error } = result;
20335
20372
  if (error)
20336
20373
  throw error;
20337
- await ((_a65 = this.stateChangeEmitters.get(id)) === null || _a65 === void 0 ? void 0 : _a65.callback("INITIAL_SESSION", session));
20374
+ await ((_a72 = this.stateChangeEmitters.get(id)) === null || _a72 === void 0 ? void 0 : _a72.callback("INITIAL_SESSION", session));
20338
20375
  this._debug("INITIAL_SESSION", "callback id", id, "session", session);
20339
20376
  } catch (err) {
20340
- await ((_b5 = this.stateChangeEmitters.get(id)) === null || _b5 === void 0 ? void 0 : _b5.callback("INITIAL_SESSION", null));
20377
+ await ((_b6 = this.stateChangeEmitters.get(id)) === null || _b6 === void 0 ? void 0 : _b6.callback("INITIAL_SESSION", null));
20341
20378
  this._debug("INITIAL_SESSION", "callback id", id, "error", err);
20342
20379
  console.error(err);
20343
20380
  }
@@ -20385,12 +20422,12 @@ var GoTrueClient = class _GoTrueClient {
20385
20422
  * Gets all the identities linked to a user.
20386
20423
  */
20387
20424
  async getUserIdentities() {
20388
- var _a65;
20425
+ var _a72;
20389
20426
  try {
20390
20427
  const { data, error } = await this.getUser();
20391
20428
  if (error)
20392
20429
  throw error;
20393
- return this._returnResult({ data: { identities: (_a65 = data.user.identities) !== null && _a65 !== void 0 ? _a65 : [] }, error: null });
20430
+ return this._returnResult({ data: { identities: (_a72 = data.user.identities) !== null && _a72 !== void 0 ? _a72 : [] }, error: null });
20394
20431
  } catch (error) {
20395
20432
  if (isAuthError(error)) {
20396
20433
  return this._returnResult({ data: null, error });
@@ -20405,16 +20442,16 @@ var GoTrueClient = class _GoTrueClient {
20405
20442
  return this.linkIdentityOAuth(credentials);
20406
20443
  }
20407
20444
  async linkIdentityOAuth(credentials) {
20408
- var _a65;
20445
+ var _a72;
20409
20446
  try {
20410
20447
  const { data, error } = await this._useSession(async (result) => {
20411
- var _a66, _b5, _c, _d, _e;
20448
+ var _a73, _b6, _c, _d, _e;
20412
20449
  const { data: data2, error: error2 } = result;
20413
20450
  if (error2)
20414
20451
  throw error2;
20415
20452
  const url = await this._getUrlForProvider(`${this.url}/user/identities/authorize`, credentials.provider, {
20416
- redirectTo: (_a66 = credentials.options) === null || _a66 === void 0 ? void 0 : _a66.redirectTo,
20417
- scopes: (_b5 = credentials.options) === null || _b5 === void 0 ? void 0 : _b5.scopes,
20453
+ redirectTo: (_a73 = credentials.options) === null || _a73 === void 0 ? void 0 : _a73.redirectTo,
20454
+ scopes: (_b6 = credentials.options) === null || _b6 === void 0 ? void 0 : _b6.scopes,
20418
20455
  queryParams: (_c = credentials.options) === null || _c === void 0 ? void 0 : _c.queryParams,
20419
20456
  skipBrowserRedirect: true
20420
20457
  });
@@ -20425,7 +20462,7 @@ var GoTrueClient = class _GoTrueClient {
20425
20462
  });
20426
20463
  if (error)
20427
20464
  throw error;
20428
- if (isBrowser() && !((_a65 = credentials.options) === null || _a65 === void 0 ? void 0 : _a65.skipBrowserRedirect)) {
20465
+ if (isBrowser() && !((_a72 = credentials.options) === null || _a72 === void 0 ? void 0 : _a72.skipBrowserRedirect)) {
20429
20466
  window.location.assign(data === null || data === void 0 ? void 0 : data.url);
20430
20467
  }
20431
20468
  return this._returnResult({
@@ -20441,7 +20478,7 @@ var GoTrueClient = class _GoTrueClient {
20441
20478
  }
20442
20479
  async linkIdentityIdToken(credentials) {
20443
20480
  return await this._useSession(async (result) => {
20444
- var _a65;
20481
+ var _a72;
20445
20482
  try {
20446
20483
  const { error: sessionError, data: { session } } = result;
20447
20484
  if (sessionError)
@@ -20449,7 +20486,7 @@ var GoTrueClient = class _GoTrueClient {
20449
20486
  const { options, provider, token, access_token, nonce } = credentials;
20450
20487
  const res = await _request(this.fetch, "POST", `${this.url}/token?grant_type=id_token`, {
20451
20488
  headers: this.headers,
20452
- jwt: (_a65 = session === null || session === void 0 ? void 0 : session.access_token) !== null && _a65 !== void 0 ? _a65 : void 0,
20489
+ jwt: (_a72 = session === null || session === void 0 ? void 0 : session.access_token) !== null && _a72 !== void 0 ? _a72 : void 0,
20453
20490
  body: {
20454
20491
  provider,
20455
20492
  id_token: token,
@@ -20489,14 +20526,14 @@ var GoTrueClient = class _GoTrueClient {
20489
20526
  async unlinkIdentity(identity) {
20490
20527
  try {
20491
20528
  return await this._useSession(async (result) => {
20492
- var _a65, _b5;
20529
+ var _a72, _b6;
20493
20530
  const { data, error } = result;
20494
20531
  if (error) {
20495
20532
  throw error;
20496
20533
  }
20497
20534
  return await _request(this.fetch, "DELETE", `${this.url}/user/identities/${identity.identity_id}`, {
20498
20535
  headers: this.headers,
20499
- jwt: (_b5 = (_a65 = data.session) === null || _a65 === void 0 ? void 0 : _a65.access_token) !== null && _b5 !== void 0 ? _b5 : void 0
20536
+ jwt: (_b6 = (_a72 = data.session) === null || _a72 === void 0 ? void 0 : _a72.access_token) !== null && _b6 !== void 0 ? _b6 : void 0
20500
20537
  });
20501
20538
  });
20502
20539
  } catch (error) {
@@ -20561,7 +20598,7 @@ var GoTrueClient = class _GoTrueClient {
20561
20598
  * Note: this method is async to accommodate for AsyncStorage e.g. in React native.
20562
20599
  */
20563
20600
  async _recoverAndRefresh() {
20564
- var _a65, _b5;
20601
+ var _a72, _b6;
20565
20602
  const debugName = "#_recoverAndRefresh()";
20566
20603
  this._debug(debugName, "begin");
20567
20604
  try {
@@ -20572,7 +20609,7 @@ var GoTrueClient = class _GoTrueClient {
20572
20609
  maybeUser = { user: currentSession.user };
20573
20610
  await setItemAsync(this.userStorage, this.storageKey + "-user", maybeUser);
20574
20611
  }
20575
- currentSession.user = (_a65 = maybeUser === null || maybeUser === void 0 ? void 0 : maybeUser.user) !== null && _a65 !== void 0 ? _a65 : userNotAvailableProxy();
20612
+ currentSession.user = (_a72 = maybeUser === null || maybeUser === void 0 ? void 0 : maybeUser.user) !== null && _a72 !== void 0 ? _a72 : userNotAvailableProxy();
20576
20613
  } else if (currentSession && !currentSession.user) {
20577
20614
  if (!currentSession.user) {
20578
20615
  const separateUser = await getItemAsync(this.storage, this.storageKey + "-user");
@@ -20593,7 +20630,7 @@ var GoTrueClient = class _GoTrueClient {
20593
20630
  }
20594
20631
  return;
20595
20632
  }
20596
- const expiresWithMargin = ((_b5 = currentSession.expires_at) !== null && _b5 !== void 0 ? _b5 : Infinity) * 1e3 - Date.now() < EXPIRY_MARGIN_MS;
20633
+ const expiresWithMargin = ((_b6 = currentSession.expires_at) !== null && _b6 !== void 0 ? _b6 : Infinity) * 1e3 - Date.now() < EXPIRY_MARGIN_MS;
20597
20634
  this._debug(debugName, `session has${expiresWithMargin ? "" : " not"} expired with margin of ${EXPIRY_MARGIN_MS}s`);
20598
20635
  if (expiresWithMargin) {
20599
20636
  if (this.autoRefreshToken && currentSession.refresh_token) {
@@ -20632,7 +20669,7 @@ var GoTrueClient = class _GoTrueClient {
20632
20669
  }
20633
20670
  }
20634
20671
  async _callRefreshToken(refreshToken) {
20635
- var _a65, _b5;
20672
+ var _a72, _b6;
20636
20673
  if (!refreshToken) {
20637
20674
  throw new AuthSessionMissingError();
20638
20675
  }
@@ -20660,10 +20697,10 @@ var GoTrueClient = class _GoTrueClient {
20660
20697
  if (!isAuthRetryableFetchError(error)) {
20661
20698
  await this._removeSession();
20662
20699
  }
20663
- (_a65 = this.refreshingDeferred) === null || _a65 === void 0 ? void 0 : _a65.resolve(result);
20700
+ (_a72 = this.refreshingDeferred) === null || _a72 === void 0 ? void 0 : _a72.resolve(result);
20664
20701
  return result;
20665
20702
  }
20666
- (_b5 = this.refreshingDeferred) === null || _b5 === void 0 ? void 0 : _b5.reject(error);
20703
+ (_b6 = this.refreshingDeferred) === null || _b6 === void 0 ? void 0 : _b6.reject(error);
20667
20704
  throw error;
20668
20705
  } finally {
20669
20706
  this.refreshingDeferred = null;
@@ -20949,14 +20986,14 @@ var GoTrueClient = class _GoTrueClient {
20949
20986
  async _unenroll(params) {
20950
20987
  try {
20951
20988
  return await this._useSession(async (result) => {
20952
- var _a65;
20989
+ var _a72;
20953
20990
  const { data: sessionData, error: sessionError } = result;
20954
20991
  if (sessionError) {
20955
20992
  return this._returnResult({ data: null, error: sessionError });
20956
20993
  }
20957
20994
  return await _request(this.fetch, "DELETE", `${this.url}/factors/${params.factorId}`, {
20958
20995
  headers: this.headers,
20959
- jwt: (_a65 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a65 === void 0 ? void 0 : _a65.access_token
20996
+ jwt: (_a72 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a72 === void 0 ? void 0 : _a72.access_token
20960
20997
  });
20961
20998
  });
20962
20999
  } catch (error) {
@@ -20969,7 +21006,7 @@ var GoTrueClient = class _GoTrueClient {
20969
21006
  async _enroll(params) {
20970
21007
  try {
20971
21008
  return await this._useSession(async (result) => {
20972
- var _a65, _b5;
21009
+ var _a72, _b6;
20973
21010
  const { data: sessionData, error: sessionError } = result;
20974
21011
  if (sessionError) {
20975
21012
  return this._returnResult({ data: null, error: sessionError });
@@ -20978,12 +21015,12 @@ var GoTrueClient = class _GoTrueClient {
20978
21015
  const { data, error } = await _request(this.fetch, "POST", `${this.url}/factors`, {
20979
21016
  body,
20980
21017
  headers: this.headers,
20981
- jwt: (_a65 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a65 === void 0 ? void 0 : _a65.access_token
21018
+ jwt: (_a72 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a72 === void 0 ? void 0 : _a72.access_token
20982
21019
  });
20983
21020
  if (error) {
20984
21021
  return this._returnResult({ data: null, error });
20985
21022
  }
20986
- 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)) {
21023
+ 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)) {
20987
21024
  data.totp.qr_code = `data:image/svg+xml;utf-8,${data.totp.qr_code}`;
20988
21025
  }
20989
21026
  return this._returnResult({ data, error: null });
@@ -20999,7 +21036,7 @@ var GoTrueClient = class _GoTrueClient {
20999
21036
  return this._acquireLock(this.lockAcquireTimeout, async () => {
21000
21037
  try {
21001
21038
  return await this._useSession(async (result) => {
21002
- var _a65;
21039
+ var _a72;
21003
21040
  const { data: sessionData, error: sessionError } = result;
21004
21041
  if (sessionError) {
21005
21042
  return this._returnResult({ data: null, error: sessionError });
@@ -21010,7 +21047,7 @@ var GoTrueClient = class _GoTrueClient {
21010
21047
  const { data, error } = await _request(this.fetch, "POST", `${this.url}/factors/${params.factorId}/verify`, {
21011
21048
  body,
21012
21049
  headers: this.headers,
21013
- jwt: (_a65 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a65 === void 0 ? void 0 : _a65.access_token
21050
+ jwt: (_a72 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a72 === void 0 ? void 0 : _a72.access_token
21014
21051
  });
21015
21052
  if (error) {
21016
21053
  return this._returnResult({ data: null, error });
@@ -21031,7 +21068,7 @@ var GoTrueClient = class _GoTrueClient {
21031
21068
  return this._acquireLock(this.lockAcquireTimeout, async () => {
21032
21069
  try {
21033
21070
  return await this._useSession(async (result) => {
21034
- var _a65;
21071
+ var _a72;
21035
21072
  const { data: sessionData, error: sessionError } = result;
21036
21073
  if (sessionError) {
21037
21074
  return this._returnResult({ data: null, error: sessionError });
@@ -21039,7 +21076,7 @@ var GoTrueClient = class _GoTrueClient {
21039
21076
  const response = await _request(this.fetch, "POST", `${this.url}/factors/${params.factorId}/challenge`, {
21040
21077
  body: params,
21041
21078
  headers: this.headers,
21042
- jwt: (_a65 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a65 === void 0 ? void 0 : _a65.access_token
21079
+ jwt: (_a72 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a72 === void 0 ? void 0 : _a72.access_token
21043
21080
  });
21044
21081
  if (response.error) {
21045
21082
  return response;
@@ -21089,7 +21126,7 @@ var GoTrueClient = class _GoTrueClient {
21089
21126
  * {@see GoTrueMFAApi#listFactors}
21090
21127
  */
21091
21128
  async _listFactors() {
21092
- var _a65;
21129
+ var _a72;
21093
21130
  const { data: { user }, error: userError } = await this.getUser();
21094
21131
  if (userError) {
21095
21132
  return { data: null, error: userError };
@@ -21100,7 +21137,7 @@ var GoTrueClient = class _GoTrueClient {
21100
21137
  totp: [],
21101
21138
  webauthn: []
21102
21139
  };
21103
- for (const factor of (_a65 = user === null || user === void 0 ? void 0 : user.factors) !== null && _a65 !== void 0 ? _a65 : []) {
21140
+ for (const factor of (_a72 = user === null || user === void 0 ? void 0 : user.factors) !== null && _a72 !== void 0 ? _a72 : []) {
21104
21141
  data.all.push(factor);
21105
21142
  if (factor.status === "verified") {
21106
21143
  ;
@@ -21116,7 +21153,7 @@ var GoTrueClient = class _GoTrueClient {
21116
21153
  * {@see GoTrueMFAApi#getAuthenticatorAssuranceLevel}
21117
21154
  */
21118
21155
  async _getAuthenticatorAssuranceLevel() {
21119
- var _a65, _b5;
21156
+ var _a72, _b6;
21120
21157
  const { data: { session }, error: sessionError } = await this.getSession();
21121
21158
  if (sessionError) {
21122
21159
  return this._returnResult({ data: null, error: sessionError });
@@ -21133,7 +21170,7 @@ var GoTrueClient = class _GoTrueClient {
21133
21170
  currentLevel = payload.aal;
21134
21171
  }
21135
21172
  let nextLevel = currentLevel;
21136
- const verifiedFactors = (_b5 = (_a65 = session.user.factors) === null || _a65 === void 0 ? void 0 : _a65.filter((factor) => factor.status === "verified")) !== null && _b5 !== void 0 ? _b5 : [];
21173
+ const verifiedFactors = (_b6 = (_a72 = session.user.factors) === null || _a72 === void 0 ? void 0 : _a72.filter((factor) => factor.status === "verified")) !== null && _b6 !== void 0 ? _b6 : [];
21137
21174
  if (verifiedFactors.length > 0) {
21138
21175
  nextLevel = "aal2";
21139
21176
  }
@@ -21739,10 +21776,10 @@ if (shouldShowDeprecationWarning()) console.warn("\u26A0\uFE0F Node.js 18 and b
21739
21776
  var cachedStargate = null;
21740
21777
  var cachedPublic = null;
21741
21778
  function getSupabase() {
21742
- var _a65;
21779
+ var _a72;
21743
21780
  if (cachedStargate) return cachedStargate;
21744
21781
  const url = getRuntimeEnv("VITE_SUPABASE_URL");
21745
- const anon = (_a65 = getRuntimeEnv("VITE_SUPABASE_ANON_KEY")) != null ? _a65 : getRuntimeEnv("VITE_SUPABASE_PUBLISHABLE_KEY");
21782
+ const anon = (_a72 = getRuntimeEnv("VITE_SUPABASE_ANON_KEY")) != null ? _a72 : getRuntimeEnv("VITE_SUPABASE_PUBLISHABLE_KEY");
21746
21783
  const schema = getRuntimeEnvOr("VITE_SUPABASE_SCHEMA", "public");
21747
21784
  if (!url || !anon) {
21748
21785
  if (isRuntimeDev()) {
@@ -21760,10 +21797,10 @@ function getSupabase() {
21760
21797
  return cachedStargate;
21761
21798
  }
21762
21799
  function getSupabasePublic() {
21763
- var _a65;
21800
+ var _a72;
21764
21801
  if (cachedPublic) return cachedPublic;
21765
21802
  const url = getRuntimeEnv("VITE_SUPABASE_URL");
21766
- const anon = (_a65 = getRuntimeEnv("VITE_SUPABASE_ANON_KEY")) != null ? _a65 : getRuntimeEnv("VITE_SUPABASE_PUBLISHABLE_KEY");
21803
+ const anon = (_a72 = getRuntimeEnv("VITE_SUPABASE_ANON_KEY")) != null ? _a72 : getRuntimeEnv("VITE_SUPABASE_PUBLISHABLE_KEY");
21767
21804
  if (!url || !anon) {
21768
21805
  if (isRuntimeDev()) {
21769
21806
  console.log("[supabase] getSupabasePublic: env faltando", { hasUrl: !!url, hasAnon: !!anon });
@@ -21838,15 +21875,15 @@ var Toaster = ({ theme, ...props }) => {
21838
21875
  // src/lib/accountsAuth.ts
21839
21876
  var normalizeBaseUrl2 = (value) => value.replace(/\/+$/, "");
21840
21877
  var getAccountsConfig = () => {
21841
- var _a65, _b5, _c;
21878
+ var _a72, _b6, _c;
21842
21879
  const baseUrl = normalizeBaseUrl2(
21843
- (_a65 = getRuntimeEnv("VITE_ACCOUNTS_BASE_URL")) != null ? _a65 : "https://accounts.cupcode.com.br"
21880
+ (_a72 = getRuntimeEnv("VITE_ACCOUNTS_BASE_URL")) != null ? _a72 : "https://accounts.cupcode.com.br"
21844
21881
  );
21845
21882
  const clientId = getRuntimeEnv("VITE_ACCOUNTS_CLIENT_ID");
21846
21883
  if (!clientId) {
21847
21884
  throw new Error("VITE_ACCOUNTS_CLIENT_ID \xE9 obrigat\xF3rio para login.");
21848
21885
  }
21849
- const redirectUri = (_b5 = getRuntimeEnv("VITE_ACCOUNTS_REDIRECT_URI")) != null ? _b5 : `${window.location.origin}/auth/callback`;
21886
+ const redirectUri = (_b6 = getRuntimeEnv("VITE_ACCOUNTS_REDIRECT_URI")) != null ? _b6 : `${window.location.origin}/auth/callback`;
21850
21887
  return {
21851
21888
  baseUrl,
21852
21889
  clientId,
@@ -21861,7 +21898,7 @@ var getAccountsConfig = () => {
21861
21898
  };
21862
21899
  var cachedDiscovery = null;
21863
21900
  var resolveOidcEndpoints = async (config) => {
21864
- var _a65, _b5, _c, _d, _e, _f;
21901
+ var _a72, _b6, _c, _d, _e, _f;
21865
21902
  if (config.authUrl && config.tokenUrl) {
21866
21903
  return {
21867
21904
  authUrl: config.authUrl,
@@ -21871,8 +21908,8 @@ var resolveOidcEndpoints = async (config) => {
21871
21908
  }
21872
21909
  if (cachedDiscovery) {
21873
21910
  return {
21874
- authUrl: (_a65 = cachedDiscovery.authorization_endpoint) != null ? _a65 : config.authUrl,
21875
- tokenUrl: (_b5 = cachedDiscovery.token_endpoint) != null ? _b5 : config.tokenUrl,
21911
+ authUrl: (_a72 = cachedDiscovery.authorization_endpoint) != null ? _a72 : config.authUrl,
21912
+ tokenUrl: (_b6 = cachedDiscovery.token_endpoint) != null ? _b6 : config.tokenUrl,
21876
21913
  logoutUrl: (_c = cachedDiscovery.end_session_endpoint) != null ? _c : config.logoutUrl
21877
21914
  };
21878
21915
  }
@@ -22229,12 +22266,12 @@ var resolveCurrentUserId = (user) => {
22229
22266
  return null;
22230
22267
  };
22231
22268
  var resolveUserIdFromClaims = (claims) => {
22232
- var _a65, _b5, _c, _d, _e;
22233
- 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"]);
22269
+ var _a72, _b6, _c, _d, _e;
22270
+ 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"]);
22234
22271
  };
22235
22272
  var resolveEmailFromClaims = (claims) => {
22236
- var _a65, _b5;
22237
- const candidate = (_b5 = (_a65 = toStringOrUndefined(claims.email)) != null ? _a65 : toStringOrUndefined(claims["https://cupcode.com/email"])) != null ? _b5 : toStringOrUndefined(claims.preferred_username);
22273
+ var _a72, _b6;
22274
+ const candidate = (_b6 = (_a72 = toStringOrUndefined(claims.email)) != null ? _a72 : toStringOrUndefined(claims["https://cupcode.com/email"])) != null ? _b6 : toStringOrUndefined(claims.preferred_username);
22238
22275
  if (!candidate || !candidate.includes("@")) return void 0;
22239
22276
  return candidate.toLowerCase();
22240
22277
  };
@@ -22245,18 +22282,7 @@ var formatMessageTime = (rawTimestamp) => {
22245
22282
  return parsed.toLocaleTimeString("pt-BR", { hour: "2-digit", minute: "2-digit" });
22246
22283
  };
22247
22284
  var resolveChatAvatarUrl = (value) => {
22248
- const raw = toStringOrUndefined(value);
22249
- if (!raw) return void 0;
22250
- if (raw.startsWith("http://") || raw.startsWith("https://") || raw.startsWith("data:") || raw.startsWith("blob:")) {
22251
- const parsedId2 = parseAssetId(raw);
22252
- if (parsedId2) {
22253
- return buildTelescupImageURL({ id: parsedId2, width: 72, height: 72, fit: "cover", format: "avif", quality: 70 });
22254
- }
22255
- return raw;
22256
- }
22257
- const parsedId = parseAssetId(raw);
22258
- if (!parsedId) return void 0;
22259
- return buildTelescupImageURL({ id: parsedId, width: 72, height: 72, fit: "cover", format: "avif", quality: 70 });
22285
+ return resolveTelescupImageURL(value, { width: 72, height: 72, fit: "cover", format: "avif", quality: 70 });
22260
22286
  };
22261
22287
  var isGenericRecord = (value) => typeof value === "object" && value !== null;
22262
22288
  var buildExternalUrl = (baseUrl, target) => {
@@ -22310,8 +22336,8 @@ var parseRecentActivityItems = (payload) => {
22310
22336
  return [];
22311
22337
  };
22312
22338
  return toRows(payload).map((item, index) => {
22313
- var _a65, _b5, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
22314
- const id = (_b5 = (_a65 = toStringOrUndefined(item.id)) != null ? _a65 : toStringOrUndefined(item.event_id)) != null ? _b5 : `accounts-activity-${index}`;
22339
+ var _a72, _b6, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
22340
+ const id = (_b6 = (_a72 = toStringOrUndefined(item.id)) != null ? _a72 : toStringOrUndefined(item.event_id)) != null ? _b6 : `accounts-activity-${index}`;
22315
22341
  const title = (_e = (_d = (_c = toStringOrUndefined(item.title)) != null ? _c : toStringOrUndefined(item.action)) != null ? _d : toStringOrUndefined(item.event)) != null ? _e : toStringOrUndefined(item.type);
22316
22342
  if (!title) return null;
22317
22343
  const description = (_h = (_g = (_f = toStringOrUndefined(item.description)) != null ? _f : toStringOrUndefined(item.details)) != null ? _g : toStringOrUndefined(item.message)) != null ? _h : toStringOrUndefined(item.summary);
@@ -22394,9 +22420,9 @@ var dedupeAndSortReactions = (reactions) => {
22394
22420
  });
22395
22421
  };
22396
22422
  var getErrorText = (error) => {
22397
- var _a65, _b5, _c;
22423
+ var _a72, _b6, _c;
22398
22424
  const typed = error;
22399
- 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();
22425
+ 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();
22400
22426
  };
22401
22427
  var isMissingColumnError = (error, column) => {
22402
22428
  const normalized = getErrorText(error);
@@ -22422,13 +22448,13 @@ var isRecoverableLookupError = (error, relationName) => {
22422
22448
  return normalized.includes("schema cache") || normalized.includes("permission denied") || normalized.includes("does not exist") || normalized.includes("could not find");
22423
22449
  };
22424
22450
  var toChatMessage = (row, currentUserId) => {
22425
- var _a65, _b5, _c, _d, _e, _f;
22426
- 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])}`;
22451
+ var _a72, _b6, _c, _d, _e, _f;
22452
+ 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])}`;
22427
22453
  const senderId = toStringOrUndefined(row[CHAT_MESSAGES_SENDER_COLUMN]);
22428
22454
  const recipientId = toStringOrUndefined(row[CHAT_MESSAGES_RECIPIENT_COLUMN]);
22429
22455
  const text = toStringOrUndefined(row[CHAT_MESSAGES_TEXT_COLUMN]);
22430
22456
  const createdAt = toStringOrUndefined(row[CHAT_MESSAGES_CREATED_AT_COLUMN]);
22431
- const editedAt = (_b5 = toStringOrUndefined(row[CHAT_MESSAGES_EDITED_AT_COLUMN])) != null ? _b5 : null;
22457
+ const editedAt = (_b6 = toStringOrUndefined(row[CHAT_MESSAGES_EDITED_AT_COLUMN])) != null ? _b6 : null;
22432
22458
  const readAt = (_c = toStringOrUndefined(row[CHAT_MESSAGES_READ_AT_COLUMN])) != null ? _c : null;
22433
22459
  const replyToMessageId = (_d = toStringOrUndefined(row[CHAT_MESSAGES_REPLY_TO_COLUMN])) != null ? _d : null;
22434
22460
  const deletedAt = (_e = toStringOrUndefined(row[CHAT_MESSAGES_DELETED_AT_COLUMN])) != null ? _e : null;
@@ -22463,13 +22489,13 @@ var toChatReaction = (row) => {
22463
22489
  return { id, messageId, userId, emoji, createdAt };
22464
22490
  };
22465
22491
  var toChatMessageLog = (row, messagesById) => {
22466
- var _a65, _b5;
22492
+ var _a72, _b6;
22467
22493
  const id = toStringOrUndefined(row[CHAT_LOGS_ID_COLUMN]);
22468
22494
  const messageId = toStringOrUndefined(row[CHAT_LOGS_MESSAGE_ID_COLUMN]);
22469
22495
  const actorId = toStringOrUndefined(row[CHAT_LOGS_ACTOR_ID_COLUMN]);
22470
22496
  const action = toStringOrUndefined(row[CHAT_LOGS_ACTION_COLUMN]);
22471
- const previousText = (_a65 = toStringOrUndefined(row[CHAT_LOGS_PREVIOUS_TEXT_COLUMN])) != null ? _a65 : null;
22472
- const nextText = (_b5 = toStringOrUndefined(row[CHAT_LOGS_NEXT_TEXT_COLUMN])) != null ? _b5 : null;
22497
+ const previousText = (_a72 = toStringOrUndefined(row[CHAT_LOGS_PREVIOUS_TEXT_COLUMN])) != null ? _a72 : null;
22498
+ const nextText = (_b6 = toStringOrUndefined(row[CHAT_LOGS_NEXT_TEXT_COLUMN])) != null ? _b6 : null;
22473
22499
  const createdAt = toStringOrUndefined(row[CHAT_LOGS_CREATED_AT_COLUMN]);
22474
22500
  if (!id || !messageId || !action || action !== "edit" && action !== "delete") return null;
22475
22501
  const relatedMessage = messagesById.get(messageId);
@@ -22510,7 +22536,7 @@ var MainNavbar = ({
22510
22536
  onOpenAccountClick,
22511
22537
  getAccessToken
22512
22538
  }) => {
22513
- var _a65, _b5, _c;
22539
+ var _a72, _b6, _c;
22514
22540
  const [chatUsers, setChatUsers] = useState13([]);
22515
22541
  const [chatMessages, setChatMessages] = useState13([]);
22516
22542
  const [chatMessageLogs, setChatMessageLogs] = useState13([]);
@@ -22541,19 +22567,19 @@ var MainNavbar = ({
22541
22567
  return "/";
22542
22568
  }, [pathname]);
22543
22569
  const currentUserId = useMemo8(() => {
22544
- var _a66;
22545
- return (_a66 = resolveCurrentUserId(authUser)) != null ? _a66 : tokenDerivedUserId;
22570
+ var _a73;
22571
+ return (_a73 = resolveCurrentUserId(authUser)) != null ? _a73 : tokenDerivedUserId;
22546
22572
  }, [authUser, tokenDerivedUserId]);
22547
22573
  const authEmail = useMemo8(
22548
22574
  () => {
22549
- var _a66, _b6;
22550
- return (_b6 = (_a66 = toStringOrUndefined(authUser == null ? void 0 : authUser.email)) == null ? void 0 : _a66.toLowerCase()) != null ? _b6 : tokenDerivedEmail;
22575
+ var _a73, _b7;
22576
+ return (_b7 = (_a73 = toStringOrUndefined(authUser == null ? void 0 : authUser.email)) == null ? void 0 : _a73.toLowerCase()) != null ? _b7 : tokenDerivedEmail;
22551
22577
  },
22552
22578
  [authUser == null ? void 0 : authUser.email, tokenDerivedEmail]
22553
22579
  );
22554
22580
  const isChatSuperAdmin = useMemo8(() => {
22555
- var _a66, _b6;
22556
- const roleTokens = `${(_a66 = authUser == null ? void 0 : authUser.role) != null ? _a66 : ""} ${(_b6 = authUser == null ? void 0 : authUser.jobTitle) != null ? _b6 : ""}`.toLowerCase();
22581
+ var _a73, _b7;
22582
+ const roleTokens = `${(_a73 = authUser == null ? void 0 : authUser.role) != null ? _a73 : ""} ${(_b7 = authUser == null ? void 0 : authUser.jobTitle) != null ? _b7 : ""}`.toLowerCase();
22557
22583
  return roleTokens.includes("superadmin") || roleTokens.includes("super admin");
22558
22584
  }, [authUser == null ? void 0 : authUser.jobTitle, authUser == null ? void 0 : authUser.role]);
22559
22585
  const resolvedTelescupBaseUrl = useMemo8(() => {
@@ -22562,7 +22588,7 @@ var MainNavbar = ({
22562
22588
  }
22563
22589
  return TELESCUP_BASE_URL_FALLBACK;
22564
22590
  }, []);
22565
- const resolvedProfileAvatarUrl = (_b5 = (_a65 = resolveChatAvatarUrl(persistedProfileAvatarValue)) != null ? _a65 : authUser == null ? void 0 : authUser.picture) != null ? _b5 : void 0;
22591
+ const resolvedProfileAvatarUrl = (_b6 = (_a72 = resolveChatAvatarUrl(persistedProfileAvatarValue)) != null ? _a72 : authUser == null ? void 0 : authUser.picture) != null ? _b6 : void 0;
22566
22592
  const effectiveCurrentUserId = resolvedSenderId != null ? resolvedSenderId : currentUserId;
22567
22593
  const hasStoredAccessToken = (() => {
22568
22594
  if (typeof window === "undefined") return false;
@@ -22600,7 +22626,7 @@ var MainNavbar = ({
22600
22626
  }
22601
22627
  let canceled = false;
22602
22628
  const resolveIdentityFromToken = async () => {
22603
- var _a66, _b6;
22629
+ var _a73, _b7;
22604
22630
  try {
22605
22631
  let token = null;
22606
22632
  if (typeof window !== "undefined") {
@@ -22620,9 +22646,9 @@ var MainNavbar = ({
22620
22646
  }
22621
22647
  return;
22622
22648
  }
22623
- const claims = (_a66 = decodeJwt(token)) != null ? _a66 : {};
22649
+ const claims = (_a73 = decodeJwt(token)) != null ? _a73 : {};
22624
22650
  if (canceled) return;
22625
- setTokenDerivedUserId((_b6 = resolveUserIdFromClaims(claims)) != null ? _b6 : null);
22651
+ setTokenDerivedUserId((_b7 = resolveUserIdFromClaims(claims)) != null ? _b7 : null);
22626
22652
  setTokenDerivedEmail(resolveEmailFromClaims(claims));
22627
22653
  } catch (error) {
22628
22654
  if (isRuntimeDev()) {
@@ -22665,7 +22691,7 @@ var MainNavbar = ({
22665
22691
  );
22666
22692
  const warnings = [];
22667
22693
  const runLookup = async (kind, value, columns) => {
22668
- var _a66, _b6, _c2;
22694
+ var _a73, _b7, _c2;
22669
22695
  for (const tableName of CHAT_USERS_LOOKUP_TABLES) {
22670
22696
  for (const columnName of columns) {
22671
22697
  if (!columnName) continue;
@@ -22674,10 +22700,10 @@ var MainNavbar = ({
22674
22700
  const lookupError = response.error;
22675
22701
  if (lookupError) {
22676
22702
  if (isRecoverableLookupError(lookupError, tableName)) {
22677
- warnings.push(`${tableName}.${columnName}: ${(_a66 = lookupError.message) != null ? _a66 : "falha de lookup"}`);
22703
+ warnings.push(`${tableName}.${columnName}: ${(_a73 = lookupError.message) != null ? _a73 : "falha de lookup"}`);
22678
22704
  continue;
22679
22705
  }
22680
- warnings.push(`${tableName}.${columnName}: ${(_b6 = lookupError.message) != null ? _b6 : "falha de lookup"}`);
22706
+ warnings.push(`${tableName}.${columnName}: ${(_b7 = lookupError.message) != null ? _b7 : "falha de lookup"}`);
22681
22707
  continue;
22682
22708
  }
22683
22709
  const row2 = (_c2 = response.data) == null ? void 0 : _c2[0];
@@ -22726,7 +22752,7 @@ var MainNavbar = ({
22726
22752
  return sessionStorage.getItem(ACCESS_TOKEN_STORAGE_KEY);
22727
22753
  };
22728
22754
  const loadAccountsContext = async () => {
22729
- var _a66, _b6, _c2, _d, _e, _f, _g;
22755
+ var _a73, _b7, _c2, _d, _e, _f, _g;
22730
22756
  setIsAccountsActivityLoading(true);
22731
22757
  try {
22732
22758
  const token = await resolveAccountsToken();
@@ -22736,9 +22762,9 @@ var MainNavbar = ({
22736
22762
  }
22737
22763
  return;
22738
22764
  }
22739
- const claims = (_a66 = decodeJwt(token)) != null ? _a66 : {};
22765
+ const claims = (_a73 = decodeJwt(token)) != null ? _a73 : {};
22740
22766
  const languageFromToken = normalizeMenuLanguage(
22741
- (_d = (_c2 = (_b6 = claims.locale) != null ? _b6 : claims.lang) != null ? _c2 : claims.language) != null ? _d : claims["https://cupcode.com/locale"]
22767
+ (_d = (_c2 = (_b7 = claims.locale) != null ? _b7 : claims.lang) != null ? _c2 : claims.language) != null ? _d : claims["https://cupcode.com/locale"]
22742
22768
  );
22743
22769
  if (!canceled) {
22744
22770
  setAccountsLanguage(languageFromToken);
@@ -22824,11 +22850,11 @@ var MainNavbar = ({
22824
22850
  }
22825
22851
  let canceled = false;
22826
22852
  const loadChatData = async () => {
22827
- var _a66, _b6, _c2, _d, _e, _f, _g, _h, _i;
22853
+ var _a73, _b7, _c2, _d, _e, _f, _g, _h, _i;
22828
22854
  setIsChatLoading(true);
22829
22855
  setChatError(null);
22830
22856
  const fetchFirstAvailableTable = async (tableNames) => {
22831
- var _a67;
22857
+ var _a74;
22832
22858
  let lastError = null;
22833
22859
  for (const tableName of tableNames) {
22834
22860
  const response = await supabase.from(tableName).select("*");
@@ -22850,7 +22876,7 @@ var MainNavbar = ({
22850
22876
  }
22851
22877
  }
22852
22878
  return {
22853
- tableName: (_a67 = tableNames[0]) != null ? _a67 : null,
22879
+ tableName: (_a74 = tableNames[0]) != null ? _a74 : null,
22854
22880
  data: null,
22855
22881
  error: lastError
22856
22882
  };
@@ -22952,7 +22978,7 @@ var MainNavbar = ({
22952
22978
  console.warn("[chat] Falha ao carregar presen\xE7a:", presenceResponse.error.message);
22953
22979
  }
22954
22980
  } else {
22955
- (_a66 = presenceResponse.data) == null ? void 0 : _a66.forEach((row) => {
22981
+ (_a73 = presenceResponse.data) == null ? void 0 : _a73.forEach((row) => {
22956
22982
  const userId = readFirstRecordString(row, [USER_PRESENCE_USER_ID_COLUMN, "user_id", "id"]);
22957
22983
  if (!userId) return;
22958
22984
  const statusValue = readFirstRecordString(row, [USER_PRESENCE_STATUS_COLUMN, "status", "presence_status"]);
@@ -22966,7 +22992,7 @@ var MainNavbar = ({
22966
22992
  console.warn("[chat] Falha ao carregar profiles para enriquecimento:", profilesResponse.error.message);
22967
22993
  }
22968
22994
  } else {
22969
- (_b6 = profilesResponse.data) == null ? void 0 : _b6.forEach((row) => {
22995
+ (_b7 = profilesResponse.data) == null ? void 0 : _b7.forEach((row) => {
22970
22996
  const id = readFirstRecordString(row, [...CHAT_USERS_LOOKUP_ID_COLUMNS, "id", "user_id"]);
22971
22997
  const email = readFirstRecordString(row, [...CHAT_USERS_LOOKUP_EMAIL_COLUMNS, "email"]);
22972
22998
  if (id) profileById.set(id, row);
@@ -22994,13 +23020,13 @@ var MainNavbar = ({
22994
23020
  }
22995
23021
  } else {
22996
23022
  (_e = usersResponse.data) == null ? void 0 : _e.forEach((row) => {
22997
- var _a67, _b7, _c3, _d2, _e2, _f2, _g2, _h2;
23023
+ var _a74, _b8, _c3, _d2, _e2, _f2, _g2, _h2;
22998
23024
  const id = readFirstRecordString(row, [...CHAT_USERS_LOOKUP_ID_COLUMNS, "id", "user_id"]);
22999
23025
  if (!id || id === effectiveCurrentUserId) return;
23000
23026
  const rowEmail = readFirstRecordString(row, [...CHAT_USERS_LOOKUP_EMAIL_COLUMNS, "email"]);
23001
- const profile = (_a67 = profileById.get(id)) != null ? _a67 : rowEmail ? profileByEmail.get(rowEmail.toLowerCase()) : void 0;
23027
+ const profile = (_a74 = profileById.get(id)) != null ? _a74 : rowEmail ? profileByEmail.get(rowEmail.toLowerCase()) : void 0;
23002
23028
  const email = rowEmail != null ? rowEmail : readFirstRecordString(profile, [CHAT_USERS_UPDATE_EMAIL_COLUMN, CHAT_USERS_EMAIL_COLUMN, "email"]);
23003
- const rawUsername = (_b7 = readFirstRecordString(row, [CHAT_USERS_USERNAME_COLUMN, "username", "user_name"])) != null ? _b7 : readFirstRecordString(profile, [CHAT_USERS_USERNAME_COLUMN, "username", "user_name"]);
23029
+ const rawUsername = (_b8 = readFirstRecordString(row, [CHAT_USERS_USERNAME_COLUMN, "username", "user_name"])) != null ? _b8 : readFirstRecordString(profile, [CHAT_USERS_USERNAME_COLUMN, "username", "user_name"]);
23004
23030
  const username = buildHandle2(rawUsername, email);
23005
23031
  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"]);
23006
23032
  const name = resolveReadableUserLabel(rawName, rawUsername, email, id);
@@ -23018,7 +23044,7 @@ var MainNavbar = ({
23018
23044
  });
23019
23045
  }
23020
23046
  profileById.forEach((profile, id) => {
23021
- var _a67, _b7;
23047
+ var _a74, _b8;
23022
23048
  if (!id || id === effectiveCurrentUserId || usersMap.has(id)) return;
23023
23049
  const email = readFirstRecordString(profile, [CHAT_USERS_UPDATE_EMAIL_COLUMN, CHAT_USERS_EMAIL_COLUMN, "email"]);
23024
23050
  const rawUsername = readFirstRecordString(profile, [CHAT_USERS_USERNAME_COLUMN, "username", "user_name"]);
@@ -23039,7 +23065,7 @@ var MainNavbar = ({
23039
23065
  email,
23040
23066
  avatarUrl: resolveChatAvatarUrl(avatarValue),
23041
23067
  roleLabel,
23042
- status: (_b7 = (_a67 = presenceMap.get(id)) != null ? _a67 : readPresenceStatusFromRecord(profile)) != null ? _b7 : "offline"
23068
+ status: (_b8 = (_a74 = presenceMap.get(id)) != null ? _a74 : readPresenceStatusFromRecord(profile)) != null ? _b8 : "offline"
23043
23069
  });
23044
23070
  });
23045
23071
  presenceMap.forEach((statusValue, id) => {
@@ -23081,7 +23107,7 @@ var MainNavbar = ({
23081
23107
  );
23082
23108
  setChatMessages(resolvedMessages);
23083
23109
  resolvedMessages.forEach((message) => {
23084
- var _a67, _b7;
23110
+ var _a74, _b8;
23085
23111
  const contactId = message.contactId;
23086
23112
  if (!contactId || contactId === effectiveCurrentUserId || usersMap.has(contactId)) return;
23087
23113
  const profile = profileById.get(contactId);
@@ -23104,7 +23130,7 @@ var MainNavbar = ({
23104
23130
  email,
23105
23131
  avatarUrl: resolveChatAvatarUrl(avatarValue),
23106
23132
  roleLabel,
23107
- status: (_b7 = (_a67 = presenceMap.get(contactId)) != null ? _a67 : readPresenceStatusFromRecord(profile)) != null ? _b7 : "offline"
23133
+ status: (_b8 = (_a74 = presenceMap.get(contactId)) != null ? _a74 : readPresenceStatusFromRecord(profile)) != null ? _b8 : "offline"
23108
23134
  });
23109
23135
  });
23110
23136
  const resolvedUsers = [...usersMap.values()].sort((left, right) => left.name.localeCompare(right.name, "pt-BR"));
@@ -23289,10 +23315,10 @@ var MainNavbar = ({
23289
23315
  const chatUnreadByUser = useMemo8(() => {
23290
23316
  const counters = {};
23291
23317
  chatMessages.forEach((message) => {
23292
- var _a66;
23318
+ var _a73;
23293
23319
  if (message.sender !== "them") return;
23294
23320
  if (message.readAt) return;
23295
- counters[message.contactId] = ((_a66 = counters[message.contactId]) != null ? _a66 : 0) + 1;
23321
+ counters[message.contactId] = ((_a73 = counters[message.contactId]) != null ? _a73 : 0) + 1;
23296
23322
  });
23297
23323
  return counters;
23298
23324
  }, [chatMessages]);
@@ -23340,9 +23366,9 @@ var MainNavbar = ({
23340
23366
  }
23341
23367
  const persistedReadAtByMessageId = /* @__PURE__ */ new Map();
23342
23368
  (data != null ? data : []).forEach((row) => {
23343
- var _a66;
23369
+ var _a73;
23344
23370
  const messageId = toStringOrUndefined(row[CHAT_MESSAGES_ID_COLUMN]);
23345
- const persistedReadAt = (_a66 = toStringOrUndefined(row[CHAT_MESSAGES_READ_AT_COLUMN])) != null ? _a66 : readAt;
23371
+ const persistedReadAt = (_a73 = toStringOrUndefined(row[CHAT_MESSAGES_READ_AT_COLUMN])) != null ? _a73 : readAt;
23346
23372
  if (!messageId) return;
23347
23373
  persistedReadAtByMessageId.set(messageId, persistedReadAt);
23348
23374
  });
@@ -23511,8 +23537,8 @@ var MainNavbar = ({
23511
23537
  (current) => dedupeAndSortMessages(
23512
23538
  current.map(
23513
23539
  (message) => {
23514
- var _a66;
23515
- return message.id === messageId ? { ...message, text: previousText, editedAt: (_a66 = targetMessage.editedAt) != null ? _a66 : null } : message;
23540
+ var _a73;
23541
+ return message.id === messageId ? { ...message, text: previousText, editedAt: (_a73 = targetMessage.editedAt) != null ? _a73 : null } : message;
23516
23542
  }
23517
23543
  )
23518
23544
  )
@@ -23543,13 +23569,13 @@ var MainNavbar = ({
23543
23569
  (current) => dedupeAndSortMessages(
23544
23570
  current.map(
23545
23571
  (message) => {
23546
- var _a66;
23572
+ var _a73;
23547
23573
  return message.id === messageId ? {
23548
23574
  ...message,
23549
23575
  text: CHAT_DELETED_PLACEHOLDER_TEXT2,
23550
23576
  deletedAt,
23551
23577
  deletedBy: effectiveCurrentUserId,
23552
- editedAt: (_a66 = message.editedAt) != null ? _a66 : deletedAt
23578
+ editedAt: (_a73 = message.editedAt) != null ? _a73 : deletedAt
23553
23579
  } : message;
23554
23580
  }
23555
23581
  )
@@ -23733,8 +23759,8 @@ var MainNavbar = ({
23733
23759
  ...item,
23734
23760
  isActive,
23735
23761
  onClick: isAnchor ? item.onClick : (event) => {
23736
- var _a66;
23737
- (_a66 = item.onClick) == null ? void 0 : _a66.call(item, event);
23762
+ var _a73;
23763
+ (_a73 = item.onClick) == null ? void 0 : _a73.call(item, event);
23738
23764
  if (!onNavigate || event.defaultPrevented) return;
23739
23765
  event.preventDefault();
23740
23766
  onNavigate(item.href);
@@ -23776,9 +23802,9 @@ var MainNavbar = ({
23776
23802
  window.open(`${MC_BASE_URL2}/tasks`, "_blank", "noopener,noreferrer");
23777
23803
  };
23778
23804
  const handleChatOpenUserProfile = useCallback6(({ userId }) => {
23779
- var _a66;
23805
+ var _a73;
23780
23806
  if (!userId || typeof window === "undefined") return;
23781
- const baseUrl = ((_a66 = getRuntimeEnv("VITE_ACCOUNTS_BASE_URL")) != null ? _a66 : "https://accounts.cupcode.com.br").replace(
23807
+ const baseUrl = ((_a73 = getRuntimeEnv("VITE_ACCOUNTS_BASE_URL")) != null ? _a73 : "https://accounts.cupcode.com.br").replace(
23782
23808
  /\/+$/,
23783
23809
  ""
23784
23810
  );
@@ -23848,8 +23874,8 @@ var MainNavbar = ({
23848
23874
  );
23849
23875
  const handleProfileAvatarChange = useCallback6(
23850
23876
  async ({ avatarId, avatarUrl }) => {
23851
- var _a66;
23852
- const normalizedAvatarId = (_a66 = parseAssetId(avatarId)) != null ? _a66 : parseAssetId(avatarUrl);
23877
+ var _a73;
23878
+ const normalizedAvatarId = (_a73 = parseAssetId(avatarId)) != null ? _a73 : parseAssetId(avatarUrl);
23853
23879
  if (!normalizedAvatarId) {
23854
23880
  throw new Error("ID da imagem inv\xE1lido.");
23855
23881
  }
@@ -23865,27 +23891,27 @@ var MainNavbar = ({
23865
23891
  );
23866
23892
  const updateErrors = [];
23867
23893
  const isRecoverableUpdateError = (error) => {
23868
- var _a67;
23869
- const message = ((_a67 = error.message) != null ? _a67 : "").toLowerCase();
23894
+ var _a74;
23895
+ const message = ((_a74 = error.message) != null ? _a74 : "").toLowerCase();
23870
23896
  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");
23871
23897
  };
23872
23898
  const isRecoverableLookupError2 = (error) => {
23873
- var _a67;
23874
- const message = ((_a67 = error.message) != null ? _a67 : "").toLowerCase();
23899
+ var _a74;
23900
+ const message = ((_a74 = error.message) != null ? _a74 : "").toLowerCase();
23875
23901
  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");
23876
23902
  };
23877
23903
  const isPermissionDeniedError2 = (error) => {
23878
- var _a67;
23879
- const message = ((_a67 = error.message) != null ? _a67 : "").toLowerCase();
23904
+ var _a74;
23905
+ const message = ((_a74 = error.message) != null ? _a74 : "").toLowerCase();
23880
23906
  return error.code === "42501" || message.includes("permission denied");
23881
23907
  };
23882
23908
  const updateAvatarByUserId = async (userId) => {
23883
- var _a67, _b6, _c2, _d, _e;
23909
+ var _a74, _b7, _c2, _d, _e;
23884
23910
  for (const tableName of updateTargets) {
23885
23911
  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);
23886
23912
  if (!updateWithSelect.error) {
23887
23913
  const rows = updateWithSelect.data;
23888
- const row = (_a67 = rows == null ? void 0 : rows[0]) != null ? _a67 : null;
23914
+ const row = (_a74 = rows == null ? void 0 : rows[0]) != null ? _a74 : null;
23889
23915
  if (row) {
23890
23916
  return row;
23891
23917
  }
@@ -23905,7 +23931,7 @@ var MainNavbar = ({
23905
23931
  throw new Error(`Falha ao atualizar avatar em "${tableName}": ${withoutSelectError.message}`);
23906
23932
  }
23907
23933
  updateErrors.push(
23908
- `${tableName}: ${(_b6 = withoutSelectError.code) != null ? _b6 : "erro"} ${(_c2 = withoutSelectError.message) != null ? _c2 : "falha desconhecida"}`
23934
+ `${tableName}: ${(_b7 = withoutSelectError.code) != null ? _b7 : "erro"} ${(_c2 = withoutSelectError.message) != null ? _c2 : "falha desconhecida"}`
23909
23935
  );
23910
23936
  continue;
23911
23937
  }
@@ -23917,13 +23943,13 @@ var MainNavbar = ({
23917
23943
  return null;
23918
23944
  };
23919
23945
  const resolveUserIdByEmail = async (emailValue) => {
23920
- var _a67;
23946
+ var _a74;
23921
23947
  let lastRecoverableError = null;
23922
23948
  for (const tableName of lookupTargets) {
23923
23949
  const { data, error } = await supabase.from(tableName).select(CHAT_USERS_UPDATE_ID_COLUMN).ilike(CHAT_USERS_UPDATE_EMAIL_COLUMN, emailValue).limit(1);
23924
23950
  if (!error) {
23925
23951
  const rows = data;
23926
- const resolvedId = toStringOrUndefined((_a67 = rows == null ? void 0 : rows[0]) == null ? void 0 : _a67[CHAT_USERS_UPDATE_ID_COLUMN]);
23952
+ const resolvedId = toStringOrUndefined((_a74 = rows == null ? void 0 : rows[0]) == null ? void 0 : _a74[CHAT_USERS_UPDATE_ID_COLUMN]);
23927
23953
  if (resolvedId) {
23928
23954
  return resolvedId;
23929
23955
  }
@@ -24086,7 +24112,7 @@ function ParticleSystem({
24086
24112
  if (particle.y < 0) particle.y = canvas.height;
24087
24113
  if (particle.y > canvas.height) particle.y = 0;
24088
24114
  if (variant === "stars") {
24089
- ctx.fillStyle = `rgba(237, 30, 121, ${particle.opacity})`;
24115
+ ctx.fillStyle = `rgba(151, 90, 182, ${particle.opacity})`;
24090
24116
  ctx.beginPath();
24091
24117
  ctx.arc(particle.x, particle.y, particle.size, 0, Math.PI * 2);
24092
24118
  ctx.fill();
@@ -24097,8 +24123,8 @@ function ParticleSystem({
24097
24123
  particle.x - particle.speedX * 10,
24098
24124
  particle.y - particle.speedY * 10
24099
24125
  );
24100
- gradient.addColorStop(0, `rgba(149, 29, 219, ${particle.opacity})`);
24101
- gradient.addColorStop(1, "rgba(149, 29, 219, 0)");
24126
+ gradient.addColorStop(0, `rgba(124,91,187, ${particle.opacity})`);
24127
+ gradient.addColorStop(1, "rgba(124,91,187, 0)");
24102
24128
  ctx.strokeStyle = gradient;
24103
24129
  ctx.lineWidth = particle.size;
24104
24130
  ctx.beginPath();
@@ -24416,7 +24442,7 @@ var Switch2 = React32.forwardRef(({ className, ...props }, ref) => /* @__PURE__
24416
24442
  "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-cupcode-purple focus-visible:ring-offset-2",
24417
24443
  "focus-visible:ring-offset-background",
24418
24444
  "disabled:cursor-not-allowed disabled:opacity-50",
24419
- "data-[state=checked]:bg-gradient-to-r data-[state=checked]:from-cupcode-pink data-[state=checked]:to-cupcode-purple",
24445
+ "data-[state=checked]:bg-gradient-to-r data-[state=checked]:from-cupcode-hover data-[state=checked]:to-cupcode-purple",
24420
24446
  "data-[state=unchecked]:bg-border",
24421
24447
  className
24422
24448
  ),
@@ -24479,7 +24505,7 @@ var TabsTrigger2 = React33.forwardRef(({ className, ...props }, ref) => /* @__PU
24479
24505
  "relative",
24480
24506
  "data-[state=active]:after:absolute data-[state=active]:after:bottom-0 data-[state=active]:after:left-0",
24481
24507
  "data-[state=active]:after:h-0.5 data-[state=active]:after:w-full",
24482
- "data-[state=active]:after:bg-gradient-to-r data-[state=active]:after:from-cupcode-pink data-[state=active]:after:to-cupcode-purple",
24508
+ "data-[state=active]:after:bg-gradient-to-r data-[state=active]:after:from-cupcode-hover data-[state=active]:after:to-cupcode-purple",
24483
24509
  "data-[state=active]:after:animate-scale-in",
24484
24510
  className
24485
24511
  ),
@@ -24544,10 +24570,10 @@ function isThemeMode(value) {
24544
24570
  return value === "light" || value === "dark";
24545
24571
  }
24546
24572
  function readStoredTheme() {
24547
- var _a65;
24573
+ var _a72;
24548
24574
  if (typeof window === "undefined") return null;
24549
24575
  try {
24550
- const storedTheme = (_a65 = window.localStorage.getItem(THEME_STORAGE_KEY2)) != null ? _a65 : window.localStorage.getItem("theme");
24576
+ const storedTheme = (_a72 = window.localStorage.getItem(THEME_STORAGE_KEY2)) != null ? _a72 : window.localStorage.getItem("theme");
24551
24577
  return isThemeMode(storedTheme) ? storedTheme : null;
24552
24578
  } catch (e) {
24553
24579
  return null;
@@ -24584,11 +24610,11 @@ var ThemeToggle = ({
24584
24610
  defaultTheme = "light",
24585
24611
  onThemeChange
24586
24612
  }) => {
24587
- var _a65;
24613
+ var _a72;
24588
24614
  const [mounted, setMounted] = React35.useState(false);
24589
24615
  const [internalTheme, setInternalTheme] = React35.useState(defaultTheme);
24590
24616
  const isControlled = typeof theme !== "undefined";
24591
- const activeTheme = (_a65 = isControlled ? theme : internalTheme) != null ? _a65 : defaultTheme;
24617
+ const activeTheme = (_a72 = isControlled ? theme : internalTheme) != null ? _a72 : defaultTheme;
24592
24618
  React35.useEffect(() => {
24593
24619
  if (!isControlled) {
24594
24620
  setInternalTheme(resolveTheme(defaultTheme));
@@ -24633,7 +24659,7 @@ var ThemeToggle = ({
24633
24659
  "aria-label": "Toggle theme",
24634
24660
  children: [
24635
24661
  /* @__PURE__ */ jsx54(Sun2, { className: "h-5 w-5 text-cupcode-purple rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0" }),
24636
- /* @__PURE__ */ jsx54(Moon2, { className: "absolute h-5 w-5 text-cupcode-pink rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100" }),
24662
+ /* @__PURE__ */ jsx54(Moon2, { className: "absolute h-5 w-5 text-cupcode-hover rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100" }),
24637
24663
  /* @__PURE__ */ jsxs34("span", { className: "sr-only", children: [
24638
24664
  "Current theme: ",
24639
24665
  activeTheme
@@ -25226,8 +25252,8 @@ var ChartStyle = ({ id, config }) => {
25226
25252
  ([theme, prefix]) => `
25227
25253
  ${prefix} [data-chart=${id}] {
25228
25254
  ${colorConfig.map(([key, itemConfig]) => {
25229
- var _a65;
25230
- const color = ((_a65 = itemConfig.theme) == null ? void 0 : _a65[theme]) || itemConfig.color;
25255
+ var _a72;
25256
+ const color = ((_a72 = itemConfig.theme) == null ? void 0 : _a72[theme]) || itemConfig.color;
25231
25257
  return color ? ` --color-${key}: ${color};` : null;
25232
25258
  }).join("\n")}
25233
25259
  }
@@ -25256,14 +25282,14 @@ var ChartTooltipContent = React42.forwardRef(
25256
25282
  }, ref) => {
25257
25283
  const { config } = useChart();
25258
25284
  const tooltipLabel = React42.useMemo(() => {
25259
- var _a65;
25285
+ var _a72;
25260
25286
  if (hideLabel || !(payload == null ? void 0 : payload.length)) {
25261
25287
  return null;
25262
25288
  }
25263
25289
  const [item] = payload;
25264
25290
  const key = `${labelKey || item.dataKey || item.name || "value"}`;
25265
25291
  const itemConfig = getPayloadConfigFromPayload(config, item, key);
25266
- const value = !labelKey && typeof label === "string" ? ((_a65 = config[label]) == null ? void 0 : _a65.label) || label : itemConfig == null ? void 0 : itemConfig.label;
25292
+ const value = !labelKey && typeof label === "string" ? ((_a72 = config[label]) == null ? void 0 : _a72.label) || label : itemConfig == null ? void 0 : itemConfig.label;
25267
25293
  if (labelFormatter) {
25268
25294
  return /* @__PURE__ */ jsx64("div", { className: cn("font-medium", labelClassName), children: labelFormatter(value, payload) });
25269
25295
  }
@@ -26948,8 +26974,8 @@ ToggleGroupItem.displayName = ToggleGroupPrimitive.Item.displayName;
26948
26974
  // src/hooks/useActiveSection.ts
26949
26975
  import { useEffect as useEffect23, useState as useState18 } from "react";
26950
26976
  var useActiveSection = (sectionIds, offset = 180) => {
26951
- var _a65;
26952
- const [activeId, setActiveId] = useState18((_a65 = sectionIds[0]) != null ? _a65 : "");
26977
+ var _a72;
26978
+ const [activeId, setActiveId] = useState18((_a72 = sectionIds[0]) != null ? _a72 : "");
26953
26979
  useEffect23(() => {
26954
26980
  if (!sectionIds.length || typeof window === "undefined") return;
26955
26981
  const update = () => {
@@ -27003,6 +27029,35 @@ var _a63;
27003
27029
  var USER_PRESENCE_USER_ID_COLUMN2 = ((_a63 = getRuntimeEnv("VITE_USER_PRESENCE_USER_ID_COLUMN")) != null ? _a63 : "user_id").trim();
27004
27030
  var _a64;
27005
27031
  var USER_PRESENCE_STATUS_COLUMN2 = ((_a64 = getRuntimeEnv("VITE_USER_PRESENCE_STATUS_COLUMN")) != null ? _a64 : "status").trim();
27032
+ var _a65, _b5;
27033
+ var SUPABASE_CHAT_SCHEMA = ((_b5 = (_a65 = getRuntimeEnv("VITE_CHAT_SCHEMA")) != null ? _a65 : getRuntimeEnv("VITE_SUPABASE_SCHEMA")) != null ? _b5 : "public").trim();
27034
+ var _a66;
27035
+ var CHAT_USERS_TABLE2 = ((_a66 = getRuntimeEnv("VITE_CHAT_USERS_TABLE")) != null ? _a66 : "chat_users").trim();
27036
+ var _a67;
27037
+ var CHAT_USERS_ID_COLUMN2 = ((_a67 = getRuntimeEnv("VITE_CHAT_USERS_ID_COLUMN")) != null ? _a67 : "id").trim();
27038
+ var _a68;
27039
+ var CHAT_USERS_EMAIL_COLUMN2 = ((_a68 = getRuntimeEnv("VITE_CHAT_USERS_EMAIL_COLUMN")) != null ? _a68 : "email").trim();
27040
+ var _a69;
27041
+ var CHAT_USERS_UPDATE_TABLE2 = ((_a69 = getRuntimeEnv("VITE_CHAT_USERS_UPDATE_TABLE")) != null ? _a69 : "profiles").trim();
27042
+ var _a70;
27043
+ var CHAT_USERS_UPDATE_ID_COLUMN2 = ((_a70 = getRuntimeEnv("VITE_CHAT_USERS_UPDATE_ID_COLUMN")) != null ? _a70 : "id").trim();
27044
+ var _a71;
27045
+ var CHAT_USERS_UPDATE_EMAIL_COLUMN2 = ((_a71 = getRuntimeEnv("VITE_CHAT_USERS_UPDATE_EMAIL_COLUMN")) != null ? _a71 : "email").trim();
27046
+ var PRESENCE_USER_LOOKUP_TABLES = Array.from(
27047
+ new Set(
27048
+ [CHAT_USERS_UPDATE_TABLE2, CHAT_USERS_TABLE2, "profiles", "chat_users"].map((entry) => entry.trim()).filter((entry) => entry.length > 0)
27049
+ )
27050
+ );
27051
+ var PRESENCE_USER_LOOKUP_ID_COLUMNS = Array.from(
27052
+ new Set(
27053
+ [CHAT_USERS_UPDATE_ID_COLUMN2, CHAT_USERS_ID_COLUMN2, "id", "user_id"].map((entry) => entry.trim()).filter((entry) => entry.length > 0)
27054
+ )
27055
+ );
27056
+ var PRESENCE_USER_LOOKUP_EMAIL_COLUMNS = Array.from(
27057
+ new Set(
27058
+ [CHAT_USERS_UPDATE_EMAIL_COLUMN2, CHAT_USERS_EMAIL_COLUMN2, "email"].map((entry) => entry.trim()).filter((entry) => entry.length > 0)
27059
+ )
27060
+ );
27006
27061
  var AWAY_AFTER_MS = 10 * 60 * 1e3;
27007
27062
  var ACTIVITY_BROADCAST_THROTTLE_MS = 5e3;
27008
27063
  var INACTIVITY_CHECK_INTERVAL_MS = 3e4;
@@ -27021,14 +27076,27 @@ var PRESENCE_STATUS_VALUES2 = [
27021
27076
  var isUserPresenceStatus = (value) => {
27022
27077
  return typeof value === "string" && PRESENCE_STATUS_VALUES2.includes(value);
27023
27078
  };
27079
+ var toNonEmptyString = (value) => {
27080
+ if (typeof value !== "string") return void 0;
27081
+ const trimmed = value.trim();
27082
+ return trimmed === "" ? void 0 : trimmed;
27083
+ };
27084
+ var readFirstRecordString2 = (row, keys) => {
27085
+ if (!row) return void 0;
27086
+ for (const key of keys) {
27087
+ const value = toNonEmptyString(row[key]);
27088
+ if (value) return value;
27089
+ }
27090
+ return void 0;
27091
+ };
27024
27092
  var readStoredPresence = () => {
27025
27093
  const stored = sessionStorage.getItem(STORAGE_KEYS.presence);
27026
27094
  if (!stored) return DEFAULT_PRESENCE_STATUS;
27027
27095
  return isUserPresenceStatus(stored) ? stored : DEFAULT_PRESENCE_STATUS;
27028
27096
  };
27029
27097
  var readStoredPresenceSource = () => {
27030
- var _a65;
27031
- const stored = (_a65 = sessionStorage.getItem(STORAGE_KEYS.presenceSource)) != null ? _a65 : localStorage.getItem(LOCAL_STORAGE_KEYS.presenceSource);
27098
+ var _a72;
27099
+ const stored = (_a72 = sessionStorage.getItem(STORAGE_KEYS.presenceSource)) != null ? _a72 : localStorage.getItem(LOCAL_STORAGE_KEYS.presenceSource);
27032
27100
  return stored === "system" ? "system" : "manual";
27033
27101
  };
27034
27102
  var AuthContext = createContext6(void 0);
@@ -27046,30 +27114,33 @@ var readStoredToken = () => {
27046
27114
  return { accessToken, idToken };
27047
27115
  };
27048
27116
  var storeTokens = (tokens) => {
27049
- var _a65;
27117
+ var _a72;
27050
27118
  sessionStorage.setItem(STORAGE_KEYS.accessToken, tokens.accessToken);
27051
27119
  if (tokens.idToken) sessionStorage.setItem(STORAGE_KEYS.idToken, tokens.idToken);
27052
27120
  if (tokens.refreshToken) sessionStorage.setItem(STORAGE_KEYS.refreshToken, tokens.refreshToken);
27053
- const expiresAt2 = Date.now() + ((_a65 = tokens.expiresIn) != null ? _a65 : 3600) * 1e3;
27121
+ const expiresAt2 = Date.now() + ((_a72 = tokens.expiresIn) != null ? _a72 : 3600) * 1e3;
27054
27122
  sessionStorage.setItem(STORAGE_KEYS.expiresAt, String(expiresAt2));
27055
27123
  };
27056
27124
  var clearTokens = () => {
27057
27125
  Object.values(STORAGE_KEYS).forEach((key) => sessionStorage.removeItem(key));
27058
27126
  };
27059
27127
  var buildUserFromToken = (idToken) => {
27060
- var _a65, _b5, _c, _d;
27128
+ var _a72, _b6, _c, _d, _e, _f, _g, _h;
27061
27129
  const payload = decodeJwt(idToken);
27062
27130
  if (!payload) return null;
27063
- const roleClaim = (_a65 = payload.role) != null ? _a65 : payload.roles;
27131
+ 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);
27132
+ const roleClaim = (_e = payload.role) != null ? _e : payload.roles;
27064
27133
  const resolvedRole = typeof roleClaim === "string" ? roleClaim : Array.isArray(roleClaim) ? roleClaim.find((entry) => typeof entry === "string") : void 0;
27065
- const jobTitleClaim = (_c = (_b5 = payload.job_title) != null ? _b5 : payload.jobTitle) != null ? _c : payload.title;
27134
+ const jobTitleClaim = (_g = (_f = payload.job_title) != null ? _f : payload.jobTitle) != null ? _g : payload.title;
27066
27135
  const resolvedJobTitle = typeof jobTitleClaim === "string" ? jobTitleClaim : void 0;
27067
27136
  return {
27068
27137
  sub: payload.sub,
27138
+ id: resolvedId,
27139
+ userId: resolvedId,
27069
27140
  name: payload.name,
27070
27141
  email: payload.email,
27071
27142
  picture: payload.picture,
27072
- preferredUsername: (_d = payload.preferred_username) != null ? _d : payload.preferredUsername,
27143
+ preferredUsername: (_h = payload.preferred_username) != null ? _h : payload.preferredUsername,
27073
27144
  nickname: payload.nickname,
27074
27145
  role: resolvedRole,
27075
27146
  jobTitle: resolvedJobTitle
@@ -27087,22 +27158,54 @@ var AuthProvider = ({ children }) => {
27087
27158
  );
27088
27159
  const lastActivityAtRef = useRef14(Date.now());
27089
27160
  const lastActivityBroadcastAtRef = useRef14(0);
27161
+ const resolvedPresenceIdentityKeyRef = useRef14(null);
27162
+ const resolvedPresenceUserIdRef = useRef14(null);
27090
27163
  const storePresenceStatus = useCallback9((nextStatus) => {
27091
27164
  setPresenceStatusState(nextStatus);
27092
27165
  presenceStatusRef.current = nextStatus;
27093
27166
  sessionStorage.setItem(STORAGE_KEYS.presence, nextStatus);
27094
27167
  }, []);
27095
- const resolvePresenceUserId = useCallback9((targetUser) => {
27096
- var _a65, _b5;
27097
- const sub = (_a65 = targetUser == null ? void 0 : targetUser.sub) == null ? void 0 : _a65.trim();
27098
- if (sub) return sub;
27099
- const email = (_b5 = targetUser == null ? void 0 : targetUser.email) == null ? void 0 : _b5.trim();
27100
- if (email) return email;
27101
- return null;
27168
+ const resolvePresenceUserId = useCallback9(async (targetUser) => {
27169
+ var _a72, _b6, _c, _d;
27170
+ const sub = toNonEmptyString(targetUser == null ? void 0 : targetUser.sub);
27171
+ const id = toNonEmptyString(targetUser == null ? void 0 : targetUser.id);
27172
+ const userId = toNonEmptyString(targetUser == null ? void 0 : targetUser.userId);
27173
+ const email = (_a72 = toNonEmptyString(targetUser == null ? void 0 : targetUser.email)) == null ? void 0 : _a72.toLowerCase();
27174
+ const identityKey = [sub != null ? sub : "", id != null ? id : "", userId != null ? userId : "", email != null ? email : ""].join("|");
27175
+ if (resolvedPresenceIdentityKeyRef.current === identityKey && resolvedPresenceUserIdRef.current) {
27176
+ return resolvedPresenceUserIdRef.current;
27177
+ }
27178
+ const fallbackUserId = (_d = (_c = (_b6 = sub != null ? sub : id) != null ? _b6 : userId) != null ? _c : email) != null ? _d : null;
27179
+ if (!email) {
27180
+ resolvedPresenceIdentityKeyRef.current = identityKey;
27181
+ resolvedPresenceUserIdRef.current = fallbackUserId;
27182
+ return fallbackUserId;
27183
+ }
27184
+ const supabase = getSupabase();
27185
+ if (!supabase) {
27186
+ resolvedPresenceIdentityKeyRef.current = identityKey;
27187
+ resolvedPresenceUserIdRef.current = fallbackUserId;
27188
+ return fallbackUserId;
27189
+ }
27190
+ for (const tableName of PRESENCE_USER_LOOKUP_TABLES) {
27191
+ for (const emailColumn of PRESENCE_USER_LOOKUP_EMAIL_COLUMNS) {
27192
+ const { data, error } = await supabase.from(tableName).select("*").ilike(emailColumn, email).limit(1);
27193
+ if (error) continue;
27194
+ const row = data == null ? void 0 : data[0];
27195
+ const mappedId = readFirstRecordString2(row, PRESENCE_USER_LOOKUP_ID_COLUMNS);
27196
+ if (!mappedId) continue;
27197
+ resolvedPresenceIdentityKeyRef.current = identityKey;
27198
+ resolvedPresenceUserIdRef.current = mappedId;
27199
+ return mappedId;
27200
+ }
27201
+ }
27202
+ resolvedPresenceIdentityKeyRef.current = identityKey;
27203
+ resolvedPresenceUserIdRef.current = fallbackUserId;
27204
+ return fallbackUserId;
27102
27205
  }, []);
27103
27206
  const persistPresenceStatus = useCallback9(
27104
27207
  async (nextStatus, targetUser) => {
27105
- const userId = resolvePresenceUserId(targetUser != null ? targetUser : user);
27208
+ const userId = await resolvePresenceUserId(targetUser != null ? targetUser : user);
27106
27209
  if (!userId) return;
27107
27210
  const supabase = getSupabase();
27108
27211
  if (!supabase) return;
@@ -27131,9 +27234,23 @@ var AuthProvider = ({ children }) => {
27131
27234
  },
27132
27235
  [persistPresenceStatus, storePresenceStatus]
27133
27236
  );
27237
+ const syncPresenceFromDatabase = useCallback9(
27238
+ (nextStatus) => {
27239
+ storePresenceStatus(nextStatus);
27240
+ const storedSource = readStoredPresenceSource();
27241
+ const sourceFromDatabase = nextStatus === "away" ? storedSource : nextStatus === "offline" ? "system" : "manual";
27242
+ presenceSourceRef.current = sourceFromDatabase;
27243
+ sessionStorage.setItem(STORAGE_KEYS.presenceSource, sourceFromDatabase);
27244
+ localStorage.setItem(LOCAL_STORAGE_KEYS.presenceSource, sourceFromDatabase);
27245
+ if (nextStatus !== "offline") {
27246
+ lastManualPresenceRef.current = nextStatus;
27247
+ }
27248
+ },
27249
+ [storePresenceStatus]
27250
+ );
27134
27251
  const loadPresenceFromDatabase = useCallback9(
27135
27252
  async (targetUser) => {
27136
- const userId = resolvePresenceUserId(targetUser);
27253
+ const userId = await resolvePresenceUserId(targetUser);
27137
27254
  if (!userId) return;
27138
27255
  const supabase = getSupabase();
27139
27256
  if (!supabase) return;
@@ -27146,18 +27263,13 @@ var AuthProvider = ({ children }) => {
27146
27263
  }
27147
27264
  const row = data;
27148
27265
  const rawStatus = row == null ? void 0 : row[USER_PRESENCE_STATUS_COLUMN2];
27149
- if (!isUserPresenceStatus(rawStatus)) return;
27150
- storePresenceStatus(rawStatus);
27151
- const storedSource = readStoredPresenceSource();
27152
- const sourceFromDatabase = rawStatus === "away" ? storedSource : rawStatus === "offline" ? "system" : "manual";
27153
- presenceSourceRef.current = sourceFromDatabase;
27154
- sessionStorage.setItem(STORAGE_KEYS.presenceSource, sourceFromDatabase);
27155
- localStorage.setItem(LOCAL_STORAGE_KEYS.presenceSource, sourceFromDatabase);
27156
- if (rawStatus !== "offline") {
27157
- lastManualPresenceRef.current = rawStatus;
27266
+ if (!isUserPresenceStatus(rawStatus)) {
27267
+ await persistPresenceStatus(presenceStatusRef.current, targetUser);
27268
+ return;
27158
27269
  }
27270
+ syncPresenceFromDatabase(rawStatus);
27159
27271
  },
27160
- [resolvePresenceUserId, storePresenceStatus]
27272
+ [persistPresenceStatus, resolvePresenceUserId, syncPresenceFromDatabase]
27161
27273
  );
27162
27274
  const clearAuthFlowState = useCallback9((options) => {
27163
27275
  sessionStorage.removeItem(STORAGE_KEYS.state);
@@ -27171,7 +27283,7 @@ var AuthProvider = ({ children }) => {
27171
27283
  }, []);
27172
27284
  const startAuthorization = useCallback9(
27173
27285
  async (options) => {
27174
- var _a65, _b5;
27286
+ var _a72, _b6;
27175
27287
  const config = getAccountsConfig();
27176
27288
  const { authUrl } = await resolveOidcEndpoints(config);
27177
27289
  if (!authUrl) {
@@ -27181,8 +27293,8 @@ var AuthProvider = ({ children }) => {
27181
27293
  const challenge = await generateCodeChallenge(verifier);
27182
27294
  const state = generateState();
27183
27295
  const nonce = generateNonce();
27184
- const redirectTo = (_a65 = options == null ? void 0 : options.redirectTo) != null ? _a65 : window.location.pathname + window.location.search + window.location.hash;
27185
- const mode = (_b5 = options == null ? void 0 : options.mode) != null ? _b5 : "interactive";
27296
+ const redirectTo = (_a72 = options == null ? void 0 : options.redirectTo) != null ? _a72 : window.location.pathname + window.location.search + window.location.hash;
27297
+ const mode = (_b6 = options == null ? void 0 : options.mode) != null ? _b6 : "interactive";
27186
27298
  sessionStorage.setItem(STORAGE_KEYS.verifier, verifier);
27187
27299
  sessionStorage.setItem(STORAGE_KEYS.state, state);
27188
27300
  sessionStorage.setItem(STORAGE_KEYS.nonce, nonce);
@@ -27209,14 +27321,14 @@ var AuthProvider = ({ children }) => {
27209
27321
  useEffect24(() => {
27210
27322
  let cancelled = false;
27211
27323
  const initializeAuth = async () => {
27212
- var _a65;
27324
+ var _a72;
27213
27325
  const stored = readStoredToken();
27214
27326
  const storedPresence = readStoredPresence();
27215
27327
  setPresenceStatusState(storedPresence);
27216
27328
  if (stored == null ? void 0 : stored.accessToken) {
27217
27329
  if (cancelled) return;
27218
27330
  setAccessToken(stored.accessToken);
27219
- setUser(buildUserFromToken((_a65 = stored.idToken) != null ? _a65 : void 0));
27331
+ setUser(buildUserFromToken((_a72 = stored.idToken) != null ? _a72 : void 0));
27220
27332
  setStatus("authenticated");
27221
27333
  return;
27222
27334
  }
@@ -27243,14 +27355,56 @@ var AuthProvider = ({ children }) => {
27243
27355
  cancelled = true;
27244
27356
  };
27245
27357
  }, [attemptSilentLogin]);
27358
+ useEffect24(() => {
27359
+ resolvedPresenceIdentityKeyRef.current = null;
27360
+ resolvedPresenceUserIdRef.current = null;
27361
+ }, [user == null ? void 0 : user.email, user == null ? void 0 : user.id, user == null ? void 0 : user.sub, user == null ? void 0 : user.userId]);
27246
27362
  useEffect24(() => {
27247
27363
  if (status !== "authenticated") return;
27248
27364
  void loadPresenceFromDatabase(user);
27249
27365
  }, [loadPresenceFromDatabase, status, user]);
27250
27366
  useEffect24(() => {
27251
- var _a65;
27252
27367
  if (status !== "authenticated") return;
27253
- const initialFromStorage = Number((_a65 = localStorage.getItem(LOCAL_STORAGE_KEYS.lastActivityAt)) != null ? _a65 : "0");
27368
+ const supabase = getSupabase();
27369
+ if (!supabase) return;
27370
+ let cancelled = false;
27371
+ let presenceChannel = null;
27372
+ const startPresenceSync = async () => {
27373
+ const currentUserId = await resolvePresenceUserId(user);
27374
+ if (!currentUserId || cancelled) return;
27375
+ presenceChannel = supabase.channel(`cc-auth-presence-${currentUserId}`).on(
27376
+ "postgres_changes",
27377
+ {
27378
+ event: "*",
27379
+ schema: SUPABASE_CHAT_SCHEMA,
27380
+ table: USER_PRESENCE_TABLE2
27381
+ },
27382
+ (payload) => {
27383
+ const row = payload.new || payload.old;
27384
+ const rowUserId = toNonEmptyString(row == null ? void 0 : row[USER_PRESENCE_USER_ID_COLUMN2]);
27385
+ if (!rowUserId || rowUserId !== currentUserId) return;
27386
+ if (payload.eventType === "DELETE") {
27387
+ syncPresenceFromDatabase("offline");
27388
+ return;
27389
+ }
27390
+ const nextStatus = row == null ? void 0 : row[USER_PRESENCE_STATUS_COLUMN2];
27391
+ if (!isUserPresenceStatus(nextStatus)) return;
27392
+ syncPresenceFromDatabase(nextStatus);
27393
+ }
27394
+ ).subscribe();
27395
+ };
27396
+ void startPresenceSync();
27397
+ return () => {
27398
+ cancelled = true;
27399
+ if (presenceChannel) {
27400
+ void supabase.removeChannel(presenceChannel);
27401
+ }
27402
+ };
27403
+ }, [resolvePresenceUserId, status, syncPresenceFromDatabase, user]);
27404
+ useEffect24(() => {
27405
+ var _a72;
27406
+ if (status !== "authenticated") return;
27407
+ const initialFromStorage = Number((_a72 = localStorage.getItem(LOCAL_STORAGE_KEYS.lastActivityAt)) != null ? _a72 : "0");
27254
27408
  if (Number.isFinite(initialFromStorage) && initialFromStorage > 0) {
27255
27409
  lastActivityAtRef.current = Math.max(lastActivityAtRef.current, initialFromStorage);
27256
27410
  } else {
@@ -27325,9 +27479,9 @@ var AuthProvider = ({ children }) => {
27325
27479
  });
27326
27480
  }, [startAuthorization]);
27327
27481
  const completeLogin = useCallback9(async () => {
27328
- var _a65;
27482
+ var _a72;
27329
27483
  const params = new URLSearchParams(window.location.search);
27330
- const redirectTo = (_a65 = sessionStorage.getItem(STORAGE_KEYS.redirect)) != null ? _a65 : "/";
27484
+ const redirectTo = (_a72 = sessionStorage.getItem(STORAGE_KEYS.redirect)) != null ? _a72 : "/";
27331
27485
  const authMode = sessionStorage.getItem(STORAGE_KEYS.authMode);
27332
27486
  const isSilentAuth = authMode === "silent";
27333
27487
  const error = params.get("error");
@@ -27391,10 +27545,10 @@ var AuthProvider = ({ children }) => {
27391
27545
  }
27392
27546
  }, [clearAuthFlowState]);
27393
27547
  const logout = useCallback9(async () => {
27394
- var _a65;
27548
+ var _a72;
27395
27549
  const config = getAccountsConfig();
27396
27550
  const { logoutUrl } = await resolveOidcEndpoints(config);
27397
- const idToken = (_a65 = sessionStorage.getItem(STORAGE_KEYS.idToken)) != null ? _a65 : void 0;
27551
+ const idToken = (_a72 = sessionStorage.getItem(STORAGE_KEYS.idToken)) != null ? _a72 : void 0;
27398
27552
  const currentUser = user;
27399
27553
  await persistPresenceStatus("offline", currentUser);
27400
27554
  clearTokens();
@@ -27794,6 +27948,7 @@ export {
27794
27948
  parseAssetId,
27795
27949
  reducer,
27796
27950
  resolveOidcEndpoints,
27951
+ resolveTelescupImageURL,
27797
27952
  responsiveSizeClasses,
27798
27953
  setCupcodeRuntimeEnv,
27799
27954
  toast2 as sonnerToast,