@streamoid/settings 0.15.2 → 0.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -122,6 +122,7 @@ __export(index_exports, {
122
122
  minimumCreditLimit: () => minimumCreditLimit,
123
123
  ownCreditsFirstText: () => ownCreditsFirstText,
124
124
  parseBillingEntitlement: () => parseBillingEntitlement,
125
+ parseInviteEmails: () => parseInviteEmails,
125
126
  pausedOwnCreditsText: () => pausedOwnCreditsText,
126
127
  poolEndsAtFrom: () => poolEndsAtFrom,
127
128
  poolErrorMessage: () => poolErrorMessage,
@@ -3118,7 +3119,8 @@ var APP_ACCESS_MARKS = {
3118
3119
  "artifax": "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2036%2036%22%3E%3Crect%20width%3D%2236%22%20height%3D%2236%22%20rx%3D%227%22%20fill%3D%22%23101010%22%2F%3E%3Cpath%20fill%3D%22%23fff%22%20fill-rule%3D%22evenodd%22%20d%3D%22M6%2029L15%207H21L30%2029H25.7L23.5%2023H12.5L10.3%2029ZM14%2019H22L18%209Z%22%2F%3E%3C%2Fsvg%3E%0A",
3119
3120
  "photogenix": "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2036%2036%22%3E%3Crect%20width%3D%2236%22%20height%3D%2236%22%20rx%3D%227%22%20fill%3D%22%23101010%22%2F%3E%3Cpath%20fill%3D%22%23fff%22%20fill-rule%3D%22evenodd%22%20d%3D%22M10%2029V7H20C25%207%2028%2010%2028%2014.5S25%2022%2020%2022H14V29ZM14%2011V18H20C22.7%2018%2024%2017%2024%2014.5S22.7%2011%2020%2011Z%22%2F%3E%3C%2Fsvg%3E%0A",
3120
3121
  "catalogix": "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2036%2036%22%3E%3Crect%20width%3D%2236%22%20height%3D%2236%22%20rx%3D%227%22%20fill%3D%22%23101010%22%2F%3E%3Cpath%20fill%3D%22%23fff%22%20fill-rule%3D%22evenodd%22%20d%3D%22M30%2012L26.5%2014C24.8%2011.5%2022.3%2010%2018.5%2010C12.7%2010%209%2013%209%2018S12.7%2026%2018.5%2026C22.3%2026%2024.8%2024.5%2026.5%2022L30%2024C27.7%2028%2023.7%2030%2018.5%2030C10.5%2030%205%2025.3%205%2018S10.5%206%2018.5%206C23.7%206%2027.7%208%2030%2012Z%22%2F%3E%3C%2Fsvg%3E%0A",
3121
- "returns": "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2036%2036%22%3E%3Crect%20width%3D%2236%22%20height%3D%2236%22%20rx%3D%227%22%20fill%3D%22%23101010%22%2F%3E%3Cpath%20fill%3D%22%23fff%22%20transform%3D%22translate%288.034%207%29%20scale%280.782%29%22%20d%3D%22M4.536%2028.14H0V0H14.616C21%200%2024.948%203.024%2024.948%208.274C24.948%2012.936%2021.882%2015.792%2016.59%2016.086V16.38C18.774%2016.968%2019.782%2018.228%2020.79%2019.992L25.494%2028.14H20.286L15.792%2020.37C14.532%2018.144%2013.23%2017.22%209.702%2017.22H4.536V28.14ZM4.536%204.074V13.734H14.574C18.354%2013.734%2020.244%2012.432%2020.244%208.904C20.244%205.46%2018.354%204.074%2014.574%204.074H4.536Z%22%2F%3E%3C%2Fsvg%3E%0A"
3122
+ "returns": "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2036%2036%22%3E%3Crect%20width%3D%2236%22%20height%3D%2236%22%20rx%3D%227%22%20fill%3D%22%23101010%22%2F%3E%3Cpath%20fill%3D%22%23fff%22%20transform%3D%22translate%288.034%207%29%20scale%280.782%29%22%20d%3D%22M4.536%2028.14H0V0H14.616C21%200%2024.948%203.024%2024.948%208.274C24.948%2012.936%2021.882%2015.792%2016.59%2016.086V16.38C18.774%2016.968%2019.782%2018.228%2020.79%2019.992L25.494%2028.14H20.286L15.792%2020.37C14.532%2018.144%2013.23%2017.22%209.702%2017.22H4.536V28.14ZM4.536%204.074V13.734H14.574C18.354%2013.734%2020.244%2012.432%2020.244%208.904C20.244%205.46%2018.354%204.074%2014.574%204.074H4.536Z%22%2F%3E%3C%2Fsvg%3E%0A",
3123
+ "tactix": "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2036%2036%22%3E%3Crect%20width%3D%2236%22%20height%3D%2236%22%20rx%3D%227%22%20fill%3D%22%23101010%22%2F%3E%3Cpath%20fill%3D%22%23fff%22%20fill-rule%3D%22evenodd%22%20d%3D%22M5%207H31V11H20V29H16V11H5Z%22%2F%3E%3C%2Fsvg%3E%0A"
3122
3124
  };
3123
3125
 
3124
3126
  // src/teams-content.tsx
@@ -3149,6 +3151,7 @@ var svg_rodctpja6f_default = {
3149
3151
  // src/team-types.ts
3150
3152
  var APP_KEYS = [
3151
3153
  "artifax",
3154
+ "tactix",
3152
3155
  "photogenix",
3153
3156
  "returns",
3154
3157
  "catalogix"
@@ -3158,11 +3161,27 @@ var DEFAULT_PERMISSIONS = {
3158
3161
  photogenix: true,
3159
3162
  catalogix: true,
3160
3163
  returns: true,
3164
+ tactix: true,
3161
3165
  canUseCredits: true,
3162
3166
  canInviteUser: true,
3163
3167
  role: "admin",
3164
3168
  catalogixStores: []
3165
3169
  };
3170
+ function parseInviteEmails(input) {
3171
+ const emails = [];
3172
+ const invalid = [];
3173
+ for (const raw of input.split(/[\s,;]+/)) {
3174
+ const token = raw.trim();
3175
+ if (!token) continue;
3176
+ if (/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(token)) {
3177
+ const email = token.toLowerCase();
3178
+ if (!emails.includes(email)) emails.push(email);
3179
+ } else if (!invalid.includes(token)) {
3180
+ invalid.push(token);
3181
+ }
3182
+ }
3183
+ return { emails, invalid };
3184
+ }
3166
3185
 
3167
3186
  // src/invite-update-modal.tsx
3168
3187
  var import_jsx_runtime14 = require("react/jsx-runtime");
@@ -3283,9 +3302,22 @@ function InviteUpdateModal({
3283
3302
  initialOrganizationStanding = "guest",
3284
3303
  organizationDomain: _organizationDomain,
3285
3304
  allowAdminRole = true,
3286
- onInvite
3305
+ onInvite,
3306
+ onInviteMany
3287
3307
  }) {
3288
- useOverlayOpen(open, onClose);
3308
+ const pendingInvite = (0, import_react9.useRef)(false);
3309
+ const inviteGeneration = (0, import_react9.useRef)(0);
3310
+ const requestClose = () => {
3311
+ if (!pendingInvite.current) onClose();
3312
+ };
3313
+ useOverlayOpen(open, requestClose);
3314
+ (0, import_react9.useEffect)(() => {
3315
+ setSubmitting(false);
3316
+ return () => {
3317
+ inviteGeneration.current += 1;
3318
+ pendingInvite.current = false;
3319
+ };
3320
+ }, [open, mode, userEmail]);
3289
3321
  const [emailValue, setEmailValue] = (0, import_react9.useState)("");
3290
3322
  const [hasChanges, setHasChanges] = (0, import_react9.useState)(false);
3291
3323
  const [role, setRole] = (0, import_react9.useState)("member");
@@ -3302,6 +3334,8 @@ function InviteUpdateModal({
3302
3334
  !hiddenApps.includes("catalogix")
3303
3335
  );
3304
3336
  const [returnsOn, setReturnsOn] = (0, import_react9.useState)(!hiddenApps.includes("returns"));
3337
+ const [tactixOn, setTactixOn] = (0, import_react9.useState)(!hiddenApps.includes("tactix"));
3338
+ const [submitting, setSubmitting] = (0, import_react9.useState)(false);
3305
3339
  const [storeSearch, setStoreSearch] = (0, import_react9.useState)("");
3306
3340
  const [selectedStores, setSelectedStores] = (0, import_react9.useState)(/* @__PURE__ */ new Set());
3307
3341
  const filteredStores = stores.filter(
@@ -3320,6 +3354,7 @@ function InviteUpdateModal({
3320
3354
  );
3321
3355
  setCatalogixOn(!hidden.has("catalogix") && initialPermissions.catalogix);
3322
3356
  setReturnsOn(!hidden.has("returns") && initialPermissions.returns);
3357
+ setTactixOn(!hidden.has("tactix") && Boolean(initialPermissions.tactix));
3323
3358
  setSelectedStores(
3324
3359
  new Set(hidden.has("catalogix") ? [] : initialPermissions.catalogixStores)
3325
3360
  );
@@ -3335,6 +3370,8 @@ function InviteUpdateModal({
3335
3370
  setPhotogenixOn(!hidden.has("photogenix"));
3336
3371
  setCatalogixOn(!hidden.has("catalogix"));
3337
3372
  setReturnsOn(!hidden.has("returns"));
3373
+ setTactixOn(!hidden.has("tactix"));
3374
+ setSubmitting(false);
3338
3375
  setStoreSearch("");
3339
3376
  setSelectedStores(/* @__PURE__ */ new Set());
3340
3377
  }
@@ -3342,7 +3379,8 @@ function InviteUpdateModal({
3342
3379
  const adminLocked = mode === "invite" && !allowAdminRole;
3343
3380
  if (!open) return null;
3344
3381
  const isInvite = mode === "invite";
3345
- const hasEmail = /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(emailValue.trim());
3382
+ const parsedEmails = parseInviteEmails(emailValue);
3383
+ const hasEmail = parsedEmails.emails.length > 0 && parsedEmails.invalid.length === 0;
3346
3384
  function markChanged() {
3347
3385
  setHasChanges(true);
3348
3386
  }
@@ -3352,12 +3390,13 @@ function InviteUpdateModal({
3352
3390
  artifax: artifaxOn,
3353
3391
  photogenix: photogenixOn,
3354
3392
  returns: returnsOn,
3355
- catalogix: catalogixOn
3393
+ catalogix: catalogixOn,
3394
+ tactix: tactixOn
3356
3395
  };
3357
3396
  const notLastShown = (key) => shownApps[shownApps.length - 1] !== key;
3358
3397
  const appValue = (key) => role === "admin" || showsApp(key) ? appToggles[key] : false;
3359
3398
  const grantsNoApp = role === "member" && shownApps.length > 0 && !shownApps.some((key) => appToggles[key]);
3360
- const isSubmitDisabled = isInvite ? !hasEmail || grantsNoApp : !(allowSubmitWithoutChanges || hasChanges);
3399
+ const isSubmitDisabled = isInvite ? !hasEmail || grantsNoApp || submitting : !(allowSubmitWithoutChanges || hasChanges);
3361
3400
  function toggleStore(storeId) {
3362
3401
  setSelectedStores((prev) => {
3363
3402
  const next = new Set(prev);
@@ -3373,7 +3412,7 @@ function InviteUpdateModal({
3373
3412
  className: "fixed inset-0 z-50 flex items-center justify-center",
3374
3413
  style: { backgroundColor: "rgba(0, 0, 0, 0.6)" },
3375
3414
  onClick: (e) => {
3376
- if (e.target === e.currentTarget) onClose();
3415
+ if (e.target === e.currentTarget) requestClose();
3377
3416
  },
3378
3417
  children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
3379
3418
  "div",
@@ -3416,7 +3455,7 @@ function InviteUpdateModal({
3416
3455
  children: isInvite ? "Invite" : "Update user"
3417
3456
  }
3418
3457
  ),
3419
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "shrink-0 cursor-pointer", onClick: onClose, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_icons5.SiconClose, { className: "w-6 h-6", color: T6.primary }) })
3458
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { type: "button", "aria-label": "Close invite dialog", disabled: submitting, className: "shrink-0 cursor-pointer disabled:cursor-wait", onClick: requestClose, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_icons5.SiconClose, { className: "w-6 h-6", color: T6.primary }) })
3420
3459
  ]
3421
3460
  }
3422
3461
  ) })
@@ -3463,6 +3502,7 @@ function InviteUpdateModal({
3463
3502
  color: T6.primary
3464
3503
  },
3465
3504
  placeholder: "email@domain.in, email@domain.in, email@domain.in...",
3505
+ "aria-invalid": parsedEmails.invalid.length > 0,
3466
3506
  value: emailValue,
3467
3507
  onChange: (e) => setEmailValue(e.target.value)
3468
3508
  }
@@ -3484,6 +3524,20 @@ function InviteUpdateModal({
3484
3524
  }
3485
3525
  ) })
3486
3526
  }
3527
+ ),
3528
+ isInvite && parsedEmails.invalid.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3529
+ "span",
3530
+ {
3531
+ role: "alert",
3532
+ style: {
3533
+ fontFamily: T6.font,
3534
+ fontSize: T6.fsXs,
3535
+ fontWeight: 400,
3536
+ lineHeight: T6.lhXs,
3537
+ color: "var(--alias-text---icons-error)"
3538
+ },
3539
+ children: parsedEmails.invalid.length === 1 ? `Not a valid email: ${parsedEmails.invalid[0]}` : `Not valid emails: ${parsedEmails.invalid.join(", ")}`
3540
+ }
3487
3541
  )
3488
3542
  ]
3489
3543
  }
