@cupcodev/ui 8.0.0 → 8.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1640,10 +1640,10 @@ var Dock = ({ items, className }) => {
1640
1640
  const itemsRef = (0, import_react5.useRef)([]);
1641
1641
  const OVERSHOOT = 5;
1642
1642
  (0, import_react5.useEffect)(() => {
1643
- var _a68;
1643
+ var _a66;
1644
1644
  const activeItem = itemsRef.current[activeIndex];
1645
1645
  if (!activeItem) return;
1646
- const containerRect = (_a68 = activeItem.parentElement) == null ? void 0 : _a68.getBoundingClientRect();
1646
+ const containerRect = (_a66 = activeItem.parentElement) == null ? void 0 : _a66.getBoundingClientRect();
1647
1647
  const itemRect = activeItem.getBoundingClientRect();
1648
1648
  if (!containerRect) return;
1649
1649
  const relativeLeft = itemRect.left - containerRect.left;
@@ -1705,9 +1705,9 @@ var Dock = ({ items, className }) => {
1705
1705
  "button",
1706
1706
  {
1707
1707
  onClick: () => {
1708
- var _a68;
1708
+ var _a66;
1709
1709
  setActiveIndex(index);
1710
- (_a68 = item.onClick) == null ? void 0 : _a68.call(item);
1710
+ (_a66 = item.onClick) == null ? void 0 : _a66.call(item);
1711
1711
  },
1712
1712
  className: cn(
1713
1713
  "flex items-center justify-center w-12 h-12 rounded-xl",
@@ -1775,9 +1775,9 @@ var normalizeValue = (value) => {
1775
1775
  return String(value);
1776
1776
  };
1777
1777
  var setCupcodeRuntimeEnv = (values) => {
1778
- var _a68;
1778
+ var _a66;
1779
1779
  const globalRef = globalThis;
1780
- const nextGlobalEnv = { ...(_a68 = globalRef.__CUPCODE_ENV__) != null ? _a68 : {} };
1780
+ const nextGlobalEnv = { ...(_a66 = globalRef.__CUPCODE_ENV__) != null ? _a66 : {} };
1781
1781
  Object.entries(values).forEach(([key, value]) => {
1782
1782
  const normalized = normalizeValue(value);
1783
1783
  runtimeStore[key] = normalized;
@@ -1786,8 +1786,8 @@ var setCupcodeRuntimeEnv = (values) => {
1786
1786
  globalRef.__CUPCODE_ENV__ = nextGlobalEnv;
1787
1787
  };
1788
1788
  var readFromProcessEnv = (key) => {
1789
- var _a68;
1790
- const processEnv = (_a68 = globalThis.process) == null ? void 0 : _a68.env;
1789
+ var _a66;
1790
+ const processEnv = (_a66 = globalThis.process) == null ? void 0 : _a66.env;
1791
1791
  return normalizeValue(processEnv == null ? void 0 : processEnv[key]);
1792
1792
  };
1793
1793
  var readFromImportMetaEnv = (key) => {
@@ -1799,12 +1799,12 @@ var readFromImportMetaEnv = (key) => {
1799
1799
  }
1800
1800
  };
1801
1801
  var getRuntimeEnv = (key) => {
1802
- var _a68;
1802
+ var _a66;
1803
1803
  const normalizedKey = key.trim();
1804
1804
  if (!normalizedKey) return void 0;
1805
1805
  const fromRuntimeStore = runtimeStore[normalizedKey];
1806
1806
  if (fromRuntimeStore) return fromRuntimeStore;
1807
- const fromGlobalStore = normalizeValue((_a68 = globalThis.__CUPCODE_ENV__) == null ? void 0 : _a68[normalizedKey]);
1807
+ const fromGlobalStore = normalizeValue((_a66 = globalThis.__CUPCODE_ENV__) == null ? void 0 : _a66[normalizedKey]);
1808
1808
  if (fromGlobalStore) return fromGlobalStore;
1809
1809
  const fromGlobalKey = normalizeValue(globalThis[normalizedKey]);
1810
1810
  if (fromGlobalKey) return fromGlobalKey;
@@ -1813,17 +1813,17 @@ var getRuntimeEnv = (key) => {
1813
1813
  return readFromProcessEnv(normalizedKey);
1814
1814
  };
1815
1815
  var getRuntimeEnvOr = (key, fallback) => {
1816
- var _a68;
1817
- return (_a68 = getRuntimeEnv(key)) != null ? _a68 : fallback;
1816
+ var _a66;
1817
+ return (_a66 = getRuntimeEnv(key)) != null ? _a66 : fallback;
1818
1818
  };
1819
1819
  var isRuntimeDev = () => {
1820
- var _a68, _b4, _c;
1821
- const explicitDev = (_a68 = getRuntimeEnv("DEV")) != null ? _a68 : getRuntimeEnv("VITE_DEV");
1820
+ var _a66, _b3, _c;
1821
+ const explicitDev = (_a66 = getRuntimeEnv("DEV")) != null ? _a66 : getRuntimeEnv("VITE_DEV");
1822
1822
  if (explicitDev) {
1823
1823
  const normalized = explicitDev.toLowerCase();
1824
1824
  return normalized === "1" || normalized === "true";
1825
1825
  }
1826
- const mode = ((_c = (_b4 = getRuntimeEnv("MODE")) != null ? _b4 : getRuntimeEnv("NODE_ENV")) != null ? _c : "").toLowerCase();
1826
+ const mode = ((_c = (_b3 = getRuntimeEnv("MODE")) != null ? _b3 : getRuntimeEnv("NODE_ENV")) != null ? _c : "").toLowerCase();
1827
1827
  return mode === "development";
1828
1828
  };
1829
1829
  var resolveCupcodeAppVersion = (explicitVersion) => {
@@ -1844,15 +1844,15 @@ var isUuid = (value) => {
1844
1844
  return UUID_REGEX.test(value.trim());
1845
1845
  };
1846
1846
  function parseAssetId(input) {
1847
- var _a68, _b4, _c, _d;
1847
+ var _a66, _b3, _c, _d;
1848
1848
  const raw = input == null ? void 0 : input.trim();
1849
1849
  if (!raw) return void 0;
1850
1850
  if (UUID_REGEX.test(raw)) return raw;
1851
- const matchFromRaw = (_a68 = raw.match(UUID_IN_TEXT_REGEX)) == null ? void 0 : _a68[0];
1851
+ const matchFromRaw = (_a66 = raw.match(UUID_IN_TEXT_REGEX)) == null ? void 0 : _a66[0];
1852
1852
  if (isUuid(matchFromRaw)) return matchFromRaw;
1853
1853
  try {
1854
1854
  const url = new URL(raw);
1855
- const queryParamId = (_c = (_b4 = url.searchParams.get("id")) != null ? _b4 : url.searchParams.get("asset_id")) != null ? _c : url.searchParams.get("assetId");
1855
+ const queryParamId = (_c = (_b3 = url.searchParams.get("id")) != null ? _b3 : url.searchParams.get("asset_id")) != null ? _c : url.searchParams.get("assetId");
1856
1856
  if (isUuid(queryParamId)) return queryParamId;
1857
1857
  const matchFromPath = (_d = url.pathname.match(UUID_IN_TEXT_REGEX)) == null ? void 0 : _d[0];
1858
1858
  if (isUuid(matchFromPath)) return matchFromPath;
@@ -1998,7 +1998,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
1998
1998
  return void 0;
1999
1999
  }, [sortedCategories]);
2000
2000
  (0, import_react7.useEffect)(() => {
2001
- var _a68;
2001
+ var _a66;
2002
2002
  const root = rootRef.current;
2003
2003
  if (!root) return;
2004
2004
  const $ = (sel) => root.querySelector(sel);
@@ -2010,7 +2010,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
2010
2010
  const getDockItems = () => Array.from(root.querySelectorAll(INTERACTIVE_SELECTOR));
2011
2011
  const dockItems = getDockItems();
2012
2012
  if (!tabbar || !dock || !listMenuShow || !tabbarUl || dockItems.length === 0) return;
2013
- const persistentId = (_a68 = activeCategoryId != null ? activeCategoryId : lastInteractiveId) != null ? _a68 : null;
2013
+ const persistentId = (_a66 = activeCategoryId != null ? activeCategoryId : lastInteractiveId) != null ? _a66 : null;
2014
2014
  let openItem = null;
2015
2015
  let latestToggleToken = null;
2016
2016
  const persistentSelector = persistentId != null ? `${INTERACTIVE_SELECTOR}[data-cat-id="${persistentId}"]` : null;
@@ -2309,8 +2309,8 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
2309
2309
  }, total);
2310
2310
  }
2311
2311
  const hideBootstrapTooltip = (el) => {
2312
- var _a69, _b4;
2313
- const tooltip = ((_b4 = (_a69 = window.bootstrap) == null ? void 0 : _a69.Tooltip) == null ? void 0 : _b4.getInstance) ? window.bootstrap.Tooltip.getInstance(el) : null;
2312
+ var _a67, _b3;
2313
+ const tooltip = ((_b3 = (_a67 = window.bootstrap) == null ? void 0 : _a67.Tooltip) == null ? void 0 : _b3.getInstance) ? window.bootstrap.Tooltip.getInstance(el) : null;
2314
2314
  tooltip == null ? void 0 : tooltip.hide();
2315
2315
  };
2316
2316
  const openMenuForItem = (item, menu) => {
@@ -2328,14 +2328,14 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
2328
2328
  latestToggleToken = null;
2329
2329
  };
2330
2330
  const closeActiveMenu = (opts = {}) => {
2331
- var _a69;
2331
+ var _a67;
2332
2332
  if (!opts.onClosed) {
2333
2333
  latestToggleToken = null;
2334
2334
  }
2335
2335
  const itemToClose = openItem;
2336
2336
  if (!itemToClose) {
2337
2337
  if (!opts.preserveWrapper) ensurePersistentHighlight();
2338
- (_a69 = opts.onClosed) == null ? void 0 : _a69.call(opts);
2338
+ (_a67 = opts.onClosed) == null ? void 0 : _a67.call(opts);
2339
2339
  return;
2340
2340
  }
2341
2341
  const menu = getMenuFor(itemToClose);
@@ -2343,7 +2343,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
2343
2343
  itemToClose.classList.remove("active");
2344
2344
  delete itemToClose.dataset.menuOpen;
2345
2345
  const finalize = () => {
2346
- var _a70;
2346
+ var _a68;
2347
2347
  if (!opts.preserveWrapper) {
2348
2348
  listMenuShow.classList.remove("show");
2349
2349
  tabbar.classList.remove("is-active-menu");
@@ -2351,7 +2351,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
2351
2351
  setTabbarTheme(null);
2352
2352
  ensurePersistentHighlight();
2353
2353
  }
2354
- (_a70 = opts.onClosed) == null ? void 0 : _a70.call(opts);
2354
+ (_a68 = opts.onClosed) == null ? void 0 : _a68.call(opts);
2355
2355
  };
2356
2356
  closeMenu(menu, finalize);
2357
2357
  };
@@ -2454,7 +2454,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
2454
2454
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "glass-overlay" }),
2455
2455
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "glass-specular" }),
2456
2456
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("ul", { className: "flex-center", children: sortedCategories.map((cat) => {
2457
- var _a68;
2457
+ var _a66;
2458
2458
  if (cat.type === "divider") {
2459
2459
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2460
2460
  "li",
@@ -2466,7 +2466,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
2466
2466
  cat.id
2467
2467
  );
2468
2468
  }
2469
- const hasCards = (((_a68 = cat.cards) == null ? void 0 : _a68.length) || 0) > 0;
2469
+ const hasCards = (((_a66 = cat.cards) == null ? void 0 : _a66.length) || 0) > 0;
2470
2470
  const link = cat.href;
2471
2471
  const isCurrent = cat.id === activeCategoryId;
2472
2472
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
@@ -2500,12 +2500,12 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
2500
2500
  );
2501
2501
  }) }),
2502
2502
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "list-menu-mob-show", children: sortedCategories.filter((cat) => {
2503
- var _a68;
2504
- return cat.type !== "divider" && (((_a68 = cat.cards) == null ? void 0 : _a68.length) || 0) > 0;
2503
+ var _a66;
2504
+ return cat.type !== "divider" && (((_a66 = cat.cards) == null ? void 0 : _a66.length) || 0) > 0;
2505
2505
  }).map((cat) => {
2506
- var _a68;
2507
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "mob-list-menu hide", "data-tagget": cat.slug, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: `submenu-stack ${cat.slug}`, children: ((_a68 = cat.cards) != null ? _a68 : []).map((card, i) => {
2508
- var _a69;
2506
+ var _a66;
2507
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "mob-list-menu hide", "data-tagget": cat.slug, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: `submenu-stack ${cat.slug}`, children: ((_a66 = cat.cards) != null ? _a66 : []).map((card, i) => {
2508
+ var _a67;
2509
2509
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
2510
2510
  "div",
2511
2511
  {
@@ -2521,8 +2521,8 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
2521
2521
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "title", children: card.title }),
2522
2522
  card.description ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "description", children: card.description }) : null
2523
2523
  ] }),
2524
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "actions", children: ((_a69 = card.buttons) != null ? _a69 : []).slice(0, 2).map((btn, idx) => {
2525
- var _a70, _b4, _c, _d;
2524
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "actions", children: ((_a67 = card.buttons) != null ? _a67 : []).slice(0, 2).map((btn, idx) => {
2525
+ var _a68, _b3, _c, _d;
2526
2526
  const className = idx === 0 ? "saiba-mais" : "saiba-mais-1";
2527
2527
  if (btn.type === "popup") {
2528
2528
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
@@ -2537,7 +2537,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
2537
2537
  window.dispatchEvent(new Event(`qw:open:${btn.popupId}`));
2538
2538
  }
2539
2539
  },
2540
- children: (_a70 = btn.label) != null ? _a70 : "Abrir"
2540
+ children: (_a68 = btn.label) != null ? _a68 : "Abrir"
2541
2541
  },
2542
2542
  `${cat.id}-card-${i}-btn-${idx}`
2543
2543
  );
@@ -2547,7 +2547,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
2547
2547
  {
2548
2548
  href: btn.href || "#",
2549
2549
  className,
2550
- target: ((_b4 = btn.href) == null ? void 0 : _b4.startsWith("http")) ? "_blank" : void 0,
2550
+ target: ((_b3 = btn.href) == null ? void 0 : _b3.startsWith("http")) ? "_blank" : void 0,
2551
2551
  rel: ((_c = btn.href) == null ? void 0 : _c.startsWith("http")) ? "noopener noreferrer" : void 0,
2552
2552
  children: (_d = btn.label) != null ? _d : "Saiba mais >"
2553
2553
  },
@@ -2615,10 +2615,10 @@ var NavbarCupcode = ({
2615
2615
  React5.useEffect(() => {
2616
2616
  if (!hasItems || !isOpen) return;
2617
2617
  const handlePointerDown = (event) => {
2618
- var _a68, _b4;
2618
+ var _a66, _b3;
2619
2619
  const target = event.target;
2620
2620
  if (!(target instanceof Node)) return;
2621
- if (!((_a68 = navRef.current) == null ? void 0 : _a68.contains(target)) && !((_b4 = mobileDrawerRef.current) == null ? void 0 : _b4.contains(target))) {
2621
+ if (!((_a66 = navRef.current) == null ? void 0 : _a66.contains(target)) && !((_b3 = mobileDrawerRef.current) == null ? void 0 : _b3.contains(target))) {
2622
2622
  setIsOpen(false);
2623
2623
  }
2624
2624
  };
@@ -2687,8 +2687,8 @@ var NavbarCupcode = ({
2687
2687
  isActive && "text-[hsl(var(--cc-navbar-link-active))] after:w-full after:bg-[hsl(var(--cc-navbar-link-active))]"
2688
2688
  );
2689
2689
  const handleClick = (event) => {
2690
- var _a68;
2691
- (_a68 = item.onClick) == null ? void 0 : _a68.call(item, event);
2690
+ var _a66;
2691
+ (_a66 = item.onClick) == null ? void 0 : _a66.call(item, event);
2692
2692
  };
2693
2693
  if (item.href.startsWith("#")) {
2694
2694
  return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
@@ -2789,8 +2789,8 @@ var NavbarCupcode = ({
2789
2789
  isActive && "text-[hsl(var(--cc-navbar-link-active))]"
2790
2790
  );
2791
2791
  const handleClick = (event) => {
2792
- var _a68;
2793
- (_a68 = item.onClick) == null ? void 0 : _a68.call(item, event);
2792
+ var _a66;
2793
+ (_a66 = item.onClick) == null ? void 0 : _a66.call(item, event);
2794
2794
  setIsOpen(false);
2795
2795
  };
2796
2796
  if (item.href.startsWith("#")) {
@@ -3027,11 +3027,11 @@ JellyButton.displayName = "JellyButton";
3027
3027
  // src/components/cupcode/JellyButtonOriginal.tsx
3028
3028
  var import_jsx_runtime15 = require("react/jsx-runtime");
3029
3029
  var resolveResponsiveSize = (value, currentBp) => {
3030
- var _a68, _b4, _c, _d, _e;
3030
+ var _a66, _b3, _c, _d, _e;
3031
3031
  if (typeof value === "string") {
3032
3032
  return value;
3033
3033
  }
3034
- const fallback = (_e = (_d = (_c = (_b4 = (_a68 = value.base) != null ? _a68 : value.sm) != null ? _b4 : value.md) != null ? _c : value.lg) != null ? _d : value.xl) != null ? _e : "md";
3034
+ const fallback = (_e = (_d = (_c = (_b3 = (_a66 = value.base) != null ? _a66 : value.sm) != null ? _b3 : value.md) != null ? _c : value.lg) != null ? _d : value.xl) != null ? _e : "md";
3035
3035
  if (!currentBp) {
3036
3036
  return fallback;
3037
3037
  }
@@ -3581,12 +3581,12 @@ var isAccountsOidcToken = (token) => {
3581
3581
  return issuer.startsWith(ACCOUNTS_BASE_URL_NORMALIZED) || issuer.includes("accounts.cupcode.com.br");
3582
3582
  };
3583
3583
  var readStoredIdToken = () => {
3584
- var _a68;
3584
+ var _a66;
3585
3585
  if (typeof window === "undefined" || typeof window.sessionStorage === "undefined") {
3586
3586
  return void 0;
3587
3587
  }
3588
3588
  for (const key of SESSION_ID_TOKEN_KEYS) {
3589
- const value = (_a68 = window.sessionStorage.getItem(key)) == null ? void 0 : _a68.trim();
3589
+ const value = (_a66 = window.sessionStorage.getItem(key)) == null ? void 0 : _a66.trim();
3590
3590
  if (value) return value;
3591
3591
  }
3592
3592
  return void 0;
@@ -3680,11 +3680,11 @@ var readUsageContext = (value) => {
3680
3680
  return void 0;
3681
3681
  };
3682
3682
  var getFileExtension = (filename) => {
3683
- var _a68;
3683
+ var _a66;
3684
3684
  if (!filename) return void 0;
3685
3685
  const parts = filename.split(".");
3686
3686
  if (parts.length < 2) return void 0;
3687
- const candidate = (_a68 = parts[parts.length - 1]) == null ? void 0 : _a68.trim().toLowerCase();
3687
+ const candidate = (_a66 = parts[parts.length - 1]) == null ? void 0 : _a66.trim().toLowerCase();
3688
3688
  return candidate || void 0;
3689
3689
  };
3690
3690
  var buildFacetsFromItems = (items) => {
@@ -3694,14 +3694,14 @@ var buildFacetsFromItems = (items) => {
3694
3694
  const extensions = /* @__PURE__ */ new Map();
3695
3695
  const tags = /* @__PURE__ */ new Map();
3696
3696
  items.forEach((item) => {
3697
- var _a68, _b4, _c, _d, _e, _f, _g;
3697
+ var _a66, _b3, _c, _d, _e, _f, _g;
3698
3698
  if (item.category) {
3699
- categories.set(item.category, ((_a68 = categories.get(item.category)) != null ? _a68 : 0) + 1);
3699
+ categories.set(item.category, ((_a66 = categories.get(item.category)) != null ? _a66 : 0) + 1);
3700
3700
  }
3701
3701
  if (item.folderId) {
3702
3702
  const current = folders.get(item.folderId);
3703
3703
  folders.set(item.folderId, {
3704
- label: (_b4 = item.folderName) != null ? _b4 : current == null ? void 0 : current.label,
3704
+ label: (_b3 = item.folderName) != null ? _b3 : current == null ? void 0 : current.label,
3705
3705
  count: ((_c = current == null ? void 0 : current.count) != null ? _c : 0) + 1
3706
3706
  });
3707
3707
  }
@@ -3712,16 +3712,16 @@ var buildFacetsFromItems = (items) => {
3712
3712
  extensions.set(item.extension, ((_e = extensions.get(item.extension)) != null ? _e : 0) + 1);
3713
3713
  }
3714
3714
  (_g = (_f = item.meta) == null ? void 0 : _f.tags) == null ? void 0 : _g.forEach((tag) => {
3715
- var _a69;
3715
+ var _a67;
3716
3716
  const normalizedTag = tag.trim();
3717
3717
  if (!normalizedTag) return;
3718
- tags.set(normalizedTag, ((_a69 = tags.get(normalizedTag)) != null ? _a69 : 0) + 1);
3718
+ tags.set(normalizedTag, ((_a67 = tags.get(normalizedTag)) != null ? _a67 : 0) + 1);
3719
3719
  });
3720
3720
  });
3721
3721
  const toFacetValues = (map) => Array.from(map.entries()).map(([value, count2]) => ({ value, count: count2 })).sort((a, b) => a.value.localeCompare(b.value));
3722
3722
  const toFolderFacetValues = (map) => Array.from(map.entries()).map(([value, info]) => ({ value, label: info.label, count: info.count })).sort((a, b) => {
3723
- var _a68, _b4;
3724
- return ((_a68 = a.label) != null ? _a68 : a.value).localeCompare((_b4 = b.label) != null ? _b4 : b.value);
3723
+ var _a66, _b3;
3724
+ return ((_a66 = a.label) != null ? _a66 : a.value).localeCompare((_b3 = b.label) != null ? _b3 : b.value);
3725
3725
  });
3726
3726
  return {
3727
3727
  categories: toFacetValues(categories),
@@ -3732,7 +3732,7 @@ var buildFacetsFromItems = (items) => {
3732
3732
  };
3733
3733
  };
3734
3734
  async function request(config, path, options = {}) {
3735
- var _a68, _b4;
3735
+ var _a66, _b3;
3736
3736
  const token = await config.getAccessToken();
3737
3737
  if (!token) {
3738
3738
  throw new TelescupClientError("Token de acesso n\xE3o encontrado.");
@@ -3762,7 +3762,7 @@ async function request(config, path, options = {}) {
3762
3762
  let response;
3763
3763
  try {
3764
3764
  response = await fetch(url, {
3765
- method: (_a68 = options.method) != null ? _a68 : "POST",
3765
+ method: (_a66 = options.method) != null ? _a66 : "POST",
3766
3766
  headers,
3767
3767
  body
3768
3768
  });
@@ -3777,7 +3777,7 @@ async function request(config, path, options = {}) {
3777
3777
  payload = await response.text();
3778
3778
  }
3779
3779
  const payloadObject = payload != null ? payload : {};
3780
- const message = typeof payload === "string" ? payload : (_b4 = payloadObject.message) != null ? _b4 : `Erro ao chamar ${path} (${response.status}).`;
3780
+ const message = typeof payload === "string" ? payload : (_b3 = payloadObject.message) != null ? _b3 : `Erro ao chamar ${path} (${response.status}).`;
3781
3781
  throw new TelescupClientError(message, {
3782
3782
  status: response.status,
3783
3783
  code: payloadObject.code,
@@ -3792,11 +3792,11 @@ var normalizeFunctionLanguage = (value) => {
3792
3792
  return normalized;
3793
3793
  };
3794
3794
  var toFunctionListPayload = (filters) => {
3795
- var _a68, _b4, _c, _d, _e, _f;
3796
- const page = toPositiveInt((_a68 = filters.cursor) != null ? _a68 : filters.page, 1);
3795
+ var _a66, _b3, _c, _d, _e, _f;
3796
+ const page = toPositiveInt((_a66 = filters.cursor) != null ? _a66 : filters.page, 1);
3797
3797
  const pageSize = Math.min(500, Math.max(1, toPositiveInt(filters.pageSize, 24)));
3798
3798
  return {
3799
- query: (_b4 = filters.query) != null ? _b4 : "",
3799
+ query: (_b3 = filters.query) != null ? _b3 : "",
3800
3800
  page,
3801
3801
  pageSize,
3802
3802
  sort: `${normalizeSortBy(filters.sort)}:${filters.order === "asc" ? "asc" : "desc"}`,
@@ -3814,12 +3814,12 @@ var toFunctionListPayload = (filters) => {
3814
3814
  };
3815
3815
  };
3816
3816
  var mapGenericRowToAsset = (row) => {
3817
- var _a68, _b4;
3818
- const id = (_a68 = readFirstString(row, ["asset_id", "id", "file_id", "uuid"])) != null ? _a68 : typeof row.id === "number" ? String(row.id) : void 0;
3817
+ var _a66, _b3;
3818
+ const id = (_a66 = readFirstString(row, ["asset_id", "id", "file_id", "uuid"])) != null ? _a66 : typeof row.id === "number" ? String(row.id) : void 0;
3819
3819
  if (!id) return null;
3820
3820
  const fileName = readFirstString(row, ["filename", "file_name", "name", "title", "original_name"]);
3821
3821
  const mimeType = readFirstString(row, ["mime", "mime_type", "content_type", "file_mime"]);
3822
- const extension = (_b4 = readFirstString(row, ["extension", "ext"])) != null ? _b4 : getFileExtension(fileName);
3822
+ const extension = (_b3 = readFirstString(row, ["extension", "ext"])) != null ? _b3 : getFileExtension(fileName);
3823
3823
  return {
3824
3824
  id,
3825
3825
  name: fileName,
@@ -3837,16 +3837,16 @@ var mapGenericRowToAsset = (row) => {
3837
3837
  };
3838
3838
  };
3839
3839
  var normalizeListResponseFromFunctions = (response, filters) => {
3840
- var _a68, _b4, _c, _d, _e, _f;
3840
+ var _a66, _b3, _c, _d, _e, _f;
3841
3841
  const payload = response != null ? response : {};
3842
3842
  const itemsRaw = Array.isArray(payload.items) ? payload.items : [];
3843
3843
  const selectedLanguage = normalizeLanguageKey(filters.language);
3844
3844
  const items = itemsRaw.map((row) => {
3845
- var _a69, _b5, _c2;
3845
+ var _a67, _b4, _c2;
3846
3846
  const mapped = mapGenericRowToAsset(row);
3847
3847
  if (!mapped) return null;
3848
3848
  const metaByLang = normalizeMetaByLanguage(row.meta);
3849
- const activeMeta = (_b5 = (_a69 = metaByLang[selectedLanguage]) != null ? _a69 : metaByLang.pt) != null ? _b5 : {};
3849
+ const activeMeta = (_b4 = (_a67 = metaByLang[selectedLanguage]) != null ? _a67 : metaByLang.pt) != null ? _b4 : {};
3850
3850
  const usageFromObject = readUsageContext(row.usage);
3851
3851
  const normalized = {
3852
3852
  ...mapped,
@@ -3858,7 +3858,7 @@ var normalizeListResponseFromFunctions = (response, filters) => {
3858
3858
  };
3859
3859
  return normalized;
3860
3860
  }).filter((item) => item !== null);
3861
- const total = (_c = (_b4 = (_a68 = readNumber(payload.total)) != null ? _a68 : readNumber(payload.totalCount)) != null ? _b4 : readNumber(payload.total_count)) != null ? _c : items.length;
3861
+ const total = (_c = (_b3 = (_a66 = readNumber(payload.total)) != null ? _a66 : readNumber(payload.totalCount)) != null ? _b3 : readNumber(payload.total_count)) != null ? _c : items.length;
3862
3862
  const page = toPositiveInt((_e = (_d = payload.page) != null ? _d : filters.cursor) != null ? _e : filters.page, 1);
3863
3863
  const pageSize = Math.min(100, Math.max(1, toPositiveInt((_f = payload.pageSize) != null ? _f : filters.pageSize, 24)));
3864
3864
  const nextCursor = total > page * pageSize ? String(page + 1) : void 0;
@@ -3878,13 +3878,13 @@ var mapConflictForQueue = (value) => {
3878
3878
  return "conflict";
3879
3879
  };
3880
3880
  var toInitPayloadForFunctions = (payload) => {
3881
- var _a68, _b4;
3881
+ var _a66, _b3;
3882
3882
  return {
3883
3883
  filename: payload.fileName,
3884
3884
  size: payload.size,
3885
3885
  mime: payload.mimeType,
3886
- folder_id: (_a68 = payload.folderId) != null ? _a68 : null,
3887
- overwritePolicy: (_b4 = payload.conflict) != null ? _b4 : "ask",
3886
+ folder_id: (_a66 = payload.folderId) != null ? _a66 : null,
3887
+ overwritePolicy: (_b3 = payload.conflict) != null ? _b3 : "ask",
3888
3888
  fileName: payload.fileName,
3889
3889
  mimeType: payload.mimeType,
3890
3890
  folderId: payload.folderId,
@@ -3892,10 +3892,10 @@ var toInitPayloadForFunctions = (payload) => {
3892
3892
  };
3893
3893
  };
3894
3894
  var normalizeInitResponseFromFunctions = (response) => {
3895
- var _a68, _b4, _c, _d, _e, _f, _g;
3895
+ var _a66, _b3, _c, _d, _e, _f, _g;
3896
3896
  const payload = response != null ? response : {};
3897
- const existingRaw = (_a68 = payload.existingAsset) != null ? _a68 : payload.existing_asset;
3898
- const existingAsset = existingRaw ? (_b4 = mapGenericRowToAsset(existingRaw)) != null ? _b4 : void 0 : void 0;
3897
+ const existingRaw = (_a66 = payload.existingAsset) != null ? _a66 : payload.existing_asset;
3898
+ const existingAsset = existingRaw ? (_b3 = mapGenericRowToAsset(existingRaw)) != null ? _b3 : void 0 : void 0;
3899
3899
  const assetRaw = payload.asset;
3900
3900
  const asset = assetRaw ? (_c = mapGenericRowToAsset(assetRaw)) != null ? _c : void 0 : void 0;
3901
3901
  const conflictSource = (_e = readString(payload.conflict)) != null ? _e : readString((_d = payload.conflict) == null ? void 0 : _d.type);
@@ -3916,12 +3916,12 @@ var normalizeInitResponseFromFunctions = (response) => {
3916
3916
  };
3917
3917
  };
3918
3918
  var toCompletePayloadForFunctions = (payload) => {
3919
- var _a68, _b4, _c;
3919
+ var _a66, _b3, _c;
3920
3920
  return {
3921
3921
  uploadId: payload.uploadId,
3922
- assetDraftId: (_a68 = payload.assetDraftId) != null ? _a68 : payload.assetId,
3922
+ assetDraftId: (_a66 = payload.assetDraftId) != null ? _a66 : payload.assetId,
3923
3923
  storageKey: payload.storageKey,
3924
- finalFilename: (_b4 = payload.finalFilename) != null ? _b4 : payload.fileName,
3924
+ finalFilename: (_b3 = payload.finalFilename) != null ? _b3 : payload.fileName,
3925
3925
  folder_id: (_c = payload.folderId) != null ? _c : null,
3926
3926
  upload_id: payload.uploadId,
3927
3927
  asset_id: payload.assetId,
@@ -3929,16 +3929,16 @@ var toCompletePayloadForFunctions = (payload) => {
3929
3929
  };
3930
3930
  };
3931
3931
  var normalizeCompleteResponseFromFunctions = (response) => {
3932
- var _a68, _b4, _c, _d, _e, _f;
3932
+ var _a66, _b3, _c, _d, _e, _f;
3933
3933
  const payload = response != null ? response : {};
3934
- const assetRaw = (_a68 = payload.asset) != null ? _a68 : payload;
3934
+ const assetRaw = (_a66 = payload.asset) != null ? _a66 : payload;
3935
3935
  const mapped = mapGenericRowToAsset(assetRaw);
3936
3936
  if (mapped) {
3937
3937
  const title = readFirstString(assetRaw, ["title", "title_text"]);
3938
3938
  const alt = readFirstString(assetRaw, ["alt", "alt_text"]);
3939
3939
  if (title || alt) {
3940
3940
  mapped.meta = {
3941
- ...(_b4 = mapped.meta) != null ? _b4 : {},
3941
+ ...(_b3 = mapped.meta) != null ? _b3 : {},
3942
3942
  ...title ? { title } : {},
3943
3943
  ...alt ? { alt } : {}
3944
3944
  };
@@ -3960,7 +3960,7 @@ var normalizeCompleteResponseFromFunctions = (response) => {
3960
3960
  return { asset: { id: assetId } };
3961
3961
  };
3962
3962
  var toMetaPayloadForFunctions = (payload) => {
3963
- var _a68;
3963
+ var _a66;
3964
3964
  if (payload.action && payload.action !== "update") {
3965
3965
  return payload;
3966
3966
  }
@@ -3970,7 +3970,7 @@ var toMetaPayloadForFunctions = (payload) => {
3970
3970
  en: {},
3971
3971
  es: {}
3972
3972
  };
3973
- const target = (_a68 = byLanguage[language]) != null ? _a68 : byLanguage.pt;
3973
+ const target = (_a66 = byLanguage[language]) != null ? _a66 : byLanguage.pt;
3974
3974
  if (payload.meta) {
3975
3975
  if (typeof payload.meta.alt === "string") target.alt = payload.meta.alt;
3976
3976
  if (typeof payload.meta.title === "string") target.title = payload.meta.title;
@@ -4033,14 +4033,14 @@ var createTelescupClient = (config) => ({
4033
4033
  body: toMetaPayloadForFunctions(payload)
4034
4034
  }),
4035
4035
  generateAlt: async (asset, language = "pt") => {
4036
- var _a68, _b4, _c;
4036
+ var _a66, _b3, _c;
4037
4037
  const response = await request(config, "generate-alt", {
4038
4038
  method: "POST",
4039
4039
  body: {
4040
4040
  items: [
4041
4041
  {
4042
4042
  id: asset.id,
4043
- file_path: (_a68 = asset.filePath) != null ? _a68 : asset.storageKey,
4043
+ file_path: (_a66 = asset.filePath) != null ? _a66 : asset.storageKey,
4044
4044
  mime_type: asset.mimeType
4045
4045
  }
4046
4046
  ],
@@ -4052,7 +4052,7 @@ var createTelescupClient = (config) => ({
4052
4052
  const titles = payload.titles && typeof payload.titles === "object" ? payload.titles : {};
4053
4053
  const results = Array.isArray(payload.results) ? payload.results : [];
4054
4054
  const row = results.find((item) => readFirstString(item, ["id"]) === asset.id);
4055
- const alt = (_b4 = readString(alts[asset.id])) != null ? _b4 : readFirstString(row != null ? row : {}, ["alt", "alt_text"]);
4055
+ const alt = (_b3 = readString(alts[asset.id])) != null ? _b3 : readFirstString(row != null ? row : {}, ["alt", "alt_text"]);
4056
4056
  const title = (_c = readString(titles[asset.id])) != null ? _c : readFirstString(row != null ? row : {}, ["title", "title_text"]);
4057
4057
  return {
4058
4058
  ...title ? { title } : {},
@@ -4070,12 +4070,12 @@ var createTelescupClient = (config) => ({
4070
4070
  });
4071
4071
  const payload = response != null ? response : {};
4072
4072
  const toMeta = (value) => {
4073
- var _a68;
4073
+ var _a66;
4074
4074
  if (!value || typeof value !== "object") return void 0;
4075
4075
  const row = value;
4076
4076
  const title = readString(row.title);
4077
4077
  const alt = readString(row.alt);
4078
- const description = (_a68 = readString(row.description)) != null ? _a68 : readString(row.desc);
4078
+ const description = (_a66 = readString(row.description)) != null ? _a66 : readString(row.desc);
4079
4079
  if (!title && !alt && !description) return void 0;
4080
4080
  return {
4081
4081
  ...title ? { title } : {},
@@ -4108,17 +4108,17 @@ var mergeFacetValues = (current, incoming) => {
4108
4108
  const map = /* @__PURE__ */ new Map();
4109
4109
  current == null ? void 0 : current.forEach((entry) => map.set(entry.value, entry));
4110
4110
  incoming == null ? void 0 : incoming.forEach((entry) => {
4111
- var _a68, _b4, _c;
4111
+ var _a66, _b3, _c;
4112
4112
  const previous = map.get(entry.value);
4113
4113
  map.set(entry.value, {
4114
4114
  value: entry.value,
4115
- label: (_b4 = (_a68 = entry.label) != null ? _a68 : previous == null ? void 0 : previous.label) != null ? _b4 : entry.value,
4115
+ label: (_b3 = (_a66 = entry.label) != null ? _a66 : previous == null ? void 0 : previous.label) != null ? _b3 : entry.value,
4116
4116
  count: (_c = entry.count) != null ? _c : previous == null ? void 0 : previous.count
4117
4117
  });
4118
4118
  });
4119
4119
  return Array.from(map.values()).sort((a, b) => {
4120
- var _a68, _b4;
4121
- return ((_a68 = a.label) != null ? _a68 : a.value).localeCompare((_b4 = b.label) != null ? _b4 : b.value);
4120
+ var _a66, _b3;
4121
+ return ((_a66 = a.label) != null ? _a66 : a.value).localeCompare((_b3 = b.label) != null ? _b3 : b.value);
4122
4122
  });
4123
4123
  };
4124
4124
  var DEFAULT_CACHE_MS = 3e5;
@@ -4212,9 +4212,9 @@ function useTelescupAssets(options) {
4212
4212
  ...sanitizeFilters(filters),
4213
4213
  pageSize
4214
4214
  }).then((data) => {
4215
- var _a68;
4215
+ var _a66;
4216
4216
  return {
4217
- items: (_a68 = data.items) != null ? _a68 : [],
4217
+ items: (_a66 = data.items) != null ? _a66 : [],
4218
4218
  nextCursor: data.nextCursor,
4219
4219
  total: data.total,
4220
4220
  facets: data.facets
@@ -4238,7 +4238,7 @@ function useTelescupAssets(options) {
4238
4238
  [cacheKey, cacheTimeMs, enabled, filters, pageSize, resolvedClient]
4239
4239
  );
4240
4240
  const loadMore = (0, import_react10.useCallback)(async () => {
4241
- var _a68, _b4, _c, _d, _e, _f, _g;
4241
+ var _a66, _b3, _c, _d, _e, _f, _g;
4242
4242
  if (!state.nextCursor || isLoadingMore || isLoading) return;
4243
4243
  const requestSeq = requestSeqRef.current;
4244
4244
  setIsLoadingMore(true);
@@ -4252,9 +4252,9 @@ function useTelescupAssets(options) {
4252
4252
  });
4253
4253
  if (!aliveRef.current || requestSeq !== requestSeqRef.current) return;
4254
4254
  const merged = {
4255
- items: [...state.items, ...(_a68 = data.items) != null ? _a68 : []],
4255
+ items: [...state.items, ...(_a66 = data.items) != null ? _a66 : []],
4256
4256
  nextCursor: data.nextCursor,
4257
- total: (_b4 = data.total) != null ? _b4 : state.total,
4257
+ total: (_b3 = data.total) != null ? _b3 : state.total,
4258
4258
  facets: {
4259
4259
  categories: mergeFacetValues(previousFacets == null ? void 0 : previousFacets.categories, (_c = data.facets) == null ? void 0 : _c.categories),
4260
4260
  folders: mergeFacetValues(previousFacets == null ? void 0 : previousFacets.folders, (_d = data.facets) == null ? void 0 : _d.folders),
@@ -4483,12 +4483,12 @@ var IMAGE_EXTENSIONS = /* @__PURE__ */ new Set(["jpg", "jpeg", "png", "gif", "we
4483
4483
  var VIDEO_EXTENSIONS = /* @__PURE__ */ new Set(["mp4", "mov", "webm", "mkv", "avi", "m4v", "wmv"]);
4484
4484
  var AUDIO_EXTENSIONS = /* @__PURE__ */ new Set(["mp3", "wav", "aac", "ogg", "flac", "m4a"]);
4485
4485
  var resolveAssetFamily = (asset) => {
4486
- var _a68, _b4, _c;
4487
- const explicitType = (_a68 = asset.type) == null ? void 0 : _a68.toLowerCase();
4486
+ var _a66, _b3, _c;
4487
+ const explicitType = (_a66 = asset.type) == null ? void 0 : _a66.toLowerCase();
4488
4488
  if (explicitType === "image" || explicitType === "video" || explicitType === "audio" || explicitType === "file") {
4489
4489
  return explicitType;
4490
4490
  }
4491
- const mime = (_b4 = asset.mimeType) == null ? void 0 : _b4.toLowerCase();
4491
+ const mime = (_b3 = asset.mimeType) == null ? void 0 : _b3.toLowerCase();
4492
4492
  if (mime == null ? void 0 : mime.startsWith("image/")) return "image";
4493
4493
  if (mime == null ? void 0 : mime.startsWith("video/")) return "video";
4494
4494
  if (mime == null ? void 0 : mime.startsWith("audio/")) return "audio";
@@ -4500,9 +4500,9 @@ var resolveAssetFamily = (asset) => {
4500
4500
  return "file";
4501
4501
  };
4502
4502
  var matchesAllowedAsset = (asset, allowed) => {
4503
- var _a68, _b4, _c, _d;
4503
+ var _a66, _b3, _c, _d;
4504
4504
  if (!allowed || allowed.length === 0) return true;
4505
- const mime = (_b4 = (_a68 = asset.mimeType) == null ? void 0 : _a68.toLowerCase()) != null ? _b4 : "";
4505
+ const mime = (_b3 = (_a66 = asset.mimeType) == null ? void 0 : _a66.toLowerCase()) != null ? _b3 : "";
4506
4506
  const ext = asset.extension ? `.${asset.extension.toLowerCase()}` : "";
4507
4507
  const type = (_d = (_c = asset.type) == null ? void 0 : _c.toLowerCase()) != null ? _d : "";
4508
4508
  const family = resolveAssetFamily(asset);
@@ -4557,10 +4557,10 @@ var UUID_REGEX2 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[
4557
4557
  var ROOT_FOLDERS_TO_HIDE = /* @__PURE__ */ new Set(["images", "videos"]);
4558
4558
  var normalizeFolderToken = (value) => value.trim().replace(/^\/+|\/+$/g, "").toLowerCase();
4559
4559
  var getLeafName = (value) => {
4560
- var _a68;
4560
+ var _a66;
4561
4561
  const normalized = normalizeFolderToken(value);
4562
4562
  const parts = normalized.split("/").filter(Boolean);
4563
- return (_a68 = parts[parts.length - 1]) != null ? _a68 : normalized;
4563
+ return (_a66 = parts[parts.length - 1]) != null ? _a66 : normalized;
4564
4564
  };
4565
4565
  var scoreFolderValue = (value, label) => {
4566
4566
  const normalizedValue = normalizeFolderToken(value);
@@ -4576,10 +4576,10 @@ var normalizeFacetOptions = (entries) => {
4576
4576
  if (!entries || !entries.length) return [];
4577
4577
  const byLabel = /* @__PURE__ */ new Map();
4578
4578
  entries.forEach((entry) => {
4579
- var _a68, _b4, _c, _d;
4580
- const value = (_a68 = entry.value) == null ? void 0 : _a68.trim();
4579
+ var _a66, _b3, _c, _d;
4580
+ const value = (_a66 = entry.value) == null ? void 0 : _a66.trim();
4581
4581
  if (!value) return;
4582
- const label = ((_b4 = entry.label) == null ? void 0 : _b4.trim()) || value;
4582
+ const label = ((_b3 = entry.label) == null ? void 0 : _b3.trim()) || value;
4583
4583
  const key = normalizeFolderToken(label);
4584
4584
  const incomingCount = typeof entry.count === "number" ? entry.count : 0;
4585
4585
  const existing = byLabel.get(key);
@@ -4607,16 +4607,16 @@ var normalizeFacetOptions = (entries) => {
4607
4607
  const options = Array.from(byLabel.values());
4608
4608
  const groups = /* @__PURE__ */ new Map();
4609
4609
  options.forEach((option) => {
4610
- var _a68;
4610
+ var _a66;
4611
4611
  const leaf = getLeafName(option.label || option.value);
4612
- const list = (_a68 = groups.get(leaf)) != null ? _a68 : [];
4612
+ const list = (_a66 = groups.get(leaf)) != null ? _a66 : [];
4613
4613
  list.push(option);
4614
4614
  groups.set(leaf, list);
4615
4615
  });
4616
4616
  const collapsed = options.filter((option) => {
4617
- var _a68;
4617
+ var _a66;
4618
4618
  const leaf = getLeafName(option.label || option.value);
4619
- const group = (_a68 = groups.get(leaf)) != null ? _a68 : [];
4619
+ const group = (_a66 = groups.get(leaf)) != null ? _a66 : [];
4620
4620
  const hasPathVariant = group.some((entry) => normalizeFolderToken(entry.label).includes("/"));
4621
4621
  if (!hasPathVariant) return true;
4622
4622
  return normalizeFolderToken(option.label).includes("/");
@@ -4627,13 +4627,13 @@ var normalizeFacetOptions = (entries) => {
4627
4627
  var collectFacetOptions = (items, pick, pickLabel) => {
4628
4628
  const options = /* @__PURE__ */ new Map();
4629
4629
  items.forEach((asset) => {
4630
- var _a68, _b4, _c, _d;
4631
- const value = (_a68 = pick(asset)) == null ? void 0 : _a68.trim();
4630
+ var _a66, _b3, _c, _d;
4631
+ const value = (_a66 = pick(asset)) == null ? void 0 : _a66.trim();
4632
4632
  if (!value) return;
4633
4633
  const current = options.get(value);
4634
4634
  options.set(value, {
4635
4635
  value,
4636
- label: ((_b4 = pickLabel == null ? void 0 : pickLabel(asset)) == null ? void 0 : _b4.trim()) || (current == null ? void 0 : current.label) || value,
4636
+ label: ((_b3 = pickLabel == null ? void 0 : pickLabel(asset)) == null ? void 0 : _b3.trim()) || (current == null ? void 0 : current.label) || value,
4637
4637
  count: ((_c = current == null ? void 0 : current.count) != null ? _c : 0) + 1,
4638
4638
  aliases: (_d = current == null ? void 0 : current.aliases) != null ? _d : [value]
4639
4639
  });
@@ -4707,22 +4707,22 @@ var TelescupAssetPicker = ({
4707
4707
  return folderOptions.find((option) => option.value === folderFilter);
4708
4708
  }, [folderFilter, folderOptions]);
4709
4709
  const filteredItems = (0, import_react11.useMemo)(() => {
4710
- var _a68;
4710
+ var _a66;
4711
4711
  const selectedFolderAliases = new Set(
4712
- ((_a68 = selectedFolderOption == null ? void 0 : selectedFolderOption.aliases) != null ? _a68 : folderFilter === "all" ? [] : [folderFilter]).map(
4712
+ ((_a66 = selectedFolderOption == null ? void 0 : selectedFolderOption.aliases) != null ? _a66 : folderFilter === "all" ? [] : [folderFilter]).map(
4713
4713
  (entry) => normalizeFolderToken(entry)
4714
4714
  )
4715
4715
  );
4716
4716
  return items.filter((asset) => {
4717
- var _a69, _b4;
4717
+ var _a67, _b3;
4718
4718
  if (!matchesAllowedAsset(asset, allowedTypes)) return false;
4719
4719
  if (typeFilter !== "all") {
4720
4720
  const family = resolveAssetFamily(asset);
4721
4721
  if (family !== typeFilter) return false;
4722
4722
  }
4723
4723
  if (folderFilter !== "all") {
4724
- const folderIdToken = normalizeFolderToken((_a69 = asset.folderId) != null ? _a69 : "");
4725
- const folderNameToken = normalizeFolderToken((_b4 = asset.folderName) != null ? _b4 : "");
4724
+ const folderIdToken = normalizeFolderToken((_a67 = asset.folderId) != null ? _a67 : "");
4725
+ const folderNameToken = normalizeFolderToken((_b3 = asset.folderName) != null ? _b3 : "");
4726
4726
  if (!selectedFolderAliases.has(folderIdToken) && !selectedFolderAliases.has(folderNameToken)) {
4727
4727
  return false;
4728
4728
  }
@@ -4733,9 +4733,9 @@ var TelescupAssetPicker = ({
4733
4733
  import_react11.default.useEffect(() => {
4734
4734
  if (!isRuntimeDev()) return;
4735
4735
  const familyCount = items.reduce((acc, asset) => {
4736
- var _a68, _b4;
4737
- const key = (_a68 = resolveAssetFamily(asset)) != null ? _a68 : "unknown";
4738
- acc[key] = ((_b4 = acc[key]) != null ? _b4 : 0) + 1;
4736
+ var _a66, _b3;
4737
+ const key = (_a66 = resolveAssetFamily(asset)) != null ? _a66 : "unknown";
4738
+ acc[key] = ((_b3 = acc[key]) != null ? _b3 : 0) + 1;
4739
4739
  return acc;
4740
4740
  }, {});
4741
4741
  console.log("[telescup][picker]", {
@@ -4984,14 +4984,14 @@ function useTelescupUploadQueue(options) {
4984
4984
  activeRef.current += 1;
4985
4985
  updateItem(next.id, { status: "uploading", progress: 0, error: void 0 });
4986
4986
  const run = async () => {
4987
- var _a68, _b4, _c;
4987
+ var _a66, _b3, _c;
4988
4988
  try {
4989
4989
  const init = await client.initUpload({
4990
4990
  fileName: next.file.name,
4991
4991
  size: next.file.size,
4992
4992
  mimeType: next.file.type,
4993
4993
  folderId,
4994
- conflict: (_a68 = next.conflictPolicy) != null ? _a68 : conflictPolicy
4994
+ conflict: (_a66 = next.conflictPolicy) != null ? _a66 : conflictPolicy
4995
4995
  });
4996
4996
  const conflictDetected = init.conflict === "ask" || init.conflict === "conflict" || init.conflict === "exists" || init.existingAsset && !init.uploadUrl;
4997
4997
  if (conflictDetected) {
@@ -5030,7 +5030,7 @@ function useTelescupUploadQueue(options) {
5030
5030
  storageKey: init.storageKey,
5031
5031
  finalFilename: init.finalFilename,
5032
5032
  folderId,
5033
- assetId: (_b4 = init.asset) == null ? void 0 : _b4.id,
5033
+ assetId: (_b3 = init.asset) == null ? void 0 : _b3.id,
5034
5034
  fileName: (_c = init.resolvedName) != null ? _c : next.file.name
5035
5035
  });
5036
5036
  updateItem(next.id, {
@@ -5129,7 +5129,7 @@ var TelescupUploader = ({
5129
5129
  className,
5130
5130
  onAssetUploaded
5131
5131
  }) => {
5132
- var _a68;
5132
+ var _a66;
5133
5133
  const inputRef = (0, import_react13.useRef)(null);
5134
5134
  const [dragActive, setDragActive] = (0, import_react13.useState)(false);
5135
5135
  const {
@@ -5196,8 +5196,8 @@ var TelescupUploader = ({
5196
5196
  size: "sm",
5197
5197
  variant: "secondary",
5198
5198
  onClick: () => {
5199
- var _a69;
5200
- return (_a69 = inputRef.current) == null ? void 0 : _a69.click();
5199
+ var _a67;
5200
+ return (_a67 = inputRef.current) == null ? void 0 : _a67.click();
5201
5201
  },
5202
5202
  children: labels.uploader.browse
5203
5203
  }
@@ -5211,8 +5211,8 @@ var TelescupUploader = ({
5211
5211
  accept,
5212
5212
  multiple,
5213
5213
  onChange: (event) => {
5214
- var _a69;
5215
- if ((_a69 = event.target.files) == null ? void 0 : _a69.length) {
5214
+ var _a67;
5215
+ if ((_a67 = event.target.files) == null ? void 0 : _a67.length) {
5216
5216
  handleFiles(event.target.files);
5217
5217
  event.currentTarget.value = "";
5218
5218
  }
@@ -5247,7 +5247,7 @@ var TelescupUploader = ({
5247
5247
  /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(AlertDialogTitle, { children: labels.conflict.title }),
5248
5248
  /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(AlertDialogDescription, { children: labels.conflict.description })
5249
5249
  ] }),
5250
- ((_a68 = conflictItem == null ? void 0 : conflictItem.existingAsset) == null ? void 0 : _a68.id) ? /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "mt-3 rounded-lg border border-border bg-muted/30 p-3", children: [
5250
+ ((_a66 = conflictItem == null ? void 0 : conflictItem.existingAsset) == null ? void 0 : _a66.id) ? /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "mt-3 rounded-lg border border-border bg-muted/30 p-3", children: [
5251
5251
  /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("p", { className: "text-xs font-semibold text-muted-foreground", children: "Asset existente" }),
5252
5252
  /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: "mt-2 h-28 overflow-hidden rounded-md", children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
5253
5253
  TelescupImage,
@@ -5470,7 +5470,7 @@ var DEFAULT_LABELS = {
5470
5470
  }
5471
5471
  };
5472
5472
  var mergeLabels = (overrides) => {
5473
- var _a68;
5473
+ var _a66;
5474
5474
  if (!overrides) return DEFAULT_LABELS;
5475
5475
  return {
5476
5476
  ...DEFAULT_LABELS,
@@ -5484,7 +5484,7 @@ var mergeLabels = (overrides) => {
5484
5484
  meta: {
5485
5485
  ...DEFAULT_LABELS.meta,
5486
5486
  ...overrides.meta,
5487
- fields: { ...DEFAULT_LABELS.meta.fields, ...(_a68 = overrides.meta) == null ? void 0 : _a68.fields }
5487
+ fields: { ...DEFAULT_LABELS.meta.fields, ...(_a66 = overrides.meta) == null ? void 0 : _a66.fields }
5488
5488
  },
5489
5489
  toasts: { ...DEFAULT_LABELS.toasts, ...overrides.toasts }
5490
5490
  };
@@ -5503,10 +5503,10 @@ var normalizeApiLanguageKey = (value) => {
5503
5503
  return "pt-BR";
5504
5504
  };
5505
5505
  var getAssetMeta = (asset, lang) => {
5506
- var _a68, _b4;
5506
+ var _a66, _b3;
5507
5507
  if (!asset) return {};
5508
- if ((_a68 = asset.metaByLang) == null ? void 0 : _a68[lang]) return asset.metaByLang[lang];
5509
- return (_b4 = asset.meta) != null ? _b4 : {};
5508
+ if ((_a66 = asset.metaByLang) == null ? void 0 : _a66[lang]) return asset.metaByLang[lang];
5509
+ return (_b3 = asset.meta) != null ? _b3 : {};
5510
5510
  };
5511
5511
  var TelescupMetaEditor = ({
5512
5512
  client,
@@ -5516,8 +5516,8 @@ var TelescupMetaEditor = ({
5516
5516
  labels,
5517
5517
  onAssetUpdated
5518
5518
  }) => {
5519
- var _a68, _b4, _c, _d, _e, _f, _g, _h;
5520
- const [activeAssetId, setActiveAssetId] = (0, import_react14.useState)((_b4 = (_a68 = assets[0]) == null ? void 0 : _a68.id) != null ? _b4 : "");
5519
+ var _a66, _b3, _c, _d, _e, _f, _g, _h;
5520
+ const [activeAssetId, setActiveAssetId] = (0, import_react14.useState)((_b3 = (_a66 = assets[0]) == null ? void 0 : _a66.id) != null ? _b3 : "");
5521
5521
  const [activeLang, setActiveLang] = (0, import_react14.useState)(
5522
5522
  LANGUAGES.includes(defaultLanguage) ? defaultLanguage : "pt"
5523
5523
  );
@@ -5535,18 +5535,18 @@ var TelescupMetaEditor = ({
5535
5535
  }, [activeAssetId, assets]);
5536
5536
  const asset = assets.find((item) => item.id === activeAssetId);
5537
5537
  const currentDraft = (0, import_react14.useMemo)(() => {
5538
- var _a69;
5539
- const existing = (_a69 = drafts[activeAssetId]) == null ? void 0 : _a69[activeLang];
5538
+ var _a67;
5539
+ const existing = (_a67 = drafts[activeAssetId]) == null ? void 0 : _a67[activeLang];
5540
5540
  if (existing) return existing;
5541
5541
  return getAssetMeta(asset, activeLang);
5542
5542
  }, [activeAssetId, activeLang, asset, drafts]);
5543
5543
  const updateDraft = (field, value) => {
5544
5544
  setDrafts((prev) => {
5545
- var _a69;
5545
+ var _a67;
5546
5546
  return {
5547
5547
  ...prev,
5548
5548
  [activeAssetId]: {
5549
- ...(_a69 = prev[activeAssetId]) != null ? _a69 : {},
5549
+ ...(_a67 = prev[activeAssetId]) != null ? _a67 : {},
5550
5550
  [activeLang]: {
5551
5551
  ...currentDraft,
5552
5552
  [field]: value
@@ -5614,11 +5614,11 @@ var TelescupMetaEditor = ({
5614
5614
  onAssetUpdated == null ? void 0 : onAssetUpdated(updated);
5615
5615
  const updatedMeta = getAssetMeta(updated, activeLang);
5616
5616
  setDrafts((prev) => {
5617
- var _a69;
5617
+ var _a67;
5618
5618
  return {
5619
5619
  ...prev,
5620
5620
  [asset.id]: {
5621
- ...(_a69 = prev[asset.id]) != null ? _a69 : {},
5621
+ ...(_a67 = prev[asset.id]) != null ? _a67 : {},
5622
5622
  [activeLang]: updatedMeta
5623
5623
  }
5624
5624
  };
@@ -5782,9 +5782,9 @@ var TelescupUpload = ({
5782
5782
  }, []);
5783
5783
  const enrichUploadedAsset = (0, import_react14.useCallback)(
5784
5784
  async (asset) => {
5785
- var _a68, _b4, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
5785
+ var _a66, _b3, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
5786
5786
  if (!autoGenerateMetadataOnUpload) return asset;
5787
- const mimeType = (_b4 = (_a68 = asset.mimeType) == null ? void 0 : _a68.toLowerCase()) != null ? _b4 : "";
5787
+ const mimeType = (_b3 = (_a66 = asset.mimeType) == null ? void 0 : _a66.toLowerCase()) != null ? _b3 : "";
5788
5788
  const assetType = (_d = (_c = asset.type) == null ? void 0 : _c.toLowerCase()) != null ? _d : "";
5789
5789
  const isImage = assetType === "image" || mimeType.startsWith("image/");
5790
5790
  if (!isImage) return asset;
@@ -6046,14 +6046,14 @@ function parseStoredThemePreference(value) {
6046
6046
  return value === "light" || value === "dark" || value === "system" ? value : null;
6047
6047
  }
6048
6048
  function normalizeStoredThemePreference(value) {
6049
- var _a68;
6050
- return (_a68 = parseStoredThemePreference(value)) != null ? _a68 : "system";
6049
+ var _a66;
6050
+ return (_a66 = parseStoredThemePreference(value)) != null ? _a66 : "system";
6051
6051
  }
6052
6052
  function readStoredThemeMode() {
6053
- var _a68;
6053
+ var _a66;
6054
6054
  if (typeof window === "undefined") return null;
6055
6055
  try {
6056
- const storedTheme = (_a68 = window.localStorage.getItem(THEME_STORAGE_KEY)) != null ? _a68 : window.localStorage.getItem(LEGACY_THEME_STORAGE_KEY);
6056
+ const storedTheme = (_a66 = window.localStorage.getItem(THEME_STORAGE_KEY)) != null ? _a66 : window.localStorage.getItem(LEGACY_THEME_STORAGE_KEY);
6057
6057
  return isStoredThemeMode(storedTheme) ? storedTheme : null;
6058
6058
  } catch (e) {
6059
6059
  return null;
@@ -6109,7 +6109,7 @@ function persistThemePreferenceSelection(preference) {
6109
6109
  );
6110
6110
  }
6111
6111
  function resolveStoredThemePreference(experienceSettingsTheme) {
6112
- var _a68;
6112
+ var _a66;
6113
6113
  if (typeof window === "undefined") {
6114
6114
  return normalizeStoredThemePreference(experienceSettingsTheme);
6115
6115
  }
@@ -6125,7 +6125,7 @@ function resolveStoredThemePreference(experienceSettingsTheme) {
6125
6125
  if (parsedExperienceTheme === "system" && storedThemeMode) {
6126
6126
  return storedThemeMode;
6127
6127
  }
6128
- return (_a68 = parsedExperienceTheme != null ? parsedExperienceTheme : storedThemeMode) != null ? _a68 : "system";
6128
+ return (_a66 = parsedExperienceTheme != null ? parsedExperienceTheme : storedThemeMode) != null ? _a66 : "system";
6129
6129
  } catch (e) {
6130
6130
  return normalizeStoredThemePreference(experienceSettingsTheme);
6131
6131
  }
@@ -6259,11 +6259,6 @@ var LANGUAGE_OPTIONS = [
6259
6259
  { value: "en-US", shortLabel: "EN", label: "English" },
6260
6260
  { value: "es-ES", shortLabel: "ES", label: "Espa\xF1ol" }
6261
6261
  ];
6262
- var THEME_OPTIONS = [
6263
- { value: "light", label: "Light", icon: import_lucide_react8.Sun },
6264
- { value: "dark", label: "Dark", icon: import_lucide_react8.Moon },
6265
- { value: "system", label: "Sistema", icon: import_lucide_react8.Monitor }
6266
- ];
6267
6262
  var DENSITY_OPTIONS = [
6268
6263
  { value: "compact", label: "Compacto" },
6269
6264
  { value: "comfortable", label: "Confort\xE1vel" }
@@ -6541,7 +6536,7 @@ var getNotificationTimestamp = (notification) => {
6541
6536
  return Number.isNaN(parsed) ? 0 : parsed;
6542
6537
  };
6543
6538
  var formatNotificationDateTime = (notification) => {
6544
- var _a68;
6539
+ var _a66;
6545
6540
  if (notification.createdAt) {
6546
6541
  const parsed = new Date(notification.createdAt);
6547
6542
  if (!Number.isNaN(parsed.getTime())) {
@@ -6553,7 +6548,7 @@ var formatNotificationDateTime = (notification) => {
6553
6548
  });
6554
6549
  }
6555
6550
  }
6556
- return ((_a68 = notification.timeLabel) == null ? void 0 : _a68.trim()) || "Agora";
6551
+ return ((_a66 = notification.timeLabel) == null ? void 0 : _a66.trim()) || "Agora";
6557
6552
  };
6558
6553
  var getNotificationDayKey = (notification) => {
6559
6554
  const timestamp = getNotificationTimestamp(notification);
@@ -6626,22 +6621,22 @@ var extractSharedFilesFromMessages = (messages) => {
6626
6621
  return files;
6627
6622
  };
6628
6623
  var resolveTelescupImageUrl = (value, options) => {
6629
- var _a68, _b4, _c;
6624
+ var _a66, _b3, _c;
6630
6625
  return resolveTelescupImageURL(value, {
6631
- width: (_a68 = options == null ? void 0 : options.width) != null ? _a68 : 96,
6632
- height: (_b4 = options == null ? void 0 : options.height) != null ? _b4 : 96,
6626
+ width: (_a66 = options == null ? void 0 : options.width) != null ? _a66 : 96,
6627
+ height: (_b3 = options == null ? void 0 : options.height) != null ? _b3 : 96,
6633
6628
  fit: "cover",
6634
6629
  format: "avif",
6635
6630
  quality: (_c = options == null ? void 0 : options.quality) != null ? _c : 72
6636
6631
  });
6637
6632
  };
6638
6633
  var resolveGroupAvatarFromTelescup = (asset, fallbackId) => {
6639
- var _a68, _b4;
6640
- return (_b4 = (_a68 = resolveTelescupImageUrl(asset == null ? void 0 : asset.url)) != null ? _a68 : resolveTelescupImageUrl(asset == null ? void 0 : asset.id)) != null ? _b4 : resolveTelescupImageUrl(fallbackId);
6634
+ var _a66, _b3;
6635
+ return (_b3 = (_a66 = resolveTelescupImageUrl(asset == null ? void 0 : asset.url)) != null ? _a66 : resolveTelescupImageUrl(asset == null ? void 0 : asset.id)) != null ? _b3 : resolveTelescupImageUrl(fallbackId);
6641
6636
  };
6642
6637
  var resolveProfileAvatarFromTelescup = (asset, fallbackId) => {
6643
- var _a68, _b4;
6644
- return (_b4 = (_a68 = resolveTelescupImageUrl(asset == null ? void 0 : asset.url, { width: 384, height: 384, quality: 80 })) != null ? _a68 : resolveTelescupImageUrl(asset == null ? void 0 : asset.id, { width: 384, height: 384, quality: 80 })) != null ? _b4 : resolveTelescupImageUrl(fallbackId, { width: 384, height: 384, quality: 80 });
6638
+ var _a66, _b3;
6639
+ return (_b3 = (_a66 = resolveTelescupImageUrl(asset == null ? void 0 : asset.url, { width: 384, height: 384, quality: 80 })) != null ? _a66 : resolveTelescupImageUrl(asset == null ? void 0 : asset.id, { width: 384, height: 384, quality: 80 })) != null ? _b3 : resolveTelescupImageUrl(fallbackId, { width: 384, height: 384, quality: 80 });
6645
6640
  };
6646
6641
  var playIncomingMessageSound = () => {
6647
6642
  if (typeof window === "undefined") return;
@@ -6780,7 +6775,7 @@ var UserMenuCupcode = ({
6780
6775
  panels,
6781
6776
  className
6782
6777
  }) => {
6783
- var _a68;
6778
+ var _a66;
6784
6779
  const [open, setOpen] = (0, import_react15.useState)(false);
6785
6780
  const [activeTab, setActiveTab] = (0, import_react15.useState)("profile");
6786
6781
  const [isLoggingOut, setIsLoggingOut] = (0, import_react15.useState)(false);
@@ -6885,12 +6880,12 @@ var UserMenuCupcode = ({
6885
6880
  );
6886
6881
  const normalizedNotificationFeed = (0, import_react15.useMemo)(
6887
6882
  () => resolvedNotificationFeed.map((notification) => {
6888
- var _a69;
6883
+ var _a67;
6889
6884
  const kind = normalizeNotificationKind(notification.kind);
6890
6885
  return {
6891
6886
  ...notification,
6892
6887
  kind,
6893
- topic: (_a69 = notification.topic) != null ? _a69 : NOTIFICATION_KIND_META[kind].topicFallback
6888
+ topic: (_a67 = notification.topic) != null ? _a67 : NOTIFICATION_KIND_META[kind].topicFallback
6894
6889
  };
6895
6890
  }),
6896
6891
  [resolvedNotificationFeed]
@@ -6925,10 +6920,10 @@ var UserMenuCupcode = ({
6925
6920
  const groupedNotifications = (0, import_react15.useMemo)(() => {
6926
6921
  const groups = /* @__PURE__ */ new Map();
6927
6922
  filteredNotifications.forEach((notification) => {
6928
- var _a69, _b4;
6923
+ var _a67, _b3;
6929
6924
  const kind = normalizeNotificationKind(notification.kind);
6930
- const key = notificationPreferences.grouping === "topic" ? (_a69 = notification.topic) != null ? _a69 : NOTIFICATION_KIND_META[kind].topicFallback : getNotificationDayKey(notification);
6931
- const current = (_b4 = groups.get(key)) != null ? _b4 : [];
6925
+ const key = notificationPreferences.grouping === "topic" ? (_a67 = notification.topic) != null ? _a67 : NOTIFICATION_KIND_META[kind].topicFallback : getNotificationDayKey(notification);
6926
+ const current = (_b3 = groups.get(key)) != null ? _b3 : [];
6932
6927
  current.push(notification);
6933
6928
  groups.set(key, current);
6934
6929
  });
@@ -7015,7 +7010,7 @@ var UserMenuCupcode = ({
7015
7010
  }).slice(0, 6);
7016
7011
  }, [recentActivity]);
7017
7012
  const isSendingChatMessage = isChatSending || isSendingInternalChatMessage;
7018
- const activeReactionPickerMessageId = (_a68 = activeReactionPicker == null ? void 0 : activeReactionPicker.messageId) != null ? _a68 : null;
7013
+ const activeReactionPickerMessageId = (_a66 = activeReactionPicker == null ? void 0 : activeReactionPicker.messageId) != null ? _a66 : null;
7019
7014
  const isChatSidebarOpen = isChatSidebarExpanded || isChatSidebarPinned;
7020
7015
  const hasTelescupAvatarSupport = Boolean(telescupBaseUrl && getTelescupAccessToken);
7021
7016
  const hasTelescupGroupAvatarSupport = hasTelescupAvatarSupport;
@@ -7066,8 +7061,8 @@ var UserMenuCupcode = ({
7066
7061
  meta.set(user.id, { lastMessage: null, lastTimestamp: 0, unreadCount: 0 });
7067
7062
  });
7068
7063
  resolvedAllChatMessages.forEach((message) => {
7069
- var _a69;
7070
- const current = (_a69 = meta.get(message.contactId)) != null ? _a69 : { lastMessage: null, lastTimestamp: 0, unreadCount: 0 };
7064
+ var _a67;
7065
+ const current = (_a67 = meta.get(message.contactId)) != null ? _a67 : { lastMessage: null, lastTimestamp: 0, unreadCount: 0 };
7071
7066
  const timestamp = getChatMessageTimestamp(message);
7072
7067
  if (timestamp >= current.lastTimestamp) {
7073
7068
  current.lastTimestamp = timestamp;
@@ -7087,11 +7082,11 @@ var UserMenuCupcode = ({
7087
7082
  return haystack.includes(query);
7088
7083
  });
7089
7084
  return filtered.sort((left, right) => {
7090
- var _a69, _b4, _c, _d;
7085
+ var _a67, _b3, _c, _d;
7091
7086
  const leftMeta = conversationMetaByUserId.get(left.id);
7092
7087
  const rightMeta = conversationMetaByUserId.get(right.id);
7093
- const leftUnread = (_a69 = leftMeta == null ? void 0 : leftMeta.unreadCount) != null ? _a69 : 0;
7094
- const rightUnread = (_b4 = rightMeta == null ? void 0 : rightMeta.unreadCount) != null ? _b4 : 0;
7088
+ const leftUnread = (_a67 = leftMeta == null ? void 0 : leftMeta.unreadCount) != null ? _a67 : 0;
7089
+ const rightUnread = (_b3 = rightMeta == null ? void 0 : rightMeta.unreadCount) != null ? _b3 : 0;
7095
7090
  if (leftUnread !== rightUnread) return rightUnread - leftUnread;
7096
7091
  const leftTimestamp = (_c = leftMeta == null ? void 0 : leftMeta.lastTimestamp) != null ? _c : 0;
7097
7092
  const rightTimestamp = (_d = rightMeta == null ? void 0 : rightMeta.lastTimestamp) != null ? _d : 0;
@@ -7140,11 +7135,11 @@ var UserMenuCupcode = ({
7140
7135
  let changed = false;
7141
7136
  const next = { ...current };
7142
7137
  normalizedNotificationFeed.forEach((notification) => {
7143
- var _a69;
7138
+ var _a67;
7144
7139
  if (normalizeNotificationKind(notification.kind) !== "chat") return;
7145
7140
  const contactId = notification.actionChatUserId;
7146
7141
  if (!contactId) return;
7147
- if (((_a69 = resolvedChatUnreadByUser[contactId]) != null ? _a69 : 0) > 0) return;
7142
+ if (((_a67 = resolvedChatUnreadByUser[contactId]) != null ? _a67 : 0) > 0) return;
7148
7143
  if (next[notification.id] === true) return;
7149
7144
  next[notification.id] = true;
7150
7145
  changed = true;
@@ -7158,11 +7153,11 @@ var UserMenuCupcode = ({
7158
7153
  const visibleChatUnreadCount = resolvedChatUnreadCount;
7159
7154
  const firstUnreadChatUserId = (0, import_react15.useMemo)(
7160
7155
  () => {
7161
- var _a69, _b4;
7162
- return (_b4 = (_a69 = filteredAndSortedChatUsers.find((user) => {
7163
- var _a70;
7164
- return ((_a70 = resolvedChatUnreadByUser[user.id]) != null ? _a70 : 0) > 0;
7165
- })) == null ? void 0 : _a69.id) != null ? _b4 : null;
7156
+ var _a67, _b3;
7157
+ return (_b3 = (_a67 = filteredAndSortedChatUsers.find((user) => {
7158
+ var _a68;
7159
+ return ((_a68 = resolvedChatUnreadByUser[user.id]) != null ? _a68 : 0) > 0;
7160
+ })) == null ? void 0 : _a67.id) != null ? _b3 : null;
7166
7161
  },
7167
7162
  [filteredAndSortedChatUsers, resolvedChatUnreadByUser]
7168
7163
  );
@@ -7221,11 +7216,11 @@ var UserMenuCupcode = ({
7221
7216
  );
7222
7217
  const openChatPanel = (0, import_react15.useCallback)(
7223
7218
  (contactId) => {
7224
- var _a69, _b4, _c, _d, _e;
7219
+ var _a67, _b3, _c, _d, _e;
7225
7220
  setIsLogoutConfirmOpen(false);
7226
7221
  setOpen(true);
7227
7222
  setActiveTab("chat");
7228
- const targetContactId = (_e = (_d = (_b4 = contactId != null ? contactId : firstUnreadChatUserId) != null ? _b4 : (_a69 = filteredAndSortedChatUsers[0]) == null ? void 0 : _a69.id) != null ? _d : (_c = chatUsersList[0]) == null ? void 0 : _c.id) != null ? _e : "";
7223
+ const targetContactId = (_e = (_d = (_b3 = contactId != null ? contactId : firstUnreadChatUserId) != null ? _b3 : (_a67 = filteredAndSortedChatUsers[0]) == null ? void 0 : _a67.id) != null ? _d : (_c = chatUsersList[0]) == null ? void 0 : _c.id) != null ? _e : "";
7229
7224
  if (!targetContactId) return;
7230
7225
  setActiveChatUserId(targetContactId);
7231
7226
  markConversationRead(targetContactId);
@@ -7259,9 +7254,9 @@ var UserMenuCupcode = ({
7259
7254
  const reactionsByMessageId = (0, import_react15.useMemo)(() => {
7260
7255
  const grouped = /* @__PURE__ */ new Map();
7261
7256
  resolvedAllChatReactions.forEach((reaction) => {
7262
- var _a69, _b4;
7263
- const byEmoji = (_a69 = grouped.get(reaction.messageId)) != null ? _a69 : /* @__PURE__ */ new Map();
7264
- const current = (_b4 = byEmoji.get(reaction.emoji)) != null ? _b4 : { emoji: reaction.emoji, count: 0, reactedByMe: false };
7257
+ var _a67, _b3;
7258
+ const byEmoji = (_a67 = grouped.get(reaction.messageId)) != null ? _a67 : /* @__PURE__ */ new Map();
7259
+ const current = (_b3 = byEmoji.get(reaction.emoji)) != null ? _b3 : { emoji: reaction.emoji, count: 0, reactedByMe: false };
7265
7260
  current.count += 1;
7266
7261
  if (resolvedCurrentChatUserId && reaction.userId === resolvedCurrentChatUserId) {
7267
7262
  current.reactedByMe = true;
@@ -7469,9 +7464,9 @@ var UserMenuCupcode = ({
7469
7464
  const wasFocusModeActive = wasFocusModeActiveRef.current;
7470
7465
  if (wasFocusModeActive && !isFocusModeActive && suppressedFocusNotifications.length) {
7471
7466
  const byType = suppressedFocusNotifications.reduce((acc, notification) => {
7472
- var _a69;
7467
+ var _a67;
7473
7468
  const kind = normalizeNotificationKind(notification.kind);
7474
- acc[kind] = ((_a69 = acc[kind]) != null ? _a69 : 0) + 1;
7469
+ acc[kind] = ((_a67 = acc[kind]) != null ? _a67 : 0) + 1;
7475
7470
  return acc;
7476
7471
  }, { system: 0, comment: 0, access: 0, billing: 0, chat: 0, security: 0 });
7477
7472
  const summaryParts = NOTIFICATION_KIND_ORDER.filter((kind) => byType[kind] > 0).map(
@@ -7501,9 +7496,9 @@ var UserMenuCupcode = ({
7501
7496
  return;
7502
7497
  }
7503
7498
  setActiveChatUserId((current) => {
7504
- var _a69, _b4;
7499
+ var _a67, _b3;
7505
7500
  if (current && chatUsersList.some((user) => user.id === current)) return current;
7506
- return (_b4 = (_a69 = filteredAndSortedChatUsers[0]) == null ? void 0 : _a69.id) != null ? _b4 : chatUsersList[0].id;
7501
+ return (_b3 = (_a67 = filteredAndSortedChatUsers[0]) == null ? void 0 : _a67.id) != null ? _b3 : chatUsersList[0].id;
7507
7502
  });
7508
7503
  }, [chatUsersList, filteredAndSortedChatUsers]);
7509
7504
  (0, import_react15.useEffect)(() => {
@@ -7545,7 +7540,7 @@ var UserMenuCupcode = ({
7545
7540
  };
7546
7541
  }, [activeReactionPickerMessageId]);
7547
7542
  (0, import_react15.useEffect)(() => {
7548
- var _a69;
7543
+ var _a67;
7549
7544
  if (!hasBootstrappedIncomingMessagesRef.current && isChatLoading) return;
7550
7545
  const knownIncomingIds = seenIncomingMessageIdsRef.current;
7551
7546
  const incomingMessages = resolvedAllChatMessages.filter((message) => message.sender === "them" && !message.readAt);
@@ -7567,14 +7562,14 @@ var UserMenuCupcode = ({
7567
7562
  return;
7568
7563
  }
7569
7564
  const generatedNotifications = relevantIncomingMessages.map((message) => {
7570
- var _a70, _b4, _c;
7565
+ var _a68, _b3, _c;
7571
7566
  const contact = chatUsersList.find((user) => user.id === message.contactId);
7572
- const createdAt = (_a70 = message.createdAt) != null ? _a70 : (/* @__PURE__ */ new Date()).toISOString();
7567
+ const createdAt = (_a68 = message.createdAt) != null ? _a68 : (/* @__PURE__ */ new Date()).toISOString();
7573
7568
  const previewText = chatSettings.showMessagePreview ? summarizeChatText(message.text, 100) : "Nova mensagem no chat.";
7574
7569
  return {
7575
7570
  id: `chat-notification-${message.id}`,
7576
7571
  kind: "chat",
7577
- title: `Mensagem de ${(_b4 = contact == null ? void 0 : contact.name) != null ? _b4 : "usu\xE1rio"}`,
7572
+ title: `Mensagem de ${(_b3 = contact == null ? void 0 : contact.name) != null ? _b3 : "usu\xE1rio"}`,
7578
7573
  description: previewText,
7579
7574
  createdAt,
7580
7575
  timeLabel: formatChatTime({ ...message, createdAt }),
@@ -7591,7 +7586,7 @@ var UserMenuCupcode = ({
7591
7586
  )[0];
7592
7587
  if (latestRelevantMessage) {
7593
7588
  const latestContact = chatUsersList.find((user) => user.id === latestRelevantMessage.contactId);
7594
- const senderName = (_a69 = latestContact == null ? void 0 : latestContact.name) != null ? _a69 : "usu\xE1rio";
7589
+ const senderName = (_a67 = latestContact == null ? void 0 : latestContact.name) != null ? _a67 : "usu\xE1rio";
7595
7590
  const latestPreview = chatSettings.showMessagePreview ? summarizeChatText(latestRelevantMessage.text, 96) : "Nova mensagem";
7596
7591
  const messageCount = relevantIncomingMessages.length;
7597
7592
  const messageCountLabel = messageCount > 99 ? "99+" : String(messageCount);
@@ -7640,10 +7635,10 @@ var UserMenuCupcode = ({
7640
7635
  return;
7641
7636
  }
7642
7637
  generatedNotifications.forEach((chatNotification) => {
7643
- var _a70;
7638
+ var _a68;
7644
7639
  const notification = new Notification(chatNotification.title, {
7645
7640
  body: chatSettings.showMessagePreview ? chatNotification.description : "Voc\xEA recebeu uma nova mensagem.",
7646
- tag: `cc-chat-${(_a70 = chatNotification.actionChatUserId) != null ? _a70 : chatNotification.id}`
7641
+ tag: `cc-chat-${(_a68 = chatNotification.actionChatUserId) != null ? _a68 : chatNotification.id}`
7647
7642
  });
7648
7643
  notification.onclick = () => {
7649
7644
  window.focus();
@@ -7670,31 +7665,31 @@ var UserMenuCupcode = ({
7670
7665
  ]);
7671
7666
  const activeChatUser = (0, import_react15.useMemo)(
7672
7667
  () => {
7673
- var _a69;
7674
- return (_a69 = chatUsersList.find((user) => user.id === activeChatUserId)) != null ? _a69 : null;
7668
+ var _a67;
7669
+ return (_a67 = chatUsersList.find((user) => user.id === activeChatUserId)) != null ? _a67 : null;
7675
7670
  },
7676
7671
  [activeChatUserId, chatUsersList]
7677
7672
  );
7678
7673
  const activeGroupMembers = (0, import_react15.useMemo)(() => {
7679
- var _a69;
7680
- if (!(activeChatUser == null ? void 0 : activeChatUser.isGroup) || !((_a69 = activeChatUser.memberIds) == null ? void 0 : _a69.length)) return [];
7674
+ var _a67;
7675
+ if (!(activeChatUser == null ? void 0 : activeChatUser.isGroup) || !((_a67 = activeChatUser.memberIds) == null ? void 0 : _a67.length)) return [];
7681
7676
  const members = activeChatUser.memberIds.map((memberId) => baseChatUsersList.find((user) => user.id === memberId)).filter((member) => Boolean(member));
7682
7677
  return members;
7683
7678
  }, [activeChatUser, baseChatUsersList]);
7684
7679
  const activeChatStatusLabel = (0, import_react15.useMemo)(() => {
7685
- var _a69;
7680
+ var _a67;
7686
7681
  if (!activeChatUser) return "";
7687
7682
  if (activeChatUser.isGroup) return "Grupo";
7688
- return (_a69 = activeChatUser.statusLabel) != null ? _a69 : PRESENCE_META[activeChatUser.status].label;
7683
+ return (_a67 = activeChatUser.statusLabel) != null ? _a67 : PRESENCE_META[activeChatUser.status].label;
7689
7684
  }, [activeChatUser]);
7690
7685
  const activeChatLastSeenDetail = (0, import_react15.useMemo)(() => {
7691
7686
  if (!activeChatUser || activeChatUser.isGroup) return null;
7692
7687
  return extractLastSeenDetail(activeChatStatusLabel);
7693
7688
  }, [activeChatStatusLabel, activeChatUser]);
7694
7689
  const activeChatRoleBadgeLabel = (0, import_react15.useMemo)(() => {
7695
- var _a69;
7690
+ var _a67;
7696
7691
  if (!activeChatUser || activeChatUser.isGroup) return null;
7697
- const normalizedRoleLabel = (_a69 = activeChatUser.roleLabel) == null ? void 0 : _a69.trim();
7692
+ const normalizedRoleLabel = (_a67 = activeChatUser.roleLabel) == null ? void 0 : _a67.trim();
7698
7693
  return normalizedRoleLabel || null;
7699
7694
  }, [activeChatUser]);
7700
7695
  const activeChatMessages = (0, import_react15.useMemo)(() => {
@@ -7732,8 +7727,8 @@ var UserMenuCupcode = ({
7732
7727
  return items;
7733
7728
  }, [activeChatMessages]);
7734
7729
  (0, import_react15.useEffect)(() => {
7735
- var _a69;
7736
- const conversationId = (_a69 = activeChatUser == null ? void 0 : activeChatUser.id) != null ? _a69 : null;
7730
+ var _a67;
7731
+ const conversationId = (_a67 = activeChatUser == null ? void 0 : activeChatUser.id) != null ? _a67 : null;
7737
7732
  if (!conversationId) {
7738
7733
  activeConversationIdRef.current = null;
7739
7734
  activeConversationMessageIdsRef.current = /* @__PURE__ */ new Set();
@@ -7786,9 +7781,9 @@ var UserMenuCupcode = ({
7786
7781
  });
7787
7782
  }, [activeChatUser, resolvedChatLogs]);
7788
7783
  const replyToMessage = (0, import_react15.useMemo)(() => {
7789
- var _a69;
7784
+ var _a67;
7790
7785
  if (!replyToMessageId) return null;
7791
- return (_a69 = activeChatMessagesMap.get(replyToMessageId)) != null ? _a69 : null;
7786
+ return (_a67 = activeChatMessagesMap.get(replyToMessageId)) != null ? _a67 : null;
7792
7787
  }, [activeChatMessagesMap, replyToMessageId]);
7793
7788
  (0, import_react15.useEffect)(() => {
7794
7789
  if (!replyToMessageId) return;
@@ -7815,9 +7810,9 @@ var UserMenuCupcode = ({
7815
7810
  }
7816
7811
  }, [activeChatUser]);
7817
7812
  (0, import_react15.useEffect)(() => {
7818
- var _a69;
7813
+ var _a67;
7819
7814
  if (!open || activeTab !== "chat" || !activeChatUser || activeChatUser.isGroup) return;
7820
- const unreadCount = (_a69 = resolvedChatUnreadByUser[activeChatUser.id]) != null ? _a69 : 0;
7815
+ const unreadCount = (_a67 = resolvedChatUnreadByUser[activeChatUser.id]) != null ? _a67 : 0;
7821
7816
  if (unreadCount <= 0) return;
7822
7817
  const contactId = activeChatUser.id;
7823
7818
  if (pendingReadRequestsRef.current.has(contactId)) return;
@@ -7893,13 +7888,13 @@ var UserMenuCupcode = ({
7893
7888
  openAccountsPath("/security#sessions");
7894
7889
  };
7895
7890
  const runOpenIntegrations = (provider) => {
7896
- var _a69;
7891
+ var _a67;
7897
7892
  if (!provider) {
7898
7893
  openAccountsPath("/integrations");
7899
7894
  return;
7900
7895
  }
7901
7896
  const option = INTEGRATION_OPTIONS.find((integration) => integration.id === provider);
7902
- openAccountsPath((_a69 = option == null ? void 0 : option.accountPath) != null ? _a69 : "/integrations");
7897
+ openAccountsPath((_a67 = option == null ? void 0 : option.accountPath) != null ? _a67 : "/integrations");
7903
7898
  };
7904
7899
  const changeStatus = (nextStatus) => {
7905
7900
  if (nextStatus === "offline") return;
@@ -8266,10 +8261,10 @@ var UserMenuCupcode = ({
8266
8261
  };
8267
8262
  const handleProfileAvatarChange = (0, import_react15.useCallback)(
8268
8263
  async (ids, assets) => {
8269
- var _a69, _b4, _c;
8264
+ var _a67, _b3, _c;
8270
8265
  const selectedAsset = assets == null ? void 0 : assets[0];
8271
- const selectedIdRaw = (_a69 = ids[0]) == null ? void 0 : _a69.trim();
8272
- const selectedId = (_c = (_b4 = parseAssetId(selectedIdRaw)) != null ? _b4 : parseAssetId(selectedAsset == null ? void 0 : selectedAsset.id)) != null ? _c : parseAssetId(selectedAsset == null ? void 0 : selectedAsset.url);
8266
+ const selectedIdRaw = (_a67 = ids[0]) == null ? void 0 : _a67.trim();
8267
+ const selectedId = (_c = (_b3 = parseAssetId(selectedIdRaw)) != null ? _b3 : parseAssetId(selectedAsset == null ? void 0 : selectedAsset.id)) != null ? _c : parseAssetId(selectedAsset == null ? void 0 : selectedAsset.url);
8273
8268
  if (!selectedId) {
8274
8269
  toast({
8275
8270
  title: "Imagem inv\xE1lida",
@@ -8311,7 +8306,7 @@ var UserMenuCupcode = ({
8311
8306
  [isProfileAvatarSaving, onProfileAvatarChange, resolvedProfileAvatarUrl]
8312
8307
  );
8313
8308
  const sendChatMessage = async () => {
8314
- var _a69, _b4;
8309
+ var _a67, _b3;
8315
8310
  if (!activeChatUser) return;
8316
8311
  const text = chatDraft.trim();
8317
8312
  if (!text || isSendingChatMessage) return;
@@ -8323,7 +8318,7 @@ var UserMenuCupcode = ({
8323
8318
  await onChatSendMessage({
8324
8319
  recipientId: activeChatUser.id,
8325
8320
  text,
8326
- replyToMessageId: (_a69 = replyToMessage == null ? void 0 : replyToMessage.id) != null ? _a69 : null
8321
+ replyToMessageId: (_a67 = replyToMessage == null ? void 0 : replyToMessage.id) != null ? _a67 : null
8327
8322
  });
8328
8323
  setChatDraft("");
8329
8324
  setShowEmojiPicker(false);
@@ -8350,7 +8345,7 @@ var UserMenuCupcode = ({
8350
8345
  timeLabel,
8351
8346
  createdAt,
8352
8347
  readAt: null,
8353
- replyToMessageId: (_b4 = replyToMessage == null ? void 0 : replyToMessage.id) != null ? _b4 : null
8348
+ replyToMessageId: (_b3 = replyToMessage == null ? void 0 : replyToMessage.id) != null ? _b3 : null
8354
8349
  };
8355
8350
  if (isLocalGroupConversation) {
8356
8351
  setInternalGroupMessages((current) => [...current, message]);
@@ -8365,7 +8360,7 @@ var UserMenuCupcode = ({
8365
8360
  });
8366
8361
  };
8367
8362
  const renderDefaultPanel = () => {
8368
- var _a69, _b4, _c, _d;
8363
+ var _a67, _b3, _c, _d;
8369
8364
  if (activeTab === "profile") {
8370
8365
  return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "space-y-4", children: [
8371
8366
  /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "pt-1 text-center", children: [
@@ -8638,7 +8633,7 @@ var UserMenuCupcode = ({
8638
8633
  visibleGroupedNotifications.length ? visibleGroupedNotifications.map((group) => /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("section", { className: "space-y-1.5", children: [
8639
8634
  /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("p", { className: "px-0.5 text-[11px] font-semibold uppercase tracking-[0.08em] text-muted-foreground", children: group.label }),
8640
8635
  /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "space-y-1.5", children: group.items.map((notification) => {
8641
- var _a70;
8636
+ var _a68;
8642
8637
  const kind = normalizeNotificationKind(notification.kind);
8643
8638
  const meta = NOTIFICATION_KIND_META[kind];
8644
8639
  const Icon3 = meta.icon;
@@ -8667,7 +8662,7 @@ var UserMenuCupcode = ({
8667
8662
  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",
8668
8663
  children: [
8669
8664
  /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_lucide_react8.ExternalLink, { className: "h-3 w-3" }),
8670
- (_a70 = notification.actionLabel) != null ? _a70 : "Abrir"
8665
+ (_a68 = notification.actionLabel) != null ? _a68 : "Abrir"
8671
8666
  ]
8672
8667
  }
8673
8668
  ),
@@ -8895,7 +8890,7 @@ var UserMenuCupcode = ({
8895
8890
  }
8896
8891
  if (activeTab === "chat") {
8897
8892
  const canSendChatMessage = Boolean(activeChatUser) && chatDraft.trim() !== "" && !isSendingChatMessage && !isChatLoading;
8898
- const activeConversationUnreadCount = activeChatUser ? (_a69 = resolvedChatUnreadByUser[activeChatUser.id]) != null ? _a69 : 0 : 0;
8893
+ const activeConversationUnreadCount = activeChatUser ? (_a67 = resolvedChatUnreadByUser[activeChatUser.id]) != null ? _a67 : 0 : 0;
8899
8894
  return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "h-full", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
8900
8895
  "div",
8901
8896
  {
@@ -8974,12 +8969,12 @@ var UserMenuCupcode = ({
8974
8969
  }
8975
8970
  ),
8976
8971
  /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "space-y-1", children: users.map((user) => {
8977
- var _a70, _b5, _c2, _d2;
8972
+ var _a68, _b4, _c2, _d2;
8978
8973
  const userInitials = buildInitials(user.name, user.username);
8979
8974
  const isCurrent = user.id === activeChatUserId;
8980
- const unreadCount = (_a70 = resolvedChatUnreadByUser[user.id]) != null ? _a70 : 0;
8975
+ const unreadCount = (_a68 = resolvedChatUnreadByUser[user.id]) != null ? _a68 : 0;
8981
8976
  const hasUnread = unreadCount > 0;
8982
- const lastMessage = (_b5 = conversationMetaByUserId.get(user.id)) == null ? void 0 : _b5.lastMessage;
8977
+ const lastMessage = (_b4 = conversationMetaByUserId.get(user.id)) == null ? void 0 : _b4.lastMessage;
8983
8978
  return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
8984
8979
  "button",
8985
8980
  {
@@ -9184,13 +9179,13 @@ var UserMenuCupcode = ({
9184
9179
  className: "cc-scrollbar cc-scrollbar-purple relative flex-1 space-y-2 overflow-y-auto px-3 py-2.5",
9185
9180
  children: [
9186
9181
  isChatLoading ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("p", { className: "rounded-xl border border-dashed border-border/70 bg-background/35 px-3 py-3 text-[11px] text-muted-foreground", children: "Carregando conversa..." }) : activeChatMessages.length ? activeChatTimeline.map((item) => {
9187
- var _a70, _b5;
9182
+ var _a68, _b4;
9188
9183
  if (item.type === "day") {
9189
9184
  return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "flex justify-center py-1", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: "inline-flex items-center rounded-full border border-border/70 bg-background/85 px-2.5 py-0.5 text-[10px] font-medium text-muted-foreground shadow-[var(--elevation-2)]", children: item.label }) }, item.key);
9190
9185
  }
9191
9186
  const { message } = item;
9192
- const replyMessage = message.replyToMessageId ? (_a70 = activeChatMessagesMap.get(message.replyToMessageId)) != null ? _a70 : null : null;
9193
- const reactions = (_b5 = reactionsByMessageId.get(message.id)) != null ? _b5 : [];
9187
+ const replyMessage = message.replyToMessageId ? (_a68 = activeChatMessagesMap.get(message.replyToMessageId)) != null ? _a68 : null : null;
9188
+ const reactions = (_b4 = reactionsByMessageId.get(message.id)) != null ? _b4 : [];
9194
9189
  const hasReadReceipt = Boolean(message.readAt);
9195
9190
  const isEditing = editingMessageId === message.id;
9196
9191
  const canEditOrDelete = message.sender === "me";
@@ -9363,7 +9358,7 @@ var UserMenuCupcode = ({
9363
9358
  "div",
9364
9359
  {
9365
9360
  ref: reactionPickerRef,
9366
- style: { top: `${(_b4 = activeReactionPicker == null ? void 0 : activeReactionPicker.top) != null ? _b4 : 0}px`, left: `${(_c = activeReactionPicker == null ? void 0 : activeReactionPicker.left) != null ? _c : 0}px` },
9361
+ style: { top: `${(_b3 = activeReactionPicker == null ? void 0 : activeReactionPicker.top) != null ? _b3 : 0}px`, left: `${(_c = activeReactionPicker == null ? void 0 : activeReactionPicker.left) != null ? _c : 0}px` },
9367
9362
  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)]",
9368
9363
  children: MESSAGE_REACTION_OPTIONS.map((emoji) => /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
9369
9364
  "button",
@@ -9519,8 +9514,8 @@ var UserMenuCupcode = ({
9519
9514
  ] })
9520
9515
  ] }),
9521
9516
  isChatSuperAdmin ? activeConversationLogs.length ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "space-y-2", children: activeConversationLogs.map((entry) => {
9522
- var _a70;
9523
- const actorName = entry.actorId && entry.actorId === resolvedCurrentChatUserId ? "Voc\xEA" : (_a70 = entry.actorId) != null ? _a70 : "Usu\xE1rio";
9517
+ var _a68;
9518
+ const actorName = entry.actorId && entry.actorId === resolvedCurrentChatUserId ? "Voc\xEA" : (_a68 = entry.actorId) != null ? _a68 : "Usu\xE1rio";
9524
9519
  return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
9525
9520
  "article",
9526
9521
  {
@@ -9778,32 +9773,6 @@ var UserMenuCupcode = ({
9778
9773
  /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("p", { className: "mt-1 text-[11px] leading-relaxed text-muted-foreground", children: "Prefer\xEAncias que afetam o uso no dia a dia." })
9779
9774
  ] }),
9780
9775
  /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "mt-3 space-y-2.5", children: [
9781
- /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: settingsItemClassName, children: [
9782
- /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("p", { className: "flex items-center gap-1.5 text-xs font-semibold text-foreground", children: [
9783
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_lucide_react8.Sun, { className: "h-3.5 w-3.5 text-primary" }),
9784
- "Tema"
9785
- ] }),
9786
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "mt-2 grid grid-cols-3 gap-1", children: THEME_OPTIONS.map((option) => {
9787
- const Icon3 = option.icon;
9788
- const isActive = experienceSettings.theme === option.value;
9789
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
9790
- "button",
9791
- {
9792
- type: "button",
9793
- onClick: () => updateExperienceSetting("theme", option.value),
9794
- className: cn(
9795
- "inline-flex h-8 items-center justify-center gap-1 rounded-md border px-2 text-[11px] font-semibold transition-all",
9796
- isActive ? "border-primary/45 bg-primary/12 text-primary" : "border-border/70 text-foreground hover:bg-muted/45"
9797
- ),
9798
- children: [
9799
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Icon3, { className: "h-3.5 w-3.5" }),
9800
- option.label
9801
- ]
9802
- },
9803
- option.value
9804
- );
9805
- }) })
9806
- ] }),
9807
9776
  /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: settingsItemClassName, children: [
9808
9777
  /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("p", { className: "flex items-center gap-1.5 text-xs font-semibold text-foreground", children: [
9809
9778
  /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_lucide_react8.Languages, { className: "h-3.5 w-3.5 text-primary" }),
@@ -10427,41 +10396,16 @@ SheetDescription.displayName = SheetPrimitive.Description.displayName;
10427
10396
 
10428
10397
  // src/components/cupcode/CustomerUserMenuCupcode.tsx
10429
10398
  var import_jsx_runtime37 = require("react/jsx-runtime");
10430
- var THEME_OPTIONS2 = [
10431
- {
10432
- value: "system",
10433
- label: "Sistema",
10434
- icon: import_lucide_react10.Monitor
10435
- },
10436
- {
10437
- value: "light",
10438
- label: "Claro",
10439
- icon: import_lucide_react10.Sun
10440
- },
10441
- {
10442
- value: "dark",
10443
- label: "Escuro",
10444
- icon: import_lucide_react10.Moon
10445
- }
10446
- ];
10447
- var applyThemeToRoot = (theme) => {
10448
- if (typeof document === "undefined") return;
10449
- const root = document.documentElement;
10450
- root.classList.toggle("dark", theme === "dark");
10451
- root.classList.toggle("light", theme === "light");
10452
- root.dataset.theme = theme;
10453
- root.style.colorScheme = theme;
10454
- };
10455
10399
  var resolveAvatarUrlFromTelescup = (asset, fallbackId) => {
10456
- var _a68, _b4;
10400
+ var _a66, _b3;
10457
10401
  const options = { width: 384, height: 384, fit: "cover", format: "avif", quality: 80 };
10458
- return (_b4 = (_a68 = resolveTelescupImageURL(asset == null ? void 0 : asset.url, options)) != null ? _a68 : resolveTelescupImageURL(asset == null ? void 0 : asset.id, options)) != null ? _b4 : resolveTelescupImageURL(fallbackId, options);
10402
+ return (_b3 = (_a66 = resolveTelescupImageURL(asset == null ? void 0 : asset.url, options)) != null ? _a66 : resolveTelescupImageURL(asset == null ? void 0 : asset.id, options)) != null ? _b3 : resolveTelescupImageURL(fallbackId, options);
10459
10403
  };
10460
10404
  var buildInitials2 = (displayName, email) => {
10461
- var _a68, _b4, _c, _d, _e;
10462
- const source = (displayName == null ? void 0 : displayName.trim()) || ((_a68 = email == null ? void 0 : email.split("@")[0]) == null ? void 0 : _a68.trim()) || "U";
10405
+ var _a66, _b3, _c, _d, _e;
10406
+ const source = (displayName == null ? void 0 : displayName.trim()) || ((_a66 = email == null ? void 0 : email.split("@")[0]) == null ? void 0 : _a66.trim()) || "U";
10463
10407
  const parts = source.split(/\s+/).filter(Boolean);
10464
- const initials = parts.length > 1 ? `${(_c = (_b4 = parts[0]) == null ? void 0 : _b4[0]) != null ? _c : ""}${(_e = (_d = parts[1]) == null ? void 0 : _d[0]) != null ? _e : ""}` : source.slice(0, 2);
10408
+ const initials = parts.length > 1 ? `${(_c = (_b3 = parts[0]) == null ? void 0 : _b3[0]) != null ? _c : ""}${(_e = (_d = parts[1]) == null ? void 0 : _d[0]) != null ? _e : ""}` : source.slice(0, 2);
10465
10409
  return initials.toUpperCase();
10466
10410
  };
10467
10411
  function CustomerUserMenuCupcode({
@@ -10485,25 +10429,12 @@ function CustomerUserMenuCupcode({
10485
10429
  const [isSavingAvatar, setIsSavingAvatar] = (0, import_react16.useState)(false);
10486
10430
  const [isLoggingOut, setIsLoggingOut] = (0, import_react16.useState)(false);
10487
10431
  const [profileAvatarUrl, setProfileAvatarUrl] = (0, import_react16.useState)(avatarUrl);
10488
- const [themePreference, setThemePreference] = (0, import_react16.useState)(() => resolveStoredThemePreference());
10489
10432
  (0, import_react16.useEffect)(() => {
10490
10433
  setProfileAvatarUrl(avatarUrl);
10491
10434
  }, [avatarUrl]);
10492
- (0, import_react16.useEffect)(() => {
10493
- if (typeof window === "undefined") return;
10494
- const syncThemePreference = () => setThemePreference(resolveStoredThemePreference());
10495
- window.addEventListener(THEME_PREFERENCE_CHANGE_EVENT, syncThemePreference);
10496
- return () => window.removeEventListener(THEME_PREFERENCE_CHANGE_EVENT, syncThemePreference);
10497
- }, []);
10498
10435
  const initials = (0, import_react16.useMemo)(() => buildInitials2(displayName, email), [displayName, email]);
10499
10436
  const userHandle = username ? `@${username.replace(/^@/, "")}` : email;
10500
10437
  const hasTelescupUpload = Boolean(telescupBaseUrl && getTelescupAccessToken);
10501
- const handleThemeSelect = (0, import_react16.useCallback)((nextPreference) => {
10502
- const appliedTheme = resolveAppliedThemeMode(nextPreference);
10503
- persistThemePreferenceSelection(nextPreference);
10504
- applyThemeToRoot(appliedTheme);
10505
- setThemePreference(nextPreference);
10506
- }, []);
10507
10438
  const openAvatarUpload = (0, import_react16.useCallback)(() => {
10508
10439
  if (!hasTelescupUpload || isSavingAvatar) return;
10509
10440
  setIsOpen(false);
@@ -10511,9 +10442,9 @@ function CustomerUserMenuCupcode({
10511
10442
  }, [hasTelescupUpload, isSavingAvatar]);
10512
10443
  const handleAvatarChange = (0, import_react16.useCallback)(
10513
10444
  async (ids, assets) => {
10514
- var _a68, _b4;
10445
+ var _a66, _b3;
10515
10446
  const selectedAsset = assets == null ? void 0 : assets[0];
10516
- const selectedId = (_b4 = (_a68 = parseAssetId(ids[0])) != null ? _a68 : parseAssetId(selectedAsset == null ? void 0 : selectedAsset.id)) != null ? _b4 : parseAssetId(selectedAsset == null ? void 0 : selectedAsset.url);
10447
+ const selectedId = (_b3 = (_a66 = parseAssetId(ids[0])) != null ? _a66 : parseAssetId(selectedAsset == null ? void 0 : selectedAsset.id)) != null ? _b3 : parseAssetId(selectedAsset == null ? void 0 : selectedAsset.url);
10517
10448
  if (!selectedId) {
10518
10449
  toast({
10519
10450
  title: "Imagem inv\xE1lida",
@@ -10604,61 +10535,32 @@ function CustomerUserMenuCupcode({
10604
10535
  /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { className: "sr-only", children: "Fechar" })
10605
10536
  ] })
10606
10537
  ] }),
10607
- /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "flex-1 space-y-5 px-5 py-5", children: [
10608
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("section", { className: "rounded-[22px] border border-white/12 bg-white/[0.06] p-5", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "flex items-center gap-4", children: [
10609
- /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "relative shrink-0", children: [
10610
- /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(Avatar2, { className: "h-24 w-24 border border-white/16 bg-[#24163b]", children: [
10611
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(AvatarImage2, { src: profileAvatarUrl, alt: displayName != null ? displayName : "Perfil" }),
10612
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(AvatarFallback2, { className: "bg-[#24163b] text-3xl font-black text-white", children: initials })
10613
- ] }),
10614
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
10615
- "button",
10616
- {
10617
- type: "button",
10618
- disabled: !hasTelescupUpload || isSavingAvatar,
10619
- onClick: openAvatarUpload,
10620
- className: "absolute -right-1 top-1 inline-flex h-10 w-10 items-center justify-center rounded-full border border-white/18 bg-[#7c3aed] text-white shadow-lg transition hover:bg-[#8b5cf6] disabled:cursor-not-allowed disabled:opacity-50",
10621
- "aria-label": "Alterar foto de perfil",
10622
- title: hasTelescupUpload ? "Alterar foto" : "Upload indispon\xEDvel",
10623
- children: isSavingAvatar ? /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_lucide_react10.Loader2, { className: "h-4 w-4 animate-spin" }) : /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_lucide_react10.Pencil, { className: "h-4 w-4" })
10624
- }
10625
- )
10538
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: "flex-1 space-y-5 px-5 py-5", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("section", { className: "rounded-[22px] border border-white/12 bg-white/[0.06] p-5", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "flex items-center gap-4", children: [
10539
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "relative shrink-0", children: [
10540
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(Avatar2, { className: "h-24 w-24 border border-white/16 bg-[#24163b]", children: [
10541
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(AvatarImage2, { src: profileAvatarUrl, alt: displayName != null ? displayName : "Perfil" }),
10542
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(AvatarFallback2, { className: "bg-[#24163b] text-3xl font-black text-white", children: initials })
10626
10543
  ] }),
10627
- /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "min-w-0 flex-1 text-left", children: [
10628
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("p", { className: "truncate text-xl font-black text-white", children: displayName != null ? displayName : "Usu\xE1rio" }),
10629
- userHandle ? /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("p", { className: "mt-1 truncate text-sm text-white/62", children: userHandle }) : null,
10630
- tenantId ? /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("p", { className: "mt-1 inline-flex max-w-full rounded-full border border-[#a78bfa]/28 bg-[#7c3aed]/16 px-2.5 py-1 text-xs font-bold uppercase tracking-wide text-[#d8c6ff]", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { className: "truncate", children: tenantId }) }) : null,
10631
- roleLabel ? /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("p", { className: "mt-2 text-xs font700 uppercase tracking-wide text-[#d4b8ff]", children: roleLabel }) : null
10632
- ] })
10633
- ] }) }),
10634
- /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("section", { className: "rounded-[22px] border border-white/12 bg-white/[0.06] p-4", children: [
10635
- /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "mb-3 flex items-center gap-2", children: [
10636
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_lucide_react10.Palette, { className: "h-4 w-4 text-[#d4b8ff]" }),
10637
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("h3", { className: "text-sm font-extrabold text-white", children: "Tema" })
10638
- ] }),
10639
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: "grid grid-cols-3 gap-2", children: THEME_OPTIONS2.map((option) => {
10640
- const Icon3 = option.icon;
10641
- const isActive = themePreference === option.value;
10642
- return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
10643
- "button",
10644
- {
10645
- type: "button",
10646
- onClick: () => handleThemeSelect(option.value),
10647
- className: [
10648
- "flex min-h-24 flex-col items-center justify-center gap-2 rounded-2xl border px-2 text-center transition",
10649
- isActive ? "border-[#a78bfa]/70 bg-[#7c3aed]/28 text-white" : "border-white/10 bg-black/12 text-white/72 hover:bg-white/8 hover:text-white"
10650
- ].join(" "),
10651
- "aria-pressed": isActive,
10652
- children: [
10653
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { className: "inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-white/10", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Icon3, { className: "h-4 w-4" }) }),
10654
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { className: "min-w-0", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { className: "block text-sm font-extrabold", children: option.label }) })
10655
- ]
10656
- },
10657
- option.value
10658
- );
10659
- }) })
10544
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
10545
+ "button",
10546
+ {
10547
+ type: "button",
10548
+ disabled: !hasTelescupUpload || isSavingAvatar,
10549
+ onClick: openAvatarUpload,
10550
+ className: "absolute -right-1 top-1 inline-flex h-10 w-10 items-center justify-center rounded-full border border-white/18 bg-[#7c3aed] text-white shadow-lg transition hover:bg-[#8b5cf6] disabled:cursor-not-allowed disabled:opacity-50",
10551
+ "aria-label": "Alterar foto de perfil",
10552
+ title: hasTelescupUpload ? "Alterar foto" : "Upload indispon\xEDvel",
10553
+ children: isSavingAvatar ? /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_lucide_react10.Loader2, { className: "h-4 w-4 animate-spin" }) : /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_lucide_react10.Pencil, { className: "h-4 w-4" })
10554
+ }
10555
+ )
10556
+ ] }),
10557
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "min-w-0 flex-1 text-left", children: [
10558
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("p", { className: "truncate text-xl font-black text-white", children: displayName != null ? displayName : "Usu\xE1rio" }),
10559
+ userHandle ? /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("p", { className: "mt-1 truncate text-sm text-white/62", children: userHandle }) : null,
10560
+ tenantId ? /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("p", { className: "mt-1 inline-flex max-w-full rounded-full border border-[#a78bfa]/28 bg-[#7c3aed]/16 px-2.5 py-1 text-xs font-bold uppercase tracking-wide text-[#d8c6ff]", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { className: "truncate", children: tenantId }) }) : null,
10561
+ roleLabel ? /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("p", { className: "mt-2 text-xs font700 uppercase tracking-wide text-[#d4b8ff]", children: roleLabel }) : null
10660
10562
  ] })
10661
- ] }),
10563
+ ] }) }) }),
10662
10564
  /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: "border-t border-white/10 p-5", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
10663
10565
  Button,
10664
10566
  {
@@ -10868,7 +10770,7 @@ var FunctionsClient = class {
10868
10770
  */
10869
10771
  invoke(functionName_1) {
10870
10772
  return __awaiter(this, arguments, void 0, function* (functionName, options = {}) {
10871
- var _a68;
10773
+ var _a66;
10872
10774
  let timeoutId;
10873
10775
  let timeoutController;
10874
10776
  try {
@@ -10934,7 +10836,7 @@ var FunctionsClient = class {
10934
10836
  if (!response.ok) {
10935
10837
  throw new FunctionsHttpError(response);
10936
10838
  }
10937
- let responseType = ((_a68 = response.headers.get("Content-Type")) !== null && _a68 !== void 0 ? _a68 : "text/plain").split(";")[0].trim();
10839
+ let responseType = ((_a66 = response.headers.get("Content-Type")) !== null && _a66 !== void 0 ? _a66 : "text/plain").split(";")[0].trim();
10938
10840
  let data;
10939
10841
  if (responseType === "application/json") {
10940
10842
  data = yield response.json();
@@ -12283,7 +12185,7 @@ var WebSocketFactory = class {
12283
12185
  constructor() {
12284
12186
  }
12285
12187
  static detectEnvironment() {
12286
- var _a68;
12188
+ var _a66;
12287
12189
  if (typeof WebSocket !== "undefined") {
12288
12190
  return { type: "native", constructor: WebSocket };
12289
12191
  }
@@ -12300,7 +12202,7 @@ var WebSocketFactory = class {
12300
12202
  workaround: "Use Cloudflare Workers WebSocket API for server-side WebSocket handling, or deploy to a different runtime."
12301
12203
  };
12302
12204
  }
12303
- if (typeof globalThis !== "undefined" && globalThis.EdgeRuntime || typeof navigator !== "undefined" && ((_a68 = navigator.userAgent) === null || _a68 === void 0 ? void 0 : _a68.includes("Vercel-Edge"))) {
12205
+ if (typeof globalThis !== "undefined" && globalThis.EdgeRuntime || typeof navigator !== "undefined" && ((_a66 = navigator.userAgent) === null || _a66 === void 0 ? void 0 : _a66.includes("Vercel-Edge"))) {
12304
12206
  return {
12305
12207
  type: "unsupported",
12306
12208
  error: "Edge runtime detected (Vercel Edge/Netlify Edge). WebSockets are not supported in edge functions.",
@@ -12384,7 +12286,7 @@ Suggested solution: ${env.workaround}`;
12384
12286
  try {
12385
12287
  const env = this.detectEnvironment();
12386
12288
  return env.type === "native" || env.type === "ws";
12387
- } catch (_a68) {
12289
+ } catch (_a66) {
12388
12290
  return false;
12389
12291
  }
12390
12292
  }
@@ -12458,30 +12360,30 @@ var Serializer = class {
12458
12360
  return callback(JSON.stringify(payload));
12459
12361
  }
12460
12362
  _binaryEncodeUserBroadcastPush(message) {
12461
- var _a68;
12462
- if (this._isArrayBuffer((_a68 = message.payload) === null || _a68 === void 0 ? void 0 : _a68.payload)) {
12363
+ var _a66;
12364
+ if (this._isArrayBuffer((_a66 = message.payload) === null || _a66 === void 0 ? void 0 : _a66.payload)) {
12463
12365
  return this._encodeBinaryUserBroadcastPush(message);
12464
12366
  } else {
12465
12367
  return this._encodeJsonUserBroadcastPush(message);
12466
12368
  }
12467
12369
  }
12468
12370
  _encodeBinaryUserBroadcastPush(message) {
12469
- var _a68, _b4;
12470
- const userPayload = (_b4 = (_a68 = message.payload) === null || _a68 === void 0 ? void 0 : _a68.payload) !== null && _b4 !== void 0 ? _b4 : new ArrayBuffer(0);
12371
+ var _a66, _b3;
12372
+ const userPayload = (_b3 = (_a66 = message.payload) === null || _a66 === void 0 ? void 0 : _a66.payload) !== null && _b3 !== void 0 ? _b3 : new ArrayBuffer(0);
12471
12373
  return this._encodeUserBroadcastPush(message, this.BINARY_ENCODING, userPayload);
12472
12374
  }
12473
12375
  _encodeJsonUserBroadcastPush(message) {
12474
- var _a68, _b4;
12475
- const userPayload = (_b4 = (_a68 = message.payload) === null || _a68 === void 0 ? void 0 : _a68.payload) !== null && _b4 !== void 0 ? _b4 : {};
12376
+ var _a66, _b3;
12377
+ const userPayload = (_b3 = (_a66 = message.payload) === null || _a66 === void 0 ? void 0 : _a66.payload) !== null && _b3 !== void 0 ? _b3 : {};
12476
12378
  const encoder = new TextEncoder();
12477
12379
  const encodedUserPayload = encoder.encode(JSON.stringify(userPayload)).buffer;
12478
12380
  return this._encodeUserBroadcastPush(message, this.JSON_ENCODING, encodedUserPayload);
12479
12381
  }
12480
12382
  _encodeUserBroadcastPush(message, encodingType, encodedPayload) {
12481
- var _a68, _b4;
12383
+ var _a66, _b3;
12482
12384
  const topic = message.topic;
12483
- const ref = (_a68 = message.ref) !== null && _a68 !== void 0 ? _a68 : "";
12484
- const joinRef = (_b4 = message.join_ref) !== null && _b4 !== void 0 ? _b4 : "";
12385
+ const ref = (_a66 = message.ref) !== null && _a66 !== void 0 ? _a66 : "";
12386
+ const joinRef = (_b3 = message.join_ref) !== null && _b3 !== void 0 ? _b3 : "";
12485
12387
  const userEvent = message.payload.event;
12486
12388
  const rest = this.allowedMetadataKeys ? this._pick(message.payload, this.allowedMetadataKeys) : {};
12487
12389
  const metadata = Object.keys(rest).length === 0 ? "" : JSON.stringify(rest);
@@ -12567,8 +12469,8 @@ var Serializer = class {
12567
12469
  return { join_ref: null, ref: null, topic, event: this.BROADCAST_EVENT, payload: data };
12568
12470
  }
12569
12471
  _isArrayBuffer(buffer) {
12570
- var _a68;
12571
- return buffer instanceof ArrayBuffer || ((_a68 = buffer === null || buffer === void 0 ? void 0 : buffer.constructor) === null || _a68 === void 0 ? void 0 : _a68.name) === "ArrayBuffer";
12472
+ var _a66;
12473
+ return buffer instanceof ArrayBuffer || ((_a66 = buffer === null || buffer === void 0 ? void 0 : buffer.constructor) === null || _a66 === void 0 ? void 0 : _a66.name) === "ArrayBuffer";
12572
12474
  }
12573
12475
  _pick(obj, keys) {
12574
12476
  if (!obj || typeof obj !== "object") {
@@ -12632,8 +12534,8 @@ var PostgresTypes;
12632
12534
  PostgresTypes2["tstzrange"] = "tstzrange";
12633
12535
  })(PostgresTypes || (PostgresTypes = {}));
12634
12536
  var convertChangeData = (columns, record, options = {}) => {
12635
- var _a68;
12636
- const skipTypes = (_a68 = options.skipTypes) !== null && _a68 !== void 0 ? _a68 : [];
12537
+ var _a66;
12538
+ const skipTypes = (_a66 = options.skipTypes) !== null && _a66 !== void 0 ? _a66 : [];
12637
12539
  if (!record) {
12638
12540
  return {};
12639
12541
  }
@@ -12723,7 +12625,7 @@ var toJson = (value) => {
12723
12625
  if (typeof value === "string") {
12724
12626
  try {
12725
12627
  return JSON.parse(value);
12726
- } catch (_a68) {
12628
+ } catch (_a66) {
12727
12629
  return value;
12728
12630
  }
12729
12631
  }
@@ -12815,9 +12717,9 @@ var Push = class {
12815
12717
  this.payload = Object.assign(Object.assign({}, this.payload), payload);
12816
12718
  }
12817
12719
  receive(status, callback) {
12818
- var _a68;
12720
+ var _a66;
12819
12721
  if (this._hasReceived(status)) {
12820
- callback((_a68 = this.receivedResp) === null || _a68 === void 0 ? void 0 : _a68.response);
12722
+ callback((_a66 = this.receivedResp) === null || _a66 === void 0 ? void 0 : _a66.response);
12821
12723
  }
12822
12724
  this.recHooks.push({ status, callback });
12823
12725
  return this;
@@ -13008,8 +12910,8 @@ var RealtimePresence = class _RealtimePresence {
13008
12910
  };
13009
12911
  }
13010
12912
  this.map(joins, (key, newPresences) => {
13011
- var _a68;
13012
- const currentPresences = (_a68 = state[key]) !== null && _a68 !== void 0 ? _a68 : [];
12913
+ var _a66;
12914
+ const currentPresences = (_a66 = state[key]) !== null && _a66 !== void 0 ? _a66 : [];
13013
12915
  state[key] = this.cloneDeep(newPresences);
13014
12916
  if (currentPresences.length > 0) {
13015
12917
  const joinedPresenceRefs = state[key].map((m) => m.presence_ref);
@@ -13137,7 +13039,7 @@ var RealtimeChannel = class _RealtimeChannel {
13137
13039
  * ```
13138
13040
  */
13139
13041
  constructor(topic, params = { config: {} }, socket) {
13140
- var _a68, _b4;
13042
+ var _a66, _b3;
13141
13043
  this.topic = topic;
13142
13044
  this.params = params;
13143
13045
  this.socket = socket;
@@ -13196,19 +13098,19 @@ var RealtimeChannel = class _RealtimeChannel {
13196
13098
  this.presence = new RealtimePresence(this);
13197
13099
  this.broadcastEndpointURL = httpEndpointURL(this.socket.endPoint);
13198
13100
  this.private = this.params.config.private || false;
13199
- if (!this.private && ((_b4 = (_a68 = this.params.config) === null || _a68 === void 0 ? void 0 : _a68.broadcast) === null || _b4 === void 0 ? void 0 : _b4.replay)) {
13101
+ if (!this.private && ((_b3 = (_a66 = this.params.config) === null || _a66 === void 0 ? void 0 : _a66.broadcast) === null || _b3 === void 0 ? void 0 : _b3.replay)) {
13200
13102
  throw `tried to use replay on public channel '${this.topic}'. It must be a private channel.`;
13201
13103
  }
13202
13104
  }
13203
13105
  /** Subscribe registers your client with the server */
13204
13106
  subscribe(callback, timeout = this.timeout) {
13205
- var _a68, _b4, _c;
13107
+ var _a66, _b3, _c;
13206
13108
  if (!this.socket.isConnected()) {
13207
13109
  this.socket.connect();
13208
13110
  }
13209
13111
  if (this.state == CHANNEL_STATES.closed) {
13210
13112
  const { config: { broadcast, presence, private: isPrivate } } = this.params;
13211
- const postgres_changes = (_b4 = (_a68 = this.bindings.postgres_changes) === null || _a68 === void 0 ? void 0 : _a68.map((r) => r.filter)) !== null && _b4 !== void 0 ? _b4 : [];
13113
+ const postgres_changes = (_b3 = (_a66 = this.bindings.postgres_changes) === null || _a66 === void 0 ? void 0 : _a66.map((r) => r.filter)) !== null && _b3 !== void 0 ? _b3 : [];
13212
13114
  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;
13213
13115
  const accessTokenPayload = {};
13214
13116
  const config = {
@@ -13226,7 +13128,7 @@ var RealtimeChannel = class _RealtimeChannel {
13226
13128
  this.joinedOnce = true;
13227
13129
  this._rejoin(timeout);
13228
13130
  this.joinPush.receive("ok", async ({ postgres_changes: postgres_changes2 }) => {
13229
- var _a69;
13131
+ var _a67;
13230
13132
  if (!this.socket._isManualToken()) {
13231
13133
  this.socket.setAuth();
13232
13134
  }
@@ -13235,7 +13137,7 @@ var RealtimeChannel = class _RealtimeChannel {
13235
13137
  return;
13236
13138
  } else {
13237
13139
  const clientPostgresBindings = this.bindings.postgres_changes;
13238
- const bindingsLen = (_a69 = clientPostgresBindings === null || clientPostgresBindings === void 0 ? void 0 : clientPostgresBindings.length) !== null && _a69 !== void 0 ? _a69 : 0;
13140
+ const bindingsLen = (_a67 = clientPostgresBindings === null || clientPostgresBindings === void 0 ? void 0 : clientPostgresBindings.length) !== null && _a67 !== void 0 ? _a67 : 0;
13239
13141
  const newPostgresBindings = [];
13240
13142
  for (let i = 0; i < bindingsLen; i++) {
13241
13143
  const clientPostgresBinding = clientPostgresBindings[i];
@@ -13313,7 +13215,7 @@ var RealtimeChannel = class _RealtimeChannel {
13313
13215
  * @returns Promise resolving to object with success status, and error details if failed
13314
13216
  */
13315
13217
  async httpSend(event, payload, opts = {}) {
13316
- var _a68;
13218
+ var _a66;
13317
13219
  if (payload === void 0 || payload === null) {
13318
13220
  return Promise.reject("Payload is required for httpSend()");
13319
13221
  }
@@ -13338,7 +13240,7 @@ var RealtimeChannel = class _RealtimeChannel {
13338
13240
  ]
13339
13241
  })
13340
13242
  };
13341
- const response = await this._fetchWithTimeout(this.broadcastEndpointURL, options, (_a68 = opts.timeout) !== null && _a68 !== void 0 ? _a68 : this.timeout);
13243
+ const response = await this._fetchWithTimeout(this.broadcastEndpointURL, options, (_a66 = opts.timeout) !== null && _a66 !== void 0 ? _a66 : this.timeout);
13342
13244
  if (response.status === 202) {
13343
13245
  return { success: true };
13344
13246
  }
@@ -13346,7 +13248,7 @@ var RealtimeChannel = class _RealtimeChannel {
13346
13248
  try {
13347
13249
  const errorBody = await response.json();
13348
13250
  errorMessage = errorBody.error || errorBody.message || errorMessage;
13349
- } catch (_b4) {
13251
+ } catch (_b3) {
13350
13252
  }
13351
13253
  return Promise.reject(new Error(errorMessage));
13352
13254
  }
@@ -13360,7 +13262,7 @@ var RealtimeChannel = class _RealtimeChannel {
13360
13262
  * @param opts Options to be used during the send process
13361
13263
  */
13362
13264
  async send(args, opts = {}) {
13363
- var _a68, _b4;
13265
+ var _a66, _b3;
13364
13266
  if (!this._canPush() && args.type === "broadcast") {
13365
13267
  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.");
13366
13268
  const { event, payload: endpoint_payload } = args;
@@ -13386,8 +13288,8 @@ var RealtimeChannel = class _RealtimeChannel {
13386
13288
  })
13387
13289
  };
13388
13290
  try {
13389
- const response = await this._fetchWithTimeout(this.broadcastEndpointURL, options, (_a68 = opts.timeout) !== null && _a68 !== void 0 ? _a68 : this.timeout);
13390
- await ((_b4 = response.body) === null || _b4 === void 0 ? void 0 : _b4.cancel());
13291
+ const response = await this._fetchWithTimeout(this.broadcastEndpointURL, options, (_a66 = opts.timeout) !== null && _a66 !== void 0 ? _a66 : this.timeout);
13292
+ await ((_b3 = response.body) === null || _b3 === void 0 ? void 0 : _b3.cancel());
13391
13293
  return response.ok ? "ok" : "error";
13392
13294
  } catch (error) {
13393
13295
  if (error.name === "AbortError") {
@@ -13398,9 +13300,9 @@ var RealtimeChannel = class _RealtimeChannel {
13398
13300
  }
13399
13301
  } else {
13400
13302
  return new Promise((resolve) => {
13401
- var _a69, _b5, _c;
13303
+ var _a67, _b4, _c;
13402
13304
  const push = this._push(args.type, args, opts.timeout || this.timeout);
13403
- if (args.type === "broadcast" && !((_c = (_b5 = (_a69 = this.params) === null || _a69 === void 0 ? void 0 : _a69.config) === null || _b5 === void 0 ? void 0 : _b5.broadcast) === null || _c === void 0 ? void 0 : _c.ack)) {
13305
+ if (args.type === "broadcast" && !((_c = (_b4 = (_a67 = this.params) === null || _a67 === void 0 ? void 0 : _a67.config) === null || _b4 === void 0 ? void 0 : _b4.broadcast) === null || _c === void 0 ? void 0 : _c.ack)) {
13404
13306
  resolve("ok");
13405
13307
  }
13406
13308
  push.receive("ok", () => resolve("ok"));
@@ -13519,7 +13421,7 @@ var RealtimeChannel = class _RealtimeChannel {
13519
13421
  }
13520
13422
  /** @internal */
13521
13423
  _trigger(type, payload, ref) {
13522
- var _a68, _b4;
13424
+ var _a66, _b3;
13523
13425
  const typeLower = type.toLocaleLowerCase();
13524
13426
  const { close, error, leave, join } = CHANNEL_EVENTS;
13525
13427
  const events = [close, error, leave, join];
@@ -13531,18 +13433,18 @@ var RealtimeChannel = class _RealtimeChannel {
13531
13433
  throw "channel onMessage callbacks must return the payload, modified or unmodified";
13532
13434
  }
13533
13435
  if (["insert", "update", "delete"].includes(typeLower)) {
13534
- (_a68 = this.bindings.postgres_changes) === null || _a68 === void 0 ? void 0 : _a68.filter((bind) => {
13535
- var _a69, _b5, _c;
13536
- return ((_a69 = bind.filter) === null || _a69 === void 0 ? void 0 : _a69.event) === "*" || ((_c = (_b5 = bind.filter) === null || _b5 === void 0 ? void 0 : _b5.event) === null || _c === void 0 ? void 0 : _c.toLocaleLowerCase()) === typeLower;
13436
+ (_a66 = this.bindings.postgres_changes) === null || _a66 === void 0 ? void 0 : _a66.filter((bind) => {
13437
+ var _a67, _b4, _c;
13438
+ return ((_a67 = bind.filter) === null || _a67 === void 0 ? void 0 : _a67.event) === "*" || ((_c = (_b4 = bind.filter) === null || _b4 === void 0 ? void 0 : _b4.event) === null || _c === void 0 ? void 0 : _c.toLocaleLowerCase()) === typeLower;
13537
13439
  }).map((bind) => bind.callback(handledPayload, ref));
13538
13440
  } else {
13539
- (_b4 = this.bindings[typeLower]) === null || _b4 === void 0 ? void 0 : _b4.filter((bind) => {
13540
- var _a69, _b5, _c, _d, _e, _f;
13441
+ (_b3 = this.bindings[typeLower]) === null || _b3 === void 0 ? void 0 : _b3.filter((bind) => {
13442
+ var _a67, _b4, _c, _d, _e, _f;
13541
13443
  if (["broadcast", "presence", "postgres_changes"].includes(typeLower)) {
13542
13444
  if ("id" in bind) {
13543
13445
  const bindId = bind.id;
13544
- const bindEvent = (_a69 = bind.filter) === null || _a69 === void 0 ? void 0 : _a69.event;
13545
- return bindId && ((_b5 = payload.ids) === null || _b5 === void 0 ? void 0 : _b5.includes(bindId)) && (bindEvent === "*" || (bindEvent === null || bindEvent === void 0 ? void 0 : bindEvent.toLocaleLowerCase()) === ((_c = payload.data) === null || _c === void 0 ? void 0 : _c.type.toLocaleLowerCase()));
13446
+ const bindEvent = (_a67 = bind.filter) === null || _a67 === void 0 ? void 0 : _a67.event;
13447
+ return bindId && ((_b4 = payload.ids) === null || _b4 === void 0 ? void 0 : _b4.includes(bindId)) && (bindEvent === "*" || (bindEvent === null || bindEvent === void 0 ? void 0 : bindEvent.toLocaleLowerCase()) === ((_c = payload.data) === null || _c === void 0 ? void 0 : _c.type.toLocaleLowerCase()));
13546
13448
  } else {
13547
13449
  const bindEvent = (_e = (_d = bind === null || bind === void 0 ? void 0 : bind.filter) === null || _d === void 0 ? void 0 : _d.event) === null || _e === void 0 ? void 0 : _e.toLocaleLowerCase();
13548
13450
  return bindEvent === "*" || bindEvent === ((_f = payload === null || payload === void 0 ? void 0 : payload.event) === null || _f === void 0 ? void 0 : _f.toLocaleLowerCase());
@@ -13609,8 +13511,8 @@ var RealtimeChannel = class _RealtimeChannel {
13609
13511
  const typeLower = type.toLocaleLowerCase();
13610
13512
  if (this.bindings[typeLower]) {
13611
13513
  this.bindings[typeLower] = this.bindings[typeLower].filter((bind) => {
13612
- var _a68;
13613
- return !(((_a68 = bind.type) === null || _a68 === void 0 ? void 0 : _a68.toLocaleLowerCase()) === typeLower && _RealtimeChannel.isEqual(bind.filter, filter));
13514
+ var _a66;
13515
+ return !(((_a66 = bind.type) === null || _a66 === void 0 ? void 0 : _a66.toLocaleLowerCase()) === typeLower && _RealtimeChannel.isEqual(bind.filter, filter));
13614
13516
  });
13615
13517
  }
13616
13518
  return this;
@@ -13740,7 +13642,7 @@ var RealtimeClient = class {
13740
13642
  * ```
13741
13643
  */
13742
13644
  constructor(endPoint, options) {
13743
- var _a68;
13645
+ var _a66;
13744
13646
  this.accessTokenValue = null;
13745
13647
  this.apiKey = null;
13746
13648
  this._manuallySetToken = false;
@@ -13779,7 +13681,7 @@ var RealtimeClient = class {
13779
13681
  }
13780
13682
  return (...args) => fetch(...args);
13781
13683
  };
13782
- if (!((_a68 = options === null || options === void 0 ? void 0 : options.params) === null || _a68 === void 0 ? void 0 : _a68.apikey)) {
13684
+ if (!((_a66 = options === null || options === void 0 ? void 0 : options.params) === null || _a66 === void 0 ? void 0 : _a66.apikey)) {
13783
13685
  throw new Error("API key is required to connect to Realtime");
13784
13686
  }
13785
13687
  this.apiKey = options.params.apikey;
@@ -13964,8 +13866,8 @@ Option 2: Install and provide the "ws" package:
13964
13866
  const { topic, event, payload, ref } = data;
13965
13867
  const callback = () => {
13966
13868
  this.encode(data, (result) => {
13967
- var _a68;
13968
- (_a68 = this.conn) === null || _a68 === void 0 ? void 0 : _a68.send(result);
13869
+ var _a66;
13870
+ (_a66 = this.conn) === null || _a66 === void 0 ? void 0 : _a66.send(result);
13969
13871
  });
13970
13872
  };
13971
13873
  this.log("push", `${topic} ${event} (${ref})`, payload);
@@ -14015,7 +13917,7 @@ Option 2: Install and provide the "ws" package:
14015
13917
  * Sends a heartbeat message if the socket is connected.
14016
13918
  */
14017
13919
  async sendHeartbeat() {
14018
- var _a68;
13920
+ var _a66;
14019
13921
  if (!this.isConnected()) {
14020
13922
  try {
14021
13923
  this.heartbeatCallback("disconnected");
@@ -14034,11 +13936,11 @@ Option 2: Install and provide the "ws" package:
14034
13936
  this.log("error", "error in heartbeat callback", e);
14035
13937
  }
14036
13938
  this._wasManualDisconnect = false;
14037
- (_a68 = this.conn) === null || _a68 === void 0 ? void 0 : _a68.close(WS_CLOSE_NORMAL, "heartbeat timeout");
13939
+ (_a66 = this.conn) === null || _a66 === void 0 ? void 0 : _a66.close(WS_CLOSE_NORMAL, "heartbeat timeout");
14038
13940
  setTimeout(() => {
14039
- var _a69;
13941
+ var _a67;
14040
13942
  if (!this.isConnected()) {
14041
- (_a69 = this.reconnectTimer) === null || _a69 === void 0 ? void 0 : _a69.scheduleTimeout();
13943
+ (_a67 = this.reconnectTimer) === null || _a67 === void 0 ? void 0 : _a67.scheduleTimeout();
14042
13944
  }
14043
13945
  }, CONNECTION_TIMEOUTS.HEARTBEAT_TIMEOUT_FALLBACK);
14044
13946
  return;
@@ -14136,12 +14038,12 @@ Option 2: Install and provide the "ws" package:
14136
14038
  * @internal
14137
14039
  */
14138
14040
  _clearTimer(timer) {
14139
- var _a68;
14041
+ var _a66;
14140
14042
  if (timer === "heartbeat" && this.heartbeatTimer) {
14141
14043
  clearInterval(this.heartbeatTimer);
14142
14044
  this.heartbeatTimer = void 0;
14143
14045
  } else if (timer === "reconnect") {
14144
- (_a68 = this.reconnectTimer) === null || _a68 === void 0 ? void 0 : _a68.reset();
14046
+ (_a66 = this.reconnectTimer) === null || _a66 === void 0 ? void 0 : _a66.reset();
14145
14047
  }
14146
14048
  }
14147
14049
  /**
@@ -14256,13 +14158,13 @@ Option 2: Install and provide the "ws" package:
14256
14158
  }
14257
14159
  /** @internal */
14258
14160
  _onConnClose(event) {
14259
- var _a68;
14161
+ var _a66;
14260
14162
  this._setConnectionState("disconnected");
14261
14163
  this.log("transport", "close", event);
14262
14164
  this._triggerChanError();
14263
14165
  this._clearTimer("heartbeat");
14264
14166
  if (!this._wasManualDisconnect) {
14265
- (_a68 = this.reconnectTimer) === null || _a68 === void 0 ? void 0 : _a68.scheduleTimeout();
14167
+ (_a66 = this.reconnectTimer) === null || _a66 === void 0 ? void 0 : _a66.scheduleTimeout();
14266
14168
  }
14267
14169
  this._triggerStateCallbacks("close", event);
14268
14170
  }
@@ -14410,9 +14312,9 @@ Option 2: Install and provide the "ws" package:
14410
14312
  * @internal
14411
14313
  */
14412
14314
  _initializeOptions(options) {
14413
- var _a68, _b4, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
14414
- this.transport = (_a68 = options === null || options === void 0 ? void 0 : options.transport) !== null && _a68 !== void 0 ? _a68 : null;
14415
- this.timeout = (_b4 = options === null || options === void 0 ? void 0 : options.timeout) !== null && _b4 !== void 0 ? _b4 : DEFAULT_TIMEOUT;
14315
+ var _a66, _b3, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
14316
+ this.transport = (_a66 = options === null || options === void 0 ? void 0 : options.transport) !== null && _a66 !== void 0 ? _a66 : null;
14317
+ this.timeout = (_b3 = options === null || options === void 0 ? void 0 : options.timeout) !== null && _b3 !== void 0 ? _b3 : DEFAULT_TIMEOUT;
14416
14318
  this.heartbeatIntervalMs = (_c = options === null || options === void 0 ? void 0 : options.heartbeatIntervalMs) !== null && _c !== void 0 ? _c : CONNECTION_TIMEOUTS.HEARTBEAT_INTERVAL;
14417
14319
  this.worker = (_d = options === null || options === void 0 ? void 0 : options.worker) !== null && _d !== void 0 ? _d : false;
14418
14320
  this.accessToken = (_e = options === null || options === void 0 ? void 0 : options.accessToken) !== null && _e !== void 0 ? _e : null;
@@ -14457,14 +14359,14 @@ Option 2: Install and provide the "ws" package:
14457
14359
  // node_modules/.pnpm/iceberg-js@0.8.1/node_modules/iceberg-js/dist/index.mjs
14458
14360
  var IcebergError = class extends Error {
14459
14361
  constructor(message, opts) {
14460
- var _a68;
14362
+ var _a66;
14461
14363
  super(message);
14462
14364
  this.name = "IcebergError";
14463
14365
  this.status = opts.status;
14464
14366
  this.icebergType = opts.icebergType;
14465
14367
  this.icebergCode = opts.icebergCode;
14466
14368
  this.details = opts.details;
14467
- this.isCommitStateUnknown = opts.icebergType === "CommitStateUnknownException" || [500, 502, 504].includes(opts.status) && ((_a68 = opts.icebergType) == null ? void 0 : _a68.includes("CommitState")) === true;
14369
+ this.isCommitStateUnknown = opts.icebergType === "CommitStateUnknownException" || [500, 502, 504].includes(opts.status) && ((_a66 = opts.icebergType) == null ? void 0 : _a66.includes("CommitState")) === true;
14468
14370
  }
14469
14371
  /**
14470
14372
  * Returns true if the error is a 404 Not Found error.
@@ -14512,8 +14414,8 @@ async function buildAuthHeaders(auth) {
14512
14414
  return {};
14513
14415
  }
14514
14416
  function createFetchClient(options) {
14515
- var _a68;
14516
- const fetchFn = (_a68 = options.fetchImpl) != null ? _a68 : globalThis.fetch;
14417
+ var _a66;
14418
+ const fetchFn = (_a66 = options.fetchImpl) != null ? _a66 : globalThis.fetch;
14517
14419
  return {
14518
14420
  async request({
14519
14421
  method,
@@ -14522,7 +14424,7 @@ function createFetchClient(options) {
14522
14424
  body,
14523
14425
  headers
14524
14426
  }) {
14525
- var _a69;
14427
+ var _a67;
14526
14428
  const url = buildUrl(options.baseUrl, path, query);
14527
14429
  const authHeaders = await buildAuthHeaders(options.auth);
14528
14430
  const res = await fetchFn(url, {
@@ -14541,7 +14443,7 @@ function createFetchClient(options) {
14541
14443
  const errBody = isJson ? data : void 0;
14542
14444
  const errorDetail = errBody == null ? void 0 : errBody.error;
14543
14445
  throw new IcebergError(
14544
- (_a69 = errorDetail == null ? void 0 : errorDetail.message) != null ? _a69 : `Request failed with status ${res.status}`,
14446
+ (_a67 = errorDetail == null ? void 0 : errorDetail.message) != null ? _a67 : `Request failed with status ${res.status}`,
14545
14447
  {
14546
14448
  status: res.status,
14547
14449
  icebergType: errorDetail == null ? void 0 : errorDetail.type,
@@ -14664,11 +14566,11 @@ var TableOperations = class {
14664
14566
  };
14665
14567
  }
14666
14568
  async dropTable(id, options) {
14667
- var _a68;
14569
+ var _a66;
14668
14570
  await this.client.request({
14669
14571
  method: "DELETE",
14670
14572
  path: `${this.prefix}/namespaces/${namespaceToPath2(id.namespace)}/tables/${id.name}`,
14671
- query: { purgeRequested: String((_a68 = options == null ? void 0 : options.purge) != null ? _a68 : false) }
14573
+ query: { purgeRequested: String((_a66 = options == null ? void 0 : options.purge) != null ? _a66 : false) }
14672
14574
  });
14673
14575
  }
14674
14576
  async loadTable(id) {
@@ -14720,7 +14622,7 @@ var IcebergRestCatalog = class {
14720
14622
  * @param options - Configuration options for the catalog client
14721
14623
  */
14722
14624
  constructor(options) {
14723
- var _a68;
14625
+ var _a66;
14724
14626
  let prefix = "v1";
14725
14627
  if (options.catalogName) {
14726
14628
  prefix += `/${options.catalogName}`;
@@ -14731,7 +14633,7 @@ var IcebergRestCatalog = class {
14731
14633
  auth: options.auth,
14732
14634
  fetchImpl: options.fetch
14733
14635
  });
14734
- this.accessDelegation = (_a68 = options.accessDelegation) == null ? void 0 : _a68.join(",");
14636
+ this.accessDelegation = (_a66 = options.accessDelegation) == null ? void 0 : _a66.join(",");
14735
14637
  this.namespaceOps = new NamespaceOperations(this.client, prefix);
14736
14638
  this.tableOps = new TableOperations(this.client, prefix, this.accessDelegation);
14737
14639
  }
@@ -17704,7 +17606,7 @@ var getItemAsync = async (storage, key) => {
17704
17606
  }
17705
17607
  try {
17706
17608
  return JSON.parse(value);
17707
- } catch (_a68) {
17609
+ } catch (_a66) {
17708
17610
  return value;
17709
17611
  }
17710
17612
  };
@@ -17915,7 +17817,7 @@ function deepClone(obj) {
17915
17817
  var _getErrorMessage2 = (err) => err.msg || err.message || err.error_description || err.error || JSON.stringify(err);
17916
17818
  var NETWORK_ERROR_CODES = [502, 503, 504];
17917
17819
  async function handleError2(error) {
17918
- var _a68;
17820
+ var _a66;
17919
17821
  if (!looksLikeFetchResponse(error)) {
17920
17822
  throw new AuthRetryableFetchError(_getErrorMessage2(error), 0);
17921
17823
  }
@@ -17940,7 +17842,7 @@ async function handleError2(error) {
17940
17842
  throw new AuthWeakPasswordError(_getErrorMessage2(data), error.status, data.weak_password.reasons);
17941
17843
  }
17942
17844
  } else if (errorCode === "weak_password") {
17943
- throw new AuthWeakPasswordError(_getErrorMessage2(data), error.status, ((_a68 = data.weak_password) === null || _a68 === void 0 ? void 0 : _a68.reasons) || []);
17845
+ throw new AuthWeakPasswordError(_getErrorMessage2(data), error.status, ((_a66 = data.weak_password) === null || _a66 === void 0 ? void 0 : _a66.reasons) || []);
17944
17846
  } else if (errorCode === "session_not_found") {
17945
17847
  throw new AuthSessionMissingError();
17946
17848
  }
@@ -17956,7 +17858,7 @@ var _getRequestParams2 = (method, options, parameters, body) => {
17956
17858
  return Object.assign(Object.assign({}, params), parameters);
17957
17859
  };
17958
17860
  async function _request(fetcher, method, url, options) {
17959
- var _a68;
17861
+ var _a66;
17960
17862
  const headers = Object.assign({}, options === null || options === void 0 ? void 0 : options.headers);
17961
17863
  if (!headers[API_VERSION_HEADER_NAME]) {
17962
17864
  headers[API_VERSION_HEADER_NAME] = API_VERSIONS["2024-01-01"].name;
@@ -17964,7 +17866,7 @@ async function _request(fetcher, method, url, options) {
17964
17866
  if (options === null || options === void 0 ? void 0 : options.jwt) {
17965
17867
  headers["Authorization"] = `Bearer ${options.jwt}`;
17966
17868
  }
17967
- const qs = (_a68 = options === null || options === void 0 ? void 0 : options.query) !== null && _a68 !== void 0 ? _a68 : {};
17869
+ const qs = (_a66 = options === null || options === void 0 ? void 0 : options.query) !== null && _a66 !== void 0 ? _a66 : {};
17968
17870
  if (options === null || options === void 0 ? void 0 : options.redirectTo) {
17969
17871
  qs["redirect_to"] = options.redirectTo;
17970
17872
  }
@@ -17997,7 +17899,7 @@ async function _handleRequest2(fetcher, method, url, options, parameters, body)
17997
17899
  }
17998
17900
  }
17999
17901
  function _sessionResponse(data) {
18000
- var _a68;
17902
+ var _a66;
18001
17903
  let session = null;
18002
17904
  if (hasSession(data)) {
18003
17905
  session = Object.assign({}, data);
@@ -18005,7 +17907,7 @@ function _sessionResponse(data) {
18005
17907
  session.expires_at = expiresAt(data.expires_in);
18006
17908
  }
18007
17909
  }
18008
- const user = (_a68 = data.user) !== null && _a68 !== void 0 ? _a68 : data;
17910
+ const user = (_a66 = data.user) !== null && _a66 !== void 0 ? _a66 : data;
18009
17911
  return { data: { session, user }, error: null };
18010
17912
  }
18011
17913
  function _sessionResponsePassword(data) {
@@ -18016,8 +17918,8 @@ function _sessionResponsePassword(data) {
18016
17918
  return response;
18017
17919
  }
18018
17920
  function _userResponse(data) {
18019
- var _a68;
18020
- const user = (_a68 = data.user) !== null && _a68 !== void 0 ? _a68 : data;
17921
+ var _a66;
17922
+ const user = (_a66 = data.user) !== null && _a66 !== void 0 ? _a66 : data;
18021
17923
  return { data: { user }, error: null };
18022
17924
  }
18023
17925
  function _ssoResponse(data) {
@@ -18186,14 +18088,14 @@ var GoTrueAdminApi = class {
18186
18088
  * @param params An object which supports `page` and `perPage` as numbers, to alter the paginated results.
18187
18089
  */
18188
18090
  async listUsers(params) {
18189
- var _a68, _b4, _c, _d, _e, _f, _g;
18091
+ var _a66, _b3, _c, _d, _e, _f, _g;
18190
18092
  try {
18191
18093
  const pagination = { nextPage: null, lastPage: 0, total: 0 };
18192
18094
  const response = await _request(this.fetch, "GET", `${this.url}/admin/users`, {
18193
18095
  headers: this.headers,
18194
18096
  noResolveJson: true,
18195
18097
  query: {
18196
- page: (_b4 = (_a68 = params === null || params === void 0 ? void 0 : params.page) === null || _a68 === void 0 ? void 0 : _a68.toString()) !== null && _b4 !== void 0 ? _b4 : "",
18098
+ page: (_b3 = (_a66 = params === null || params === void 0 ? void 0 : params.page) === null || _a66 === void 0 ? void 0 : _a66.toString()) !== null && _b3 !== void 0 ? _b3 : "",
18197
18099
  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 : ""
18198
18100
  },
18199
18101
  xform: _noResolveJsonResponse
@@ -18327,14 +18229,14 @@ var GoTrueAdminApi = class {
18327
18229
  * This function should only be called on a server. Never expose your `service_role` key in the browser.
18328
18230
  */
18329
18231
  async _listOAuthClients(params) {
18330
- var _a68, _b4, _c, _d, _e, _f, _g;
18232
+ var _a66, _b3, _c, _d, _e, _f, _g;
18331
18233
  try {
18332
18234
  const pagination = { nextPage: null, lastPage: 0, total: 0 };
18333
18235
  const response = await _request(this.fetch, "GET", `${this.url}/admin/oauth/clients`, {
18334
18236
  headers: this.headers,
18335
18237
  noResolveJson: true,
18336
18238
  query: {
18337
- page: (_b4 = (_a68 = params === null || params === void 0 ? void 0 : params.page) === null || _a68 === void 0 ? void 0 : _a68.toString()) !== null && _b4 !== void 0 ? _b4 : "",
18239
+ page: (_b3 = (_a66 = params === null || params === void 0 ? void 0 : params.page) === null || _a66 === void 0 ? void 0 : _a66.toString()) !== null && _b3 !== void 0 ? _b3 : "",
18338
18240
  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 : ""
18339
18241
  },
18340
18242
  xform: _noResolveJsonResponse
@@ -18587,7 +18489,7 @@ function toHex(value) {
18587
18489
  return "0x" + hex;
18588
18490
  }
18589
18491
  function createSiweMessage(parameters) {
18590
- var _a68;
18492
+ var _a66;
18591
18493
  const { chainId, domain, expirationTime, issuedAt = /* @__PURE__ */ new Date(), nonce, notBefore, requestId, resources, scheme, uri, version: version5 } = parameters;
18592
18494
  {
18593
18495
  if (!Number.isInteger(chainId))
@@ -18600,7 +18502,7 @@ function createSiweMessage(parameters) {
18600
18502
  throw new Error(`@supabase/auth-js: Invalid SIWE message field "uri". URI must be provided.`);
18601
18503
  if (version5 !== "1")
18602
18504
  throw new Error(`@supabase/auth-js: Invalid SIWE message field "version". Version must be '1'. Provided value: ${version5}`);
18603
- if ((_a68 = parameters.statement) === null || _a68 === void 0 ? void 0 : _a68.includes("\n"))
18505
+ if ((_a66 = parameters.statement) === null || _a66 === void 0 ? void 0 : _a66.includes("\n"))
18604
18506
  throw new Error(`@supabase/auth-js: Invalid SIWE message field "statement". Statement must not include '\\n'. Provided value: ${parameters.statement}`);
18605
18507
  }
18606
18508
  const address = getAddress(parameters.address);
@@ -18642,10 +18544,10 @@ ${suffix}`;
18642
18544
  // node_modules/.pnpm/@supabase+auth-js@2.95.1/node_modules/@supabase/auth-js/dist/module/lib/webauthn.errors.js
18643
18545
  var WebAuthnError = class extends Error {
18644
18546
  constructor({ message, code, cause, name }) {
18645
- var _a68;
18547
+ var _a66;
18646
18548
  super(message, { cause });
18647
18549
  this.__isWebAuthnError = true;
18648
- this.name = (_a68 = name !== null && name !== void 0 ? name : cause instanceof Error ? cause.name : void 0) !== null && _a68 !== void 0 ? _a68 : "Unknown Error";
18550
+ this.name = (_a66 = name !== null && name !== void 0 ? name : cause instanceof Error ? cause.name : void 0) !== null && _a66 !== void 0 ? _a66 : "Unknown Error";
18649
18551
  this.code = code;
18650
18552
  }
18651
18553
  };
@@ -18661,7 +18563,7 @@ var WebAuthnUnknownError = class extends WebAuthnError {
18661
18563
  }
18662
18564
  };
18663
18565
  function identifyRegistrationError({ error, options }) {
18664
- var _a68, _b4, _c;
18566
+ var _a66, _b3, _c;
18665
18567
  const { publicKey } = options;
18666
18568
  if (!publicKey) {
18667
18569
  throw Error("options was missing required publicKey property");
@@ -18675,7 +18577,7 @@ function identifyRegistrationError({ error, options }) {
18675
18577
  });
18676
18578
  }
18677
18579
  } else if (error.name === "ConstraintError") {
18678
- if (((_a68 = publicKey.authenticatorSelection) === null || _a68 === void 0 ? void 0 : _a68.requireResidentKey) === true) {
18580
+ if (((_a66 = publicKey.authenticatorSelection) === null || _a66 === void 0 ? void 0 : _a66.requireResidentKey) === true) {
18679
18581
  return new WebAuthnError({
18680
18582
  message: "Discoverable credentials were required but no available authenticator supported it",
18681
18583
  code: "ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",
@@ -18683,7 +18585,7 @@ function identifyRegistrationError({ error, options }) {
18683
18585
  });
18684
18586
  } else if (
18685
18587
  // @ts-ignore: `mediation` doesn't yet exist on CredentialCreationOptions but it's possible as of Sept 2024
18686
- options.mediation === "conditional" && ((_b4 = publicKey.authenticatorSelection) === null || _b4 === void 0 ? void 0 : _b4.userVerification) === "required"
18588
+ options.mediation === "conditional" && ((_b3 = publicKey.authenticatorSelection) === null || _b3 === void 0 ? void 0 : _b3.userVerification) === "required"
18687
18589
  ) {
18688
18590
  return new WebAuthnError({
18689
18591
  message: "User verification was required during automatic registration but it could not be performed",
@@ -18904,7 +18806,7 @@ function deserializeCredentialRequestOptions(options) {
18904
18806
  return result;
18905
18807
  }
18906
18808
  function serializeCredentialCreationResponse(credential) {
18907
- var _a68;
18809
+ var _a66;
18908
18810
  if ("toJSON" in credential && typeof credential.toJSON === "function") {
18909
18811
  return credential.toJSON();
18910
18812
  }
@@ -18919,11 +18821,11 @@ function serializeCredentialCreationResponse(credential) {
18919
18821
  type: "public-key",
18920
18822
  clientExtensionResults: credential.getClientExtensionResults(),
18921
18823
  // Convert null to undefined and cast to AuthenticatorAttachment type
18922
- authenticatorAttachment: (_a68 = credentialWithAttachment.authenticatorAttachment) !== null && _a68 !== void 0 ? _a68 : void 0
18824
+ authenticatorAttachment: (_a66 = credentialWithAttachment.authenticatorAttachment) !== null && _a66 !== void 0 ? _a66 : void 0
18923
18825
  };
18924
18826
  }
18925
18827
  function serializeCredentialRequestResponse(credential) {
18926
- var _a68;
18828
+ var _a66;
18927
18829
  if ("toJSON" in credential && typeof credential.toJSON === "function") {
18928
18830
  return credential.toJSON();
18929
18831
  }
@@ -18943,7 +18845,7 @@ function serializeCredentialRequestResponse(credential) {
18943
18845
  type: "public-key",
18944
18846
  clientExtensionResults,
18945
18847
  // Convert null to undefined and cast to AuthenticatorAttachment type
18946
- authenticatorAttachment: (_a68 = credentialWithAttachment.authenticatorAttachment) !== null && _a68 !== void 0 ? _a68 : void 0
18848
+ authenticatorAttachment: (_a66 = credentialWithAttachment.authenticatorAttachment) !== null && _a66 !== void 0 ? _a66 : void 0
18947
18849
  };
18948
18850
  }
18949
18851
  function isValidDomain(hostname) {
@@ -18953,8 +18855,8 @@ function isValidDomain(hostname) {
18953
18855
  );
18954
18856
  }
18955
18857
  function browserSupportsWebAuthn() {
18956
- var _a68, _b4;
18957
- return !!(isBrowser() && "PublicKeyCredential" in window && window.PublicKeyCredential && "credentials" in navigator && typeof ((_a68 = navigator === null || navigator === void 0 ? void 0 : navigator.credentials) === null || _a68 === void 0 ? void 0 : _a68.create) === "function" && typeof ((_b4 = navigator === null || navigator === void 0 ? void 0 : navigator.credentials) === null || _b4 === void 0 ? void 0 : _b4.get) === "function");
18858
+ var _a66, _b3;
18859
+ return !!(isBrowser() && "PublicKeyCredential" in window && window.PublicKeyCredential && "credentials" in navigator && typeof ((_a66 = navigator === null || navigator === void 0 ? void 0 : navigator.credentials) === null || _a66 === void 0 ? void 0 : _a66.create) === "function" && typeof ((_b3 = navigator === null || navigator === void 0 ? void 0 : navigator.credentials) === null || _b3 === void 0 ? void 0 : _b3.get) === "function");
18958
18860
  }
18959
18861
  async function createCredential(options) {
18960
18862
  try {
@@ -19102,7 +19004,7 @@ var WebAuthnApi = class {
19102
19004
  * @see {@link https://w3c.github.io/webauthn/#sctn-verifying-assertion W3C WebAuthn Spec - Verifying Assertion}
19103
19005
  */
19104
19006
  async _challenge({ factorId, webauthn, friendlyName, signal }, overrides) {
19105
- var _a68;
19007
+ var _a66;
19106
19008
  try {
19107
19009
  const { data: challengeResponse, error: challengeError } = await this.client.mfa.challenge({
19108
19010
  factorId,
@@ -19119,7 +19021,7 @@ var WebAuthnApi = class {
19119
19021
  if (!nameToUse) {
19120
19022
  const currentUser = await this.client.getUser();
19121
19023
  const userData = currentUser.data.user;
19122
- const fallbackName = ((_a68 = userData === null || userData === void 0 ? void 0 : userData.user_metadata) === null || _a68 === void 0 ? void 0 : _a68.name) || (userData === null || userData === void 0 ? void 0 : userData.email) || (userData === null || userData === void 0 ? void 0 : userData.id) || "User";
19024
+ const fallbackName = ((_a66 = userData === null || userData === void 0 ? void 0 : userData.user_metadata) === null || _a66 === void 0 ? void 0 : _a66.name) || (userData === null || userData === void 0 ? void 0 : userData.email) || (userData === null || userData === void 0 ? void 0 : userData.id) || "User";
19123
19025
  user.name = `${user.id}:${fallbackName}`;
19124
19026
  } else {
19125
19027
  user.name = `${user.id}:${nameToUse}`;
@@ -19292,8 +19194,8 @@ var WebAuthnApi = class {
19292
19194
  });
19293
19195
  if (!factor) {
19294
19196
  await this.client.mfa.listFactors().then((factors) => {
19295
- var _a68;
19296
- return (_a68 = factors.data) === null || _a68 === void 0 ? void 0 : _a68.all.find((v) => v.factor_type === "webauthn" && v.friendly_name === friendlyName && v.status !== "unverified");
19197
+ var _a66;
19198
+ return (_a66 = factors.data) === null || _a66 === void 0 ? void 0 : _a66.all.find((v) => v.factor_type === "webauthn" && v.friendly_name === friendlyName && v.status !== "unverified");
19297
19199
  }).then((factor2) => factor2 ? this.client.mfa.unenroll({ factorId: factor2 === null || factor2 === void 0 ? void 0 : factor2.id }) : void 0);
19298
19200
  return { data: null, error: enrollError };
19299
19201
  }
@@ -19355,15 +19257,15 @@ var GoTrueClient = class _GoTrueClient {
19355
19257
  * The JWKS used for verifying asymmetric JWTs
19356
19258
  */
19357
19259
  get jwks() {
19358
- var _a68, _b4;
19359
- return (_b4 = (_a68 = GLOBAL_JWKS[this.storageKey]) === null || _a68 === void 0 ? void 0 : _a68.jwks) !== null && _b4 !== void 0 ? _b4 : { keys: [] };
19260
+ var _a66, _b3;
19261
+ return (_b3 = (_a66 = GLOBAL_JWKS[this.storageKey]) === null || _a66 === void 0 ? void 0 : _a66.jwks) !== null && _b3 !== void 0 ? _b3 : { keys: [] };
19360
19262
  }
19361
19263
  set jwks(value) {
19362
19264
  GLOBAL_JWKS[this.storageKey] = Object.assign(Object.assign({}, GLOBAL_JWKS[this.storageKey]), { jwks: value });
19363
19265
  }
19364
19266
  get jwks_cached_at() {
19365
- var _a68, _b4;
19366
- return (_b4 = (_a68 = GLOBAL_JWKS[this.storageKey]) === null || _a68 === void 0 ? void 0 : _a68.cachedAt) !== null && _b4 !== void 0 ? _b4 : Number.MIN_SAFE_INTEGER;
19267
+ var _a66, _b3;
19268
+ return (_b3 = (_a66 = GLOBAL_JWKS[this.storageKey]) === null || _a66 === void 0 ? void 0 : _a66.cachedAt) !== null && _b3 !== void 0 ? _b3 : Number.MIN_SAFE_INTEGER;
19367
19269
  }
19368
19270
  set jwks_cached_at(value) {
19369
19271
  GLOBAL_JWKS[this.storageKey] = Object.assign(Object.assign({}, GLOBAL_JWKS[this.storageKey]), { cachedAt: value });
@@ -19383,7 +19285,7 @@ var GoTrueClient = class _GoTrueClient {
19383
19285
  * ```
19384
19286
  */
19385
19287
  constructor(options) {
19386
- var _a68, _b4, _c;
19288
+ var _a66, _b3, _c;
19387
19289
  this.userStorage = null;
19388
19290
  this.memoryStorage = null;
19389
19291
  this.stateChangeEmitters = /* @__PURE__ */ new Map();
@@ -19401,7 +19303,7 @@ var GoTrueClient = class _GoTrueClient {
19401
19303
  this.logger = console.log;
19402
19304
  const settings = Object.assign(Object.assign({}, DEFAULT_OPTIONS), options);
19403
19305
  this.storageKey = settings.storageKey;
19404
- this.instanceID = (_a68 = _GoTrueClient.nextInstanceID[this.storageKey]) !== null && _a68 !== void 0 ? _a68 : 0;
19306
+ this.instanceID = (_a66 = _GoTrueClient.nextInstanceID[this.storageKey]) !== null && _a66 !== void 0 ? _a66 : 0;
19405
19307
  _GoTrueClient.nextInstanceID[this.storageKey] = this.instanceID + 1;
19406
19308
  this.logDebugMessages = !!settings.debug;
19407
19309
  if (typeof settings.debug === "function") {
@@ -19432,7 +19334,7 @@ var GoTrueClient = class _GoTrueClient {
19432
19334
  this.lockAcquireTimeout = settings.lockAcquireTimeout;
19433
19335
  if (settings.lock) {
19434
19336
  this.lock = settings.lock;
19435
- } else if (this.persistSession && isBrowser() && ((_b4 = globalThis === null || globalThis === void 0 ? void 0 : globalThis.navigator) === null || _b4 === void 0 ? void 0 : _b4.locks)) {
19337
+ } else if (this.persistSession && isBrowser() && ((_b3 = globalThis === null || globalThis === void 0 ? void 0 : globalThis.navigator) === null || _b3 === void 0 ? void 0 : _b3.locks)) {
19436
19338
  this.lock = navigatorLock;
19437
19339
  } else {
19438
19340
  this.lock = lockNoOp;
@@ -19544,7 +19446,7 @@ var GoTrueClient = class _GoTrueClient {
19544
19446
  * the whole lifetime of the client
19545
19447
  */
19546
19448
  async _initialize() {
19547
- var _a68;
19449
+ var _a66;
19548
19450
  try {
19549
19451
  let params = {};
19550
19452
  let callbackUrlType = "none";
@@ -19561,7 +19463,7 @@ var GoTrueClient = class _GoTrueClient {
19561
19463
  if (error) {
19562
19464
  this._debug("#_initialize()", "error detecting session from URL", error);
19563
19465
  if (isAuthImplicitGrantRedirectError(error)) {
19564
- const errorCode = (_a68 = error.details) === null || _a68 === void 0 ? void 0 : _a68.code;
19466
+ const errorCode = (_a66 = error.details) === null || _a66 === void 0 ? void 0 : _a66.code;
19565
19467
  if (errorCode === "identity_already_exists" || errorCode === "identity_not_found" || errorCode === "single_identity_not_deletable") {
19566
19468
  return { error };
19567
19469
  }
@@ -19600,12 +19502,12 @@ var GoTrueClient = class _GoTrueClient {
19600
19502
  * @returns A session where the is_anonymous claim in the access token JWT set to true
19601
19503
  */
19602
19504
  async signInAnonymously(credentials) {
19603
- var _a68, _b4, _c;
19505
+ var _a66, _b3, _c;
19604
19506
  try {
19605
19507
  const res = await _request(this.fetch, "POST", `${this.url}/signup`, {
19606
19508
  headers: this.headers,
19607
19509
  body: {
19608
- data: (_b4 = (_a68 = credentials === null || credentials === void 0 ? void 0 : credentials.options) === null || _a68 === void 0 ? void 0 : _a68.data) !== null && _b4 !== void 0 ? _b4 : {},
19510
+ data: (_b3 = (_a66 = credentials === null || credentials === void 0 ? void 0 : credentials.options) === null || _a66 === void 0 ? void 0 : _a66.data) !== null && _b3 !== void 0 ? _b3 : {},
19609
19511
  gotrue_meta_security: { captcha_token: (_c = credentials === null || credentials === void 0 ? void 0 : credentials.options) === null || _c === void 0 ? void 0 : _c.captchaToken }
19610
19512
  },
19611
19513
  xform: _sessionResponse
@@ -19639,7 +19541,7 @@ var GoTrueClient = class _GoTrueClient {
19639
19541
  * @returns A user if the server has "autoconfirm" OFF
19640
19542
  */
19641
19543
  async signUp(credentials) {
19642
- var _a68, _b4, _c;
19544
+ var _a66, _b3, _c;
19643
19545
  try {
19644
19546
  let res;
19645
19547
  if ("email" in credentials) {
@@ -19656,7 +19558,7 @@ var GoTrueClient = class _GoTrueClient {
19656
19558
  body: {
19657
19559
  email,
19658
19560
  password,
19659
- data: (_a68 = options === null || options === void 0 ? void 0 : options.data) !== null && _a68 !== void 0 ? _a68 : {},
19561
+ data: (_a66 = options === null || options === void 0 ? void 0 : options.data) !== null && _a66 !== void 0 ? _a66 : {},
19660
19562
  gotrue_meta_security: { captcha_token: options === null || options === void 0 ? void 0 : options.captchaToken },
19661
19563
  code_challenge: codeChallenge,
19662
19564
  code_challenge_method: codeChallengeMethod
@@ -19670,7 +19572,7 @@ var GoTrueClient = class _GoTrueClient {
19670
19572
  body: {
19671
19573
  phone,
19672
19574
  password,
19673
- data: (_b4 = options === null || options === void 0 ? void 0 : options.data) !== null && _b4 !== void 0 ? _b4 : {},
19575
+ data: (_b3 = options === null || options === void 0 ? void 0 : options.data) !== null && _b3 !== void 0 ? _b3 : {},
19674
19576
  channel: (_c = options === null || options === void 0 ? void 0 : options.channel) !== null && _c !== void 0 ? _c : "sms",
19675
19577
  gotrue_meta_security: { captcha_token: options === null || options === void 0 ? void 0 : options.captchaToken }
19676
19578
  },
@@ -19762,10 +19664,10 @@ var GoTrueClient = class _GoTrueClient {
19762
19664
  * This method supports the PKCE flow.
19763
19665
  */
19764
19666
  async signInWithOAuth(credentials) {
19765
- var _a68, _b4, _c, _d;
19667
+ var _a66, _b3, _c, _d;
19766
19668
  return await this._handleProviderSignIn(credentials.provider, {
19767
- redirectTo: (_a68 = credentials.options) === null || _a68 === void 0 ? void 0 : _a68.redirectTo,
19768
- scopes: (_b4 = credentials.options) === null || _b4 === void 0 ? void 0 : _b4.scopes,
19669
+ redirectTo: (_a66 = credentials.options) === null || _a66 === void 0 ? void 0 : _a66.redirectTo,
19670
+ scopes: (_b3 = credentials.options) === null || _b3 === void 0 ? void 0 : _b3.scopes,
19769
19671
  queryParams: (_c = credentials.options) === null || _c === void 0 ? void 0 : _c.queryParams,
19770
19672
  skipBrowserRedirect: (_d = credentials.options) === null || _d === void 0 ? void 0 : _d.skipBrowserRedirect
19771
19673
  });
@@ -19798,7 +19700,7 @@ var GoTrueClient = class _GoTrueClient {
19798
19700
  }
19799
19701
  }
19800
19702
  async signInWithEthereum(credentials) {
19801
- var _a68, _b4, _c, _d, _e, _f, _g, _h, _j, _k, _l;
19703
+ var _a66, _b3, _c, _d, _e, _f, _g, _h, _j, _k, _l;
19802
19704
  let message;
19803
19705
  let signature;
19804
19706
  if ("message" in credentials) {
@@ -19822,7 +19724,7 @@ var GoTrueClient = class _GoTrueClient {
19822
19724
  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.`);
19823
19725
  }
19824
19726
  }
19825
- const url = new URL((_a68 = options === null || options === void 0 ? void 0 : options.url) !== null && _a68 !== void 0 ? _a68 : window.location.href);
19727
+ const url = new URL((_a66 = options === null || options === void 0 ? void 0 : options.url) !== null && _a66 !== void 0 ? _a66 : window.location.href);
19826
19728
  const accounts = await resolvedWallet.request({
19827
19729
  method: "eth_requestAccounts"
19828
19730
  }).then((accs) => accs).catch(() => {
@@ -19832,7 +19734,7 @@ var GoTrueClient = class _GoTrueClient {
19832
19734
  throw new Error(`@supabase/auth-js: No accounts available. Please ensure the wallet is connected.`);
19833
19735
  }
19834
19736
  const address = getAddress(accounts[0]);
19835
- let chainId = (_b4 = options === null || options === void 0 ? void 0 : options.signInWithEthereum) === null || _b4 === void 0 ? void 0 : _b4.chainId;
19737
+ let chainId = (_b3 = options === null || options === void 0 ? void 0 : options.signInWithEthereum) === null || _b3 === void 0 ? void 0 : _b3.chainId;
19836
19738
  if (!chainId) {
19837
19739
  const chainIdHex = await resolvedWallet.request({
19838
19740
  method: "eth_chainId"
@@ -19889,7 +19791,7 @@ var GoTrueClient = class _GoTrueClient {
19889
19791
  }
19890
19792
  }
19891
19793
  async signInWithSolana(credentials) {
19892
- var _a68, _b4, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
19794
+ var _a66, _b3, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
19893
19795
  let message;
19894
19796
  let signature;
19895
19797
  if ("message" in credentials) {
@@ -19913,7 +19815,7 @@ var GoTrueClient = class _GoTrueClient {
19913
19815
  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.`);
19914
19816
  }
19915
19817
  }
19916
- const url = new URL((_a68 = options === null || options === void 0 ? void 0 : options.url) !== null && _a68 !== void 0 ? _a68 : window.location.href);
19818
+ const url = new URL((_a66 = options === null || options === void 0 ? void 0 : options.url) !== null && _a66 !== void 0 ? _a66 : window.location.href);
19917
19819
  if ("signIn" in resolvedWallet && resolvedWallet.signIn) {
19918
19820
  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), {
19919
19821
  // non-overridable properties
@@ -19945,7 +19847,7 @@ var GoTrueClient = class _GoTrueClient {
19945
19847
  ...statement ? ["", statement, ""] : [""],
19946
19848
  "Version: 1",
19947
19849
  `URI: ${url.href}`,
19948
- `Issued At: ${(_c = (_b4 = options === null || options === void 0 ? void 0 : options.signInWithSolana) === null || _b4 === void 0 ? void 0 : _b4.issuedAt) !== null && _c !== void 0 ? _c : (/* @__PURE__ */ new Date()).toISOString()}`,
19850
+ `Issued At: ${(_c = (_b3 = options === null || options === void 0 ? void 0 : options.signInWithSolana) === null || _b3 === void 0 ? void 0 : _b3.issuedAt) !== null && _c !== void 0 ? _c : (/* @__PURE__ */ new Date()).toISOString()}`,
19949
19851
  ...((_d = options === null || options === void 0 ? void 0 : options.signInWithSolana) === null || _d === void 0 ? void 0 : _d.notBefore) ? [`Not Before: ${options.signInWithSolana.notBefore}`] : [],
19950
19852
  ...((_e = options === null || options === void 0 ? void 0 : options.signInWithSolana) === null || _e === void 0 ? void 0 : _e.expirationTime) ? [`Expiration Time: ${options.signInWithSolana.expirationTime}`] : [],
19951
19853
  ...((_f = options === null || options === void 0 ? void 0 : options.signInWithSolana) === null || _f === void 0 ? void 0 : _f.chainId) ? [`Chain ID: ${options.signInWithSolana.chainId}`] : [],
@@ -20085,7 +19987,7 @@ var GoTrueClient = class _GoTrueClient {
20085
19987
  * This method supports PKCE when an email is passed.
20086
19988
  */
20087
19989
  async signInWithOtp(credentials) {
20088
- var _a68, _b4, _c, _d, _e;
19990
+ var _a66, _b3, _c, _d, _e;
20089
19991
  try {
20090
19992
  if ("email" in credentials) {
20091
19993
  const { email, options } = credentials;
@@ -20099,8 +20001,8 @@ var GoTrueClient = class _GoTrueClient {
20099
20001
  headers: this.headers,
20100
20002
  body: {
20101
20003
  email,
20102
- data: (_a68 = options === null || options === void 0 ? void 0 : options.data) !== null && _a68 !== void 0 ? _a68 : {},
20103
- create_user: (_b4 = options === null || options === void 0 ? void 0 : options.shouldCreateUser) !== null && _b4 !== void 0 ? _b4 : true,
20004
+ data: (_a66 = options === null || options === void 0 ? void 0 : options.data) !== null && _a66 !== void 0 ? _a66 : {},
20005
+ create_user: (_b3 = options === null || options === void 0 ? void 0 : options.shouldCreateUser) !== null && _b3 !== void 0 ? _b3 : true,
20104
20006
  gotrue_meta_security: { captcha_token: options === null || options === void 0 ? void 0 : options.captchaToken },
20105
20007
  code_challenge: codeChallenge,
20106
20008
  code_challenge_method: codeChallengeMethod
@@ -20139,13 +20041,13 @@ var GoTrueClient = class _GoTrueClient {
20139
20041
  * Log in a user given a User supplied OTP or TokenHash received through mobile or email.
20140
20042
  */
20141
20043
  async verifyOtp(params) {
20142
- var _a68, _b4;
20044
+ var _a66, _b3;
20143
20045
  try {
20144
20046
  let redirectTo = void 0;
20145
20047
  let captchaToken = void 0;
20146
20048
  if ("options" in params) {
20147
- redirectTo = (_a68 = params.options) === null || _a68 === void 0 ? void 0 : _a68.redirectTo;
20148
- captchaToken = (_b4 = params.options) === null || _b4 === void 0 ? void 0 : _b4.captchaToken;
20049
+ redirectTo = (_a66 = params.options) === null || _a66 === void 0 ? void 0 : _a66.redirectTo;
20050
+ captchaToken = (_b3 = params.options) === null || _b3 === void 0 ? void 0 : _b3.captchaToken;
20149
20051
  }
20150
20052
  const { data, error } = await _request(this.fetch, "POST", `${this.url}/verify`, {
20151
20053
  headers: this.headers,
@@ -20189,7 +20091,7 @@ var GoTrueClient = class _GoTrueClient {
20189
20091
  * organization's SSO Identity Provider UUID directly instead.
20190
20092
  */
20191
20093
  async signInWithSSO(params) {
20192
- var _a68, _b4, _c, _d, _e;
20094
+ var _a66, _b3, _c, _d, _e;
20193
20095
  try {
20194
20096
  let codeChallenge = null;
20195
20097
  let codeChallengeMethod = null;
@@ -20198,7 +20100,7 @@ var GoTrueClient = class _GoTrueClient {
20198
20100
  [codeChallenge, codeChallengeMethod] = await getCodeChallengeAndMethod(this.storage, this.storageKey);
20199
20101
  }
20200
20102
  const result = await _request(this.fetch, "POST", `${this.url}/sso`, {
20201
- 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: (_b4 = (_a68 = params.options) === null || _a68 === void 0 ? void 0 : _a68.redirectTo) !== null && _b4 !== void 0 ? _b4 : 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 }),
20103
+ body: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, "providerId" in params ? { provider_id: params.providerId } : null), "domain" in params ? { domain: params.domain } : null), { redirect_to: (_b3 = (_a66 = params.options) === null || _a66 === void 0 ? void 0 : _a66.redirectTo) !== null && _b3 !== void 0 ? _b3 : void 0 }), ((_c = params === null || params === void 0 ? void 0 : params.options) === null || _c === void 0 ? void 0 : _c.captchaToken) ? { gotrue_meta_security: { captcha_token: params.options.captchaToken } } : null), { skip_http_redirect: true, code_challenge: codeChallenge, code_challenge_method: codeChallengeMethod }),
20202
20104
  headers: this.headers,
20203
20105
  xform: _ssoResponse
20204
20106
  });
@@ -20452,17 +20354,17 @@ var GoTrueClient = class _GoTrueClient {
20452
20354
  });
20453
20355
  }
20454
20356
  return await this._useSession(async (result) => {
20455
- var _a68, _b4, _c;
20357
+ var _a66, _b3, _c;
20456
20358
  const { data, error } = result;
20457
20359
  if (error) {
20458
20360
  throw error;
20459
20361
  }
20460
- if (!((_a68 = data.session) === null || _a68 === void 0 ? void 0 : _a68.access_token) && !this.hasCustomAuthorizationHeader) {
20362
+ if (!((_a66 = data.session) === null || _a66 === void 0 ? void 0 : _a66.access_token) && !this.hasCustomAuthorizationHeader) {
20461
20363
  return { data: { user: null }, error: new AuthSessionMissingError() };
20462
20364
  }
20463
20365
  return await _request(this.fetch, "GET", `${this.url}/user`, {
20464
20366
  headers: this.headers,
20465
- jwt: (_c = (_b4 = data.session) === null || _b4 === void 0 ? void 0 : _b4.access_token) !== null && _c !== void 0 ? _c : void 0,
20367
+ jwt: (_c = (_b3 = data.session) === null || _b3 === void 0 ? void 0 : _b3.access_token) !== null && _c !== void 0 ? _c : void 0,
20466
20368
  xform: _userResponse
20467
20369
  });
20468
20370
  });
@@ -20599,13 +20501,13 @@ var GoTrueClient = class _GoTrueClient {
20599
20501
  async _refreshSession(currentSession) {
20600
20502
  try {
20601
20503
  return await this._useSession(async (result) => {
20602
- var _a68;
20504
+ var _a66;
20603
20505
  if (!currentSession) {
20604
20506
  const { data, error: error2 } = result;
20605
20507
  if (error2) {
20606
20508
  throw error2;
20607
20509
  }
20608
- currentSession = (_a68 = data.session) !== null && _a68 !== void 0 ? _a68 : void 0;
20510
+ currentSession = (_a66 = data.session) !== null && _a66 !== void 0 ? _a66 : void 0;
20609
20511
  }
20610
20512
  if (!(currentSession === null || currentSession === void 0 ? void 0 : currentSession.refresh_token)) {
20611
20513
  throw new AuthSessionMissingError();
@@ -20743,12 +20645,12 @@ var GoTrueClient = class _GoTrueClient {
20743
20645
  }
20744
20646
  async _signOut({ scope } = { scope: "global" }) {
20745
20647
  return await this._useSession(async (result) => {
20746
- var _a68;
20648
+ var _a66;
20747
20649
  const { data, error: sessionError } = result;
20748
20650
  if (sessionError && !isAuthSessionMissingError(sessionError)) {
20749
20651
  return this._returnResult({ error: sessionError });
20750
20652
  }
20751
- const accessToken = (_a68 = data.session) === null || _a68 === void 0 ? void 0 : _a68.access_token;
20653
+ const accessToken = (_a66 = data.session) === null || _a66 === void 0 ? void 0 : _a66.access_token;
20752
20654
  if (accessToken) {
20753
20655
  const { error } = await this.admin.signOut(accessToken, scope);
20754
20656
  if (error) {
@@ -20786,15 +20688,15 @@ var GoTrueClient = class _GoTrueClient {
20786
20688
  }
20787
20689
  async _emitInitialSession(id) {
20788
20690
  return await this._useSession(async (result) => {
20789
- var _a68, _b4;
20691
+ var _a66, _b3;
20790
20692
  try {
20791
20693
  const { data: { session }, error } = result;
20792
20694
  if (error)
20793
20695
  throw error;
20794
- await ((_a68 = this.stateChangeEmitters.get(id)) === null || _a68 === void 0 ? void 0 : _a68.callback("INITIAL_SESSION", session));
20696
+ await ((_a66 = this.stateChangeEmitters.get(id)) === null || _a66 === void 0 ? void 0 : _a66.callback("INITIAL_SESSION", session));
20795
20697
  this._debug("INITIAL_SESSION", "callback id", id, "session", session);
20796
20698
  } catch (err) {
20797
- await ((_b4 = this.stateChangeEmitters.get(id)) === null || _b4 === void 0 ? void 0 : _b4.callback("INITIAL_SESSION", null));
20699
+ await ((_b3 = this.stateChangeEmitters.get(id)) === null || _b3 === void 0 ? void 0 : _b3.callback("INITIAL_SESSION", null));
20798
20700
  this._debug("INITIAL_SESSION", "callback id", id, "error", err);
20799
20701
  console.error(err);
20800
20702
  }
@@ -20842,12 +20744,12 @@ var GoTrueClient = class _GoTrueClient {
20842
20744
  * Gets all the identities linked to a user.
20843
20745
  */
20844
20746
  async getUserIdentities() {
20845
- var _a68;
20747
+ var _a66;
20846
20748
  try {
20847
20749
  const { data, error } = await this.getUser();
20848
20750
  if (error)
20849
20751
  throw error;
20850
- return this._returnResult({ data: { identities: (_a68 = data.user.identities) !== null && _a68 !== void 0 ? _a68 : [] }, error: null });
20752
+ return this._returnResult({ data: { identities: (_a66 = data.user.identities) !== null && _a66 !== void 0 ? _a66 : [] }, error: null });
20851
20753
  } catch (error) {
20852
20754
  if (isAuthError(error)) {
20853
20755
  return this._returnResult({ data: null, error });
@@ -20862,16 +20764,16 @@ var GoTrueClient = class _GoTrueClient {
20862
20764
  return this.linkIdentityOAuth(credentials);
20863
20765
  }
20864
20766
  async linkIdentityOAuth(credentials) {
20865
- var _a68;
20767
+ var _a66;
20866
20768
  try {
20867
20769
  const { data, error } = await this._useSession(async (result) => {
20868
- var _a69, _b4, _c, _d, _e;
20770
+ var _a67, _b3, _c, _d, _e;
20869
20771
  const { data: data2, error: error2 } = result;
20870
20772
  if (error2)
20871
20773
  throw error2;
20872
20774
  const url = await this._getUrlForProvider(`${this.url}/user/identities/authorize`, credentials.provider, {
20873
- redirectTo: (_a69 = credentials.options) === null || _a69 === void 0 ? void 0 : _a69.redirectTo,
20874
- scopes: (_b4 = credentials.options) === null || _b4 === void 0 ? void 0 : _b4.scopes,
20775
+ redirectTo: (_a67 = credentials.options) === null || _a67 === void 0 ? void 0 : _a67.redirectTo,
20776
+ scopes: (_b3 = credentials.options) === null || _b3 === void 0 ? void 0 : _b3.scopes,
20875
20777
  queryParams: (_c = credentials.options) === null || _c === void 0 ? void 0 : _c.queryParams,
20876
20778
  skipBrowserRedirect: true
20877
20779
  });
@@ -20882,7 +20784,7 @@ var GoTrueClient = class _GoTrueClient {
20882
20784
  });
20883
20785
  if (error)
20884
20786
  throw error;
20885
- if (isBrowser() && !((_a68 = credentials.options) === null || _a68 === void 0 ? void 0 : _a68.skipBrowserRedirect)) {
20787
+ if (isBrowser() && !((_a66 = credentials.options) === null || _a66 === void 0 ? void 0 : _a66.skipBrowserRedirect)) {
20886
20788
  window.location.assign(data === null || data === void 0 ? void 0 : data.url);
20887
20789
  }
20888
20790
  return this._returnResult({
@@ -20898,7 +20800,7 @@ var GoTrueClient = class _GoTrueClient {
20898
20800
  }
20899
20801
  async linkIdentityIdToken(credentials) {
20900
20802
  return await this._useSession(async (result) => {
20901
- var _a68;
20803
+ var _a66;
20902
20804
  try {
20903
20805
  const { error: sessionError, data: { session } } = result;
20904
20806
  if (sessionError)
@@ -20906,7 +20808,7 @@ var GoTrueClient = class _GoTrueClient {
20906
20808
  const { options, provider, token, access_token, nonce } = credentials;
20907
20809
  const res = await _request(this.fetch, "POST", `${this.url}/token?grant_type=id_token`, {
20908
20810
  headers: this.headers,
20909
- jwt: (_a68 = session === null || session === void 0 ? void 0 : session.access_token) !== null && _a68 !== void 0 ? _a68 : void 0,
20811
+ jwt: (_a66 = session === null || session === void 0 ? void 0 : session.access_token) !== null && _a66 !== void 0 ? _a66 : void 0,
20910
20812
  body: {
20911
20813
  provider,
20912
20814
  id_token: token,
@@ -20946,14 +20848,14 @@ var GoTrueClient = class _GoTrueClient {
20946
20848
  async unlinkIdentity(identity) {
20947
20849
  try {
20948
20850
  return await this._useSession(async (result) => {
20949
- var _a68, _b4;
20851
+ var _a66, _b3;
20950
20852
  const { data, error } = result;
20951
20853
  if (error) {
20952
20854
  throw error;
20953
20855
  }
20954
20856
  return await _request(this.fetch, "DELETE", `${this.url}/user/identities/${identity.identity_id}`, {
20955
20857
  headers: this.headers,
20956
- jwt: (_b4 = (_a68 = data.session) === null || _a68 === void 0 ? void 0 : _a68.access_token) !== null && _b4 !== void 0 ? _b4 : void 0
20858
+ jwt: (_b3 = (_a66 = data.session) === null || _a66 === void 0 ? void 0 : _a66.access_token) !== null && _b3 !== void 0 ? _b3 : void 0
20957
20859
  });
20958
20860
  });
20959
20861
  } catch (error) {
@@ -21018,7 +20920,7 @@ var GoTrueClient = class _GoTrueClient {
21018
20920
  * Note: this method is async to accommodate for AsyncStorage e.g. in React native.
21019
20921
  */
21020
20922
  async _recoverAndRefresh() {
21021
- var _a68, _b4;
20923
+ var _a66, _b3;
21022
20924
  const debugName = "#_recoverAndRefresh()";
21023
20925
  this._debug(debugName, "begin");
21024
20926
  try {
@@ -21029,7 +20931,7 @@ var GoTrueClient = class _GoTrueClient {
21029
20931
  maybeUser = { user: currentSession.user };
21030
20932
  await setItemAsync(this.userStorage, this.storageKey + "-user", maybeUser);
21031
20933
  }
21032
- currentSession.user = (_a68 = maybeUser === null || maybeUser === void 0 ? void 0 : maybeUser.user) !== null && _a68 !== void 0 ? _a68 : userNotAvailableProxy();
20934
+ currentSession.user = (_a66 = maybeUser === null || maybeUser === void 0 ? void 0 : maybeUser.user) !== null && _a66 !== void 0 ? _a66 : userNotAvailableProxy();
21033
20935
  } else if (currentSession && !currentSession.user) {
21034
20936
  if (!currentSession.user) {
21035
20937
  const separateUser = await getItemAsync(this.storage, this.storageKey + "-user");
@@ -21050,7 +20952,7 @@ var GoTrueClient = class _GoTrueClient {
21050
20952
  }
21051
20953
  return;
21052
20954
  }
21053
- const expiresWithMargin = ((_b4 = currentSession.expires_at) !== null && _b4 !== void 0 ? _b4 : Infinity) * 1e3 - Date.now() < EXPIRY_MARGIN_MS;
20955
+ const expiresWithMargin = ((_b3 = currentSession.expires_at) !== null && _b3 !== void 0 ? _b3 : Infinity) * 1e3 - Date.now() < EXPIRY_MARGIN_MS;
21054
20956
  this._debug(debugName, `session has${expiresWithMargin ? "" : " not"} expired with margin of ${EXPIRY_MARGIN_MS}s`);
21055
20957
  if (expiresWithMargin) {
21056
20958
  if (this.autoRefreshToken && currentSession.refresh_token) {
@@ -21089,7 +20991,7 @@ var GoTrueClient = class _GoTrueClient {
21089
20991
  }
21090
20992
  }
21091
20993
  async _callRefreshToken(refreshToken) {
21092
- var _a68, _b4;
20994
+ var _a66, _b3;
21093
20995
  if (!refreshToken) {
21094
20996
  throw new AuthSessionMissingError();
21095
20997
  }
@@ -21117,10 +21019,10 @@ var GoTrueClient = class _GoTrueClient {
21117
21019
  if (!isAuthRetryableFetchError(error)) {
21118
21020
  await this._removeSession();
21119
21021
  }
21120
- (_a68 = this.refreshingDeferred) === null || _a68 === void 0 ? void 0 : _a68.resolve(result);
21022
+ (_a66 = this.refreshingDeferred) === null || _a66 === void 0 ? void 0 : _a66.resolve(result);
21121
21023
  return result;
21122
21024
  }
21123
- (_b4 = this.refreshingDeferred) === null || _b4 === void 0 ? void 0 : _b4.reject(error);
21025
+ (_b3 = this.refreshingDeferred) === null || _b3 === void 0 ? void 0 : _b3.reject(error);
21124
21026
  throw error;
21125
21027
  } finally {
21126
21028
  this.refreshingDeferred = null;
@@ -21412,14 +21314,14 @@ var GoTrueClient = class _GoTrueClient {
21412
21314
  async _unenroll(params) {
21413
21315
  try {
21414
21316
  return await this._useSession(async (result) => {
21415
- var _a68;
21317
+ var _a66;
21416
21318
  const { data: sessionData, error: sessionError } = result;
21417
21319
  if (sessionError) {
21418
21320
  return this._returnResult({ data: null, error: sessionError });
21419
21321
  }
21420
21322
  return await _request(this.fetch, "DELETE", `${this.url}/factors/${params.factorId}`, {
21421
21323
  headers: this.headers,
21422
- jwt: (_a68 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a68 === void 0 ? void 0 : _a68.access_token
21324
+ jwt: (_a66 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a66 === void 0 ? void 0 : _a66.access_token
21423
21325
  });
21424
21326
  });
21425
21327
  } catch (error) {
@@ -21432,7 +21334,7 @@ var GoTrueClient = class _GoTrueClient {
21432
21334
  async _enroll(params) {
21433
21335
  try {
21434
21336
  return await this._useSession(async (result) => {
21435
- var _a68, _b4;
21337
+ var _a66, _b3;
21436
21338
  const { data: sessionData, error: sessionError } = result;
21437
21339
  if (sessionError) {
21438
21340
  return this._returnResult({ data: null, error: sessionError });
@@ -21441,12 +21343,12 @@ var GoTrueClient = class _GoTrueClient {
21441
21343
  const { data, error } = await _request(this.fetch, "POST", `${this.url}/factors`, {
21442
21344
  body,
21443
21345
  headers: this.headers,
21444
- jwt: (_a68 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a68 === void 0 ? void 0 : _a68.access_token
21346
+ jwt: (_a66 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a66 === void 0 ? void 0 : _a66.access_token
21445
21347
  });
21446
21348
  if (error) {
21447
21349
  return this._returnResult({ data: null, error });
21448
21350
  }
21449
- if (params.factorType === "totp" && data.type === "totp" && ((_b4 = data === null || data === void 0 ? void 0 : data.totp) === null || _b4 === void 0 ? void 0 : _b4.qr_code)) {
21351
+ if (params.factorType === "totp" && data.type === "totp" && ((_b3 = data === null || data === void 0 ? void 0 : data.totp) === null || _b3 === void 0 ? void 0 : _b3.qr_code)) {
21450
21352
  data.totp.qr_code = `data:image/svg+xml;utf-8,${data.totp.qr_code}`;
21451
21353
  }
21452
21354
  return this._returnResult({ data, error: null });
@@ -21462,7 +21364,7 @@ var GoTrueClient = class _GoTrueClient {
21462
21364
  return this._acquireLock(this.lockAcquireTimeout, async () => {
21463
21365
  try {
21464
21366
  return await this._useSession(async (result) => {
21465
- var _a68;
21367
+ var _a66;
21466
21368
  const { data: sessionData, error: sessionError } = result;
21467
21369
  if (sessionError) {
21468
21370
  return this._returnResult({ data: null, error: sessionError });
@@ -21473,7 +21375,7 @@ var GoTrueClient = class _GoTrueClient {
21473
21375
  const { data, error } = await _request(this.fetch, "POST", `${this.url}/factors/${params.factorId}/verify`, {
21474
21376
  body,
21475
21377
  headers: this.headers,
21476
- jwt: (_a68 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a68 === void 0 ? void 0 : _a68.access_token
21378
+ jwt: (_a66 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a66 === void 0 ? void 0 : _a66.access_token
21477
21379
  });
21478
21380
  if (error) {
21479
21381
  return this._returnResult({ data: null, error });
@@ -21494,7 +21396,7 @@ var GoTrueClient = class _GoTrueClient {
21494
21396
  return this._acquireLock(this.lockAcquireTimeout, async () => {
21495
21397
  try {
21496
21398
  return await this._useSession(async (result) => {
21497
- var _a68;
21399
+ var _a66;
21498
21400
  const { data: sessionData, error: sessionError } = result;
21499
21401
  if (sessionError) {
21500
21402
  return this._returnResult({ data: null, error: sessionError });
@@ -21502,7 +21404,7 @@ var GoTrueClient = class _GoTrueClient {
21502
21404
  const response = await _request(this.fetch, "POST", `${this.url}/factors/${params.factorId}/challenge`, {
21503
21405
  body: params,
21504
21406
  headers: this.headers,
21505
- jwt: (_a68 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a68 === void 0 ? void 0 : _a68.access_token
21407
+ jwt: (_a66 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a66 === void 0 ? void 0 : _a66.access_token
21506
21408
  });
21507
21409
  if (response.error) {
21508
21410
  return response;
@@ -21552,7 +21454,7 @@ var GoTrueClient = class _GoTrueClient {
21552
21454
  * {@see GoTrueMFAApi#listFactors}
21553
21455
  */
21554
21456
  async _listFactors() {
21555
- var _a68;
21457
+ var _a66;
21556
21458
  const { data: { user }, error: userError } = await this.getUser();
21557
21459
  if (userError) {
21558
21460
  return { data: null, error: userError };
@@ -21563,7 +21465,7 @@ var GoTrueClient = class _GoTrueClient {
21563
21465
  totp: [],
21564
21466
  webauthn: []
21565
21467
  };
21566
- for (const factor of (_a68 = user === null || user === void 0 ? void 0 : user.factors) !== null && _a68 !== void 0 ? _a68 : []) {
21468
+ for (const factor of (_a66 = user === null || user === void 0 ? void 0 : user.factors) !== null && _a66 !== void 0 ? _a66 : []) {
21567
21469
  data.all.push(factor);
21568
21470
  if (factor.status === "verified") {
21569
21471
  ;
@@ -21579,7 +21481,7 @@ var GoTrueClient = class _GoTrueClient {
21579
21481
  * {@see GoTrueMFAApi#getAuthenticatorAssuranceLevel}
21580
21482
  */
21581
21483
  async _getAuthenticatorAssuranceLevel(jwt) {
21582
- var _a68, _b4, _c, _d;
21484
+ var _a66, _b3, _c, _d;
21583
21485
  if (jwt) {
21584
21486
  try {
21585
21487
  const { payload: payload2 } = decodeJWT(jwt);
@@ -21592,7 +21494,7 @@ var GoTrueClient = class _GoTrueClient {
21592
21494
  if (userError) {
21593
21495
  return this._returnResult({ data: null, error: userError });
21594
21496
  }
21595
- const verifiedFactors2 = (_b4 = (_a68 = user === null || user === void 0 ? void 0 : user.factors) === null || _a68 === void 0 ? void 0 : _a68.filter((factor) => factor.status === "verified")) !== null && _b4 !== void 0 ? _b4 : [];
21497
+ const verifiedFactors2 = (_b3 = (_a66 = user === null || user === void 0 ? void 0 : user.factors) === null || _a66 === void 0 ? void 0 : _a66.filter((factor) => factor.status === "verified")) !== null && _b3 !== void 0 ? _b3 : [];
21596
21498
  if (verifiedFactors2.length > 0) {
21597
21499
  nextLevel2 = "aal2";
21598
21500
  }
@@ -22229,10 +22131,10 @@ if (shouldShowDeprecationWarning()) console.warn("\u26A0\uFE0F Node.js 18 and b
22229
22131
  var cachedStargate = null;
22230
22132
  var cachedPublic = null;
22231
22133
  function getSupabase() {
22232
- var _a68;
22134
+ var _a66;
22233
22135
  if (cachedStargate) return cachedStargate;
22234
22136
  const url = getRuntimeEnv("VITE_SUPABASE_URL");
22235
- const anon = (_a68 = getRuntimeEnv("VITE_SUPABASE_ANON_KEY")) != null ? _a68 : getRuntimeEnv("VITE_SUPABASE_PUBLISHABLE_KEY");
22137
+ const anon = (_a66 = getRuntimeEnv("VITE_SUPABASE_ANON_KEY")) != null ? _a66 : getRuntimeEnv("VITE_SUPABASE_PUBLISHABLE_KEY");
22236
22138
  const schema = getRuntimeEnvOr("VITE_SUPABASE_SCHEMA", "public");
22237
22139
  if (!url || !anon) {
22238
22140
  return null;
@@ -22247,10 +22149,10 @@ function getSupabase() {
22247
22149
  return cachedStargate;
22248
22150
  }
22249
22151
  function getSupabasePublic() {
22250
- var _a68;
22152
+ var _a66;
22251
22153
  if (cachedPublic) return cachedPublic;
22252
22154
  const url = getRuntimeEnv("VITE_SUPABASE_URL");
22253
- const anon = (_a68 = getRuntimeEnv("VITE_SUPABASE_ANON_KEY")) != null ? _a68 : getRuntimeEnv("VITE_SUPABASE_PUBLISHABLE_KEY");
22155
+ const anon = (_a66 = getRuntimeEnv("VITE_SUPABASE_ANON_KEY")) != null ? _a66 : getRuntimeEnv("VITE_SUPABASE_PUBLISHABLE_KEY");
22254
22156
  if (!url || !anon) {
22255
22157
  return null;
22256
22158
  }
@@ -22801,11 +22703,11 @@ var ignoreLoopbackUrlOnPublicOrigin = (value) => {
22801
22703
  return isLoopbackUrl(value) ? void 0 : value;
22802
22704
  };
22803
22705
  var getAppsApiBaseUrl = () => {
22804
- var _a68, _b4;
22706
+ var _a66, _b3;
22805
22707
  return normalizeBaseUrl2(
22806
- (_b4 = ignoreLoopbackUrlOnPublicOrigin(
22807
- (_a68 = getRuntimeEnv("VITE_APPS_API_BASE_URL")) != null ? _a68 : getRuntimeEnv("VITE_APPS_API_BASE")
22808
- )) != null ? _b4 : isLocalBrowserOrigin() ? "http://localhost:8787" : "https://api.apps.cupcode.com.br"
22708
+ (_b3 = ignoreLoopbackUrlOnPublicOrigin(
22709
+ (_a66 = getRuntimeEnv("VITE_APPS_API_BASE_URL")) != null ? _a66 : getRuntimeEnv("VITE_APPS_API_BASE")
22710
+ )) != null ? _b3 : isLocalBrowserOrigin() ? "http://localhost:8787" : "https://api.apps.cupcode.com.br"
22809
22711
  );
22810
22712
  };
22811
22713
  var isLocalBrowserOrigin = () => {
@@ -22837,9 +22739,9 @@ var fetchWithTimeout = async (input, init, timeoutMs = AUTH_REQUEST_TIMEOUT_MS)
22837
22739
  }
22838
22740
  };
22839
22741
  var getAccountsConfig = () => {
22840
- var _a68, _b4;
22742
+ var _a66, _b3;
22841
22743
  const baseUrl = normalizeBaseUrl2(
22842
- (_a68 = getRuntimeEnv("VITE_ACCOUNTS_BASE_URL")) != null ? _a68 : "https://accounts.cupcode.com.br"
22744
+ (_a66 = getRuntimeEnv("VITE_ACCOUNTS_BASE_URL")) != null ? _a66 : "https://accounts.cupcode.com.br"
22843
22745
  );
22844
22746
  const clientId = getRuntimeEnv("VITE_ACCOUNTS_CLIENT_ID");
22845
22747
  if (!clientId) {
@@ -22853,7 +22755,7 @@ var getAccountsConfig = () => {
22853
22755
  baseUrl,
22854
22756
  clientId,
22855
22757
  redirectUri,
22856
- scope: (_b4 = getRuntimeEnv("VITE_ACCOUNTS_SCOPE")) != null ? _b4 : "openid profile email",
22758
+ scope: (_b3 = getRuntimeEnv("VITE_ACCOUNTS_SCOPE")) != null ? _b3 : "openid profile email",
22857
22759
  audience: getRuntimeEnv("VITE_ACCOUNTS_AUDIENCE"),
22858
22760
  authUrl: getRuntimeEnv("VITE_ACCOUNTS_AUTH_URL"),
22859
22761
  tokenUrl: runtimeTokenUrl != null ? runtimeTokenUrl : `${getAppsApiBaseUrl()}/api/accounts/oidc-token`,
@@ -22863,7 +22765,7 @@ var getAccountsConfig = () => {
22863
22765
  };
22864
22766
  var cachedDiscovery = null;
22865
22767
  var resolveOidcEndpoints = async (config) => {
22866
- var _a68, _b4, _c, _d, _e, _f;
22768
+ var _a66, _b3, _c, _d, _e, _f;
22867
22769
  if (config.authUrl && config.tokenUrl) {
22868
22770
  return {
22869
22771
  authUrl: config.authUrl,
@@ -22873,8 +22775,8 @@ var resolveOidcEndpoints = async (config) => {
22873
22775
  }
22874
22776
  if (cachedDiscovery) {
22875
22777
  return {
22876
- authUrl: (_a68 = cachedDiscovery.authorization_endpoint) != null ? _a68 : config.authUrl,
22877
- tokenUrl: (_b4 = cachedDiscovery.token_endpoint) != null ? _b4 : config.tokenUrl,
22778
+ authUrl: (_a66 = cachedDiscovery.authorization_endpoint) != null ? _a66 : config.authUrl,
22779
+ tokenUrl: (_b3 = cachedDiscovery.token_endpoint) != null ? _b3 : config.tokenUrl,
22878
22780
  logoutUrl: (_c = cachedDiscovery.end_session_endpoint) != null ? _c : config.logoutUrl
22879
22781
  };
22880
22782
  }
@@ -23054,10 +22956,10 @@ var resolveLocalTelescupRedirectUri = () => {
23054
22956
  return `${window.location.protocol}//localhost:${port}/oidc/callback`;
23055
22957
  };
23056
22958
  var readStorageItem = (key) => {
23057
- var _a68;
22959
+ var _a66;
23058
22960
  if (!canUseWindow()) return null;
23059
22961
  try {
23060
- return (_a68 = window.sessionStorage.getItem(key)) != null ? _a68 : window.localStorage.getItem(key);
22962
+ return (_a66 = window.sessionStorage.getItem(key)) != null ? _a66 : window.localStorage.getItem(key);
23061
22963
  } catch (e) {
23062
22964
  return null;
23063
22965
  }
@@ -23167,16 +23069,16 @@ var getPopupOrigin = () => {
23167
23069
  return window.location.origin;
23168
23070
  };
23169
23071
  var getTelescupAccountsConfig = () => {
23170
- var _a68, _b4, _c, _d, _e, _f, _g, _h, _i, _j, _k;
23072
+ var _a66, _b3, _c, _d, _e, _f, _g, _h, _i, _j, _k;
23171
23073
  const primary = getAccountsConfig();
23172
23074
  const runtimeRedirectUri = ignoreLoopbackUrlOnPublicOrigin2(
23173
- (_a68 = getRuntimeEnv("VITE_TELESCUP_ACCOUNTS_REDIRECT_URI")) != null ? _a68 : getRuntimeEnv("VITE_TELESCUP_OIDC_REDIRECT_URI")
23075
+ (_a66 = getRuntimeEnv("VITE_TELESCUP_ACCOUNTS_REDIRECT_URI")) != null ? _a66 : getRuntimeEnv("VITE_TELESCUP_OIDC_REDIRECT_URI")
23174
23076
  );
23175
23077
  const fallbackRedirectUri = canUseWindow() ? `${window.location.origin}/oidc/callback` : "http://localhost:8080/oidc/callback";
23176
23078
  const redirectUri = isLocalBrowserOrigin2() && runtimeRedirectUri && !runtimeRedirectUri.includes("localhost") ? resolveLocalTelescupRedirectUri() : runtimeRedirectUri != null ? runtimeRedirectUri : fallbackRedirectUri;
23177
23079
  return {
23178
23080
  ...primary,
23179
- baseUrl: (_b4 = getRuntimeEnv("VITE_TELESCUP_ACCOUNTS_BASE_URL")) != null ? _b4 : primary.baseUrl,
23081
+ baseUrl: (_b3 = getRuntimeEnv("VITE_TELESCUP_ACCOUNTS_BASE_URL")) != null ? _b3 : primary.baseUrl,
23180
23082
  clientId: (_d = (_c = getRuntimeEnv("VITE_TELESCUP_ACCOUNTS_CLIENT_ID")) != null ? _c : getRuntimeEnv("VITE_TELESCUP_OIDC_CLIENT_ID")) != null ? _d : "telescup-local",
23181
23083
  redirectUri,
23182
23084
  scope: (_f = (_e = getRuntimeEnv("VITE_TELESCUP_ACCOUNTS_SCOPE")) != null ? _e : getRuntimeEnv("VITE_TELESCUP_OIDC_SCOPE")) != null ? _f : "openid profile email offline_access",
@@ -23188,12 +23090,12 @@ var getTelescupAccountsConfig = () => {
23188
23090
  };
23189
23091
  };
23190
23092
  var buildTokenBundle = (tokens, config, previous) => {
23191
- var _a68, _b4, _c, _d, _e, _f;
23192
- const idToken = ((_a68 = tokens.id_token) == null ? void 0 : _a68.trim()) || (previous == null ? void 0 : previous.idToken) || "";
23093
+ var _a66, _b3, _c, _d, _e, _f;
23094
+ const idToken = ((_a66 = tokens.id_token) == null ? void 0 : _a66.trim()) || (previous == null ? void 0 : previous.idToken) || "";
23193
23095
  if (!idToken) {
23194
23096
  throw new Error("Token ID do Telescup n\xE3o retornado pelo Accounts.");
23195
23097
  }
23196
- const expiresAt2 = (_d = (_c = (_b4 = getTokenExpiryMs(idToken)) != null ? _b4 : getTokenExpiryMs(tokens.access_token)) != null ? _c : previous == null ? void 0 : previous.expiresAt) != null ? _d : Date.now() + 55 * 60 * 1e3;
23098
+ const expiresAt2 = (_d = (_c = (_b3 = getTokenExpiryMs(idToken)) != null ? _b3 : getTokenExpiryMs(tokens.access_token)) != null ? _c : previous == null ? void 0 : previous.expiresAt) != null ? _d : Date.now() + 55 * 60 * 1e3;
23197
23099
  return {
23198
23100
  idToken,
23199
23101
  accessToken: ((_e = tokens.access_token) == null ? void 0 : _e.trim()) || (previous == null ? void 0 : previous.accessToken),
@@ -23236,10 +23138,10 @@ var centerPopupFeatures = () => {
23236
23138
  return `popup,width=${width},height=${height},left=${left},top=${top},resizable=yes,scrollbars=yes`;
23237
23139
  };
23238
23140
  var notifyOpener = (result) => {
23239
- var _a68;
23141
+ var _a66;
23240
23142
  if (!canUseWindow()) return;
23241
23143
  try {
23242
- (_a68 = window.opener) == null ? void 0 : _a68.postMessage(result, getPopupOrigin());
23144
+ (_a66 = window.opener) == null ? void 0 : _a66.postMessage(result, getPopupOrigin());
23243
23145
  } catch (e) {
23244
23146
  }
23245
23147
  };
@@ -23348,7 +23250,7 @@ var ensureTelescupOidcToken = async () => {
23348
23250
  return pendingTokenPromise;
23349
23251
  };
23350
23252
  var completeTelescupOidcCallback = async () => {
23351
- var _a68;
23253
+ var _a66;
23352
23254
  if (!canUseWindow()) {
23353
23255
  return { ok: false, error: "Callback do Telescup indispon\xEDvel fora do navegador." };
23354
23256
  }
@@ -23377,7 +23279,7 @@ var completeTelescupOidcCallback = async () => {
23377
23279
  throw new Error("Token endpoint do Telescup n\xE3o encontrado.");
23378
23280
  }
23379
23281
  const tokens = await exchangeCodeForToken(config, tokenUrl, code, flow.verifier);
23380
- const nonce = String(((_a68 = decodeJwt(tokens.id_token)) == null ? void 0 : _a68.nonce) || "").trim();
23282
+ const nonce = String(((_a66 = decodeJwt(tokens.id_token)) == null ? void 0 : _a66.nonce) || "").trim();
23381
23283
  if (!nonce || nonce !== flow.nonce) {
23382
23284
  throw new Error("Nonce inv\xE1lido no callback do Telescup.");
23383
23285
  }
@@ -23509,20 +23411,23 @@ var CHAT_LOGS_CREATED_AT_COLUMN = ((_a49 = getRuntimeEnv("VITE_CHAT_LOGS_CREATED
23509
23411
  var CHAT_MESSAGE_HISTORY_LIMIT = 200;
23510
23412
  var CHAT_EDIT_WINDOW_MINUTES2 = 15;
23511
23413
  var CHAT_DELETED_PLACEHOLDER_TEXT2 = "Mensagem deletada";
23512
- var _a50, _b2;
23513
- var APPS_API_BASE_URL = ((_b2 = (_a50 = getRuntimeEnv("VITE_APPS_API_BASE_URL")) != null ? _a50 : getRuntimeEnv("VITE_APPS_API_BASE")) != null ? _b2 : "http://localhost:8787").trim().replace(/\/+$/, "");
23514
- var _a51;
23515
- var TELESCUP_BASE_URL = (_a51 = getRuntimeEnv("VITE_TELESCUP_BASE_URL")) == null ? void 0 : _a51.trim();
23516
- var TELESCUP_LOCAL_API_BASE_URL = `${APPS_API_BASE_URL}/api/telescup`;
23414
+ var resolveAppsApiBaseUrl = () => {
23415
+ var _a66, _b3;
23416
+ return ((_b3 = (_a66 = getRuntimeEnv("VITE_APPS_API_BASE_URL")) != null ? _a66 : getRuntimeEnv("VITE_APPS_API_BASE")) != null ? _b3 : "http://localhost:8787").trim().replace(/\/+$/, "");
23417
+ };
23418
+ var resolveTelescupBaseUrl = () => {
23419
+ var _a66;
23420
+ return ((_a66 = getRuntimeEnv("VITE_TELESCUP_BASE_URL")) == null ? void 0 : _a66.trim()) || `${resolveAppsApiBaseUrl()}/api/telescup`;
23421
+ };
23517
23422
  var ACCESS_TOKEN_STORAGE_KEY = "cc_access_token";
23423
+ var _a50;
23424
+ var ACCOUNTS_BASE_URL2 = ((_a50 = getRuntimeEnv("VITE_ACCOUNTS_BASE_URL")) != null ? _a50 : "https://accounts.cupcode.com.br").trim().replace(/\/+$/, "");
23425
+ var _a51;
23426
+ var MC_BASE_URL2 = ((_a51 = getRuntimeEnv("VITE_MC_BASE_URL")) != null ? _a51 : "https://mc.cupcode.com.br").trim().replace(/\/+$/, "");
23518
23427
  var _a52;
23519
- var ACCOUNTS_BASE_URL2 = ((_a52 = getRuntimeEnv("VITE_ACCOUNTS_BASE_URL")) != null ? _a52 : "https://accounts.cupcode.com.br").trim().replace(/\/+$/, "");
23428
+ var ACCOUNTS_LANGUAGE_ENDPOINT = (_a52 = getRuntimeEnv("VITE_ACCOUNTS_LANGUAGE_ENDPOINT")) == null ? void 0 : _a52.trim();
23520
23429
  var _a53;
23521
- var MC_BASE_URL2 = ((_a53 = getRuntimeEnv("VITE_MC_BASE_URL")) != null ? _a53 : "https://mc.cupcode.com.br").trim().replace(/\/+$/, "");
23522
- var _a54;
23523
- var ACCOUNTS_LANGUAGE_ENDPOINT = (_a54 = getRuntimeEnv("VITE_ACCOUNTS_LANGUAGE_ENDPOINT")) == null ? void 0 : _a54.trim();
23524
- var _a55;
23525
- var ACCOUNTS_ACTIVITY_ENDPOINT = (_a55 = getRuntimeEnv("VITE_ACCOUNTS_ACTIVITY_ENDPOINT")) == null ? void 0 : _a55.trim();
23430
+ var ACCOUNTS_ACTIVITY_ENDPOINT = (_a53 = getRuntimeEnv("VITE_ACCOUNTS_ACTIVITY_ENDPOINT")) == null ? void 0 : _a53.trim();
23526
23431
  var PRESENCE_STATUS_VALUES = [
23527
23432
  "online",
23528
23433
  "away",
@@ -23736,10 +23641,10 @@ var resolvePresenceStatusLabel = (snapshot, effectiveStatus, now = Date.now()) =
23736
23641
  return PRESENCE_STATUS_LABELS[effectiveStatus];
23737
23642
  };
23738
23643
  var readPresenceSnapshotFromRecord = (row) => {
23739
- var _a68, _b4, _c, _d;
23644
+ var _a66, _b3, _c, _d;
23740
23645
  if (!row) return null;
23741
- const status = normalizePresenceStatus((_a68 = row[USER_PRESENCE_STATUS_COLUMN]) != null ? _a68 : row.status);
23742
- const source = normalizePresenceSource((_b4 = row[USER_PRESENCE_SOURCE_COLUMN]) != null ? _b4 : row.status_source);
23646
+ const status = normalizePresenceStatus((_a66 = row[USER_PRESENCE_STATUS_COLUMN]) != null ? _a66 : row.status);
23647
+ const source = normalizePresenceSource((_b3 = row[USER_PRESENCE_SOURCE_COLUMN]) != null ? _b3 : row.status_source);
23743
23648
  const lastActiveAtMs = toTimestampMs((_d = (_c = row[USER_PRESENCE_LAST_ACTIVE_COLUMN]) != null ? _c : row.last_active_at) != null ? _d : row.updated_at);
23744
23649
  return { status, source, lastActiveAtMs };
23745
23650
  };
@@ -23772,25 +23677,25 @@ var resolveCurrentUserId = (user) => {
23772
23677
  return null;
23773
23678
  };
23774
23679
  var resolveUserIdFromClaims = (claims) => {
23775
- var _a68, _b4, _c, _d, _e;
23776
- return (_e = (_d = (_c = (_b4 = (_a68 = toStringOrUndefined(claims.sub)) != null ? _a68 : toStringOrUndefined(claims.user_id)) != null ? _b4 : toStringOrUndefined(claims.userId)) != null ? _c : toStringOrUndefined(claims.uid)) != null ? _d : toStringOrUndefined(claims.id)) != null ? _e : toStringOrUndefined(claims["https://cupcode.com/user_id"]);
23680
+ var _a66, _b3, _c, _d, _e;
23681
+ return (_e = (_d = (_c = (_b3 = (_a66 = toStringOrUndefined(claims.sub)) != null ? _a66 : toStringOrUndefined(claims.user_id)) != null ? _b3 : toStringOrUndefined(claims.userId)) != null ? _c : toStringOrUndefined(claims.uid)) != null ? _d : toStringOrUndefined(claims.id)) != null ? _e : toStringOrUndefined(claims["https://cupcode.com/user_id"]);
23777
23682
  };
23778
23683
  var resolveEmailFromClaims = (claims) => {
23779
- var _a68, _b4;
23780
- const candidate = (_b4 = (_a68 = toStringOrUndefined(claims.email)) != null ? _a68 : toStringOrUndefined(claims["https://cupcode.com/email"])) != null ? _b4 : toStringOrUndefined(claims.preferred_username);
23684
+ var _a66, _b3;
23685
+ const candidate = (_b3 = (_a66 = toStringOrUndefined(claims.email)) != null ? _a66 : toStringOrUndefined(claims["https://cupcode.com/email"])) != null ? _b3 : toStringOrUndefined(claims.preferred_username);
23781
23686
  if (!candidate || !candidate.includes("@")) return void 0;
23782
23687
  return candidate.toLowerCase();
23783
23688
  };
23784
23689
  var normalizeTenantId = (value) => {
23785
- var _a68;
23786
- const normalized = (_a68 = toStringOrUndefined(value)) == null ? void 0 : _a68.toLowerCase();
23690
+ var _a66;
23691
+ const normalized = (_a66 = toStringOrUndefined(value)) == null ? void 0 : _a66.toLowerCase();
23787
23692
  if (!normalized) return void 0;
23788
23693
  return normalized.replace(/^@/, "");
23789
23694
  };
23790
23695
  var resolveTenantIdFromClaims = (claims) => {
23791
- var _a68, _b4, _c, _d, _e, _f, _g, _h, _i, _j;
23696
+ var _a66, _b3, _c, _d, _e, _f, _g, _h, _i, _j;
23792
23697
  return normalizeTenantId(
23793
- (_j = (_i = (_h = (_g = (_f = (_e = (_d = (_c = (_b4 = (_a68 = toStringOrUndefined(claims.tenant_id)) != null ? _a68 : toStringOrUndefined(claims.tenantId)) != null ? _b4 : toStringOrUndefined(claims.tenant_slug)) != null ? _c : toStringOrUndefined(claims.tenantSlug)) != null ? _d : toStringOrUndefined(claims.company_slug)) != null ? _e : toStringOrUndefined(claims.companySlug)) != null ? _f : toStringOrUndefined(claims.company)) != null ? _g : toStringOrUndefined(claims.org_slug)) != null ? _h : toStringOrUndefined(claims.orgSlug)) != null ? _i : toStringOrUndefined(claims["https://cupcode.com/tenant_id"])) != null ? _j : toStringOrUndefined(claims["https://cupcode.com/tenant_slug"])
23698
+ (_j = (_i = (_h = (_g = (_f = (_e = (_d = (_c = (_b3 = (_a66 = toStringOrUndefined(claims.tenant_id)) != null ? _a66 : toStringOrUndefined(claims.tenantId)) != null ? _b3 : toStringOrUndefined(claims.tenant_slug)) != null ? _c : toStringOrUndefined(claims.tenantSlug)) != null ? _d : toStringOrUndefined(claims.company_slug)) != null ? _e : toStringOrUndefined(claims.companySlug)) != null ? _f : toStringOrUndefined(claims.company)) != null ? _g : toStringOrUndefined(claims.org_slug)) != null ? _h : toStringOrUndefined(claims.orgSlug)) != null ? _i : toStringOrUndefined(claims["https://cupcode.com/tenant_id"])) != null ? _j : toStringOrUndefined(claims["https://cupcode.com/tenant_slug"])
23794
23699
  );
23795
23700
  };
23796
23701
  var formatMessageTime = (rawTimestamp) => {
@@ -23803,8 +23708,8 @@ var resolveChatAvatarUrl = (value) => {
23803
23708
  return resolveTelescupImageURL(value, { width: 72, height: 72, fit: "cover", format: "avif", quality: 70 });
23804
23709
  };
23805
23710
  var resolveAvatarPreviewUrl = (asset, fallback) => {
23806
- var _a68, _b4, _c;
23807
- return (_c = (_b4 = (_a68 = resolveTelescupImageURL(asset == null ? void 0 : asset.thumb_url, { width: 300, height: 300, fit: "cover", format: "avif", quality: 80 })) != null ? _a68 : resolveTelescupImageURL(asset == null ? void 0 : asset.preview_url, { width: 300, height: 300, fit: "cover", format: "avif", quality: 80 })) != null ? _b4 : resolveTelescupImageURL(asset == null ? void 0 : asset.url, { width: 300, height: 300, fit: "cover", format: "avif", quality: 80 })) != null ? _c : resolveTelescupImageURL(fallback, { width: 300, height: 300, fit: "cover", format: "avif", quality: 80 });
23711
+ var _a66, _b3, _c;
23712
+ return (_c = (_b3 = (_a66 = resolveTelescupImageURL(asset == null ? void 0 : asset.thumb_url, { width: 300, height: 300, fit: "cover", format: "avif", quality: 80 })) != null ? _a66 : resolveTelescupImageURL(asset == null ? void 0 : asset.preview_url, { width: 300, height: 300, fit: "cover", format: "avif", quality: 80 })) != null ? _b3 : resolveTelescupImageURL(asset == null ? void 0 : asset.url, { width: 300, height: 300, fit: "cover", format: "avif", quality: 80 })) != null ? _c : resolveTelescupImageURL(fallback, { width: 300, height: 300, fit: "cover", format: "avif", quality: 80 });
23808
23713
  };
23809
23714
  var isGenericRecord = (value) => typeof value === "object" && value !== null;
23810
23715
  var buildExternalUrl = (baseUrl, target) => {
@@ -23858,8 +23763,8 @@ var parseRecentActivityItems = (payload) => {
23858
23763
  return [];
23859
23764
  };
23860
23765
  return toRows(payload).map((item, index) => {
23861
- var _a68, _b4, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
23862
- const id = (_b4 = (_a68 = toStringOrUndefined(item.id)) != null ? _a68 : toStringOrUndefined(item.event_id)) != null ? _b4 : `accounts-activity-${index}`;
23766
+ var _a66, _b3, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
23767
+ const id = (_b3 = (_a66 = toStringOrUndefined(item.id)) != null ? _a66 : toStringOrUndefined(item.event_id)) != null ? _b3 : `accounts-activity-${index}`;
23863
23768
  const title = (_e = (_d = (_c = toStringOrUndefined(item.title)) != null ? _c : toStringOrUndefined(item.action)) != null ? _d : toStringOrUndefined(item.event)) != null ? _e : toStringOrUndefined(item.type);
23864
23769
  if (!title) return null;
23865
23770
  const description = (_h = (_g = (_f = toStringOrUndefined(item.description)) != null ? _f : toStringOrUndefined(item.details)) != null ? _g : toStringOrUndefined(item.message)) != null ? _h : toStringOrUndefined(item.summary);
@@ -23942,9 +23847,9 @@ var dedupeAndSortReactions = (reactions) => {
23942
23847
  });
23943
23848
  };
23944
23849
  var getErrorText = (error) => {
23945
- var _a68, _b4, _c;
23850
+ var _a66, _b3, _c;
23946
23851
  const typed = error;
23947
- return `${(_a68 = typed == null ? void 0 : typed.message) != null ? _a68 : ""} ${(_b4 = typed == null ? void 0 : typed.details) != null ? _b4 : ""} ${(_c = typed == null ? void 0 : typed.hint) != null ? _c : ""}`.toLowerCase();
23852
+ return `${(_a66 = typed == null ? void 0 : typed.message) != null ? _a66 : ""} ${(_b3 = typed == null ? void 0 : typed.details) != null ? _b3 : ""} ${(_c = typed == null ? void 0 : typed.hint) != null ? _c : ""}`.toLowerCase();
23948
23853
  };
23949
23854
  var isMissingColumnError = (error, column) => {
23950
23855
  const normalized = getErrorText(error);
@@ -23970,13 +23875,13 @@ var isRecoverableLookupError = (error, relationName) => {
23970
23875
  return normalized.includes("schema cache") || normalized.includes("permission denied") || normalized.includes("does not exist") || normalized.includes("could not find");
23971
23876
  };
23972
23877
  var toChatMessage = (row, currentUserId) => {
23973
- var _a68, _b4, _c, _d, _e, _f;
23974
- const id = (_a68 = toStringOrUndefined(row[CHAT_MESSAGES_ID_COLUMN])) != null ? _a68 : `${toStringOrUndefined(row[CHAT_MESSAGES_SENDER_COLUMN])}-${toStringOrUndefined(row[CHAT_MESSAGES_RECIPIENT_COLUMN])}-${toStringOrUndefined(row[CHAT_MESSAGES_CREATED_AT_COLUMN])}`;
23878
+ var _a66, _b3, _c, _d, _e, _f;
23879
+ const id = (_a66 = toStringOrUndefined(row[CHAT_MESSAGES_ID_COLUMN])) != null ? _a66 : `${toStringOrUndefined(row[CHAT_MESSAGES_SENDER_COLUMN])}-${toStringOrUndefined(row[CHAT_MESSAGES_RECIPIENT_COLUMN])}-${toStringOrUndefined(row[CHAT_MESSAGES_CREATED_AT_COLUMN])}`;
23975
23880
  const senderId = toStringOrUndefined(row[CHAT_MESSAGES_SENDER_COLUMN]);
23976
23881
  const recipientId = toStringOrUndefined(row[CHAT_MESSAGES_RECIPIENT_COLUMN]);
23977
23882
  const text = toStringOrUndefined(row[CHAT_MESSAGES_TEXT_COLUMN]);
23978
23883
  const createdAt = toStringOrUndefined(row[CHAT_MESSAGES_CREATED_AT_COLUMN]);
23979
- const editedAt = (_b4 = toStringOrUndefined(row[CHAT_MESSAGES_EDITED_AT_COLUMN])) != null ? _b4 : null;
23884
+ const editedAt = (_b3 = toStringOrUndefined(row[CHAT_MESSAGES_EDITED_AT_COLUMN])) != null ? _b3 : null;
23980
23885
  const readAt = (_c = toStringOrUndefined(row[CHAT_MESSAGES_READ_AT_COLUMN])) != null ? _c : null;
23981
23886
  const replyToMessageId = (_d = toStringOrUndefined(row[CHAT_MESSAGES_REPLY_TO_COLUMN])) != null ? _d : null;
23982
23887
  const deletedAt = (_e = toStringOrUndefined(row[CHAT_MESSAGES_DELETED_AT_COLUMN])) != null ? _e : null;
@@ -24011,13 +23916,13 @@ var toChatReaction = (row) => {
24011
23916
  return { id, messageId, userId, emoji, createdAt };
24012
23917
  };
24013
23918
  var toChatMessageLog = (row, messagesById) => {
24014
- var _a68, _b4;
23919
+ var _a66, _b3;
24015
23920
  const id = toStringOrUndefined(row[CHAT_LOGS_ID_COLUMN]);
24016
23921
  const messageId = toStringOrUndefined(row[CHAT_LOGS_MESSAGE_ID_COLUMN]);
24017
23922
  const actorId = toStringOrUndefined(row[CHAT_LOGS_ACTOR_ID_COLUMN]);
24018
23923
  const action = toStringOrUndefined(row[CHAT_LOGS_ACTION_COLUMN]);
24019
- const previousText = (_a68 = toStringOrUndefined(row[CHAT_LOGS_PREVIOUS_TEXT_COLUMN])) != null ? _a68 : null;
24020
- const nextText = (_b4 = toStringOrUndefined(row[CHAT_LOGS_NEXT_TEXT_COLUMN])) != null ? _b4 : null;
23924
+ const previousText = (_a66 = toStringOrUndefined(row[CHAT_LOGS_PREVIOUS_TEXT_COLUMN])) != null ? _a66 : null;
23925
+ const nextText = (_b3 = toStringOrUndefined(row[CHAT_LOGS_NEXT_TEXT_COLUMN])) != null ? _b3 : null;
24021
23926
  const createdAt = toStringOrUndefined(row[CHAT_LOGS_CREATED_AT_COLUMN]);
24022
23927
  if (!id || !messageId || !action || action !== "edit" && action !== "delete") return null;
24023
23928
  const relatedMessage = messagesById.get(messageId);
@@ -24063,7 +23968,7 @@ var MainNavbar = ({
24063
23968
  getAccessToken,
24064
23969
  appVersion
24065
23970
  }) => {
24066
- var _a68, _b4, _c;
23971
+ var _a66, _b3, _c;
24067
23972
  const [chatUsers, setChatUsers] = (0, import_react19.useState)([]);
24068
23973
  const [chatMessages, setChatMessages] = (0, import_react19.useState)([]);
24069
23974
  const [chatMessageLogs, setChatMessageLogs] = (0, import_react19.useState)([]);
@@ -24096,21 +24001,21 @@ var MainNavbar = ({
24096
24001
  return "/";
24097
24002
  }, [pathname]);
24098
24003
  const currentUserId = (0, import_react19.useMemo)(() => {
24099
- var _a69;
24100
- return (_a69 = resolveCurrentUserId(authUser)) != null ? _a69 : tokenDerivedUserId;
24004
+ var _a67;
24005
+ return (_a67 = resolveCurrentUserId(authUser)) != null ? _a67 : tokenDerivedUserId;
24101
24006
  }, [authUser, tokenDerivedUserId]);
24102
24007
  const authEmail = (0, import_react19.useMemo)(
24103
24008
  () => {
24104
- var _a69, _b5;
24105
- return (_b5 = (_a69 = toStringOrUndefined(authUser == null ? void 0 : authUser.email)) == null ? void 0 : _a69.toLowerCase()) != null ? _b5 : tokenDerivedEmail;
24009
+ var _a67, _b4;
24010
+ return (_b4 = (_a67 = toStringOrUndefined(authUser == null ? void 0 : authUser.email)) == null ? void 0 : _a67.toLowerCase()) != null ? _b4 : tokenDerivedEmail;
24106
24011
  },
24107
24012
  [authUser == null ? void 0 : authUser.email, tokenDerivedEmail]
24108
24013
  );
24109
24014
  const resolvedTenantId = (0, import_react19.useMemo)(
24110
24015
  () => {
24111
- var _a69, _b5, _c2, _d, _e, _f;
24016
+ var _a67, _b4, _c2, _d, _e, _f;
24112
24017
  return normalizeTenantId(
24113
- (_f = (_e = (_d = (_c2 = (_b5 = (_a69 = authUser == null ? void 0 : authUser.tenantId) != null ? _a69 : authUser == null ? void 0 : authUser.tenantSlug) != null ? _b5 : authUser == null ? void 0 : authUser.tenant_id) != null ? _c2 : authUser == null ? void 0 : authUser.companySlug) != null ? _d : authUser == null ? void 0 : authUser.company) != null ? _e : authUser == null ? void 0 : authUser.orgSlug) != null ? _f : tokenDerivedTenantId
24018
+ (_f = (_e = (_d = (_c2 = (_b4 = (_a67 = authUser == null ? void 0 : authUser.tenantId) != null ? _a67 : authUser == null ? void 0 : authUser.tenantSlug) != null ? _b4 : authUser == null ? void 0 : authUser.tenant_id) != null ? _c2 : authUser == null ? void 0 : authUser.companySlug) != null ? _d : authUser == null ? void 0 : authUser.company) != null ? _e : authUser == null ? void 0 : authUser.orgSlug) != null ? _f : tokenDerivedTenantId
24114
24019
  );
24115
24020
  },
24116
24021
  [
@@ -24125,14 +24030,14 @@ var MainNavbar = ({
24125
24030
  );
24126
24031
  const isCupcodeTenant = resolvedTenantId === "cupcode-admin";
24127
24032
  const isChatSuperAdmin = (0, import_react19.useMemo)(() => {
24128
- var _a69, _b5;
24129
- const roleTokens = `${(_a69 = authUser == null ? void 0 : authUser.role) != null ? _a69 : ""} ${(_b5 = authUser == null ? void 0 : authUser.jobTitle) != null ? _b5 : ""}`.toLowerCase();
24033
+ var _a67, _b4;
24034
+ const roleTokens = `${(_a67 = authUser == null ? void 0 : authUser.role) != null ? _a67 : ""} ${(_b4 = authUser == null ? void 0 : authUser.jobTitle) != null ? _b4 : ""}`.toLowerCase();
24130
24035
  return roleTokens.includes("superadmin") || roleTokens.includes("super admin");
24131
24036
  }, [authUser == null ? void 0 : authUser.jobTitle, authUser == null ? void 0 : authUser.role]);
24132
24037
  const resolvedTelescupBaseUrl = (0, import_react19.useMemo)(() => {
24133
- return TELESCUP_BASE_URL || TELESCUP_LOCAL_API_BASE_URL;
24038
+ return resolveTelescupBaseUrl();
24134
24039
  }, []);
24135
- const resolvedProfileAvatarUrl = (_a68 = resolveAvatarPreviewUrl({ url: persistedProfileAvatarValue != null ? persistedProfileAvatarValue : authUser == null ? void 0 : authUser.picture })) != null ? _a68 : void 0;
24040
+ const resolvedProfileAvatarUrl = (_a66 = resolveAvatarPreviewUrl({ url: persistedProfileAvatarValue != null ? persistedProfileAvatarValue : authUser == null ? void 0 : authUser.picture })) != null ? _a66 : void 0;
24136
24041
  const effectiveCurrentUserId = resolvedSenderId != null ? resolvedSenderId : currentUserId;
24137
24042
  const hasStoredAccessToken = (() => {
24138
24043
  if (typeof window === "undefined") return false;
@@ -24171,7 +24076,7 @@ var MainNavbar = ({
24171
24076
  }
24172
24077
  let canceled = false;
24173
24078
  const resolveIdentityFromToken = async () => {
24174
- var _a69, _b5;
24079
+ var _a67, _b4;
24175
24080
  try {
24176
24081
  let token = null;
24177
24082
  if (typeof window !== "undefined") {
@@ -24192,9 +24097,9 @@ var MainNavbar = ({
24192
24097
  }
24193
24098
  return;
24194
24099
  }
24195
- const claims = (_a69 = decodeJwt(token)) != null ? _a69 : {};
24100
+ const claims = (_a67 = decodeJwt(token)) != null ? _a67 : {};
24196
24101
  if (canceled) return;
24197
- setTokenDerivedUserId((_b5 = resolveUserIdFromClaims(claims)) != null ? _b5 : null);
24102
+ setTokenDerivedUserId((_b4 = resolveUserIdFromClaims(claims)) != null ? _b4 : null);
24198
24103
  setTokenDerivedEmail(resolveEmailFromClaims(claims));
24199
24104
  setTokenDerivedTenantId(resolveTenantIdFromClaims(claims));
24200
24105
  } catch (error) {
@@ -24238,7 +24143,7 @@ var MainNavbar = ({
24238
24143
  );
24239
24144
  const warnings = [];
24240
24145
  const runLookup = async (kind, value, columns) => {
24241
- var _a69, _b5, _c2;
24146
+ var _a67, _b4, _c2;
24242
24147
  for (const tableName of CHAT_USERS_LOOKUP_TABLES) {
24243
24148
  for (const columnName of columns) {
24244
24149
  if (!columnName) continue;
@@ -24247,10 +24152,10 @@ var MainNavbar = ({
24247
24152
  const lookupError = response.error;
24248
24153
  if (lookupError) {
24249
24154
  if (isRecoverableLookupError(lookupError, tableName)) {
24250
- warnings.push(`${tableName}.${columnName}: ${(_a69 = lookupError.message) != null ? _a69 : "falha de lookup"}`);
24155
+ warnings.push(`${tableName}.${columnName}: ${(_a67 = lookupError.message) != null ? _a67 : "falha de lookup"}`);
24251
24156
  continue;
24252
24157
  }
24253
- warnings.push(`${tableName}.${columnName}: ${(_b5 = lookupError.message) != null ? _b5 : "falha de lookup"}`);
24158
+ warnings.push(`${tableName}.${columnName}: ${(_b4 = lookupError.message) != null ? _b4 : "falha de lookup"}`);
24254
24159
  continue;
24255
24160
  }
24256
24161
  const row2 = (_c2 = response.data) == null ? void 0 : _c2[0];
@@ -24299,7 +24204,7 @@ var MainNavbar = ({
24299
24204
  return sessionStorage.getItem(ACCESS_TOKEN_STORAGE_KEY);
24300
24205
  };
24301
24206
  const loadAccountsContext = async () => {
24302
- var _a69, _b5, _c2, _d, _e, _f, _g;
24207
+ var _a67, _b4, _c2, _d, _e, _f, _g;
24303
24208
  setIsAccountsActivityLoading(true);
24304
24209
  try {
24305
24210
  const token = await resolveAccountsToken();
@@ -24309,9 +24214,9 @@ var MainNavbar = ({
24309
24214
  }
24310
24215
  return;
24311
24216
  }
24312
- const claims = (_a69 = decodeJwt(token)) != null ? _a69 : {};
24217
+ const claims = (_a67 = decodeJwt(token)) != null ? _a67 : {};
24313
24218
  const languageFromToken = normalizeMenuLanguage(
24314
- (_d = (_c2 = (_b5 = claims.locale) != null ? _b5 : claims.lang) != null ? _c2 : claims.language) != null ? _d : claims["https://cupcode.com/locale"]
24219
+ (_d = (_c2 = (_b4 = claims.locale) != null ? _b4 : claims.lang) != null ? _c2 : claims.language) != null ? _d : claims["https://cupcode.com/locale"]
24315
24220
  );
24316
24221
  if (!canceled) {
24317
24222
  setAccountsLanguage(languageFromToken);
@@ -24400,11 +24305,11 @@ var MainNavbar = ({
24400
24305
  }
24401
24306
  let canceled = false;
24402
24307
  const loadChatData = async () => {
24403
- var _a69, _b5, _c2, _d, _e, _f, _g, _h, _i;
24308
+ var _a67, _b4, _c2, _d, _e, _f, _g, _h, _i;
24404
24309
  setIsChatLoading(true);
24405
24310
  setChatError(null);
24406
24311
  const fetchFirstAvailableTable = async (tableNames) => {
24407
- var _a70;
24312
+ var _a68;
24408
24313
  let lastError = null;
24409
24314
  for (const tableName of tableNames) {
24410
24315
  const response = await supabase.from(tableName).select("*");
@@ -24426,7 +24331,7 @@ var MainNavbar = ({
24426
24331
  }
24427
24332
  }
24428
24333
  return {
24429
- tableName: (_a70 = tableNames[0]) != null ? _a70 : null,
24334
+ tableName: (_a68 = tableNames[0]) != null ? _a68 : null,
24430
24335
  data: null,
24431
24336
  error: lastError
24432
24337
  };
@@ -24540,7 +24445,7 @@ var MainNavbar = ({
24540
24445
  console.warn("[chat] Falha ao carregar presen\xE7a:", presenceResponse.error.message);
24541
24446
  }
24542
24447
  } else {
24543
- (_a69 = presenceResponse.data) == null ? void 0 : _a69.forEach((row) => {
24448
+ (_a67 = presenceResponse.data) == null ? void 0 : _a67.forEach((row) => {
24544
24449
  const userId = readFirstRecordString(row, [USER_PRESENCE_USER_ID_COLUMN, "user_id", "id"]);
24545
24450
  if (!userId) return;
24546
24451
  const snapshot = readPresenceSnapshotFromRecord(row);
@@ -24559,7 +24464,7 @@ var MainNavbar = ({
24559
24464
  console.warn("[chat] Falha ao carregar profiles para enriquecimento:", profilesResponse.error.message);
24560
24465
  }
24561
24466
  } else {
24562
- (_b5 = profilesResponse.data) == null ? void 0 : _b5.forEach((row) => {
24467
+ (_b4 = profilesResponse.data) == null ? void 0 : _b4.forEach((row) => {
24563
24468
  const id = readFirstRecordString(row, [...CHAT_USERS_LOOKUP_ID_COLUMNS, "id", "user_id"]);
24564
24469
  const email = readFirstRecordString(row, [...CHAT_USERS_LOOKUP_EMAIL_COLUMNS, "email"]);
24565
24470
  if (id) profileById.set(id, row);
@@ -24587,13 +24492,13 @@ var MainNavbar = ({
24587
24492
  }
24588
24493
  } else {
24589
24494
  (_e = usersResponse.data) == null ? void 0 : _e.forEach((row) => {
24590
- var _a70, _b6, _c3, _d2, _e2, _f2, _g2, _h2, _i2;
24495
+ var _a68, _b5, _c3, _d2, _e2, _f2, _g2, _h2, _i2;
24591
24496
  const id = readFirstRecordString(row, [...CHAT_USERS_LOOKUP_ID_COLUMNS, "id", "user_id"]);
24592
24497
  if (!id || id === effectiveCurrentUserId) return;
24593
24498
  const rowEmail = readFirstRecordString(row, [...CHAT_USERS_LOOKUP_EMAIL_COLUMNS, "email"]);
24594
- const profile = (_a70 = profileById.get(id)) != null ? _a70 : rowEmail ? profileByEmail.get(rowEmail.toLowerCase()) : void 0;
24499
+ const profile = (_a68 = profileById.get(id)) != null ? _a68 : rowEmail ? profileByEmail.get(rowEmail.toLowerCase()) : void 0;
24595
24500
  const email = rowEmail != null ? rowEmail : readFirstRecordString(profile, [CHAT_USERS_UPDATE_EMAIL_COLUMN, CHAT_USERS_EMAIL_COLUMN, "email"]);
24596
- const rawUsername = (_b6 = readFirstRecordString(row, [CHAT_USERS_USERNAME_COLUMN, "username", "user_name"])) != null ? _b6 : readFirstRecordString(profile, [CHAT_USERS_USERNAME_COLUMN, "username", "user_name"]);
24501
+ const rawUsername = (_b5 = readFirstRecordString(row, [CHAT_USERS_USERNAME_COLUMN, "username", "user_name"])) != null ? _b5 : readFirstRecordString(profile, [CHAT_USERS_USERNAME_COLUMN, "username", "user_name"]);
24597
24502
  const username = buildHandle2(rawUsername, email);
24598
24503
  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"]);
24599
24504
  const name = resolveReadableUserLabel(rawName, rawUsername, email, id);
@@ -24613,7 +24518,7 @@ var MainNavbar = ({
24613
24518
  });
24614
24519
  }
24615
24520
  profileById.forEach((profile, id) => {
24616
- var _a70, _b6, _c3;
24521
+ var _a68, _b5, _c3;
24617
24522
  if (!id || id === effectiveCurrentUserId || usersMap.has(id)) return;
24618
24523
  const email = readFirstRecordString(profile, [CHAT_USERS_UPDATE_EMAIL_COLUMN, CHAT_USERS_EMAIL_COLUMN, "email"]);
24619
24524
  const rawUsername = readFirstRecordString(profile, [CHAT_USERS_USERNAME_COLUMN, "username", "user_name"]);
@@ -24627,7 +24532,7 @@ var MainNavbar = ({
24627
24532
  "avatar"
24628
24533
  ]);
24629
24534
  const roleLabel = readFirstRecordString(profile, [CHAT_USERS_ROLE_COLUMN, "job_title", "role"]);
24630
- const resolvedStatus = (_b6 = (_a70 = presenceMap.get(id)) != null ? _a70 : readPresenceStatusFromRecord(profile)) != null ? _b6 : "offline";
24535
+ const resolvedStatus = (_b5 = (_a68 = presenceMap.get(id)) != null ? _a68 : readPresenceStatusFromRecord(profile)) != null ? _b5 : "offline";
24631
24536
  usersMap.set(id, {
24632
24537
  id,
24633
24538
  name: resolveReadableUserLabel(rawName, rawUsername, email, id),
@@ -24640,7 +24545,7 @@ var MainNavbar = ({
24640
24545
  });
24641
24546
  });
24642
24547
  presenceMap.forEach((statusValue, id) => {
24643
- var _a70;
24548
+ var _a68;
24644
24549
  if (id === effectiveCurrentUserId || usersMap.has(id)) return;
24645
24550
  const profile = profileById.get(id);
24646
24551
  const email = readFirstRecordString(profile, [CHAT_USERS_UPDATE_EMAIL_COLUMN, CHAT_USERS_EMAIL_COLUMN, "email"]);
@@ -24663,7 +24568,7 @@ var MainNavbar = ({
24663
24568
  avatarUrl: resolveChatAvatarUrl(avatarValue),
24664
24569
  roleLabel,
24665
24570
  status: statusValue,
24666
- statusLabel: (_a70 = presenceStatusLabelMap.get(id)) != null ? _a70 : PRESENCE_STATUS_LABELS[statusValue]
24571
+ statusLabel: (_a68 = presenceStatusLabelMap.get(id)) != null ? _a68 : PRESENCE_STATUS_LABELS[statusValue]
24667
24572
  });
24668
24573
  });
24669
24574
  if (messageErrors.length > 0) {
@@ -24680,7 +24585,7 @@ var MainNavbar = ({
24680
24585
  );
24681
24586
  setChatMessages(resolvedMessages);
24682
24587
  resolvedMessages.forEach((message) => {
24683
- var _a70, _b6, _c3;
24588
+ var _a68, _b5, _c3;
24684
24589
  const contactId = message.contactId;
24685
24590
  if (!contactId || contactId === effectiveCurrentUserId || usersMap.has(contactId)) return;
24686
24591
  const profile = profileById.get(contactId);
@@ -24696,7 +24601,7 @@ var MainNavbar = ({
24696
24601
  "avatar"
24697
24602
  ]);
24698
24603
  const roleLabel = readFirstRecordString(profile, [CHAT_USERS_ROLE_COLUMN, "job_title", "role"]);
24699
- const resolvedStatus = (_b6 = (_a70 = presenceMap.get(contactId)) != null ? _a70 : readPresenceStatusFromRecord(profile)) != null ? _b6 : "offline";
24604
+ const resolvedStatus = (_b5 = (_a68 = presenceMap.get(contactId)) != null ? _a68 : readPresenceStatusFromRecord(profile)) != null ? _b5 : "offline";
24700
24605
  usersMap.set(contactId, {
24701
24606
  id: contactId,
24702
24607
  name: resolveReadableUserLabel(rawName, rawUsername, email, contactId),
@@ -24852,9 +24757,9 @@ var MainNavbar = ({
24852
24757
  table: USER_PRESENCE_TABLE
24853
24758
  },
24854
24759
  (payload) => {
24855
- var _a69, _b5;
24760
+ var _a67, _b4;
24856
24761
  const row = payload.new || payload.old;
24857
- const userId = toStringOrUndefined((_b5 = (_a69 = row[USER_PRESENCE_USER_ID_COLUMN]) != null ? _a69 : row.user_id) != null ? _b5 : row.id);
24762
+ const userId = toStringOrUndefined((_b4 = (_a67 = row[USER_PRESENCE_USER_ID_COLUMN]) != null ? _a67 : row.user_id) != null ? _b4 : row.id);
24858
24763
  if (!userId || userId === effectiveCurrentUserId) return;
24859
24764
  let nextStatus = "offline";
24860
24765
  let nextStatusLabel = PRESENCE_STATUS_LABELS.offline;
@@ -24928,10 +24833,10 @@ var MainNavbar = ({
24928
24833
  const chatUnreadByUser = (0, import_react19.useMemo)(() => {
24929
24834
  const counters = {};
24930
24835
  chatMessages.forEach((message) => {
24931
- var _a69;
24836
+ var _a67;
24932
24837
  if (message.sender !== "them") return;
24933
24838
  if (message.readAt) return;
24934
- counters[message.contactId] = ((_a69 = counters[message.contactId]) != null ? _a69 : 0) + 1;
24839
+ counters[message.contactId] = ((_a67 = counters[message.contactId]) != null ? _a67 : 0) + 1;
24935
24840
  });
24936
24841
  return counters;
24937
24842
  }, [chatMessages]);
@@ -24979,9 +24884,9 @@ var MainNavbar = ({
24979
24884
  }
24980
24885
  const persistedReadAtByMessageId = /* @__PURE__ */ new Map();
24981
24886
  (data != null ? data : []).forEach((row) => {
24982
- var _a69;
24887
+ var _a67;
24983
24888
  const messageId = toStringOrUndefined(row[CHAT_MESSAGES_ID_COLUMN]);
24984
- const persistedReadAt = (_a69 = toStringOrUndefined(row[CHAT_MESSAGES_READ_AT_COLUMN])) != null ? _a69 : readAt;
24889
+ const persistedReadAt = (_a67 = toStringOrUndefined(row[CHAT_MESSAGES_READ_AT_COLUMN])) != null ? _a67 : readAt;
24985
24890
  if (!messageId) return;
24986
24891
  persistedReadAtByMessageId.set(messageId, persistedReadAt);
24987
24892
  });
@@ -25150,8 +25055,8 @@ var MainNavbar = ({
25150
25055
  (current) => dedupeAndSortMessages(
25151
25056
  current.map(
25152
25057
  (message) => {
25153
- var _a69;
25154
- return message.id === messageId ? { ...message, text: previousText, editedAt: (_a69 = targetMessage.editedAt) != null ? _a69 : null } : message;
25058
+ var _a67;
25059
+ return message.id === messageId ? { ...message, text: previousText, editedAt: (_a67 = targetMessage.editedAt) != null ? _a67 : null } : message;
25155
25060
  }
25156
25061
  )
25157
25062
  )
@@ -25182,13 +25087,13 @@ var MainNavbar = ({
25182
25087
  (current) => dedupeAndSortMessages(
25183
25088
  current.map(
25184
25089
  (message) => {
25185
- var _a69;
25090
+ var _a67;
25186
25091
  return message.id === messageId ? {
25187
25092
  ...message,
25188
25093
  text: CHAT_DELETED_PLACEHOLDER_TEXT2,
25189
25094
  deletedAt,
25190
25095
  deletedBy: effectiveCurrentUserId,
25191
- editedAt: (_a69 = message.editedAt) != null ? _a69 : deletedAt
25096
+ editedAt: (_a67 = message.editedAt) != null ? _a67 : deletedAt
25192
25097
  } : message;
25193
25098
  }
25194
25099
  )
@@ -25364,7 +25269,7 @@ var MainNavbar = ({
25364
25269
  [effectiveCurrentUserId, updateChatFeatureFlags]
25365
25270
  );
25366
25271
  const items = (0, import_react19.useMemo)(() => {
25367
- var _a69;
25272
+ var _a67;
25368
25273
  if (!showNavItems) return [];
25369
25274
  const normalizedPathname = currentPathname === "" ? "/" : currentPathname;
25370
25275
  const navItems = getMainNavItems();
@@ -25374,7 +25279,7 @@ var MainNavbar = ({
25374
25279
  if (normalizedPathname.startsWith(`${href}/`)) return href.length;
25375
25280
  return -1;
25376
25281
  };
25377
- const bestMatchHref = (_a69 = navItems.filter((item) => !item.href.startsWith("#")).map((item) => ({ href: item.href, score: scoreRouteMatch(item.href) })).filter((candidate) => candidate.score >= 0).sort((left, right) => right.score - left.score)[0]) == null ? void 0 : _a69.href;
25282
+ const bestMatchHref = (_a67 = navItems.filter((item) => !item.href.startsWith("#")).map((item) => ({ href: item.href, score: scoreRouteMatch(item.href) })).filter((candidate) => candidate.score >= 0).sort((left, right) => right.score - left.score)[0]) == null ? void 0 : _a67.href;
25378
25283
  return navItems.map((item) => {
25379
25284
  const isAnchor = item.href.startsWith("#");
25380
25285
  const isActive = !isAnchor ? item.href === bestMatchHref : false;
@@ -25382,8 +25287,8 @@ var MainNavbar = ({
25382
25287
  ...item,
25383
25288
  isActive,
25384
25289
  onClick: isAnchor ? item.onClick : (event) => {
25385
- var _a70;
25386
- (_a70 = item.onClick) == null ? void 0 : _a70.call(item, event);
25290
+ var _a68;
25291
+ (_a68 = item.onClick) == null ? void 0 : _a68.call(item, event);
25387
25292
  if (!onNavigate || event.defaultPrevented) return;
25388
25293
  event.preventDefault();
25389
25294
  onNavigate(item.href);
@@ -25430,9 +25335,9 @@ var MainNavbar = ({
25430
25335
  window.open(`${MC_BASE_URL2}/tasks`, "_blank", "noopener,noreferrer");
25431
25336
  };
25432
25337
  const handleChatOpenUserProfile = (0, import_react19.useCallback)(({ userId }) => {
25433
- var _a69;
25338
+ var _a67;
25434
25339
  if (!userId || typeof window === "undefined") return;
25435
- const baseUrl = ((_a69 = getRuntimeEnv("VITE_ACCOUNTS_BASE_URL")) != null ? _a69 : "https://accounts.cupcode.com.br").replace(
25340
+ const baseUrl = ((_a67 = getRuntimeEnv("VITE_ACCOUNTS_BASE_URL")) != null ? _a67 : "https://accounts.cupcode.com.br").replace(
25436
25341
  /\/+$/,
25437
25342
  ""
25438
25343
  );
@@ -25499,121 +25404,54 @@ var MainNavbar = ({
25499
25404
  );
25500
25405
  const handleProfileAvatarChange = (0, import_react19.useCallback)(
25501
25406
  async ({ avatarId, avatarUrl }) => {
25502
- var _a69, _b5;
25503
- const normalizedAvatarId = (_a69 = parseAssetId(avatarId)) != null ? _a69 : parseAssetId(avatarUrl);
25407
+ var _a67, _b4, _c2, _d, _e;
25408
+ const normalizedAvatarId = (_a67 = parseAssetId(avatarId)) != null ? _a67 : parseAssetId(avatarUrl);
25504
25409
  if (!normalizedAvatarId) {
25505
25410
  throw new Error("ID da imagem inv\xE1lido.");
25506
25411
  }
25507
- const supabase = getSupabase();
25508
- if (!supabase) {
25412
+ const nextAvatarValue = avatarUrl || normalizedAvatarId;
25413
+ const token = await getTelescupAccessToken().catch(() => "");
25414
+ if (!resolvedTelescupBaseUrl || !token || typeof fetch === "undefined") {
25509
25415
  throw new Error("N\xE3o foi poss\xEDvel salvar sua nova imagem agora.");
25510
25416
  }
25511
- const updateTargets = [CHAT_USERS_UPDATE_TABLE];
25512
- const lookupTargets = Array.from(
25513
- new Set(
25514
- [CHAT_USERS_TABLE, CHAT_USERS_UPDATE_TABLE, "profiles", "users"].map((entry) => entry.trim()).filter((entry) => entry.length > 0)
25515
- )
25516
- );
25517
- const updateErrors = [];
25518
- const isRecoverableUpdateError = (error) => {
25519
- var _a70;
25520
- const message = ((_a70 = error.message) != null ? _a70 : "").toLowerCase();
25521
- 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");
25522
- };
25523
- const isRecoverableLookupError2 = (error) => {
25524
- var _a70;
25525
- const message = ((_a70 = error.message) != null ? _a70 : "").toLowerCase();
25526
- 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");
25527
- };
25528
- const isPermissionDeniedError = (error) => {
25529
- var _a70;
25530
- const message = ((_a70 = error.message) != null ? _a70 : "").toLowerCase();
25531
- return error.code === "42501" || message.includes("permission denied");
25532
- };
25533
- const updateAvatarByUserId = async (userId) => {
25534
- var _a70, _b6, _c2, _d, _e;
25535
- for (const tableName of updateTargets) {
25536
- 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);
25537
- if (!updateWithSelect.error) {
25538
- const rows = updateWithSelect.data;
25539
- const row = (_a70 = rows == null ? void 0 : rows[0]) != null ? _a70 : null;
25540
- if (row) {
25541
- return row;
25542
- }
25543
- continue;
25544
- }
25545
- const selectError = updateWithSelect.error;
25546
- if (isPermissionDeniedError(selectError)) {
25547
- const updateWithoutSelect = await supabase.from(tableName).update({ [CHAT_USERS_UPDATE_AVATAR_COLUMN]: normalizedAvatarId }).eq(CHAT_USERS_UPDATE_ID_COLUMN, userId);
25548
- if (!updateWithoutSelect.error) {
25549
- return {
25550
- [CHAT_USERS_UPDATE_ID_COLUMN]: userId,
25551
- [CHAT_USERS_UPDATE_AVATAR_COLUMN]: normalizedAvatarId
25552
- };
25553
- }
25554
- const withoutSelectError = updateWithoutSelect.error;
25555
- if (!isRecoverableUpdateError(withoutSelectError)) {
25556
- throw new Error(`Falha ao atualizar avatar em "${tableName}": ${withoutSelectError.message}`);
25557
- }
25558
- updateErrors.push(
25559
- `${tableName}: ${(_b6 = withoutSelectError.code) != null ? _b6 : "erro"} ${(_c2 = withoutSelectError.message) != null ? _c2 : "falha desconhecida"}`
25560
- );
25561
- continue;
25562
- }
25563
- if (!isRecoverableUpdateError(selectError)) {
25564
- throw new Error(`Falha ao atualizar avatar em "${tableName}": ${selectError.message}`);
25565
- }
25566
- updateErrors.push(`${tableName}: ${(_d = selectError.code) != null ? _d : "erro"} ${(_e = selectError.message) != null ? _e : "falha desconhecida"}`);
25567
- }
25568
- return null;
25569
- };
25570
- const resolveUserIdByEmail = async (emailValue) => {
25571
- var _a70;
25572
- let lastRecoverableError = null;
25573
- for (const tableName of lookupTargets) {
25574
- const { data, error } = await supabase.from(tableName).select(CHAT_USERS_UPDATE_ID_COLUMN).ilike(CHAT_USERS_UPDATE_EMAIL_COLUMN, emailValue).limit(1);
25575
- if (!error) {
25576
- const rows = data;
25577
- const resolvedId = toStringOrUndefined((_a70 = rows == null ? void 0 : rows[0]) == null ? void 0 : _a70[CHAT_USERS_UPDATE_ID_COLUMN]);
25578
- if (resolvedId) {
25579
- return resolvedId;
25580
- }
25581
- continue;
25582
- }
25583
- if (!isRecoverableLookupError2(error)) {
25584
- throw new Error(`Falha ao localizar usu\xE1rio em "${tableName}" por e-mail: ${error.message}`);
25585
- }
25586
- lastRecoverableError = error;
25587
- }
25588
- if (lastRecoverableError && isRuntimeDev()) {
25589
- console.warn("[chat] Falha ao buscar usu\xE1rio por e-mail para salvar avatar:", lastRecoverableError.message);
25590
- }
25591
- return null;
25592
- };
25593
- const currentCandidateId = resolvedSenderId != null ? resolvedSenderId : currentUserId;
25594
- let updatedRow = null;
25595
- let finalUserId = currentCandidateId != null ? currentCandidateId : null;
25596
- if (currentCandidateId) {
25597
- updatedRow = await updateAvatarByUserId(currentCandidateId);
25598
- }
25599
- if (!updatedRow && authEmail) {
25600
- const normalizedEmail = authEmail.toLowerCase();
25601
- const resolvedByEmailId = await resolveUserIdByEmail(normalizedEmail);
25602
- if (resolvedByEmailId) {
25603
- updatedRow = await updateAvatarByUserId(resolvedByEmailId);
25604
- finalUserId = resolvedByEmailId;
25605
- }
25606
- }
25607
- if (!updatedRow) {
25608
- throw new Error("N\xE3o foi poss\xEDvel salvar sua nova imagem agora.");
25417
+ const response = await fetch(buildExternalUrl(resolvedTelescupBaseUrl.replace(/\/+$/, ""), "/tenant-users-admin"), {
25418
+ method: "POST",
25419
+ headers: {
25420
+ Authorization: `Bearer ${token}`,
25421
+ "Content-Type": "application/json"
25422
+ },
25423
+ body: JSON.stringify({
25424
+ action: "update_self_avatar",
25425
+ avatar_id: normalizedAvatarId,
25426
+ avatar_url: nextAvatarValue
25427
+ })
25428
+ });
25429
+ if (!response.ok) {
25430
+ throw new Error(`Falha ao salvar avatar pela API: ${response.status}`);
25609
25431
  }
25432
+ const payload = await response.json().catch(() => null);
25433
+ const profile = payload == null ? void 0 : payload.profile;
25434
+ const finalUserId = (_d = (_c2 = (_b4 = toStringOrUndefined(profile == null ? void 0 : profile.user_id)) != null ? _b4 : toStringOrUndefined(profile == null ? void 0 : profile.id)) != null ? _c2 : resolvedSenderId) != null ? _d : currentUserId;
25610
25435
  if (finalUserId && finalUserId !== resolvedSenderId) {
25611
25436
  setResolvedSenderId(finalUserId);
25612
25437
  }
25613
- setPersistedProfileAvatarValue((_b5 = resolveAvatarPreviewUrl({ url: avatarUrl }, normalizedAvatarId)) != null ? _b5 : normalizedAvatarId);
25438
+ const nextAvatarPreview = (_e = resolveAvatarPreviewUrl({ url: avatarUrl }, normalizedAvatarId)) != null ? _e : normalizedAvatarId;
25439
+ setPersistedProfileAvatarValue(nextAvatarPreview);
25440
+ if (typeof window !== "undefined") {
25441
+ window.dispatchEvent(
25442
+ new CustomEvent("cupcode:profile-avatar-change", {
25443
+ detail: {
25444
+ avatarId: normalizedAvatarId,
25445
+ avatarUrl: nextAvatarPreview,
25446
+ rawAvatarUrl: nextAvatarValue,
25447
+ userId: finalUserId
25448
+ }
25449
+ })
25450
+ );
25451
+ }
25614
25452
  import_sonner.toast.success("Nova imagem salva com sucesso");
25615
25453
  },
25616
- [authEmail, currentUserId, resolvedSenderId]
25454
+ [currentUserId, getTelescupAccessToken, resolvedSenderId, resolvedTelescupBaseUrl]
25617
25455
  );
25618
25456
  return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_jsx_runtime41.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
25619
25457
  NavbarCupcode,
@@ -25623,7 +25461,7 @@ var MainNavbar = ({
25623
25461
  leadingSlot,
25624
25462
  className,
25625
25463
  actions: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "flex items-center gap-3", children: [
25626
- isCupcodeTenant ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ThemeToggle, {}) : null,
25464
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ThemeToggle, {}),
25627
25465
  isCupcodeTenant ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
25628
25466
  UserMenuCupcode,
25629
25467
  {
@@ -25631,7 +25469,7 @@ var MainNavbar = ({
25631
25469
  isLoading: resolvedAuthStatus === "loading",
25632
25470
  loginLabel: ctaLabel,
25633
25471
  displayName: authUser == null ? void 0 : authUser.name,
25634
- username: (_b4 = authUser == null ? void 0 : authUser.preferredUsername) != null ? _b4 : authUser == null ? void 0 : authUser.nickname,
25472
+ username: (_b3 = authUser == null ? void 0 : authUser.preferredUsername) != null ? _b3 : authUser == null ? void 0 : authUser.nickname,
25635
25473
  email: authUser == null ? void 0 : authUser.email,
25636
25474
  avatarUrl: resolvedProfileAvatarUrl,
25637
25475
  roleLabel: authUser == null ? void 0 : authUser.jobTitle,
@@ -26304,7 +26142,7 @@ var DocumentationSearchDialog = ({ open, onOpenChange }) => {
26304
26142
  const totalSections = map.sections.length;
26305
26143
  const mapMatches = normalizedQuery.length === 0 || normalizeText([map.title, map.subtitle, map.searchLabel].join(" ")).includes(normalizedQuery);
26306
26144
  const sections = map.sections.filter((section) => {
26307
- var _a68, _b4, _c;
26145
+ var _a66, _b3, _c;
26308
26146
  if (mapMatches) return true;
26309
26147
  const parent = section.parentId ? parents.get(section.parentId) : null;
26310
26148
  const haystack = normalizeText(
@@ -26313,8 +26151,8 @@ var DocumentationSearchDialog = ({ open, onOpenChange }) => {
26313
26151
  map.searchLabel,
26314
26152
  section.label,
26315
26153
  section.group,
26316
- (_a68 = section.description) != null ? _a68 : "",
26317
- (_b4 = parent == null ? void 0 : parent.label) != null ? _b4 : "",
26154
+ (_a66 = section.description) != null ? _a66 : "",
26155
+ (_b3 = parent == null ? void 0 : parent.label) != null ? _b3 : "",
26318
26156
  ...(_c = section.keywords) != null ? _c : []
26319
26157
  ].join(" ")
26320
26158
  );
@@ -26433,10 +26271,10 @@ var DocumentationSearchDialog = ({ open, onOpenChange }) => {
26433
26271
  // src/components/layout/sidebar-groups.tsx
26434
26272
  var toStableId = (value) => value.toLowerCase().normalize("NFD").replace(/\p{Diacritic}+/gu, "").replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)+/g, "");
26435
26273
  var getGroupMetadata = (item) => {
26436
- var _a68, _b4;
26274
+ var _a66, _b3;
26437
26275
  return {
26438
- id: ((_a68 = item.groupId) == null ? void 0 : _a68.trim()) || "",
26439
- label: ((_b4 = item.groupLabel) == null ? void 0 : _b4.trim()) || "",
26276
+ id: ((_a66 = item.groupId) == null ? void 0 : _a66.trim()) || "",
26277
+ label: ((_b3 = item.groupLabel) == null ? void 0 : _b3.trim()) || "",
26440
26278
  icon: item.groupIcon
26441
26279
  };
26442
26280
  };
@@ -26451,7 +26289,7 @@ var buildSidebarGroupsFromNavItems = (items, defaultGroupLabel = "Principal") =>
26451
26289
  if (navItems.length === 0) return [];
26452
26290
  const groupsMap = /* @__PURE__ */ new Map();
26453
26291
  navItems.forEach((item) => {
26454
- var _a68;
26292
+ var _a66;
26455
26293
  const groupId = item.group.id || toStableId(item.group.label || defaultGroupLabel);
26456
26294
  const groupLabel = item.group.label || defaultGroupLabel;
26457
26295
  const existing = groupsMap.get(groupId);
@@ -26459,7 +26297,7 @@ var buildSidebarGroupsFromNavItems = (items, defaultGroupLabel = "Principal") =>
26459
26297
  groupsMap.set(groupId, {
26460
26298
  id: groupId,
26461
26299
  label: groupLabel,
26462
- icon: (_a68 = item.group.icon) != null ? _a68 : item.icon,
26300
+ icon: (_a66 = item.group.icon) != null ? _a66 : item.icon,
26463
26301
  items: [{ id: item.id, label: item.label, icon: item.icon, route: item.route }]
26464
26302
  });
26465
26303
  return;
@@ -26476,8 +26314,8 @@ var defaultSidebarGroups = buildSidebarGroupsFromNavItems(getMainNavItems());
26476
26314
  // src/components/layout/sidebar.tsx
26477
26315
  var import_jsx_runtime43 = require("react/jsx-runtime");
26478
26316
  var findGroupByRoute = (groups, pathname) => {
26479
- var _a68, _b4;
26480
- return (_b4 = (_a68 = groups.find((group) => group.items.some((item) => item.route === pathname))) == null ? void 0 : _a68.label) != null ? _b4 : null;
26317
+ var _a66, _b3;
26318
+ return (_b3 = (_a66 = groups.find((group) => group.items.some((item) => item.route === pathname))) == null ? void 0 : _a66.label) != null ? _b3 : null;
26481
26319
  };
26482
26320
  var IconFallback = () => /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_lucide_react13.Circle, { className: "h-3 w-3 opacity-80", "aria-hidden": "true" });
26483
26321
  var DEFAULT_EXPANDED_LOGO_SLOT = /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "h-10 w-[175px] shrink-0", "aria-hidden": "true" });
@@ -27670,10 +27508,10 @@ function isThemeMode(value) {
27670
27508
  return value === "light" || value === "dark";
27671
27509
  }
27672
27510
  function readStoredTheme() {
27673
- var _a68;
27511
+ var _a66;
27674
27512
  if (typeof window === "undefined") return null;
27675
27513
  try {
27676
- const storedTheme = (_a68 = window.localStorage.getItem(THEME_STORAGE_KEY2)) != null ? _a68 : window.localStorage.getItem("theme");
27514
+ const storedTheme = (_a66 = window.localStorage.getItem(THEME_STORAGE_KEY2)) != null ? _a66 : window.localStorage.getItem("theme");
27677
27515
  return isThemeMode(storedTheme) ? storedTheme : null;
27678
27516
  } catch (e) {
27679
27517
  return null;
@@ -27696,10 +27534,10 @@ function applyThemeClass(theme) {
27696
27534
  root.style.colorScheme = theme;
27697
27535
  }
27698
27536
  function readThemeFromRoot() {
27699
- var _a68;
27537
+ var _a66;
27700
27538
  if (typeof document === "undefined") return null;
27701
27539
  const root = document.documentElement;
27702
- const datasetTheme = (_a68 = root.dataset.theme) != null ? _a68 : null;
27540
+ const datasetTheme = (_a66 = root.dataset.theme) != null ? _a66 : null;
27703
27541
  if (isThemeMode(datasetTheme)) return datasetTheme;
27704
27542
  if (root.classList.contains("dark")) return "dark";
27705
27543
  if (root.classList.contains("light")) return "light";
@@ -27722,13 +27560,13 @@ var ThemeToggle2 = ({
27722
27560
  defaultTheme = "light",
27723
27561
  onThemeChange
27724
27562
  }) => {
27725
- var _a68;
27563
+ var _a66;
27726
27564
  const themeContext = React34.useContext(ThemeContext);
27727
27565
  const [mounted, setMounted] = React34.useState(false);
27728
27566
  const [internalTheme, setInternalTheme] = React34.useState(defaultTheme);
27729
27567
  const isControlled = typeof theme !== "undefined";
27730
27568
  const usesProviderTheme = !isControlled && themeContext !== null;
27731
- const activeTheme = (_a68 = isControlled ? theme : usesProviderTheme ? themeContext.theme : internalTheme) != null ? _a68 : defaultTheme;
27569
+ const activeTheme = (_a66 = isControlled ? theme : usesProviderTheme ? themeContext.theme : internalTheme) != null ? _a66 : defaultTheme;
27732
27570
  React34.useEffect(() => {
27733
27571
  if (!isControlled && !usesProviderTheme) {
27734
27572
  setInternalTheme(resolveTheme(defaultTheme));
@@ -27753,8 +27591,8 @@ var ThemeToggle2 = ({
27753
27591
  return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("div", { className: cn("w-10 h-10 rounded-lg bg-muted", className) });
27754
27592
  }
27755
27593
  const handleToggle = (event) => {
27756
- var _a69;
27757
- const currentTheme = (_a69 = readThemeFromRoot()) != null ? _a69 : activeTheme;
27594
+ var _a67;
27595
+ const currentTheme = (_a67 = readThemeFromRoot()) != null ? _a67 : activeTheme;
27758
27596
  const nextTheme = currentTheme === "dark" ? "light" : "dark";
27759
27597
  if (usesProviderTheme) {
27760
27598
  themeContext.toggleTheme({
@@ -27808,11 +27646,11 @@ function getPreferredTheme() {
27808
27646
  return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
27809
27647
  }
27810
27648
  function getStoredTheme() {
27811
- var _a68;
27649
+ var _a66;
27812
27650
  if (typeof window === "undefined") {
27813
27651
  return null;
27814
27652
  }
27815
- const storedTheme = (_a68 = window.localStorage.getItem(STORAGE_KEY2)) != null ? _a68 : window.localStorage.getItem(LEGACY_STORAGE_KEY);
27653
+ const storedTheme = (_a66 = window.localStorage.getItem(STORAGE_KEY2)) != null ? _a66 : window.localStorage.getItem(LEGACY_STORAGE_KEY);
27816
27654
  return storedTheme === "light" || storedTheme === "dark" ? storedTheme : null;
27817
27655
  }
27818
27656
  function getThemeFromRoot() {
@@ -27833,10 +27671,10 @@ function getThemeFromRoot() {
27833
27671
  return null;
27834
27672
  }
27835
27673
  function resolveTheme2() {
27836
- var _a68, _b4;
27837
- return (_b4 = (_a68 = getThemeFromRoot()) != null ? _a68 : getStoredTheme()) != null ? _b4 : getPreferredTheme();
27674
+ var _a66, _b3;
27675
+ return (_b3 = (_a66 = getThemeFromRoot()) != null ? _a66 : getStoredTheme()) != null ? _b3 : getPreferredTheme();
27838
27676
  }
27839
- function applyThemeToRoot2(theme) {
27677
+ function applyThemeToRoot(theme) {
27840
27678
  const root = document.documentElement;
27841
27679
  root.classList.toggle("dark", theme === "dark");
27842
27680
  root.classList.toggle("light", theme === "light");
@@ -27853,7 +27691,7 @@ function ThemeProvider({ children }) {
27853
27691
  (0, import_react27.useEffect)(() => {
27854
27692
  const initialTheme = resolveTheme2();
27855
27693
  setThemeState((currentTheme) => currentTheme === initialTheme ? currentTheme : initialTheme);
27856
- applyThemeToRoot2(initialTheme);
27694
+ applyThemeToRoot(initialTheme);
27857
27695
  setMounted(true);
27858
27696
  }, []);
27859
27697
  (0, import_react27.useEffect)(() => {
@@ -27862,7 +27700,7 @@ function ThemeProvider({ children }) {
27862
27700
  }
27863
27701
  const rootTheme = getThemeFromRoot();
27864
27702
  if (rootTheme !== theme) {
27865
- applyThemeToRoot2(theme);
27703
+ applyThemeToRoot(theme);
27866
27704
  }
27867
27705
  const storedTheme = getStoredTheme();
27868
27706
  if (storedTheme !== theme) {
@@ -27880,7 +27718,7 @@ function ThemeProvider({ children }) {
27880
27718
  }
27881
27719
  const nextTheme = mediaQuery.matches ? "dark" : "light";
27882
27720
  setThemeState(nextTheme);
27883
- applyThemeToRoot2(nextTheme);
27721
+ applyThemeToRoot(nextTheme);
27884
27722
  };
27885
27723
  mediaQuery.addEventListener("change", handleChange);
27886
27724
  return () => mediaQuery.removeEventListener("change", handleChange);
@@ -27904,7 +27742,7 @@ function ThemeProvider({ children }) {
27904
27742
  return () => observer.disconnect();
27905
27743
  }, []);
27906
27744
  const applyThemeSelection = (0, import_react27.useCallback)((nextTheme, coords) => {
27907
- var _a68;
27745
+ var _a66;
27908
27746
  const documentWithTransition = document;
27909
27747
  const root = document.documentElement;
27910
27748
  const prefersReducedMotion = window.matchMedia(
@@ -27912,7 +27750,7 @@ function ThemeProvider({ children }) {
27912
27750
  ).matches;
27913
27751
  const supportsTransition = typeof documentWithTransition.startViewTransition === "function";
27914
27752
  const commitTheme = () => {
27915
- applyThemeToRoot2(nextTheme);
27753
+ applyThemeToRoot(nextTheme);
27916
27754
  persistThemePreferenceSelection(nextTheme);
27917
27755
  setThemeState(
27918
27756
  (currentTheme) => currentTheme === nextTheme ? currentTheme : nextTheme
@@ -27929,7 +27767,7 @@ function ThemeProvider({ children }) {
27929
27767
  root.style.setProperty("--theme-x", "50%");
27930
27768
  root.style.setProperty("--theme-y", "50%");
27931
27769
  }
27932
- (_a68 = documentWithTransition.startViewTransition) == null ? void 0 : _a68.call(documentWithTransition, () => {
27770
+ (_a66 = documentWithTransition.startViewTransition) == null ? void 0 : _a66.call(documentWithTransition, () => {
27933
27771
  (0, import_react_dom.flushSync)(() => {
27934
27772
  commitTheme();
27935
27773
  });
@@ -27939,8 +27777,8 @@ function ThemeProvider({ children }) {
27939
27777
  applyThemeSelection(nextTheme);
27940
27778
  }, [applyThemeSelection]);
27941
27779
  const toggleTheme = (0, import_react27.useCallback)((coords) => {
27942
- var _a68;
27943
- const currentTheme = (_a68 = getThemeFromRoot()) != null ? _a68 : theme;
27780
+ var _a66;
27781
+ const currentTheme = (_a66 = getThemeFromRoot()) != null ? _a66 : theme;
27944
27782
  const nextTheme = currentTheme === "light" ? "dark" : "light";
27945
27783
  applyThemeSelection(nextTheme, coords);
27946
27784
  }, [applyThemeSelection, theme]);
@@ -28593,8 +28431,8 @@ var ChartStyle = ({ id, config }) => {
28593
28431
  ([theme, prefix]) => `
28594
28432
  ${prefix} [data-chart=${id}] {
28595
28433
  ${colorConfig.map(([key, itemConfig]) => {
28596
- var _a68;
28597
- const color = ((_a68 = itemConfig.theme) == null ? void 0 : _a68[theme]) || itemConfig.color;
28434
+ var _a66;
28435
+ const color = ((_a66 = itemConfig.theme) == null ? void 0 : _a66[theme]) || itemConfig.color;
28598
28436
  return color ? ` --color-${key}: ${color};` : null;
28599
28437
  }).join("\n")}
28600
28438
  }
@@ -28623,14 +28461,14 @@ var ChartTooltipContent = React42.forwardRef(
28623
28461
  }, ref) => {
28624
28462
  const { config } = useChart();
28625
28463
  const tooltipLabel = React42.useMemo(() => {
28626
- var _a68;
28464
+ var _a66;
28627
28465
  if (hideLabel || !(payload == null ? void 0 : payload.length)) {
28628
28466
  return null;
28629
28467
  }
28630
28468
  const [item] = payload;
28631
28469
  const key = `${labelKey || item.dataKey || item.name || "value"}`;
28632
28470
  const itemConfig = getPayloadConfigFromPayload(config, item, key);
28633
- const value = !labelKey && typeof label === "string" ? ((_a68 = config[label]) == null ? void 0 : _a68.label) || label : itemConfig == null ? void 0 : itemConfig.label;
28471
+ const value = !labelKey && typeof label === "string" ? ((_a66 = config[label]) == null ? void 0 : _a66.label) || label : itemConfig == null ? void 0 : itemConfig.label;
28634
28472
  if (labelFormatter) {
28635
28473
  return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("div", { className: cn("font-medium", labelClassName), children: labelFormatter(value, payload) });
28636
28474
  }
@@ -30248,9 +30086,9 @@ ToggleGroupItem.displayName = ToggleGroupPrimitive.Item.displayName;
30248
30086
  // src/hooks/useActiveSection.ts
30249
30087
  var import_react29 = require("react");
30250
30088
  var resolveActiveFromOffsets = (sectionIds, topById, offset, scrollY) => {
30251
- var _a68;
30089
+ var _a66;
30252
30090
  const line = scrollY + offset;
30253
- let nextActive = (_a68 = sectionIds[0]) != null ? _a68 : "";
30091
+ let nextActive = (_a66 = sectionIds[0]) != null ? _a66 : "";
30254
30092
  for (const id of sectionIds) {
30255
30093
  const top = topById.get(id);
30256
30094
  if (typeof top !== "number") continue;
@@ -30263,10 +30101,10 @@ var resolveActiveFromOffsets = (sectionIds, topById, offset, scrollY) => {
30263
30101
  return nextActive;
30264
30102
  };
30265
30103
  var useActiveSection = (sectionIds, offset = 180) => {
30266
- var _a68;
30267
- const [activeId, setActiveId] = (0, import_react29.useState)((_a68 = sectionIds[0]) != null ? _a68 : "");
30104
+ var _a66;
30105
+ const [activeId, setActiveId] = (0, import_react29.useState)((_a66 = sectionIds[0]) != null ? _a66 : "");
30268
30106
  (0, import_react29.useEffect)(() => {
30269
- var _a69;
30107
+ var _a67;
30270
30108
  if (!sectionIds.length || typeof window === "undefined") return;
30271
30109
  const sections = sectionIds.map((id) => {
30272
30110
  const element = document.getElementById(id);
@@ -30274,7 +30112,7 @@ var useActiveSection = (sectionIds, offset = 180) => {
30274
30112
  return { id, element };
30275
30113
  }).filter((section) => section !== null);
30276
30114
  if (!sections.length) {
30277
- setActiveId((_a69 = sectionIds[0]) != null ? _a69 : "");
30115
+ setActiveId((_a67 = sectionIds[0]) != null ? _a67 : "");
30278
30116
  return;
30279
30117
  }
30280
30118
  const topById = /* @__PURE__ */ new Map();
@@ -30409,9 +30247,9 @@ var useLayoutMode = () => {
30409
30247
  setMode(normalizeLayoutMode(event.newValue));
30410
30248
  };
30411
30249
  const handleModeChange = (event) => {
30412
- var _a68;
30250
+ var _a66;
30413
30251
  const customEvent = event;
30414
- setMode((_a68 = customEvent.detail) != null ? _a68 : readStoredLayoutMode());
30252
+ setMode((_a66 = customEvent.detail) != null ? _a66 : readStoredLayoutMode());
30415
30253
  };
30416
30254
  window.addEventListener("storage", handleStorage);
30417
30255
  window.addEventListener(LAYOUT_MODE_CHANGE_EVENT, handleModeChange);
@@ -30442,6 +30280,7 @@ var STORAGE_KEYS = {
30442
30280
  state: "cc_auth_state",
30443
30281
  nonce: "cc_auth_nonce",
30444
30282
  authMode: "cc_auth_mode",
30283
+ profileAvatar: "cc_profile_avatar",
30445
30284
  silentCheckDone: "cc_auth_silent_check_done",
30446
30285
  logoutIntent: "cc_auth_logout_intent",
30447
30286
  redirect: "cc_post_login_redirect",
@@ -30451,18 +30290,18 @@ var STORAGE_KEYS = {
30451
30290
  var LOCAL_STORAGE_KEYS = {
30452
30291
  presenceSource: "cc_user_presence_source"
30453
30292
  };
30293
+ var _a54;
30294
+ var USER_PRESENCE_TABLE2 = ((_a54 = getRuntimeEnv("VITE_USER_PRESENCE_TABLE")) != null ? _a54 : "user_presence").trim();
30295
+ var _a55;
30296
+ var USER_PRESENCE_USER_ID_COLUMN2 = ((_a55 = getRuntimeEnv("VITE_USER_PRESENCE_USER_ID_COLUMN")) != null ? _a55 : "user_id").trim();
30454
30297
  var _a56;
30455
- var USER_PRESENCE_TABLE2 = ((_a56 = getRuntimeEnv("VITE_USER_PRESENCE_TABLE")) != null ? _a56 : "user_presence").trim();
30298
+ var USER_PRESENCE_STATUS_COLUMN2 = ((_a56 = getRuntimeEnv("VITE_USER_PRESENCE_STATUS_COLUMN")) != null ? _a56 : "status").trim();
30456
30299
  var _a57;
30457
- var USER_PRESENCE_USER_ID_COLUMN2 = ((_a57 = getRuntimeEnv("VITE_USER_PRESENCE_USER_ID_COLUMN")) != null ? _a57 : "user_id").trim();
30300
+ var USER_PRESENCE_SOURCE_COLUMN2 = ((_a57 = getRuntimeEnv("VITE_USER_PRESENCE_SOURCE_COLUMN")) != null ? _a57 : "status_source").trim();
30458
30301
  var _a58;
30459
- var USER_PRESENCE_STATUS_COLUMN2 = ((_a58 = getRuntimeEnv("VITE_USER_PRESENCE_STATUS_COLUMN")) != null ? _a58 : "status").trim();
30460
- var _a59;
30461
- var USER_PRESENCE_SOURCE_COLUMN2 = ((_a59 = getRuntimeEnv("VITE_USER_PRESENCE_SOURCE_COLUMN")) != null ? _a59 : "status_source").trim();
30462
- var _a60;
30463
- var USER_PRESENCE_LAST_ACTIVE_COLUMN2 = ((_a60 = getRuntimeEnv("VITE_USER_PRESENCE_LAST_ACTIVE_COLUMN")) != null ? _a60 : "last_active_at").trim();
30464
- var _a61, _b3;
30465
- var SUPABASE_CHAT_SCHEMA = ((_b3 = (_a61 = getRuntimeEnv("VITE_CHAT_SCHEMA")) != null ? _a61 : getRuntimeEnv("VITE_SUPABASE_SCHEMA")) != null ? _b3 : "public").trim();
30302
+ var USER_PRESENCE_LAST_ACTIVE_COLUMN2 = ((_a58 = getRuntimeEnv("VITE_USER_PRESENCE_LAST_ACTIVE_COLUMN")) != null ? _a58 : "last_active_at").trim();
30303
+ var _a59, _b2;
30304
+ var SUPABASE_CHAT_SCHEMA = ((_b2 = (_a59 = getRuntimeEnv("VITE_CHAT_SCHEMA")) != null ? _a59 : getRuntimeEnv("VITE_SUPABASE_SCHEMA")) != null ? _b2 : "public").trim();
30466
30305
  var PRESENCE_TOUCH_RPC = "cc_presence_touch";
30467
30306
  var PRESENCE_MARK_IDLE_RPC = "cc_presence_mark_idle";
30468
30307
  var PRESENCE_SET_STATUS_RPC = "cc_presence_set_status";
@@ -30471,18 +30310,18 @@ var parsePositiveInteger2 = (rawValue, fallback) => {
30471
30310
  if (!Number.isFinite(parsed) || parsed <= 0) return fallback;
30472
30311
  return Math.floor(parsed);
30473
30312
  };
30313
+ var _a60;
30314
+ var CHAT_USERS_TABLE2 = ((_a60 = getRuntimeEnv("VITE_CHAT_USERS_TABLE")) != null ? _a60 : "chat_users").trim();
30315
+ var _a61;
30316
+ var CHAT_USERS_ID_COLUMN2 = ((_a61 = getRuntimeEnv("VITE_CHAT_USERS_ID_COLUMN")) != null ? _a61 : "id").trim();
30474
30317
  var _a62;
30475
- var CHAT_USERS_TABLE2 = ((_a62 = getRuntimeEnv("VITE_CHAT_USERS_TABLE")) != null ? _a62 : "chat_users").trim();
30318
+ var CHAT_USERS_EMAIL_COLUMN2 = ((_a62 = getRuntimeEnv("VITE_CHAT_USERS_EMAIL_COLUMN")) != null ? _a62 : "email").trim();
30476
30319
  var _a63;
30477
- var CHAT_USERS_ID_COLUMN2 = ((_a63 = getRuntimeEnv("VITE_CHAT_USERS_ID_COLUMN")) != null ? _a63 : "id").trim();
30320
+ var CHAT_USERS_UPDATE_TABLE2 = ((_a63 = getRuntimeEnv("VITE_CHAT_USERS_UPDATE_TABLE")) != null ? _a63 : "profiles").trim();
30478
30321
  var _a64;
30479
- var CHAT_USERS_EMAIL_COLUMN2 = ((_a64 = getRuntimeEnv("VITE_CHAT_USERS_EMAIL_COLUMN")) != null ? _a64 : "email").trim();
30322
+ var CHAT_USERS_UPDATE_ID_COLUMN2 = ((_a64 = getRuntimeEnv("VITE_CHAT_USERS_UPDATE_ID_COLUMN")) != null ? _a64 : "id").trim();
30480
30323
  var _a65;
30481
- var CHAT_USERS_UPDATE_TABLE2 = ((_a65 = getRuntimeEnv("VITE_CHAT_USERS_UPDATE_TABLE")) != null ? _a65 : "profiles").trim();
30482
- var _a66;
30483
- var CHAT_USERS_UPDATE_ID_COLUMN2 = ((_a66 = getRuntimeEnv("VITE_CHAT_USERS_UPDATE_ID_COLUMN")) != null ? _a66 : "id").trim();
30484
- var _a67;
30485
- var CHAT_USERS_UPDATE_EMAIL_COLUMN2 = ((_a67 = getRuntimeEnv("VITE_CHAT_USERS_UPDATE_EMAIL_COLUMN")) != null ? _a67 : "email").trim();
30324
+ var CHAT_USERS_UPDATE_EMAIL_COLUMN2 = ((_a65 = getRuntimeEnv("VITE_CHAT_USERS_UPDATE_EMAIL_COLUMN")) != null ? _a65 : "email").trim();
30486
30325
  var PRESENCE_USER_LOOKUP_TABLES = Array.from(
30487
30326
  new Set(
30488
30327
  [CHAT_USERS_UPDATE_TABLE2, CHAT_USERS_TABLE2, "profiles", "chat_users"].map((entry) => entry.trim()).filter((entry) => entry.length > 0)
@@ -30599,6 +30438,32 @@ var toTimestampMs2 = (value) => {
30599
30438
  const parsed = new Date(trimmed).getTime();
30600
30439
  return Number.isNaN(parsed) ? void 0 : parsed;
30601
30440
  };
30441
+ var readStoredProfileAvatar = () => {
30442
+ var _a66;
30443
+ if (typeof window === "undefined") return void 0;
30444
+ const raw = localStorage.getItem(STORAGE_KEYS.profileAvatar) || sessionStorage.getItem(STORAGE_KEYS.profileAvatar);
30445
+ if (!raw) return void 0;
30446
+ try {
30447
+ const parsed = JSON.parse(raw);
30448
+ return (_a66 = toNonEmptyString(parsed.avatarUrl)) != null ? _a66 : toNonEmptyString(parsed.avatarId);
30449
+ } catch (e) {
30450
+ return toNonEmptyString(raw);
30451
+ }
30452
+ };
30453
+ var writeStoredProfileAvatar = (payload) => {
30454
+ if (typeof window === "undefined") return;
30455
+ const avatarId = toNonEmptyString(payload.avatarId);
30456
+ const avatarUrl = toNonEmptyString(payload.avatarUrl);
30457
+ if (!avatarId && !avatarUrl) return;
30458
+ const serialized = JSON.stringify({ avatarId, avatarUrl });
30459
+ sessionStorage.setItem(STORAGE_KEYS.profileAvatar, serialized);
30460
+ localStorage.setItem(STORAGE_KEYS.profileAvatar, serialized);
30461
+ };
30462
+ var applyStoredProfileAvatar = (user) => {
30463
+ if (!user) return user;
30464
+ const storedAvatar = readStoredProfileAvatar();
30465
+ return storedAvatar ? { ...user, picture: storedAvatar } : user;
30466
+ };
30602
30467
  var readPresenceRow = (payload) => {
30603
30468
  if (!payload) return null;
30604
30469
  if (Array.isArray(payload)) {
@@ -30611,8 +30476,8 @@ var readPresenceRow = (payload) => {
30611
30476
  return null;
30612
30477
  };
30613
30478
  var isMissingColumnError2 = (error, column) => {
30614
- var _a68;
30615
- const message = ((_a68 = error == null ? void 0 : error.message) != null ? _a68 : "").toLowerCase();
30479
+ var _a66;
30480
+ const message = ((_a66 = error == null ? void 0 : error.message) != null ? _a66 : "").toLowerCase();
30616
30481
  const code = error == null ? void 0 : error.code;
30617
30482
  const token = column.trim().toLowerCase();
30618
30483
  if (!token) return false;
@@ -30634,8 +30499,8 @@ var readStoredPresence = () => {
30634
30499
  return isUserPresenceStatus(stored) ? stored : DEFAULT_PRESENCE_STATUS;
30635
30500
  };
30636
30501
  var readStoredPresenceSource = () => {
30637
- var _a68;
30638
- const stored = (_a68 = sessionStorage.getItem(STORAGE_KEYS.presenceSource)) != null ? _a68 : localStorage.getItem(LOCAL_STORAGE_KEYS.presenceSource);
30502
+ var _a66;
30503
+ const stored = (_a66 = sessionStorage.getItem(STORAGE_KEYS.presenceSource)) != null ? _a66 : localStorage.getItem(LOCAL_STORAGE_KEYS.presenceSource);
30639
30504
  if (isPresenceSource(stored)) return stored;
30640
30505
  return "auto";
30641
30506
  };
@@ -30682,9 +30547,9 @@ var readClaimValue = (claims, keys) => {
30682
30547
  return void 0;
30683
30548
  };
30684
30549
  var readClaimRole = (claims) => {
30685
- var _a68, _b4, _c;
30550
+ var _a66, _b3, _c;
30686
30551
  if (!claims) return void 0;
30687
- const roleClaim = (_c = (_b4 = (_a68 = claims.role) != null ? _a68 : claims.roles) != null ? _b4 : claims["https://cupcode.com/role"]) != null ? _c : claims["https://cupcode.com/roles"];
30552
+ const roleClaim = (_c = (_b3 = (_a66 = claims.role) != null ? _a66 : claims.roles) != null ? _b3 : claims["https://cupcode.com/role"]) != null ? _c : claims["https://cupcode.com/roles"];
30688
30553
  if (typeof roleClaim === "string") return toNonEmptyString(roleClaim);
30689
30554
  if (Array.isArray(roleClaim)) {
30690
30555
  return roleClaim.find((entry) => typeof entry === "string" && entry.trim() !== "");
@@ -30695,7 +30560,7 @@ var buildUserFromTokens = ({
30695
30560
  idToken,
30696
30561
  accessToken
30697
30562
  }) => {
30698
- var _a68;
30563
+ var _a66;
30699
30564
  const idClaims = decodeJwt(idToken != null ? idToken : void 0);
30700
30565
  const accessClaims = decodeJwt(accessToken != null ? accessToken : void 0);
30701
30566
  if (!idClaims && !accessClaims) return null;
@@ -30722,7 +30587,7 @@ var buildUserFromTokens = ({
30722
30587
  "id",
30723
30588
  "sub"
30724
30589
  ]);
30725
- const resolvedSub = (_a68 = readFromClaims(["sub"])) != null ? _a68 : resolvedId;
30590
+ const resolvedSub = (_a66 = readFromClaims(["sub"])) != null ? _a66 : resolvedId;
30726
30591
  const preferredUsername = readFromClaims([
30727
30592
  "preferred_username",
30728
30593
  "preferredUsername",
@@ -30757,7 +30622,7 @@ var buildUserFromTokens = ({
30757
30622
  "photoURL",
30758
30623
  "https://cupcode.com/picture"
30759
30624
  ]);
30760
- return {
30625
+ return applyStoredProfileAvatar({
30761
30626
  sub: resolvedSub,
30762
30627
  id: resolvedId,
30763
30628
  userId: resolvedId,
@@ -30770,7 +30635,7 @@ var buildUserFromTokens = ({
30770
30635
  nickname,
30771
30636
  role: readRole(),
30772
30637
  jobTitle: readFromClaims(["job_title", "jobTitle", "title", "position", "https://cupcode.com/job_title"])
30773
- };
30638
+ });
30774
30639
  };
30775
30640
  var AuthProvider = ({ children }) => {
30776
30641
  const [status, setStatus] = (0, import_react31.useState)("loading");
@@ -30794,16 +30659,16 @@ var AuthProvider = ({ children }) => {
30794
30659
  }
30795
30660
  }, []);
30796
30661
  const resolvePresenceUserId = (0, import_react31.useCallback)(async (targetUser) => {
30797
- var _a68, _b4, _c, _d;
30662
+ var _a66, _b3, _c, _d;
30798
30663
  const sub = toNonEmptyString(targetUser == null ? void 0 : targetUser.sub);
30799
30664
  const id = toNonEmptyString(targetUser == null ? void 0 : targetUser.id);
30800
30665
  const userId = toNonEmptyString(targetUser == null ? void 0 : targetUser.userId);
30801
- const email = (_a68 = toNonEmptyString(targetUser == null ? void 0 : targetUser.email)) == null ? void 0 : _a68.toLowerCase();
30666
+ const email = (_a66 = toNonEmptyString(targetUser == null ? void 0 : targetUser.email)) == null ? void 0 : _a66.toLowerCase();
30802
30667
  const identityKey = [sub != null ? sub : "", id != null ? id : "", userId != null ? userId : "", email != null ? email : ""].join("|");
30803
30668
  if (resolvedPresenceIdentityKeyRef.current === identityKey && resolvedPresenceUserIdRef.current) {
30804
30669
  return resolvedPresenceUserIdRef.current;
30805
30670
  }
30806
- const fallbackUserId = (_d = (_c = (_b4 = sub != null ? sub : id) != null ? _b4 : userId) != null ? _c : email) != null ? _d : null;
30671
+ const fallbackUserId = (_d = (_c = (_b3 = sub != null ? sub : id) != null ? _b3 : userId) != null ? _c : email) != null ? _d : null;
30807
30672
  if (!email) {
30808
30673
  resolvedPresenceIdentityKeyRef.current = identityKey;
30809
30674
  resolvedPresenceUserIdRef.current = fallbackUserId;
@@ -30833,11 +30698,11 @@ var AuthProvider = ({ children }) => {
30833
30698
  }, []);
30834
30699
  const syncPresenceFromRecord = (0, import_react31.useCallback)(
30835
30700
  (rawRow) => {
30836
- var _a68, _b4, _c;
30701
+ var _a66, _b3, _c;
30837
30702
  if (!rawRow) return;
30838
- const statusValue = toNonEmptyString((_a68 = rawRow[USER_PRESENCE_STATUS_COLUMN2]) != null ? _a68 : rawRow.status);
30703
+ const statusValue = toNonEmptyString((_a66 = rawRow[USER_PRESENCE_STATUS_COLUMN2]) != null ? _a66 : rawRow.status);
30839
30704
  if (!isUserPresenceStatus(statusValue)) return;
30840
- const sourceValue = normalizePresenceSource2((_b4 = rawRow[USER_PRESENCE_SOURCE_COLUMN2]) != null ? _b4 : rawRow.status_source);
30705
+ const sourceValue = normalizePresenceSource2((_b3 = rawRow[USER_PRESENCE_SOURCE_COLUMN2]) != null ? _b3 : rawRow.status_source);
30841
30706
  const lastActiveTimestamp = toTimestampMs2((_c = rawRow[USER_PRESENCE_LAST_ACTIVE_COLUMN2]) != null ? _c : rawRow.last_active_at);
30842
30707
  if (typeof lastActiveTimestamp === "number" && Number.isFinite(lastActiveTimestamp)) {
30843
30708
  lastActivityAtRef.current = Math.max(lastActivityAtRef.current, lastActiveTimestamp);
@@ -30911,8 +30776,8 @@ var AuthProvider = ({ children }) => {
30911
30776
  );
30912
30777
  const touchPresence = (0, import_react31.useCallback)(
30913
30778
  async (options) => {
30914
- var _a68;
30915
- const targetUser = (_a68 = options == null ? void 0 : options.targetUser) != null ? _a68 : user;
30779
+ var _a66;
30780
+ const targetUser = (_a66 = options == null ? void 0 : options.targetUser) != null ? _a66 : user;
30916
30781
  const userId = await resolvePresenceUserId(targetUser);
30917
30782
  if (!userId) return;
30918
30783
  const now = Date.now();
@@ -31037,7 +30902,7 @@ var AuthProvider = ({ children }) => {
31037
30902
  }, []);
31038
30903
  const startAuthorization = (0, import_react31.useCallback)(
31039
30904
  async (options) => {
31040
- var _a68, _b4;
30905
+ var _a66, _b3;
31041
30906
  const config = getAccountsConfig();
31042
30907
  const { authUrl } = await resolveOidcEndpoints(config);
31043
30908
  if (!authUrl) {
@@ -31047,8 +30912,8 @@ var AuthProvider = ({ children }) => {
31047
30912
  const challenge = await generateCodeChallenge(verifier);
31048
30913
  const state = generateState();
31049
30914
  const nonce = generateNonce();
31050
- const redirectTo = (_a68 = options == null ? void 0 : options.redirectTo) != null ? _a68 : window.location.pathname + window.location.search + window.location.hash;
31051
- const mode = (_b4 = options == null ? void 0 : options.mode) != null ? _b4 : "interactive";
30915
+ const redirectTo = (_a66 = options == null ? void 0 : options.redirectTo) != null ? _a66 : window.location.pathname + window.location.search + window.location.hash;
30916
+ const mode = (_b3 = options == null ? void 0 : options.mode) != null ? _b3 : "interactive";
31052
30917
  if (mode === "interactive") {
31053
30918
  clearLogoutIntent();
31054
30919
  }
@@ -31082,14 +30947,14 @@ var AuthProvider = ({ children }) => {
31082
30947
  (0, import_react31.useEffect)(() => {
31083
30948
  let cancelled = false;
31084
30949
  const initializeAuth = async () => {
31085
- var _a68;
30950
+ var _a66;
31086
30951
  const stored = readStoredToken();
31087
30952
  const storedPresence = readStoredPresence();
31088
30953
  setPresenceStatusState(storedPresence);
31089
30954
  if (stored == null ? void 0 : stored.accessToken) {
31090
30955
  if (cancelled) return;
31091
30956
  const hydratedUser = buildUserFromTokens({
31092
- idToken: (_a68 = stored.idToken) != null ? _a68 : void 0,
30957
+ idToken: (_a66 = stored.idToken) != null ? _a66 : void 0,
31093
30958
  accessToken: stored.accessToken
31094
30959
  });
31095
30960
  setAccessToken(stored.accessToken);
@@ -31125,18 +30990,33 @@ var AuthProvider = ({ children }) => {
31125
30990
  };
31126
30991
  }, [attemptSilentLogin]);
31127
30992
  (0, import_react31.useEffect)(() => {
31128
- var _a68;
30993
+ var _a66;
31129
30994
  if (status !== "authenticated") return;
31130
30995
  if (user) return;
31131
30996
  const stored = readStoredToken();
31132
30997
  if (!(stored == null ? void 0 : stored.accessToken)) return;
31133
30998
  const hydratedUser = buildUserFromTokens({
31134
- idToken: (_a68 = stored.idToken) != null ? _a68 : void 0,
30999
+ idToken: (_a66 = stored.idToken) != null ? _a66 : void 0,
31135
31000
  accessToken: stored.accessToken
31136
31001
  });
31137
31002
  if (!hydratedUser) return;
31138
31003
  setUser(hydratedUser);
31139
31004
  }, [status, user]);
31005
+ (0, import_react31.useEffect)(() => {
31006
+ if (typeof window === "undefined") return;
31007
+ const handleProfileAvatarChange = (event) => {
31008
+ const detail = event.detail;
31009
+ writeStoredProfileAvatar({
31010
+ avatarId: detail == null ? void 0 : detail.avatarId,
31011
+ avatarUrl: detail == null ? void 0 : detail.avatarUrl
31012
+ });
31013
+ const nextPicture = readStoredProfileAvatar();
31014
+ if (!nextPicture) return;
31015
+ setUser((current) => current ? { ...current, picture: nextPicture } : current);
31016
+ };
31017
+ window.addEventListener("cupcode:profile-avatar-change", handleProfileAvatarChange);
31018
+ return () => window.removeEventListener("cupcode:profile-avatar-change", handleProfileAvatarChange);
31019
+ }, []);
31140
31020
  (0, import_react31.useEffect)(() => {
31141
31021
  resolvedPresenceIdentityKeyRef.current = null;
31142
31022
  resolvedPresenceUserIdRef.current = null;
@@ -31162,9 +31042,9 @@ var AuthProvider = ({ children }) => {
31162
31042
  table: USER_PRESENCE_TABLE2
31163
31043
  },
31164
31044
  (payload) => {
31165
- var _a68, _b4;
31045
+ var _a66, _b3;
31166
31046
  const row = payload.new || payload.old;
31167
- const rowUserId = toNonEmptyString((_b4 = (_a68 = row == null ? void 0 : row[USER_PRESENCE_USER_ID_COLUMN2]) != null ? _a68 : row == null ? void 0 : row.user_id) != null ? _b4 : row == null ? void 0 : row.id);
31047
+ const rowUserId = toNonEmptyString((_b3 = (_a66 = row == null ? void 0 : row[USER_PRESENCE_USER_ID_COLUMN2]) != null ? _a66 : row == null ? void 0 : row.user_id) != null ? _b3 : row == null ? void 0 : row.id);
31168
31048
  if (!rowUserId || rowUserId !== currentUserId) return;
31169
31049
  if (payload.eventType === "DELETE") {
31170
31050
  storePresenceStatus("offline", "system");
@@ -31238,9 +31118,9 @@ var AuthProvider = ({ children }) => {
31238
31118
  });
31239
31119
  }, [startAuthorization]);
31240
31120
  const completeLogin = (0, import_react31.useCallback)(async () => {
31241
- var _a68;
31121
+ var _a66;
31242
31122
  const params = new URLSearchParams(window.location.search);
31243
- const redirectTo = (_a68 = sessionStorage.getItem(STORAGE_KEYS.redirect)) != null ? _a68 : "/";
31123
+ const redirectTo = (_a66 = sessionStorage.getItem(STORAGE_KEYS.redirect)) != null ? _a66 : "/";
31244
31124
  const authMode = sessionStorage.getItem(STORAGE_KEYS.authMode);
31245
31125
  const isSilentAuth = authMode === "silent";
31246
31126
  const error = params.get("error");
@@ -31309,11 +31189,11 @@ var AuthProvider = ({ children }) => {
31309
31189
  }
31310
31190
  }, [clearAuthFlowState]);
31311
31191
  const logout = (0, import_react31.useCallback)(async () => {
31312
- var _a68, _b4;
31192
+ var _a66, _b3;
31313
31193
  const config = getAccountsConfig();
31314
31194
  const { logoutUrl } = await resolveOidcEndpoints(config);
31315
- const idToken = (_a68 = sessionStorage.getItem(STORAGE_KEYS.idToken)) != null ? _a68 : void 0;
31316
- const refreshToken = (_b4 = sessionStorage.getItem(STORAGE_KEYS.refreshToken)) != null ? _b4 : void 0;
31195
+ const idToken = (_a66 = sessionStorage.getItem(STORAGE_KEYS.idToken)) != null ? _a66 : void 0;
31196
+ const refreshToken = (_b3 = sessionStorage.getItem(STORAGE_KEYS.refreshToken)) != null ? _b3 : void 0;
31317
31197
  const currentUser = user;
31318
31198
  await setPresenceNetworkStatus("offline", "system", currentUser);
31319
31199
  clearTokens();