@wix/himalaya-cli 0.1820.0 → 0.1822.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6760,6 +6760,211 @@ function createRedirectSession(req = {}, opts) {
6760
6760
  );
6761
6761
  }
6762
6762
 
6763
+ // ../../core/ts/src/message-format.ts
6764
+ function pluralCategory(n, locale) {
6765
+ const lang = (locale || "en").split(/[-_]/)[0].toLowerCase();
6766
+ if (typeof Intl !== "undefined" && typeof Intl.PluralRules === "function") {
6767
+ try {
6768
+ return new Intl.PluralRules(lang).select(n);
6769
+ } catch {
6770
+ }
6771
+ }
6772
+ return pluralCategoryFallback(n, lang);
6773
+ }
6774
+ function pluralCategoryFallback(n, locale) {
6775
+ const lang = (locale || "en").split(/[-_]/)[0].toLowerCase();
6776
+ const i = Math.floor(Math.abs(n));
6777
+ const isInt = Number.isInteger(n);
6778
+ const m10 = i % 10;
6779
+ const m100 = i % 100;
6780
+ const millions = isInt && i !== 0 && i % 1e6 === 0;
6781
+ switch (lang) {
6782
+ case "he":
6783
+ if (i === 1 && isInt || i === 0 && !isInt) return "one";
6784
+ if (i === 2 && isInt) return "two";
6785
+ return "other";
6786
+ case "fr":
6787
+ case "pt":
6788
+ if (i === 0 || i === 1) return "one";
6789
+ return millions ? "many" : "other";
6790
+ case "es":
6791
+ case "it":
6792
+ if (i === 1 && isInt) return "one";
6793
+ return millions ? "many" : "other";
6794
+ case "da":
6795
+ if (isInt ? i === 1 : i === 0 || i === 1) return "one";
6796
+ return "other";
6797
+ case "cs":
6798
+ if (!isInt) return "many";
6799
+ if (i === 1) return "one";
6800
+ return i >= 2 && i <= 4 ? "few" : "other";
6801
+ case "pl":
6802
+ if (!isInt) return "other";
6803
+ if (i === 1) return "one";
6804
+ if (m10 >= 2 && m10 <= 4 && !(m100 >= 12 && m100 <= 14)) return "few";
6805
+ return "many";
6806
+ case "ru":
6807
+ case "uk":
6808
+ if (!isInt) return "other";
6809
+ if (m10 === 1 && m100 !== 11) return "one";
6810
+ if (m10 >= 2 && m10 <= 4 && !(m100 >= 12 && m100 <= 14)) return "few";
6811
+ return "many";
6812
+ case "lt": {
6813
+ if (!isInt) return "many";
6814
+ const tail = m100 >= 11 && m100 <= 19;
6815
+ if (m10 === 1 && !tail) return "one";
6816
+ return m10 >= 2 && !tail ? "few" : "other";
6817
+ }
6818
+ case "ar": {
6819
+ if (!isInt) return "other";
6820
+ if (i === 0) return "zero";
6821
+ if (i === 1) return "one";
6822
+ if (i === 2) return "two";
6823
+ if (m100 >= 3 && m100 <= 10) return "few";
6824
+ return m100 >= 11 ? "many" : "other";
6825
+ }
6826
+ case "id":
6827
+ case "ja":
6828
+ case "ko":
6829
+ case "th":
6830
+ case "vi":
6831
+ case "zh":
6832
+ return "other";
6833
+ case "en":
6834
+ default:
6835
+ return i === 1 && isInt ? "one" : "other";
6836
+ }
6837
+ }
6838
+ function splitArg(body) {
6839
+ const out = [];
6840
+ let depth = 0;
6841
+ let start = 0;
6842
+ for (let i = 0; i < body.length && out.length < 2; i++) {
6843
+ const c = body[i];
6844
+ if (c === "{") depth++;
6845
+ else if (c === "}") depth--;
6846
+ else if (c === "," && depth === 0) {
6847
+ out.push(body.slice(start, i).trim());
6848
+ start = i + 1;
6849
+ }
6850
+ }
6851
+ out.push(body.slice(start));
6852
+ return out;
6853
+ }
6854
+ function parseBranchEntries(spec) {
6855
+ const entries = [];
6856
+ let i = 0;
6857
+ while (i < spec.length) {
6858
+ while (i < spec.length && /\s/.test(spec[i])) i++;
6859
+ const keyStart = i;
6860
+ while (i < spec.length && !/\s|\{/.test(spec[i])) i++;
6861
+ const key = spec.slice(keyStart, i).trim();
6862
+ while (i < spec.length && /\s/.test(spec[i])) i++;
6863
+ if (spec[i] !== "{" || !key) break;
6864
+ let depth = 0;
6865
+ const bodyStart = ++i;
6866
+ for (; i < spec.length; i++) {
6867
+ if (spec[i] === "{") depth++;
6868
+ else if (spec[i] === "}") {
6869
+ if (depth === 0) break;
6870
+ depth--;
6871
+ }
6872
+ }
6873
+ entries.push({ key, body: spec.slice(bodyStart, i), bodyStart, bodyEnd: i });
6874
+ i++;
6875
+ }
6876
+ return entries;
6877
+ }
6878
+ function parseBranches(spec) {
6879
+ const branches = /* @__PURE__ */ Object.create(null);
6880
+ for (const { key, body } of parseBranchEntries(spec)) branches[key] = body;
6881
+ return branches;
6882
+ }
6883
+ function formatMessage(pattern, args = {}, locale = "en") {
6884
+ return formatAt(pattern, args, locale, 0);
6885
+ }
6886
+ var MAX_NESTING = 16;
6887
+ function ownArg(args, name) {
6888
+ return Object.prototype.hasOwnProperty.call(args, name) ? args[name] : void 0;
6889
+ }
6890
+ function formatAt(pattern, args, locale, nesting) {
6891
+ if (!pattern.includes("{") && !pattern.includes("''")) return pattern;
6892
+ let out = "";
6893
+ let i = 0;
6894
+ while (i < pattern.length) {
6895
+ const c = pattern[i];
6896
+ if (c === "'" && pattern[i + 1] === "'") {
6897
+ out += "'";
6898
+ i += 2;
6899
+ continue;
6900
+ }
6901
+ if (c === "'" && (pattern[i + 1] === "{" || pattern[i + 1] === "}" || pattern[i + 1] === "#")) {
6902
+ const close = pattern.indexOf("'", i + 1);
6903
+ if (close === -1) {
6904
+ out += pattern.slice(i + 1);
6905
+ break;
6906
+ }
6907
+ out += pattern.slice(i + 1, close);
6908
+ i = close + 1;
6909
+ continue;
6910
+ }
6911
+ if (c !== "{") {
6912
+ out += c;
6913
+ i++;
6914
+ continue;
6915
+ }
6916
+ let depth = 0;
6917
+ const start = ++i;
6918
+ for (; i < pattern.length; i++) {
6919
+ if (pattern[i] === "{") depth++;
6920
+ else if (pattern[i] === "}") {
6921
+ if (depth === 0) break;
6922
+ depth--;
6923
+ }
6924
+ }
6925
+ if (i >= pattern.length) {
6926
+ out += "{" + pattern.slice(start);
6927
+ break;
6928
+ }
6929
+ const body = pattern.slice(start, i);
6930
+ i++;
6931
+ const [name, kind, spec] = splitArg(body);
6932
+ const value = ownArg(args, name);
6933
+ if (!kind) {
6934
+ out += value === void 0 || value === null ? `{${name}}` : String(value);
6935
+ continue;
6936
+ }
6937
+ if ((kind === "plural" || kind === "select") && spec !== void 0 && nesting >= MAX_NESTING) {
6938
+ out += "{" + body + "}";
6939
+ continue;
6940
+ }
6941
+ if (kind === "plural" && spec !== void 0) {
6942
+ const n = typeof value === "number" ? value : Number(value);
6943
+ const branches = parseBranches(spec);
6944
+ const exact = branches[`=${n}`];
6945
+ const chosen = exact ?? branches[pluralCategory(n, locale)] ?? branches.other;
6946
+ if (chosen === void 0) {
6947
+ out += "{" + body + "}";
6948
+ continue;
6949
+ }
6950
+ out += formatAt(chosen.replace(/#/g, Number.isFinite(n) ? String(n) : ""), args, locale, nesting + 1);
6951
+ continue;
6952
+ }
6953
+ if (kind === "select" && spec !== void 0) {
6954
+ const branches = parseBranches(spec);
6955
+ const chosen = branches[String(value)] ?? branches.other;
6956
+ if (chosen === void 0) {
6957
+ out += "{" + body + "}";
6958
+ continue;
6959
+ }
6960
+ out += formatAt(chosen, args, locale, nesting + 1);
6961
+ continue;
6962
+ }
6963
+ out += value === void 0 || value === null ? `{${name}}` : String(value);
6964
+ }
6965
+ return out;
6966
+ }
6967
+
6763
6968
  // ../../stdlib/flows/screens/src/index.ts
6764
6969
  var PKG = "himalaya";
6765
6970
  var node4 = (id2, type, props) => ({ id: id2, body: { package: PKG, type, props } });
@@ -7023,29 +7228,51 @@ function createAuthService(opts = {}) {
7023
7228
  svc.load();
7024
7229
  return svc;
7025
7230
  }
7231
+ var SIGN_IN_FIRST = "Sign in to join a plan \u2014 memberships belong to a member account.";
7026
7232
  var PRICING_PLANS_APP_ID = "1522827f-c56c-a5c9-2ac9-00f9e6ae12d3";
7027
- function money(pricing) {
7028
- const v = pricing?.price?.value ?? pricing?.value;
7029
- const c = String(pricing?.price?.currency ?? pricing?.currency ?? "");
7233
+ var FALLBACK_SYMBOL = { USD: "$", EUR: "\u20AC", ILS: "\u20AA", GBP: "\xA3", JPY: "\xA5", CNY: "\xA5", INR: "\u20B9", KRW: "\u20A9", BRL: "R$", CAD: "CA$", AUD: "A$" };
7234
+ function money(pricing, loc) {
7235
+ const price = pricing?.price ?? pricing;
7236
+ const formatted = price?.formattedValue ?? price?.formatted ?? pricing?.formatted;
7237
+ if (typeof formatted === "string" && formatted.trim() !== "") return formatted;
7238
+ const v = price?.value;
7239
+ const c = String(price?.currency ?? "");
7030
7240
  if (v == null || v === "") return "";
7031
7241
  const n = Number(v);
7032
- const amount = Number.isFinite(n) ? n % 1 === 0 ? String(n) : n.toFixed(2) : String(v);
7033
- return c ? `${c === "USD" ? "$" : c === "EUR" ? "\u20AC" : c === "ILS" ? "\u20AA" : c + " "}${amount}` : amount;
7034
- }
7035
- function period(pricing) {
7036
- const sub = pricing?.subscription;
7037
- if (sub?.cycleDuration) {
7038
- const n = sub.cycleDuration.count ?? 1;
7039
- const u = String(sub.cycleDuration.unit ?? "MONTH").toLowerCase();
7040
- return n === 1 ? `per ${u}` : `every ${n} ${u}s`;
7242
+ const whole = Number.isFinite(n) && n % 1 === 0;
7243
+ if (c && Number.isFinite(n) && typeof Intl === "object" && typeof Intl.NumberFormat === "function") {
7244
+ try {
7245
+ return new Intl.NumberFormat(loc, { style: "currency", currency: c, ...whole ? { minimumFractionDigits: 0, maximumFractionDigits: 0 } : {} }).format(n);
7246
+ } catch {
7247
+ }
7041
7248
  }
7249
+ const amount = Number.isFinite(n) ? whole ? String(n) : n.toFixed(2) : String(v);
7250
+ return c ? `${FALLBACK_SYMBOL[c] ?? c + " "}${amount}` : amount;
7251
+ }
7252
+ var PERIOD_DEFAULTS = {
7253
+ periodDay: "{count, plural, one {per day} other {every # days}}",
7254
+ periodWeek: "{count, plural, one {per week} other {every # weeks}}",
7255
+ periodMonth: "{count, plural, one {per month} other {every # months}}",
7256
+ periodYear: "{count, plural, one {per year} other {every # years}}",
7257
+ validDay: "{count, plural, one {valid # day} other {valid # days}}",
7258
+ validWeek: "{count, plural, one {valid # week} other {valid # weeks}}",
7259
+ validMonth: "{count, plural, one {valid # month} other {valid # months}}",
7260
+ validYear: "{count, plural, one {valid # year} other {valid # years}}",
7261
+ oneTimeNoExpiry: "one-time, no expiry"
7262
+ };
7263
+ function period(pricing, tpl, loc) {
7264
+ const line = (family, unit, n) => {
7265
+ const u = unit.toLowerCase();
7266
+ const key = family + u.charAt(0).toUpperCase() + u.slice(1);
7267
+ const fallback = PERIOD_DEFAULTS[key] ?? (family === "period" ? `{count, plural, one {per ${u}} other {every # ${u}s}}` : `{count, plural, one {valid # ${u}} other {valid # ${u}s}}`);
7268
+ const pattern = tpl(key, fallback);
7269
+ return formatMessage(pattern, { count: n }, pattern === fallback ? "en" : loc);
7270
+ };
7271
+ const sub = pricing?.subscription;
7272
+ if (sub?.cycleDuration) return line("period", String(sub.cycleDuration.unit ?? "MONTH"), sub.cycleDuration.count ?? 1);
7042
7273
  const d = pricing?.singlePaymentForDuration;
7043
- if (d) {
7044
- const n = d.count ?? 0;
7045
- const u = String(d.unit ?? "DAY").toLowerCase();
7046
- return `valid ${n} ${u}${n === 1 ? "" : "s"}`;
7047
- }
7048
- if (pricing?.singlePaymentUnlimited) return "one-time, no expiry";
7274
+ if (d) return line("valid", String(d.unit ?? "DAY"), d.count ?? 0);
7275
+ if (pricing?.singlePaymentUnlimited) return tpl("oneTimeNoExpiry", PERIOD_DEFAULTS.oneTimeNoExpiry);
7049
7276
  return "";
7050
7277
  }
7051
7278
  function appleOffered(row, view) {
@@ -7058,7 +7285,39 @@ function createCheckoutService(opts = {}) {
7058
7285
  const commerce = createIapCommerce({ adapters: [pricingPlanOrders], onChange: () => {
7059
7286
  void svc.pricingPublish();
7060
7287
  } });
7061
- const purchaseCopy = { buy: c.joinCta ?? "Buy now", processing: c.pendingNotice ?? "Processing your purchase\u2026", awaitingApproval: "Waiting for approval", unavailable: c.failedNotice ?? "Purchasing is temporarily unavailable.", signInRequired: c.signInFirst ?? "Sign in to join a plan \u2014 memberships belong to a member account.", retry: c.failedNotice ?? "Something went wrong. Try again.", priceChanged: "The price changed. Check it and try again.", support: "We couldn't finish this purchase. Contact support.", memberDetailsRequired: "Complete your profile, then try again.", alreadySubscribed: "You already have this subscription." };
7288
+ const loc = () => {
7289
+ const l = opts.locale?.();
7290
+ return typeof l === "string" && l !== "" ? l : "en";
7291
+ };
7292
+ const text2 = (field, fallback) => {
7293
+ const base2 = c[field] ?? fallback;
7294
+ const key = `checkout.${field}`;
7295
+ const v = opts.text?.(key, base2);
7296
+ return typeof v === "string" && v !== "" && v !== key ? v : base2;
7297
+ };
7298
+ const fmt = (field, fallback, args = {}) => (() => {
7299
+ const pattern = text2(field, fallback);
7300
+ return formatMessage(pattern, args, pattern === fallback ? "en" : loc());
7301
+ })();
7302
+ const purchaseCopy = () => {
7303
+ const out = {
7304
+ buy: text2("joinCta", "Buy now"),
7305
+ processing: text2("pendingNotice", "Processing your purchase\u2026"),
7306
+ awaitingApproval: text2("awaitingApprovalText", "Waiting for approval"),
7307
+ unavailable: text2("purchaseUnavailableText", c.failedNotice ?? "Purchasing is temporarily unavailable."),
7308
+ signInRequired: text2("signInFirst", SIGN_IN_FIRST),
7309
+ retry: text2("retryText", c.failedNotice ?? "Something went wrong. Try again."),
7310
+ priceChanged: text2("priceChangedText", "The price changed. Check it and try again."),
7311
+ support: text2("supportText", "We couldn't finish this purchase. Contact support."),
7312
+ memberDetailsRequired: text2("memberDetailsRequiredText", "Complete your profile, then try again."),
7313
+ alreadySubscribed: text2("alreadySubscribedText", "You already have this subscription.")
7314
+ };
7315
+ const another = text2("buyAnotherText", "");
7316
+ if (another) out.buyAnother = another;
7317
+ const site = text2("sitePaymentUnavailableText", "");
7318
+ if (site) out.sitePaymentUnavailable = site;
7319
+ return out;
7320
+ };
7062
7321
  let catalogRows = [];
7063
7322
  let items = [];
7064
7323
  let started = false;
@@ -7068,30 +7327,32 @@ function createCheckoutService(opts = {}) {
7068
7327
  let regularAccess = /* @__PURE__ */ new Set();
7069
7328
  let loading = 0;
7070
7329
  function project(state) {
7330
+ const pc = purchaseCopy();
7331
+ const currentPlan = text2("joinedLabel", "Current plan");
7071
7332
  const rows = catalogRows.map((row) => {
7072
7333
  const reference = { kind: "pricingPlan", id: row.id };
7073
7334
  const view = commerce.pricing.view(reference);
7074
- const price = iapPriceFields(view, { loading: "Loading price\u2026", unavailable: "Price unavailable", oneTimePurchase: "One-time purchase", purchaseUnavailable: purchaseCopy.unavailable });
7075
- const purchase = commerce.purchaseFields(reference, purchaseCopy);
7335
+ const price = iapPriceFields(view, { loading: text2("priceLoadingText", "Loading price\u2026"), unavailable: text2("priceUnavailableText", "Price unavailable"), oneTimePurchase: text2("oneTimePurchaseLabel", "One-time purchase"), purchaseUnavailable: pc.unavailable });
7336
+ const purchase = commerce.purchaseFields(reference, pc);
7076
7337
  const joined = purchase.appleRoute ? purchase.accessReady : memberSession.current().generation === offerGeneration && regularAccess.has(row.id);
7077
7338
  return {
7078
7339
  ...row,
7079
7340
  joined,
7080
7341
  notJoined: !joined,
7081
- joinedLabel: joined ? c.joinedLabel ?? "Current plan" : "",
7342
+ joinedLabel: joined ? currentPlan : "",
7082
7343
  priceLine: view.route === "disabled" ? row.priceLine : price.priceText,
7083
7344
  periodLine: purchase.appleRoute ? view.renews ? row.periodLine : price.priceNote : price.actionDisabled ? "" : row.periodLine,
7084
- cta: joined ? c.joinedLabel ?? "Current plan" : purchase.appleRoute ? purchase.buyLabel : row.cta,
7345
+ cta: joined ? currentPlan : purchase.appleRoute ? purchase.buyLabel : row.cta,
7085
7346
  joinDisabled: joined || (purchase.appleRoute ? purchase.buyDisabled || !appleOffered(row, view) : price.actionDisabled || memberSession.current().generation !== offerGeneration),
7086
- joinNote: purchase.appleRoute ? appleOffered(row, view) ? purchase.buyNote : purchaseCopy.unavailable : price.actionNote
7347
+ joinNote: purchase.appleRoute ? appleOffered(row, view) ? purchase.buyNote : pc.unavailable : price.actionNote
7087
7348
  };
7088
7349
  });
7089
- const visibleAppleOwner = catalogRows.some((row) => row.id === existingAccess.planId && commerce.purchaseFields({ kind: "pricingPlan", id: row.id }, purchaseCopy).appleRoute);
7350
+ const visibleAppleOwner = catalogRows.some((row) => row.id === existingAccess.planId && commerce.purchaseFields({ kind: "pricingPlan", id: row.id }, pc).appleRoute);
7090
7351
  const entitled = rows.some((row) => row.joined) || existingAccess.generation === memberSession.current().generation && !visibleAppleOwner && existingAccess.entitled;
7091
7352
  const poll = commerce.pollDirective(`${name}.iapPoll`);
7092
7353
  return { ...state, rows, entitled, notEntitled: !entitled, ...poll ? { _poll: poll } : {} };
7093
7354
  }
7094
- const BASE = {
7355
+ const base = () => ({
7095
7356
  status: "loading",
7096
7357
  isLoading: true,
7097
7358
  notLoading: false,
@@ -7100,8 +7361,8 @@ function createCheckoutService(opts = {}) {
7100
7361
  noRows: false,
7101
7362
  emptyCatalog: false,
7102
7363
  notEmptyCatalog: true,
7103
- headline: c.headline ?? "Membership",
7104
- subhead: c.subhead ?? "Choose a plan to unlock everything.",
7364
+ headline: text2("headline", "Membership"),
7365
+ subhead: text2("subhead", "Choose a plan to unlock everything."),
7105
7366
  notice: "",
7106
7367
  noNotice: true,
7107
7368
  error: "",
@@ -7110,15 +7371,15 @@ function createCheckoutService(opts = {}) {
7110
7371
  notEntitled: true,
7111
7372
  needsSignIn: false,
7112
7373
  notNeedsSignIn: true
7113
- };
7374
+ });
7114
7375
  const markJoined = (rows, id2) => rows.map(
7115
7376
  (r) => r.id === id2 ? {
7116
7377
  ...r,
7117
7378
  joined: true,
7118
7379
  notJoined: false,
7119
- joinedLabel: c.joinedLabel ?? "Current plan",
7380
+ joinedLabel: text2("joinedLabel", "Current plan"),
7120
7381
  joinDisabled: true,
7121
- cta: c.joinedLabel ?? "Current plan"
7382
+ cta: text2("joinedLabel", "Current plan")
7122
7383
  } : r
7123
7384
  );
7124
7385
  const rowFrom = (p, activePlanId) => {
@@ -7128,23 +7389,23 @@ function createCheckoutService(opts = {}) {
7128
7389
  const joined = withJoined && !!activePlanId && id2 === activePlanId;
7129
7390
  return {
7130
7391
  id: id2,
7131
- name: String(p?.name ?? "Plan"),
7392
+ name: String(p?.name ?? text2("untitledPlan", "Plan")),
7132
7393
  description: String(p?.description ?? ""),
7133
- priceLine: money(p?.pricing),
7134
- periodLine: period(p?.pricing),
7394
+ priceLine: money(p?.pricing, loc()),
7395
+ periodLine: period(p?.pricing, (key, fallback) => text2(key, fallback), loc()),
7135
7396
  perk1: String(perks[0] ?? ""),
7136
7397
  perk2: String(perks[1] ?? ""),
7137
7398
  perk3: String(perks[2] ?? ""),
7138
7399
  noPerk1: !perks[0],
7139
7400
  noPerk2: !perks[1],
7140
7401
  noPerk3: !perks[2],
7141
- badge: featured ? c.badgeLabel ?? "Most popular" : "",
7402
+ badge: featured ? text2("badgeLabel", "Most popular") : "",
7142
7403
  noBadge: !featured,
7143
7404
  hasBadge: featured,
7144
7405
  joined,
7145
7406
  notJoined: !joined,
7146
- joinedLabel: joined ? c.joinedLabel ?? "Current plan" : "",
7147
- cta: joined ? c.joinedLabel ?? "Current plan" : c.joinCta ?? "Join",
7407
+ joinedLabel: joined ? text2("joinedLabel", "Current plan") : "",
7408
+ cta: joined ? text2("joinedLabel", "Current plan") : text2("joinCta", "Join"),
7148
7409
  appleSupported: isAppleSellablePlan(p?.pricing),
7149
7410
  applePeriod: applePlanPeriod(p?.pricing),
7150
7411
  joinDisabled: false,
@@ -7152,7 +7413,7 @@ function createCheckoutService(opts = {}) {
7152
7413
  };
7153
7414
  };
7154
7415
  const svc = defineService(name, {
7155
- state: { ...BASE, rows: [] },
7416
+ state: { ...base(), rows: [] },
7156
7417
  notHydrated: ["rows", "entitled", "notEntitled", "notice", "needsSignIn"],
7157
7418
  actions: {
7158
7419
  pricingPublish: project,
@@ -7190,7 +7451,7 @@ function createCheckoutService(opts = {}) {
7190
7451
  existingAccess = { entitled, planId: activePlanId, generation };
7191
7452
  regularAccess = new Set(rows.filter((row) => row.joined).map((row) => row.id));
7192
7453
  return project({
7193
- ...BASE,
7454
+ ...base(),
7194
7455
  status: "ready",
7195
7456
  isLoading: false,
7196
7457
  notLoading: true,
@@ -7207,11 +7468,11 @@ function createCheckoutService(opts = {}) {
7207
7468
  } catch {
7208
7469
  if (seq !== loading || generation !== memberSession.current().generation) return void 0;
7209
7470
  return {
7210
- ...BASE,
7471
+ ...base(),
7211
7472
  status: "error",
7212
7473
  isLoading: false,
7213
7474
  notLoading: true,
7214
- error: c.loadError ?? "Plans could not be loaded. Pull to retry.",
7475
+ error: text2("loadError", "Plans could not be loaded. Pull to retry."),
7215
7476
  noError: false
7216
7477
  };
7217
7478
  }
@@ -7223,7 +7484,7 @@ function createCheckoutService(opts = {}) {
7223
7484
  if (!id2 || !row) {
7224
7485
  return {
7225
7486
  ...s2,
7226
- notice: c.goneNotice ?? "That plan is no longer available.",
7487
+ notice: text2("goneNotice", "That plan is no longer available."),
7227
7488
  noNotice: false,
7228
7489
  needsSignIn: false,
7229
7490
  notNeedsSignIn: true
@@ -7232,7 +7493,7 @@ function createCheckoutService(opts = {}) {
7232
7493
  if (row.joined) {
7233
7494
  return {
7234
7495
  ...s2,
7235
- notice: c.joinedNotice ?? `You're already on ${row.name}.`,
7496
+ notice: fmt("alreadyJoinedNotice", "You're already on {name}.", { name: row.name }),
7236
7497
  noNotice: false,
7237
7498
  needsSignIn: false,
7238
7499
  notNeedsSignIn: true
@@ -7240,7 +7501,7 @@ function createCheckoutService(opts = {}) {
7240
7501
  }
7241
7502
  const generation = memberSession.current().generation;
7242
7503
  const reference = { kind: "pricingPlan", id: id2 };
7243
- const purchase = commerce.purchaseFields(reference, purchaseCopy);
7504
+ const purchase = commerce.purchaseFields(reference, purchaseCopy());
7244
7505
  if (purchase.appleRoute) {
7245
7506
  if (!appleOffered(row, commerce.pricing.view(reference))) return project(s2);
7246
7507
  await commerce.buy({ reference });
@@ -7260,7 +7521,7 @@ function createCheckoutService(opts = {}) {
7260
7521
  return {
7261
7522
  ...s2,
7262
7523
  rows: markJoined(s2.rows, id2),
7263
- notice: c.joinedNotice ?? `You've joined ${row.name}.`,
7524
+ notice: fmt("joinedNotice", "You've joined {name}.", { name: row.name }),
7264
7525
  noNotice: false,
7265
7526
  entitled: true,
7266
7527
  notEntitled: false,
@@ -7272,7 +7533,7 @@ function createCheckoutService(opts = {}) {
7272
7533
  const who = await authState().catch(() => ({ signedIn: false }));
7273
7534
  return {
7274
7535
  ...s2,
7275
- notice: who.signedIn ? c.failedNotice ?? "We could not start that purchase. Please try again." : c.signInFirst ?? "Sign in to join a plan \u2014 memberships belong to a member account.",
7536
+ notice: who.signedIn ? text2("failedNotice", "We could not start that purchase. Please try again.") : text2("signInFirst", SIGN_IN_FIRST),
7276
7537
  noNotice: false,
7277
7538
  // The one branch where a sign-in screen is the right destination.
7278
7539
  needsSignIn: !who.signedIn,
@@ -7305,7 +7566,7 @@ function createCheckoutService(opts = {}) {
7305
7566
  // Settled ⇒ the row is theirs. PENDING is not access yet, so its row
7306
7567
  // stays joinable and the gate stays shut until the payment clears.
7307
7568
  rows: granted ? markJoined(s2.rows, id2) : s2.rows,
7308
- notice: !granted ? c.pendingNotice ?? "Payment accepted and clearing. Access opens once it settles." : c.joinedNotice ?? `You've joined ${row.name}.`,
7569
+ notice: !granted ? text2("pendingNotice", "Payment accepted and clearing. Access opens once it settles.") : fmt("joinedNotice", "You've joined {name}.", { name: row.name }),
7309
7570
  noNotice: false,
7310
7571
  entitled: granted,
7311
7572
  notEntitled: !granted,
@@ -7316,7 +7577,7 @@ function createCheckoutService(opts = {}) {
7316
7577
  if (outcome.kind === "handoff") {
7317
7578
  return {
7318
7579
  ...s2,
7319
- notice: c.handoffNotice ?? "Complete the payment in the checkout, then return here.",
7580
+ notice: text2("handoffNotice", "Complete the payment in the checkout, then return here."),
7320
7581
  noNotice: false,
7321
7582
  needsSignIn: false,
7322
7583
  notNeedsSignIn: true
@@ -7325,7 +7586,7 @@ function createCheckoutService(opts = {}) {
7325
7586
  if (outcome.kind === "cancelled") {
7326
7587
  return {
7327
7588
  ...s2,
7328
- notice: c.cancelledNotice ?? "Payment cancelled. Nothing was charged.",
7589
+ notice: text2("cancelledNotice", "Payment cancelled. Nothing was charged."),
7329
7590
  noNotice: false,
7330
7591
  needsSignIn: false,
7331
7592
  notNeedsSignIn: true
@@ -7333,7 +7594,7 @@ function createCheckoutService(opts = {}) {
7333
7594
  }
7334
7595
  return {
7335
7596
  ...s2,
7336
- notice: c.failedNotice ?? "Checkout could not start. Please try again.",
7597
+ notice: text2("failedNotice", "Checkout could not start. Please try again."),
7337
7598
  noNotice: false,
7338
7599
  needsSignIn: false,
7339
7600
  notNeedsSignIn: true
@@ -7341,7 +7602,7 @@ function createCheckoutService(opts = {}) {
7341
7602
  }
7342
7603
  }
7343
7604
  });
7344
- if (globalThis.himalaya?.hydrationOptOut !== true) Object.assign(svc.getState(), BASE);
7605
+ if (globalThis.himalaya?.hydrationOptOut !== true) Object.assign(svc.getState(), base());
7345
7606
  memberSession.subscribe(() => {
7346
7607
  offerGeneration = -1;
7347
7608
  existingAccess = { entitled: false, planId: "", generation: -1 };
@@ -7356,6 +7617,12 @@ function checkoutScreen(opts) {
7356
7617
  const s2 = opts.service ?? "plans";
7357
7618
  const screenId = opts.screenId ?? "plans";
7358
7619
  const c = opts.copy ?? {};
7620
+ const label = (field, fallback) => {
7621
+ const base = c[field] ?? fallback;
7622
+ const key = `checkout.${field}`;
7623
+ const v = opts.text?.(key, base);
7624
+ return typeof v === "string" && v !== "" && v !== key ? v : base;
7625
+ };
7359
7626
  const row = vstack(
7360
7627
  `${s2}.row`,
7361
7628
  [
@@ -7387,14 +7654,14 @@ function checkoutScreen(opts) {
7387
7654
  const children = [
7388
7655
  text(`${s2}.headline`, `$service:${s2}.headline`, "title1"),
7389
7656
  text(`${s2}.subhead`, `$service:${s2}.subhead`),
7390
- hideWhen(text(`${s2}.loading`, c.loadingText ?? "Loading plans\u2026"), `$service:${s2}.notLoading`),
7657
+ hideWhen(text(`${s2}.loading`, label("loadingText", "Loading plans\u2026")), `$service:${s2}.notLoading`),
7391
7658
  // A site with no plans is a real state, not an impossible one, and hiding the
7392
7659
  // list alone leaves a headline over blank space. Bound to a flag the SERVICE
7393
7660
  // computes: `hiddenPath` is a single path, so nesting two hideWhen calls to
7394
7661
  // mean "ready AND empty" just overwrites the inner one and shows this line
7395
7662
  // during the first load.
7396
7663
  hideWhen(
7397
- text(`${s2}.empty`, c.emptyText ?? "No plans are available right now."),
7664
+ text(`${s2}.empty`, label("emptyText", "No plans are available right now.")),
7398
7665
  `$service:${s2}.notEmptyCatalog`
7399
7666
  ),
7400
7667
  hideWhen(text(`${s2}.error`, `$service:${s2}.error`), `$service:${s2}.noError`),
@@ -7404,7 +7671,7 @@ function checkoutScreen(opts) {
7404
7671
  if (opts.signInScreenId) {
7405
7672
  children.push(
7406
7673
  hideWhen(
7407
- button(`${s2}.signin`, "Sign in to continue", openScreen(opts.signInScreenId), "secondary"),
7674
+ button(`${s2}.signin`, label("signInCta", "Sign in to continue"), openScreen(opts.signInScreenId), "secondary"),
7408
7675
  `$service:${s2}.notNeedsSignIn`
7409
7676
  )
7410
7677
  );
@@ -7415,11 +7682,11 @@ function checkoutScreen(opts) {
7415
7682
  `$service:${s2}.noRows`
7416
7683
  )
7417
7684
  );
7418
- return envelope(screenId, opts.title ?? "Membership", vstack(`${s2}.root`, children, 16), {
7685
+ return envelope(screenId, opts.title ?? label("screenTitle", "Membership"), vstack(`${s2}.root`, children, 16), {
7419
7686
  url: opts.bundleUrl,
7420
7687
  // wix_api reads the plans; the other two ARE the payment rail (in-app cashier,
7421
7688
  // then the hosted checkout). A paywall without them renders and cannot charge.
7422
- caps: ["wix_api", "wix_cashier", "open_url", "iap", "app_info"]
7689
+ caps: [.../* @__PURE__ */ new Set(["wix_api", "wix_cashier", "open_url", "iap", "app_info", ...opts.capabilities ?? []])]
7423
7690
  });
7424
7691
  }
7425
7692
  export {