@monetize.software/sdk-extension 3.0.0-alpha.24 → 3.0.0-alpha.25

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/content.js CHANGED
@@ -1,4 +1,4 @@
1
- import { P as L, B as qe, E as Ne, c as Fe, A as de, w as $e, a as Q, r as Ve, b as He } from "./chunks/chrome-port-bfTUUDz_.js";
1
+ import { P as L, B as qe, E as Ne, c as Fe, A as de, w as Ve, a as Q, r as $e, b as He } from "./chunks/chrome-port-bfTUUDz_.js";
2
2
  import { render as ee, h as he, createContext as Ge } from "preact";
3
3
  import { jsx as o, jsxs as u, Fragment as le } from "preact/jsx-runtime";
4
4
  import { useState as k, useEffect as P, useContext as We, useRef as j, useMemo as Ze, useLayoutEffect as Ye } from "preact/hooks";
@@ -15,7 +15,7 @@ function Ce(r, e) {
15
15
  (i) => i.price_id == null && (i.discount_percent ?? 0) > 0
16
16
  ) ?? null);
17
17
  }
18
- function V(r, e, t = {}) {
18
+ function $(r, e, t = {}) {
19
19
  const n = Ce(r, e);
20
20
  return n && Ie(n, t) ? n : null;
21
21
  }
@@ -1548,8 +1548,8 @@ function Ft({ block: r }) {
1548
1548
  ] })
1549
1549
  ] }, e.id)) }) : null;
1550
1550
  }
