@cupcodev/ui 1.2.1 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -708,10 +708,10 @@ var Dock = ({ items, className }) => {
708
708
  const itemsRef = useRef3([]);
709
709
  const OVERSHOOT = 5;
710
710
  useEffect3(() => {
711
- var _a60;
711
+ var _a58;
712
712
  const activeItem = itemsRef.current[activeIndex];
713
713
  if (!activeItem) return;
714
- const containerRect = (_a60 = activeItem.parentElement) == null ? void 0 : _a60.getBoundingClientRect();
714
+ const containerRect = (_a58 = activeItem.parentElement) == null ? void 0 : _a58.getBoundingClientRect();
715
715
  const itemRect = activeItem.getBoundingClientRect();
716
716
  if (!containerRect) return;
717
717
  const relativeLeft = itemRect.left - containerRect.left;
@@ -773,9 +773,9 @@ var Dock = ({ items, className }) => {
773
773
  "button",
774
774
  {
775
775
  onClick: () => {
776
- var _a60;
776
+ var _a58;
777
777
  setActiveIndex(index);
778
- (_a60 = item.onClick) == null ? void 0 : _a60.call(item);
778
+ (_a58 = item.onClick) == null ? void 0 : _a58.call(item);
779
779
  },
780
780
  className: cn(
781
781
  "flex items-center justify-center w-12 h-12 rounded-xl",
@@ -808,9 +808,62 @@ import { useEffect as useEffect5, useRef as useRef4, useMemo } from "react";
808
808
 
809
809
  // src/hooks/useTelescupAsset.ts
810
810
  import { useState as useState2, useEffect as useEffect4 } from "react";
811
- var import_meta = {};
812
- var _a;
813
- var API_BASE = ((_a = import_meta.env.VITE_TELESCUP_API_BASE) != null ? _a : "https://cdn.cupcode.com.br").replace(/\/+$/, "");
811
+
812
+ // src/lib/runtimeEnv.ts
813
+ var runtimeStore = {};
814
+ var normalizeValue = (value) => {
815
+ if (value === null || typeof value === "undefined") return void 0;
816
+ if (typeof value === "string") {
817
+ const trimmed = value.trim();
818
+ return trimmed === "" ? void 0 : trimmed;
819
+ }
820
+ return String(value);
821
+ };
822
+ var setCupcodeRuntimeEnv = (values) => {
823
+ var _a58;
824
+ const globalRef = globalThis;
825
+ const nextGlobalEnv = { ...(_a58 = globalRef.__CUPCODE_ENV__) != null ? _a58 : {} };
826
+ Object.entries(values).forEach(([key, value]) => {
827
+ const normalized = normalizeValue(value);
828
+ runtimeStore[key] = normalized;
829
+ nextGlobalEnv[key] = normalized;
830
+ });
831
+ globalRef.__CUPCODE_ENV__ = nextGlobalEnv;
832
+ };
833
+ var readFromProcessEnv = (key) => {
834
+ var _a58;
835
+ const processEnv = (_a58 = globalThis.process) == null ? void 0 : _a58.env;
836
+ return normalizeValue(processEnv == null ? void 0 : processEnv[key]);
837
+ };
838
+ var getRuntimeEnv = (key) => {
839
+ var _a58;
840
+ const normalizedKey = key.trim();
841
+ if (!normalizedKey) return void 0;
842
+ const fromRuntimeStore = runtimeStore[normalizedKey];
843
+ if (fromRuntimeStore) return fromRuntimeStore;
844
+ const fromGlobalStore = normalizeValue((_a58 = globalThis.__CUPCODE_ENV__) == null ? void 0 : _a58[normalizedKey]);
845
+ if (fromGlobalStore) return fromGlobalStore;
846
+ const fromGlobalKey = normalizeValue(globalThis[normalizedKey]);
847
+ if (fromGlobalKey) return fromGlobalKey;
848
+ return readFromProcessEnv(normalizedKey);
849
+ };
850
+ var getRuntimeEnvOr = (key, fallback) => {
851
+ var _a58;
852
+ return (_a58 = getRuntimeEnv(key)) != null ? _a58 : fallback;
853
+ };
854
+ var isRuntimeDev = () => {
855
+ var _a58, _b5, _c;
856
+ const explicitDev = (_a58 = getRuntimeEnv("DEV")) != null ? _a58 : getRuntimeEnv("VITE_DEV");
857
+ if (explicitDev) {
858
+ const normalized = explicitDev.toLowerCase();
859
+ return normalized === "1" || normalized === "true";
860
+ }
861
+ const mode = ((_c = (_b5 = getRuntimeEnv("MODE")) != null ? _b5 : getRuntimeEnv("NODE_ENV")) != null ? _c : "").toLowerCase();
862
+ return mode === "development";
863
+ };
864
+
865
+ // src/hooks/useTelescupAsset.ts
866
+ var getApiBase = () => getRuntimeEnvOr("VITE_TELESCUP_API_BASE", "https://cdn.cupcode.com.br").replace(/\/+$/, "");
814
867
  function buildTelescupImageURL(options) {
815
868
  const { id, width, height, fit = "cover", format = "avif", quality = 60 } = options;
816
869
  const params = new URLSearchParams({ id });
@@ -819,10 +872,10 @@ function buildTelescupImageURL(options) {
819
872
  params.set("fit", fit);
820
873
  params.set("format", format);
821
874
  params.set("q", quality.toString());
822
- return `${API_BASE}/i?${params.toString()}`;
875
+ return `${getApiBase()}/i?${params.toString()}`;
823
876
  }
824
877
  function buildTelescupVideoURL(id) {
825
- return `${API_BASE}/i/v?id=${id}`;
878
+ return `${getApiBase()}/i/v?id=${id}`;
826
879
  }
827
880
  function useTelescupMeta(id, lang = "pt-BR") {
828
881
  const [meta, setMeta] = useState2({});
@@ -831,7 +884,7 @@ function useTelescupMeta(id, lang = "pt-BR") {
831
884
  async function fetchMeta() {
832
885
  try {
833
886
  const response = await fetch(
834
- `${API_BASE}/i/meta?${new URLSearchParams({ id, lang })}`
887
+ `${getApiBase()}/i/meta?${new URLSearchParams({ id, lang })}`
835
888
  );
836
889
  if (response.ok) {
837
890
  const data = await response.json();
@@ -863,15 +916,15 @@ var isUuid = (value) => {
863
916
  return UUID_REGEX.test(value.trim());
864
917
  };
865
918
  function parseAssetId(input) {
866
- var _a60, _b6, _c, _d;
919
+ var _a58, _b5, _c, _d;
867
920
  const raw = input == null ? void 0 : input.trim();
868
921
  if (!raw) return void 0;
869
922
  if (UUID_REGEX.test(raw)) return raw;
870
- const matchFromRaw = (_a60 = raw.match(UUID_IN_TEXT_REGEX)) == null ? void 0 : _a60[0];
923
+ const matchFromRaw = (_a58 = raw.match(UUID_IN_TEXT_REGEX)) == null ? void 0 : _a58[0];
871
924
  if (isUuid(matchFromRaw)) return matchFromRaw;
872
925
  try {
873
926
  const url = new URL(raw);
874
- const queryParamId = (_c = (_b6 = url.searchParams.get("id")) != null ? _b6 : url.searchParams.get("asset_id")) != null ? _c : url.searchParams.get("assetId");
927
+ const queryParamId = (_c = (_b5 = url.searchParams.get("id")) != null ? _b5 : url.searchParams.get("asset_id")) != null ? _c : url.searchParams.get("assetId");
875
928
  if (isUuid(queryParamId)) return queryParamId;
876
929
  const matchFromPath = (_d = url.pathname.match(UUID_IN_TEXT_REGEX)) == null ? void 0 : _d[0];
877
930
  if (isUuid(matchFromPath)) return matchFromPath;
@@ -938,7 +991,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
938
991
  return void 0;
939
992
  }, [sortedCategories]);
940
993
  useEffect5(() => {
941
- var _a60;
994
+ var _a58;
942
995
  const root = rootRef.current;
943
996
  if (!root) return;
944
997
  const $ = (sel) => root.querySelector(sel);
@@ -950,7 +1003,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
950
1003
  const getDockItems = () => Array.from(root.querySelectorAll(INTERACTIVE_SELECTOR));
951
1004
  const dockItems = getDockItems();
952
1005
  if (!tabbar || !dock || !listMenuShow || !tabbarUl || dockItems.length === 0) return;
953
- const persistentId = (_a60 = activeCategoryId != null ? activeCategoryId : lastInteractiveId) != null ? _a60 : null;
1006
+ const persistentId = (_a58 = activeCategoryId != null ? activeCategoryId : lastInteractiveId) != null ? _a58 : null;
954
1007
  let openItem = null;
955
1008
  let latestToggleToken = null;
956
1009
  const persistentSelector = persistentId != null ? `${INTERACTIVE_SELECTOR}[data-cat-id="${persistentId}"]` : null;
@@ -1249,8 +1302,8 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
1249
1302
  }, total);
1250
1303
  }
1251
1304
  const hideBootstrapTooltip = (el) => {
1252
- var _a61, _b6;
1253
- const tooltip = ((_b6 = (_a61 = window.bootstrap) == null ? void 0 : _a61.Tooltip) == null ? void 0 : _b6.getInstance) ? window.bootstrap.Tooltip.getInstance(el) : null;
1305
+ var _a59, _b5;
1306
+ const tooltip = ((_b5 = (_a59 = window.bootstrap) == null ? void 0 : _a59.Tooltip) == null ? void 0 : _b5.getInstance) ? window.bootstrap.Tooltip.getInstance(el) : null;
1254
1307
  tooltip == null ? void 0 : tooltip.hide();
1255
1308
  };
1256
1309
  const openMenuForItem = (item, menu) => {
@@ -1268,14 +1321,14 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
1268
1321
  latestToggleToken = null;
1269
1322
  };
1270
1323
  const closeActiveMenu = (opts = {}) => {
1271
- var _a61;
1324
+ var _a59;
1272
1325
  if (!opts.onClosed) {
1273
1326
  latestToggleToken = null;
1274
1327
  }
1275
1328
  const itemToClose = openItem;
1276
1329
  if (!itemToClose) {
1277
1330
  if (!opts.preserveWrapper) ensurePersistentHighlight();
1278
- (_a61 = opts.onClosed) == null ? void 0 : _a61.call(opts);
1331
+ (_a59 = opts.onClosed) == null ? void 0 : _a59.call(opts);
1279
1332
  return;
1280
1333
  }
1281
1334
  const menu = getMenuFor(itemToClose);
@@ -1283,7 +1336,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
1283
1336
  itemToClose.classList.remove("active");
1284
1337
  delete itemToClose.dataset.menuOpen;
1285
1338
  const finalize = () => {
1286
- var _a62;
1339
+ var _a60;
1287
1340
  if (!opts.preserveWrapper) {
1288
1341
  listMenuShow.classList.remove("show");
1289
1342
  tabbar.classList.remove("is-active-menu");
@@ -1291,7 +1344,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
1291
1344
  setTabbarTheme(null);
1292
1345
  ensurePersistentHighlight();
1293
1346
  }
1294
- (_a62 = opts.onClosed) == null ? void 0 : _a62.call(opts);
1347
+ (_a60 = opts.onClosed) == null ? void 0 : _a60.call(opts);
1295
1348
  };
1296
1349
  closeMenu(menu, finalize);
1297
1350
  };
@@ -1394,7 +1447,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
1394
1447
  /* @__PURE__ */ jsx10("div", { className: "glass-overlay" }),
1395
1448
  /* @__PURE__ */ jsx10("div", { className: "glass-specular" }),
1396
1449
  /* @__PURE__ */ jsx10("ul", { className: "flex-center", children: sortedCategories.map((cat) => {
1397
- var _a60;
1450
+ var _a58;
1398
1451
  if (cat.type === "divider") {
1399
1452
  return /* @__PURE__ */ jsx10(
1400
1453
  "li",
@@ -1406,7 +1459,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
1406
1459
  cat.id
1407
1460
  );
1408
1461
  }
1409
- const hasCards = (((_a60 = cat.cards) == null ? void 0 : _a60.length) || 0) > 0;
1462
+ const hasCards = (((_a58 = cat.cards) == null ? void 0 : _a58.length) || 0) > 0;
1410
1463
  const link = cat.href;
1411
1464
  const isCurrent = cat.id === activeCategoryId;
1412
1465
  return /* @__PURE__ */ jsxs8(
@@ -1440,12 +1493,12 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
1440
1493
  );
1441
1494
  }) }),
1442
1495
  /* @__PURE__ */ jsx10("div", { className: "list-menu-mob-show", children: sortedCategories.filter((cat) => {
1443
- var _a60;
1444
- return cat.type !== "divider" && (((_a60 = cat.cards) == null ? void 0 : _a60.length) || 0) > 0;
1496
+ var _a58;
1497
+ return cat.type !== "divider" && (((_a58 = cat.cards) == null ? void 0 : _a58.length) || 0) > 0;
1445
1498
  }).map((cat) => {
1446
- var _a60;
1447
- return /* @__PURE__ */ jsx10("div", { className: "mob-list-menu hide", "data-tagget": cat.slug, children: /* @__PURE__ */ jsx10("div", { className: `submenu-stack ${cat.slug}`, children: ((_a60 = cat.cards) != null ? _a60 : []).map((card, i) => {
1448
- var _a61;
1499
+ var _a58;
1500
+ return /* @__PURE__ */ jsx10("div", { className: "mob-list-menu hide", "data-tagget": cat.slug, children: /* @__PURE__ */ jsx10("div", { className: `submenu-stack ${cat.slug}`, children: ((_a58 = cat.cards) != null ? _a58 : []).map((card, i) => {
1501
+ var _a59;
1449
1502
  return /* @__PURE__ */ jsxs8(
1450
1503
  "div",
1451
1504
  {
@@ -1461,8 +1514,8 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
1461
1514
  /* @__PURE__ */ jsx10("div", { className: "title", children: card.title }),
1462
1515
  card.description ? /* @__PURE__ */ jsx10("div", { className: "description", children: card.description }) : null
1463
1516
  ] }),
1464
- /* @__PURE__ */ jsx10("div", { className: "actions", children: ((_a61 = card.buttons) != null ? _a61 : []).slice(0, 2).map((btn, idx) => {
1465
- var _a62, _b6, _c, _d;
1517
+ /* @__PURE__ */ jsx10("div", { className: "actions", children: ((_a59 = card.buttons) != null ? _a59 : []).slice(0, 2).map((btn, idx) => {
1518
+ var _a60, _b5, _c, _d;
1466
1519
  const className = idx === 0 ? "saiba-mais" : "saiba-mais-1";
1467
1520
  if (btn.type === "popup") {
1468
1521
  return /* @__PURE__ */ jsx10(
@@ -1477,7 +1530,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
1477
1530
  window.dispatchEvent(new Event(`qw:open:${btn.popupId}`));
1478
1531
  }
1479
1532
  },
1480
- children: (_a62 = btn.label) != null ? _a62 : "Abrir"
1533
+ children: (_a60 = btn.label) != null ? _a60 : "Abrir"
1481
1534
  },
1482
1535
  `${cat.id}-card-${i}-btn-${idx}`
1483
1536
  );
@@ -1487,7 +1540,7 @@ var DockWrapper = ({ categories, activeCategoryId }) => {
1487
1540
  {
1488
1541
  href: btn.href || "#",
1489
1542
  className,
1490
- target: ((_b6 = btn.href) == null ? void 0 : _b6.startsWith("http")) ? "_blank" : void 0,
1543
+ target: ((_b5 = btn.href) == null ? void 0 : _b5.startsWith("http")) ? "_blank" : void 0,
1491
1544
  rel: ((_c = btn.href) == null ? void 0 : _c.startsWith("http")) ? "noopener noreferrer" : void 0,
1492
1545
  children: (_d = btn.label) != null ? _d : "Saiba mais >"
1493
1546
  },
@@ -2254,8 +2307,8 @@ var NavbarCupcode = ({
2254
2307
  isActive && "text-primary after:w-full"
2255
2308
  );
2256
2309
  const handleClick = (event) => {
2257
- var _a60;
2258
- (_a60 = item.onClick) == null ? void 0 : _a60.call(item, event);
2310
+ var _a58;
2311
+ (_a58 = item.onClick) == null ? void 0 : _a58.call(item, event);
2259
2312
  };
2260
2313
  if (item.href.startsWith("#")) {
2261
2314
  return /* @__PURE__ */ jsxs17(
@@ -2307,8 +2360,8 @@ var NavbarCupcode = ({
2307
2360
  isActive && "text-primary"
2308
2361
  );
2309
2362
  const handleClick = (event) => {
2310
- var _a60;
2311
- (_a60 = item.onClick) == null ? void 0 : _a60.call(item, event);
2363
+ var _a58;
2364
+ (_a58 = item.onClick) == null ? void 0 : _a58.call(item, event);
2312
2365
  setIsOpen(false);
2313
2366
  };
2314
2367
  if (item.href.startsWith("#")) {
@@ -2382,10 +2435,10 @@ function isThemeMode(value) {
2382
2435
  return value === "light" || value === "dark";
2383
2436
  }
2384
2437
  function readStoredTheme() {
2385
- var _a60;
2438
+ var _a58;
2386
2439
  if (typeof window === "undefined") return null;
2387
2440
  try {
2388
- const storedTheme = (_a60 = window.localStorage.getItem(THEME_STORAGE_KEY)) != null ? _a60 : window.localStorage.getItem("theme");
2441
+ const storedTheme = (_a58 = window.localStorage.getItem(THEME_STORAGE_KEY)) != null ? _a58 : window.localStorage.getItem("theme");
2389
2442
  return isThemeMode(storedTheme) ? storedTheme : null;
2390
2443
  } catch (e) {
2391
2444
  return null;
@@ -2422,11 +2475,11 @@ var ThemeToggle = ({
2422
2475
  defaultTheme = "light",
2423
2476
  onThemeChange
2424
2477
  }) => {
2425
- var _a60;
2478
+ var _a58;
2426
2479
  const [mounted, setMounted] = React11.useState(false);
2427
2480
  const [internalTheme, setInternalTheme] = React11.useState(defaultTheme);
2428
2481
  const isControlled = typeof theme !== "undefined";
2429
- const activeTheme = (_a60 = isControlled ? theme : internalTheme) != null ? _a60 : defaultTheme;
2482
+ const activeTheme = (_a58 = isControlled ? theme : internalTheme) != null ? _a58 : defaultTheme;
2430
2483
  React11.useEffect(() => {
2431
2484
  if (!isControlled) {
2432
2485
  setInternalTheme(resolveTheme(defaultTheme));
@@ -3142,7 +3195,6 @@ function useToast() {
3142
3195
  import React29, { useCallback as useCallback4, useEffect as useEffect13, useMemo as useMemo6, useState as useState11 } from "react";
3143
3196
 
3144
3197
  // src/lib/telescupClient.ts
3145
- var import_meta2 = {};
3146
3198
  var TelescupClientError = class extends Error {
3147
3199
  constructor(message, opts) {
3148
3200
  super(message);
@@ -3157,39 +3209,39 @@ var TelescupClientError = class extends Error {
3157
3209
  };
3158
3210
  var normalizeBaseUrl = (baseUrl) => baseUrl.replace(/\/+$/, "");
3159
3211
  var joinUrl = (base, path) => path.startsWith("/") ? `${base}${path}` : `${base}/${path}`;
3160
- var _a2;
3161
- var SUPABASE_URL = (_a2 = import_meta2.env.VITE_SUPABASE_URL) == null ? void 0 : _a2.trim();
3162
- var _a3, _b;
3163
- var SUPABASE_ANON_KEY = (_b = (_a3 = import_meta2.env.VITE_SUPABASE_ANON_KEY) != null ? _a3 : import_meta2.env.VITE_SUPABASE_PUBLISHABLE_KEY) == null ? void 0 : _b.trim();
3212
+ var _a;
3213
+ var SUPABASE_URL = (_a = getRuntimeEnv("VITE_SUPABASE_URL")) == null ? void 0 : _a.trim();
3214
+ var _a2, _b;
3215
+ var SUPABASE_ANON_KEY = (_b = (_a2 = getRuntimeEnv("VITE_SUPABASE_ANON_KEY")) != null ? _a2 : getRuntimeEnv("VITE_SUPABASE_PUBLISHABLE_KEY")) == null ? void 0 : _b.trim();
3164
3216
  var SUPABASE_URL_NORMALIZED = SUPABASE_URL ? normalizeBaseUrl(SUPABASE_URL) : void 0;
3165
3217
  var DEV_REST_PROXY_BASE_URL = "/rest/v1";
3166
3218
  var UUID_REGEX2 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
3167
- var _a4, _b2;
3168
- var TELESCUP_MANAGER_FIRST = ((_b2 = (_a4 = import_meta2.env.VITE_TELESCUP_MANAGER_FIRST) == null ? void 0 : _a4.trim().toLowerCase()) != null ? _b2 : "true") !== "false";
3219
+ var _a3, _b2;
3220
+ var TELESCUP_MANAGER_FIRST = ((_b2 = (_a3 = getRuntimeEnv("VITE_TELESCUP_MANAGER_FIRST")) == null ? void 0 : _a3.trim().toLowerCase()) != null ? _b2 : "true") !== "false";
3221
+ var _a4;
3222
+ var TELESCUP_LIST_FUNCTION = ((_a4 = getRuntimeEnv("VITE_TELESCUP_LIST_FUNCTION")) == null ? void 0 : _a4.trim()) || "telescup-assets-list";
3169
3223
  var _a5;
3170
- var TELESCUP_LIST_FUNCTION = ((_a5 = import_meta2.env.VITE_TELESCUP_LIST_FUNCTION) == null ? void 0 : _a5.trim()) || "telescup-assets-list";
3224
+ var TELESCUP_UPLOAD_INIT_FUNCTION = ((_a5 = getRuntimeEnv("VITE_TELESCUP_UPLOAD_INIT_FUNCTION")) == null ? void 0 : _a5.trim()) || "telescup-upload-init";
3171
3225
  var _a6;
3172
- var TELESCUP_UPLOAD_INIT_FUNCTION = ((_a6 = import_meta2.env.VITE_TELESCUP_UPLOAD_INIT_FUNCTION) == null ? void 0 : _a6.trim()) || "telescup-upload-init";
3226
+ var TELESCUP_UPLOAD_COMPLETE_FUNCTION = ((_a6 = getRuntimeEnv("VITE_TELESCUP_UPLOAD_COMPLETE_FUNCTION")) == null ? void 0 : _a6.trim()) || "telescup-upload-complete";
3173
3227
  var _a7;
3174
- var TELESCUP_UPLOAD_COMPLETE_FUNCTION = ((_a7 = import_meta2.env.VITE_TELESCUP_UPLOAD_COMPLETE_FUNCTION) == null ? void 0 : _a7.trim()) || "telescup-upload-complete";
3228
+ var TELESCUP_UPDATE_META_FUNCTION = ((_a7 = getRuntimeEnv("VITE_TELESCUP_UPDATE_META_FUNCTION")) == null ? void 0 : _a7.trim()) || "telescup-assets-update-meta";
3175
3229
  var _a8;
3176
- var TELESCUP_UPDATE_META_FUNCTION = ((_a8 = import_meta2.env.VITE_TELESCUP_UPDATE_META_FUNCTION) == null ? void 0 : _a8.trim()) || "telescup-assets-update-meta";
3230
+ var TELESCUP_UPLOAD_DIRECT_FUNCTION = ((_a8 = getRuntimeEnv("VITE_TELESCUP_UPLOAD_DIRECT_FUNCTION")) == null ? void 0 : _a8.trim()) || "asset-api/upload";
3177
3231
  var _a9;
3178
- var TELESCUP_UPLOAD_DIRECT_FUNCTION = ((_a9 = import_meta2.env.VITE_TELESCUP_UPLOAD_DIRECT_FUNCTION) == null ? void 0 : _a9.trim()) || "asset-api/upload";
3179
- var _a10;
3180
- var TELESCUP_SEARCH_DEFAULT_QUERY = ((_a10 = import_meta2.env.VITE_TELESCUP_SEARCH_DEFAULT_QUERY) == null ? void 0 : _a10.trim()) || "images";
3181
- var _a11, _b3;
3182
- var TELESCUP_PREFER_RPC = ((_b3 = (_a11 = import_meta2.env.VITE_TELESCUP_PREFER_RPC) == null ? void 0 : _a11.trim().toLowerCase()) != null ? _b3 : "false") === "true";
3183
- var _a12;
3184
- var TELESCUP_ASSET_API_FACET_SEED_LIMIT_RAW = Number((_a12 = import_meta2.env.VITE_TELESCUP_FACET_SEED_LIMIT) != null ? _a12 : "120");
3232
+ var TELESCUP_SEARCH_DEFAULT_QUERY = ((_a9 = getRuntimeEnv("VITE_TELESCUP_SEARCH_DEFAULT_QUERY")) == null ? void 0 : _a9.trim()) || "images";
3233
+ var _a10, _b3;
3234
+ var TELESCUP_PREFER_RPC = ((_b3 = (_a10 = getRuntimeEnv("VITE_TELESCUP_PREFER_RPC")) == null ? void 0 : _a10.trim().toLowerCase()) != null ? _b3 : "false") === "true";
3235
+ var _a11;
3236
+ var TELESCUP_ASSET_API_FACET_SEED_LIMIT_RAW = Number((_a11 = getRuntimeEnv("VITE_TELESCUP_FACET_SEED_LIMIT")) != null ? _a11 : "120");
3185
3237
  var TELESCUP_ASSET_API_FACET_SEED_LIMIT = Math.min(
3186
3238
  500,
3187
3239
  Math.max(50, Number.isFinite(TELESCUP_ASSET_API_FACET_SEED_LIMIT_RAW) ? Math.floor(TELESCUP_ASSET_API_FACET_SEED_LIMIT_RAW) : 120)
3188
3240
  );
3241
+ var _a12;
3242
+ var TELESCUP_DB_SCHEMA = ((_a12 = getRuntimeEnv("VITE_TELESCUP_SCHEMA")) != null ? _a12 : "telescup").trim() || "telescup";
3189
3243
  var _a13;
3190
- var TELESCUP_DB_SCHEMA = ((_a13 = import_meta2.env.VITE_TELESCUP_SCHEMA) != null ? _a13 : "telescup").trim() || "telescup";
3191
- var _a14;
3192
- var TELESCUP_RPC_SCHEMA = ((_a14 = import_meta2.env.VITE_TELESCUP_RPC_SCHEMA) != null ? _a14 : TELESCUP_DB_SCHEMA).trim() || TELESCUP_DB_SCHEMA;
3244
+ var TELESCUP_RPC_SCHEMA = ((_a13 = getRuntimeEnv("VITE_TELESCUP_RPC_SCHEMA")) != null ? _a13 : TELESCUP_DB_SCHEMA).trim() || TELESCUP_DB_SCHEMA;
3193
3245
  var TELESCUP_DB_PROFILES = [TELESCUP_DB_SCHEMA];
3194
3246
  var TELESCUP_TABLE_FACET_LIMIT = 1e3;
3195
3247
  var TELESCUP_DENIED_TABLE_CACHE = /* @__PURE__ */ new Set();
@@ -3289,12 +3341,12 @@ var rpcPreferredSchema = TELESCUP_RPC_SCHEMA;
3289
3341
  var RPC_MISSING_SCHEMAS_BY_PATH = /* @__PURE__ */ new Map();
3290
3342
  var FUNCTION_NOT_FOUND_CACHE = /* @__PURE__ */ new Set();
3291
3343
  var buildRestHeaders = (token, options) => {
3292
- var _a60;
3344
+ var _a58;
3293
3345
  const headers = {};
3294
3346
  if (SUPABASE_ANON_KEY) {
3295
3347
  headers.apikey = SUPABASE_ANON_KEY;
3296
3348
  }
3297
- const authorizationToken = (_a60 = resolveRpcAuthorizationToken(token)) != null ? _a60 : token;
3349
+ const authorizationToken = (_a58 = resolveRpcAuthorizationToken(token)) != null ? _a58 : token;
3298
3350
  if (authorizationToken) {
3299
3351
  headers.Authorization = `Bearer ${authorizationToken}`;
3300
3352
  }
@@ -3312,7 +3364,7 @@ var buildRestHeaders = (token, options) => {
3312
3364
  };
3313
3365
  var resolveRpcBaseUrl = (baseUrl) => {
3314
3366
  const functionsBaseUrl = resolveFunctionsBaseUrl(baseUrl);
3315
- if (import_meta2.env.DEV && functionsBaseUrl.startsWith("/functions/v1")) {
3367
+ if (isRuntimeDev() && functionsBaseUrl.startsWith("/functions/v1")) {
3316
3368
  return DEV_REST_PROXY_BASE_URL;
3317
3369
  }
3318
3370
  if (SUPABASE_URL) {
@@ -3429,22 +3481,22 @@ var parseAssetSize = (value) => {
3429
3481
  return Number.isFinite(parsed) ? parsed : void 0;
3430
3482
  };
3431
3483
  var getFileExtension = (filename) => {
3432
- var _a60;
3484
+ var _a58;
3433
3485
  if (!filename) return void 0;
3434
3486
  const parts = filename.split(".");
3435
3487
  if (parts.length < 2) return void 0;
3436
- const candidate = (_a60 = parts[parts.length - 1]) == null ? void 0 : _a60.trim().toLowerCase();
3488
+ const candidate = (_a58 = parts[parts.length - 1]) == null ? void 0 : _a58.trim().toLowerCase();
3437
3489
  return candidate || void 0;
3438
3490
  };
3439
3491
  var resolveCategory = (row, activeMeta) => {
3440
- var _a60;
3441
- return (_a60 = readString(row.category)) != null ? _a60 : readString(activeMeta.category);
3492
+ var _a58;
3493
+ return (_a58 = readString(row.category)) != null ? _a58 : readString(activeMeta.category);
3442
3494
  };
3443
3495
  var resolveFolderName = (row) => readString(row.folder_name);
3444
3496
  var toTelescupAsset = (row, selectedLanguage) => {
3445
- var _a60, _b6, _c, _d, _e;
3497
+ var _a58, _b5, _c, _d, _e;
3446
3498
  const metaByLang = normalizeMetaByLanguage(row.meta);
3447
- const activeMeta = (_b6 = (_a60 = metaByLang[selectedLanguage]) != null ? _a60 : metaByLang.pt) != null ? _b6 : {};
3499
+ const activeMeta = (_b5 = (_a58 = metaByLang[selectedLanguage]) != null ? _a58 : metaByLang.pt) != null ? _b5 : {};
3448
3500
  return {
3449
3501
  id: (_c = row.id) != null ? _c : "",
3450
3502
  name: row.filename,
@@ -3470,14 +3522,14 @@ var buildFacetsFromItems = (items) => {
3470
3522
  const extensions = /* @__PURE__ */ new Map();
3471
3523
  const tags = /* @__PURE__ */ new Map();
3472
3524
  items.forEach((item) => {
3473
- var _a60, _b6, _c, _d, _e, _f, _g;
3525
+ var _a58, _b5, _c, _d, _e, _f, _g;
3474
3526
  if (item.category) {
3475
- categories.set(item.category, ((_a60 = categories.get(item.category)) != null ? _a60 : 0) + 1);
3527
+ categories.set(item.category, ((_a58 = categories.get(item.category)) != null ? _a58 : 0) + 1);
3476
3528
  }
3477
3529
  if (item.folderId) {
3478
3530
  const current = folders.get(item.folderId);
3479
3531
  folders.set(item.folderId, {
3480
- label: (_b6 = item.folderName) != null ? _b6 : current == null ? void 0 : current.label,
3532
+ label: (_b5 = item.folderName) != null ? _b5 : current == null ? void 0 : current.label,
3481
3533
  count: ((_c = current == null ? void 0 : current.count) != null ? _c : 0) + 1
3482
3534
  });
3483
3535
  }
@@ -3488,16 +3540,16 @@ var buildFacetsFromItems = (items) => {
3488
3540
  extensions.set(item.extension, ((_e = extensions.get(item.extension)) != null ? _e : 0) + 1);
3489
3541
  }
3490
3542
  (_g = (_f = item.meta) == null ? void 0 : _f.tags) == null ? void 0 : _g.forEach((tag) => {
3491
- var _a61;
3543
+ var _a59;
3492
3544
  const normalizedTag = tag.trim();
3493
3545
  if (!normalizedTag) return;
3494
- tags.set(normalizedTag, ((_a61 = tags.get(normalizedTag)) != null ? _a61 : 0) + 1);
3546
+ tags.set(normalizedTag, ((_a59 = tags.get(normalizedTag)) != null ? _a59 : 0) + 1);
3495
3547
  });
3496
3548
  });
3497
3549
  const toFacetValues = (map) => Array.from(map.entries()).map(([value, count2]) => ({ value, count: count2 })).sort((a, b) => a.value.localeCompare(b.value));
3498
3550
  const toFolderFacetValues = (map) => Array.from(map.entries()).map(([value, info]) => ({ value, label: info.label, count: info.count })).sort((a, b) => {
3499
- var _a60, _b6;
3500
- return ((_a60 = a.label) != null ? _a60 : a.value).localeCompare((_b6 = b.label) != null ? _b6 : b.value);
3551
+ var _a58, _b5;
3552
+ return ((_a58 = a.label) != null ? _a58 : a.value).localeCompare((_b5 = b.label) != null ? _b5 : b.value);
3501
3553
  });
3502
3554
  return {
3503
3555
  categories: toFacetValues(categories),
@@ -3515,7 +3567,7 @@ var isManagerScopeRetryable = (error) => {
3515
3567
  return /permission|not allowed|wrong key type|insufficient|unauthorized/i.test(detailsText);
3516
3568
  };
3517
3569
  async function listAssetsViaRpc(config, filters) {
3518
- var _a60, _b6, _c, _d, _e, _f, _g, _h, _i;
3570
+ var _a58, _b5, _c, _d, _e, _f, _g, _h, _i;
3519
3571
  if (!SUPABASE_ANON_KEY) {
3520
3572
  throw new TelescupClientError(
3521
3573
  "VITE_SUPABASE_ANON_KEY (ou VITE_SUPABASE_PUBLISHABLE_KEY) n\xE3o encontrado para fallback RPC do Telescup."
@@ -3535,11 +3587,11 @@ async function listAssetsViaRpc(config, filters) {
3535
3587
  }
3536
3588
  const shouldLoadFacetTables = isSupabaseAccessToken(token);
3537
3589
  const pageSize = Math.min(100, Math.max(1, toPositiveInt(filters.pageSize, 24)));
3538
- const page = toPositiveInt((_a60 = filters.cursor) != null ? _a60 : filters.page, 1);
3590
+ const page = toPositiveInt((_a58 = filters.cursor) != null ? _a58 : filters.page, 1);
3539
3591
  const selectedLanguage = normalizeLanguageKey(filters.language);
3540
3592
  const bodyBase = {
3541
3593
  p_user_id: userId,
3542
- p_query: (_b6 = filters.query) != null ? _b6 : null,
3594
+ p_query: (_b5 = filters.query) != null ? _b5 : null,
3543
3595
  p_page: page,
3544
3596
  p_page_size: pageSize,
3545
3597
  p_type: filters.type && filters.type !== "all" ? filters.type : null,
@@ -3635,13 +3687,13 @@ var getRpcSchemaCandidates = (rpcPath) => {
3635
3687
  return filtered.length ? filtered : ordered;
3636
3688
  };
3637
3689
  var markRpcSchemaMissing = (rpcPath, schema) => {
3638
- var _a60;
3639
- const set = (_a60 = RPC_MISSING_SCHEMAS_BY_PATH.get(rpcPath)) != null ? _a60 : /* @__PURE__ */ new Set();
3690
+ var _a58;
3691
+ const set = (_a58 = RPC_MISSING_SCHEMAS_BY_PATH.get(rpcPath)) != null ? _a58 : /* @__PURE__ */ new Set();
3640
3692
  set.add(schema);
3641
3693
  RPC_MISSING_SCHEMAS_BY_PATH.set(rpcPath, set);
3642
3694
  };
3643
3695
  async function requestRpc(config, rpcPath, payload) {
3644
- var _a60, _b6;
3696
+ var _a58, _b5;
3645
3697
  if (!SUPABASE_ANON_KEY) {
3646
3698
  throw new TelescupClientError(
3647
3699
  "VITE_SUPABASE_ANON_KEY (ou VITE_SUPABASE_PUBLISHABLE_KEY) n\xE3o encontrado para fallback RPC do Telescup."
@@ -3684,7 +3736,7 @@ async function requestRpc(config, rpcPath, payload) {
3684
3736
  throw new TelescupClientError(`Falha de rede ao chamar RPC ${rpcPath}.`, { details: error });
3685
3737
  }
3686
3738
  if (response.ok) {
3687
- const contentType = (_a60 = response.headers.get("content-type")) != null ? _a60 : "";
3739
+ const contentType = (_a58 = response.headers.get("content-type")) != null ? _a58 : "";
3688
3740
  if (!contentType.includes("application/json")) {
3689
3741
  const text = await response.text();
3690
3742
  if (!text) return {};
@@ -3706,7 +3758,7 @@ async function requestRpc(config, rpcPath, payload) {
3706
3758
  responsePayload = await response.text();
3707
3759
  }
3708
3760
  const payloadObject = responsePayload != null ? responsePayload : {};
3709
- const message = typeof responsePayload === "string" ? responsePayload : (_b6 = payloadObject.message) != null ? _b6 : `Erro ao chamar RPC ${schema}.${rpcPath} (${response.status}).`;
3761
+ const message = typeof responsePayload === "string" ? responsePayload : (_b5 = payloadObject.message) != null ? _b5 : `Erro ao chamar RPC ${schema}.${rpcPath} (${response.status}).`;
3710
3762
  const rpcError = new TelescupClientError(message, {
3711
3763
  status: response.status,
3712
3764
  code: payloadObject.code,
@@ -3736,7 +3788,7 @@ async function requestRpc(config, rpcPath, payload) {
3736
3788
  throw new TelescupClientError(`Falha ao chamar RPC ${rpcPath}.`);
3737
3789
  }
3738
3790
  var toTelescupError = async (response, fallbackMessage) => {
3739
- var _a60;
3791
+ var _a58;
3740
3792
  let payload = void 0;
3741
3793
  try {
3742
3794
  payload = await response.json();
@@ -3744,7 +3796,7 @@ var toTelescupError = async (response, fallbackMessage) => {
3744
3796
  payload = await response.text();
3745
3797
  }
3746
3798
  const payloadObject = payload != null ? payload : {};
3747
- const message = typeof payload === "string" ? payload : (_a60 = payloadObject.message) != null ? _a60 : `${fallbackMessage} (${response.status}).`;
3799
+ const message = typeof payload === "string" ? payload : (_a58 = payloadObject.message) != null ? _a58 : `${fallbackMessage} (${response.status}).`;
3748
3800
  return new TelescupClientError(message, {
3749
3801
  status: response.status,
3750
3802
  code: payloadObject.code,
@@ -3792,11 +3844,11 @@ var mergeFacetEntries = (current, incoming) => {
3792
3844
  const map = /* @__PURE__ */ new Map();
3793
3845
  current == null ? void 0 : current.forEach((entry) => map.set(entry.value, entry));
3794
3846
  incoming == null ? void 0 : incoming.forEach((entry) => {
3795
- var _a60, _b6, _c;
3847
+ var _a58, _b5, _c;
3796
3848
  const previous = map.get(entry.value);
3797
3849
  map.set(entry.value, {
3798
3850
  value: entry.value,
3799
- label: (_b6 = (_a60 = entry.label) != null ? _a60 : previous == null ? void 0 : previous.label) != null ? _b6 : entry.value,
3851
+ label: (_b5 = (_a58 = entry.label) != null ? _a58 : previous == null ? void 0 : previous.label) != null ? _b5 : entry.value,
3800
3852
  count: (_c = entry.count) != null ? _c : previous == null ? void 0 : previous.count
3801
3853
  });
3802
3854
  });
@@ -3816,10 +3868,10 @@ var mergeFacets = (base, incoming) => {
3816
3868
  var toFacetEntriesFromRows = (rows, valueKeys, labelKeys) => {
3817
3869
  const result = /* @__PURE__ */ new Map();
3818
3870
  rows.forEach((row) => {
3819
- var _a60;
3871
+ var _a58;
3820
3872
  const value = readFirstString(row, valueKeys);
3821
3873
  if (!value) return;
3822
- const label = (_a60 = readFirstString(row, labelKeys)) != null ? _a60 : value;
3874
+ const label = (_a58 = readFirstString(row, labelKeys)) != null ? _a58 : value;
3823
3875
  result.set(value, { value, label });
3824
3876
  });
3825
3877
  return Array.from(result.values()).sort((a, b) => a.label.localeCompare(b.label));
@@ -3878,7 +3930,7 @@ async function loadFacetsFromTelescupTables(config) {
3878
3930
  };
3879
3931
  }
3880
3932
  async function request(config, path, options = {}) {
3881
- var _a60, _b6, _c;
3933
+ var _a58, _b5, _c;
3882
3934
  const token = await config.getAccessToken();
3883
3935
  if (!token) {
3884
3936
  throw new TelescupClientError("Token de acesso n\xE3o encontrado.");
@@ -3886,7 +3938,7 @@ async function request(config, path, options = {}) {
3886
3938
  const functionsBaseUrl = resolveFunctionsBaseUrl(config.baseUrl);
3887
3939
  const url = joinUrl(functionsBaseUrl, path);
3888
3940
  const isAssetApiRoute = path.startsWith("asset-api/");
3889
- const authorizationToken = isAssetApiRoute ? (_a60 = resolveRpcAuthorizationToken(token)) != null ? _a60 : token : token;
3941
+ const authorizationToken = isAssetApiRoute ? (_a58 = resolveRpcAuthorizationToken(token)) != null ? _a58 : token : token;
3890
3942
  const headers = {
3891
3943
  Authorization: `Bearer ${authorizationToken}`,
3892
3944
  ...options.headers
@@ -3902,7 +3954,7 @@ async function request(config, path, options = {}) {
3902
3954
  let response;
3903
3955
  try {
3904
3956
  response = await fetch(url, {
3905
- method: (_b6 = options.method) != null ? _b6 : "POST",
3957
+ method: (_b5 = options.method) != null ? _b5 : "POST",
3906
3958
  headers,
3907
3959
  body
3908
3960
  });
@@ -3936,11 +3988,11 @@ var normalizeFunctionLanguage = (value) => {
3936
3988
  return normalized;
3937
3989
  };
3938
3990
  var toFunctionListPayload = (filters) => {
3939
- var _a60, _b6, _c, _d, _e, _f;
3940
- const page = toPositiveInt((_a60 = filters.cursor) != null ? _a60 : filters.page, 1);
3991
+ var _a58, _b5, _c, _d, _e, _f;
3992
+ const page = toPositiveInt((_a58 = filters.cursor) != null ? _a58 : filters.page, 1);
3941
3993
  const pageSize = Math.min(500, Math.max(1, toPositiveInt(filters.pageSize, 24)));
3942
3994
  return {
3943
- query: (_b6 = filters.query) != null ? _b6 : "",
3995
+ query: (_b5 = filters.query) != null ? _b5 : "",
3944
3996
  page,
3945
3997
  pageSize,
3946
3998
  sort: `${normalizeSortBy(filters.sort)}:${filters.order === "asc" ? "asc" : "desc"}`,
@@ -3975,8 +4027,8 @@ var toFolderPath = (value) => {
3975
4027
  return normalized.slice(0, lastSlash);
3976
4028
  };
3977
4029
  var normalizeFilterText = (value) => {
3978
- var _a60;
3979
- return (_a60 = value == null ? void 0 : value.trim().toLowerCase()) != null ? _a60 : "";
4030
+ var _a58;
4031
+ return (_a58 = value == null ? void 0 : value.trim().toLowerCase()) != null ? _a58 : "";
3980
4032
  };
3981
4033
  var normalizeExtensionFilter = (value) => {
3982
4034
  const normalized = normalizeFilterText(value);
@@ -3990,16 +4042,16 @@ var normalizeFolderFilter = (value) => {
3990
4042
  var sortAssets = (items, sort, order) => {
3991
4043
  const direction = order === "asc" ? 1 : -1;
3992
4044
  const byName = (a, b) => {
3993
- var _a60, _b6, _c, _d;
3994
- return ((_b6 = (_a60 = a.fileName) != null ? _a60 : a.name) != null ? _b6 : "").localeCompare((_d = (_c = b.fileName) != null ? _c : b.name) != null ? _d : "");
4045
+ var _a58, _b5, _c, _d;
4046
+ return ((_b5 = (_a58 = a.fileName) != null ? _a58 : a.name) != null ? _b5 : "").localeCompare((_d = (_c = b.fileName) != null ? _c : b.name) != null ? _d : "");
3995
4047
  };
3996
4048
  const byDate = (a, b, key) => {
3997
- var _a60, _b6;
3998
- return (Date.parse((_a60 = a[key]) != null ? _a60 : "") || 0) - (Date.parse((_b6 = b[key]) != null ? _b6 : "") || 0);
4049
+ var _a58, _b5;
4050
+ return (Date.parse((_a58 = a[key]) != null ? _a58 : "") || 0) - (Date.parse((_b5 = b[key]) != null ? _b5 : "") || 0);
3999
4051
  };
4000
4052
  const bySize = (a, b) => {
4001
- var _a60, _b6;
4002
- return ((_a60 = a.size) != null ? _a60 : 0) - ((_b6 = b.size) != null ? _b6 : 0);
4053
+ var _a58, _b5;
4054
+ return ((_a58 = a.size) != null ? _a58 : 0) - ((_b5 = b.size) != null ? _b5 : 0);
4003
4055
  };
4004
4056
  const sorted = [...items];
4005
4057
  sorted.sort((a, b) => {
@@ -4034,7 +4086,7 @@ var applyAssetApiSearchFilters = (items, filters) => {
4034
4086
  const folderFilter = normalizeFolderFilter(filters.folderId);
4035
4087
  const requireAlt = filters.hasAlt === true;
4036
4088
  return items.filter((asset) => {
4037
- var _a60, _b6, _c, _d, _e, _f, _g, _h, _i;
4089
+ var _a58, _b5, _c, _d, _e, _f, _g, _h, _i;
4038
4090
  const haystack = [
4039
4091
  asset.id,
4040
4092
  asset.name,
@@ -4043,8 +4095,8 @@ var applyAssetApiSearchFilters = (items, filters) => {
4043
4095
  asset.folderName,
4044
4096
  asset.category,
4045
4097
  asset.usage,
4046
- (_a60 = asset.meta) == null ? void 0 : _a60.title,
4047
- (_b6 = asset.meta) == null ? void 0 : _b6.description,
4098
+ (_a58 = asset.meta) == null ? void 0 : _a58.title,
4099
+ (_b5 = asset.meta) == null ? void 0 : _b5.description,
4048
4100
  (_c = asset.meta) == null ? void 0 : _c.alt,
4049
4101
  ...Array.isArray((_d = asset.meta) == null ? void 0 : _d.tags) ? asset.meta.tags : []
4050
4102
  ].filter((value) => typeof value === "string" && value.trim() !== "").join(" ").toLowerCase();
@@ -4063,15 +4115,15 @@ var applyAssetApiSearchFilters = (items, filters) => {
4063
4115
  });
4064
4116
  };
4065
4117
  var mapAssetApiSearchRowToAsset = (row) => {
4066
- var _a60, _b6, _c, _d;
4118
+ var _a58, _b5, _c, _d;
4067
4119
  const id = readFirstString(row, ["asset_id", "id"]);
4068
4120
  if (!id) return null;
4069
- const fileName = (_a60 = readFirstString(row, ["original_filename", "filename", "title"])) != null ? _a60 : readFirstString(row, ["file_path"]);
4121
+ const fileName = (_a58 = readFirstString(row, ["original_filename", "filename", "title"])) != null ? _a58 : readFirstString(row, ["file_path"]);
4070
4122
  const mimeType = readFirstString(row, ["mime_type", "mime"]);
4071
4123
  const extension = getFileExtension(readFirstString(row, ["file_path", "filename", "original_filename"]));
4072
4124
  const tags = Array.isArray(row.tags) ? row.tags.filter((item) => typeof item === "string") : void 0;
4073
4125
  const categories = readStringArray(row.categories);
4074
- const category = (_b6 = readFirstString(row, ["category"])) != null ? _b6 : categories[0];
4126
+ const category = (_b5 = readFirstString(row, ["category"])) != null ? _b5 : categories[0];
4075
4127
  const alt = readFirstString(row, ["alt_text"]);
4076
4128
  const title = readFirstString(row, ["title"]);
4077
4129
  const description = readFirstString(row, ["description"]);
@@ -4114,14 +4166,14 @@ var mapAssetApiSearchRowToAsset = (row) => {
4114
4166
  };
4115
4167
  };
4116
4168
  async function listAssetsViaAssetApiSearch(config, filters) {
4117
- var _a60, _b6;
4169
+ var _a58, _b5;
4118
4170
  const pageSize = Math.min(500, Math.max(1, toPositiveInt(filters.pageSize, 24)));
4119
- const page = toPositiveInt((_a60 = filters.cursor) != null ? _a60 : filters.page, 1);
4171
+ const page = toPositiveInt((_a58 = filters.cursor) != null ? _a58 : filters.page, 1);
4120
4172
  const hasActiveFacetFilter = Boolean(filters.type && filters.type !== "all") || Boolean(filters.extension) || Boolean(filters.category) || Boolean(filters.folderId) || Boolean(filters.usage) || filters.hasAlt === true;
4121
4173
  const baseLimit = page * pageSize + 1;
4122
4174
  const seedLimit = hasActiveFacetFilter ? baseLimit : Math.max(baseLimit, TELESCUP_ASSET_API_FACET_SEED_LIMIT);
4123
4175
  const limit = Math.min(500, seedLimit);
4124
- const query = ((_b6 = filters.query) != null ? _b6 : "").trim() || TELESCUP_SEARCH_DEFAULT_QUERY;
4176
+ const query = ((_b5 = filters.query) != null ? _b5 : "").trim() || TELESCUP_SEARCH_DEFAULT_QUERY;
4125
4177
  const [pathBase, rawQuery] = TELESCUP_LIST_FUNCTION.split("?");
4126
4178
  const params = new URLSearchParams(rawQuery != null ? rawQuery : "");
4127
4179
  params.set("q", query);
@@ -4145,12 +4197,12 @@ async function listAssetsViaAssetApiSearch(config, filters) {
4145
4197
  };
4146
4198
  }
4147
4199
  var mapGenericRowToAsset = (row) => {
4148
- var _a60, _b6;
4149
- const id = (_a60 = readFirstString(row, ["asset_id", "id", "file_id", "uuid"])) != null ? _a60 : typeof row.id === "number" ? String(row.id) : void 0;
4200
+ var _a58, _b5;
4201
+ const id = (_a58 = readFirstString(row, ["asset_id", "id", "file_id", "uuid"])) != null ? _a58 : typeof row.id === "number" ? String(row.id) : void 0;
4150
4202
  if (!id) return null;
4151
4203
  const fileName = readFirstString(row, ["filename", "file_name", "name", "title", "original_name"]);
4152
4204
  const mimeType = readFirstString(row, ["mime", "mime_type", "content_type", "file_mime"]);
4153
- const extension = (_b6 = readFirstString(row, ["extension", "ext"])) != null ? _b6 : getFileExtension(fileName);
4205
+ const extension = (_b5 = readFirstString(row, ["extension", "ext"])) != null ? _b5 : getFileExtension(fileName);
4154
4206
  return {
4155
4207
  id,
4156
4208
  name: fileName,
@@ -4168,16 +4220,16 @@ var mapGenericRowToAsset = (row) => {
4168
4220
  };
4169
4221
  };
4170
4222
  var normalizeListResponseFromFunctions = (response, filters) => {
4171
- var _a60, _b6, _c, _d, _e, _f;
4223
+ var _a58, _b5, _c, _d, _e, _f;
4172
4224
  const payload = response != null ? response : {};
4173
4225
  const itemsRaw = Array.isArray(payload.items) ? payload.items : [];
4174
4226
  const selectedLanguage = normalizeLanguageKey(filters.language);
4175
4227
  const items = itemsRaw.map((row) => {
4176
- var _a61, _b7, _c2;
4228
+ var _a59, _b6, _c2;
4177
4229
  const mapped = mapGenericRowToAsset(row);
4178
4230
  if (!mapped) return null;
4179
4231
  const metaByLang = normalizeMetaByLanguage(row.meta);
4180
- const activeMeta = (_b7 = (_a61 = metaByLang[selectedLanguage]) != null ? _a61 : metaByLang.pt) != null ? _b7 : {};
4232
+ const activeMeta = (_b6 = (_a59 = metaByLang[selectedLanguage]) != null ? _a59 : metaByLang.pt) != null ? _b6 : {};
4181
4233
  const usageFromObject = readUsageContext(row.usage);
4182
4234
  const normalized = {
4183
4235
  ...mapped,
@@ -4189,7 +4241,7 @@ var normalizeListResponseFromFunctions = (response, filters) => {
4189
4241
  };
4190
4242
  return normalized;
4191
4243
  }).filter((item) => item !== null);
4192
- const total = (_c = (_b6 = (_a60 = readNumber(payload.total)) != null ? _a60 : readNumber(payload.totalCount)) != null ? _b6 : readNumber(payload.total_count)) != null ? _c : items.length;
4244
+ const total = (_c = (_b5 = (_a58 = readNumber(payload.total)) != null ? _a58 : readNumber(payload.totalCount)) != null ? _b5 : readNumber(payload.total_count)) != null ? _c : items.length;
4193
4245
  const page = toPositiveInt((_e = (_d = payload.page) != null ? _d : filters.cursor) != null ? _e : filters.page, 1);
4194
4246
  const pageSize = Math.min(100, Math.max(1, toPositiveInt((_f = payload.pageSize) != null ? _f : filters.pageSize, 24)));
4195
4247
  const nextCursor = total > page * pageSize ? String(page + 1) : void 0;
@@ -4209,13 +4261,13 @@ var mapConflictForQueue = (value) => {
4209
4261
  return "conflict";
4210
4262
  };
4211
4263
  var toInitPayloadForFunctions = (payload) => {
4212
- var _a60, _b6;
4264
+ var _a58, _b5;
4213
4265
  return {
4214
4266
  filename: payload.fileName,
4215
4267
  size: payload.size,
4216
4268
  mime: payload.mimeType,
4217
- folder_id: (_a60 = payload.folderId) != null ? _a60 : null,
4218
- overwritePolicy: (_b6 = payload.conflict) != null ? _b6 : "ask",
4269
+ folder_id: (_a58 = payload.folderId) != null ? _a58 : null,
4270
+ overwritePolicy: (_b5 = payload.conflict) != null ? _b5 : "ask",
4219
4271
  fileName: payload.fileName,
4220
4272
  mimeType: payload.mimeType,
4221
4273
  folderId: payload.folderId,
@@ -4223,10 +4275,10 @@ var toInitPayloadForFunctions = (payload) => {
4223
4275
  };
4224
4276
  };
4225
4277
  var normalizeInitResponseFromFunctions = (response) => {
4226
- var _a60, _b6, _c, _d, _e, _f, _g;
4278
+ var _a58, _b5, _c, _d, _e, _f, _g;
4227
4279
  const payload = response != null ? response : {};
4228
- const existingRaw = (_a60 = payload.existingAsset) != null ? _a60 : payload.existing_asset;
4229
- const existingAsset = existingRaw ? (_b6 = mapGenericRowToAsset(existingRaw)) != null ? _b6 : void 0 : void 0;
4280
+ const existingRaw = (_a58 = payload.existingAsset) != null ? _a58 : payload.existing_asset;
4281
+ const existingAsset = existingRaw ? (_b5 = mapGenericRowToAsset(existingRaw)) != null ? _b5 : void 0 : void 0;
4230
4282
  const assetRaw = payload.asset;
4231
4283
  const asset = assetRaw ? (_c = mapGenericRowToAsset(assetRaw)) != null ? _c : void 0 : void 0;
4232
4284
  const conflictSource = (_e = readString(payload.conflict)) != null ? _e : readString((_d = payload.conflict) == null ? void 0 : _d.type);
@@ -4247,12 +4299,12 @@ var normalizeInitResponseFromFunctions = (response) => {
4247
4299
  };
4248
4300
  };
4249
4301
  var toCompletePayloadForFunctions = (payload) => {
4250
- var _a60, _b6, _c;
4302
+ var _a58, _b5, _c;
4251
4303
  return {
4252
4304
  uploadId: payload.uploadId,
4253
- assetDraftId: (_a60 = payload.assetDraftId) != null ? _a60 : payload.assetId,
4305
+ assetDraftId: (_a58 = payload.assetDraftId) != null ? _a58 : payload.assetId,
4254
4306
  storageKey: payload.storageKey,
4255
- finalFilename: (_b6 = payload.finalFilename) != null ? _b6 : payload.fileName,
4307
+ finalFilename: (_b5 = payload.finalFilename) != null ? _b5 : payload.fileName,
4256
4308
  folder_id: (_c = payload.folderId) != null ? _c : null,
4257
4309
  upload_id: payload.uploadId,
4258
4310
  asset_id: payload.assetId,
@@ -4260,21 +4312,21 @@ var toCompletePayloadForFunctions = (payload) => {
4260
4312
  };
4261
4313
  };
4262
4314
  var normalizeCompleteResponseFromFunctions = (response) => {
4263
- var _a60, _b6;
4315
+ var _a58, _b5;
4264
4316
  const payload = response != null ? response : {};
4265
- const assetRaw = (_a60 = payload.asset) != null ? _a60 : payload;
4317
+ const assetRaw = (_a58 = payload.asset) != null ? _a58 : payload;
4266
4318
  const mapped = mapGenericRowToAsset(assetRaw);
4267
4319
  if (mapped) return { asset: mapped };
4268
- const assetId = (_b6 = readFirstString(assetRaw, ["id", "asset_id"])) != null ? _b6 : readFirstString(payload, ["assetId", "asset_id"]);
4320
+ const assetId = (_b5 = readFirstString(assetRaw, ["id", "asset_id"])) != null ? _b5 : readFirstString(payload, ["assetId", "asset_id"]);
4269
4321
  if (!assetId) {
4270
4322
  throw new TelescupClientError("Resposta inv\xE1lida ao finalizar upload no Telescup.");
4271
4323
  }
4272
4324
  return { asset: { id: assetId } };
4273
4325
  };
4274
4326
  var toMetaPayloadForFunctions = (payload) => {
4275
- var _a60, _b6;
4327
+ var _a58, _b5;
4276
4328
  if (TELESCUP_UPDATE_META_FUNCTION === "update-asset-meta") {
4277
- const categories = ((_a60 = payload.meta) == null ? void 0 : _a60.category) ? [payload.meta.category] : [];
4329
+ const categories = ((_a58 = payload.meta) == null ? void 0 : _a58.category) ? [payload.meta.category] : [];
4278
4330
  return {
4279
4331
  asset_id: payload.assetId,
4280
4332
  categories
@@ -4289,7 +4341,7 @@ var toMetaPayloadForFunctions = (payload) => {
4289
4341
  en: {},
4290
4342
  es: {}
4291
4343
  };
4292
- const target = (_b6 = byLanguage[language]) != null ? _b6 : byLanguage.pt;
4344
+ const target = (_b5 = byLanguage[language]) != null ? _b5 : byLanguage.pt;
4293
4345
  if (payload.meta) {
4294
4346
  if (typeof payload.meta.alt === "string") target.alt = payload.meta.alt;
4295
4347
  if (typeof payload.meta.title === "string") target.title = payload.meta.title;
@@ -4385,7 +4437,7 @@ var createTelescupClient = (config) => ({
4385
4437
  body: toMetaPayloadForFunctions(payload)
4386
4438
  }),
4387
4439
  uploadDirect: async (file) => {
4388
- var _a60;
4440
+ var _a58;
4389
4441
  const token = await config.getAccessToken();
4390
4442
  const userId = resolveUserIdFromToken(token);
4391
4443
  if (!userId) {
@@ -4413,7 +4465,7 @@ var createTelescupClient = (config) => ({
4413
4465
  }
4414
4466
  });
4415
4467
  const payload = response != null ? response : {};
4416
- const asset = mapAssetApiSearchRowToAsset((_a60 = payload.asset) != null ? _a60 : {});
4468
+ const asset = mapAssetApiSearchRowToAsset((_a58 = payload.asset) != null ? _a58 : {});
4417
4469
  if (!asset) {
4418
4470
  throw new TelescupClientError("Resposta inv\xE1lida do upload direto (asset-api).");
4419
4471
  }
@@ -4485,9 +4537,9 @@ function useTelescupAssets(options) {
4485
4537
  ...sanitizeFilters(filters),
4486
4538
  pageSize
4487
4539
  }).then((data) => {
4488
- var _a60;
4540
+ var _a58;
4489
4541
  return {
4490
- items: (_a60 = data.items) != null ? _a60 : [],
4542
+ items: (_a58 = data.items) != null ? _a58 : [],
4491
4543
  nextCursor: data.nextCursor,
4492
4544
  total: data.total,
4493
4545
  facets: data.facets
@@ -4510,7 +4562,7 @@ function useTelescupAssets(options) {
4510
4562
  [cacheKey, cacheTimeMs, enabled, filters, pageSize, resolvedClient]
4511
4563
  );
4512
4564
  const loadMore = useCallback(async () => {
4513
- var _a60, _b6, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
4565
+ var _a58, _b5, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
4514
4566
  if (!state.nextCursor || isLoadingMore || isLoading) return;
4515
4567
  const requestSeq = requestSeqRef.current;
4516
4568
  setIsLoadingMore(true);
@@ -4524,9 +4576,9 @@ function useTelescupAssets(options) {
4524
4576
  });
4525
4577
  if (!aliveRef.current || requestSeq !== requestSeqRef.current) return;
4526
4578
  const merged = {
4527
- items: [...state.items, ...(_a60 = data.items) != null ? _a60 : []],
4579
+ items: [...state.items, ...(_a58 = data.items) != null ? _a58 : []],
4528
4580
  nextCursor: data.nextCursor,
4529
- total: (_b6 = data.total) != null ? _b6 : state.total,
4581
+ total: (_b5 = data.total) != null ? _b5 : state.total,
4530
4582
  facets: {
4531
4583
  categories: (_d = (_c = data.facets) == null ? void 0 : _c.categories) != null ? _d : previousFacets == null ? void 0 : previousFacets.categories,
4532
4584
  folders: (_f = (_e = data.facets) == null ? void 0 : _e.folders) != null ? _f : previousFacets == null ? void 0 : previousFacets.folders,
@@ -4675,12 +4727,12 @@ var IMAGE_EXTENSIONS = /* @__PURE__ */ new Set(["jpg", "jpeg", "png", "gif", "we
4675
4727
  var VIDEO_EXTENSIONS = /* @__PURE__ */ new Set(["mp4", "mov", "webm", "mkv", "avi", "m4v", "wmv"]);
4676
4728
  var AUDIO_EXTENSIONS = /* @__PURE__ */ new Set(["mp3", "wav", "aac", "ogg", "flac", "m4a"]);
4677
4729
  var resolveAssetFamily = (asset) => {
4678
- var _a60, _b6, _c;
4679
- const explicitType = (_a60 = asset.type) == null ? void 0 : _a60.toLowerCase();
4730
+ var _a58, _b5, _c;
4731
+ const explicitType = (_a58 = asset.type) == null ? void 0 : _a58.toLowerCase();
4680
4732
  if (explicitType === "image" || explicitType === "video" || explicitType === "audio" || explicitType === "file") {
4681
4733
  return explicitType;
4682
4734
  }
4683
- const mime = (_b6 = asset.mimeType) == null ? void 0 : _b6.toLowerCase();
4735
+ const mime = (_b5 = asset.mimeType) == null ? void 0 : _b5.toLowerCase();
4684
4736
  if (mime == null ? void 0 : mime.startsWith("image/")) return "image";
4685
4737
  if (mime == null ? void 0 : mime.startsWith("video/")) return "video";
4686
4738
  if (mime == null ? void 0 : mime.startsWith("audio/")) return "audio";
@@ -4692,9 +4744,9 @@ var resolveAssetFamily = (asset) => {
4692
4744
  return "file";
4693
4745
  };
4694
4746
  var matchesAllowedAsset = (asset, allowed) => {
4695
- var _a60, _b6, _c, _d;
4747
+ var _a58, _b5, _c, _d;
4696
4748
  if (!allowed || allowed.length === 0) return true;
4697
- const mime = (_b6 = (_a60 = asset.mimeType) == null ? void 0 : _a60.toLowerCase()) != null ? _b6 : "";
4749
+ const mime = (_b5 = (_a58 = asset.mimeType) == null ? void 0 : _a58.toLowerCase()) != null ? _b5 : "";
4698
4750
  const ext = asset.extension ? `.${asset.extension.toLowerCase()}` : "";
4699
4751
  const type = (_d = (_c = asset.type) == null ? void 0 : _c.toLowerCase()) != null ? _d : "";
4700
4752
  const family = resolveAssetFamily(asset);
@@ -4740,12 +4792,12 @@ var getPreview = (asset) => {
4740
4792
  var normalizeFacetOptions = (entries) => {
4741
4793
  if (!entries || !entries.length) return [];
4742
4794
  return entries.reduce((acc, entry) => {
4743
- var _a60, _b6;
4744
- const value = (_a60 = entry.value) == null ? void 0 : _a60.trim();
4795
+ var _a58, _b5;
4796
+ const value = (_a58 = entry.value) == null ? void 0 : _a58.trim();
4745
4797
  if (!value) return acc;
4746
4798
  acc.push({
4747
4799
  value,
4748
- label: ((_b6 = entry.label) == null ? void 0 : _b6.trim()) || value,
4800
+ label: ((_b5 = entry.label) == null ? void 0 : _b5.trim()) || value,
4749
4801
  count: typeof entry.count === "number" ? entry.count : void 0
4750
4802
  });
4751
4803
  return acc;
@@ -4754,13 +4806,13 @@ var normalizeFacetOptions = (entries) => {
4754
4806
  var collectFacetOptions = (items, pick, pickLabel) => {
4755
4807
  const options = /* @__PURE__ */ new Map();
4756
4808
  items.forEach((asset) => {
4757
- var _a60, _b6, _c;
4758
- const value = (_a60 = pick(asset)) == null ? void 0 : _a60.trim();
4809
+ var _a58, _b5, _c;
4810
+ const value = (_a58 = pick(asset)) == null ? void 0 : _a58.trim();
4759
4811
  if (!value) return;
4760
4812
  const current = options.get(value);
4761
4813
  options.set(value, {
4762
4814
  value,
4763
- label: ((_b6 = pickLabel == null ? void 0 : pickLabel(asset)) == null ? void 0 : _b6.trim()) || (current == null ? void 0 : current.label) || value,
4815
+ label: ((_b5 = pickLabel == null ? void 0 : pickLabel(asset)) == null ? void 0 : _b5.trim()) || (current == null ? void 0 : current.label) || value,
4764
4816
  count: ((_c = current == null ? void 0 : current.count) != null ? _c : 0) + 1
4765
4817
  });
4766
4818
  });
@@ -4909,10 +4961,8 @@ import { useMemo as useMemo5, useRef as useRef9, useState as useState10 } from "
4909
4961
 
4910
4962
  // src/hooks/useTelescupUploadQueue.tsx
4911
4963
  import { useCallback as useCallback3, useEffect as useEffect12, useMemo as useMemo4, useRef as useRef8, useState as useState9 } from "react";
4912
- var import_meta3 = {};
4913
4964
  var DEFAULT_CONCURRENCY = 3;
4914
- var _a15, _b4;
4915
- var TELESCUP_UPLOAD_MODE = (_b4 = (_a15 = import_meta3.env.VITE_TELESCUP_UPLOAD_MODE) == null ? void 0 : _a15.trim().toLowerCase()) != null ? _b4 : "standard";
4965
+ var TELESCUP_UPLOAD_MODE = getRuntimeEnvOr("VITE_TELESCUP_UPLOAD_MODE", "standard").trim().toLowerCase();
4916
4966
  var makeId = () => Math.random().toString(36).slice(2, 10);
4917
4967
  var matchesAllowedType = (file, allowed) => {
4918
4968
  if (!allowed || allowed.length === 0) return true;
@@ -5017,7 +5067,7 @@ function useTelescupUploadQueue(options) {
5017
5067
  activeRef.current += 1;
5018
5068
  updateItem(next.id, { status: "uploading", progress: 0, error: void 0 });
5019
5069
  const run = async () => {
5020
- var _a60, _b6, _c;
5070
+ var _a58, _b5, _c;
5021
5071
  try {
5022
5072
  if (TELESCUP_UPLOAD_MODE === "direct") {
5023
5073
  const completed2 = await client.uploadDirect(next.file);
@@ -5036,7 +5086,7 @@ function useTelescupUploadQueue(options) {
5036
5086
  size: next.file.size,
5037
5087
  mimeType: next.file.type,
5038
5088
  folderId,
5039
- conflict: (_a60 = next.conflictPolicy) != null ? _a60 : conflictPolicy
5089
+ conflict: (_a58 = next.conflictPolicy) != null ? _a58 : conflictPolicy
5040
5090
  });
5041
5091
  const conflictDetected = init.conflict === "ask" || init.conflict === "conflict" || init.conflict === "exists" || init.existingAsset && !init.uploadUrl;
5042
5092
  if (conflictDetected) {
@@ -5075,7 +5125,7 @@ function useTelescupUploadQueue(options) {
5075
5125
  storageKey: init.storageKey,
5076
5126
  finalFilename: init.finalFilename,
5077
5127
  folderId,
5078
- assetId: (_b6 = init.asset) == null ? void 0 : _b6.id,
5128
+ assetId: (_b5 = init.asset) == null ? void 0 : _b5.id,
5079
5129
  fileName: (_c = init.resolvedName) != null ? _c : next.file.name
5080
5130
  });
5081
5131
  updateItem(next.id, {
@@ -5174,7 +5224,7 @@ var TelescupUploader = ({
5174
5224
  className,
5175
5225
  onAssetUploaded
5176
5226
  }) => {
5177
- var _a60;
5227
+ var _a58;
5178
5228
  const inputRef = useRef9(null);
5179
5229
  const [dragActive, setDragActive] = useState10(false);
5180
5230
  const {
@@ -5241,8 +5291,8 @@ var TelescupUploader = ({
5241
5291
  size: "sm",
5242
5292
  variant: "secondary",
5243
5293
  onClick: () => {
5244
- var _a61;
5245
- return (_a61 = inputRef.current) == null ? void 0 : _a61.click();
5294
+ var _a59;
5295
+ return (_a59 = inputRef.current) == null ? void 0 : _a59.click();
5246
5296
  },
5247
5297
  children: labels.uploader.browse
5248
5298
  }
@@ -5256,8 +5306,8 @@ var TelescupUploader = ({
5256
5306
  accept,
5257
5307
  multiple,
5258
5308
  onChange: (event) => {
5259
- var _a61;
5260
- if ((_a61 = event.target.files) == null ? void 0 : _a61.length) {
5309
+ var _a59;
5310
+ if ((_a59 = event.target.files) == null ? void 0 : _a59.length) {
5261
5311
  handleFiles(event.target.files);
5262
5312
  event.currentTarget.value = "";
5263
5313
  }
@@ -5292,7 +5342,7 @@ var TelescupUploader = ({
5292
5342
  /* @__PURE__ */ jsx39(AlertDialogTitle, { children: labels.conflict.title }),
5293
5343
  /* @__PURE__ */ jsx39(AlertDialogDescription, { children: labels.conflict.description })
5294
5344
  ] }),
5295
- ((_a60 = conflictItem == null ? void 0 : conflictItem.existingAsset) == null ? void 0 : _a60.id) ? /* @__PURE__ */ jsxs25("div", { className: "mt-3 rounded-lg border border-border bg-muted/30 p-3", children: [
5345
+ ((_a58 = conflictItem == null ? void 0 : conflictItem.existingAsset) == null ? void 0 : _a58.id) ? /* @__PURE__ */ jsxs25("div", { className: "mt-3 rounded-lg border border-border bg-muted/30 p-3", children: [
5296
5346
  /* @__PURE__ */ jsx39("p", { className: "text-xs font-semibold text-muted-foreground", children: "Asset existente" }),
5297
5347
  /* @__PURE__ */ jsx39("div", { className: "mt-2 h-28 overflow-hidden rounded-md", children: /* @__PURE__ */ jsx39(
5298
5348
  TelescupImage,
@@ -5515,7 +5565,7 @@ var DEFAULT_LABELS = {
5515
5565
  }
5516
5566
  };
5517
5567
  var mergeLabels = (overrides) => {
5518
- var _a60;
5568
+ var _a58;
5519
5569
  if (!overrides) return DEFAULT_LABELS;
5520
5570
  return {
5521
5571
  ...DEFAULT_LABELS,
@@ -5529,17 +5579,17 @@ var mergeLabels = (overrides) => {
5529
5579
  meta: {
5530
5580
  ...DEFAULT_LABELS.meta,
5531
5581
  ...overrides.meta,
5532
- fields: { ...DEFAULT_LABELS.meta.fields, ...(_a60 = overrides.meta) == null ? void 0 : _a60.fields }
5582
+ fields: { ...DEFAULT_LABELS.meta.fields, ...(_a58 = overrides.meta) == null ? void 0 : _a58.fields }
5533
5583
  },
5534
5584
  toasts: { ...DEFAULT_LABELS.toasts, ...overrides.toasts }
5535
5585
  };
5536
5586
  };
5537
5587
  var LANGUAGES = ["pt", "en", "es"];
5538
5588
  var getAssetMeta = (asset, lang) => {
5539
- var _a60, _b6;
5589
+ var _a58, _b5;
5540
5590
  if (!asset) return {};
5541
- if ((_a60 = asset.metaByLang) == null ? void 0 : _a60[lang]) return asset.metaByLang[lang];
5542
- return (_b6 = asset.meta) != null ? _b6 : {};
5591
+ if ((_a58 = asset.metaByLang) == null ? void 0 : _a58[lang]) return asset.metaByLang[lang];
5592
+ return (_b5 = asset.meta) != null ? _b5 : {};
5543
5593
  };
5544
5594
  var TelescupMetaEditor = ({
5545
5595
  client,
@@ -5549,8 +5599,8 @@ var TelescupMetaEditor = ({
5549
5599
  labels,
5550
5600
  onAssetUpdated
5551
5601
  }) => {
5552
- var _a60, _b6, _c, _d, _e, _f, _g, _h;
5553
- const [activeAssetId, setActiveAssetId] = useState11((_b6 = (_a60 = assets[0]) == null ? void 0 : _a60.id) != null ? _b6 : "");
5602
+ var _a58, _b5, _c, _d, _e, _f, _g, _h;
5603
+ const [activeAssetId, setActiveAssetId] = useState11((_b5 = (_a58 = assets[0]) == null ? void 0 : _a58.id) != null ? _b5 : "");
5554
5604
  const [activeLang, setActiveLang] = useState11(
5555
5605
  LANGUAGES.includes(defaultLanguage) ? defaultLanguage : "pt"
5556
5606
  );
@@ -5568,18 +5618,18 @@ var TelescupMetaEditor = ({
5568
5618
  }, [activeAssetId, assets]);
5569
5619
  const asset = assets.find((item) => item.id === activeAssetId);
5570
5620
  const currentDraft = useMemo6(() => {
5571
- var _a61;
5572
- const existing = (_a61 = drafts[activeAssetId]) == null ? void 0 : _a61[activeLang];
5621
+ var _a59;
5622
+ const existing = (_a59 = drafts[activeAssetId]) == null ? void 0 : _a59[activeLang];
5573
5623
  if (existing) return existing;
5574
5624
  return getAssetMeta(asset, activeLang);
5575
5625
  }, [activeAssetId, activeLang, asset, drafts]);
5576
5626
  const updateDraft = (field, value) => {
5577
5627
  setDrafts((prev) => {
5578
- var _a61;
5628
+ var _a59;
5579
5629
  return {
5580
5630
  ...prev,
5581
5631
  [activeAssetId]: {
5582
- ...(_a61 = prev[activeAssetId]) != null ? _a61 : {},
5632
+ ...(_a59 = prev[activeAssetId]) != null ? _a59 : {},
5583
5633
  [activeLang]: {
5584
5634
  ...currentDraft,
5585
5635
  [field]: value
@@ -5647,11 +5697,11 @@ var TelescupMetaEditor = ({
5647
5697
  onAssetUpdated == null ? void 0 : onAssetUpdated(updated);
5648
5698
  const updatedMeta = getAssetMeta(updated, activeLang);
5649
5699
  setDrafts((prev) => {
5650
- var _a61;
5700
+ var _a59;
5651
5701
  return {
5652
5702
  ...prev,
5653
5703
  [asset.id]: {
5654
- ...(_a61 = prev[asset.id]) != null ? _a61 : {},
5704
+ ...(_a59 = prev[asset.id]) != null ? _a59 : {},
5655
5705
  [activeLang]: updatedMeta
5656
5706
  }
5657
5707
  };
@@ -5957,7 +6007,6 @@ var TelescupUpload = ({
5957
6007
  };
5958
6008
 
5959
6009
  // src/components/cupcode/UserMenuCupcode.tsx
5960
- var import_meta4 = {};
5961
6010
  import { Fragment as Fragment3, jsx as jsx44, jsxs as jsxs28 } from "react/jsx-runtime";
5962
6011
  var PRESENCE_META = {
5963
6012
  online: { label: "On-line", group: "online", kind: "dot", dotClass: "bg-success" },
@@ -6079,10 +6128,10 @@ var SHARED_FILE_EXTENSIONS = [
6079
6128
  ".mov",
6080
6129
  ".avi"
6081
6130
  ];
6082
- var _a16;
6083
- var ACCOUNTS_BASE_URL = ((_a16 = import_meta4.env.VITE_ACCOUNTS_BASE_URL) != null ? _a16 : "https://accounts.cupcode.com.br").trim().replace(/\/+$/, "");
6084
- var _a17;
6085
- var MC_BASE_URL = ((_a17 = import_meta4.env.VITE_MC_BASE_URL) != null ? _a17 : "https://mc.cupcode.com.br").trim().replace(/\/+$/, "");
6131
+ var _a14;
6132
+ var ACCOUNTS_BASE_URL = ((_a14 = getRuntimeEnv("VITE_ACCOUNTS_BASE_URL")) != null ? _a14 : "https://accounts.cupcode.com.br").trim().replace(/\/+$/, "");
6133
+ var _a15;
6134
+ var MC_BASE_URL = ((_a15 = getRuntimeEnv("VITE_MC_BASE_URL")) != null ? _a15 : "https://mc.cupcode.com.br").trim().replace(/\/+$/, "");
6086
6135
  var LANGUAGE_OPTIONS = [
6087
6136
  { value: "pt-BR", shortLabel: "BR", label: "Portugu\xEAs (Brasil)" },
6088
6137
  { value: "en-US", shortLabel: "EN", label: "English" },
@@ -6223,16 +6272,16 @@ var normalizeContrastMode = (value) => {
6223
6272
  return (value == null ? void 0 : value.trim().toLowerCase()) === "high" ? "high" : "normal";
6224
6273
  };
6225
6274
  var readStoredExperienceSettings = () => {
6226
- var _a60, _b6, _c;
6275
+ var _a58, _b5, _c;
6227
6276
  const fallback = defaultExperienceSettings();
6228
6277
  if (typeof window === "undefined") return fallback;
6229
6278
  try {
6230
6279
  const raw = window.localStorage.getItem(EXPERIENCE_SETTINGS_STORAGE_KEY);
6231
6280
  const parsed = raw ? JSON.parse(raw) : null;
6232
6281
  const storedThemePreference = window.localStorage.getItem(THEME_PREFERENCE_STORAGE_KEY);
6233
- const legacyTheme = (_a60 = window.localStorage.getItem(THEME_STORAGE_KEY2)) != null ? _a60 : window.localStorage.getItem(LEGACY_THEME_STORAGE_KEY);
6282
+ const legacyTheme = (_a58 = window.localStorage.getItem(THEME_STORAGE_KEY2)) != null ? _a58 : window.localStorage.getItem(LEGACY_THEME_STORAGE_KEY);
6234
6283
  return {
6235
- theme: normalizeThemePreference((_c = (_b6 = parsed == null ? void 0 : parsed.theme) != null ? _b6 : storedThemePreference) != null ? _c : legacyTheme),
6284
+ theme: normalizeThemePreference((_c = (_b5 = parsed == null ? void 0 : parsed.theme) != null ? _b5 : storedThemePreference) != null ? _c : legacyTheme),
6236
6285
  density: normalizeDensityMode(parsed == null ? void 0 : parsed.density),
6237
6286
  contrast: normalizeContrastMode(parsed == null ? void 0 : parsed.contrast),
6238
6287
  showEmailPublicly: typeof (parsed == null ? void 0 : parsed.showEmailPublicly) === "boolean" ? parsed.showEmailPublicly : fallback.showEmailPublicly
@@ -6374,7 +6423,7 @@ var getNotificationTimestamp = (notification) => {
6374
6423
  return Number.isNaN(parsed) ? 0 : parsed;
6375
6424
  };
6376
6425
  var formatNotificationDateTime = (notification) => {
6377
- var _a60;
6426
+ var _a58;
6378
6427
  if (notification.createdAt) {
6379
6428
  const parsed = new Date(notification.createdAt);
6380
6429
  if (!Number.isNaN(parsed.getTime())) {
@@ -6386,7 +6435,7 @@ var formatNotificationDateTime = (notification) => {
6386
6435
  });
6387
6436
  }
6388
6437
  }
6389
- return ((_a60 = notification.timeLabel) == null ? void 0 : _a60.trim()) || "Agora";
6438
+ return ((_a58 = notification.timeLabel) == null ? void 0 : _a58.trim()) || "Agora";
6390
6439
  };
6391
6440
  var getNotificationDayKey = (notification) => {
6392
6441
  const timestamp = getNotificationTimestamp(notification);
@@ -6466,9 +6515,9 @@ var isCupcodeCdnUrl = (value) => {
6466
6515
  }
6467
6516
  };
6468
6517
  var resolveTelescupImageUrl = (value, options) => {
6469
- var _a60, _b6, _c;
6470
- const width = (_a60 = options == null ? void 0 : options.width) != null ? _a60 : 96;
6471
- const height = (_b6 = options == null ? void 0 : options.height) != null ? _b6 : 96;
6518
+ var _a58, _b5, _c;
6519
+ const width = (_a58 = options == null ? void 0 : options.width) != null ? _a58 : 96;
6520
+ const height = (_b5 = options == null ? void 0 : options.height) != null ? _b5 : 96;
6472
6521
  const quality = (_c = options == null ? void 0 : options.quality) != null ? _c : 72;
6473
6522
  const raw = value == null ? void 0 : value.trim();
6474
6523
  if (!raw) return void 0;
@@ -6485,12 +6534,12 @@ var resolveTelescupImageUrl = (value, options) => {
6485
6534
  return buildTelescupImageURL({ id: parsedId, width, height, fit: "cover", format: "avif", quality });
6486
6535
  };
6487
6536
  var resolveGroupAvatarFromTelescup = (asset, fallbackId) => {
6488
- var _a60, _b6;
6489
- return (_b6 = (_a60 = resolveTelescupImageUrl(asset == null ? void 0 : asset.url)) != null ? _a60 : resolveTelescupImageUrl(asset == null ? void 0 : asset.id)) != null ? _b6 : resolveTelescupImageUrl(fallbackId);
6537
+ var _a58, _b5;
6538
+ return (_b5 = (_a58 = resolveTelescupImageUrl(asset == null ? void 0 : asset.url)) != null ? _a58 : resolveTelescupImageUrl(asset == null ? void 0 : asset.id)) != null ? _b5 : resolveTelescupImageUrl(fallbackId);
6490
6539
  };
6491
6540
  var resolveProfileAvatarFromTelescup = (asset, fallbackId) => {
6492
- var _a60, _b6;
6493
- return (_b6 = (_a60 = resolveTelescupImageUrl(asset == null ? void 0 : asset.url, { width: 384, height: 384, quality: 80 })) != null ? _a60 : resolveTelescupImageUrl(asset == null ? void 0 : asset.id, { width: 384, height: 384, quality: 80 })) != null ? _b6 : resolveTelescupImageUrl(fallbackId, { width: 384, height: 384, quality: 80 });
6541
+ var _a58, _b5;
6542
+ return (_b5 = (_a58 = resolveTelescupImageUrl(asset == null ? void 0 : asset.url, { width: 384, height: 384, quality: 80 })) != null ? _a58 : resolveTelescupImageUrl(asset == null ? void 0 : asset.id, { width: 384, height: 384, quality: 80 })) != null ? _b5 : resolveTelescupImageUrl(fallbackId, { width: 384, height: 384, quality: 80 });
6494
6543
  };
6495
6544
  var playIncomingMessageSound = () => {
6496
6545
  if (typeof window === "undefined") return;
@@ -6625,7 +6674,7 @@ var UserMenuCupcode = ({
6625
6674
  panels,
6626
6675
  className
6627
6676
  }) => {
6628
- var _a60;
6677
+ var _a58;
6629
6678
  const [open, setOpen] = useState12(false);
6630
6679
  const [activeTab, setActiveTab] = useState12("profile");
6631
6680
  const [isLoggingOut, setIsLoggingOut] = useState12(false);
@@ -6721,12 +6770,12 @@ var UserMenuCupcode = ({
6721
6770
  );
6722
6771
  const normalizedNotificationFeed = useMemo7(
6723
6772
  () => resolvedNotificationFeed.map((notification) => {
6724
- var _a61;
6773
+ var _a59;
6725
6774
  const kind = normalizeNotificationKind(notification.kind);
6726
6775
  return {
6727
6776
  ...notification,
6728
6777
  kind,
6729
- topic: (_a61 = notification.topic) != null ? _a61 : NOTIFICATION_KIND_META[kind].topicFallback
6778
+ topic: (_a59 = notification.topic) != null ? _a59 : NOTIFICATION_KIND_META[kind].topicFallback
6730
6779
  };
6731
6780
  }),
6732
6781
  [resolvedNotificationFeed]
@@ -6761,10 +6810,10 @@ var UserMenuCupcode = ({
6761
6810
  const groupedNotifications = useMemo7(() => {
6762
6811
  const groups = /* @__PURE__ */ new Map();
6763
6812
  filteredNotifications.forEach((notification) => {
6764
- var _a61, _b6;
6813
+ var _a59, _b5;
6765
6814
  const kind = normalizeNotificationKind(notification.kind);
6766
- const key = notificationPreferences.grouping === "topic" ? (_a61 = notification.topic) != null ? _a61 : NOTIFICATION_KIND_META[kind].topicFallback : getNotificationDayKey(notification);
6767
- const current = (_b6 = groups.get(key)) != null ? _b6 : [];
6815
+ const key = notificationPreferences.grouping === "topic" ? (_a59 = notification.topic) != null ? _a59 : NOTIFICATION_KIND_META[kind].topicFallback : getNotificationDayKey(notification);
6816
+ const current = (_b5 = groups.get(key)) != null ? _b5 : [];
6768
6817
  current.push(notification);
6769
6818
  groups.set(key, current);
6770
6819
  });
@@ -6851,7 +6900,7 @@ var UserMenuCupcode = ({
6851
6900
  }).slice(0, 6);
6852
6901
  }, [recentActivity]);
6853
6902
  const isSendingChatMessage = isChatSending || isSendingInternalChatMessage;
6854
- const activeReactionPickerMessageId = (_a60 = activeReactionPicker == null ? void 0 : activeReactionPicker.messageId) != null ? _a60 : null;
6903
+ const activeReactionPickerMessageId = (_a58 = activeReactionPicker == null ? void 0 : activeReactionPicker.messageId) != null ? _a58 : null;
6855
6904
  const isChatSidebarOpen = isChatSidebarExpanded || isChatSidebarPinned;
6856
6905
  const hasTelescupAvatarSupport = Boolean(telescupBaseUrl && getTelescupAccessToken);
6857
6906
  const hasTelescupGroupAvatarSupport = hasTelescupAvatarSupport;
@@ -6865,8 +6914,8 @@ var UserMenuCupcode = ({
6865
6914
  meta.set(user.id, { lastMessage: null, lastTimestamp: 0, unreadCount: 0 });
6866
6915
  });
6867
6916
  resolvedAllChatMessages.forEach((message) => {
6868
- var _a61;
6869
- const current = (_a61 = meta.get(message.contactId)) != null ? _a61 : { lastMessage: null, lastTimestamp: 0, unreadCount: 0 };
6917
+ var _a59;
6918
+ const current = (_a59 = meta.get(message.contactId)) != null ? _a59 : { lastMessage: null, lastTimestamp: 0, unreadCount: 0 };
6870
6919
  const timestamp = getChatMessageTimestamp(message);
6871
6920
  if (timestamp >= current.lastTimestamp) {
6872
6921
  current.lastTimestamp = timestamp;
@@ -6879,8 +6928,8 @@ var UserMenuCupcode = ({
6879
6928
  });
6880
6929
  if (chatUnreadByUser) {
6881
6930
  Object.entries(chatUnreadByUser).forEach(([contactId, unreadCount]) => {
6882
- var _a61;
6883
- const current = (_a61 = meta.get(contactId)) != null ? _a61 : { lastMessage: null, lastTimestamp: 0, unreadCount: 0 };
6931
+ var _a59;
6932
+ const current = (_a59 = meta.get(contactId)) != null ? _a59 : { lastMessage: null, lastTimestamp: 0, unreadCount: 0 };
6884
6933
  current.unreadCount = unreadCount;
6885
6934
  meta.set(contactId, current);
6886
6935
  });
@@ -6894,11 +6943,11 @@ var UserMenuCupcode = ({
6894
6943
  return haystack.includes(query);
6895
6944
  });
6896
6945
  return filtered.sort((left, right) => {
6897
- var _a61, _b6, _c, _d;
6946
+ var _a59, _b5, _c, _d;
6898
6947
  const leftMeta = conversationMetaByUserId.get(left.id);
6899
6948
  const rightMeta = conversationMetaByUserId.get(right.id);
6900
- const leftTimestamp = (_a61 = leftMeta == null ? void 0 : leftMeta.lastTimestamp) != null ? _a61 : 0;
6901
- const rightTimestamp = (_b6 = rightMeta == null ? void 0 : rightMeta.lastTimestamp) != null ? _b6 : 0;
6949
+ const leftTimestamp = (_a59 = leftMeta == null ? void 0 : leftMeta.lastTimestamp) != null ? _a59 : 0;
6950
+ const rightTimestamp = (_b5 = rightMeta == null ? void 0 : rightMeta.lastTimestamp) != null ? _b5 : 0;
6902
6951
  if (leftTimestamp !== rightTimestamp) return rightTimestamp - leftTimestamp;
6903
6952
  const leftUnread = (_c = leftMeta == null ? void 0 : leftMeta.unreadCount) != null ? _c : 0;
6904
6953
  const rightUnread = (_d = rightMeta == null ? void 0 : rightMeta.unreadCount) != null ? _d : 0;
@@ -6949,11 +6998,11 @@ var UserMenuCupcode = ({
6949
6998
  const visibleChatUnreadCount = isBadgeSuppressedByFocus ? 0 : resolvedChatUnreadCount;
6950
6999
  const firstUnreadChatUserId = useMemo7(
6951
7000
  () => {
6952
- var _a61, _b6;
6953
- return (_b6 = (_a61 = filteredAndSortedChatUsers.find((user) => {
6954
- var _a62;
6955
- return ((_a62 = resolvedChatUnreadByUser[user.id]) != null ? _a62 : 0) > 0;
6956
- })) == null ? void 0 : _a61.id) != null ? _b6 : null;
7001
+ var _a59, _b5;
7002
+ return (_b5 = (_a59 = filteredAndSortedChatUsers.find((user) => {
7003
+ var _a60;
7004
+ return ((_a60 = resolvedChatUnreadByUser[user.id]) != null ? _a60 : 0) > 0;
7005
+ })) == null ? void 0 : _a59.id) != null ? _b5 : null;
6957
7006
  },
6958
7007
  [filteredAndSortedChatUsers, resolvedChatUnreadByUser]
6959
7008
  );
@@ -6983,11 +7032,11 @@ var UserMenuCupcode = ({
6983
7032
  );
6984
7033
  const openChatPanel = useCallback5(
6985
7034
  (contactId) => {
6986
- var _a61, _b6, _c, _d, _e;
7035
+ var _a59, _b5, _c, _d, _e;
6987
7036
  setIsLogoutConfirmOpen(false);
6988
7037
  setOpen(true);
6989
7038
  setActiveTab("chat");
6990
- const targetContactId = (_e = (_d = (_b6 = contactId != null ? contactId : firstUnreadChatUserId) != null ? _b6 : (_a61 = filteredAndSortedChatUsers[0]) == null ? void 0 : _a61.id) != null ? _d : (_c = chatUsersList[0]) == null ? void 0 : _c.id) != null ? _e : "";
7039
+ const targetContactId = (_e = (_d = (_b5 = contactId != null ? contactId : firstUnreadChatUserId) != null ? _b5 : (_a59 = filteredAndSortedChatUsers[0]) == null ? void 0 : _a59.id) != null ? _d : (_c = chatUsersList[0]) == null ? void 0 : _c.id) != null ? _e : "";
6991
7040
  if (!targetContactId) return;
6992
7041
  setActiveChatUserId(targetContactId);
6993
7042
  markConversationRead(targetContactId);
@@ -6997,9 +7046,9 @@ var UserMenuCupcode = ({
6997
7046
  const reactionsByMessageId = useMemo7(() => {
6998
7047
  const grouped = /* @__PURE__ */ new Map();
6999
7048
  resolvedAllChatReactions.forEach((reaction) => {
7000
- var _a61, _b6;
7001
- const byEmoji = (_a61 = grouped.get(reaction.messageId)) != null ? _a61 : /* @__PURE__ */ new Map();
7002
- const current = (_b6 = byEmoji.get(reaction.emoji)) != null ? _b6 : { emoji: reaction.emoji, count: 0, reactedByMe: false };
7049
+ var _a59, _b5;
7050
+ const byEmoji = (_a59 = grouped.get(reaction.messageId)) != null ? _a59 : /* @__PURE__ */ new Map();
7051
+ const current = (_b5 = byEmoji.get(reaction.emoji)) != null ? _b5 : { emoji: reaction.emoji, count: 0, reactedByMe: false };
7003
7052
  current.count += 1;
7004
7053
  if (resolvedCurrentChatUserId && reaction.userId === resolvedCurrentChatUserId) {
7005
7054
  current.reactedByMe = true;
@@ -7186,9 +7235,9 @@ var UserMenuCupcode = ({
7186
7235
  const wasFocusModeActive = wasFocusModeActiveRef.current;
7187
7236
  if (wasFocusModeActive && !isFocusModeActive && suppressedFocusNotifications.length) {
7188
7237
  const byType = suppressedFocusNotifications.reduce((acc, notification) => {
7189
- var _a61;
7238
+ var _a59;
7190
7239
  const kind = normalizeNotificationKind(notification.kind);
7191
- acc[kind] = ((_a61 = acc[kind]) != null ? _a61 : 0) + 1;
7240
+ acc[kind] = ((_a59 = acc[kind]) != null ? _a59 : 0) + 1;
7192
7241
  return acc;
7193
7242
  }, { system: 0, comment: 0, access: 0, billing: 0, chat: 0, security: 0 });
7194
7243
  const summaryParts = NOTIFICATION_KIND_ORDER.filter((kind) => byType[kind] > 0).map(
@@ -7218,9 +7267,9 @@ var UserMenuCupcode = ({
7218
7267
  return;
7219
7268
  }
7220
7269
  setActiveChatUserId((current) => {
7221
- var _a61, _b6;
7270
+ var _a59, _b5;
7222
7271
  if (current && chatUsersList.some((user) => user.id === current)) return current;
7223
- return (_b6 = (_a61 = filteredAndSortedChatUsers[0]) == null ? void 0 : _a61.id) != null ? _b6 : chatUsersList[0].id;
7272
+ return (_b5 = (_a59 = filteredAndSortedChatUsers[0]) == null ? void 0 : _a59.id) != null ? _b5 : chatUsersList[0].id;
7224
7273
  });
7225
7274
  }, [chatUsersList, filteredAndSortedChatUsers]);
7226
7275
  useEffect14(() => {
@@ -7262,7 +7311,7 @@ var UserMenuCupcode = ({
7262
7311
  };
7263
7312
  }, [activeReactionPickerMessageId]);
7264
7313
  useEffect14(() => {
7265
- var _a61;
7314
+ var _a59;
7266
7315
  const knownIncomingIds = seenIncomingMessageIdsRef.current;
7267
7316
  const incomingMessages = resolvedAllChatMessages.filter((message) => message.sender === "them");
7268
7317
  if (!hasBootstrappedIncomingMessagesRef.current) {
@@ -7283,14 +7332,14 @@ var UserMenuCupcode = ({
7283
7332
  return;
7284
7333
  }
7285
7334
  const generatedNotifications = relevantIncomingMessages.map((message) => {
7286
- var _a62, _b6, _c;
7335
+ var _a60, _b5, _c;
7287
7336
  const contact = chatUsersList.find((user) => user.id === message.contactId);
7288
- const createdAt = (_a62 = message.createdAt) != null ? _a62 : (/* @__PURE__ */ new Date()).toISOString();
7337
+ const createdAt = (_a60 = message.createdAt) != null ? _a60 : (/* @__PURE__ */ new Date()).toISOString();
7289
7338
  const previewText = chatSettings.showMessagePreview ? summarizeChatText(message.text, 100) : "Nova mensagem no chat.";
7290
7339
  return {
7291
7340
  id: `chat-notification-${message.id}`,
7292
7341
  kind: "chat",
7293
- title: `Mensagem de ${(_b6 = contact == null ? void 0 : contact.name) != null ? _b6 : "usu\xE1rio"}`,
7342
+ title: `Mensagem de ${(_b5 = contact == null ? void 0 : contact.name) != null ? _b5 : "usu\xE1rio"}`,
7294
7343
  description: previewText,
7295
7344
  createdAt,
7296
7345
  timeLabel: formatChatTime({ ...message, createdAt }),
@@ -7311,7 +7360,7 @@ var UserMenuCupcode = ({
7311
7360
  )[0];
7312
7361
  if (latestRelevantMessage) {
7313
7362
  const latestContact = chatUsersList.find((user) => user.id === latestRelevantMessage.contactId);
7314
- const senderName = (_a61 = latestContact == null ? void 0 : latestContact.name) != null ? _a61 : "usu\xE1rio";
7363
+ const senderName = (_a59 = latestContact == null ? void 0 : latestContact.name) != null ? _a59 : "usu\xE1rio";
7315
7364
  const latestPreview = chatSettings.showMessagePreview ? summarizeChatText(latestRelevantMessage.text, 96) : "Nova mensagem";
7316
7365
  const remainingCount = Math.max(relevantIncomingMessages.length - 1, 0);
7317
7366
  const toastTitle = remainingCount > 0 ? `Mensagem de ${senderName} (+${remainingCount})` : `Mensagem de ${senderName}`;
@@ -7345,10 +7394,10 @@ var UserMenuCupcode = ({
7345
7394
  return;
7346
7395
  }
7347
7396
  generatedNotifications.forEach((chatNotification) => {
7348
- var _a62;
7397
+ var _a60;
7349
7398
  const notification = new Notification(chatNotification.title, {
7350
7399
  body: chatSettings.showMessagePreview ? chatNotification.description : "Voc\xEA recebeu uma nova mensagem.",
7351
- tag: `cc-chat-${(_a62 = chatNotification.actionChatUserId) != null ? _a62 : chatNotification.id}`
7400
+ tag: `cc-chat-${(_a60 = chatNotification.actionChatUserId) != null ? _a60 : chatNotification.id}`
7352
7401
  });
7353
7402
  notification.onclick = () => {
7354
7403
  window.focus();
@@ -7375,14 +7424,14 @@ var UserMenuCupcode = ({
7375
7424
  ]);
7376
7425
  const activeChatUser = useMemo7(
7377
7426
  () => {
7378
- var _a61;
7379
- return (_a61 = chatUsersList.find((user) => user.id === activeChatUserId)) != null ? _a61 : null;
7427
+ var _a59;
7428
+ return (_a59 = chatUsersList.find((user) => user.id === activeChatUserId)) != null ? _a59 : null;
7380
7429
  },
7381
7430
  [activeChatUserId, chatUsersList]
7382
7431
  );
7383
7432
  const activeGroupMembers = useMemo7(() => {
7384
- var _a61;
7385
- if (!(activeChatUser == null ? void 0 : activeChatUser.isGroup) || !((_a61 = activeChatUser.memberIds) == null ? void 0 : _a61.length)) return [];
7433
+ var _a59;
7434
+ if (!(activeChatUser == null ? void 0 : activeChatUser.isGroup) || !((_a59 = activeChatUser.memberIds) == null ? void 0 : _a59.length)) return [];
7386
7435
  const members = activeChatUser.memberIds.map((memberId) => baseChatUsersList.find((user) => user.id === memberId)).filter((member) => Boolean(member));
7387
7436
  return members;
7388
7437
  }, [activeChatUser, baseChatUsersList]);
@@ -7430,9 +7479,9 @@ var UserMenuCupcode = ({
7430
7479
  });
7431
7480
  }, [activeChatUser, resolvedChatLogs]);
7432
7481
  const replyToMessage = useMemo7(() => {
7433
- var _a61;
7482
+ var _a59;
7434
7483
  if (!replyToMessageId) return null;
7435
- return (_a61 = activeChatMessagesMap.get(replyToMessageId)) != null ? _a61 : null;
7484
+ return (_a59 = activeChatMessagesMap.get(replyToMessageId)) != null ? _a59 : null;
7436
7485
  }, [activeChatMessagesMap, replyToMessageId]);
7437
7486
  useEffect14(() => {
7438
7487
  if (!replyToMessageId) return;
@@ -7459,9 +7508,9 @@ var UserMenuCupcode = ({
7459
7508
  }
7460
7509
  }, [activeChatUser]);
7461
7510
  useEffect14(() => {
7462
- var _a61;
7511
+ var _a59;
7463
7512
  if (!open || activeTab !== "chat" || !activeChatUser || activeChatUser.isGroup) return;
7464
- const unreadCount = (_a61 = resolvedChatUnreadByUser[activeChatUser.id]) != null ? _a61 : 0;
7513
+ const unreadCount = (_a59 = resolvedChatUnreadByUser[activeChatUser.id]) != null ? _a59 : 0;
7465
7514
  if (unreadCount <= 0) return;
7466
7515
  const requestKey = `${activeChatUser.id}:${unreadCount}`;
7467
7516
  if (lastReadRequestRef.current === requestKey) return;
@@ -7535,13 +7584,13 @@ var UserMenuCupcode = ({
7535
7584
  openAccountsPath("/security#sessions");
7536
7585
  };
7537
7586
  const runOpenIntegrations = (provider) => {
7538
- var _a61;
7587
+ var _a59;
7539
7588
  if (!provider) {
7540
7589
  openAccountsPath("/integrations");
7541
7590
  return;
7542
7591
  }
7543
7592
  const option = INTEGRATION_OPTIONS.find((integration) => integration.id === provider);
7544
- openAccountsPath((_a61 = option == null ? void 0 : option.accountPath) != null ? _a61 : "/integrations");
7593
+ openAccountsPath((_a59 = option == null ? void 0 : option.accountPath) != null ? _a59 : "/integrations");
7545
7594
  };
7546
7595
  const changeStatus = (nextStatus) => {
7547
7596
  if (nextStatus === "offline") return;
@@ -7893,10 +7942,10 @@ var UserMenuCupcode = ({
7893
7942
  };
7894
7943
  const handleProfileAvatarChange = useCallback5(
7895
7944
  async (ids, assets) => {
7896
- var _a61, _b6, _c;
7945
+ var _a59, _b5, _c;
7897
7946
  const selectedAsset = assets == null ? void 0 : assets[0];
7898
- const selectedIdRaw = (_a61 = ids[0]) == null ? void 0 : _a61.trim();
7899
- const selectedId = (_c = (_b6 = parseAssetId(selectedIdRaw)) != null ? _b6 : parseAssetId(selectedAsset == null ? void 0 : selectedAsset.id)) != null ? _c : parseAssetId(selectedAsset == null ? void 0 : selectedAsset.url);
7947
+ const selectedIdRaw = (_a59 = ids[0]) == null ? void 0 : _a59.trim();
7948
+ const selectedId = (_c = (_b5 = parseAssetId(selectedIdRaw)) != null ? _b5 : parseAssetId(selectedAsset == null ? void 0 : selectedAsset.id)) != null ? _c : parseAssetId(selectedAsset == null ? void 0 : selectedAsset.url);
7900
7949
  if (!selectedId) {
7901
7950
  toast({
7902
7951
  title: "Imagem inv\xE1lida",
@@ -7938,7 +7987,7 @@ var UserMenuCupcode = ({
7938
7987
  [isProfileAvatarSaving, onProfileAvatarChange, resolvedProfileAvatarUrl]
7939
7988
  );
7940
7989
  const sendChatMessage = async () => {
7941
- var _a61, _b6;
7990
+ var _a59, _b5;
7942
7991
  if (!activeChatUser) return;
7943
7992
  const text = chatDraft.trim();
7944
7993
  if (!text || isSendingChatMessage) return;
@@ -7949,7 +7998,7 @@ var UserMenuCupcode = ({
7949
7998
  await onChatSendMessage({
7950
7999
  recipientId: activeChatUser.id,
7951
8000
  text,
7952
- replyToMessageId: (_a61 = replyToMessage == null ? void 0 : replyToMessage.id) != null ? _a61 : null
8001
+ replyToMessageId: (_a59 = replyToMessage == null ? void 0 : replyToMessage.id) != null ? _a59 : null
7953
8002
  });
7954
8003
  setChatDraft("");
7955
8004
  setShowEmojiPicker(false);
@@ -7969,7 +8018,7 @@ var UserMenuCupcode = ({
7969
8018
  timeLabel,
7970
8019
  createdAt,
7971
8020
  readAt: null,
7972
- replyToMessageId: (_b6 = replyToMessage == null ? void 0 : replyToMessage.id) != null ? _b6 : null
8021
+ replyToMessageId: (_b5 = replyToMessage == null ? void 0 : replyToMessage.id) != null ? _b5 : null
7973
8022
  };
7974
8023
  if (isLocalGroupConversation) {
7975
8024
  setInternalGroupMessages((current) => [...current, message]);
@@ -7981,7 +8030,7 @@ var UserMenuCupcode = ({
7981
8030
  setReplyToMessageId(null);
7982
8031
  };
7983
8032
  const renderDefaultPanel = () => {
7984
- var _a61, _b6, _c, _d;
8033
+ var _a59, _b5, _c, _d;
7985
8034
  if (activeTab === "profile") {
7986
8035
  return /* @__PURE__ */ jsxs28("div", { className: "space-y-4", children: [
7987
8036
  /* @__PURE__ */ jsxs28("div", { className: "pt-1 text-center", children: [
@@ -8261,7 +8310,7 @@ var UserMenuCupcode = ({
8261
8310
  visibleGroupedNotifications.length ? visibleGroupedNotifications.map((group) => /* @__PURE__ */ jsxs28("section", { className: "space-y-1.5", children: [
8262
8311
  /* @__PURE__ */ jsx44("p", { className: "px-0.5 text-[11px] font-semibold uppercase tracking-[0.08em] text-muted-foreground", children: group.label }),
8263
8312
  /* @__PURE__ */ jsx44("div", { className: "space-y-1.5", children: group.items.map((notification) => {
8264
- var _a62;
8313
+ var _a60;
8265
8314
  const kind = normalizeNotificationKind(notification.kind);
8266
8315
  const meta = NOTIFICATION_KIND_META[kind];
8267
8316
  const Icon3 = meta.icon;
@@ -8290,7 +8339,7 @@ var UserMenuCupcode = ({
8290
8339
  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",
8291
8340
  children: [
8292
8341
  /* @__PURE__ */ jsx44(ExternalLink, { className: "h-3 w-3" }),
8293
- (_a62 = notification.actionLabel) != null ? _a62 : "Abrir"
8342
+ (_a60 = notification.actionLabel) != null ? _a60 : "Abrir"
8294
8343
  ]
8295
8344
  }
8296
8345
  ),
@@ -8518,7 +8567,7 @@ var UserMenuCupcode = ({
8518
8567
  }
8519
8568
  if (activeTab === "chat") {
8520
8569
  const canSendChatMessage = Boolean(activeChatUser) && chatDraft.trim() !== "" && !isSendingChatMessage && !isChatLoading;
8521
- const activeConversationUnreadCount = activeChatUser ? (_a61 = resolvedChatUnreadByUser[activeChatUser.id]) != null ? _a61 : 0 : 0;
8570
+ const activeConversationUnreadCount = activeChatUser ? (_a59 = resolvedChatUnreadByUser[activeChatUser.id]) != null ? _a59 : 0 : 0;
8522
8571
  return /* @__PURE__ */ jsx44("div", { className: "h-full", children: /* @__PURE__ */ jsxs28(
8523
8572
  "div",
8524
8573
  {
@@ -8597,12 +8646,12 @@ var UserMenuCupcode = ({
8597
8646
  }
8598
8647
  ),
8599
8648
  /* @__PURE__ */ jsx44("div", { className: "space-y-1", children: users.map((user) => {
8600
- var _a62, _b7, _c2;
8649
+ var _a60, _b6, _c2;
8601
8650
  const userInitials = buildInitials(user.name, user.username);
8602
8651
  const isCurrent = user.id === activeChatUserId;
8603
- const unreadCount = (_a62 = resolvedChatUnreadByUser[user.id]) != null ? _a62 : 0;
8652
+ const unreadCount = (_a60 = resolvedChatUnreadByUser[user.id]) != null ? _a60 : 0;
8604
8653
  const hasUnread = unreadCount > 0;
8605
- const lastMessage = (_b7 = conversationMetaByUserId.get(user.id)) == null ? void 0 : _b7.lastMessage;
8654
+ const lastMessage = (_b6 = conversationMetaByUserId.get(user.id)) == null ? void 0 : _b6.lastMessage;
8606
8655
  return /* @__PURE__ */ jsxs28(
8607
8656
  "button",
8608
8657
  {
@@ -8802,13 +8851,13 @@ var UserMenuCupcode = ({
8802
8851
  ] }) }),
8803
8852
  /* @__PURE__ */ jsxs28("div", { ref: chatMessagesPaneRef, className: "cc-scrollbar cc-scrollbar-pink relative flex-1 space-y-2 overflow-y-auto px-3 py-2.5", children: [
8804
8853
  isChatLoading ? /* @__PURE__ */ jsx44("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) => {
8805
- var _a62, _b7;
8854
+ var _a60, _b6;
8806
8855
  if (item.type === "day") {
8807
8856
  return /* @__PURE__ */ jsx44("div", { className: "flex justify-center py-1", children: /* @__PURE__ */ jsx44("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);
8808
8857
  }
8809
8858
  const { message } = item;
8810
- const replyMessage = message.replyToMessageId ? (_a62 = activeChatMessagesMap.get(message.replyToMessageId)) != null ? _a62 : null : null;
8811
- const reactions = (_b7 = reactionsByMessageId.get(message.id)) != null ? _b7 : [];
8859
+ const replyMessage = message.replyToMessageId ? (_a60 = activeChatMessagesMap.get(message.replyToMessageId)) != null ? _a60 : null : null;
8860
+ const reactions = (_b6 = reactionsByMessageId.get(message.id)) != null ? _b6 : [];
8812
8861
  const hasReadReceipt = Boolean(message.readAt);
8813
8862
  const isEditing = editingMessageId === message.id;
8814
8863
  const canEditOrDelete = message.sender === "me";
@@ -8985,7 +9034,7 @@ var UserMenuCupcode = ({
8985
9034
  "div",
8986
9035
  {
8987
9036
  ref: reactionPickerRef,
8988
- style: { top: `${(_b6 = activeReactionPicker == null ? void 0 : activeReactionPicker.top) != null ? _b6 : 0}px`, left: `${(_c = activeReactionPicker == null ? void 0 : activeReactionPicker.left) != null ? _c : 0}px` },
9037
+ style: { top: `${(_b5 = activeReactionPicker == null ? void 0 : activeReactionPicker.top) != null ? _b5 : 0}px`, left: `${(_c = activeReactionPicker == null ? void 0 : activeReactionPicker.left) != null ? _c : 0}px` },
8989
9038
  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)]",
8990
9039
  children: MESSAGE_REACTION_OPTIONS.map((emoji) => /* @__PURE__ */ jsx44(
8991
9040
  "button",
@@ -9125,8 +9174,8 @@ var UserMenuCupcode = ({
9125
9174
  ] })
9126
9175
  ] }),
9127
9176
  isChatSuperAdmin ? activeConversationLogs.length ? /* @__PURE__ */ jsx44("div", { className: "space-y-2", children: activeConversationLogs.map((entry) => {
9128
- var _a62;
9129
- const actorName = entry.actorId && entry.actorId === resolvedCurrentChatUserId ? "Voc\xEA" : (_a62 = entry.actorId) != null ? _a62 : "Usu\xE1rio";
9177
+ var _a60;
9178
+ const actorName = entry.actorId && entry.actorId === resolvedCurrentChatUserId ? "Voc\xEA" : (_a60 = entry.actorId) != null ? _a60 : "Usu\xE1rio";
9130
9179
  return /* @__PURE__ */ jsxs28(
9131
9180
  "article",
9132
9181
  {
@@ -10067,7 +10116,7 @@ var FunctionsClient = class {
10067
10116
  */
10068
10117
  invoke(functionName_1) {
10069
10118
  return __awaiter(this, arguments, void 0, function* (functionName, options = {}) {
10070
- var _a60;
10119
+ var _a58;
10071
10120
  let timeoutId;
10072
10121
  let timeoutController;
10073
10122
  try {
@@ -10133,7 +10182,7 @@ var FunctionsClient = class {
10133
10182
  if (!response.ok) {
10134
10183
  throw new FunctionsHttpError(response);
10135
10184
  }
10136
- let responseType = ((_a60 = response.headers.get("Content-Type")) !== null && _a60 !== void 0 ? _a60 : "text/plain").split(";")[0].trim();
10185
+ let responseType = ((_a58 = response.headers.get("Content-Type")) !== null && _a58 !== void 0 ? _a58 : "text/plain").split(";")[0].trim();
10137
10186
  let data;
10138
10187
  if (responseType === "application/json") {
10139
10188
  data = yield response.json();
@@ -11379,7 +11428,7 @@ var WebSocketFactory = class {
11379
11428
  constructor() {
11380
11429
  }
11381
11430
  static detectEnvironment() {
11382
- var _a60;
11431
+ var _a58;
11383
11432
  if (typeof WebSocket !== "undefined") {
11384
11433
  return { type: "native", constructor: WebSocket };
11385
11434
  }
@@ -11396,7 +11445,7 @@ var WebSocketFactory = class {
11396
11445
  workaround: "Use Cloudflare Workers WebSocket API for server-side WebSocket handling, or deploy to a different runtime."
11397
11446
  };
11398
11447
  }
11399
- if (typeof globalThis !== "undefined" && globalThis.EdgeRuntime || typeof navigator !== "undefined" && ((_a60 = navigator.userAgent) === null || _a60 === void 0 ? void 0 : _a60.includes("Vercel-Edge"))) {
11448
+ if (typeof globalThis !== "undefined" && globalThis.EdgeRuntime || typeof navigator !== "undefined" && ((_a58 = navigator.userAgent) === null || _a58 === void 0 ? void 0 : _a58.includes("Vercel-Edge"))) {
11400
11449
  return {
11401
11450
  type: "unsupported",
11402
11451
  error: "Edge runtime detected (Vercel Edge/Netlify Edge). WebSockets are not supported in edge functions.",
@@ -11480,7 +11529,7 @@ Suggested solution: ${env.workaround}`;
11480
11529
  try {
11481
11530
  const env = this.detectEnvironment();
11482
11531
  return env.type === "native" || env.type === "ws";
11483
- } catch (_a60) {
11532
+ } catch (_a58) {
11484
11533
  return false;
11485
11534
  }
11486
11535
  }
@@ -11554,30 +11603,30 @@ var Serializer = class {
11554
11603
  return callback(JSON.stringify(payload));
11555
11604
  }
11556
11605
  _binaryEncodeUserBroadcastPush(message) {
11557
- var _a60;
11558
- if (this._isArrayBuffer((_a60 = message.payload) === null || _a60 === void 0 ? void 0 : _a60.payload)) {
11606
+ var _a58;
11607
+ if (this._isArrayBuffer((_a58 = message.payload) === null || _a58 === void 0 ? void 0 : _a58.payload)) {
11559
11608
  return this._encodeBinaryUserBroadcastPush(message);
11560
11609
  } else {
11561
11610
  return this._encodeJsonUserBroadcastPush(message);
11562
11611
  }
11563
11612
  }
11564
11613
  _encodeBinaryUserBroadcastPush(message) {
11565
- var _a60, _b6;
11566
- const userPayload = (_b6 = (_a60 = message.payload) === null || _a60 === void 0 ? void 0 : _a60.payload) !== null && _b6 !== void 0 ? _b6 : new ArrayBuffer(0);
11614
+ var _a58, _b5;
11615
+ const userPayload = (_b5 = (_a58 = message.payload) === null || _a58 === void 0 ? void 0 : _a58.payload) !== null && _b5 !== void 0 ? _b5 : new ArrayBuffer(0);
11567
11616
  return this._encodeUserBroadcastPush(message, this.BINARY_ENCODING, userPayload);
11568
11617
  }
11569
11618
  _encodeJsonUserBroadcastPush(message) {
11570
- var _a60, _b6;
11571
- const userPayload = (_b6 = (_a60 = message.payload) === null || _a60 === void 0 ? void 0 : _a60.payload) !== null && _b6 !== void 0 ? _b6 : {};
11619
+ var _a58, _b5;
11620
+ const userPayload = (_b5 = (_a58 = message.payload) === null || _a58 === void 0 ? void 0 : _a58.payload) !== null && _b5 !== void 0 ? _b5 : {};
11572
11621
  const encoder = new TextEncoder();
11573
11622
  const encodedUserPayload = encoder.encode(JSON.stringify(userPayload)).buffer;
11574
11623
  return this._encodeUserBroadcastPush(message, this.JSON_ENCODING, encodedUserPayload);
11575
11624
  }
11576
11625
  _encodeUserBroadcastPush(message, encodingType, encodedPayload) {
11577
- var _a60, _b6;
11626
+ var _a58, _b5;
11578
11627
  const topic = message.topic;
11579
- const ref = (_a60 = message.ref) !== null && _a60 !== void 0 ? _a60 : "";
11580
- const joinRef = (_b6 = message.join_ref) !== null && _b6 !== void 0 ? _b6 : "";
11628
+ const ref = (_a58 = message.ref) !== null && _a58 !== void 0 ? _a58 : "";
11629
+ const joinRef = (_b5 = message.join_ref) !== null && _b5 !== void 0 ? _b5 : "";
11581
11630
  const userEvent = message.payload.event;
11582
11631
  const rest = this.allowedMetadataKeys ? this._pick(message.payload, this.allowedMetadataKeys) : {};
11583
11632
  const metadata = Object.keys(rest).length === 0 ? "" : JSON.stringify(rest);
@@ -11663,8 +11712,8 @@ var Serializer = class {
11663
11712
  return { join_ref: null, ref: null, topic, event: this.BROADCAST_EVENT, payload: data };
11664
11713
  }
11665
11714
  _isArrayBuffer(buffer) {
11666
- var _a60;
11667
- return buffer instanceof ArrayBuffer || ((_a60 = buffer === null || buffer === void 0 ? void 0 : buffer.constructor) === null || _a60 === void 0 ? void 0 : _a60.name) === "ArrayBuffer";
11715
+ var _a58;
11716
+ return buffer instanceof ArrayBuffer || ((_a58 = buffer === null || buffer === void 0 ? void 0 : buffer.constructor) === null || _a58 === void 0 ? void 0 : _a58.name) === "ArrayBuffer";
11668
11717
  }
11669
11718
  _pick(obj, keys) {
11670
11719
  if (!obj || typeof obj !== "object") {
@@ -11728,8 +11777,8 @@ var PostgresTypes;
11728
11777
  PostgresTypes2["tstzrange"] = "tstzrange";
11729
11778
  })(PostgresTypes || (PostgresTypes = {}));
11730
11779
  var convertChangeData = (columns, record, options = {}) => {
11731
- var _a60;
11732
- const skipTypes = (_a60 = options.skipTypes) !== null && _a60 !== void 0 ? _a60 : [];
11780
+ var _a58;
11781
+ const skipTypes = (_a58 = options.skipTypes) !== null && _a58 !== void 0 ? _a58 : [];
11733
11782
  if (!record) {
11734
11783
  return {};
11735
11784
  }
@@ -11819,7 +11868,7 @@ var toJson = (value) => {
11819
11868
  if (typeof value === "string") {
11820
11869
  try {
11821
11870
  return JSON.parse(value);
11822
- } catch (_a60) {
11871
+ } catch (_a58) {
11823
11872
  return value;
11824
11873
  }
11825
11874
  }
@@ -11911,9 +11960,9 @@ var Push = class {
11911
11960
  this.payload = Object.assign(Object.assign({}, this.payload), payload);
11912
11961
  }
11913
11962
  receive(status, callback) {
11914
- var _a60;
11963
+ var _a58;
11915
11964
  if (this._hasReceived(status)) {
11916
- callback((_a60 = this.receivedResp) === null || _a60 === void 0 ? void 0 : _a60.response);
11965
+ callback((_a58 = this.receivedResp) === null || _a58 === void 0 ? void 0 : _a58.response);
11917
11966
  }
11918
11967
  this.recHooks.push({ status, callback });
11919
11968
  return this;
@@ -12104,8 +12153,8 @@ var RealtimePresence = class _RealtimePresence {
12104
12153
  };
12105
12154
  }
12106
12155
  this.map(joins, (key, newPresences) => {
12107
- var _a60;
12108
- const currentPresences = (_a60 = state[key]) !== null && _a60 !== void 0 ? _a60 : [];
12156
+ var _a58;
12157
+ const currentPresences = (_a58 = state[key]) !== null && _a58 !== void 0 ? _a58 : [];
12109
12158
  state[key] = this.cloneDeep(newPresences);
12110
12159
  if (currentPresences.length > 0) {
12111
12160
  const joinedPresenceRefs = state[key].map((m) => m.presence_ref);
@@ -12233,7 +12282,7 @@ var RealtimeChannel = class _RealtimeChannel {
12233
12282
  * ```
12234
12283
  */
12235
12284
  constructor(topic, params = { config: {} }, socket) {
12236
- var _a60, _b6;
12285
+ var _a58, _b5;
12237
12286
  this.topic = topic;
12238
12287
  this.params = params;
12239
12288
  this.socket = socket;
@@ -12292,19 +12341,19 @@ var RealtimeChannel = class _RealtimeChannel {
12292
12341
  this.presence = new RealtimePresence(this);
12293
12342
  this.broadcastEndpointURL = httpEndpointURL(this.socket.endPoint);
12294
12343
  this.private = this.params.config.private || false;
12295
- if (!this.private && ((_b6 = (_a60 = this.params.config) === null || _a60 === void 0 ? void 0 : _a60.broadcast) === null || _b6 === void 0 ? void 0 : _b6.replay)) {
12344
+ if (!this.private && ((_b5 = (_a58 = this.params.config) === null || _a58 === void 0 ? void 0 : _a58.broadcast) === null || _b5 === void 0 ? void 0 : _b5.replay)) {
12296
12345
  throw `tried to use replay on public channel '${this.topic}'. It must be a private channel.`;
12297
12346
  }
12298
12347
  }
12299
12348
  /** Subscribe registers your client with the server */
12300
12349
  subscribe(callback, timeout = this.timeout) {
12301
- var _a60, _b6, _c;
12350
+ var _a58, _b5, _c;
12302
12351
  if (!this.socket.isConnected()) {
12303
12352
  this.socket.connect();
12304
12353
  }
12305
12354
  if (this.state == CHANNEL_STATES.closed) {
12306
12355
  const { config: { broadcast, presence, private: isPrivate } } = this.params;
12307
- const postgres_changes = (_b6 = (_a60 = this.bindings.postgres_changes) === null || _a60 === void 0 ? void 0 : _a60.map((r) => r.filter)) !== null && _b6 !== void 0 ? _b6 : [];
12356
+ const postgres_changes = (_b5 = (_a58 = this.bindings.postgres_changes) === null || _a58 === void 0 ? void 0 : _a58.map((r) => r.filter)) !== null && _b5 !== void 0 ? _b5 : [];
12308
12357
  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;
12309
12358
  const accessTokenPayload = {};
12310
12359
  const config = {
@@ -12322,7 +12371,7 @@ var RealtimeChannel = class _RealtimeChannel {
12322
12371
  this.joinedOnce = true;
12323
12372
  this._rejoin(timeout);
12324
12373
  this.joinPush.receive("ok", async ({ postgres_changes: postgres_changes2 }) => {
12325
- var _a61;
12374
+ var _a59;
12326
12375
  if (!this.socket._isManualToken()) {
12327
12376
  this.socket.setAuth();
12328
12377
  }
@@ -12331,7 +12380,7 @@ var RealtimeChannel = class _RealtimeChannel {
12331
12380
  return;
12332
12381
  } else {
12333
12382
  const clientPostgresBindings = this.bindings.postgres_changes;
12334
- const bindingsLen = (_a61 = clientPostgresBindings === null || clientPostgresBindings === void 0 ? void 0 : clientPostgresBindings.length) !== null && _a61 !== void 0 ? _a61 : 0;
12383
+ const bindingsLen = (_a59 = clientPostgresBindings === null || clientPostgresBindings === void 0 ? void 0 : clientPostgresBindings.length) !== null && _a59 !== void 0 ? _a59 : 0;
12335
12384
  const newPostgresBindings = [];
12336
12385
  for (let i = 0; i < bindingsLen; i++) {
12337
12386
  const clientPostgresBinding = clientPostgresBindings[i];
@@ -12409,7 +12458,7 @@ var RealtimeChannel = class _RealtimeChannel {
12409
12458
  * @returns Promise resolving to object with success status, and error details if failed
12410
12459
  */
12411
12460
  async httpSend(event, payload, opts = {}) {
12412
- var _a60;
12461
+ var _a58;
12413
12462
  if (payload === void 0 || payload === null) {
12414
12463
  return Promise.reject("Payload is required for httpSend()");
12415
12464
  }
@@ -12434,7 +12483,7 @@ var RealtimeChannel = class _RealtimeChannel {
12434
12483
  ]
12435
12484
  })
12436
12485
  };
12437
- const response = await this._fetchWithTimeout(this.broadcastEndpointURL, options, (_a60 = opts.timeout) !== null && _a60 !== void 0 ? _a60 : this.timeout);
12486
+ const response = await this._fetchWithTimeout(this.broadcastEndpointURL, options, (_a58 = opts.timeout) !== null && _a58 !== void 0 ? _a58 : this.timeout);
12438
12487
  if (response.status === 202) {
12439
12488
  return { success: true };
12440
12489
  }
@@ -12442,7 +12491,7 @@ var RealtimeChannel = class _RealtimeChannel {
12442
12491
  try {
12443
12492
  const errorBody = await response.json();
12444
12493
  errorMessage = errorBody.error || errorBody.message || errorMessage;
12445
- } catch (_b6) {
12494
+ } catch (_b5) {
12446
12495
  }
12447
12496
  return Promise.reject(new Error(errorMessage));
12448
12497
  }
@@ -12456,7 +12505,7 @@ var RealtimeChannel = class _RealtimeChannel {
12456
12505
  * @param opts Options to be used during the send process
12457
12506
  */
12458
12507
  async send(args, opts = {}) {
12459
- var _a60, _b6;
12508
+ var _a58, _b5;
12460
12509
  if (!this._canPush() && args.type === "broadcast") {
12461
12510
  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.");
12462
12511
  const { event, payload: endpoint_payload } = args;
@@ -12482,8 +12531,8 @@ var RealtimeChannel = class _RealtimeChannel {
12482
12531
  })
12483
12532
  };
12484
12533
  try {
12485
- const response = await this._fetchWithTimeout(this.broadcastEndpointURL, options, (_a60 = opts.timeout) !== null && _a60 !== void 0 ? _a60 : this.timeout);
12486
- await ((_b6 = response.body) === null || _b6 === void 0 ? void 0 : _b6.cancel());
12534
+ const response = await this._fetchWithTimeout(this.broadcastEndpointURL, options, (_a58 = opts.timeout) !== null && _a58 !== void 0 ? _a58 : this.timeout);
12535
+ await ((_b5 = response.body) === null || _b5 === void 0 ? void 0 : _b5.cancel());
12487
12536
  return response.ok ? "ok" : "error";
12488
12537
  } catch (error) {
12489
12538
  if (error.name === "AbortError") {
@@ -12494,9 +12543,9 @@ var RealtimeChannel = class _RealtimeChannel {
12494
12543
  }
12495
12544
  } else {
12496
12545
  return new Promise((resolve) => {
12497
- var _a61, _b7, _c;
12546
+ var _a59, _b6, _c;
12498
12547
  const push = this._push(args.type, args, opts.timeout || this.timeout);
12499
- if (args.type === "broadcast" && !((_c = (_b7 = (_a61 = this.params) === null || _a61 === void 0 ? void 0 : _a61.config) === null || _b7 === void 0 ? void 0 : _b7.broadcast) === null || _c === void 0 ? void 0 : _c.ack)) {
12548
+ if (args.type === "broadcast" && !((_c = (_b6 = (_a59 = this.params) === null || _a59 === void 0 ? void 0 : _a59.config) === null || _b6 === void 0 ? void 0 : _b6.broadcast) === null || _c === void 0 ? void 0 : _c.ack)) {
12500
12549
  resolve("ok");
12501
12550
  }
12502
12551
  push.receive("ok", () => resolve("ok"));
@@ -12615,7 +12664,7 @@ var RealtimeChannel = class _RealtimeChannel {
12615
12664
  }
12616
12665
  /** @internal */
12617
12666
  _trigger(type, payload, ref) {
12618
- var _a60, _b6;
12667
+ var _a58, _b5;
12619
12668
  const typeLower = type.toLocaleLowerCase();
12620
12669
  const { close, error, leave, join } = CHANNEL_EVENTS;
12621
12670
  const events = [close, error, leave, join];
@@ -12627,18 +12676,18 @@ var RealtimeChannel = class _RealtimeChannel {
12627
12676
  throw "channel onMessage callbacks must return the payload, modified or unmodified";
12628
12677
  }
12629
12678
  if (["insert", "update", "delete"].includes(typeLower)) {
12630
- (_a60 = this.bindings.postgres_changes) === null || _a60 === void 0 ? void 0 : _a60.filter((bind) => {
12631
- var _a61, _b7, _c;
12632
- return ((_a61 = bind.filter) === null || _a61 === void 0 ? void 0 : _a61.event) === "*" || ((_c = (_b7 = bind.filter) === null || _b7 === void 0 ? void 0 : _b7.event) === null || _c === void 0 ? void 0 : _c.toLocaleLowerCase()) === typeLower;
12679
+ (_a58 = this.bindings.postgres_changes) === null || _a58 === void 0 ? void 0 : _a58.filter((bind) => {
12680
+ var _a59, _b6, _c;
12681
+ return ((_a59 = bind.filter) === null || _a59 === void 0 ? void 0 : _a59.event) === "*" || ((_c = (_b6 = bind.filter) === null || _b6 === void 0 ? void 0 : _b6.event) === null || _c === void 0 ? void 0 : _c.toLocaleLowerCase()) === typeLower;
12633
12682
  }).map((bind) => bind.callback(handledPayload, ref));
12634
12683
  } else {
12635
- (_b6 = this.bindings[typeLower]) === null || _b6 === void 0 ? void 0 : _b6.filter((bind) => {
12636
- var _a61, _b7, _c, _d, _e, _f, _g, _h;
12684
+ (_b5 = this.bindings[typeLower]) === null || _b5 === void 0 ? void 0 : _b5.filter((bind) => {
12685
+ var _a59, _b6, _c, _d, _e, _f, _g, _h;
12637
12686
  if (["broadcast", "presence", "postgres_changes"].includes(typeLower)) {
12638
12687
  if ("id" in bind) {
12639
12688
  const bindId = bind.id;
12640
- const bindEvent = (_a61 = bind.filter) === null || _a61 === void 0 ? void 0 : _a61.event;
12641
- return bindId && ((_b7 = payload.ids) === null || _b7 === void 0 ? void 0 : _b7.includes(bindId)) && (bindEvent === "*" || (bindEvent === null || bindEvent === void 0 ? void 0 : bindEvent.toLocaleLowerCase()) === ((_c = payload.data) === null || _c === void 0 ? void 0 : _c.type.toLocaleLowerCase())) && (!((_d = bind.filter) === null || _d === void 0 ? void 0 : _d.table) || bind.filter.table === ((_e = payload.data) === null || _e === void 0 ? void 0 : _e.table));
12689
+ const bindEvent = (_a59 = bind.filter) === null || _a59 === void 0 ? void 0 : _a59.event;
12690
+ return bindId && ((_b6 = payload.ids) === null || _b6 === void 0 ? void 0 : _b6.includes(bindId)) && (bindEvent === "*" || (bindEvent === null || bindEvent === void 0 ? void 0 : bindEvent.toLocaleLowerCase()) === ((_c = payload.data) === null || _c === void 0 ? void 0 : _c.type.toLocaleLowerCase())) && (!((_d = bind.filter) === null || _d === void 0 ? void 0 : _d.table) || bind.filter.table === ((_e = payload.data) === null || _e === void 0 ? void 0 : _e.table));
12642
12691
  } else {
12643
12692
  const bindEvent = (_g = (_f = bind === null || bind === void 0 ? void 0 : bind.filter) === null || _f === void 0 ? void 0 : _f.event) === null || _g === void 0 ? void 0 : _g.toLocaleLowerCase();
12644
12693
  return bindEvent === "*" || bindEvent === ((_h = payload === null || payload === void 0 ? void 0 : payload.event) === null || _h === void 0 ? void 0 : _h.toLocaleLowerCase());
@@ -12705,8 +12754,8 @@ var RealtimeChannel = class _RealtimeChannel {
12705
12754
  const typeLower = type.toLocaleLowerCase();
12706
12755
  if (this.bindings[typeLower]) {
12707
12756
  this.bindings[typeLower] = this.bindings[typeLower].filter((bind) => {
12708
- var _a60;
12709
- return !(((_a60 = bind.type) === null || _a60 === void 0 ? void 0 : _a60.toLocaleLowerCase()) === typeLower && _RealtimeChannel.isEqual(bind.filter, filter));
12757
+ var _a58;
12758
+ return !(((_a58 = bind.type) === null || _a58 === void 0 ? void 0 : _a58.toLocaleLowerCase()) === typeLower && _RealtimeChannel.isEqual(bind.filter, filter));
12710
12759
  });
12711
12760
  }
12712
12761
  return this;
@@ -12836,7 +12885,7 @@ var RealtimeClient = class {
12836
12885
  * ```
12837
12886
  */
12838
12887
  constructor(endPoint, options) {
12839
- var _a60;
12888
+ var _a58;
12840
12889
  this.accessTokenValue = null;
12841
12890
  this.apiKey = null;
12842
12891
  this._manuallySetToken = false;
@@ -12875,7 +12924,7 @@ var RealtimeClient = class {
12875
12924
  }
12876
12925
  return (...args) => fetch(...args);
12877
12926
  };
12878
- if (!((_a60 = options === null || options === void 0 ? void 0 : options.params) === null || _a60 === void 0 ? void 0 : _a60.apikey)) {
12927
+ if (!((_a58 = options === null || options === void 0 ? void 0 : options.params) === null || _a58 === void 0 ? void 0 : _a58.apikey)) {
12879
12928
  throw new Error("API key is required to connect to Realtime");
12880
12929
  }
12881
12930
  this.apiKey = options.params.apikey;
@@ -13057,8 +13106,8 @@ Option 2: Install and provide the "ws" package:
13057
13106
  const { topic, event, payload, ref } = data;
13058
13107
  const callback = () => {
13059
13108
  this.encode(data, (result) => {
13060
- var _a60;
13061
- (_a60 = this.conn) === null || _a60 === void 0 ? void 0 : _a60.send(result);
13109
+ var _a58;
13110
+ (_a58 = this.conn) === null || _a58 === void 0 ? void 0 : _a58.send(result);
13062
13111
  });
13063
13112
  };
13064
13113
  this.log("push", `${topic} ${event} (${ref})`, payload);
@@ -13108,7 +13157,7 @@ Option 2: Install and provide the "ws" package:
13108
13157
  * Sends a heartbeat message if the socket is connected.
13109
13158
  */
13110
13159
  async sendHeartbeat() {
13111
- var _a60;
13160
+ var _a58;
13112
13161
  if (!this.isConnected()) {
13113
13162
  try {
13114
13163
  this.heartbeatCallback("disconnected");
@@ -13127,11 +13176,11 @@ Option 2: Install and provide the "ws" package:
13127
13176
  this.log("error", "error in heartbeat callback", e);
13128
13177
  }
13129
13178
  this._wasManualDisconnect = false;
13130
- (_a60 = this.conn) === null || _a60 === void 0 ? void 0 : _a60.close(WS_CLOSE_NORMAL, "heartbeat timeout");
13179
+ (_a58 = this.conn) === null || _a58 === void 0 ? void 0 : _a58.close(WS_CLOSE_NORMAL, "heartbeat timeout");
13131
13180
  setTimeout(() => {
13132
- var _a61;
13181
+ var _a59;
13133
13182
  if (!this.isConnected()) {
13134
- (_a61 = this.reconnectTimer) === null || _a61 === void 0 ? void 0 : _a61.scheduleTimeout();
13183
+ (_a59 = this.reconnectTimer) === null || _a59 === void 0 ? void 0 : _a59.scheduleTimeout();
13135
13184
  }
13136
13185
  }, CONNECTION_TIMEOUTS.HEARTBEAT_TIMEOUT_FALLBACK);
13137
13186
  return;
@@ -13229,12 +13278,12 @@ Option 2: Install and provide the "ws" package:
13229
13278
  * @internal
13230
13279
  */
13231
13280
  _clearTimer(timer) {
13232
- var _a60;
13281
+ var _a58;
13233
13282
  if (timer === "heartbeat" && this.heartbeatTimer) {
13234
13283
  clearInterval(this.heartbeatTimer);
13235
13284
  this.heartbeatTimer = void 0;
13236
13285
  } else if (timer === "reconnect") {
13237
- (_a60 = this.reconnectTimer) === null || _a60 === void 0 ? void 0 : _a60.reset();
13286
+ (_a58 = this.reconnectTimer) === null || _a58 === void 0 ? void 0 : _a58.reset();
13238
13287
  }
13239
13288
  }
13240
13289
  /**
@@ -13349,13 +13398,13 @@ Option 2: Install and provide the "ws" package:
13349
13398
  }
13350
13399
  /** @internal */
13351
13400
  _onConnClose(event) {
13352
- var _a60;
13401
+ var _a58;
13353
13402
  this._setConnectionState("disconnected");
13354
13403
  this.log("transport", "close", event);
13355
13404
  this._triggerChanError();
13356
13405
  this._clearTimer("heartbeat");
13357
13406
  if (!this._wasManualDisconnect) {
13358
- (_a60 = this.reconnectTimer) === null || _a60 === void 0 ? void 0 : _a60.scheduleTimeout();
13407
+ (_a58 = this.reconnectTimer) === null || _a58 === void 0 ? void 0 : _a58.scheduleTimeout();
13359
13408
  }
13360
13409
  this._triggerStateCallbacks("close", event);
13361
13410
  }
@@ -13498,9 +13547,9 @@ Option 2: Install and provide the "ws" package:
13498
13547
  * @internal
13499
13548
  */
13500
13549
  _initializeOptions(options) {
13501
- var _a60, _b6, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
13502
- this.transport = (_a60 = options === null || options === void 0 ? void 0 : options.transport) !== null && _a60 !== void 0 ? _a60 : null;
13503
- this.timeout = (_b6 = options === null || options === void 0 ? void 0 : options.timeout) !== null && _b6 !== void 0 ? _b6 : DEFAULT_TIMEOUT;
13550
+ var _a58, _b5, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
13551
+ this.transport = (_a58 = options === null || options === void 0 ? void 0 : options.transport) !== null && _a58 !== void 0 ? _a58 : null;
13552
+ this.timeout = (_b5 = options === null || options === void 0 ? void 0 : options.timeout) !== null && _b5 !== void 0 ? _b5 : DEFAULT_TIMEOUT;
13504
13553
  this.heartbeatIntervalMs = (_c = options === null || options === void 0 ? void 0 : options.heartbeatIntervalMs) !== null && _c !== void 0 ? _c : CONNECTION_TIMEOUTS.HEARTBEAT_INTERVAL;
13505
13554
  this.worker = (_d = options === null || options === void 0 ? void 0 : options.worker) !== null && _d !== void 0 ? _d : false;
13506
13555
  this.accessToken = (_e = options === null || options === void 0 ? void 0 : options.accessToken) !== null && _e !== void 0 ? _e : null;
@@ -13545,14 +13594,14 @@ Option 2: Install and provide the "ws" package:
13545
13594
  // node_modules/iceberg-js/dist/index.mjs
13546
13595
  var IcebergError = class extends Error {
13547
13596
  constructor(message, opts) {
13548
- var _a60;
13597
+ var _a58;
13549
13598
  super(message);
13550
13599
  this.name = "IcebergError";
13551
13600
  this.status = opts.status;
13552
13601
  this.icebergType = opts.icebergType;
13553
13602
  this.icebergCode = opts.icebergCode;
13554
13603
  this.details = opts.details;
13555
- this.isCommitStateUnknown = opts.icebergType === "CommitStateUnknownException" || [500, 502, 504].includes(opts.status) && ((_a60 = opts.icebergType) == null ? void 0 : _a60.includes("CommitState")) === true;
13604
+ this.isCommitStateUnknown = opts.icebergType === "CommitStateUnknownException" || [500, 502, 504].includes(opts.status) && ((_a58 = opts.icebergType) == null ? void 0 : _a58.includes("CommitState")) === true;
13556
13605
  }
13557
13606
  /**
13558
13607
  * Returns true if the error is a 404 Not Found error.
@@ -13600,8 +13649,8 @@ async function buildAuthHeaders(auth) {
13600
13649
  return {};
13601
13650
  }
13602
13651
  function createFetchClient(options) {
13603
- var _a60;
13604
- const fetchFn = (_a60 = options.fetchImpl) != null ? _a60 : globalThis.fetch;
13652
+ var _a58;
13653
+ const fetchFn = (_a58 = options.fetchImpl) != null ? _a58 : globalThis.fetch;
13605
13654
  return {
13606
13655
  async request({
13607
13656
  method,
@@ -13610,7 +13659,7 @@ function createFetchClient(options) {
13610
13659
  body,
13611
13660
  headers
13612
13661
  }) {
13613
- var _a61;
13662
+ var _a59;
13614
13663
  const url = buildUrl(options.baseUrl, path, query);
13615
13664
  const authHeaders = await buildAuthHeaders(options.auth);
13616
13665
  const res = await fetchFn(url, {
@@ -13629,7 +13678,7 @@ function createFetchClient(options) {
13629
13678
  const errBody = isJson ? data : void 0;
13630
13679
  const errorDetail = errBody == null ? void 0 : errBody.error;
13631
13680
  throw new IcebergError(
13632
- (_a61 = errorDetail == null ? void 0 : errorDetail.message) != null ? _a61 : `Request failed with status ${res.status}`,
13681
+ (_a59 = errorDetail == null ? void 0 : errorDetail.message) != null ? _a59 : `Request failed with status ${res.status}`,
13633
13682
  {
13634
13683
  status: res.status,
13635
13684
  icebergType: errorDetail == null ? void 0 : errorDetail.type,
@@ -13752,11 +13801,11 @@ var TableOperations = class {
13752
13801
  };
13753
13802
  }
13754
13803
  async dropTable(id, options) {
13755
- var _a60;
13804
+ var _a58;
13756
13805
  await this.client.request({
13757
13806
  method: "DELETE",
13758
13807
  path: `${this.prefix}/namespaces/${namespaceToPath2(id.namespace)}/tables/${id.name}`,
13759
- query: { purgeRequested: String((_a60 = options == null ? void 0 : options.purge) != null ? _a60 : false) }
13808
+ query: { purgeRequested: String((_a58 = options == null ? void 0 : options.purge) != null ? _a58 : false) }
13760
13809
  });
13761
13810
  }
13762
13811
  async loadTable(id) {
@@ -13808,7 +13857,7 @@ var IcebergRestCatalog = class {
13808
13857
  * @param options - Configuration options for the catalog client
13809
13858
  */
13810
13859
  constructor(options) {
13811
- var _a60;
13860
+ var _a58;
13812
13861
  let prefix = "v1";
13813
13862
  if (options.catalogName) {
13814
13863
  prefix += `/${options.catalogName}`;
@@ -13819,7 +13868,7 @@ var IcebergRestCatalog = class {
13819
13868
  auth: options.auth,
13820
13869
  fetchImpl: options.fetch
13821
13870
  });
13822
- this.accessDelegation = (_a60 = options.accessDelegation) == null ? void 0 : _a60.join(",");
13871
+ this.accessDelegation = (_a58 = options.accessDelegation) == null ? void 0 : _a58.join(",");
13823
13872
  this.namespaceOps = new NamespaceOperations(this.client, prefix);
13824
13873
  this.tableOps = new TableOperations(this.client, prefix, this.accessDelegation);
13825
13874
  }
@@ -17158,7 +17207,7 @@ var getItemAsync = async (storage, key) => {
17158
17207
  }
17159
17208
  try {
17160
17209
  return JSON.parse(value);
17161
- } catch (_a60) {
17210
+ } catch (_a58) {
17162
17211
  return value;
17163
17212
  }
17164
17213
  };
@@ -17369,7 +17418,7 @@ function deepClone(obj) {
17369
17418
  var _getErrorMessage2 = (err) => err.msg || err.message || err.error_description || err.error || JSON.stringify(err);
17370
17419
  var NETWORK_ERROR_CODES = [502, 503, 504];
17371
17420
  async function handleError2(error) {
17372
- var _a60;
17421
+ var _a58;
17373
17422
  if (!looksLikeFetchResponse(error)) {
17374
17423
  throw new AuthRetryableFetchError(_getErrorMessage2(error), 0);
17375
17424
  }
@@ -17394,7 +17443,7 @@ async function handleError2(error) {
17394
17443
  throw new AuthWeakPasswordError(_getErrorMessage2(data), error.status, data.weak_password.reasons);
17395
17444
  }
17396
17445
  } else if (errorCode === "weak_password") {
17397
- throw new AuthWeakPasswordError(_getErrorMessage2(data), error.status, ((_a60 = data.weak_password) === null || _a60 === void 0 ? void 0 : _a60.reasons) || []);
17446
+ throw new AuthWeakPasswordError(_getErrorMessage2(data), error.status, ((_a58 = data.weak_password) === null || _a58 === void 0 ? void 0 : _a58.reasons) || []);
17398
17447
  } else if (errorCode === "session_not_found") {
17399
17448
  throw new AuthSessionMissingError();
17400
17449
  }
@@ -17410,7 +17459,7 @@ var _getRequestParams2 = (method, options, parameters, body) => {
17410
17459
  return Object.assign(Object.assign({}, params), parameters);
17411
17460
  };
17412
17461
  async function _request(fetcher, method, url, options) {
17413
- var _a60;
17462
+ var _a58;
17414
17463
  const headers = Object.assign({}, options === null || options === void 0 ? void 0 : options.headers);
17415
17464
  if (!headers[API_VERSION_HEADER_NAME]) {
17416
17465
  headers[API_VERSION_HEADER_NAME] = API_VERSIONS["2024-01-01"].name;
@@ -17418,7 +17467,7 @@ async function _request(fetcher, method, url, options) {
17418
17467
  if (options === null || options === void 0 ? void 0 : options.jwt) {
17419
17468
  headers["Authorization"] = `Bearer ${options.jwt}`;
17420
17469
  }
17421
- const qs = (_a60 = options === null || options === void 0 ? void 0 : options.query) !== null && _a60 !== void 0 ? _a60 : {};
17470
+ const qs = (_a58 = options === null || options === void 0 ? void 0 : options.query) !== null && _a58 !== void 0 ? _a58 : {};
17422
17471
  if (options === null || options === void 0 ? void 0 : options.redirectTo) {
17423
17472
  qs["redirect_to"] = options.redirectTo;
17424
17473
  }
@@ -17451,7 +17500,7 @@ async function _handleRequest2(fetcher, method, url, options, parameters, body)
17451
17500
  }
17452
17501
  }
17453
17502
  function _sessionResponse(data) {
17454
- var _a60;
17503
+ var _a58;
17455
17504
  let session = null;
17456
17505
  if (hasSession(data)) {
17457
17506
  session = Object.assign({}, data);
@@ -17459,7 +17508,7 @@ function _sessionResponse(data) {
17459
17508
  session.expires_at = expiresAt(data.expires_in);
17460
17509
  }
17461
17510
  }
17462
- const user = (_a60 = data.user) !== null && _a60 !== void 0 ? _a60 : data;
17511
+ const user = (_a58 = data.user) !== null && _a58 !== void 0 ? _a58 : data;
17463
17512
  return { data: { session, user }, error: null };
17464
17513
  }
17465
17514
  function _sessionResponsePassword(data) {
@@ -17470,8 +17519,8 @@ function _sessionResponsePassword(data) {
17470
17519
  return response;
17471
17520
  }
17472
17521
  function _userResponse(data) {
17473
- var _a60;
17474
- const user = (_a60 = data.user) !== null && _a60 !== void 0 ? _a60 : data;
17522
+ var _a58;
17523
+ const user = (_a58 = data.user) !== null && _a58 !== void 0 ? _a58 : data;
17475
17524
  return { data: { user }, error: null };
17476
17525
  }
17477
17526
  function _ssoResponse(data) {
@@ -17640,14 +17689,14 @@ var GoTrueAdminApi = class {
17640
17689
  * @param params An object which supports `page` and `perPage` as numbers, to alter the paginated results.
17641
17690
  */
17642
17691
  async listUsers(params) {
17643
- var _a60, _b6, _c, _d, _e, _f, _g;
17692
+ var _a58, _b5, _c, _d, _e, _f, _g;
17644
17693
  try {
17645
17694
  const pagination = { nextPage: null, lastPage: 0, total: 0 };
17646
17695
  const response = await _request(this.fetch, "GET", `${this.url}/admin/users`, {
17647
17696
  headers: this.headers,
17648
17697
  noResolveJson: true,
17649
17698
  query: {
17650
- page: (_b6 = (_a60 = params === null || params === void 0 ? void 0 : params.page) === null || _a60 === void 0 ? void 0 : _a60.toString()) !== null && _b6 !== void 0 ? _b6 : "",
17699
+ page: (_b5 = (_a58 = params === null || params === void 0 ? void 0 : params.page) === null || _a58 === void 0 ? void 0 : _a58.toString()) !== null && _b5 !== void 0 ? _b5 : "",
17651
17700
  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 : ""
17652
17701
  },
17653
17702
  xform: _noResolveJsonResponse
@@ -17781,14 +17830,14 @@ var GoTrueAdminApi = class {
17781
17830
  * This function should only be called on a server. Never expose your `service_role` key in the browser.
17782
17831
  */
17783
17832
  async _listOAuthClients(params) {
17784
- var _a60, _b6, _c, _d, _e, _f, _g;
17833
+ var _a58, _b5, _c, _d, _e, _f, _g;
17785
17834
  try {
17786
17835
  const pagination = { nextPage: null, lastPage: 0, total: 0 };
17787
17836
  const response = await _request(this.fetch, "GET", `${this.url}/admin/oauth/clients`, {
17788
17837
  headers: this.headers,
17789
17838
  noResolveJson: true,
17790
17839
  query: {
17791
- page: (_b6 = (_a60 = params === null || params === void 0 ? void 0 : params.page) === null || _a60 === void 0 ? void 0 : _a60.toString()) !== null && _b6 !== void 0 ? _b6 : "",
17840
+ page: (_b5 = (_a58 = params === null || params === void 0 ? void 0 : params.page) === null || _a58 === void 0 ? void 0 : _a58.toString()) !== null && _b5 !== void 0 ? _b5 : "",
17792
17841
  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 : ""
17793
17842
  },
17794
17843
  xform: _noResolveJsonResponse
@@ -18041,7 +18090,7 @@ function toHex(value) {
18041
18090
  return "0x" + hex;
18042
18091
  }
18043
18092
  function createSiweMessage(parameters) {
18044
- var _a60;
18093
+ var _a58;
18045
18094
  const { chainId, domain, expirationTime, issuedAt = /* @__PURE__ */ new Date(), nonce, notBefore, requestId, resources, scheme, uri, version: version5 } = parameters;
18046
18095
  {
18047
18096
  if (!Number.isInteger(chainId))
@@ -18054,7 +18103,7 @@ function createSiweMessage(parameters) {
18054
18103
  throw new Error(`@supabase/auth-js: Invalid SIWE message field "uri". URI must be provided.`);
18055
18104
  if (version5 !== "1")
18056
18105
  throw new Error(`@supabase/auth-js: Invalid SIWE message field "version". Version must be '1'. Provided value: ${version5}`);
18057
- if ((_a60 = parameters.statement) === null || _a60 === void 0 ? void 0 : _a60.includes("\n"))
18106
+ if ((_a58 = parameters.statement) === null || _a58 === void 0 ? void 0 : _a58.includes("\n"))
18058
18107
  throw new Error(`@supabase/auth-js: Invalid SIWE message field "statement". Statement must not include '\\n'. Provided value: ${parameters.statement}`);
18059
18108
  }
18060
18109
  const address = getAddress(parameters.address);
@@ -18096,10 +18145,10 @@ ${suffix}`;
18096
18145
  // node_modules/@supabase/auth-js/dist/module/lib/webauthn.errors.js
18097
18146
  var WebAuthnError = class extends Error {
18098
18147
  constructor({ message, code, cause, name }) {
18099
- var _a60;
18148
+ var _a58;
18100
18149
  super(message, { cause });
18101
18150
  this.__isWebAuthnError = true;
18102
- this.name = (_a60 = name !== null && name !== void 0 ? name : cause instanceof Error ? cause.name : void 0) !== null && _a60 !== void 0 ? _a60 : "Unknown Error";
18151
+ this.name = (_a58 = name !== null && name !== void 0 ? name : cause instanceof Error ? cause.name : void 0) !== null && _a58 !== void 0 ? _a58 : "Unknown Error";
18103
18152
  this.code = code;
18104
18153
  }
18105
18154
  };
@@ -18115,7 +18164,7 @@ var WebAuthnUnknownError = class extends WebAuthnError {
18115
18164
  }
18116
18165
  };
18117
18166
  function identifyRegistrationError({ error, options }) {
18118
- var _a60, _b6, _c;
18167
+ var _a58, _b5, _c;
18119
18168
  const { publicKey } = options;
18120
18169
  if (!publicKey) {
18121
18170
  throw Error("options was missing required publicKey property");
@@ -18129,7 +18178,7 @@ function identifyRegistrationError({ error, options }) {
18129
18178
  });
18130
18179
  }
18131
18180
  } else if (error.name === "ConstraintError") {
18132
- if (((_a60 = publicKey.authenticatorSelection) === null || _a60 === void 0 ? void 0 : _a60.requireResidentKey) === true) {
18181
+ if (((_a58 = publicKey.authenticatorSelection) === null || _a58 === void 0 ? void 0 : _a58.requireResidentKey) === true) {
18133
18182
  return new WebAuthnError({
18134
18183
  message: "Discoverable credentials were required but no available authenticator supported it",
18135
18184
  code: "ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",
@@ -18137,7 +18186,7 @@ function identifyRegistrationError({ error, options }) {
18137
18186
  });
18138
18187
  } else if (
18139
18188
  // @ts-ignore: `mediation` doesn't yet exist on CredentialCreationOptions but it's possible as of Sept 2024
18140
- options.mediation === "conditional" && ((_b6 = publicKey.authenticatorSelection) === null || _b6 === void 0 ? void 0 : _b6.userVerification) === "required"
18189
+ options.mediation === "conditional" && ((_b5 = publicKey.authenticatorSelection) === null || _b5 === void 0 ? void 0 : _b5.userVerification) === "required"
18141
18190
  ) {
18142
18191
  return new WebAuthnError({
18143
18192
  message: "User verification was required during automatic registration but it could not be performed",
@@ -18358,7 +18407,7 @@ function deserializeCredentialRequestOptions(options) {
18358
18407
  return result;
18359
18408
  }
18360
18409
  function serializeCredentialCreationResponse(credential) {
18361
- var _a60;
18410
+ var _a58;
18362
18411
  if ("toJSON" in credential && typeof credential.toJSON === "function") {
18363
18412
  return credential.toJSON();
18364
18413
  }
@@ -18373,11 +18422,11 @@ function serializeCredentialCreationResponse(credential) {
18373
18422
  type: "public-key",
18374
18423
  clientExtensionResults: credential.getClientExtensionResults(),
18375
18424
  // Convert null to undefined and cast to AuthenticatorAttachment type
18376
- authenticatorAttachment: (_a60 = credentialWithAttachment.authenticatorAttachment) !== null && _a60 !== void 0 ? _a60 : void 0
18425
+ authenticatorAttachment: (_a58 = credentialWithAttachment.authenticatorAttachment) !== null && _a58 !== void 0 ? _a58 : void 0
18377
18426
  };
18378
18427
  }
18379
18428
  function serializeCredentialRequestResponse(credential) {
18380
- var _a60;
18429
+ var _a58;
18381
18430
  if ("toJSON" in credential && typeof credential.toJSON === "function") {
18382
18431
  return credential.toJSON();
18383
18432
  }
@@ -18397,7 +18446,7 @@ function serializeCredentialRequestResponse(credential) {
18397
18446
  type: "public-key",
18398
18447
  clientExtensionResults,
18399
18448
  // Convert null to undefined and cast to AuthenticatorAttachment type
18400
- authenticatorAttachment: (_a60 = credentialWithAttachment.authenticatorAttachment) !== null && _a60 !== void 0 ? _a60 : void 0
18449
+ authenticatorAttachment: (_a58 = credentialWithAttachment.authenticatorAttachment) !== null && _a58 !== void 0 ? _a58 : void 0
18401
18450
  };
18402
18451
  }
18403
18452
  function isValidDomain(hostname) {
@@ -18407,8 +18456,8 @@ function isValidDomain(hostname) {
18407
18456
  );
18408
18457
  }
18409
18458
  function browserSupportsWebAuthn() {
18410
- var _a60, _b6;
18411
- return !!(isBrowser() && "PublicKeyCredential" in window && window.PublicKeyCredential && "credentials" in navigator && typeof ((_a60 = navigator === null || navigator === void 0 ? void 0 : navigator.credentials) === null || _a60 === void 0 ? void 0 : _a60.create) === "function" && typeof ((_b6 = navigator === null || navigator === void 0 ? void 0 : navigator.credentials) === null || _b6 === void 0 ? void 0 : _b6.get) === "function");
18459
+ var _a58, _b5;
18460
+ return !!(isBrowser() && "PublicKeyCredential" in window && window.PublicKeyCredential && "credentials" in navigator && typeof ((_a58 = navigator === null || navigator === void 0 ? void 0 : navigator.credentials) === null || _a58 === void 0 ? void 0 : _a58.create) === "function" && typeof ((_b5 = navigator === null || navigator === void 0 ? void 0 : navigator.credentials) === null || _b5 === void 0 ? void 0 : _b5.get) === "function");
18412
18461
  }
18413
18462
  async function createCredential(options) {
18414
18463
  try {
@@ -18737,8 +18786,8 @@ var WebAuthnApi = class {
18737
18786
  });
18738
18787
  if (!factor) {
18739
18788
  await this.client.mfa.listFactors().then((factors) => {
18740
- var _a60;
18741
- return (_a60 = factors.data) === null || _a60 === void 0 ? void 0 : _a60.all.find((v) => v.factor_type === "webauthn" && v.friendly_name === friendlyName && v.status !== "unverified");
18789
+ var _a58;
18790
+ return (_a58 = factors.data) === null || _a58 === void 0 ? void 0 : _a58.all.find((v) => v.factor_type === "webauthn" && v.friendly_name === friendlyName && v.status !== "unverified");
18742
18791
  }).then((factor2) => factor2 ? this.client.mfa.unenroll({ factorId: factor2 === null || factor2 === void 0 ? void 0 : factor2.id }) : void 0);
18743
18792
  return { data: null, error: enrollError };
18744
18793
  }
@@ -18800,15 +18849,15 @@ var GoTrueClient = class _GoTrueClient {
18800
18849
  * The JWKS used for verifying asymmetric JWTs
18801
18850
  */
18802
18851
  get jwks() {
18803
- var _a60, _b6;
18804
- return (_b6 = (_a60 = GLOBAL_JWKS[this.storageKey]) === null || _a60 === void 0 ? void 0 : _a60.jwks) !== null && _b6 !== void 0 ? _b6 : { keys: [] };
18852
+ var _a58, _b5;
18853
+ return (_b5 = (_a58 = GLOBAL_JWKS[this.storageKey]) === null || _a58 === void 0 ? void 0 : _a58.jwks) !== null && _b5 !== void 0 ? _b5 : { keys: [] };
18805
18854
  }
18806
18855
  set jwks(value) {
18807
18856
  GLOBAL_JWKS[this.storageKey] = Object.assign(Object.assign({}, GLOBAL_JWKS[this.storageKey]), { jwks: value });
18808
18857
  }
18809
18858
  get jwks_cached_at() {
18810
- var _a60, _b6;
18811
- return (_b6 = (_a60 = GLOBAL_JWKS[this.storageKey]) === null || _a60 === void 0 ? void 0 : _a60.cachedAt) !== null && _b6 !== void 0 ? _b6 : Number.MIN_SAFE_INTEGER;
18859
+ var _a58, _b5;
18860
+ return (_b5 = (_a58 = GLOBAL_JWKS[this.storageKey]) === null || _a58 === void 0 ? void 0 : _a58.cachedAt) !== null && _b5 !== void 0 ? _b5 : Number.MIN_SAFE_INTEGER;
18812
18861
  }
18813
18862
  set jwks_cached_at(value) {
18814
18863
  GLOBAL_JWKS[this.storageKey] = Object.assign(Object.assign({}, GLOBAL_JWKS[this.storageKey]), { cachedAt: value });
@@ -18828,7 +18877,7 @@ var GoTrueClient = class _GoTrueClient {
18828
18877
  * ```
18829
18878
  */
18830
18879
  constructor(options) {
18831
- var _a60, _b6, _c;
18880
+ var _a58, _b5, _c;
18832
18881
  this.userStorage = null;
18833
18882
  this.memoryStorage = null;
18834
18883
  this.stateChangeEmitters = /* @__PURE__ */ new Map();
@@ -18846,7 +18895,7 @@ var GoTrueClient = class _GoTrueClient {
18846
18895
  this.logger = console.log;
18847
18896
  const settings = Object.assign(Object.assign({}, DEFAULT_OPTIONS), options);
18848
18897
  this.storageKey = settings.storageKey;
18849
- this.instanceID = (_a60 = _GoTrueClient.nextInstanceID[this.storageKey]) !== null && _a60 !== void 0 ? _a60 : 0;
18898
+ this.instanceID = (_a58 = _GoTrueClient.nextInstanceID[this.storageKey]) !== null && _a58 !== void 0 ? _a58 : 0;
18850
18899
  _GoTrueClient.nextInstanceID[this.storageKey] = this.instanceID + 1;
18851
18900
  this.logDebugMessages = !!settings.debug;
18852
18901
  if (typeof settings.debug === "function") {
@@ -18877,7 +18926,7 @@ var GoTrueClient = class _GoTrueClient {
18877
18926
  this.lockAcquireTimeout = settings.lockAcquireTimeout;
18878
18927
  if (settings.lock) {
18879
18928
  this.lock = settings.lock;
18880
- } else if (this.persistSession && isBrowser() && ((_b6 = globalThis === null || globalThis === void 0 ? void 0 : globalThis.navigator) === null || _b6 === void 0 ? void 0 : _b6.locks)) {
18929
+ } else if (this.persistSession && isBrowser() && ((_b5 = globalThis === null || globalThis === void 0 ? void 0 : globalThis.navigator) === null || _b5 === void 0 ? void 0 : _b5.locks)) {
18881
18930
  this.lock = navigatorLock;
18882
18931
  } else {
18883
18932
  this.lock = lockNoOp;
@@ -18983,7 +19032,7 @@ var GoTrueClient = class _GoTrueClient {
18983
19032
  * the whole lifetime of the client
18984
19033
  */
18985
19034
  async _initialize() {
18986
- var _a60;
19035
+ var _a58;
18987
19036
  try {
18988
19037
  let params = {};
18989
19038
  let callbackUrlType = "none";
@@ -19000,7 +19049,7 @@ var GoTrueClient = class _GoTrueClient {
19000
19049
  if (error) {
19001
19050
  this._debug("#_initialize()", "error detecting session from URL", error);
19002
19051
  if (isAuthImplicitGrantRedirectError(error)) {
19003
- const errorCode = (_a60 = error.details) === null || _a60 === void 0 ? void 0 : _a60.code;
19052
+ const errorCode = (_a58 = error.details) === null || _a58 === void 0 ? void 0 : _a58.code;
19004
19053
  if (errorCode === "identity_already_exists" || errorCode === "identity_not_found" || errorCode === "single_identity_not_deletable") {
19005
19054
  return { error };
19006
19055
  }
@@ -19039,12 +19088,12 @@ var GoTrueClient = class _GoTrueClient {
19039
19088
  * @returns A session where the is_anonymous claim in the access token JWT set to true
19040
19089
  */
19041
19090
  async signInAnonymously(credentials) {
19042
- var _a60, _b6, _c;
19091
+ var _a58, _b5, _c;
19043
19092
  try {
19044
19093
  const res = await _request(this.fetch, "POST", `${this.url}/signup`, {
19045
19094
  headers: this.headers,
19046
19095
  body: {
19047
- data: (_b6 = (_a60 = credentials === null || credentials === void 0 ? void 0 : credentials.options) === null || _a60 === void 0 ? void 0 : _a60.data) !== null && _b6 !== void 0 ? _b6 : {},
19096
+ data: (_b5 = (_a58 = credentials === null || credentials === void 0 ? void 0 : credentials.options) === null || _a58 === void 0 ? void 0 : _a58.data) !== null && _b5 !== void 0 ? _b5 : {},
19048
19097
  gotrue_meta_security: { captcha_token: (_c = credentials === null || credentials === void 0 ? void 0 : credentials.options) === null || _c === void 0 ? void 0 : _c.captchaToken }
19049
19098
  },
19050
19099
  xform: _sessionResponse
@@ -19078,7 +19127,7 @@ var GoTrueClient = class _GoTrueClient {
19078
19127
  * @returns A user if the server has "autoconfirm" OFF
19079
19128
  */
19080
19129
  async signUp(credentials) {
19081
- var _a60, _b6, _c;
19130
+ var _a58, _b5, _c;
19082
19131
  try {
19083
19132
  let res;
19084
19133
  if ("email" in credentials) {
@@ -19095,7 +19144,7 @@ var GoTrueClient = class _GoTrueClient {
19095
19144
  body: {
19096
19145
  email,
19097
19146
  password,
19098
- data: (_a60 = options === null || options === void 0 ? void 0 : options.data) !== null && _a60 !== void 0 ? _a60 : {},
19147
+ data: (_a58 = options === null || options === void 0 ? void 0 : options.data) !== null && _a58 !== void 0 ? _a58 : {},
19099
19148
  gotrue_meta_security: { captcha_token: options === null || options === void 0 ? void 0 : options.captchaToken },
19100
19149
  code_challenge: codeChallenge,
19101
19150
  code_challenge_method: codeChallengeMethod
@@ -19109,7 +19158,7 @@ var GoTrueClient = class _GoTrueClient {
19109
19158
  body: {
19110
19159
  phone,
19111
19160
  password,
19112
- data: (_b6 = options === null || options === void 0 ? void 0 : options.data) !== null && _b6 !== void 0 ? _b6 : {},
19161
+ data: (_b5 = options === null || options === void 0 ? void 0 : options.data) !== null && _b5 !== void 0 ? _b5 : {},
19113
19162
  channel: (_c = options === null || options === void 0 ? void 0 : options.channel) !== null && _c !== void 0 ? _c : "sms",
19114
19163
  gotrue_meta_security: { captcha_token: options === null || options === void 0 ? void 0 : options.captchaToken }
19115
19164
  },
@@ -19201,10 +19250,10 @@ var GoTrueClient = class _GoTrueClient {
19201
19250
  * This method supports the PKCE flow.
19202
19251
  */
19203
19252
  async signInWithOAuth(credentials) {
19204
- var _a60, _b6, _c, _d;
19253
+ var _a58, _b5, _c, _d;
19205
19254
  return await this._handleProviderSignIn(credentials.provider, {
19206
- redirectTo: (_a60 = credentials.options) === null || _a60 === void 0 ? void 0 : _a60.redirectTo,
19207
- scopes: (_b6 = credentials.options) === null || _b6 === void 0 ? void 0 : _b6.scopes,
19255
+ redirectTo: (_a58 = credentials.options) === null || _a58 === void 0 ? void 0 : _a58.redirectTo,
19256
+ scopes: (_b5 = credentials.options) === null || _b5 === void 0 ? void 0 : _b5.scopes,
19208
19257
  queryParams: (_c = credentials.options) === null || _c === void 0 ? void 0 : _c.queryParams,
19209
19258
  skipBrowserRedirect: (_d = credentials.options) === null || _d === void 0 ? void 0 : _d.skipBrowserRedirect
19210
19259
  });
@@ -19237,7 +19286,7 @@ var GoTrueClient = class _GoTrueClient {
19237
19286
  }
19238
19287
  }
19239
19288
  async signInWithEthereum(credentials) {
19240
- var _a60, _b6, _c, _d, _e, _f, _g, _h, _j, _k, _l;
19289
+ var _a58, _b5, _c, _d, _e, _f, _g, _h, _j, _k, _l;
19241
19290
  let message;
19242
19291
  let signature;
19243
19292
  if ("message" in credentials) {
@@ -19261,7 +19310,7 @@ var GoTrueClient = class _GoTrueClient {
19261
19310
  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.`);
19262
19311
  }
19263
19312
  }
19264
- const url = new URL((_a60 = options === null || options === void 0 ? void 0 : options.url) !== null && _a60 !== void 0 ? _a60 : window.location.href);
19313
+ const url = new URL((_a58 = options === null || options === void 0 ? void 0 : options.url) !== null && _a58 !== void 0 ? _a58 : window.location.href);
19265
19314
  const accounts = await resolvedWallet.request({
19266
19315
  method: "eth_requestAccounts"
19267
19316
  }).then((accs) => accs).catch(() => {
@@ -19271,7 +19320,7 @@ var GoTrueClient = class _GoTrueClient {
19271
19320
  throw new Error(`@supabase/auth-js: No accounts available. Please ensure the wallet is connected.`);
19272
19321
  }
19273
19322
  const address = getAddress(accounts[0]);
19274
- let chainId = (_b6 = options === null || options === void 0 ? void 0 : options.signInWithEthereum) === null || _b6 === void 0 ? void 0 : _b6.chainId;
19323
+ let chainId = (_b5 = options === null || options === void 0 ? void 0 : options.signInWithEthereum) === null || _b5 === void 0 ? void 0 : _b5.chainId;
19275
19324
  if (!chainId) {
19276
19325
  const chainIdHex = await resolvedWallet.request({
19277
19326
  method: "eth_chainId"
@@ -19328,7 +19377,7 @@ var GoTrueClient = class _GoTrueClient {
19328
19377
  }
19329
19378
  }
19330
19379
  async signInWithSolana(credentials) {
19331
- var _a60, _b6, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
19380
+ var _a58, _b5, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
19332
19381
  let message;
19333
19382
  let signature;
19334
19383
  if ("message" in credentials) {
@@ -19352,7 +19401,7 @@ var GoTrueClient = class _GoTrueClient {
19352
19401
  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.`);
19353
19402
  }
19354
19403
  }
19355
- const url = new URL((_a60 = options === null || options === void 0 ? void 0 : options.url) !== null && _a60 !== void 0 ? _a60 : window.location.href);
19404
+ const url = new URL((_a58 = options === null || options === void 0 ? void 0 : options.url) !== null && _a58 !== void 0 ? _a58 : window.location.href);
19356
19405
  if ("signIn" in resolvedWallet && resolvedWallet.signIn) {
19357
19406
  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), {
19358
19407
  // non-overridable properties
@@ -19384,7 +19433,7 @@ var GoTrueClient = class _GoTrueClient {
19384
19433
  ...statement ? ["", statement, ""] : [""],
19385
19434
  "Version: 1",
19386
19435
  `URI: ${url.href}`,
19387
- `Issued At: ${(_c = (_b6 = options === null || options === void 0 ? void 0 : options.signInWithSolana) === null || _b6 === void 0 ? void 0 : _b6.issuedAt) !== null && _c !== void 0 ? _c : (/* @__PURE__ */ new Date()).toISOString()}`,
19436
+ `Issued At: ${(_c = (_b5 = options === null || options === void 0 ? void 0 : options.signInWithSolana) === null || _b5 === void 0 ? void 0 : _b5.issuedAt) !== null && _c !== void 0 ? _c : (/* @__PURE__ */ new Date()).toISOString()}`,
19388
19437
  ...((_d = options === null || options === void 0 ? void 0 : options.signInWithSolana) === null || _d === void 0 ? void 0 : _d.notBefore) ? [`Not Before: ${options.signInWithSolana.notBefore}`] : [],
19389
19438
  ...((_e = options === null || options === void 0 ? void 0 : options.signInWithSolana) === null || _e === void 0 ? void 0 : _e.expirationTime) ? [`Expiration Time: ${options.signInWithSolana.expirationTime}`] : [],
19390
19439
  ...((_f = options === null || options === void 0 ? void 0 : options.signInWithSolana) === null || _f === void 0 ? void 0 : _f.chainId) ? [`Chain ID: ${options.signInWithSolana.chainId}`] : [],
@@ -19526,7 +19575,7 @@ var GoTrueClient = class _GoTrueClient {
19526
19575
  * This method supports PKCE when an email is passed.
19527
19576
  */
19528
19577
  async signInWithOtp(credentials) {
19529
- var _a60, _b6, _c, _d, _e;
19578
+ var _a58, _b5, _c, _d, _e;
19530
19579
  try {
19531
19580
  if ("email" in credentials) {
19532
19581
  const { email, options } = credentials;
@@ -19540,8 +19589,8 @@ var GoTrueClient = class _GoTrueClient {
19540
19589
  headers: this.headers,
19541
19590
  body: {
19542
19591
  email,
19543
- data: (_a60 = options === null || options === void 0 ? void 0 : options.data) !== null && _a60 !== void 0 ? _a60 : {},
19544
- create_user: (_b6 = options === null || options === void 0 ? void 0 : options.shouldCreateUser) !== null && _b6 !== void 0 ? _b6 : true,
19592
+ data: (_a58 = options === null || options === void 0 ? void 0 : options.data) !== null && _a58 !== void 0 ? _a58 : {},
19593
+ create_user: (_b5 = options === null || options === void 0 ? void 0 : options.shouldCreateUser) !== null && _b5 !== void 0 ? _b5 : true,
19545
19594
  gotrue_meta_security: { captcha_token: options === null || options === void 0 ? void 0 : options.captchaToken },
19546
19595
  code_challenge: codeChallenge,
19547
19596
  code_challenge_method: codeChallengeMethod
@@ -19580,13 +19629,13 @@ var GoTrueClient = class _GoTrueClient {
19580
19629
  * Log in a user given a User supplied OTP or TokenHash received through mobile or email.
19581
19630
  */
19582
19631
  async verifyOtp(params) {
19583
- var _a60, _b6;
19632
+ var _a58, _b5;
19584
19633
  try {
19585
19634
  let redirectTo = void 0;
19586
19635
  let captchaToken = void 0;
19587
19636
  if ("options" in params) {
19588
- redirectTo = (_a60 = params.options) === null || _a60 === void 0 ? void 0 : _a60.redirectTo;
19589
- captchaToken = (_b6 = params.options) === null || _b6 === void 0 ? void 0 : _b6.captchaToken;
19637
+ redirectTo = (_a58 = params.options) === null || _a58 === void 0 ? void 0 : _a58.redirectTo;
19638
+ captchaToken = (_b5 = params.options) === null || _b5 === void 0 ? void 0 : _b5.captchaToken;
19590
19639
  }
19591
19640
  const { data, error } = await _request(this.fetch, "POST", `${this.url}/verify`, {
19592
19641
  headers: this.headers,
@@ -19630,7 +19679,7 @@ var GoTrueClient = class _GoTrueClient {
19630
19679
  * organization's SSO Identity Provider UUID directly instead.
19631
19680
  */
19632
19681
  async signInWithSSO(params) {
19633
- var _a60, _b6, _c, _d, _e;
19682
+ var _a58, _b5, _c, _d, _e;
19634
19683
  try {
19635
19684
  let codeChallenge = null;
19636
19685
  let codeChallengeMethod = null;
@@ -19639,7 +19688,7 @@ var GoTrueClient = class _GoTrueClient {
19639
19688
  [codeChallenge, codeChallengeMethod] = await getCodeChallengeAndMethod(this.storage, this.storageKey);
19640
19689
  }
19641
19690
  const result = await _request(this.fetch, "POST", `${this.url}/sso`, {
19642
- body: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, "providerId" in params ? { provider_id: params.providerId } : null), "domain" in params ? { domain: params.domain } : null), { redirect_to: (_b6 = (_a60 = params.options) === null || _a60 === void 0 ? void 0 : _a60.redirectTo) !== null && _b6 !== void 0 ? _b6 : void 0 }), ((_c = params === null || params === void 0 ? void 0 : params.options) === null || _c === void 0 ? void 0 : _c.captchaToken) ? { gotrue_meta_security: { captcha_token: params.options.captchaToken } } : null), { skip_http_redirect: true, code_challenge: codeChallenge, code_challenge_method: codeChallengeMethod }),
19691
+ body: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, "providerId" in params ? { provider_id: params.providerId } : null), "domain" in params ? { domain: params.domain } : null), { redirect_to: (_b5 = (_a58 = params.options) === null || _a58 === void 0 ? void 0 : _a58.redirectTo) !== null && _b5 !== void 0 ? _b5 : void 0 }), ((_c = params === null || params === void 0 ? void 0 : params.options) === null || _c === void 0 ? void 0 : _c.captchaToken) ? { gotrue_meta_security: { captcha_token: params.options.captchaToken } } : null), { skip_http_redirect: true, code_challenge: codeChallenge, code_challenge_method: codeChallengeMethod }),
19643
19692
  headers: this.headers,
19644
19693
  xform: _ssoResponse
19645
19694
  });
@@ -19893,17 +19942,17 @@ var GoTrueClient = class _GoTrueClient {
19893
19942
  });
19894
19943
  }
19895
19944
  return await this._useSession(async (result) => {
19896
- var _a60, _b6, _c;
19945
+ var _a58, _b5, _c;
19897
19946
  const { data, error } = result;
19898
19947
  if (error) {
19899
19948
  throw error;
19900
19949
  }
19901
- if (!((_a60 = data.session) === null || _a60 === void 0 ? void 0 : _a60.access_token) && !this.hasCustomAuthorizationHeader) {
19950
+ if (!((_a58 = data.session) === null || _a58 === void 0 ? void 0 : _a58.access_token) && !this.hasCustomAuthorizationHeader) {
19902
19951
  return { data: { user: null }, error: new AuthSessionMissingError() };
19903
19952
  }
19904
19953
  return await _request(this.fetch, "GET", `${this.url}/user`, {
19905
19954
  headers: this.headers,
19906
- jwt: (_c = (_b6 = data.session) === null || _b6 === void 0 ? void 0 : _b6.access_token) !== null && _c !== void 0 ? _c : void 0,
19955
+ jwt: (_c = (_b5 = data.session) === null || _b5 === void 0 ? void 0 : _b5.access_token) !== null && _c !== void 0 ? _c : void 0,
19907
19956
  xform: _userResponse
19908
19957
  });
19909
19958
  });
@@ -20040,13 +20089,13 @@ var GoTrueClient = class _GoTrueClient {
20040
20089
  async _refreshSession(currentSession) {
20041
20090
  try {
20042
20091
  return await this._useSession(async (result) => {
20043
- var _a60;
20092
+ var _a58;
20044
20093
  if (!currentSession) {
20045
20094
  const { data, error: error2 } = result;
20046
20095
  if (error2) {
20047
20096
  throw error2;
20048
20097
  }
20049
- currentSession = (_a60 = data.session) !== null && _a60 !== void 0 ? _a60 : void 0;
20098
+ currentSession = (_a58 = data.session) !== null && _a58 !== void 0 ? _a58 : void 0;
20050
20099
  }
20051
20100
  if (!(currentSession === null || currentSession === void 0 ? void 0 : currentSession.refresh_token)) {
20052
20101
  throw new AuthSessionMissingError();
@@ -20184,12 +20233,12 @@ var GoTrueClient = class _GoTrueClient {
20184
20233
  }
20185
20234
  async _signOut({ scope } = { scope: "global" }) {
20186
20235
  return await this._useSession(async (result) => {
20187
- var _a60;
20236
+ var _a58;
20188
20237
  const { data, error: sessionError } = result;
20189
20238
  if (sessionError) {
20190
20239
  return this._returnResult({ error: sessionError });
20191
20240
  }
20192
- const accessToken = (_a60 = data.session) === null || _a60 === void 0 ? void 0 : _a60.access_token;
20241
+ const accessToken = (_a58 = data.session) === null || _a58 === void 0 ? void 0 : _a58.access_token;
20193
20242
  if (accessToken) {
20194
20243
  const { error } = await this.admin.signOut(accessToken, scope);
20195
20244
  if (error) {
@@ -20227,15 +20276,15 @@ var GoTrueClient = class _GoTrueClient {
20227
20276
  }
20228
20277
  async _emitInitialSession(id) {
20229
20278
  return await this._useSession(async (result) => {
20230
- var _a60, _b6;
20279
+ var _a58, _b5;
20231
20280
  try {
20232
20281
  const { data: { session }, error } = result;
20233
20282
  if (error)
20234
20283
  throw error;
20235
- await ((_a60 = this.stateChangeEmitters.get(id)) === null || _a60 === void 0 ? void 0 : _a60.callback("INITIAL_SESSION", session));
20284
+ await ((_a58 = this.stateChangeEmitters.get(id)) === null || _a58 === void 0 ? void 0 : _a58.callback("INITIAL_SESSION", session));
20236
20285
  this._debug("INITIAL_SESSION", "callback id", id, "session", session);
20237
20286
  } catch (err) {
20238
- await ((_b6 = this.stateChangeEmitters.get(id)) === null || _b6 === void 0 ? void 0 : _b6.callback("INITIAL_SESSION", null));
20287
+ await ((_b5 = this.stateChangeEmitters.get(id)) === null || _b5 === void 0 ? void 0 : _b5.callback("INITIAL_SESSION", null));
20239
20288
  this._debug("INITIAL_SESSION", "callback id", id, "error", err);
20240
20289
  console.error(err);
20241
20290
  }
@@ -20283,12 +20332,12 @@ var GoTrueClient = class _GoTrueClient {
20283
20332
  * Gets all the identities linked to a user.
20284
20333
  */
20285
20334
  async getUserIdentities() {
20286
- var _a60;
20335
+ var _a58;
20287
20336
  try {
20288
20337
  const { data, error } = await this.getUser();
20289
20338
  if (error)
20290
20339
  throw error;
20291
- return this._returnResult({ data: { identities: (_a60 = data.user.identities) !== null && _a60 !== void 0 ? _a60 : [] }, error: null });
20340
+ return this._returnResult({ data: { identities: (_a58 = data.user.identities) !== null && _a58 !== void 0 ? _a58 : [] }, error: null });
20292
20341
  } catch (error) {
20293
20342
  if (isAuthError(error)) {
20294
20343
  return this._returnResult({ data: null, error });
@@ -20303,16 +20352,16 @@ var GoTrueClient = class _GoTrueClient {
20303
20352
  return this.linkIdentityOAuth(credentials);
20304
20353
  }
20305
20354
  async linkIdentityOAuth(credentials) {
20306
- var _a60;
20355
+ var _a58;
20307
20356
  try {
20308
20357
  const { data, error } = await this._useSession(async (result) => {
20309
- var _a61, _b6, _c, _d, _e;
20358
+ var _a59, _b5, _c, _d, _e;
20310
20359
  const { data: data2, error: error2 } = result;
20311
20360
  if (error2)
20312
20361
  throw error2;
20313
20362
  const url = await this._getUrlForProvider(`${this.url}/user/identities/authorize`, credentials.provider, {
20314
- redirectTo: (_a61 = credentials.options) === null || _a61 === void 0 ? void 0 : _a61.redirectTo,
20315
- scopes: (_b6 = credentials.options) === null || _b6 === void 0 ? void 0 : _b6.scopes,
20363
+ redirectTo: (_a59 = credentials.options) === null || _a59 === void 0 ? void 0 : _a59.redirectTo,
20364
+ scopes: (_b5 = credentials.options) === null || _b5 === void 0 ? void 0 : _b5.scopes,
20316
20365
  queryParams: (_c = credentials.options) === null || _c === void 0 ? void 0 : _c.queryParams,
20317
20366
  skipBrowserRedirect: true
20318
20367
  });
@@ -20323,7 +20372,7 @@ var GoTrueClient = class _GoTrueClient {
20323
20372
  });
20324
20373
  if (error)
20325
20374
  throw error;
20326
- if (isBrowser() && !((_a60 = credentials.options) === null || _a60 === void 0 ? void 0 : _a60.skipBrowserRedirect)) {
20375
+ if (isBrowser() && !((_a58 = credentials.options) === null || _a58 === void 0 ? void 0 : _a58.skipBrowserRedirect)) {
20327
20376
  window.location.assign(data === null || data === void 0 ? void 0 : data.url);
20328
20377
  }
20329
20378
  return this._returnResult({
@@ -20339,7 +20388,7 @@ var GoTrueClient = class _GoTrueClient {
20339
20388
  }
20340
20389
  async linkIdentityIdToken(credentials) {
20341
20390
  return await this._useSession(async (result) => {
20342
- var _a60;
20391
+ var _a58;
20343
20392
  try {
20344
20393
  const { error: sessionError, data: { session } } = result;
20345
20394
  if (sessionError)
@@ -20347,7 +20396,7 @@ var GoTrueClient = class _GoTrueClient {
20347
20396
  const { options, provider, token, access_token, nonce } = credentials;
20348
20397
  const res = await _request(this.fetch, "POST", `${this.url}/token?grant_type=id_token`, {
20349
20398
  headers: this.headers,
20350
- jwt: (_a60 = session === null || session === void 0 ? void 0 : session.access_token) !== null && _a60 !== void 0 ? _a60 : void 0,
20399
+ jwt: (_a58 = session === null || session === void 0 ? void 0 : session.access_token) !== null && _a58 !== void 0 ? _a58 : void 0,
20351
20400
  body: {
20352
20401
  provider,
20353
20402
  id_token: token,
@@ -20387,14 +20436,14 @@ var GoTrueClient = class _GoTrueClient {
20387
20436
  async unlinkIdentity(identity) {
20388
20437
  try {
20389
20438
  return await this._useSession(async (result) => {
20390
- var _a60, _b6;
20439
+ var _a58, _b5;
20391
20440
  const { data, error } = result;
20392
20441
  if (error) {
20393
20442
  throw error;
20394
20443
  }
20395
20444
  return await _request(this.fetch, "DELETE", `${this.url}/user/identities/${identity.identity_id}`, {
20396
20445
  headers: this.headers,
20397
- jwt: (_b6 = (_a60 = data.session) === null || _a60 === void 0 ? void 0 : _a60.access_token) !== null && _b6 !== void 0 ? _b6 : void 0
20446
+ jwt: (_b5 = (_a58 = data.session) === null || _a58 === void 0 ? void 0 : _a58.access_token) !== null && _b5 !== void 0 ? _b5 : void 0
20398
20447
  });
20399
20448
  });
20400
20449
  } catch (error) {
@@ -20459,7 +20508,7 @@ var GoTrueClient = class _GoTrueClient {
20459
20508
  * Note: this method is async to accommodate for AsyncStorage e.g. in React native.
20460
20509
  */
20461
20510
  async _recoverAndRefresh() {
20462
- var _a60, _b6;
20511
+ var _a58, _b5;
20463
20512
  const debugName = "#_recoverAndRefresh()";
20464
20513
  this._debug(debugName, "begin");
20465
20514
  try {
@@ -20470,7 +20519,7 @@ var GoTrueClient = class _GoTrueClient {
20470
20519
  maybeUser = { user: currentSession.user };
20471
20520
  await setItemAsync(this.userStorage, this.storageKey + "-user", maybeUser);
20472
20521
  }
20473
- currentSession.user = (_a60 = maybeUser === null || maybeUser === void 0 ? void 0 : maybeUser.user) !== null && _a60 !== void 0 ? _a60 : userNotAvailableProxy();
20522
+ currentSession.user = (_a58 = maybeUser === null || maybeUser === void 0 ? void 0 : maybeUser.user) !== null && _a58 !== void 0 ? _a58 : userNotAvailableProxy();
20474
20523
  } else if (currentSession && !currentSession.user) {
20475
20524
  if (!currentSession.user) {
20476
20525
  const separateUser = await getItemAsync(this.storage, this.storageKey + "-user");
@@ -20491,7 +20540,7 @@ var GoTrueClient = class _GoTrueClient {
20491
20540
  }
20492
20541
  return;
20493
20542
  }
20494
- const expiresWithMargin = ((_b6 = currentSession.expires_at) !== null && _b6 !== void 0 ? _b6 : Infinity) * 1e3 - Date.now() < EXPIRY_MARGIN_MS;
20543
+ const expiresWithMargin = ((_b5 = currentSession.expires_at) !== null && _b5 !== void 0 ? _b5 : Infinity) * 1e3 - Date.now() < EXPIRY_MARGIN_MS;
20495
20544
  this._debug(debugName, `session has${expiresWithMargin ? "" : " not"} expired with margin of ${EXPIRY_MARGIN_MS}s`);
20496
20545
  if (expiresWithMargin) {
20497
20546
  if (this.autoRefreshToken && currentSession.refresh_token) {
@@ -20530,7 +20579,7 @@ var GoTrueClient = class _GoTrueClient {
20530
20579
  }
20531
20580
  }
20532
20581
  async _callRefreshToken(refreshToken) {
20533
- var _a60, _b6;
20582
+ var _a58, _b5;
20534
20583
  if (!refreshToken) {
20535
20584
  throw new AuthSessionMissingError();
20536
20585
  }
@@ -20558,10 +20607,10 @@ var GoTrueClient = class _GoTrueClient {
20558
20607
  if (!isAuthRetryableFetchError(error)) {
20559
20608
  await this._removeSession();
20560
20609
  }
20561
- (_a60 = this.refreshingDeferred) === null || _a60 === void 0 ? void 0 : _a60.resolve(result);
20610
+ (_a58 = this.refreshingDeferred) === null || _a58 === void 0 ? void 0 : _a58.resolve(result);
20562
20611
  return result;
20563
20612
  }
20564
- (_b6 = this.refreshingDeferred) === null || _b6 === void 0 ? void 0 : _b6.reject(error);
20613
+ (_b5 = this.refreshingDeferred) === null || _b5 === void 0 ? void 0 : _b5.reject(error);
20565
20614
  throw error;
20566
20615
  } finally {
20567
20616
  this.refreshingDeferred = null;
@@ -20847,14 +20896,14 @@ var GoTrueClient = class _GoTrueClient {
20847
20896
  async _unenroll(params) {
20848
20897
  try {
20849
20898
  return await this._useSession(async (result) => {
20850
- var _a60;
20899
+ var _a58;
20851
20900
  const { data: sessionData, error: sessionError } = result;
20852
20901
  if (sessionError) {
20853
20902
  return this._returnResult({ data: null, error: sessionError });
20854
20903
  }
20855
20904
  return await _request(this.fetch, "DELETE", `${this.url}/factors/${params.factorId}`, {
20856
20905
  headers: this.headers,
20857
- jwt: (_a60 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a60 === void 0 ? void 0 : _a60.access_token
20906
+ jwt: (_a58 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a58 === void 0 ? void 0 : _a58.access_token
20858
20907
  });
20859
20908
  });
20860
20909
  } catch (error) {
@@ -20867,7 +20916,7 @@ var GoTrueClient = class _GoTrueClient {
20867
20916
  async _enroll(params) {
20868
20917
  try {
20869
20918
  return await this._useSession(async (result) => {
20870
- var _a60, _b6;
20919
+ var _a58, _b5;
20871
20920
  const { data: sessionData, error: sessionError } = result;
20872
20921
  if (sessionError) {
20873
20922
  return this._returnResult({ data: null, error: sessionError });
@@ -20876,12 +20925,12 @@ var GoTrueClient = class _GoTrueClient {
20876
20925
  const { data, error } = await _request(this.fetch, "POST", `${this.url}/factors`, {
20877
20926
  body,
20878
20927
  headers: this.headers,
20879
- jwt: (_a60 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a60 === void 0 ? void 0 : _a60.access_token
20928
+ jwt: (_a58 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a58 === void 0 ? void 0 : _a58.access_token
20880
20929
  });
20881
20930
  if (error) {
20882
20931
  return this._returnResult({ data: null, error });
20883
20932
  }
20884
- if (params.factorType === "totp" && data.type === "totp" && ((_b6 = data === null || data === void 0 ? void 0 : data.totp) === null || _b6 === void 0 ? void 0 : _b6.qr_code)) {
20933
+ if (params.factorType === "totp" && data.type === "totp" && ((_b5 = data === null || data === void 0 ? void 0 : data.totp) === null || _b5 === void 0 ? void 0 : _b5.qr_code)) {
20885
20934
  data.totp.qr_code = `data:image/svg+xml;utf-8,${data.totp.qr_code}`;
20886
20935
  }
20887
20936
  return this._returnResult({ data, error: null });
@@ -20897,7 +20946,7 @@ var GoTrueClient = class _GoTrueClient {
20897
20946
  return this._acquireLock(this.lockAcquireTimeout, async () => {
20898
20947
  try {
20899
20948
  return await this._useSession(async (result) => {
20900
- var _a60;
20949
+ var _a58;
20901
20950
  const { data: sessionData, error: sessionError } = result;
20902
20951
  if (sessionError) {
20903
20952
  return this._returnResult({ data: null, error: sessionError });
@@ -20908,7 +20957,7 @@ var GoTrueClient = class _GoTrueClient {
20908
20957
  const { data, error } = await _request(this.fetch, "POST", `${this.url}/factors/${params.factorId}/verify`, {
20909
20958
  body,
20910
20959
  headers: this.headers,
20911
- jwt: (_a60 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a60 === void 0 ? void 0 : _a60.access_token
20960
+ jwt: (_a58 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a58 === void 0 ? void 0 : _a58.access_token
20912
20961
  });
20913
20962
  if (error) {
20914
20963
  return this._returnResult({ data: null, error });
@@ -20929,7 +20978,7 @@ var GoTrueClient = class _GoTrueClient {
20929
20978
  return this._acquireLock(this.lockAcquireTimeout, async () => {
20930
20979
  try {
20931
20980
  return await this._useSession(async (result) => {
20932
- var _a60;
20981
+ var _a58;
20933
20982
  const { data: sessionData, error: sessionError } = result;
20934
20983
  if (sessionError) {
20935
20984
  return this._returnResult({ data: null, error: sessionError });
@@ -20937,7 +20986,7 @@ var GoTrueClient = class _GoTrueClient {
20937
20986
  const response = await _request(this.fetch, "POST", `${this.url}/factors/${params.factorId}/challenge`, {
20938
20987
  body: params,
20939
20988
  headers: this.headers,
20940
- jwt: (_a60 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a60 === void 0 ? void 0 : _a60.access_token
20989
+ jwt: (_a58 = sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) === null || _a58 === void 0 ? void 0 : _a58.access_token
20941
20990
  });
20942
20991
  if (response.error) {
20943
20992
  return response;
@@ -20987,7 +21036,7 @@ var GoTrueClient = class _GoTrueClient {
20987
21036
  * {@see GoTrueMFAApi#listFactors}
20988
21037
  */
20989
21038
  async _listFactors() {
20990
- var _a60;
21039
+ var _a58;
20991
21040
  const { data: { user }, error: userError } = await this.getUser();
20992
21041
  if (userError) {
20993
21042
  return { data: null, error: userError };
@@ -20998,7 +21047,7 @@ var GoTrueClient = class _GoTrueClient {
20998
21047
  totp: [],
20999
21048
  webauthn: []
21000
21049
  };
21001
- for (const factor of (_a60 = user === null || user === void 0 ? void 0 : user.factors) !== null && _a60 !== void 0 ? _a60 : []) {
21050
+ for (const factor of (_a58 = user === null || user === void 0 ? void 0 : user.factors) !== null && _a58 !== void 0 ? _a58 : []) {
21002
21051
  data.all.push(factor);
21003
21052
  if (factor.status === "verified") {
21004
21053
  ;
@@ -21014,7 +21063,7 @@ var GoTrueClient = class _GoTrueClient {
21014
21063
  * {@see GoTrueMFAApi#getAuthenticatorAssuranceLevel}
21015
21064
  */
21016
21065
  async _getAuthenticatorAssuranceLevel() {
21017
- var _a60, _b6;
21066
+ var _a58, _b5;
21018
21067
  const { data: { session }, error: sessionError } = await this.getSession();
21019
21068
  if (sessionError) {
21020
21069
  return this._returnResult({ data: null, error: sessionError });
@@ -21031,7 +21080,7 @@ var GoTrueClient = class _GoTrueClient {
21031
21080
  currentLevel = payload.aal;
21032
21081
  }
21033
21082
  let nextLevel = currentLevel;
21034
- const verifiedFactors = (_b6 = (_a60 = session.user.factors) === null || _a60 === void 0 ? void 0 : _a60.filter((factor) => factor.status === "verified")) !== null && _b6 !== void 0 ? _b6 : [];
21083
+ const verifiedFactors = (_b5 = (_a58 = session.user.factors) === null || _a58 === void 0 ? void 0 : _a58.filter((factor) => factor.status === "verified")) !== null && _b5 !== void 0 ? _b5 : [];
21035
21084
  if (verifiedFactors.length > 0) {
21036
21085
  nextLevel = "aal2";
21037
21086
  }
@@ -21634,15 +21683,15 @@ function shouldShowDeprecationWarning() {
21634
21683
  if (shouldShowDeprecationWarning()) console.warn("\u26A0\uFE0F Node.js 18 and below are deprecated and will no longer be supported in future versions of @supabase/supabase-js. Please upgrade to Node.js 20 or later. For more information, visit: https://github.com/orgs/supabase/discussions/37217");
21635
21684
 
21636
21685
  // src/lib/supabase.ts
21637
- var import_meta5 = {};
21638
21686
  var cachedStargate = null;
21639
21687
  function getSupabase() {
21688
+ var _a58;
21640
21689
  if (cachedStargate) return cachedStargate;
21641
- const url = import_meta5.env.VITE_SUPABASE_URL;
21642
- const anon = import_meta5.env.VITE_SUPABASE_ANON_KEY || import_meta5.env.VITE_SUPABASE_PUBLISHABLE_KEY;
21643
- const schema = import_meta5.env.VITE_SUPABASE_SCHEMA || "public";
21690
+ const url = getRuntimeEnv("VITE_SUPABASE_URL");
21691
+ const anon = (_a58 = getRuntimeEnv("VITE_SUPABASE_ANON_KEY")) != null ? _a58 : getRuntimeEnv("VITE_SUPABASE_PUBLISHABLE_KEY");
21692
+ const schema = getRuntimeEnvOr("VITE_SUPABASE_SCHEMA", "public");
21644
21693
  if (!url || !anon) {
21645
- if (import_meta5.env.DEV) {
21694
+ if (isRuntimeDev()) {
21646
21695
  console.log("[supabase] getSupabase: env faltando", { hasUrl: !!url, hasAnon: !!anon, schema });
21647
21696
  }
21648
21697
  return null;
@@ -21713,8 +21762,6 @@ var Toaster = ({ theme, ...props }) => {
21713
21762
  };
21714
21763
 
21715
21764
  // src/lib/accountsAuth.ts
21716
- var import_meta6 = {};
21717
- var ENV = import_meta6.env;
21718
21765
  var decodeJwt = (token) => {
21719
21766
  if (!token) return null;
21720
21767
  const parts = token.split(".");
@@ -21729,101 +21776,100 @@ var decodeJwt = (token) => {
21729
21776
  };
21730
21777
 
21731
21778
  // src/components/cupcode/MainNavbar.tsx
21732
- var import_meta7 = {};
21733
21779
  import { Fragment as Fragment4, jsx as jsx47, jsxs as jsxs29 } from "react/jsx-runtime";
21734
- var _a18, _b5;
21735
- var SUPABASE_SCHEMA = ((_b5 = (_a18 = import_meta7.env.VITE_CHAT_SCHEMA) != null ? _a18 : import_meta7.env.VITE_SUPABASE_SCHEMA) != null ? _b5 : "public").trim();
21780
+ var _a16, _b4;
21781
+ var SUPABASE_SCHEMA = ((_b4 = (_a16 = getRuntimeEnv("VITE_CHAT_SCHEMA")) != null ? _a16 : getRuntimeEnv("VITE_SUPABASE_SCHEMA")) != null ? _b4 : "public").trim();
21782
+ var _a17;
21783
+ var USER_PRESENCE_TABLE = ((_a17 = getRuntimeEnv("VITE_USER_PRESENCE_TABLE")) != null ? _a17 : "user_presence").trim();
21784
+ var _a18;
21785
+ var USER_PRESENCE_USER_ID_COLUMN = ((_a18 = getRuntimeEnv("VITE_USER_PRESENCE_USER_ID_COLUMN")) != null ? _a18 : "user_id").trim();
21736
21786
  var _a19;
21737
- var USER_PRESENCE_TABLE = ((_a19 = import_meta7.env.VITE_USER_PRESENCE_TABLE) != null ? _a19 : "user_presence").trim();
21787
+ var USER_PRESENCE_STATUS_COLUMN = ((_a19 = getRuntimeEnv("VITE_USER_PRESENCE_STATUS_COLUMN")) != null ? _a19 : "status").trim();
21738
21788
  var _a20;
21739
- var USER_PRESENCE_USER_ID_COLUMN = ((_a20 = import_meta7.env.VITE_USER_PRESENCE_USER_ID_COLUMN) != null ? _a20 : "user_id").trim();
21789
+ var CHAT_USERS_TABLE = ((_a20 = getRuntimeEnv("VITE_CHAT_USERS_TABLE")) != null ? _a20 : "users").trim();
21740
21790
  var _a21;
21741
- var USER_PRESENCE_STATUS_COLUMN = ((_a21 = import_meta7.env.VITE_USER_PRESENCE_STATUS_COLUMN) != null ? _a21 : "status").trim();
21791
+ var CHAT_USERS_ID_COLUMN = ((_a21 = getRuntimeEnv("VITE_CHAT_USERS_ID_COLUMN")) != null ? _a21 : "id").trim();
21742
21792
  var _a22;
21743
- var CHAT_USERS_TABLE = ((_a22 = import_meta7.env.VITE_CHAT_USERS_TABLE) != null ? _a22 : "users").trim();
21793
+ var CHAT_USERS_NAME_COLUMN = ((_a22 = getRuntimeEnv("VITE_CHAT_USERS_NAME_COLUMN")) != null ? _a22 : "name").trim();
21744
21794
  var _a23;
21745
- var CHAT_USERS_ID_COLUMN = ((_a23 = import_meta7.env.VITE_CHAT_USERS_ID_COLUMN) != null ? _a23 : "id").trim();
21795
+ var CHAT_USERS_USERNAME_COLUMN = ((_a23 = getRuntimeEnv("VITE_CHAT_USERS_USERNAME_COLUMN")) != null ? _a23 : "username").trim();
21746
21796
  var _a24;
21747
- var CHAT_USERS_NAME_COLUMN = ((_a24 = import_meta7.env.VITE_CHAT_USERS_NAME_COLUMN) != null ? _a24 : "name").trim();
21797
+ var CHAT_USERS_EMAIL_COLUMN = ((_a24 = getRuntimeEnv("VITE_CHAT_USERS_EMAIL_COLUMN")) != null ? _a24 : "email").trim();
21748
21798
  var _a25;
21749
- var CHAT_USERS_USERNAME_COLUMN = ((_a25 = import_meta7.env.VITE_CHAT_USERS_USERNAME_COLUMN) != null ? _a25 : "username").trim();
21799
+ var CHAT_USERS_AVATAR_COLUMN = ((_a25 = getRuntimeEnv("VITE_CHAT_USERS_AVATAR_COLUMN")) != null ? _a25 : "avatar_url").trim();
21750
21800
  var _a26;
21751
- var CHAT_USERS_EMAIL_COLUMN = ((_a26 = import_meta7.env.VITE_CHAT_USERS_EMAIL_COLUMN) != null ? _a26 : "email").trim();
21752
- var _a27;
21753
- var CHAT_USERS_AVATAR_COLUMN = ((_a27 = import_meta7.env.VITE_CHAT_USERS_AVATAR_COLUMN) != null ? _a27 : "avatar_url").trim();
21754
- var _a28;
21755
- var CHAT_USERS_ROLE_COLUMN = ((_a28 = import_meta7.env.VITE_CHAT_USERS_ROLE_COLUMN) != null ? _a28 : "job_title").trim();
21801
+ var CHAT_USERS_ROLE_COLUMN = ((_a26 = getRuntimeEnv("VITE_CHAT_USERS_ROLE_COLUMN")) != null ? _a26 : "job_title").trim();
21756
21802
  var CHAT_USERS_UPDATE_TABLE = "profiles";
21757
21803
  var CHAT_USERS_UPDATE_ID_COLUMN = "id";
21758
21804
  var CHAT_USERS_UPDATE_EMAIL_COLUMN = "email";
21759
21805
  var CHAT_USERS_UPDATE_AVATAR_COLUMN = "avatar_url";
21806
+ var _a27;
21807
+ var CHAT_MESSAGES_TABLE = ((_a27 = getRuntimeEnv("VITE_CHAT_MESSAGES_TABLE")) != null ? _a27 : "chat_messages").trim();
21808
+ var _a28;
21809
+ var CHAT_MESSAGES_ID_COLUMN = ((_a28 = getRuntimeEnv("VITE_CHAT_MESSAGES_ID_COLUMN")) != null ? _a28 : "id").trim();
21760
21810
  var _a29;
21761
- var CHAT_MESSAGES_TABLE = ((_a29 = import_meta7.env.VITE_CHAT_MESSAGES_TABLE) != null ? _a29 : "chat_messages").trim();
21811
+ var CHAT_MESSAGES_SENDER_COLUMN = ((_a29 = getRuntimeEnv("VITE_CHAT_MESSAGES_SENDER_COLUMN")) != null ? _a29 : "sender_id").trim();
21762
21812
  var _a30;
21763
- var CHAT_MESSAGES_ID_COLUMN = ((_a30 = import_meta7.env.VITE_CHAT_MESSAGES_ID_COLUMN) != null ? _a30 : "id").trim();
21813
+ var CHAT_MESSAGES_RECIPIENT_COLUMN = ((_a30 = getRuntimeEnv("VITE_CHAT_MESSAGES_RECIPIENT_COLUMN")) != null ? _a30 : "recipient_id").trim();
21764
21814
  var _a31;
21765
- var CHAT_MESSAGES_SENDER_COLUMN = ((_a31 = import_meta7.env.VITE_CHAT_MESSAGES_SENDER_COLUMN) != null ? _a31 : "sender_id").trim();
21815
+ var CHAT_MESSAGES_TEXT_COLUMN = ((_a31 = getRuntimeEnv("VITE_CHAT_MESSAGES_TEXT_COLUMN")) != null ? _a31 : "text").trim();
21766
21816
  var _a32;
21767
- var CHAT_MESSAGES_RECIPIENT_COLUMN = ((_a32 = import_meta7.env.VITE_CHAT_MESSAGES_RECIPIENT_COLUMN) != null ? _a32 : "recipient_id").trim();
21817
+ var CHAT_MESSAGES_CREATED_AT_COLUMN = ((_a32 = getRuntimeEnv("VITE_CHAT_MESSAGES_CREATED_AT_COLUMN")) != null ? _a32 : "created_at").trim();
21768
21818
  var _a33;
21769
- var CHAT_MESSAGES_TEXT_COLUMN = ((_a33 = import_meta7.env.VITE_CHAT_MESSAGES_TEXT_COLUMN) != null ? _a33 : "text").trim();
21819
+ var CHAT_MESSAGES_READ_AT_COLUMN = ((_a33 = getRuntimeEnv("VITE_CHAT_MESSAGES_READ_AT_COLUMN")) != null ? _a33 : "read_at").trim();
21770
21820
  var _a34;
21771
- var CHAT_MESSAGES_CREATED_AT_COLUMN = ((_a34 = import_meta7.env.VITE_CHAT_MESSAGES_CREATED_AT_COLUMN) != null ? _a34 : "created_at").trim();
21821
+ var CHAT_MESSAGES_REPLY_TO_COLUMN = ((_a34 = getRuntimeEnv("VITE_CHAT_MESSAGES_REPLY_TO_COLUMN")) != null ? _a34 : "reply_to_message_id").trim();
21772
21822
  var _a35;
21773
- var CHAT_MESSAGES_READ_AT_COLUMN = ((_a35 = import_meta7.env.VITE_CHAT_MESSAGES_READ_AT_COLUMN) != null ? _a35 : "read_at").trim();
21823
+ var CHAT_MESSAGES_EDITED_AT_COLUMN = ((_a35 = getRuntimeEnv("VITE_CHAT_MESSAGES_EDITED_AT_COLUMN")) != null ? _a35 : "edited_at").trim();
21774
21824
  var _a36;
21775
- var CHAT_MESSAGES_REPLY_TO_COLUMN = ((_a36 = import_meta7.env.VITE_CHAT_MESSAGES_REPLY_TO_COLUMN) != null ? _a36 : "reply_to_message_id").trim();
21825
+ var CHAT_MESSAGES_DELETED_AT_COLUMN = ((_a36 = getRuntimeEnv("VITE_CHAT_MESSAGES_DELETED_AT_COLUMN")) != null ? _a36 : "deleted_at").trim();
21776
21826
  var _a37;
21777
- var CHAT_MESSAGES_EDITED_AT_COLUMN = ((_a37 = import_meta7.env.VITE_CHAT_MESSAGES_EDITED_AT_COLUMN) != null ? _a37 : "edited_at").trim();
21827
+ var CHAT_MESSAGES_DELETED_BY_COLUMN = ((_a37 = getRuntimeEnv("VITE_CHAT_MESSAGES_DELETED_BY_COLUMN")) != null ? _a37 : "deleted_by").trim();
21778
21828
  var _a38;
21779
- var CHAT_MESSAGES_DELETED_AT_COLUMN = ((_a38 = import_meta7.env.VITE_CHAT_MESSAGES_DELETED_AT_COLUMN) != null ? _a38 : "deleted_at").trim();
21829
+ var CHAT_REACTIONS_TABLE = ((_a38 = getRuntimeEnv("VITE_CHAT_REACTIONS_TABLE")) != null ? _a38 : "chat_message_reactions").trim();
21780
21830
  var _a39;
21781
- var CHAT_MESSAGES_DELETED_BY_COLUMN = ((_a39 = import_meta7.env.VITE_CHAT_MESSAGES_DELETED_BY_COLUMN) != null ? _a39 : "deleted_by").trim();
21831
+ var CHAT_REACTIONS_ID_COLUMN = ((_a39 = getRuntimeEnv("VITE_CHAT_REACTIONS_ID_COLUMN")) != null ? _a39 : "id").trim();
21782
21832
  var _a40;
21783
- var CHAT_REACTIONS_TABLE = ((_a40 = import_meta7.env.VITE_CHAT_REACTIONS_TABLE) != null ? _a40 : "chat_message_reactions").trim();
21833
+ var CHAT_REACTIONS_MESSAGE_ID_COLUMN = ((_a40 = getRuntimeEnv("VITE_CHAT_REACTIONS_MESSAGE_ID_COLUMN")) != null ? _a40 : "message_id").trim();
21784
21834
  var _a41;
21785
- var CHAT_REACTIONS_ID_COLUMN = ((_a41 = import_meta7.env.VITE_CHAT_REACTIONS_ID_COLUMN) != null ? _a41 : "id").trim();
21835
+ var CHAT_REACTIONS_USER_ID_COLUMN = ((_a41 = getRuntimeEnv("VITE_CHAT_REACTIONS_USER_ID_COLUMN")) != null ? _a41 : "user_id").trim();
21786
21836
  var _a42;
21787
- var CHAT_REACTIONS_MESSAGE_ID_COLUMN = ((_a42 = import_meta7.env.VITE_CHAT_REACTIONS_MESSAGE_ID_COLUMN) != null ? _a42 : "message_id").trim();
21837
+ var CHAT_REACTIONS_EMOJI_COLUMN = ((_a42 = getRuntimeEnv("VITE_CHAT_REACTIONS_EMOJI_COLUMN")) != null ? _a42 : "emoji").trim();
21788
21838
  var _a43;
21789
- var CHAT_REACTIONS_USER_ID_COLUMN = ((_a43 = import_meta7.env.VITE_CHAT_REACTIONS_USER_ID_COLUMN) != null ? _a43 : "user_id").trim();
21839
+ var CHAT_REACTIONS_CREATED_AT_COLUMN = ((_a43 = getRuntimeEnv("VITE_CHAT_REACTIONS_CREATED_AT_COLUMN")) != null ? _a43 : "created_at").trim();
21790
21840
  var _a44;
21791
- var CHAT_REACTIONS_EMOJI_COLUMN = ((_a44 = import_meta7.env.VITE_CHAT_REACTIONS_EMOJI_COLUMN) != null ? _a44 : "emoji").trim();
21841
+ var CHAT_LOGS_TABLE = ((_a44 = getRuntimeEnv("VITE_CHAT_LOGS_TABLE")) != null ? _a44 : "chat_message_logs").trim();
21792
21842
  var _a45;
21793
- var CHAT_REACTIONS_CREATED_AT_COLUMN = ((_a45 = import_meta7.env.VITE_CHAT_REACTIONS_CREATED_AT_COLUMN) != null ? _a45 : "created_at").trim();
21843
+ var CHAT_LOGS_ID_COLUMN = ((_a45 = getRuntimeEnv("VITE_CHAT_LOGS_ID_COLUMN")) != null ? _a45 : "id").trim();
21794
21844
  var _a46;
21795
- var CHAT_LOGS_TABLE = ((_a46 = import_meta7.env.VITE_CHAT_LOGS_TABLE) != null ? _a46 : "chat_message_logs").trim();
21845
+ var CHAT_LOGS_MESSAGE_ID_COLUMN = ((_a46 = getRuntimeEnv("VITE_CHAT_LOGS_MESSAGE_ID_COLUMN")) != null ? _a46 : "message_id").trim();
21796
21846
  var _a47;
21797
- var CHAT_LOGS_ID_COLUMN = ((_a47 = import_meta7.env.VITE_CHAT_LOGS_ID_COLUMN) != null ? _a47 : "id").trim();
21847
+ var CHAT_LOGS_ACTOR_ID_COLUMN = ((_a47 = getRuntimeEnv("VITE_CHAT_LOGS_ACTOR_ID_COLUMN")) != null ? _a47 : "actor_id").trim();
21798
21848
  var _a48;
21799
- var CHAT_LOGS_MESSAGE_ID_COLUMN = ((_a48 = import_meta7.env.VITE_CHAT_LOGS_MESSAGE_ID_COLUMN) != null ? _a48 : "message_id").trim();
21849
+ var CHAT_LOGS_ACTION_COLUMN = ((_a48 = getRuntimeEnv("VITE_CHAT_LOGS_ACTION_COLUMN")) != null ? _a48 : "action").trim();
21800
21850
  var _a49;
21801
- var CHAT_LOGS_ACTOR_ID_COLUMN = ((_a49 = import_meta7.env.VITE_CHAT_LOGS_ACTOR_ID_COLUMN) != null ? _a49 : "actor_id").trim();
21851
+ var CHAT_LOGS_PREVIOUS_TEXT_COLUMN = ((_a49 = getRuntimeEnv("VITE_CHAT_LOGS_PREVIOUS_TEXT_COLUMN")) != null ? _a49 : "previous_text").trim();
21802
21852
  var _a50;
21803
- var CHAT_LOGS_ACTION_COLUMN = ((_a50 = import_meta7.env.VITE_CHAT_LOGS_ACTION_COLUMN) != null ? _a50 : "action").trim();
21853
+ var CHAT_LOGS_NEXT_TEXT_COLUMN = ((_a50 = getRuntimeEnv("VITE_CHAT_LOGS_NEXT_TEXT_COLUMN")) != null ? _a50 : "next_text").trim();
21804
21854
  var _a51;
21805
- var CHAT_LOGS_PREVIOUS_TEXT_COLUMN = ((_a51 = import_meta7.env.VITE_CHAT_LOGS_PREVIOUS_TEXT_COLUMN) != null ? _a51 : "previous_text").trim();
21806
- var _a52;
21807
- var CHAT_LOGS_NEXT_TEXT_COLUMN = ((_a52 = import_meta7.env.VITE_CHAT_LOGS_NEXT_TEXT_COLUMN) != null ? _a52 : "next_text").trim();
21808
- var _a53;
21809
- var CHAT_LOGS_CREATED_AT_COLUMN = ((_a53 = import_meta7.env.VITE_CHAT_LOGS_CREATED_AT_COLUMN) != null ? _a53 : "created_at").trim();
21855
+ var CHAT_LOGS_CREATED_AT_COLUMN = ((_a51 = getRuntimeEnv("VITE_CHAT_LOGS_CREATED_AT_COLUMN")) != null ? _a51 : "created_at").trim();
21810
21856
  var CHAT_MESSAGE_HISTORY_LIMIT = 200;
21811
21857
  var CHAT_EDIT_WINDOW_MINUTES2 = 15;
21812
21858
  var CHAT_DELETED_PLACEHOLDER_TEXT2 = "Mensagem deletada";
21813
- var _a54;
21814
- var TELESCUP_BASE_URL = (_a54 = import_meta7.env.VITE_TELESCUP_BASE_URL) == null ? void 0 : _a54.trim();
21815
- var _a55;
21816
- var SUPABASE_URL2 = (_a55 = import_meta7.env.VITE_SUPABASE_URL) == null ? void 0 : _a55.trim();
21859
+ var _a52;
21860
+ var TELESCUP_BASE_URL = (_a52 = getRuntimeEnv("VITE_TELESCUP_BASE_URL")) == null ? void 0 : _a52.trim();
21861
+ var _a53;
21862
+ var SUPABASE_URL2 = (_a53 = getRuntimeEnv("VITE_SUPABASE_URL")) == null ? void 0 : _a53.trim();
21817
21863
  var TELESCUP_BASE_URL_FALLBACK = SUPABASE_URL2 ? `${SUPABASE_URL2.replace(/\/+$/, "")}/functions/v1` : void 0;
21818
21864
  var ACCESS_TOKEN_STORAGE_KEY = "cc_access_token";
21865
+ var _a54;
21866
+ var ACCOUNTS_BASE_URL2 = ((_a54 = getRuntimeEnv("VITE_ACCOUNTS_BASE_URL")) != null ? _a54 : "https://accounts.cupcode.com.br").trim().replace(/\/+$/, "");
21867
+ var _a55;
21868
+ var MC_BASE_URL2 = ((_a55 = getRuntimeEnv("VITE_MC_BASE_URL")) != null ? _a55 : "https://mc.cupcode.com.br").trim().replace(/\/+$/, "");
21819
21869
  var _a56;
21820
- var ACCOUNTS_BASE_URL2 = ((_a56 = import_meta7.env.VITE_ACCOUNTS_BASE_URL) != null ? _a56 : "https://accounts.cupcode.com.br").trim().replace(/\/+$/, "");
21870
+ var ACCOUNTS_LANGUAGE_ENDPOINT = (_a56 = getRuntimeEnv("VITE_ACCOUNTS_LANGUAGE_ENDPOINT")) == null ? void 0 : _a56.trim();
21821
21871
  var _a57;
21822
- var MC_BASE_URL2 = ((_a57 = import_meta7.env.VITE_MC_BASE_URL) != null ? _a57 : "https://mc.cupcode.com.br").trim().replace(/\/+$/, "");
21823
- var _a58;
21824
- var ACCOUNTS_LANGUAGE_ENDPOINT = (_a58 = import_meta7.env.VITE_ACCOUNTS_LANGUAGE_ENDPOINT) == null ? void 0 : _a58.trim();
21825
- var _a59;
21826
- var ACCOUNTS_ACTIVITY_ENDPOINT = (_a59 = import_meta7.env.VITE_ACCOUNTS_ACTIVITY_ENDPOINT) == null ? void 0 : _a59.trim();
21872
+ var ACCOUNTS_ACTIVITY_ENDPOINT = (_a57 = getRuntimeEnv("VITE_ACCOUNTS_ACTIVITY_ENDPOINT")) == null ? void 0 : _a57.trim();
21827
21873
  var PRESENCE_STATUS_VALUES = [
21828
21874
  "online",
21829
21875
  "away",
@@ -21988,8 +22034,8 @@ var parseRecentActivityItems = (payload) => {
21988
22034
  return [];
21989
22035
  };
21990
22036
  return toRows(payload).map((item, index) => {
21991
- var _a60, _b6, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
21992
- const id = (_b6 = (_a60 = toStringOrUndefined(item.id)) != null ? _a60 : toStringOrUndefined(item.event_id)) != null ? _b6 : `accounts-activity-${index}`;
22037
+ var _a58, _b5, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
22038
+ const id = (_b5 = (_a58 = toStringOrUndefined(item.id)) != null ? _a58 : toStringOrUndefined(item.event_id)) != null ? _b5 : `accounts-activity-${index}`;
21993
22039
  const title = (_e = (_d = (_c = toStringOrUndefined(item.title)) != null ? _c : toStringOrUndefined(item.action)) != null ? _d : toStringOrUndefined(item.event)) != null ? _e : toStringOrUndefined(item.type);
21994
22040
  if (!title) return null;
21995
22041
  const description = (_h = (_g = (_f = toStringOrUndefined(item.description)) != null ? _f : toStringOrUndefined(item.details)) != null ? _g : toStringOrUndefined(item.message)) != null ? _h : toStringOrUndefined(item.summary);
@@ -22079,25 +22125,25 @@ var dedupeAndSortReactions = (reactions) => {
22079
22125
  });
22080
22126
  };
22081
22127
  var isMissingColumnError = (error, column) => {
22082
- var _a60, _b6;
22083
- const normalized = (_b6 = (_a60 = error == null ? void 0 : error.message) == null ? void 0 : _a60.toLowerCase()) != null ? _b6 : "";
22128
+ var _a58, _b5;
22129
+ const normalized = (_b5 = (_a58 = error == null ? void 0 : error.message) == null ? void 0 : _a58.toLowerCase()) != null ? _b5 : "";
22084
22130
  const code = error == null ? void 0 : error.code;
22085
22131
  return code === "42703" && normalized.includes(column.toLowerCase());
22086
22132
  };
22087
22133
  var isMissingTableError = (error, table) => {
22088
- var _a60, _b6;
22089
- const normalized = (_b6 = (_a60 = error == null ? void 0 : error.message) == null ? void 0 : _a60.toLowerCase()) != null ? _b6 : "";
22134
+ var _a58, _b5;
22135
+ const normalized = (_b5 = (_a58 = error == null ? void 0 : error.message) == null ? void 0 : _a58.toLowerCase()) != null ? _b5 : "";
22090
22136
  const code = error == null ? void 0 : error.code;
22091
22137
  return code === "PGRST205" && normalized.includes(table.toLowerCase());
22092
22138
  };
22093
22139
  var toChatMessage = (row, currentUserId) => {
22094
- var _a60, _b6, _c, _d, _e, _f;
22095
- const id = (_a60 = toStringOrUndefined(row[CHAT_MESSAGES_ID_COLUMN])) != null ? _a60 : `${toStringOrUndefined(row[CHAT_MESSAGES_SENDER_COLUMN])}-${toStringOrUndefined(row[CHAT_MESSAGES_RECIPIENT_COLUMN])}-${toStringOrUndefined(row[CHAT_MESSAGES_CREATED_AT_COLUMN])}`;
22140
+ var _a58, _b5, _c, _d, _e, _f;
22141
+ const id = (_a58 = toStringOrUndefined(row[CHAT_MESSAGES_ID_COLUMN])) != null ? _a58 : `${toStringOrUndefined(row[CHAT_MESSAGES_SENDER_COLUMN])}-${toStringOrUndefined(row[CHAT_MESSAGES_RECIPIENT_COLUMN])}-${toStringOrUndefined(row[CHAT_MESSAGES_CREATED_AT_COLUMN])}`;
22096
22142
  const senderId = toStringOrUndefined(row[CHAT_MESSAGES_SENDER_COLUMN]);
22097
22143
  const recipientId = toStringOrUndefined(row[CHAT_MESSAGES_RECIPIENT_COLUMN]);
22098
22144
  const text = toStringOrUndefined(row[CHAT_MESSAGES_TEXT_COLUMN]);
22099
22145
  const createdAt = toStringOrUndefined(row[CHAT_MESSAGES_CREATED_AT_COLUMN]);
22100
- const editedAt = (_b6 = toStringOrUndefined(row[CHAT_MESSAGES_EDITED_AT_COLUMN])) != null ? _b6 : null;
22146
+ const editedAt = (_b5 = toStringOrUndefined(row[CHAT_MESSAGES_EDITED_AT_COLUMN])) != null ? _b5 : null;
22101
22147
  const readAt = (_c = toStringOrUndefined(row[CHAT_MESSAGES_READ_AT_COLUMN])) != null ? _c : null;
22102
22148
  const replyToMessageId = (_d = toStringOrUndefined(row[CHAT_MESSAGES_REPLY_TO_COLUMN])) != null ? _d : null;
22103
22149
  const deletedAt = (_e = toStringOrUndefined(row[CHAT_MESSAGES_DELETED_AT_COLUMN])) != null ? _e : null;
@@ -22132,13 +22178,13 @@ var toChatReaction = (row) => {
22132
22178
  return { id, messageId, userId, emoji, createdAt };
22133
22179
  };
22134
22180
  var toChatMessageLog = (row, messagesById) => {
22135
- var _a60, _b6;
22181
+ var _a58, _b5;
22136
22182
  const id = toStringOrUndefined(row[CHAT_LOGS_ID_COLUMN]);
22137
22183
  const messageId = toStringOrUndefined(row[CHAT_LOGS_MESSAGE_ID_COLUMN]);
22138
22184
  const actorId = toStringOrUndefined(row[CHAT_LOGS_ACTOR_ID_COLUMN]);
22139
22185
  const action = toStringOrUndefined(row[CHAT_LOGS_ACTION_COLUMN]);
22140
- const previousText = (_a60 = toStringOrUndefined(row[CHAT_LOGS_PREVIOUS_TEXT_COLUMN])) != null ? _a60 : null;
22141
- const nextText = (_b6 = toStringOrUndefined(row[CHAT_LOGS_NEXT_TEXT_COLUMN])) != null ? _b6 : null;
22186
+ const previousText = (_a58 = toStringOrUndefined(row[CHAT_LOGS_PREVIOUS_TEXT_COLUMN])) != null ? _a58 : null;
22187
+ const nextText = (_b5 = toStringOrUndefined(row[CHAT_LOGS_NEXT_TEXT_COLUMN])) != null ? _b5 : null;
22142
22188
  const createdAt = toStringOrUndefined(row[CHAT_LOGS_CREATED_AT_COLUMN]);
22143
22189
  if (!id || !messageId || !action || action !== "edit" && action !== "delete") return null;
22144
22190
  const relatedMessage = messagesById.get(messageId);
@@ -22179,7 +22225,7 @@ var MainNavbar = ({
22179
22225
  onOpenAccountClick,
22180
22226
  getAccessToken
22181
22227
  }) => {
22182
- var _a60, _b6, _c;
22228
+ var _a58, _b5, _c;
22183
22229
  const [chatUsers, setChatUsers] = useState14([]);
22184
22230
  const [chatMessages, setChatMessages] = useState14([]);
22185
22231
  const [chatMessageLogs, setChatMessageLogs] = useState14([]);
@@ -22214,8 +22260,8 @@ var MainNavbar = ({
22214
22260
  const currentUserId = useMemo8(() => resolveCurrentUserId(authUser), [authUser]);
22215
22261
  const authEmail = useMemo8(() => toStringOrUndefined(authUser == null ? void 0 : authUser.email), [authUser == null ? void 0 : authUser.email]);
22216
22262
  const isChatSuperAdmin = useMemo8(() => {
22217
- var _a61, _b7;
22218
- const roleTokens = `${(_a61 = authUser == null ? void 0 : authUser.role) != null ? _a61 : ""} ${(_b7 = authUser == null ? void 0 : authUser.jobTitle) != null ? _b7 : ""}`.toLowerCase();
22263
+ var _a59, _b6;
22264
+ const roleTokens = `${(_a59 = authUser == null ? void 0 : authUser.role) != null ? _a59 : ""} ${(_b6 = authUser == null ? void 0 : authUser.jobTitle) != null ? _b6 : ""}`.toLowerCase();
22219
22265
  return roleTokens.includes("superadmin") || roleTokens.includes("super admin");
22220
22266
  }, [authUser == null ? void 0 : authUser.jobTitle, authUser == null ? void 0 : authUser.role]);
22221
22267
  const resolvedTelescupBaseUrl = useMemo8(() => {
@@ -22224,7 +22270,7 @@ var MainNavbar = ({
22224
22270
  }
22225
22271
  return TELESCUP_BASE_URL_FALLBACK;
22226
22272
  }, []);
22227
- const resolvedProfileAvatarUrl = (_b6 = (_a60 = resolveChatAvatarUrl(persistedProfileAvatarValue)) != null ? _a60 : authUser == null ? void 0 : authUser.picture) != null ? _b6 : void 0;
22273
+ const resolvedProfileAvatarUrl = (_b5 = (_a58 = resolveChatAvatarUrl(persistedProfileAvatarValue)) != null ? _a58 : authUser == null ? void 0 : authUser.picture) != null ? _b5 : void 0;
22228
22274
  const effectiveCurrentUserId = resolvedSenderId != null ? resolvedSenderId : currentUserId;
22229
22275
  const isAuthenticated = authStatus === "authenticated";
22230
22276
  useEffect16(() => {
@@ -22267,7 +22313,7 @@ var MainNavbar = ({
22267
22313
  }
22268
22314
  if (canceled) return;
22269
22315
  if (error) {
22270
- if (import_meta7.env.DEV) {
22316
+ if (isRuntimeDev()) {
22271
22317
  console.warn("[chat] Falha ao resolver sender_id por email:", error.message);
22272
22318
  }
22273
22319
  setResolvedSenderId(fallbackId);
@@ -22281,7 +22327,7 @@ var MainNavbar = ({
22281
22327
  setResolvedSenderId(mappedId != null ? mappedId : fallbackId);
22282
22328
  setPersistedProfileAvatarValue(mappedAvatar);
22283
22329
  } catch (error) {
22284
- if (import_meta7.env.DEV) {
22330
+ if (isRuntimeDev()) {
22285
22331
  console.warn("[chat] Excecao ao resolver sender_id por email:", error.message);
22286
22332
  }
22287
22333
  if (!canceled) {
@@ -22307,7 +22353,7 @@ var MainNavbar = ({
22307
22353
  return sessionStorage.getItem(ACCESS_TOKEN_STORAGE_KEY);
22308
22354
  };
22309
22355
  const loadAccountsContext = async () => {
22310
- var _a61, _b7, _c2, _d, _e, _f, _g;
22356
+ var _a59, _b6, _c2, _d, _e, _f, _g;
22311
22357
  setIsAccountsActivityLoading(true);
22312
22358
  try {
22313
22359
  const token = await resolveAccountsToken();
@@ -22317,9 +22363,9 @@ var MainNavbar = ({
22317
22363
  }
22318
22364
  return;
22319
22365
  }
22320
- const claims = (_a61 = decodeJwt(token)) != null ? _a61 : {};
22366
+ const claims = (_a59 = decodeJwt(token)) != null ? _a59 : {};
22321
22367
  const languageFromToken = normalizeMenuLanguage(
22322
- (_d = (_c2 = (_b7 = claims.locale) != null ? _b7 : claims.lang) != null ? _c2 : claims.language) != null ? _d : claims["https://cupcode.com/locale"]
22368
+ (_d = (_c2 = (_b6 = claims.locale) != null ? _b6 : claims.lang) != null ? _c2 : claims.language) != null ? _d : claims["https://cupcode.com/locale"]
22323
22369
  );
22324
22370
  if (!canceled) {
22325
22371
  setAccountsLanguage(languageFromToken);
@@ -22356,7 +22402,7 @@ var MainNavbar = ({
22356
22402
  }
22357
22403
  }
22358
22404
  } catch (error) {
22359
- if (import_meta7.env.DEV) {
22405
+ if (isRuntimeDev()) {
22360
22406
  console.warn("[accounts] Falha ao carregar idioma/atividade recente:", error.message);
22361
22407
  }
22362
22408
  } finally {
@@ -22408,7 +22454,7 @@ var MainNavbar = ({
22408
22454
  }
22409
22455
  let canceled = false;
22410
22456
  const loadChatData = async () => {
22411
- var _a61, _b7, _c2, _d, _e, _f;
22457
+ var _a59, _b6, _c2, _d, _e, _f;
22412
22458
  setIsChatLoading(true);
22413
22459
  setChatError(null);
22414
22460
  const userColumns = Array.from(
@@ -22508,11 +22554,11 @@ var MainNavbar = ({
22508
22554
  if (canceled) return;
22509
22555
  const presenceMap = /* @__PURE__ */ new Map();
22510
22556
  if (presenceResponse.error) {
22511
- if (import_meta7.env.DEV) {
22557
+ if (isRuntimeDev()) {
22512
22558
  console.warn("[chat] Falha ao carregar presen\xE7a:", presenceResponse.error.message);
22513
22559
  }
22514
22560
  } else {
22515
- (_a61 = presenceResponse.data) == null ? void 0 : _a61.forEach((row) => {
22561
+ (_a59 = presenceResponse.data) == null ? void 0 : _a59.forEach((row) => {
22516
22562
  const userId = toStringOrUndefined(row[USER_PRESENCE_USER_ID_COLUMN]);
22517
22563
  if (!userId) return;
22518
22564
  presenceMap.set(userId, normalizePresenceStatus(row[USER_PRESENCE_STATUS_COLUMN]));
@@ -22520,17 +22566,17 @@ var MainNavbar = ({
22520
22566
  }
22521
22567
  const usersMap = /* @__PURE__ */ new Map();
22522
22568
  if (usersResponse.error) {
22523
- if (import_meta7.env.DEV) {
22569
+ if (isRuntimeDev()) {
22524
22570
  console.warn("[chat] Falha ao carregar tabela de usu\xE1rios:", usersResponse.error.message);
22525
22571
  }
22526
22572
  } else {
22527
- (_b7 = usersResponse.data) == null ? void 0 : _b7.forEach((row) => {
22528
- var _a62, _b8, _c3;
22573
+ (_b6 = usersResponse.data) == null ? void 0 : _b6.forEach((row) => {
22574
+ var _a60, _b7, _c3;
22529
22575
  const id = toStringOrUndefined(row[CHAT_USERS_ID_COLUMN]);
22530
22576
  if (!id || id === effectiveCurrentUserId) return;
22531
22577
  const email = toStringOrUndefined(row[CHAT_USERS_EMAIL_COLUMN]);
22532
22578
  const username = buildHandle2(toStringOrUndefined(row[CHAT_USERS_USERNAME_COLUMN]), email, id);
22533
- const name = (_b8 = (_a62 = toStringOrUndefined(row[CHAT_USERS_NAME_COLUMN])) != null ? _a62 : toStringOrUndefined(row[CHAT_USERS_USERNAME_COLUMN])) != null ? _b8 : username;
22579
+ const name = (_b7 = (_a60 = toStringOrUndefined(row[CHAT_USERS_NAME_COLUMN])) != null ? _a60 : toStringOrUndefined(row[CHAT_USERS_USERNAME_COLUMN])) != null ? _b7 : username;
22534
22580
  usersMap.set(id, {
22535
22581
  id,
22536
22582
  name,
@@ -22555,7 +22601,7 @@ var MainNavbar = ({
22555
22601
  const resolvedUsers = [...usersMap.values()].sort((left, right) => left.name.localeCompare(right.name, "pt-BR"));
22556
22602
  setChatUsers(resolvedUsers);
22557
22603
  if (messageErrors.length > 0) {
22558
- if (import_meta7.env.DEV) {
22604
+ if (isRuntimeDev()) {
22559
22605
  messageErrors.forEach((error) => console.warn("[chat] Falha ao carregar mensagens:", error == null ? void 0 : error.message));
22560
22606
  }
22561
22607
  }
@@ -22587,7 +22633,7 @@ var MainNavbar = ({
22587
22633
  setChatMessageLogs([]);
22588
22634
  } else if (logsQuery.error) {
22589
22635
  logsError = logsQuery.error;
22590
- if (import_meta7.env.DEV) {
22636
+ if (isRuntimeDev()) {
22591
22637
  console.warn("[chat] Falha ao carregar logs:", logsQuery.error.message);
22592
22638
  }
22593
22639
  setChatMessageLogs([]);
@@ -22600,7 +22646,7 @@ var MainNavbar = ({
22600
22646
  setChatMessageLogs([]);
22601
22647
  }
22602
22648
  if (reactionsResponse.error) {
22603
- if (import_meta7.env.DEV) {
22649
+ if (isRuntimeDev()) {
22604
22650
  console.warn("[chat] Falha ao carregar rea\xE7\xF5es:", reactionsResponse.error.message);
22605
22651
  }
22606
22652
  setChatReactions([]);
@@ -22649,7 +22695,7 @@ var MainNavbar = ({
22649
22695
  table: CHAT_MESSAGES_TABLE
22650
22696
  },
22651
22697
  (payload) => {
22652
- var _a61;
22698
+ var _a59;
22653
22699
  const row = payload.new;
22654
22700
  const message = upsertChatMessage(row);
22655
22701
  if (!message) return;
@@ -22659,7 +22705,7 @@ var MainNavbar = ({
22659
22705
  if (notifiedMessagesRef.current.has(message.id)) return;
22660
22706
  notifiedMessagesRef.current.add(message.id);
22661
22707
  const sender = usersByIdRef.current.get(senderId);
22662
- const senderName = (_a61 = sender == null ? void 0 : sender.name) != null ? _a61 : senderId;
22708
+ const senderName = (_a59 = sender == null ? void 0 : sender.name) != null ? _a59 : senderId;
22663
22709
  const senderAvatar = sender == null ? void 0 : sender.avatarUrl;
22664
22710
  const preview = summarizeMessage(message.text);
22665
22711
  const initials = buildInitials2(senderName);
@@ -22795,10 +22841,10 @@ var MainNavbar = ({
22795
22841
  if (!chatFeatureFlagsRef.current.hasReadAt) return {};
22796
22842
  const counters = {};
22797
22843
  chatMessages.forEach((message) => {
22798
- var _a61;
22844
+ var _a59;
22799
22845
  if (message.sender !== "them") return;
22800
22846
  if (message.readAt) return;
22801
- counters[message.contactId] = ((_a61 = counters[message.contactId]) != null ? _a61 : 0) + 1;
22847
+ counters[message.contactId] = ((_a59 = counters[message.contactId]) != null ? _a59 : 0) + 1;
22802
22848
  });
22803
22849
  return counters;
22804
22850
  }, [chatMessages]);
@@ -22826,7 +22872,7 @@ var MainNavbar = ({
22826
22872
  updateChatFeatureFlags({ hasReadAt: false });
22827
22873
  return;
22828
22874
  }
22829
- if (import_meta7.env.DEV) {
22875
+ if (isRuntimeDev()) {
22830
22876
  console.warn("[chat] Falha ao marcar mensagens como lidas:", error.message);
22831
22877
  }
22832
22878
  }
@@ -22936,7 +22982,7 @@ var MainNavbar = ({
22936
22982
  updateChatFeatureFlags({ hasLogsTable: false });
22937
22983
  return;
22938
22984
  }
22939
- if (import_meta7.env.DEV) {
22985
+ if (isRuntimeDev()) {
22940
22986
  console.warn("[chat] Falha ao registrar log de mensagem:", error.message);
22941
22987
  }
22942
22988
  },
@@ -22994,8 +23040,8 @@ var MainNavbar = ({
22994
23040
  (current) => dedupeAndSortMessages(
22995
23041
  current.map(
22996
23042
  (message) => {
22997
- var _a61;
22998
- return message.id === messageId ? { ...message, text: previousText, editedAt: (_a61 = targetMessage.editedAt) != null ? _a61 : null } : message;
23043
+ var _a59;
23044
+ return message.id === messageId ? { ...message, text: previousText, editedAt: (_a59 = targetMessage.editedAt) != null ? _a59 : null } : message;
22999
23045
  }
23000
23046
  )
23001
23047
  )
@@ -23026,13 +23072,13 @@ var MainNavbar = ({
23026
23072
  (current) => dedupeAndSortMessages(
23027
23073
  current.map(
23028
23074
  (message) => {
23029
- var _a61;
23075
+ var _a59;
23030
23076
  return message.id === messageId ? {
23031
23077
  ...message,
23032
23078
  text: CHAT_DELETED_PLACEHOLDER_TEXT2,
23033
23079
  deletedAt,
23034
23080
  deletedBy: effectiveCurrentUserId,
23035
- editedAt: (_a61 = message.editedAt) != null ? _a61 : deletedAt
23081
+ editedAt: (_a59 = message.editedAt) != null ? _a59 : deletedAt
23036
23082
  } : message;
23037
23083
  }
23038
23084
  )
@@ -23217,8 +23263,8 @@ var MainNavbar = ({
23217
23263
  ...item,
23218
23264
  isActive,
23219
23265
  onClick: isAnchor ? item.onClick : (event) => {
23220
- var _a61;
23221
- (_a61 = item.onClick) == null ? void 0 : _a61.call(item, event);
23266
+ var _a59;
23267
+ (_a59 = item.onClick) == null ? void 0 : _a59.call(item, event);
23222
23268
  if (!onNavigate || event.defaultPrevented) return;
23223
23269
  event.preventDefault();
23224
23270
  onNavigate(item.href);
@@ -23260,9 +23306,9 @@ var MainNavbar = ({
23260
23306
  window.open(`${MC_BASE_URL2}/tasks`, "_blank", "noopener,noreferrer");
23261
23307
  };
23262
23308
  const handleChatOpenUserProfile = useCallback6(({ userId }) => {
23263
- var _a61;
23309
+ var _a59;
23264
23310
  if (!userId || typeof window === "undefined") return;
23265
- const baseUrl = ((_a61 = import_meta7.env.VITE_ACCOUNTS_BASE_URL) != null ? _a61 : "https://accounts.cupcode.com.br").replace(
23311
+ const baseUrl = ((_a59 = getRuntimeEnv("VITE_ACCOUNTS_BASE_URL")) != null ? _a59 : "https://accounts.cupcode.com.br").replace(
23266
23312
  /\/+$/,
23267
23313
  ""
23268
23314
  );
@@ -23319,11 +23365,11 @@ var MainNavbar = ({
23319
23365
  },
23320
23366
  body: JSON.stringify({ language: nextLanguage })
23321
23367
  });
23322
- if (!response.ok && import_meta7.env.DEV) {
23368
+ if (!response.ok && isRuntimeDev()) {
23323
23369
  console.warn("[accounts] Falha ao atualizar idioma:", response.status, response.statusText);
23324
23370
  }
23325
23371
  } catch (error) {
23326
- if (import_meta7.env.DEV) {
23372
+ if (isRuntimeDev()) {
23327
23373
  console.warn("[accounts] Falha ao atualizar idioma:", error.message);
23328
23374
  }
23329
23375
  }
@@ -23332,8 +23378,8 @@ var MainNavbar = ({
23332
23378
  );
23333
23379
  const handleProfileAvatarChange = useCallback6(
23334
23380
  async ({ avatarId, avatarUrl }) => {
23335
- var _a61;
23336
- const normalizedAvatarId = (_a61 = parseAssetId(avatarId)) != null ? _a61 : parseAssetId(avatarUrl);
23381
+ var _a59;
23382
+ const normalizedAvatarId = (_a59 = parseAssetId(avatarId)) != null ? _a59 : parseAssetId(avatarUrl);
23337
23383
  if (!normalizedAvatarId) {
23338
23384
  throw new Error("ID da imagem inv\xE1lido.");
23339
23385
  }
@@ -23349,27 +23395,27 @@ var MainNavbar = ({
23349
23395
  );
23350
23396
  const updateErrors = [];
23351
23397
  const isRecoverableUpdateError = (error) => {
23352
- var _a62;
23353
- const message = ((_a62 = error.message) != null ? _a62 : "").toLowerCase();
23398
+ var _a60;
23399
+ const message = ((_a60 = error.message) != null ? _a60 : "").toLowerCase();
23354
23400
  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");
23355
23401
  };
23356
23402
  const isRecoverableLookupError = (error) => {
23357
- var _a62;
23358
- const message = ((_a62 = error.message) != null ? _a62 : "").toLowerCase();
23403
+ var _a60;
23404
+ const message = ((_a60 = error.message) != null ? _a60 : "").toLowerCase();
23359
23405
  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");
23360
23406
  };
23361
23407
  const isPermissionDeniedError2 = (error) => {
23362
- var _a62;
23363
- const message = ((_a62 = error.message) != null ? _a62 : "").toLowerCase();
23408
+ var _a60;
23409
+ const message = ((_a60 = error.message) != null ? _a60 : "").toLowerCase();
23364
23410
  return error.code === "42501" || message.includes("permission denied");
23365
23411
  };
23366
23412
  const updateAvatarByUserId = async (userId) => {
23367
- var _a62, _b7, _c2, _d, _e;
23413
+ var _a60, _b6, _c2, _d, _e;
23368
23414
  for (const tableName of updateTargets) {
23369
23415
  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);
23370
23416
  if (!updateWithSelect.error) {
23371
23417
  const rows = updateWithSelect.data;
23372
- const row = (_a62 = rows == null ? void 0 : rows[0]) != null ? _a62 : null;
23418
+ const row = (_a60 = rows == null ? void 0 : rows[0]) != null ? _a60 : null;
23373
23419
  if (row) {
23374
23420
  return row;
23375
23421
  }
@@ -23389,7 +23435,7 @@ var MainNavbar = ({
23389
23435
  throw new Error(`Falha ao atualizar avatar em "${tableName}": ${withoutSelectError.message}`);
23390
23436
  }
23391
23437
  updateErrors.push(
23392
- `${tableName}: ${(_b7 = withoutSelectError.code) != null ? _b7 : "erro"} ${(_c2 = withoutSelectError.message) != null ? _c2 : "falha desconhecida"}`
23438
+ `${tableName}: ${(_b6 = withoutSelectError.code) != null ? _b6 : "erro"} ${(_c2 = withoutSelectError.message) != null ? _c2 : "falha desconhecida"}`
23393
23439
  );
23394
23440
  continue;
23395
23441
  }
@@ -23401,13 +23447,13 @@ var MainNavbar = ({
23401
23447
  return null;
23402
23448
  };
23403
23449
  const resolveUserIdByEmail = async (emailValue) => {
23404
- var _a62;
23450
+ var _a60;
23405
23451
  let lastRecoverableError = null;
23406
23452
  for (const tableName of lookupTargets) {
23407
23453
  const { data, error } = await supabase.from(tableName).select(CHAT_USERS_UPDATE_ID_COLUMN).ilike(CHAT_USERS_UPDATE_EMAIL_COLUMN, emailValue).limit(1);
23408
23454
  if (!error) {
23409
23455
  const rows = data;
23410
- const resolvedId = toStringOrUndefined((_a62 = rows == null ? void 0 : rows[0]) == null ? void 0 : _a62[CHAT_USERS_UPDATE_ID_COLUMN]);
23456
+ const resolvedId = toStringOrUndefined((_a60 = rows == null ? void 0 : rows[0]) == null ? void 0 : _a60[CHAT_USERS_UPDATE_ID_COLUMN]);
23411
23457
  if (resolvedId) {
23412
23458
  return resolvedId;
23413
23459
  }
@@ -23418,7 +23464,7 @@ var MainNavbar = ({
23418
23464
  }
23419
23465
  lastRecoverableError = error;
23420
23466
  }
23421
- if (lastRecoverableError && import_meta7.env.DEV) {
23467
+ if (lastRecoverableError && isRuntimeDev()) {
23422
23468
  console.warn("[chat] Falha ao buscar usu\xE1rio por e-mail para salvar avatar:", lastRecoverableError.message);
23423
23469
  }
23424
23470
  return null;
@@ -24606,8 +24652,8 @@ var ChartStyle = ({ id, config }) => {
24606
24652
  ([theme, prefix]) => `
24607
24653
  ${prefix} [data-chart=${id}] {
24608
24654
  ${colorConfig.map(([key, itemConfig]) => {
24609
- var _a60;
24610
- const color = ((_a60 = itemConfig.theme) == null ? void 0 : _a60[theme]) || itemConfig.color;
24655
+ var _a58;
24656
+ const color = ((_a58 = itemConfig.theme) == null ? void 0 : _a58[theme]) || itemConfig.color;
24611
24657
  return color ? ` --color-${key}: ${color};` : null;
24612
24658
  }).join("\n")}
24613
24659
  }
@@ -24636,14 +24682,14 @@ var ChartTooltipContent = React43.forwardRef(
24636
24682
  }, ref) => {
24637
24683
  const { config } = useChart();
24638
24684
  const tooltipLabel = React43.useMemo(() => {
24639
- var _a60;
24685
+ var _a58;
24640
24686
  if (hideLabel || !(payload == null ? void 0 : payload.length)) {
24641
24687
  return null;
24642
24688
  }
24643
24689
  const [item] = payload;
24644
24690
  const key = `${labelKey || item.dataKey || item.name || "value"}`;
24645
24691
  const itemConfig = getPayloadConfigFromPayload(config, item, key);
24646
- const value = !labelKey && typeof label === "string" ? ((_a60 = config[label]) == null ? void 0 : _a60.label) || label : itemConfig == null ? void 0 : itemConfig.label;
24692
+ const value = !labelKey && typeof label === "string" ? ((_a58 = config[label]) == null ? void 0 : _a58.label) || label : itemConfig == null ? void 0 : itemConfig.label;
24647
24693
  if (labelFormatter) {
24648
24694
  return /* @__PURE__ */ jsx65("div", { className: cn("font-medium", labelClassName), children: labelFormatter(value, payload) });
24649
24695
  }
@@ -26557,9 +26603,13 @@ export {
26557
26603
  buttonVariants,
26558
26604
  cn,
26559
26605
  getMainNavItems,
26606
+ getRuntimeEnv,
26607
+ getRuntimeEnvOr,
26608
+ isRuntimeDev,
26560
26609
  navigationMenuTriggerStyle,
26561
26610
  parseAssetId,
26562
26611
  responsiveSizeClasses,
26612
+ setCupcodeRuntimeEnv,
26563
26613
  toast2 as sonnerToast,
26564
26614
  toast,
26565
26615
  toggleVariants,