@@ -3918,6 +3972,101 @@ function InviteUpdateModal({
3918
3972
  }
3919
3973
  ) })
3920
3974
  ] }) }),
3975
+ showsApp("tactix") && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_jsx_runtime14.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "shrink-0 w-full relative", children: [
3976
+ notLastShown("tactix") && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3977
+ "div",
3978
+ {
3979
+ "aria-hidden": true,
3980
+ className: "absolute inset-0 pointer-events-none",
3981
+ style: {
3982
+ borderBottom: `1px solid ${T6.borderSubtle}`
3983
+ }
3984
+ }
3985
+ ),
3986
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "flex flex-row items-center size-full", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
3987
+ "div",
3988
+ {
3989
+ className: "flex items-center w-full",
3990
+ style: { padding: T6.sp3xl, gap: T6.spMd },
3991
+ children: [
3992
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
3993
+ "div",
3994
+ {
3995
+ className: "flex flex-1 min-w-0 items-center",
3996
+ style: { gap: T6.spXl },
3997
+ children: [
3998
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3999
+ "div",
4000
+ {
4001
+ className: "shrink-0 flex items-center",
4002
+ style: {
4003
+ background: T6.fillHover,
4004
+ borderRadius: T6.rXl,
4005
+ padding: T6.spMd
4006
+ },
4007
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
4008
+ import_icons5.SiconChartBar,
4009
+ {
4010
+ className: "w-6 h-6",
4011
+ color: T6.primary
4012
+ }
4013
+ )
4014
+ }
4015
+ ),
4016
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
4017
+ "div",
4018
+ {
4019
+ className: "flex flex-1 min-w-0 flex-col items-start overflow-hidden text-ellipsis whitespace-nowrap",
4020
+ style: { opacity: tactixOn ? 1 : 0.5 },
4021
+ children: [
4022
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
4023
+ "p",
4024
+ {
4025
+ className: "w-full overflow-hidden shrink-0",
4026
+ style: {
4027
+ fontFamily: T6.font,
4028
+ fontSize: T6.fsSm,
4029
+ fontWeight: 500,
4030
+ lineHeight: T6.lhSm,
4031
+ color: T6.primary
4032
+ },
4033
+ children: "Tactix"
4034
+ }
4035
+ ),
4036
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
4037
+ "p",
4038
+ {
4039
+ className: "w-full overflow-hidden shrink-0",
4040
+ style: {
4041
+ fontFamily: T6.font,
4042
+ fontSize: T6.fsXs,
4043
+ fontWeight: 400,
4044
+ lineHeight: T6.lhXs,
4045
+ color: T6.tertiary
4046
+ },
4047
+ children: "Buying and planning"
4048
+ }
4049
+ )
4050
+ ]
4051
+ }
4052
+ )
4053
+ ]
4054
+ }
4055
+ ),
4056
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
4057
+ ToggleSwitch,
4058
+ {
4059
+ active: tactixOn,
4060
+ onClick: () => {
4061
+ setTactixOn(!tactixOn);
4062
+ markChanged();
4063
+ }
4064
+ }
4065
+ )
4066
+ ]
4067
+ }
4068
+ ) })
4069
+ ] }) }),
3921
4070
  showsApp("photogenix") && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_jsx_runtime14.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "shrink-0 w-full relative", children: [
3922
4071
  notLastShown("photogenix") && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3923
4072
  "div",
@@ -4432,18 +4581,33 @@ function InviteUpdateModal({
4432
4581
  photogenix: appValue("photogenix"),
4433
4582
  catalogix: appValue("catalogix"),
4434
4583
  returns: appValue("returns"),
4584
+ tactix: appValue("tactix"),
4435
4585
  // Stores ride on Catalogix, so they follow it: a
4436
4586
  // hidden Catalogix grants no app and therefore no
4437
4587
  // storefronts. Keeping them would leave a member
4438
4588
  // scoped to stores in a product they cannot open.
4439
4589
  catalogixStores: role === "admin" || showsApp("catalogix") ? Array.from(selectedStores) : []
4440
4590
  };
4441
- if (isInvite && onInvite) {
4442
- onInvite(
4443
- perms,
4444
- emailValue.trim(),
4445
- showOrganizationStanding ? orgStanding : void 0
4446
- );
4591
+ const standing = showOrganizationStanding ? orgStanding : void 0;
4592
+ if (isInvite && onInviteMany) {
4593
+ if (pendingInvite.current) return;
4594
+ pendingInvite.current = true;
4595
+ const generation = ++inviteGeneration.current;
4596
+ const current = () => inviteGeneration.current === generation;
4597
+ setSubmitting(true);
4598
+ Promise.resolve().then(() => current() ? onInviteMany(perms, parsedEmails.emails, standing) : void 0).then((result) => {
4599
+ if (current() && result && result.failed.length > 0) {
4600
+ setEmailValue(result.failed.join(", "));
4601
+ }
4602
+ }).catch(() => void 0).finally(() => {
4603
+ if (!current()) return;
4604
+ pendingInvite.current = false;
4605
+ setSubmitting(false);
4606
+ });
4607
+ } else if (isInvite && onInvite) {
4608
+ for (const email of parsedEmails.emails) {
4609
+ onInvite(perms, email, standing);
4610
+ }
4447
4611
  } else if (onSave) {
4448
4612
  onSave(perms);
4449
4613
  }
@@ -4678,6 +4842,7 @@ function appNameTokens(app) {
4678
4842
  return ["artifax", "artifact", "artifacts", "artifex", "chat"];
4679
4843
  if (app === "photogenix") return ["photogenix"];
4680
4844
  if (app === "returns") return ["returns", "return"];
4845
+ if (app === "tactix") return ["tactix"];
4681
4846
  return ["catalogix"];
4682
4847
  }
4683
4848
  function normalizeServiceName(value) {
@@ -4706,6 +4871,7 @@ function permissionServiceIds(services, permissions) {
4706
4871
  if (serviceMatchesApp(s, "catalogix") && permissions.catalogix)
4707
4872
  return true;
4708
4873
  if (serviceMatchesApp(s, "returns") && permissions.returns) return true;
4874
+ if (serviceMatchesApp(s, "tactix") && permissions.tactix) return true;
4709
4875
  return false;
4710
4876
  }).map((s) => s._id);
4711
4877
  }
@@ -4818,7 +4984,8 @@ function readInviteAppFlag(invRecord, app) {
4818
4984
  ],
4819
4985
  photogenix: ["photogenix", "photogenixAccess"],
4820
4986
  catalogix: ["catalogix", "catalogixAccess"],
4821
- returns: ["returns", "return", "returnsAccess"]
4987
+ returns: ["returns", "return", "returnsAccess"],
4988
+ tactix: ["tactix", "tactixAccess"]
4822
4989
  };
4823
4990
  const containers = [invRecord];
4824
4991
  for (const nestedKey of ["permissions", "permission", "access", "apps"]) {
@@ -4893,6 +5060,7 @@ function memberToTeamMember(m, services) {
4893
5060
  const hasPhotogenix = isAdmin || userHasApp("photogenix");
4894
5061
  const hasCatalogix = isAdmin || userHasApp("catalogix");
4895
5062
  const hasReturns = isAdmin || userHasApp("returns");
5063
+ const hasTactix = isAdmin || userHasApp("tactix");
4896
5064
  return {
4897
5065
  id: m._id,
4898
5066
  kind: "member",
@@ -4919,6 +5087,7 @@ function memberToTeamMember(m, services) {
4919
5087
  photogenix: hasPhotogenix,
4920
5088
  catalogix: hasCatalogix,
4921
5089
  returns: hasReturns,
5090
+ tactix: hasTactix,
4922
5091
  canUseCredits: m.creditAccess,
4923
5092
  canInviteUser: m.inviteAccess,
4924
5093
  role: m.role,
@@ -4937,14 +5106,17 @@ function inviteToTeamMember(inv, services) {
4937
5106
  );
4938
5107
  const derivedCatalogix = serviceNames.some((n) => matchesApp(n, "catalogix"));
4939
5108
  const derivedReturns = serviceNames.some((n) => matchesApp(n, "returns"));
5109
+ const derivedTactix = serviceNames.some((n) => matchesApp(n, "tactix"));
4940
5110
  const explicitArtifax = readInviteAppFlag(invRecord, "artifax");
4941
5111
  const explicitPhotogenix = readInviteAppFlag(invRecord, "photogenix");
4942
5112
  const explicitCatalogix = readInviteAppFlag(invRecord, "catalogix");
4943
5113
  const explicitReturns = readInviteAppFlag(invRecord, "returns");
5114
+ const explicitTactix = readInviteAppFlag(invRecord, "tactix");
4944
5115
  const artifaxFlag = Boolean(explicitArtifax) || derivedArtifax;
4945
5116
  const photogenixFlag = Boolean(explicitPhotogenix) || derivedPhotogenix;
4946
5117
  const catalogixFlag = Boolean(explicitCatalogix) || derivedCatalogix;
4947
5118
  const returnsFlag = Boolean(explicitReturns) || derivedReturns;
5119
+ const tactixFlag = Boolean(explicitTactix) || derivedTactix;
4948
5120
  const catalogixStores = uniqueNonEmpty([
4949
5121
  ...extractIdsFromMixedArray(invRecord.stores),
4950
5122
  ...extractIdsFromMixedArray(invRecord.storeIds)
@@ -4961,6 +5133,7 @@ function inviteToTeamMember(inv, services) {
4961
5133
  photogenix: photogenixFlag,
4962
5134
  catalogix: catalogixFlag,
4963
5135
  returns: returnsFlag,
5136
+ tactix: tactixFlag,
4964
5137
  canUseCredits: inv.creditAccess ?? false,
4965
5138
  canInviteUser: inv.inviteAccess ?? false,
4966
5139
  role: inv.role ?? "member",
@@ -4969,7 +5142,7 @@ function inviteToTeamMember(inv, services) {
4969
5142
  };
4970
5143
  }
4971
5144
  function AccessIcons({ permissions }) {
4972
- const apps = ["artifax", "photogenix", "catalogix", "returns"];
5145
+ const apps = ["artifax", "tactix", "photogenix", "catalogix", "returns"];
4973
5146
  return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "flex items-center shrink-0", style: { gap: 6 }, children: apps.filter((app) => permissions[app]).map((app) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
4974
5147
  "img",
4975
5148
  {
@@ -5162,12 +5335,17 @@ function TeamsContent({
5162
5335
  isReady: permissionsReady,
5163
5336
  failed: permissionData?.failed
5164
5337
  });
5338
+ const modalSession = (0, import_react10.useRef)(0);
5165
5339
  const [modal, setModal] = (0, import_react10.useState)({
5166
5340
  open: false,
5167
5341
  mode: "invite"
5168
5342
  });
5169
5343
  (0, import_react10.useEffect)(() => {
5344
+ modalSession.current += 1;
5170
5345
  setModal({ open: false, mode: "invite" });
5346
+ return () => {
5347
+ modalSession.current += 1;
5348
+ };
5171
5349
  }, [permissionScope, api]);
5172
5350
  const MOCK_ACTIVE = [
5173
5351
  {
@@ -5316,7 +5494,10 @@ function TeamsContent({
5316
5494
  fetchGeneration.current += 1;
5317
5495
  };
5318
5496
  }, [fetchData]);
5319
- const openInviteModal = () => setModal({ open: true, mode: "invite" });
5497
+ const openInviteModal = () => {
5498
+ modalSession.current += 1;
5499
+ setModal({ open: true, mode: "invite" });
5500
+ };
5320
5501
  (0, import_react10.useEffect)(() => {
5321
5502
  if ((onInviteOpen || inviteRequested) && permissionsReady && !permissionData?.failed) {
5322
5503
  if (viewerCanInvite) openInviteModal();
@@ -5328,6 +5509,7 @@ function TeamsContent({
5328
5509
  onCanInviteChange?.(viewerCanInvite);
5329
5510
  }, [viewerCanInvite, onCanInviteChange]);
5330
5511
  const openUpdateModal = async (member) => {
5512
+ modalSession.current += 1;
5331
5513
  setModal({
5332
5514
  open: true,
5333
5515
  mode: "update",
@@ -5347,7 +5529,10 @@ function TeamsContent({
5347
5529
  } catch {
5348
5530
  }
5349
5531
  };
5350
- const closeModal = () => setModal({ open: false, mode: "invite" });
5532
+ const closeModal = () => {
5533
+ modalSession.current += 1;
5534
+ setModal({ open: false, mode: "invite" });
5535
+ };
5351
5536
  const currentMemberPermissions = modal.target?.permissions;
5352
5537
  const handleSave = async (permissions) => {
5353
5538
  if (!modal.target) {
@@ -5492,34 +5677,55 @@ function TeamsContent({
5492
5677
  toast.error(msg);
5493
5678
  }
5494
5679
  };
5495
- const handleInvite = async (permissions, email, organizationStanding) => {
5680
+ const handleInviteMany = async (permissions, emails, organizationStanding) => {
5681
+ const session = modalSession.current;
5682
+ const isCurrent = () => fetchMounted.current && modalSession.current === session && latestFetchScope.current.scope === permissionScope && latestFetchScope.current.api === api;
5683
+ if (!isCurrent()) return { failed: emails };
5496
5684
  if (!viewerCanInvite || permissions.role === "admin" && highestRole !== "admin") {
5497
5685
  toast.error("You do not have permission to invite users");
5498
5686
  closeModal();
5499
- return;
5687
+ return { failed: [] };
5500
5688
  }
5501
5689
  const serviceIds = permissions.role === "admin" ? [] : permissionServiceIds(allServices, permissions);
5502
- try {
5503
- await api.inviteMember({
5504
- email,
5505
- creditAccess: permissions.canUseCredits,
5506
- inviteAccess: permissions.canInviteUser,
5507
- role: permissions.role,
5508
- serviceIds,
5509
- storeIds: permissions.catalogixStores || [],
5510
- // Omitted when the control was never shown, which leaves the backend
5511
- // deriving the standing from the invitee's email domain as before.
5512
- ...organizationStanding ? {
5513
- organizationRole: organizationStanding === "colleague" ? "member" : "guest"
5514
- } : {}
5515
- });
5516
- toast.success(`Invitation sent to ${email}`);
5517
- await fetchData();
5518
- closeModal();
5519
- } catch (err) {
5520
- const msg = errorMessage(err, { method: "POST" });
5521
- toast.error(msg);
5690
+ const sent = [];
5691
+ const failed = [];
5692
+ for (const email of emails) {
5693
+ if (!isCurrent()) return { failed: emails.filter((address) => !sent.includes(address)) };
5694
+ try {
5695
+ await api.inviteMember({
5696
+ email,
5697
+ creditAccess: permissions.canUseCredits,
5698
+ inviteAccess: permissions.canInviteUser,
5699
+ role: permissions.role,
5700
+ serviceIds,
5701
+ storeIds: permissions.catalogixStores || [],
5702
+ // Omitted when the control was never shown, which leaves the backend
5703
+ // deriving the standing from the invitee's email domain as before.
5704
+ ...organizationStanding ? {
5705
+ organizationRole: organizationStanding === "colleague" ? "member" : "guest"
5706
+ } : {}
5707
+ });
5708
+ sent.push(email);
5709
+ } catch (err) {
5710
+ failed.push({ email, message: errorMessage(err, { method: "POST" }) });
5711
+ }
5712
+ }
5713
+ if (!isCurrent()) return { failed: failed.map((f) => f.email) };
5714
+ if (sent.length === 1) toast.success(`Invitation sent to ${sent[0]}`);
5715
+ else if (sent.length > 1)
5716
+ toast.success(`Invitations sent to ${sent.length} people`);
5717
+ if (failed.length === 1) {
5718
+ toast.error(
5719
+ emails.length === 1 ? failed[0].message : `${failed[0].email}: ${failed[0].message}`
5720
+ );
5721
+ } else if (failed.length > 1) {
5722
+ toast.error(
5723
+ `${failed.length} invitations were not sent. ${failed[0].email}: ${failed[0].message}`
5724
+ );
5522
5725
  }
5726
+ if (sent.length > 0) await fetchData();
5727
+ if (isCurrent() && failed.length === 0) closeModal();
5728
+ return { failed: failed.map((f) => f.email) };
5523
5729
  };
5524
5730
  const filteredActive = activeMembers.filter((m) => {
5525
5731
  const q = searchQuery.toLowerCase();
@@ -5637,7 +5843,7 @@ function TeamsContent({
5637
5843
  showOrganizationStanding: mayGrantOrgMembership,
5638
5844
  organizationName: organizationName ?? orgCurrent?.name,
5639
5845
  organizationDomain: workspaceOrgId && orgCurrent?.id === workspaceOrgId ? orgCurrent?.domain : void 0,
5640
- onInvite: handleInvite
5846
+ onInviteMany: handleInviteMany
5641
5847
  }
5642
5848
  )
5643
5849
  ] });
@@ -7744,6 +7950,35 @@ function OrganizationListContent() {
7744
7950
  ] });
7745
7951
  }
7746
7952
 
7953
+ // src/billing-request-gate.ts
7954
+ function createBillingRequestGate(initialScope) {
7955
+ let scope = initialScope;
7956
+ let generation = 0;
7957
+ return {
7958
+ setScope(next) {
7959
+ if (next !== scope) {
7960
+ scope = next;
7961
+ generation++;
7962
+ }
7963
+ },
7964
+ invalidate() {
7965
+ generation++;
7966
+ },
7967
+ begin(requestScope) {
7968
+ if (requestScope !== scope) return null;
7969
+ const id = ++generation;
7970
+ return () => id === generation && requestScope === scope;
7971
+ }
7972
+ };
7973
+ }
7974
+
7975
+ // src/plan-card-state.ts
7976
+ function planCardState(loaded, loading, failed, hasSubscription) {
7977
+ if (!loaded || loading) return "loading";
7978
+ if (failed) return "error";
7979
+ return hasSubscription ? "ready" : "empty";
7980
+ }
7981
+
7747
7982
  // src/billing-errors.ts
7748
7983
  function isBillingWorkspaceMissing(failure) {
7749
7984
  const seen = /* @__PURE__ */ new Set();
@@ -10695,12 +10930,23 @@ async function loadCurrentPlan(fetchCurrentPlan) {
10695
10930
  response = await fetchCurrentPlan();
10696
10931
  } catch (failure) {
10697
10932
  const entitlement2 = entitlementFromFailure(failure);
10698
- if (!entitlement2) throw failure;
10933
+ if (!entitlement2) {
10934
+ const error = failure;
10935
+ if (error?.status === 404 || error?.response?.status === 404) {
10936
+ return { subscription: null, entitlement: null, paid: false, noSubscriptionConfirmed: true };
10937
+ }
10938
+ throw failure;
10939
+ }
10699
10940
  return { subscription: null, entitlement: entitlement2, paid: entitlement2.paid };
10700
10941
  }
10701
10942
  const subscription = response?.data ?? null;
10702
10943
  const entitlement = entitlementFromBody(response);
10703
- return { subscription, entitlement, paid: hasPaidFeatures({ entitlement, subscription }) };
10944
+ return {
10945
+ subscription,
10946
+ entitlement,
10947
+ paid: hasPaidFeatures({ entitlement, subscription }),
10948
+ ...response?.noSubscription === true ? { noSubscriptionConfirmed: true } : {}
10949
+ };
10704
10950
  }
10705
10951
 
10706
10952
  // src/billing-layout.ts
@@ -12228,6 +12474,10 @@ function BillingContent({
12228
12474
  );
12229
12475
  const [buyCreditsInFlight, setBuyCreditsInFlight] = (0, import_react23.useState)(false);
12230
12476
  const [loadingBilling, setLoadingBilling] = (0, import_react23.useState)(false);
12477
+ const [planLoadFailed, setPlanLoadFailed] = (0, import_react23.useState)(false);
12478
+ const billingRequestGate = (0, import_react23.useRef)(createBillingRequestGate(workspaceId));
12479
+ billingRequestGate.current.setScope(workspaceId);
12480
+ (0, import_react23.useEffect)(() => () => billingRequestGate.current.invalidate(), []);
12231
12481
  const [billingOverviewLoaded, setBillingOverviewLoaded] = (0, import_react23.useState)(false);
12232
12482
  const [loadingTable, setLoadingTable] = (0, import_react23.useState)(false);
12233
12483
  const [showInitialLoader, setShowInitialLoader] = (0, import_react23.useState)(true);
@@ -12252,6 +12502,8 @@ function BillingContent({
12252
12502
  }
12253
12503
  }, [api]);
12254
12504
  const fetchBillingOverview = (0, import_react23.useCallback)(async () => {
12505
+ const isCurrent = billingRequestGate.current.begin(workspaceId);
12506
+ if (!isCurrent) return;
12255
12507
  setLoadingBilling(true);
12256
12508
  setBillingOverviewLoaded(false);
12257
12509
  try {
@@ -12264,8 +12516,13 @@ function BillingContent({
12264
12516
  api.fetchPlans().catch(() => null),
12265
12517
  api.getCustomCreditInfo?.().catch(() => null) ?? Promise.resolve(null)
12266
12518
  ]);
12267
- if (subRes?.subscription) setSubscription(subRes.subscription);
12268
- if (subRes) setEntitlement(subRes.entitlement);
12519
+ if (!isCurrent()) return;
12520
+ const knownPlan = subRes && (subRes.subscription || subRes.entitlement || subRes.noSubscriptionConfirmed);
12521
+ setPlanLoadFailed(!knownPlan);
12522
+ if (knownPlan) {
12523
+ setSubscription(subRes.subscription);
12524
+ setEntitlement(subRes.entitlement);
12525
+ }
12269
12526
  if (creditsRes?.availableCredits != null)
12270
12527
  setAvailableCredits(creditsRes.availableCredits);
12271
12528
  setSharedPool(creditsRes?.sharedPool ?? null);
@@ -12274,11 +12531,14 @@ function BillingContent({
12274
12531
  setCustomPlanCredits(customRes.data.credits);
12275
12532
  }
12276
12533
  } catch {
12534
+ if (isCurrent()) setPlanLoadFailed(true);
12277
12535
  } finally {
12278
- setLoadingBilling(false);
12279
- setBillingOverviewLoaded(true);
12536
+ if (isCurrent()) {
12537
+ setLoadingBilling(false);
12538
+ setBillingOverviewLoaded(true);
12539
+ }
12280
12540
  }
12281
- }, [api]);
12541
+ }, [api, workspaceId]);
12282
12542
  const fetchUserMap = (0, import_react23.useCallback)(async () => {
12283
12543
  try {
12284
12544
  const members = await api.fetchMembers();
@@ -12474,8 +12734,10 @@ function BillingContent({
12474
12734
  setInitialFetchTriggered(false);
12475
12735
  setBillingOverviewLoaded(false);
12476
12736
  setSubscription(null);
12737
+ setPlanLoadFailed(false);
12477
12738
  setEntitlement(null);
12478
12739
  setAvailableCredits(null);
12740
+ setSharedPool(null);
12479
12741
  setProducts([]);
12480
12742
  setTotalCredits(null);
12481
12743
  setCustomPlanCredits(null);
@@ -12536,15 +12798,17 @@ function BillingContent({
12536
12798
  );
12537
12799
  const scheduledDowngradeText = subscription?.downgradeScheduled && subscription.plan?.name ? `Downgrades to ${subscription.plan.name}${scheduledDowngradeDateLabel ? ` ${scheduledDowngradeDateLabel}` : ""}` : void 0;
12538
12800
  const sponsored = isSponsoredEntitlement(entitlement);
12539
- const sponsoredWithoutPlan = sponsored && billingOverviewLoaded && !loadingBilling && subscription == null;
12540
- const isPlanDetailsLoading = sponsoredWithoutPlan ? false : !billingOverviewLoaded || loadingBilling || subscription?.plan == null || !planName || planName === "-" || !planAmount || currentPlanCredits == null;
12801
+ const planState = planCardState(billingOverviewLoaded, loadingBilling, planLoadFailed, subscription != null);
12802
+ const withoutPlan = planState === "empty";
12803
+ const sponsoredWithoutPlan = sponsored && withoutPlan;
12804
+ const isPlanDetailsLoading = planState === "loading";
12541
12805
  const paidFeatures = hasPaidFeatures({ entitlement, subscription });
12542
12806
  const onEntitlementChangeRef = (0, import_react23.useRef)(onEntitlementChange);
12543
12807
  onEntitlementChangeRef.current = onEntitlementChange;
12544
12808
  (0, import_react23.useEffect)(() => {
12545
- if (!billingOverviewLoaded) return;
12809
+ if (!billingOverviewLoaded || loadingBilling || planLoadFailed) return;
12546
12810
  onEntitlementChangeRef.current?.({ entitlement, paid: paidFeatures });
12547
- }, [billingOverviewLoaded, entitlement, paidFeatures]);
12811
+ }, [billingOverviewLoaded, loadingBilling, planLoadFailed, entitlement, paidFeatures]);
12548
12812
  const {
12549
12813
  used: usedCredits,
12550
12814
  remaining: remainingCredits,
@@ -12814,20 +13078,27 @@ function BillingContent({
12814
13078
  className: "flex items-start shrink-0 w-full",
12815
13079
  style: { gap: 12 },
12816
13080
  children: [
12817
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
13081
+ planState === "error" ? /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { role: "alert", className: "flex-1 min-w-0", style: { padding: 16 }, children: [
13082
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("p", { children: "Plan details could not be loaded." }),
13083
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_ui17.ScButton, { text: "Retry plan details", variant: "outline", size: "sm", onClick: () => void fetchBillingOverview() })
13084
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
12818
13085
  import_ui17.ScPlanDetailsCard,
12819
13086
  {
12820
- planName: sponsoredWithoutPlan ? "Free" : planName,
13087
+ planName: withoutPlan ? "Free" : planName || "Current plan",
12821
13088
  planCredits: sponsoredWithoutPlan ? "Shared credits" : planCreditsText,
12822
- planPrice: sponsoredWithoutPlan ? `${workspace.current?.country?.trim().toUpperCase() === "IN" ? "\u20B9" : "$"}0.00 / month` : planAmount,
13089
+ planPrice: withoutPlan ? "No paid subscription" : planAmount,
12823
13090
  badgeText: "Active",
12824
13091
  badgeSubText: scheduledDowngradeText,
12825
13092
  currentPlanLabel: "Current plan",
12826
- upgradeButtonText: subscription?.downgradeScheduled ? "Cancel downgrade" : "Manage Plan",
13093
+ upgradeButtonText: withoutPlan ? "See plans" : navigation.manageBilling ? "Manage Plan" : subscription?.downgradeScheduled ? "Cancel downgrade" : "Manage Plan",
12827
13094
  isLoading: isPlanDetailsLoading,
12828
13095
  className: "flex-1 min-w-0",
12829
13096
  style: { padding: 16, gap: 8 },
12830
13097
  onUpgrade: () => {
13098
+ if (navigation.manageBilling) {
13099
+ navigation.manageBilling();
13100
+ return;
13101
+ }
12831
13102
  void logBillingEvent("billing_plans_opened", "Plans opened", {
12832
13103
  action: "open_plans"
12833
13104
  });
@@ -12852,6 +13123,10 @@ function BillingContent({
12852
13123
  className: "flex-1 min-w-0",
12853
13124
  style: { padding: 16, gap: 8 },
12854
13125
  onBuyClick: () => {
13126
+ if (navigation.manageBilling) {
13127
+ navigation.manageBilling();
13128
+ return;
13129
+ }
12855
13130
  void logBillingEvent(
12856
13131
  "billing_buy_credits_clicked",
12857
13132
  "Buy credits clicked",