1551
- function $t({ block: r }) {
1552
- const { t: e } = S(), t = r.title ?? e("pricing.money_back", "30-day money-back guarantee"), n = r.subtitle, i = (r.icon ?? "dollar_shield") !== "none", s = Vt(t);
1551
+ function Vt({ block: r }) {
1552
+ const { t: e } = S(), t = r.title ?? e("pricing.money_back", "30-day money-back guarantee"), n = r.subtitle, i = (r.icon ?? "dollar_shield") !== "none", s = $t(t);
1553
1553
  return /* @__PURE__ */ u("div", { class: "flex flex-col items-center gap-1.5 border-b-1 pb-4 mb-1 border-gray-100", children: [
1554
1554
  /* @__PURE__ */ u("div", { class: "inline-flex items-center gap-2 text-[12px] text-gray-700", children: [
1555
1555
  i ? /* @__PURE__ */ o(Ht, {}) : null,
@@ -1562,7 +1562,7 @@ function $t({ block: r }) {
1562
1562
  n ? /* @__PURE__ */ o("span", { class: "text-center text-xs leading-relaxed text-gray-500", children: n }) : null
1563
1563
  ] });
1564
1564
  }
1565
- function Vt(r) {
1565
+ function $t(r) {
1566
1566
  const e = r.match(/^(\d+[-\s]?days?)\s+(.+)$/i);
1567
1567
  return e ? { bold: e[1], rest: e[2] } : null;
1568
1568
  }
@@ -1693,7 +1693,7 @@ function Xt({ block: r, ctx: e }) {
1693
1693
  isLast: l === i.length - 1,
1694
1694
  isPopular: r.popular_price_id === a.id,
1695
1695
  popularLabel: s,
1696
- offer: V(e.bootstrap.offers, a.id, { readStart: N }),
1696
+ offer: $(e.bootstrap.offers, a.id, { readStart: N }),
1697
1697
  selected: e.selectedPriceId === a.id,
1698
1698
  onSelect: () => {
1699
1699
  e.setSelectedPriceId(a.id), e.onAction("price_selected", { priceId: a.id, price: a });
@@ -1706,7 +1706,7 @@ function Xt({ block: r, ctx: e }) {
1706
1706
  );
1707
1707
  if (r.view === "horizontal") {
1708
1708
  const a = Math.min(i.length, 3), l = i.some(
1709
- (c) => (V(e.bootstrap.offers, c.id, { readStart: N })?.discount_percent ?? 0) > 0
1709
+ (c) => ($(e.bootstrap.offers, c.id, { readStart: N })?.discount_percent ?? 0) > 0
1710
1710
  );
1711
1711
  return /* @__PURE__ */ o(
1712
1712
  "div",
@@ -1721,7 +1721,7 @@ function Xt({ block: r, ctx: e }) {
1721
1721
  price: c,
1722
1722
  isPopular: r.popular_price_id === c.id,
1723
1723
  popularLabel: s,
1724
- offer: V(e.bootstrap.offers, c.id, { readStart: N }),
1724
+ offer: $(e.bootstrap.offers, c.id, { readStart: N }),
1725
1725
  reserveStrikeRow: l,
1726
1726
  selected: e.selectedPriceId === c.id,
1727
1727
  onSelect: () => {
@@ -1741,7 +1741,7 @@ function Xt({ block: r, ctx: e }) {
1741
1741
  role: "radiogroup",
1742
1742
  "aria-label": t("pricing.plans_aria", "Plans"),
1743
1743
  children: i.map((a) => {
1744
- const l = e.selectedPriceId === a.id, c = r.popular_price_id === a.id, d = V(e.bootstrap.offers, a.id, { readStart: N })?.discount_percent ?? null, { currency: g, amount: _, originalAmount: p } = ce(a, d);
1744
+ const l = e.selectedPriceId === a.id, c = r.popular_price_id === a.id, d = $(e.bootstrap.offers, a.id, { readStart: N })?.discount_percent ?? null, { currency: g, amount: _, originalAmount: p } = ce(a, d);
1745
1745
  return /* @__PURE__ */ u(
1746
1746
  "button",
1747
1747
  {
@@ -2065,7 +2065,7 @@ const or = {
2065
2065
  current_session: Nt,
2066
2066
  features_list: Ft,
2067
2067
  tokenization_gate: ir,
2068
- guarantee_badge: $t,
2068
+ guarantee_badge: Vt,
2069
2069
  offer_banner: Lt
2070
2070
  };
2071
2071
  function sr({ layout: r, bootstrap: e, onAction: t, auth: n, authSession: i, hasTopBanner: s }) {
@@ -2194,16 +2194,16 @@ function cr({
2194
2194
  }, [e, i, a, l]);
2195
2195
  const M = async (x) => {
2196
2196
  try {
2197
- const f = r.getCachedOffers?.() ?? null, w = f ? V(f, x, { readStart: N }) : null, B = await r.createCheckout({
2197
+ const f = r.getCachedOffers?.() ?? null, w = f ? $(f, x, { readStart: N }) : null, B = await r.createCheckout({
2198
2198
  priceId: x,
2199
2199
  offerId: w?.id,
2200
2200
  ignoreActivePurchase: h === !0
2201
2201
  });
2202
2202
  if (n("checkout_started", { priceId: x, url: B.url, acquiring: B.acquiring }), typeof window > "u" || !B.url) return;
2203
- const $ = window.open(B.url, "_blank");
2204
- if ($) {
2203
+ const V = window.open(B.url, "_blank");
2204
+ if (V) {
2205
2205
  try {
2206
- $.opener = null;
2206
+ V.opener = null;
2207
2207
  } catch {
2208
2208
  }
2209
2209
  y({ kind: "awaiting_payment", priceId: x, url: B.url });
@@ -2284,7 +2284,7 @@ function cr({
2284
2284
  n("error", new L("no_price", "No price selected"));
2285
2285
  return;
2286
2286
  }
2287
- const B = p.data.settings.checkout_mode ?? "guest", $ = r.auth?.getCachedSession() ?? null, ze = !!$ && !$.user.is_anonymous;
2287
+ const B = p.data.settings.checkout_mode ?? "guest", V = r.auth?.getCachedSession() ?? null, ze = !!V && !V.user.is_anonymous;
2288
2288
  if (B === "preauth" && !!r.auth && !ze) {
2289
2289
  y({ kind: "auth_gate", pendingCheckout: { priceId: w } });
2290
2290
  return;
@@ -2557,15 +2557,14 @@ function _e({
2557
2557
  restored: e = !1
2558
2558
  }) {
2559
2559
  const { t } = S();
2560
- return /* @__PURE__ */ u("div", { class: "flex flex-col items-center gap-3 py-8 text-center", children: [
2560
+ return /* @__PURE__ */ u("div", { class: "flex flex-col items-center gap-4 py-6 text-center", children: [
2561
2561
  /* @__PURE__ */ o(
2562
2562
  "div",
2563
2563
  {
2564
- class: "flex h-14 w-14 items-center justify-center rounded-full ring-8",
2564
+ class: "flex h-14 w-14 items-center justify-center rounded-full",
2565
2565
  style: {
2566
2566
  background: "linear-gradient(135deg, #4ade80, #16a34a)",
2567
2567
  color: "#fff",
2568
- // emerald ring with low alpha for a halo effect
2569
2568
  boxShadow: "0 0 0 8px rgba(74,222,128,0.12), 0 8px 20px -6px rgba(22,163,74,0.45)"
2570
2569
  },
2571
2570
  "aria-hidden": "true",
@@ -2581,8 +2580,8 @@ function _e({
2581
2580
  ) })
2582
2581
  }
2583
2582
  ),
2584
- /* @__PURE__ */ o("p", { id: "pw-title", class: "mt-1 text-lg font-semibold tracking-tight text-gray-900", children: e ? t("modal.purchase_restored_title", "Subscription restored") : t("modal.purchase_success_title", "Payment received") }),
2585
- /* @__PURE__ */ o("p", { class: "text-sm leading-relaxed text-gray-500", children: e ? t(
2583
+ /* @__PURE__ */ o("p", { id: "pw-title", class: "mt-1 text-3xl font-bold tracking-tight text-gray-900", children: e ? t("modal.purchase_restored_title", "Subscription restored") : t("modal.purchase_success_title", "Payment received") }),
2584
+ /* @__PURE__ */ o("p", { class: "text-base leading-relaxed text-gray-600", children: e ? t(
2586
2585
  "modal.purchase_restored_subtitle",
2587
2586
  "Welcome back — your subscription is already active."
2588
2587
  ) : t("modal.purchase_success_subtitle", "Your subscription is now active.") }),
@@ -2591,12 +2590,12 @@ function _e({
2591
2590
  {
2592
2591
  type: "button",
2593
2592
  onClick: r,
2594
- class: "mt-3 rounded-xl px-5 py-2.5 text-sm font-semibold text-white transition-all hover:-translate-y-px hover:brightness-105 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-[var(--pw-accent)]",
2593
+ class: "pw-cta-shimmer relative mt-2 flex min-h-12 w-full items-center justify-center overflow-hidden rounded-3xl px-5 py-2 text-center text-base font-semibold leading-tight text-white transition-transform duration-150 active:scale-[0.98] focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-[var(--pw-accent)]",
2595
2594
  style: {
2596
- background: "linear-gradient(180deg, color-mix(in srgb, var(--pw-accent) 92%, white), var(--pw-accent))",
2597
- boxShadow: "0 1px 2px rgba(15,23,42,0.08), 0 8px 20px -6px color-mix(in srgb, var(--pw-accent) 50%, transparent)"
2595
+ background: "linear-gradient(135deg, color-mix(in srgb, var(--pw-accent) 55%, white) 0%, var(--pw-accent) 55%, color-mix(in srgb, var(--pw-accent) 90%, black) 100%)",
2596
+ boxShadow: "0 0 20px 0 color-mix(in srgb, var(--pw-accent) 25%, transparent), inset 0 0 8px 0 color-mix(in srgb, white 25%, transparent)"
2598
2597
  },
2599
- children: t("modal.continue", "Continue")
2598
+ children: /* @__PURE__ */ o("span", { class: "relative z-10", children: t("modal.continue", "Continue") })
2600
2599
  }
2601
2600
  )
2602
2601
  ] });
@@ -2665,7 +2664,7 @@ const ae = {
2665
2664
  };
2666
2665
  let xr = class {
2667
2666
  constructor(e) {
2668
- this.handle = null, this.isOpen = !1, this.listeners = /* @__PURE__ */ new Map(), this.userUnsub = null, this.authUnsub = null, this.watcher = null, this.tracker = null, this.purchased = !1, this.trialStore = null, this.trialStoreConfig = null, this.lastTrialStatus = null, this.trialExpiredFired = !1, this.lastVisibility = null, this.currentState = ae, this.stateListeners = /* @__PURE__ */ new Set();
2667
+ this.handle = null, this.isOpen = !1, this.listeners = /* @__PURE__ */ new Map(), this.userUnsub = null, this.authUnsub = null, this.watcher = null, this.tracker = null, this.purchased = !1, this.lastMountedView = null, this.trialStore = null, this.trialStoreConfig = null, this.lastTrialStatus = null, this.trialExpiredFired = !1, this.lastVisibility = null, this.currentState = ae, this.stateListeners = /* @__PURE__ */ new Set();
2669
2668
  const { auth: t, ownsAuth: n } = wr(e);
2670
2669
  this.auth = t, this.ownsAuth = n, this.billing = e.client ?? new qe({ ...e, auth: this.auth }), this.host = e.host, this.shadowMode = e.shadowMode ?? "closed", this.mountThenLoad = e.mountThenLoad ?? !0, this.inline = e.inline === !0, this.forceLocale = e.locale ?? null, this.userUnsub = this.billing.onUserChange((i) => {
2671
2670
  this.emit("userChange", i);
@@ -2689,14 +2688,15 @@ let xr = class {
2689
2688
  maxBufferSize: t.maxBufferSize,
2690
2689
  fetch: t.fetch,
2691
2690
  sendBeacon: t.sendBeacon
2692
- }), this.on("open", () => this.tracker?.track("paywall_opened")), this.on(
2693
- "ready",
2694
- (i) => this.tracker?.track("paywall_viewed", {
2691
+ }), this.on("open", () => {
2692
+ this.lastMountedView === "layout" && this.tracker?.track("paywall_opened");
2693
+ }), this.on("ready", (i) => {
2694
+ this.lastMountedView === "layout" && this.tracker?.track("paywall_viewed", {
2695
2695
  is_test_mode: i.settings.is_test_mode,
2696
2696
  prices_count: i.prices.length,
2697
2697
  offers_count: i.offers.length
2698
- })
2699
- ), this.on(
2698
+ });
2699
+ }), this.on(
2700
2700
  "price_selected",
2701
2701
  (i) => this.tracker?.track("price_selected", { price_id: i.priceId })
2702
2702
  ), this.on(
@@ -2714,7 +2714,9 @@ let xr = class {
2714
2714
  ), this.on(
2715
2715
  "purchase_failed",
2716
2716
  (i) => this.tracker?.track("purchase_failed", { reason: i.reason })
2717
- ), this.on("close", () => this.tracker?.track("paywall_closed")), this.on(
2717
+ ), this.on("close", () => {
2718
+ this.lastMountedView === "layout" && this.tracker?.track("paywall_closed");
2719
+ }), this.on(
2718
2720
  "trial_blocked",
2719
2721
  (i) => this.tracker?.track("trial_blocked", {
2720
2722
  mode: i.mode,
@@ -3167,6 +3169,7 @@ let xr = class {
3167
3169
  return this.trialStore = typeof t == "function" ? t.call(this.billing, e) : Fe(this.billing.getStorage(), this.billing.paywallId, e), this.trialStore;
3168
3170
  }
3169
3171
  mountAndShow(e, t = {}) {
3172
+ this.lastMountedView = e;
3170
3173
  const n = t.renew === !0, i = t.authMode, a = e === "auth" || e === "awaiting_payment" || e === "popup_blocked" ? t.checkoutPriceId ?? null : null, l = e === "awaiting_payment" || e === "popup_blocked" ? t.checkoutUrl ?? null : null;
3171
3174
  if (this.handle) {
3172
3175
  this.isOpen = !0, this.handle.update({
@@ -3900,7 +3903,7 @@ class Er {
3900
3903
  userMeta: e.userMeta
3901
3904
  });
3902
3905
  n.name = `pw-oauth-${s}`, n.location.replace(i), e.onPopupOpened?.();
3903
- const a = await $e(n, s), l = await this.transport.request("auth.oauthExchange", { state: s, code: a });
3906
+ const a = await Ve(n, s), l = await this.transport.request("auth.oauthExchange", { state: s, code: a });
3904
3907
  return this.applySession("SIGNED_IN", l), l;
3905
3908
  } catch (i) {
3906
3909
  try {
@@ -3990,7 +3993,7 @@ class Ur {
3990
3993
  if (e.type === "response") {
3991
3994
  const t = this.pending.get(e.id);
3992
3995
  if (!t) return;
3993
- this.pending.delete(e.id), t.signal?.removeEventListener("abort", t.abortListener), e.ok ? t.resolve(e.result) : t.reject(Ve(e.error));
3996
+ this.pending.delete(e.id), t.signal?.removeEventListener("abort", t.abortListener), e.ok ? t.resolve(e.result) : t.reject($e(e.error));
3994
3997
  return;
3995
3998
  }
3996
3999
  if (e.type === "event") {