@disconetwork/shopify 0.0.8 → 0.0.10
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/{DiscoPrepurchaseThankYou-0LqiJGuU.js → DiscoPrepurchaseThankYou-Cu3yyFVs.js} +43 -29
- package/dist/DiscoPrepurchaseThankYou-Cu3yyFVs.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/internal.js +1 -1
- package/package.json +3 -3
- package/dist/DiscoPrepurchaseThankYou-0LqiJGuU.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DiscoPrepurchaseThankYou-Cu3yyFVs.js","names":["createContext","useContext","useState","useMemo","useCallback","createContext","useContext","useMemo","createElement","useState","useEventTracker","getShopIdentifier","packageJson.name","packageJson.version","useMemo","DiscoClientContext$1","useCheckoutPurchasingCompany","useCheckoutTotalAmount","useCheckoutCartLines","useCheckoutDiscountCodes","useCheckoutShop","useCheckoutApi","useCheckoutSubscription","useCustomerAccountPurchasingCompany","useCustomerAccountTotalAmount","useCustomerAccountCartLines","useCustomerAccountDiscountCodes","useCustomerAccountShop","useCustomerAccountApi","useCustomerAccountSubscription","useEventTracker","useEventTracker","useEventTracker","useEventTracker","useEventTracker","useEventTracker","getShopIdentifier","useEventTracker","LeadGenRecommendationsWidget","useMemo","resolveWidget","email","emailSchema","email","emailSchema"],"sources":["../../react-shared/dist/createHeadlessBindings-CPuF5wZQ.js","../../react-shared/dist/bindings-D-XXI0bV.js","../../react-shared/dist/headless-C9iZrlrk.js","../src/managers/RecommendationsTrackingManager/index.tsx","../src/hooks/usePayload.tsx","../src/utils/dataManagerUtils.ts","../src/components/CardContainer.tsx","../src/components/RecommendationsWidget/RecommendationsWidgetSkeleton.tsx","../package.json","../src/sdkIdentity.ts","../../react-shared/dist/sdk-internals.js","../src/managers/DataManager.tsx","../src/utils/address.ts","../src/managers/PayloadManager.tsx","../src/managers/UserManager.tsx","../src/managers/index.ts","../src/hooks/useRecommendationsData.tsx","../src/hooks/useCounter.tsx","../src/components/RecommendationsWidget/HeroOfferProvider.tsx","../src/components/RecommendationsWidget/ScrollableSlotProvider.tsx","../src/hooks/useIdentity.tsx","../src/hooks/useCustomization.ts","../src/hooks/useRecommendationsCustomization.tsx","../src/components/RecommendationsWidget/useFirstOfferHeading.ts","../src/conf/env_conf.ts","../src/utils/getImgUrl.ts","../src/hooks/useDiscoEnv.ts","../src/components/Essential/generation/LinkGenerator.tsx","../src/components/Essential/generation/ParagraphGenerator.tsx","../src/components/Essential/generation/ScrollViewGenerator.tsx","../src/components/Essential/generation/TextGenerator.tsx","../src/components/Essential/EssentialOfferContent.tsx","../src/components/RecommendationsWidget/Essential/EssentialLayoutType.tsx","../src/components/RecommendationsWidget/DotIndicators.tsx","../src/conf/index.ts","../src/components/PrivacyLink.tsx","../src/components/RecommendationsWidget/Footer.tsx","../src/components/RecommendationsWidget/Cover/index.tsx","../src/components/DiscoFeed/DiscoFeedProduct.tsx","../src/components/RecommendationsWidget/RecommendationsOfferRow.tsx","../src/components/RecommendationsWidget/Essential/index.tsx","../src/components/RecommendationsWidget/LeadGen/LeadGenHeader.tsx","../src/components/RecommendationsWidget/LeadGen/LeadGenBrand.tsx","../src/hooks/useResource.tsx","../src/hooks/useSendOfferEmail.ts","../src/components/RecommendationsWidget/LeadGen/LeadGenActionButton.tsx","../src/components/RecommendationsWidget/LeadGen/LeadGenOfferRow.tsx","../src/components/RecommendationsWidget/LeadGen/index.tsx","../src/components/RecommendationsWidget/index.tsx","../src/DiscoRecommendations.tsx","../src/prepurchase/conf.ts","../src/prepurchase/context.ts","../src/prepurchase/PrepurchaseProvider.tsx","../src/prepurchase/tracking/tracking-manager.tsx","../../../node_modules/.pnpm/@portabletext+toolkit@5.0.2/node_modules/@portabletext/toolkit/dist/index.js","../../../node_modules/.pnpm/@portabletext+react@6.2.0_@preact+compat@18.3.2_preact@10.29.8_/node_modules/@portabletext/react/dist/index.js","../src/prepurchase/portable-text-renderer.tsx","../src/prepurchase/attribute.ts","../src/prepurchase/hooks/usePrepurchaseOptIn.ts","../src/prepurchase/components/checkout/shared.tsx","../src/prepurchase/components/checkout/inline-checkbox.tsx","../src/prepurchase/components/checkout/inline-checkbox-with-logo.tsx","../src/prepurchase/components/checkout/inline-checkbox-logo-card.tsx","../src/prepurchase/components/checkout/inline-checkbox-confirmation.tsx","../src/prepurchase/components/checkout/inline-button-confirmation.tsx","../src/prepurchase/components/checkout/inline-radio-confirmation.tsx","../src/prepurchase/components/checkout/inline-checkbox-confirmation-undo.tsx","../src/prepurchase/components/checkout/inline-button-confirmation-decline.tsx","../src/prepurchase/components/checkout/inline-radio-confirmation-undo.tsx","../src/prepurchase/components/checkout/inline-radio.tsx","../src/prepurchase/components/checkout/inline-radio-with-large-logo.tsx","../src/prepurchase/components/checkout/cash-back-tiers.ts","../src/prepurchase/components/checkout/tier-progress.tsx","../src/prepurchase/components/checkout/inline-radio-with-tier-progress.tsx","../src/prepurchase/components/checkout/inline-radio-with-tier-progress-with-large-logo.tsx","../src/prepurchase/quick-add-cart.ts","../src/prepurchase/hooks/useAddCartProduct.ts","../src/prepurchase/quick-add-products.ts","../src/prepurchase/hooks/useQuickAddProducts.ts","../src/prepurchase/components/checkout/quick-add-products.tsx","../src/prepurchase/components/checkout/inline-radio-with-tier-progress-and-quick-add.tsx","../src/prepurchase/components/checkout/inline-radio-with-tier-progress-and-quick-add-with-large-logo.tsx","../src/prepurchase/components/prepurchase-widget.tsx","../src/prepurchase/utils.ts","../src/prepurchase/hooks/useGetIncentive.ts","../src/prepurchase/DiscoPrepurchaseIncentive.tsx","../src/prepurchase/hooks/useSubmitOrder.ts","../src/prepurchase/hooks/useCreateOrderIntent.ts","../src/prepurchase/components/thank-you/check-icons.tsx","../src/prepurchase/components/thank-you/cash-back-cost.tsx","../src/prepurchase/components/thank-you/countdown.ts","../src/prepurchase/components/thank-you/countdown-10-minute.tsx","../src/prepurchase/components/thank-you/earned-progress.tsx","../src/prepurchase/components/thank-you/order-earned.tsx","../src/prepurchase/components/thank-you/social-proof.tsx","../src/prepurchase/components/thank-you-widget.tsx","../src/prepurchase/DiscoPrepurchaseThankYou.tsx"],"sourcesContent":["import { createContext, useCallback, useContext, useEffect, useMemo, useState } from \"react\";\nimport { withImpressionDedupe } from \"@disconetwork/core\";\nimport { jsx } from \"react/jsx-runtime\";\n//#region src/factory/createHeadlessBindings.tsx\n/**\n* Build a self-contained set of headless React bindings for one client type.\n*\n* Returns the client context (for a backing-specific `DiscoProvider` to provide\n* into), the `useDiscoClient` accessor, the `Disco.Root` controller, and the\n* `useDiscoRecommendations` / `useDiscoTracker` / `useFetchRecommendations`\n* hooks — all concretely typed to `TRequest` / `TResponse`. Call this once per\n* backing at module load; the returned components/hooks are stable references.\n*/\nfunction createHeadlessBindings() {\n\t/**\n\t* Holds the client built by the backing's `<DiscoProvider>`. Read it with\n\t* `useDiscoClient` to fetch recommendations or create trackers.\n\t*/\n\tconst DiscoClientContext = createContext(null);\n\t/**\n\t* Read the client configured by the surrounding `<DiscoProvider>`.\n\t*\n\t* Returns the single, stable, provider-configured instance — use this rather\n\t* than constructing a client in a component (which would create a new one each\n\t* render and risk drifting from the provider's auth/env). Throws if used\n\t* outside a provider.\n\t*/\n\tfunction useDiscoClient() {\n\t\tconst client = useContext(DiscoClientContext);\n\t\tif (!client) throw new Error(\"useDiscoClient must be used inside a <DiscoProvider>.\");\n\t\treturn client;\n\t}\n\tconst LOADING = {\n\t\tstatus: \"loading\",\n\t\tdata: void 0,\n\t\terror: void 0\n\t};\n\t/**\n\t* Fetch-on-mount state machine for a recommendations surface.\n\t*\n\t* Owns the request lifecycle — fetch on mount, refetch when the request\n\t* changes or `refetch` is called, abort in-flight requests on unmount/change —\n\t* and derives the session-bound tracker from each response. Renders nothing and\n\t* knows nothing about the `Disco.*` contexts; `<Disco.Root>` adapts its result.\n\t*\n\t* Exported from each backing's `/headless` entry as the shared fetch\n\t* primitive: `<Disco.Root>` builds on it. Reach for it directly only when\n\t* building a custom surface that needs the fetch lifecycle without the\n\t* `Disco.*` contexts.\n\t*/\n\tfunction useFetchRecommendations(request) {\n\t\tconst client = useDiscoClient();\n\t\tconst [state, setState] = useState(LOADING);\n\t\tconst [tracker, setTracker] = useState(null);\n\t\tconst requestKey = useMemo(() => JSON.stringify(request), [request]);\n\t\tconst [reloadCount, setReloadCount] = useState(0);\n\t\tconst refetch = useCallback(() => setReloadCount((n) => n + 1), []);\n\t\tuseEffect(() => {\n\t\t\tconst controller = new AbortController();\n\t\t\tsetState(LOADING);\n\t\t\tsetTracker(null);\n\t\t\tclient.getRecommendationsWithTracker(request, { signal: controller.signal }).then(({ data, tracker }) => {\n\t\t\t\tif (controller.signal.aborted) return;\n\t\t\t\tsetState({\n\t\t\t\t\tstatus: \"success\",\n\t\t\t\t\tdata,\n\t\t\t\t\terror: void 0\n\t\t\t\t});\n\t\t\t\tsetTracker(withImpressionDedupe(tracker));\n\t\t\t}).catch((error) => {\n\t\t\t\tif (controller.signal.aborted) return;\n\t\t\t\tsetState({\n\t\t\t\t\tstatus: \"error\",\n\t\t\t\t\tdata: void 0,\n\t\t\t\t\terror\n\t\t\t\t});\n\t\t\t});\n\t\t\treturn () => controller.abort();\n\t\t}, [\n\t\t\tclient,\n\t\t\trequestKey,\n\t\t\treloadCount\n\t\t]);\n\t\treturn {\n\t\t\tstate,\n\t\t\ttracker,\n\t\t\trefetch\n\t\t};\n\t}\n\tconst DiscoContext = createContext(null);\n\t/**\n\t* Read the recommendations fetch state, the session-bound tracker, and\n\t* `refetch` from the surrounding `<Disco.Root>`. The tracker is non-null only\n\t* once `status === \"success\"`; for consumers that only need the tracker and\n\t* render inside a success branch, {@link useDiscoTracker} returns a non-null\n\t* tracker and throws if used before success. Throws if used outside a\n\t* `<Disco.Root>`.\n\t*/\n\tfunction useDiscoRecommendations() {\n\t\tconst ctx = useContext(DiscoContext);\n\t\tif (!ctx) throw new Error(\"useDiscoRecommendations must be used inside a <Disco.Root>.\");\n\t\treturn ctx;\n\t}\n\t/**\n\t* Read the session-bound {@link EventTracker} for the surrounding\n\t* `<Disco.Root>`.\n\t*\n\t* The tracker exists only once recommendations have loaded (its session comes\n\t* from the response). Render tracking UI inside the `success` branch and this\n\t* hook returns a ready tracker; it throws if used before `success`, surfacing\n\t* misuse loudly rather than silently dropping events. Throws if used outside a\n\t* `<Disco.Root>`.\n\t*/\n\tfunction useDiscoTracker() {\n\t\tconst ctx = useContext(DiscoContext);\n\t\tif (!ctx) throw new Error(\"useDiscoTracker must be used inside a <Disco.Root>.\");\n\t\tif (!ctx.tracker) throw new Error(\"useDiscoTracker is only available after recommendations have loaded — render tracking UI inside the <Disco.Root> success branch.\");\n\t\treturn ctx.tracker;\n\t}\n\t/**\n\t* Headless controller for a Disco recommendations surface — the root of the\n\t* `Disco.*` compound. Fetches via `useFetchRecommendations` and provides the\n\t* fetch state (read with `useDiscoRecommendations`) and the session-bound\n\t* tracker (read with `useDiscoTracker`) to its subtree. Renders no UI of its\n\t* own; aborts in-flight requests on unmount or request change.\n\t*/\n\tfunction DiscoRoot({ request, children }) {\n\t\tconst { state, tracker, refetch } = useFetchRecommendations(request);\n\t\tconst value = useMemo(() => ({\n\t\t\t...state,\n\t\t\ttracker,\n\t\t\trefetch\n\t\t}), [\n\t\t\tstate,\n\t\t\ttracker,\n\t\t\trefetch\n\t\t]);\n\t\treturn /* @__PURE__ */ jsx(DiscoContext.Provider, {\n\t\t\tvalue,\n\t\t\tchildren\n\t\t});\n\t}\n\treturn {\n\t\tDiscoClientContext,\n\t\tuseDiscoClient,\n\t\tuseDiscoRecommendations,\n\t\tuseDiscoTracker,\n\t\tuseFetchRecommendations,\n\t\tDiscoRoot\n\t};\n}\n//#endregion\nexport { createHeadlessBindings as t };\n\n//# sourceMappingURL=createHeadlessBindings-CPuF5wZQ.js.map","import { t as createHeadlessBindings } from \"./createHeadlessBindings-CPuF5wZQ.js\";\n//#region src/internal/bindings.ts\nconst bindings = createHeadlessBindings();\nconst DiscoClientContext = bindings.DiscoClientContext;\nconst useDiscoClient = bindings.useDiscoClient;\nconst DiscoRoot = bindings.DiscoRoot;\nconst useFetchRecommendations = bindings.useFetchRecommendations;\nconst useDiscoRecommendations = bindings.useDiscoRecommendations;\nconst useDiscoTracker = bindings.useDiscoTracker;\n//#endregion\nexport { useDiscoTracker as a, useDiscoRecommendations as i, DiscoRoot as n, useFetchRecommendations as o, useDiscoClient as r, DiscoClientContext as t };\n\n//# sourceMappingURL=bindings-D-XXI0bV.js.map","import { cloneElement, createContext, createElement, isValidElement, useContext, useEffect, useMemo, useState } from \"react\";\nimport { parseScreens } from \"@disconetwork/core/internal\";\n//#region src/internal/screens/RendererContext.ts\nconst RendererContext = createContext(null);\nfunction useRendererContext() {\n\tconst ctx = useContext(RendererContext);\n\tif (!ctx) throw new Error(\"useRendererContext must be used within a ScreensRenderer\");\n\treturn ctx;\n}\n//#endregion\n//#region src/internal/screens/generateNodes.ts\nfunction generateNodes({ nodes, path, renderers }) {\n\treturn nodes.map((node, idx) => {\n\t\tconst generator = renderers[node.type];\n\t\tif (!generator) throw new Error(`No renderer found for node type: \"${node.type}\"`);\n\t\tconst nodePath = `${path}.${node.type}.${idx}`;\n\t\tconst reactNode = generator({\n\t\t\tnode,\n\t\t\tnodesToJSX: (args) => generateNodes({\n\t\t\t\tnodes: args.nodes,\n\t\t\t\tpath: nodePath,\n\t\t\t\trenderers\n\t\t\t})\n\t\t});\n\t\tif (isValidElement(reactNode)) return cloneElement(reactNode, { key: nodePath });\n\t\treturn reactNode;\n\t});\n}\n//#endregion\n//#region src/internal/screens/ScreensRenderer.ts\nfunction ScreensRenderer({ jsonContent, renderers, fallback = null }) {\n\tconst screens = useMemo(() => parseScreens(jsonContent), [jsonContent]);\n\tif (!screens) return fallback;\n\treturn createElement(ScreensNavigator, {\n\t\tscreens,\n\t\trenderers\n\t});\n}\nfunction ScreensNavigator({ screens, renderers }) {\n\tconst [currentScreenId, setCurrentScreenId] = useState(() => screens[0]?.id ?? \"default\");\n\tuseEffect(() => {\n\t\tsetCurrentScreenId(screens[0]?.id ?? \"default\");\n\t}, [screens]);\n\tconst activeScreen = screens.find((screen) => screen.id === currentScreenId) ?? screens[0];\n\tif (!activeScreen) return null;\n\treturn createElement(RendererContext.Provider, { value: {\n\t\tscreens,\n\t\tcurrentScreenId: activeScreen.id,\n\t\tsetCurrentScreenId\n\t} }, generateNodes({\n\t\tnodes: activeScreen.children,\n\t\tpath: activeScreen.id,\n\t\trenderers\n\t}));\n}\n//#endregion\nexport { useRendererContext as n, ScreensRenderer as t };\n\n//# sourceMappingURL=headless-C9iZrlrk.js.map","import { createContext, type ComponentChildren } from \"preact\";\nimport { useContext } from \"preact/hooks\";\nimport type { EventTracker } from \"@disconetwork/react-shared/internal/headless\";\n\nconst RecommendationsTrackingManagerContext =\n createContext<EventTracker | null>(null);\n\nexport function RecommendationsTrackingManager({\n children,\n tracker,\n}: {\n children: ComponentChildren;\n tracker: EventTracker;\n}) {\n return (\n <RecommendationsTrackingManagerContext.Provider value={tracker}>\n {children}\n </RecommendationsTrackingManagerContext.Provider>\n );\n}\n\nexport function useEventTracker() {\n const ctx = useContext(RecommendationsTrackingManagerContext);\n\n if (!ctx) {\n throw new Error(\n \"useEventTracker must be used inside RecommendationsTrackingManager\",\n );\n }\n\n return ctx;\n}\n","import { useContext } from \"preact/hooks\";\nimport { PayloadContext } from \"../managers/index.js\";\nimport { PayloadManagerType } from \"../managers/PayloadManager.js\";\n\nconst usePayload = <T extends PayloadManagerType>() => {\n const data = useContext(PayloadContext) as PayloadManagerType;\n\n if (!data) {\n throw new Error(\"No wrapper Payload context found\");\n }\n\n return data as T;\n};\nexport default usePayload;\n","import { PayloadManagerType } from \"../managers/PayloadManager.js\";\nimport type { RecommendationsRequest } from \"@disconetwork/core/internal\";\n\nexport const getShopIdentifier = (shopGid: string) => {\n return shopGid.replace(\"gid://shopify/Shop/\", \"\");\n};\n\nexport const shopifyOrderIdFormatter = (inp?: string | null) =>\n typeof inp === \"string\" ? inp.replace(\"gid://shopify/Order/\", \"\") : inp;\n\nexport const getRecommendationsRequest = ({\n payload,\n widgetId,\n}: {\n payload: PayloadManagerType;\n widgetId?: string;\n}): RecommendationsRequest => {\n return {\n user: {\n email: payload.buyerEmail,\n firstName: payload.extrapolatedFirstName,\n lastName: payload.customerLastName,\n phone: payload.extrapolatedPhone,\n },\n placement: {\n displayMode: \"INLINE\",\n view: payload.target,\n widgetId,\n },\n order: {\n amount: payload.totalCost,\n currencyCode: payload.currencyCode,\n id: shopifyOrderIdFormatter(payload.orderId) ?? undefined,\n },\n shipping: payload.shippingAddress,\n billing: payload.billingAddress,\n purchases: payload.cartLines.map((cartLine) => {\n return {\n name: cartLine.merchandise.title,\n type: cartLine.merchandise.product.productType,\n variant: cartLine.merchandise.subtitle,\n quantity: cartLine.quantity,\n amount: cartLine.cost.totalAmount.amount,\n currencyCode: cartLine.cost.totalAmount.currencyCode,\n productId: cartLine.merchandise.product.id.replace(\n \"gid://shopify/Product/\",\n \"\",\n ),\n };\n }),\n };\n};\n","import type { ComponentProps } from \"preact\";\n\ntype Props = ComponentProps<\"s-box\">;\n\nconst CardContainer = ({ children, ...rest }: Props) => {\n return (\n <s-box\n border={\"base\"}\n borderWidth={\"base\"}\n borderRadius={\"large\"}\n {...rest}\n >\n {children}\n </s-box>\n );\n};\n\nexport default CardContainer;\n","import type { ComponentProps } from \"preact\";\n\nimport CardContainer from \"../CardContainer.js\";\n\n// Placeholder shown while recommendations load, built to match the Essential\n// widget (the layout all partners use) section for section: the hero offer\n// slot, the 4-up product tile row and the privacy footer, with the same\n// padding, gaps, dividers and 450px breakpoint. That keeps the page from\n// jumping when the real widget replaces it.\n\nconst WIDE = \"@container (inline-size > 450px)\";\nconst TILE_COUNT = 4;\n\nconst Block = ({\n blockSize,\n}: {\n blockSize: ComponentProps<\"s-box\">[\"blockSize\"];\n}) => (\n <s-box\n blockSize={blockSize}\n inlineSize=\"100%\"\n background=\"subdued\"\n borderRadius=\"base\"\n />\n);\n\nconst HeroOfferSkeleton = () => (\n <s-box padding=\"base\" border=\"base\" borderWidth=\"none none base none\">\n <s-stack gap=\"small-400\">\n <s-skeleton-paragraph content=\"Thank you for your purchase:\" />\n <s-stack gap=\"base\">\n <s-stack gap=\"small-200\">\n <s-skeleton-paragraph content=\"Exclusive offer from a brand you'll love\" />\n <s-skeleton-paragraph content=\"Get a special discount on your next order\" />\n </s-stack>\n <s-stack direction={`${WIDE} inline, block`} gap=\"base\">\n {[0, 1].map((index) => (\n <s-box key={index} inlineSize={`${WIDE} 160px, 100%`}>\n <Block blockSize=\"44px\" />\n </s-box>\n ))}\n </s-stack>\n </s-stack>\n </s-stack>\n </s-box>\n);\n\nconst OfferRowSkeleton = () => (\n <s-box padding=\"base\" border=\"base\" borderWidth=\"none none base none\">\n <s-grid gridTemplateColumns=\"repeat(4, minmax(0, 1fr))\" gap=\"small-200\">\n {Array.from({ length: TILE_COUNT }, (_, index) => (\n <s-stack key={index} gap=\"small-400\">\n {/* Essential tiles are square, so their height follows the card\n width. An image with no src renders its placeholder, and with\n the real tile image's props it matches the tile at any width. */}\n <s-image\n aspectRatio=\"1\"\n inlineSize=\"fill\"\n border=\"base\"\n borderRadius=\"small\"\n accessibilityRole=\"presentation\"\n />\n {/* Tile labels are \"<brand> <offer>\", which usually wraps. */}\n <s-stack gap=\"none\">\n <s-skeleton-paragraph content=\"Brand\" />\n <s-skeleton-paragraph content=\"Offer\" />\n </s-stack>\n </s-stack>\n ))}\n </s-grid>\n </s-box>\n);\n\nconst RecommendationsWidgetSkeleton = () => (\n <s-box\n accessibilityRole=\"status\"\n accessibilityLabel=\"Loading recommendations\"\n >\n <CardContainer background=\"base\">\n <s-query-container>\n <HeroOfferSkeleton />\n <OfferRowSkeleton />\n <s-stack padding=\"small-200 base\" alignItems=\"end\">\n <s-skeleton-paragraph content=\"Privacy Policy\" />\n </s-stack>\n </s-query-container>\n </CardContainer>\n </s-box>\n);\n\nexport default RecommendationsWidgetSkeleton;\n","","import packageJson from \"../package.json\" with { type: \"json\" };\n\nexport const SDK_IDENTITY = {\n name: packageJson.name,\n version: packageJson.version,\n};\n","\"use client\";\nimport { t as DiscoClientContext } from \"./bindings-Tjn3P4tn.js\";\nimport { t as DiscoClientContext$1 } from \"./bindings-D-XXI0bV.js\";\nimport { useMemo } from \"react\";\nimport { DiscoClient } from \"@disconetwork/core\";\nimport { jsx } from \"react/jsx-runtime\";\nimport { InternalDiscoClient } from \"@disconetwork/core/internal\";\n//#region src/sdk-internals.tsx\n/**\n* @internal SDK composition API. Not re-exported from public/headless entries.\n* Bind a renderer's identity once without exposing it in provider props.\n*/\n/** @internal Bind SDK identity to a provider using the direct partners API. */\nfunction createSdkProvider(sdk) {\n\treturn function SdkProvider({ apiKey, baseUrl, children }) {\n\t\tconst client = useMemo(() => new DiscoClient({\n\t\t\tapiKey,\n\t\t\tbaseUrl,\n\t\t\tsdk\n\t\t}), [apiKey, baseUrl]);\n\t\treturn /* @__PURE__ */ jsx(DiscoClientContext.Provider, {\n\t\t\tvalue: client,\n\t\t\tchildren\n\t\t});\n\t};\n}\n/** @internal Bind SDK identity to a provider using the legacy backend proxy. */\nfunction createProxySdkProvider(sdk) {\n\treturn function ProxySdkProvider({ children, ...auth }) {\n\t\tconst apiKey = \"apiKey\" in auth ? auth.apiKey : void 0;\n\t\tconst surface = \"surface\" in auth ? auth.surface : void 0;\n\t\tconst shopGid = \"shopGid\" in auth ? auth.shopGid : void 0;\n\t\tconst env = \"env\" in auth ? auth.env : void 0;\n\t\tconst client = useMemo(() => apiKey !== void 0 ? new InternalDiscoClient({\n\t\t\tapiKey,\n\t\t\tsurface,\n\t\t\tsdk\n\t\t}) : new InternalDiscoClient({\n\t\t\tshopGid,\n\t\t\tenv,\n\t\t\tsdk\n\t\t}), [\n\t\t\tapiKey,\n\t\t\tsurface,\n\t\t\tshopGid,\n\t\t\tenv\n\t\t]);\n\t\treturn /* @__PURE__ */ jsx(DiscoClientContext$1.Provider, {\n\t\t\tvalue: client,\n\t\t\tchildren\n\t\t});\n\t};\n}\n//#endregion\nexport { createProxySdkProvider, createSdkProvider };\n\n//# sourceMappingURL=sdk-internals.js.map","import type { ComponentChildren } from \"preact\";\nimport type { DiscoEnv } from \"@disconetwork/core/internal\";\nimport {\n useFetchRecommendations,\n type DiscoAuth,\n type RecommendationsRequest,\n} from \"@disconetwork/react-shared/internal/headless\";\n\nimport { RecommendationsDataContext } from \"./index.js\";\nimport { RecommendationsTrackingManager } from \"./RecommendationsTrackingManager/index.js\";\nimport usePayload from \"../hooks/usePayload.js\";\nimport { getRecommendationsRequest } from \"../utils/dataManagerUtils.js\";\nimport RecommendationsWidgetSkeleton from \"../components/RecommendationsWidget/RecommendationsWidgetSkeleton.js\";\nimport { SDK_IDENTITY } from \"../sdkIdentity.js\";\nimport { createProxySdkProvider } from \"@disconetwork/react-shared/sdk-internals\";\n\nconst ShopifySdkProvider = createProxySdkProvider(SDK_IDENTITY);\n\n// The public widget authenticates by API key; Disco's own (internal) widget by\n// shop, against the given backend.\nexport type DataManagerAuth = { apiKey: string } | { env: DiscoEnv };\n\n/**\n * Where the recommendations request comes from: built from the Shopify payload\n * (optionally for a `widgetId`), or a caller-supplied `request` sent as-is.\n * Never both: `request` replaces the whole body, so a `widgetId` alongside it\n * would be silently ignored.\n */\nexport type RecommendationsRequestSource =\n | { widgetId?: string; request?: never }\n | { request: RecommendationsRequest; widgetId?: never };\n\ntype DataManagerProps = {\n auth: DataManagerAuth;\n children: ComponentChildren;\n} & RecommendationsRequestSource;\n\ntype RecommendationsContentProps = {\n children: ComponentChildren;\n request: RecommendationsRequest;\n};\n\nconst DataManager = ({\n auth,\n widgetId,\n request,\n children,\n}: DataManagerProps) => {\n const payload = usePayload();\n // With a key, the shopify route authenticates by it. Without one, the\n // shop_gid route resolves the publisher from the shop.\n const discoAuth: DiscoAuth =\n \"apiKey\" in auth\n ? { apiKey: auth.apiKey, surface: \"shopify\" }\n : { shopGid: payload.shopGid, env: auth.env };\n\n return (\n <ShopifySdkProvider {...discoAuth}>\n <RecommendationsContent\n request={request ?? getRecommendationsRequest({ payload, widgetId })}\n >\n {children}\n </RecommendationsContent>\n </ShopifySdkProvider>\n );\n};\n\nconst RecommendationsContent = ({\n children,\n request,\n}: RecommendationsContentProps) => {\n const { state: recommendations, tracker } = useFetchRecommendations(request);\n\n if (recommendations.status === \"error\") return null;\n\n if (recommendations.status === \"loading\" || !tracker) {\n return <RecommendationsWidgetSkeleton />;\n }\n\n return (\n <RecommendationsDataContext.Provider value={recommendations.data}>\n <RecommendationsTrackingManager tracker={tracker}>\n {children}\n </RecommendationsTrackingManager>\n </RecommendationsDataContext.Provider>\n );\n};\n\nexport default DataManager;\n","import type { Address } from \"@disconetwork/core/internal\";\nimport type { MailingAddress as CheckoutMailingAddress } from \"@shopify/ui-extensions/checkout\";\nimport type { MailingAddress as CustomerAccountMailingAddress } from \"@shopify/ui-extensions/customer-account\";\n\n/** The address type of either extension surface (thank-you or order status). */\nexport type ShopifyMailingAddress =\n | CheckoutMailingAddress\n | CustomerAccountMailingAddress;\n\n/**\n * Map a Shopify `MailingAddress` onto the recommendations `Address`, dropping\n * empty fields. `undefined` when Shopify gives no address (e.g. no protected\n * customer data access) or the address has none of the fields we forward.\n */\nexport const toRecommendationsAddress = (\n address?: ShopifyMailingAddress,\n): Address | undefined => {\n if (!address) return undefined;\n const mapped: Address = {\n addressLine1: address.address1 || undefined,\n addressLine2: address.address2 || undefined,\n city: address.city || undefined,\n state: address.provinceCode || undefined,\n zip: address.zip || undefined,\n phone: address.phone || undefined,\n countryCode: address.countryCode || undefined,\n };\n return Object.values(mapped).some(Boolean) ? mapped : undefined;\n};\n","import { useEffect } from \"preact/hooks\";\nimport type { ComponentChildren } from \"preact\";\nimport type { Address } from \"@disconetwork/core/internal\";\nimport type { Customer as CheckoutCustomer } from \"@shopify/ui-extensions/checkout\";\nimport type { OrderStatusCustomer } from \"@shopify/ui-extensions/customer-account\";\n\nimport { PayloadContext } from \"./index.js\";\nimport { Extend, ObjectValuesAsTypes } from \"../utils/shared.types.js\";\nimport {\n toRecommendationsAddress,\n type ShopifyMailingAddress,\n} from \"../utils/address.js\";\nimport {\n useApi as useCheckoutApi,\n useCartLines as useCheckoutCartLines,\n useCheckoutToken,\n useDiscountCodes as useCheckoutDiscountCodes,\n usePurchasingCompany as useCheckoutPurchasingCompany,\n useShop as useCheckoutShop,\n useSubscription as useCheckoutSubscription,\n useTotalAmount as useCheckoutTotalAmount,\n} from \"@shopify/ui-extensions/checkout/preact\";\nimport {\n useApi as useCustomerAccountApi,\n useCartLines as useCustomerAccountCartLines,\n useDiscountCodes as useCustomerAccountDiscountCodes,\n useOrder,\n usePurchasingCompany as useCustomerAccountPurchasingCompany,\n useShop as useCustomerAccountShop,\n useSubscription as useCustomerAccountSubscription,\n useTotalAmount as useCustomerAccountTotalAmount,\n} from \"@shopify/ui-extensions/customer-account/preact\";\n\ntype PayloadCartLine = {\n merchandise: {\n title: string;\n subtitle?: string;\n product: {\n id: string;\n productType?: string;\n };\n };\n quantity: number;\n cost: {\n totalAmount: {\n amount: number;\n currencyCode: string;\n };\n };\n};\n\ntype PayloadDiscountCode = { code: string };\n\ntype GenericPayloadManagerType = {\n buyerPhone?: string;\n buyerEmail?: string;\n customerId?: string;\n customerFirstName?: string;\n customerLastName?: string;\n customerFullName?: string;\n derivedFirstName?: string;\n billingFirstName?: string;\n billingLastName?: string;\n billingZipCode?: string;\n shippingZipCode?: string;\n shippingAddress?: Address;\n billingAddress?: Address;\n extrapolatedFirstName?: string;\n extrapolatedPhone?: string;\n totalCost: number;\n currencyCode: string;\n cartLines: PayloadCartLine[];\n checkoutToken?: string;\n discountCodes: PayloadDiscountCode[];\n shopGid: string;\n orderId?: string;\n target: typeof PAYLOAD_MANAGER_TARGET.GENERIC;\n extensionTarget: string;\n};\n\ntype GenericPayloadProviderProps = {\n target: PayloadManagerTargetType;\n payload: GenericPayloadManagerType;\n additionalPayload?:\n | BaseOrderStatusPayloadManagerType\n | BaseThankYouPayloadManagerType;\n isB2BPurchase: boolean;\n children: ComponentChildren;\n};\n\nconst GenericPayloadProvider = ({\n target,\n children,\n payload,\n additionalPayload,\n isB2BPurchase,\n}: GenericPayloadProviderProps) => {\n useEffect(() => {\n if (!isB2BPurchase) return;\n throw new Error(\"[Disco]: Disabling for B2B purchase\");\n }, [isB2BPurchase]);\n\n if (isB2BPurchase) return null;\n\n return (\n <PayloadContext.Provider\n value={\n {\n ...payload,\n ...(additionalPayload || {}),\n target,\n } as PayloadManagerType\n }\n >\n {children}\n </PayloadContext.Provider>\n );\n};\n\nfunction createGenericPayload({\n buyerPhone,\n buyerEmail,\n customer,\n shippingAddress,\n billingAddress,\n totalAmount,\n cartLines,\n checkoutToken,\n discountCodes,\n shopGid,\n extensionTarget,\n}: {\n buyerPhone?: string;\n buyerEmail?: string;\n customer?: CheckoutCustomer | OrderStatusCustomer;\n shippingAddress?: ShopifyMailingAddress;\n billingAddress?: ShopifyMailingAddress;\n totalAmount: { amount: number; currencyCode: string };\n cartLines: PayloadCartLine[];\n checkoutToken?: string;\n discountCodes: PayloadDiscountCode[];\n shopGid: string;\n extensionTarget: string;\n}): GenericPayloadManagerType {\n const derivedFirstName =\n billingAddress?.firstName || shippingAddress?.firstName;\n\n return {\n buyerPhone,\n buyerEmail,\n customerId: customer?.id,\n customerFirstName: customer?.firstName,\n customerLastName: customer?.lastName,\n customerFullName: customer?.fullName,\n derivedFirstName,\n billingFirstName: billingAddress?.firstName,\n billingLastName: billingAddress?.lastName,\n billingZipCode: billingAddress?.zip,\n shippingZipCode: shippingAddress?.zip,\n shippingAddress: toRecommendationsAddress(shippingAddress),\n billingAddress: toRecommendationsAddress(billingAddress),\n extrapolatedFirstName: customer?.firstName || derivedFirstName,\n extrapolatedPhone:\n buyerPhone || shippingAddress?.phone || billingAddress?.phone || \"\",\n totalCost: totalAmount.amount,\n currencyCode: totalAmount.currencyCode,\n cartLines,\n checkoutToken,\n discountCodes,\n shopGid,\n target: PAYLOAD_MANAGER_TARGET.GENERIC,\n extensionTarget,\n };\n}\n\ntype BaseOrderStatusPayloadManagerType = {\n orderName?: string;\n orderId?: string;\n target: typeof PAYLOAD_MANAGER_TARGET.ORDER_STATUS;\n};\n\nexport type OrderStatusPayloadManagerType = Extend<\n GenericPayloadManagerType,\n BaseOrderStatusPayloadManagerType\n>;\n\ntype BaseThankYouPayloadManagerType = {\n orderId?: string;\n target: typeof PAYLOAD_MANAGER_TARGET.THANK_YOU;\n};\n\nexport type ThankYouPayloadManagerType = Extend<\n GenericPayloadManagerType,\n BaseThankYouPayloadManagerType\n>;\n\ntype ThankYouPayloadManagerProps = {\n children: ComponentChildren;\n};\n\nconst ThankYouPayloadManager = ({ children }: ThankYouPayloadManagerProps) => {\n const target = PAYLOAD_MANAGER_TARGET.THANK_YOU;\n const purchasingCompany = useCheckoutPurchasingCompany();\n const totalAmount = useCheckoutTotalAmount();\n const cartLines = useCheckoutCartLines();\n const checkoutToken = useCheckoutToken();\n const discountCodes = useCheckoutDiscountCodes();\n const shop = useCheckoutShop();\n const api = useCheckoutApi<\"purchase.thank-you.block.render\">();\n const orderConfirmation = useCheckoutSubscription(api.orderConfirmation);\n const orderId = orderConfirmation.order.id.split(\"/\").pop();\n\n if (!orderId) {\n console.warn(\"[Disco]: Order ID not found in thank you page\");\n }\n\n const payload = createGenericPayload({\n buyerPhone: shopify.buyerIdentity?.phone.value,\n buyerEmail: shopify.buyerIdentity?.email.value,\n customer: shopify.buyerIdentity?.customer.value,\n shippingAddress: shopify.shippingAddress?.value,\n billingAddress: shopify.billingAddress?.value,\n totalAmount,\n cartLines,\n checkoutToken,\n discountCodes,\n shopGid: shop.id,\n extensionTarget: api.extension.target,\n });\n\n return (\n <GenericPayloadProvider\n target={target}\n payload={payload}\n additionalPayload={{ orderId, target }}\n isB2BPurchase={Boolean(purchasingCompany?.company)}\n >\n {children}\n </GenericPayloadProvider>\n );\n};\n\ntype OrderStatusPayloadManagerProps = {\n children: ComponentChildren;\n};\n\nconst OrderStatusPayloadManager = ({\n children,\n}: OrderStatusPayloadManagerProps) => {\n const target = PAYLOAD_MANAGER_TARGET.ORDER_STATUS;\n const purchasingCompany = useCustomerAccountPurchasingCompany();\n const totalAmount = useCustomerAccountTotalAmount();\n const cartLines = useCustomerAccountCartLines();\n const discountCodes = useCustomerAccountDiscountCodes();\n const shop = useCustomerAccountShop();\n const order = useOrder();\n const api =\n useCustomerAccountApi<\"customer-account.order-status.block.render\">();\n const checkoutToken = useCustomerAccountSubscription(api.checkoutToken);\n\n const payload = createGenericPayload({\n buyerPhone: shopify.buyerIdentity?.phone.value,\n buyerEmail: shopify.buyerIdentity?.email.value,\n customer: shopify.buyerIdentity?.customer.value,\n shippingAddress: shopify.shippingAddress?.value,\n billingAddress: shopify.billingAddress?.value,\n totalAmount,\n cartLines,\n checkoutToken,\n discountCodes,\n shopGid: shop.id,\n extensionTarget: api.extension.target,\n });\n\n return (\n <GenericPayloadProvider\n target={target}\n payload={payload}\n additionalPayload={{\n orderId: order?.id,\n orderName: order?.name,\n target,\n }}\n isB2BPurchase={Boolean(purchasingCompany?.company)}\n >\n {children}\n </GenericPayloadProvider>\n );\n};\n\nexport const PAYLOAD_MANAGER_TARGET = {\n GENERIC: \"GENERIC\",\n ORDER_STATUS: \"ORDER_STATUS\",\n THANK_YOU: \"THANK_YOU\",\n} as const;\n\nexport type PayloadManagerTargetType = ObjectValuesAsTypes<\n typeof PAYLOAD_MANAGER_TARGET\n>;\nexport type PayloadManagerType =\n | GenericPayloadManagerType\n | OrderStatusPayloadManagerType\n | ThankYouPayloadManagerType;\n\nconst EXTENSION_TARGETS: Record<string, PayloadManagerTargetType> = {\n \"purchase.thank-you.block.render\": PAYLOAD_MANAGER_TARGET.THANK_YOU,\n \"customer-account.order-status.block.render\":\n PAYLOAD_MANAGER_TARGET.ORDER_STATUS,\n};\n\ntype PayloadManagerProps = {\n children: ComponentChildren;\n};\n\nconst PayloadManager = ({ children }: PayloadManagerProps) => {\n // Every UI extension target exposes its API on the `shopify` global from API\n // version 2025-10, so the block a merchant placed tells us which page we're on.\n const extensionTarget: string = shopify.extension.target;\n const target = EXTENSION_TARGETS[extensionTarget];\n\n if (target === PAYLOAD_MANAGER_TARGET.THANK_YOU) {\n return <ThankYouPayloadManager>{children}</ThankYouPayloadManager>;\n }\n\n if (target === PAYLOAD_MANAGER_TARGET.ORDER_STATUS) {\n return <OrderStatusPayloadManager>{children}</OrderStatusPayloadManager>;\n }\n\n throw new Error(`[Disco]: Unsupported extension target ${extensionTarget}`);\n};\n\nexport default PayloadManager;\n","import {\n useState,\n useMemo,\n type Dispatch,\n type StateUpdater,\n} from \"preact/hooks\";\nimport { ComponentChildren } from \"preact\";\n\nimport { UserContext } from \"./index.js\";\nimport usePayload from \"../hooks/usePayload.js\";\n\nexport type UserType = {\n email?: string;\n firstName?: string;\n lastName?: string;\n fullName?: string;\n\n derivedFirstName?: string;\n extrapolatedFirstName?: string;\n};\n\nexport type UserManagerType = {\n user: UserType;\n setUser: Dispatch<StateUpdater<UserType>>;\n hasIdentity: boolean;\n};\n\ntype Props = {\n children: ComponentChildren;\n};\n\nconst UserManager = ({ children }: Props) => {\n const {\n buyerEmail,\n customerFirstName,\n customerLastName,\n customerFullName,\n derivedFirstName,\n extrapolatedFirstName,\n } = usePayload();\n\n const [user, setUser] = useState<UserType>({\n email: buyerEmail,\n firstName: customerFirstName,\n lastName: customerLastName,\n fullName: customerFullName,\n\n derivedFirstName,\n extrapolatedFirstName,\n });\n\n const hasIdentity = useMemo(() => !!user?.email, [user]);\n\n return (\n <UserContext.Provider value={{ user, setUser, hasIdentity }}>\n {children}\n </UserContext.Provider>\n );\n};\nexport default UserManager;\n","import { createContext } from \"preact\";\nimport type { PayloadManagerType } from \"./PayloadManager.js\";\nimport type { UserManagerType } from \"./UserManager.js\";\nimport type { RecommendationsResponse } from \"../utils/recommendationsResponseMapper.js\";\n\nexport { default as DataManager } from \"./DataManager.js\";\nexport type {\n DataManagerAuth,\n RecommendationsRequestSource,\n} from \"./DataManager.js\";\n\nexport const RecommendationsDataContext =\n createContext<RecommendationsResponse | null>(null);\n\nexport const PayloadContext = createContext<PayloadManagerType | null>(null);\nexport { default as PayloadManager } from \"./PayloadManager.js\";\n\nexport const UserContext = createContext<UserManagerType | null>(null);\nexport { default as UserManager } from \"./UserManager.js\";\n","import { useContext } from \"preact/hooks\";\n\nimport { RecommendationsDataContext } from \"../managers/index.js\";\n\nfunction useRecommendationsData() {\n const ctx = useContext(RecommendationsDataContext);\n\n if (!ctx) {\n throw new Error(\n \"useRecommendationsData must be used inside RecommendationsDataContext\",\n );\n }\n\n return ctx;\n}\n\nexport default useRecommendationsData;\n","import { useCallback, useState, useMemo } from \"preact/hooks\";\n\nconst useCounter = ({\n start = 0,\n min = 0,\n max = Infinity,\n resetOnMax = false,\n disabled = false,\n} = {}) => {\n const [counter, setCounter] = useState(start);\n\n const incrementCounter = useCallback(\n (counter: number) =>\n Math.min(max, counter + 1) % (resetOnMax ? max : Infinity),\n [max, resetOnMax],\n );\n const increment = useCallback(\n () => (disabled ? null : setCounter(incrementCounter)),\n [incrementCounter, disabled],\n );\n\n const decrementCounter = useCallback(\n (counter: number) => Math.max(min, counter - 1),\n [min],\n );\n const decrement = useCallback(\n () => (disabled ? null : setCounter(decrementCounter)),\n [decrementCounter, disabled],\n );\n\n const nextCounter = useMemo(\n () => incrementCounter(counter),\n [incrementCounter, counter],\n );\n const prevCounter = useMemo(\n () => decrementCounter(counter),\n [decrementCounter, counter],\n );\n\n const isMin = useMemo(() => counter === min, [min, counter]);\n const isMax = useMemo(() => counter === max, [max, counter]);\n\n const procValue = useCallback(\n (value: number) => Math.max(min, Math.min(max, value)),\n [max, min],\n );\n\n const handleCounter = useCallback(\n (cb: unknown) => {\n if (disabled) return;\n setCounter((counter) =>\n procValue(typeof cb === \"function\" ? cb(counter) : cb),\n );\n },\n [procValue, disabled],\n );\n\n return {\n counter,\n setCounter: handleCounter,\n increment,\n decrement,\n nextCounter,\n prevCounter,\n isMin,\n isMax,\n };\n};\n\nexport default useCounter;\n","import { type ComponentChildren, createContext } from \"preact\";\nimport { useContext, useState } from \"preact/hooks\";\n\nimport useCounter from \"../../hooks/useCounter.js\";\nimport {\n Recommendation,\n RecommendationGroup,\n} from \"../../utils/recommendationsResponseMapper.js\";\n\ntype HeroProviderContextValue = {\n activeRecommendation: Recommendation;\n activeOfferIndex: number;\n nextOffer: () => void;\n prevOffer: () => void;\n isOfferClaimed: boolean;\n handleOfferClaim: () => void;\n TOTAL_NUM_OFFERS: number;\n isFirstOffer: boolean;\n isLastOffer: boolean;\n claimedOffers: string[];\n recommendations: Recommendation[];\n};\n\nconst HeroContext = createContext<HeroProviderContextValue | null>(null);\n\ntype Props = {\n children: ComponentChildren;\n recommendationGroup: RecommendationGroup;\n loop?: boolean;\n};\n\nconst HeroOfferProvider = ({ children, recommendationGroup, loop }: Props) => {\n const [claimedOffers, setClaimedOffers] = useState<string[]>([]);\n\n const { recommendations } = recommendationGroup;\n const {\n counter: activeRecommendationIdx,\n increment: nextOffer,\n decrement: prevOffer,\n isMin: isFirstOffer,\n isMax: isLastOffer,\n } = useCounter(\n loop\n ? {\n start: 0,\n min: 0,\n max: recommendations.length,\n resetOnMax: true,\n }\n : { start: 0, min: 0, max: recommendations.length - 1 },\n );\n\n const activeRecommendation = recommendations[activeRecommendationIdx]!;\n\n const handleOfferClaim = () => {\n setClaimedOffers((claimedOffers) => [\n ...claimedOffers,\n activeRecommendation.id,\n ]);\n };\n\n const isOfferClaimed = claimedOffers.includes(activeRecommendation.id);\n\n const value = {\n activeRecommendation,\n activeOfferIndex: activeRecommendationIdx,\n nextOffer,\n prevOffer,\n isOfferClaimed,\n handleOfferClaim,\n TOTAL_NUM_OFFERS: recommendations.length,\n isFirstOffer,\n isLastOffer,\n claimedOffers,\n recommendations,\n };\n\n return <HeroContext.Provider value={value}>{children}</HeroContext.Provider>;\n};\n\nexport const useHeroOffer = () => {\n const context = useContext(HeroContext);\n if (!context) {\n throw new Error(\"useHeroOffer must be used within a HeroOfferProvider\");\n }\n\n return context;\n};\n\nexport default HeroOfferProvider;\n","import { type ComponentChildren, createContext } from \"preact\";\nimport { useContext } from \"preact/hooks\";\n\nimport { RecommendationGroup } from \"../../utils/recommendationsResponseMapper.js\";\n\ntype ScrollableSlotContextValue = {\n hasScrollableSlot: boolean;\n};\n\nconst ScrollableSlotContext = createContext<ScrollableSlotContextValue | null>(\n null,\n);\n\ntype Props = {\n children: ComponentChildren;\n scrollableRecommendationGroup?: RecommendationGroup;\n};\n\nconst ScrollableSlotProvider = ({\n children,\n scrollableRecommendationGroup,\n}: Props) => {\n const value = {\n hasScrollableSlot: !!scrollableRecommendationGroup,\n };\n\n return (\n <ScrollableSlotContext.Provider value={value}>\n {children}\n </ScrollableSlotContext.Provider>\n );\n};\n\nexport const useScrollableSlot = () => {\n const context = useContext(ScrollableSlotContext);\n if (!context) {\n throw new Error(\n \"useScrollableSlot must be used within a ScrollableSlotProvider\",\n );\n }\n\n return context;\n};\n\nexport default ScrollableSlotProvider;\n","import { useContext } from \"preact/hooks\";\nimport { UserContext } from \"../managers/index.js\";\n\nconst useIdentity = () => {\n const data = useContext(UserContext);\n\n if (!data) {\n throw new Error(\"No wrapper User manager found\");\n }\n\n return data;\n};\nexport default useIdentity;\n","export const CUSTOMIZATION_TYPE = {\n CHECKOUT: \"checkout\",\n UPFRONT: \"upfront\",\n} as const;\n","import useRecommendationsData from \"./useRecommendationsData.js\";\nimport type { ComponentChildren } from \"preact\";\n\nimport { ObjectValuesAsTypes } from \"../utils/shared.types.js\";\nimport { CUSTOMIZATION_TYPE } from \"./useCustomization.js\";\ntype useCustomizationArgs<T> = {\n type?: T;\n};\n\nconst useRecommendationsCustomization = <\n T extends ObjectValuesAsTypes<typeof CUSTOMIZATION_TYPE> =\n typeof CUSTOMIZATION_TYPE.CHECKOUT,\n>({\n type = CUSTOMIZATION_TYPE.CHECKOUT as T,\n}: useCustomizationArgs<T> = {}) => {\n const data = useRecommendationsData();\n\n const customization = data?.publisherCustomization?.[type] || null;\n\n // The SDK preserves server-defined customization keys as strings.\n type detailType = string;\n\n const hasCustomization = (detail: detailType) => {\n if (!customization || typeof customization !== \"object\" || !detail)\n return false;\n return !!customization[detail];\n };\n\n const getCustomization = (detail: detailType) => {\n if (!hasCustomization(detail) || !customization) return null;\n return customization[detail];\n };\n\n const applyCustomizationOrFallback = (\n detail: detailType,\n fallback: ComponentChildren = null,\n ) => {\n if (!hasCustomization(detail)) return fallback;\n return getCustomization(detail);\n };\n\n return {\n applyCustomizationOrFallback,\n };\n};\n\nexport default useRecommendationsCustomization;\n","import useIdentity from \"../../hooks/useIdentity.js\";\nimport useRecommendationsCustomization from \"../../hooks/useRecommendationsCustomization.js\";\n\nconst useFirstOfferHeading = () => {\n const { user } = useIdentity();\n const { applyCustomizationOrFallback } = useRecommendationsCustomization();\n\n const firstName = user?.extrapolatedFirstName;\n\n const fallback = `${\n firstName ? `${firstName}, thank you` : \"Thank you\"\n } for your purchase:`;\n\n return applyCustomizationOrFallback(\"widget_heading\", fallback);\n};\n\nexport default useFirstOfferHeading;\n","import type { DiscoEnv } from \"@disconetwork/core/internal\";\n\nexport const BUCKET_NAME = {\n production: \"coopcommerce\",\n staging: \"coopcommerce-staging\",\n} as const satisfies Record<DiscoEnv, string>;\n\nexport const IMAGE_HANDLING_CLOUDFRONT_DOMAIN = {\n production: \"https://d1t86rpuyqggut.cloudfront.net/\",\n staging: \"https://dn9o42i1jy6mo.cloudfront.net/\",\n} as const satisfies Record<DiscoEnv, string>;\n","import type { DiscoEnv } from \"@disconetwork/core/internal\";\n\nimport {\n BUCKET_NAME,\n IMAGE_HANDLING_CLOUDFRONT_DOMAIN,\n} from \"../conf/env_conf.js\";\nimport type { EmptyRecordType } from \"./shared.types.js\";\n\ninterface CloudfrontPayload {\n bucket?: string;\n key?: string;\n edits?: Record<string, unknown>;\n}\n\n/**\n * Parses a cloudfront image URL and extracts the key from its BASE64-encoded payload.\n * Returns the key if the URL is a valid cloudfront URL, otherwise returns null.\n */\nfunction parseKeyFromCloudfrontUrl(url: string, env: DiscoEnv): string | null {\n const domain = IMAGE_HANDLING_CLOUDFRONT_DOMAIN[env];\n if (!url.startsWith(domain)) {\n return null;\n }\n\n try {\n // Extract the BASE64 path (everything after the domain, before any query params)\n const pathWithParams = url.slice(domain.length);\n const base64Path = pathWithParams.split(\"?\")[0];\n\n if (!base64Path) {\n return null;\n }\n\n const decodedPayload = atob(base64Path);\n const payload: CloudfrontPayload = JSON.parse(decodedPayload);\n\n return payload.key ?? null;\n } catch {\n return null;\n }\n}\n\ntype getImgUrlEditsType = {\n resize?: EmptyRecordType;\n};\nexport type ImageSources = {\n src: string;\n srcSet?: string;\n};\n\ntype GetCloudfrontImageArgs = {\n env: DiscoEnv;\n key: string;\n edits?: getImgUrlEditsType;\n width?: number;\n height?: number;\n};\n\nconst getCloudfrontImageSources = ({\n env,\n key,\n edits,\n width,\n height,\n}: GetCloudfrontImageArgs): ImageSources => {\n const imgPayload = JSON.stringify({\n bucket: BUCKET_NAME[env],\n key,\n edits: {\n ...edits,\n resize: {\n fit: \"fill\",\n withoutEnlargement: true,\n },\n },\n });\n\n const cloudfrontUrl = `${IMAGE_HANDLING_CLOUDFRONT_DOMAIN[env]}${btoa(\n imgPayload,\n )}`;\n\n return getImageVariants(cloudfrontUrl, {\n width: width || 350,\n height: height || 350,\n });\n};\n\n/**\n * Square image sources for `url`. A cloudfront image-handler URL is re-encoded\n * at `size` with 1x-4x variants; any other URL is used as-is.\n */\nexport function getImageSources(\n url: string,\n { env, size }: { env: DiscoEnv; size: number },\n): ImageSources {\n const key = parseKeyFromCloudfrontUrl(url, env);\n return key\n ? getCloudfrontImageSources({ env, key, width: size, height: size })\n : { src: url };\n}\n\nfunction getImageVariants(\n imgUrl: string,\n dimensions: { width: number; height: number },\n): ImageSources {\n const { width: cssWidth, height: cssHeight } = dimensions;\n\n const getTransformedDimension = (\n resolution: 1 | 2 | 3 | 4,\n dimension: number,\n ) => {\n const STEP = 32;\n return Math.ceil((dimension * resolution) / STEP) * STEP;\n };\n\n const getTransformedImageUrl = (resolution: 1 | 2 | 3 | 4) => {\n const transformedWidth = getTransformedDimension(resolution, cssWidth);\n const transformedHeight = getTransformedDimension(resolution, cssHeight);\n\n return `${imgUrl}?width=${transformedWidth}&height=${transformedHeight}`;\n };\n\n const resolutions = [1, 2, 3, 4] as const;\n const variants = resolutions.map((resolution) => ({\n resolution,\n url: getTransformedImageUrl(resolution),\n }));\n\n return {\n src: getTransformedImageUrl(1),\n srcSet: variants\n .map(({ resolution, url }) => `${url} ${resolution}x`)\n .join(\", \"),\n };\n}\n","import { useDiscoClient } from \"@disconetwork/react-shared/internal/headless\";\n\n// The backend the configured client talks to. Image and lead-gen URLs follow\n// it so they always match the environment the recommendations came from.\nconst useDiscoEnv = () => useDiscoClient().env;\n\nexport default useDiscoEnv;\n","// Inspired by https://github.com/payloadcms/payload/blob/main/packages/richtext-lexical/src/features/converters/lexicalToJSX/converter/converters/link.tsx\nimport type { ComponentChildren } from \"preact\";\n\nimport type {\n JSXGenerators,\n LinkNode,\n} from \"@disconetwork/react-shared/internal/headless\";\nimport { useRendererContext } from \"@disconetwork/react-shared/internal/headless\";\n\nfunction InternalLink({\n targetScreenId,\n children,\n}: {\n targetScreenId: string;\n children: ComponentChildren;\n}) {\n const ctx = useRendererContext();\n return (\n <s-link\n tone=\"neutral\"\n onClick={() => ctx.setCurrentScreenId(targetScreenId)}\n >\n {children}\n </s-link>\n );\n}\n\nconst LinkGenerator = {\n link: ({\n node,\n nodesToJSX,\n }: Parameters<JSXGenerators<LinkNode>[\"link\"]>[0]) => {\n const children = nodesToJSX({\n nodes: node.children,\n });\n\n if (\"targetScreenId\" in node.attributes) {\n return (\n <InternalLink targetScreenId={node.attributes.targetScreenId}>\n {children}\n </InternalLink>\n );\n }\n\n const href = node.attributes.to;\n const external = node.attributes.external;\n\n return (\n <s-link tone=\"neutral\" href={href} target={external ? \"_blank\" : \"auto\"}>\n {children}\n </s-link>\n );\n },\n} as unknown as JSXGenerators<LinkNode>;\n\nexport default LinkGenerator;\n","// Inspired by https://github.com/payloadcms/payload/blob/main/packages/richtext-lexical/src/features/converters/lexicalToJSX/converter/converters/paragraph.tsx\nimport type {\n JSXGenerators,\n ParagraphNode,\n} from \"@disconetwork/react-shared/internal/headless\";\n\nconst ParagraphGenerator = {\n paragraph: ({\n node,\n nodesToJSX,\n }: Parameters<JSXGenerators<ParagraphNode>[\"paragraph\"]>[0]) => {\n const children = nodesToJSX({\n nodes: node.children,\n });\n\n return (\n <s-paragraph color=\"subdued\">\n <s-text type=\"strong\">{children}</s-text>\n </s-paragraph>\n );\n },\n} as unknown as JSXGenerators<ParagraphNode>;\n\nexport default ParagraphGenerator;\n","import type {\n JSXGenerators,\n ScrollViewNode,\n} from \"@disconetwork/react-shared/internal/headless\";\n\nconst DEFAULT_MAX_BLOCK_SIZE = 300;\n\nconst ScrollViewGenerator = {\n scrollview: ({\n node,\n nodesToJSX,\n }: Parameters<JSXGenerators<ScrollViewNode>[\"scrollview\"]>[0]) => {\n const children = nodesToJSX({\n nodes: node.children,\n });\n\n const maxBlockSize =\n node.attributes?.maxBlockSize ?? DEFAULT_MAX_BLOCK_SIZE;\n\n return (\n <s-scroll-box maxBlockSize={`${maxBlockSize}px`}>{children}</s-scroll-box>\n );\n },\n} as unknown as JSXGenerators<ScrollViewNode>;\n\nexport default ScrollViewGenerator;\n","// Inspired by https://github.com/payloadcms/payload/blob/main/packages/richtext-lexical/src/features/converters/lexicalToJSX/converter/converters/text.tsx\nimport type {\n JSXGenerators,\n TextNode,\n} from \"@disconetwork/react-shared/internal/headless\";\n\nconst TextGenerator: JSXGenerators<TextNode> = {\n text: ({ node }) => {\n const text = node.text;\n\n return text;\n },\n};\n\nexport default TextGenerator;\n","import { ScreensRenderer } from \"@disconetwork/react-shared/internal/headless\";\n\nimport LinkGenerator from \"./generation/LinkGenerator.js\";\nimport ParagraphGenerator from \"./generation/ParagraphGenerator.js\";\nimport ScrollViewGenerator from \"./generation/ScrollViewGenerator.js\";\nimport TextGenerator from \"./generation/TextGenerator.js\";\n\ntype Props = {\n heading: string;\n subheading?: string;\n jsonContent?: Record<string, unknown> | null;\n};\n\nconst renderers = {\n ...TextGenerator,\n ...LinkGenerator,\n ...ParagraphGenerator,\n ...ScrollViewGenerator,\n};\n\nconst EssentialOfferContent = ({\n heading: offerHeading,\n subheading: offerSubheading,\n jsonContent: incentiveJson,\n}: Props) => {\n return (\n <s-stack gap=\"small-200\">\n <s-heading>{offerHeading}</s-heading>\n\n <ScreensRenderer\n jsonContent={incentiveJson}\n renderers={renderers}\n fallback={\n <s-paragraph color=\"subdued\">\n <s-text type=\"strong\">{offerSubheading || \"\"}</s-text>\n </s-paragraph>\n }\n />\n </s-stack>\n );\n};\n\nexport default EssentialOfferContent;\n","import { Recommendation } from \"../../../utils/recommendationsResponseMapper.js\";\nimport { getImageSources } from \"../../../utils/getImgUrl.js\";\nimport useDiscoEnv from \"../../../hooks/useDiscoEnv.js\";\nimport { useEventTracker } from \"../../../managers/RecommendationsTrackingManager/index.js\";\nimport { useHeroOffer } from \"../HeroOfferProvider.js\";\nimport { useScrollableSlot } from \"../ScrollableSlotProvider.js\";\nimport useFirstOfferHeading from \"../useFirstOfferHeading.js\";\nimport EssentialOfferContent from \"../../Essential/EssentialOfferContent.js\";\n\ntype Props = {\n onLastOffer: () => void;\n compact?: boolean;\n};\n\nconst EssentialLayoutType = ({ onLastOffer, compact }: Props) => {\n const { isFirstOffer, activeRecommendation: recommendation } = useHeroOffer();\n const renderBrandLogo =\n recommendation.offer.metadata.layoutType === \"FEATURED_IMAGE\";\n const gridTemplateColumns = renderBrandLogo\n ? \"@container (inline-size > 450px) 1fr auto, 1fr\"\n : \"1fr\";\n\n return (\n <s-query-container>\n <s-box padding={compact ? \"none\" : \"base\"}>\n <s-stack gap=\"small-400\">\n {renderBrandLogo && (\n <s-box display=\"@container (inline-size > 450px) none, auto\">\n <s-stack alignItems=\"center\">\n <AdvertiserLogo recommendation={recommendation} />\n </s-stack>\n </s-box>\n )}\n {isFirstOffer && !compact && <FirstOfferHeading />}\n <s-grid\n gridTemplateColumns={gridTemplateColumns}\n gap=\"base\"\n alignItems=\"center\"\n >\n <s-stack gap=\"base\">\n <EssentialOfferContent\n heading={recommendation.offer.heading || \"\"}\n subheading={recommendation.offer.subheading || \"\"}\n jsonContent={recommendation.offer.jsonContent}\n />\n <s-stack\n direction=\"@container (inline-size > 450px) inline, block\"\n gap=\"base\"\n >\n <s-box inlineSize=\"@container (inline-size > 450px) auto, 100%\">\n <PrimaryButton />\n </s-box>\n <s-box inlineSize=\"@container (inline-size > 450px) auto, 100%\">\n <SecondaryButton onLastOffer={onLastOffer} />\n </s-box>\n </s-stack>\n </s-stack>\n {renderBrandLogo && (\n <s-box display=\"@container (inline-size > 450px) auto, none\">\n <AdvertiserLogo recommendation={recommendation} />\n </s-box>\n )}\n </s-grid>\n </s-stack>\n </s-box>\n </s-query-container>\n );\n};\n\nfunction AdvertiserLogo({\n recommendation,\n}: {\n recommendation: Recommendation;\n}) {\n const { advertiser } = recommendation;\n const env = useDiscoEnv();\n const imageSize = 140;\n const image = getImageSources(advertiser.logoUrl, { env, size: imageSize });\n\n return (\n <s-box blockSize={`${imageSize}px`} inlineSize={`${imageSize}px`}>\n <s-image\n aspectRatio=\"1\"\n src={image.src}\n srcSet={image.srcSet}\n alt={`${advertiser.name} Logo`}\n inlineSize=\"fill\"\n />\n </s-box>\n );\n}\n\nfunction PrimaryButton() {\n const { track } = useEventTracker();\n const {\n handleOfferClaim,\n isOfferClaimed,\n activeRecommendation: recommendation,\n } = useHeroOffer();\n\n const handleClick = () => {\n track({\n type: \"BRAND_CLICK\",\n target: \"INLINE_ACTION_BUTTON\",\n brand: {\n offerId: recommendation.offer.id,\n advertiserId: recommendation.advertiser.id,\n insertionId: recommendation.insertionId,\n },\n });\n handleOfferClaim();\n };\n\n return (\n <s-button\n href={recommendation.offer.targetUrl}\n target=\"_blank\"\n inlineSize=\"fill\"\n variant={isOfferClaimed ? \"secondary\" : \"primary\"}\n onClick={handleClick}\n >\n {recommendation.offer.ctaDetails.acceptCopy}\n </s-button>\n );\n}\n\nfunction SecondaryButton({ onLastOffer }: { onLastOffer: () => void }) {\n const { track } = useEventTracker();\n const { hasScrollableSlot } = useScrollableSlot();\n const {\n isOfferClaimed,\n nextOffer,\n isLastOffer,\n activeRecommendation: recommendation,\n } = useHeroOffer();\n\n const handleClick = () => {\n track({\n type: \"ELEMENT_CLICK\",\n target: \"INLINE_NAV_FORWARD\",\n brand: {\n offerId: recommendation.offer.id,\n advertiserId: recommendation.advertiser.id,\n insertionId: recommendation.insertionId,\n },\n });\n\n if (isLastOffer) {\n onLastOffer();\n return;\n }\n\n nextOffer();\n };\n\n const buttonText = isOfferClaimed\n ? isLastOffer\n ? hasScrollableSlot\n ? \"See more\"\n : \"Close\"\n : \"Next offer\"\n : recommendation.offer.ctaDetails.declineCopy || \"No thanks\";\n\n return (\n <s-button\n inlineSize=\"fill\"\n variant={isOfferClaimed ? \"primary\" : \"secondary\"}\n onClick={handleClick}\n >\n {buttonText}\n </s-button>\n );\n}\n\nfunction FirstOfferHeading() {\n return <s-text tone=\"info\">{useFirstOfferHeading()}</s-text>;\n}\n\nexport default EssentialLayoutType;\n","const DotIndicators = ({\n totalCount,\n activeIndex,\n}: {\n totalCount: number;\n activeIndex: number;\n}) => {\n if (totalCount <= 1) return null;\n\n return (\n <s-stack padding=\"small-200 none\" alignItems=\"center\">\n <s-stack direction=\"inline\" gap=\"small-200\">\n {Array.from({ length: totalCount }, (_, i) => (\n <s-badge\n key={i}\n size=\"small\"\n color={i === activeIndex ? \"base\" : \"subdued\"}\n >\n {`${i + 1}`}\n </s-badge>\n ))}\n </s-stack>\n </s-stack>\n );\n};\n\nexport default DotIndicators;\n","import { INTERNAL_BASE_URL, type DiscoEnv } from \"@disconetwork/core/internal\";\n\nexport const getLeadGenRegisterUrl = (env: DiscoEnv) =>\n `${INTERNAL_BASE_URL[env]}/lead_gen/register_lead/`;\n\nexport const PRIVACY_POLICY_URL = \"https://www.disconetwork.com/privacy-policy\";\n","import { PRIVACY_POLICY_URL } from \"../conf/index.js\";\n\nexport const PrivacyLink = ({ onPress }: { onPress: () => void }) => {\n return (\n <s-text color=\"subdued\">\n <s-link\n href={PRIVACY_POLICY_URL}\n target=\"_blank\"\n tone=\"neutral\"\n onClick={onPress}\n >\n Privacy Policy\n </s-link>\n </s-text>\n );\n};\n","import { PrivacyLink } from \"../PrivacyLink.js\";\nimport { useEventTracker } from \"../../managers/RecommendationsTrackingManager/index.js\";\n\nfunction Footer() {\n const { track } = useEventTracker();\n const handlePrivacyClick = () => {\n track({\n type: \"ELEMENT_CLICK\",\n target: \"INLINE_FOOTER_PRIVACY\",\n });\n };\n\n return (\n <s-stack padding=\"small-200 base\" alignItems=\"end\">\n <PrivacyLink onPress={handlePrivacyClick} />\n </s-stack>\n );\n}\n\nexport default Footer;\n","import { useEffect, useState } from \"preact/hooks\";\n\nimport { useEventTracker } from \"../../../managers/RecommendationsTrackingManager/index.js\";\nimport { RecommendationGroup } from \"../../../utils/recommendationsResponseMapper.js\";\nimport CardContainer from \"../../CardContainer.js\";\nimport HeroOfferProvider, { useHeroOffer } from \"../HeroOfferProvider.js\";\nimport ScrollableSlotProvider from \"../ScrollableSlotProvider.js\";\nimport useFirstOfferHeading from \"../useFirstOfferHeading.js\";\nimport EssentialLayoutType from \"../Essential/EssentialLayoutType.js\";\nimport DotIndicators from \"../DotIndicators.js\";\nimport Footer from \"../Footer.js\";\n\nconst CoverRecommendationsWidget = ({\n heroRecommendationGroup,\n}: {\n heroRecommendationGroup: RecommendationGroup;\n}) => {\n const { track } = useEventTracker();\n\n useEffect(() => {\n track({ type: \"WIDGET_LOAD\" });\n }, [track]);\n\n return (\n <HeroOfferProvider recommendationGroup={heroRecommendationGroup} loop>\n <CoverRecommendationsWidgetContent />\n </HeroOfferProvider>\n );\n};\n\nconst CoverRecommendationsWidgetContent = () => {\n const { track } = useEventTracker();\n const firstOfferHeading = useFirstOfferHeading();\n const modalHeading =\n typeof firstOfferHeading === \"string\" ? firstOfferHeading : \"Your rewards\";\n const {\n TOTAL_NUM_OFFERS,\n activeOfferIndex,\n nextOffer,\n activeRecommendation,\n } = useHeroOffer();\n const [modalOpen, setModalOpen] = useState(false);\n const { insertionId, offer, advertiser } = activeRecommendation;\n\n useEffect(() => {\n if (!modalOpen) return;\n track({\n type: \"BRAND_DISPLAY\",\n target: \"INLINE_SLOT\",\n brand: {\n offerId: offer.id,\n advertiserId: advertiser.id,\n insertionId,\n },\n });\n }, [modalOpen, track, insertionId, offer.id, advertiser.id]);\n\n const subtitle = `You've unlocked ${TOTAL_NUM_OFFERS} exclusive offer${TOTAL_NUM_OFFERS !== 1 ? \"s\" : \"\"} with your purchase — don't let them go to waste!`;\n\n return (\n <CardContainer background=\"transparent\">\n <s-box padding=\"base\">\n <s-stack gap=\"base\">\n <s-heading>Your purchase comes with rewards!</s-heading>\n <s-text color=\"subdued\">{subtitle}</s-text>\n <s-button\n variant=\"primary\"\n command=\"--show\"\n commandFor=\"cover-modal\"\n onClick={() =>\n track({\n type: \"ELEMENT_CLICK\",\n target: \"OPEN_OVERLAY\",\n })\n }\n >\n View my rewards\n </s-button>\n <s-modal\n id=\"cover-modal\"\n padding=\"base\"\n heading={modalHeading}\n size=\"large\"\n onShow={() => {\n setModalOpen(true);\n track({ type: \"WIDGET_DISPLAY\" });\n }}\n onHide={() => {\n setModalOpen(false);\n track({\n type: \"ELEMENT_CLICK\",\n target: \"CLOSE_BUTTON\",\n });\n }}\n >\n <ScrollableSlotProvider>\n <EssentialLayoutType onLastOffer={nextOffer} compact />\n </ScrollableSlotProvider>\n <DotIndicators\n totalCount={TOTAL_NUM_OFFERS}\n activeIndex={activeOfferIndex}\n />\n <s-divider />\n <Footer />\n </s-modal>\n </s-stack>\n </s-box>\n </CardContainer>\n );\n};\n\nexport default CoverRecommendationsWidget;\n","import type { ImageSources } from \"../../utils/getImgUrl.js\";\n\nexport function ProductTile({\n targetUrl,\n trackClick,\n image,\n productName,\n}: {\n targetUrl: string;\n trackClick: () => void;\n image: ImageSources;\n productName: string;\n}) {\n return (\n <s-box inlineSize=\"100%\">\n <s-stack alignItems=\"stretch\" gap=\"none\">\n <s-link\n target=\"_blank\"\n tone=\"neutral\"\n href={targetUrl}\n onClick={trackClick}\n >\n <s-box inlineSize=\"100%\">\n <s-image\n aspectRatio=\"1\"\n src={image.src}\n srcSet={image.srcSet}\n alt={productName}\n inlineSize=\"fill\"\n border={\"base\"}\n borderRadius=\"small\"\n />\n </s-box>\n </s-link>\n <s-stack\n maxBlockSize=\"50px\"\n maxInlineSize=\"100%\"\n padding=\"small-400 none none none\"\n overflow=\"hidden\"\n >\n <s-text type=\"strong\" color=\"subdued\">\n <s-link\n target=\"_blank\"\n tone=\"neutral\"\n href={targetUrl}\n onClick={trackClick}\n >\n {productName}\n </s-link>\n </s-text>\n </s-stack>\n </s-stack>\n </s-box>\n );\n}\n","import { useEffect, useState } from \"preact/hooks\";\nimport type { ComponentProps } from \"preact\";\n\nimport { Recommendation } from \"../../utils/recommendationsResponseMapper.js\";\nimport { ProductTile } from \"../DiscoFeed/DiscoFeedProduct.js\";\nimport { getImageSources } from \"../../utils/getImgUrl.js\";\nimport useDiscoEnv from \"../../hooks/useDiscoEnv.js\";\nimport { useEventTracker } from \"../../managers/RecommendationsTrackingManager/index.js\";\n\ntype Props = {\n recommendations: Recommendation[];\n padding?: ComponentProps<\"s-box\">[\"padding\"];\n};\n\nconst PAGE_SIZE = 4;\nconst PRODUCT_IMAGE_SOURCE_SIZE = 256;\n\nconst RecommendationsOfferRow = ({ recommendations, padding }: Props) => {\n const renderableRecommendations = recommendations.filter(\n (recommendation) => recommendation.offer.assets.length > 0,\n );\n\n return (\n <RecommendationsPager\n recommendations={renderableRecommendations}\n padding={padding}\n />\n );\n};\n\nexport default RecommendationsOfferRow;\n\nfunction RecommendationsPager({\n recommendations,\n padding,\n}: {\n recommendations: Recommendation[];\n padding?: ComponentProps<\"s-box\">[\"padding\"];\n}) {\n const [page, setPage] = useState(0);\n const pageCount = Math.ceil(recommendations.length / PAGE_SIZE);\n const currentPage = Math.min(page, Math.max(pageCount - 1, 0));\n const pageRecommendations = recommendations.slice(\n currentPage * PAGE_SIZE,\n (currentPage + 1) * PAGE_SIZE,\n );\n\n useEffect(() => {\n if (page !== currentPage) setPage(currentPage);\n }, [page, currentPage]);\n\n if (pageRecommendations.length === 0) return null;\n\n return (\n <s-box padding={padding}>\n <s-stack gap=\"base\">\n <s-grid gridTemplateColumns=\"repeat(4, minmax(0, 1fr))\" gap=\"small-200\">\n {pageRecommendations.map((recommendation) => (\n <s-box key={recommendation.id} inlineSize=\"100%\">\n <RecommendationsOfferRowTile recommendation={recommendation} />\n </s-box>\n ))}\n </s-grid>\n {pageCount > 1 && (\n <s-stack\n direction=\"inline\"\n justifyContent=\"center\"\n alignItems=\"center\"\n gap=\"small-200\"\n >\n <s-clickable\n accessibilityLabel=\"Previous recommendations page\"\n disabled={currentPage === 0}\n inlineSize=\"32px\"\n blockSize=\"32px\"\n border=\"base\"\n borderRadius=\"base\"\n onClick={() => setPage(currentPage - 1)}\n >\n <s-stack\n blockSize=\"100%\"\n alignItems=\"center\"\n justifyContent=\"center\"\n >\n <s-icon\n type=\"chevron-left\"\n size=\"small\"\n tone={currentPage === 0 ? \"neutral\" : \"auto\"}\n />\n </s-stack>\n </s-clickable>\n <s-text type=\"small\" tone=\"neutral\" color=\"base\">\n {currentPage + 1} / {pageCount}\n </s-text>\n <s-clickable\n accessibilityLabel=\"Next recommendations page\"\n disabled={currentPage === pageCount - 1}\n inlineSize=\"32px\"\n blockSize=\"32px\"\n border=\"base\"\n borderRadius=\"base\"\n onClick={() => setPage(currentPage + 1)}\n >\n <s-stack\n blockSize=\"100%\"\n alignItems=\"center\"\n justifyContent=\"center\"\n >\n <s-icon\n type=\"chevron-right\"\n size=\"small\"\n tone={currentPage === pageCount - 1 ? \"neutral\" : \"auto\"}\n />\n </s-stack>\n </s-clickable>\n </s-stack>\n )}\n </s-stack>\n </s-box>\n );\n}\n\nfunction RecommendationsOfferRowTile({\n recommendation,\n}: {\n recommendation: Recommendation;\n}) {\n const { track } = useEventTracker();\n const env = useDiscoEnv();\n\n const offerId = recommendation.offer.id;\n const advertiserId = recommendation.advertiser.id;\n const insertionId = recommendation.insertionId;\n\n useEffect(() => {\n track({\n type: \"BRAND_DISPLAY\",\n target: \"SCROLLABLE_SLOT\",\n brand: {\n offerId,\n advertiserId,\n insertionId,\n },\n });\n }, [track, offerId, advertiserId, insertionId]);\n\n const trackClick = () => {\n track({\n type: \"BRAND_CLICK\",\n target: \"SCROLLABLE_SLOT_TILE\",\n brand: {\n offerId,\n advertiserId,\n insertionId,\n },\n });\n };\n\n const targetUrl = recommendation.offer.targetUrl;\n const productName = `${recommendation.offer.heading} ${recommendation.offer.subheading}`;\n\n const offerImageAsset = recommendation.offer.assets[0];\n if (!offerImageAsset) return null;\n\n const image = getImageSources(offerImageAsset.imageUrl, {\n env,\n size: PRODUCT_IMAGE_SOURCE_SIZE,\n });\n\n return (\n <ProductTile\n targetUrl={targetUrl}\n trackClick={trackClick}\n image={image}\n productName={productName}\n />\n );\n}\n","import { useEffect, useState } from \"preact/hooks\";\n\nimport useRecommendationsCustomization from \"../../../hooks/useRecommendationsCustomization.js\";\nimport CardContainer from \"../../CardContainer.js\";\nimport HeroOfferProvider, { useHeroOffer } from \"../HeroOfferProvider.js\";\nimport ScrollableSlotProvider from \"../ScrollableSlotProvider.js\";\nimport EssentialLayoutType from \"./EssentialLayoutType.js\";\nimport { useEventTracker } from \"../../../managers/RecommendationsTrackingManager/index.js\";\nimport RecommendationsOfferRow from \"../RecommendationsOfferRow.js\";\nimport { RecommendationGroup } from \"../../../utils/recommendationsResponseMapper.js\";\nimport Footer from \"../Footer.js\";\n\nconst EssentialRecommendationsWidget = ({\n heroRecommendationGroup,\n scrollableRecommendationGroup,\n}: {\n heroRecommendationGroup?: RecommendationGroup;\n scrollableRecommendationGroup?: RecommendationGroup;\n}) => {\n const [showOfferSlot, setShowOfferSlot] = useState(!!heroRecommendationGroup);\n const { track } = useEventTracker();\n\n const { applyCustomizationOrFallback } = useRecommendationsCustomization();\n\n useEffect(() => {\n track({ type: \"WIDGET_LOAD\" });\n track({ type: \"WIDGET_DISPLAY\" });\n }, [track]);\n\n const hideOfferSlot = () => setShowOfferSlot(false);\n\n const heading = applyCustomizationOrFallback(\n \"widget_bottom_slot_heading\",\n \"Trending brands we think you'll love\",\n );\n\n if (!showOfferSlot && !scrollableRecommendationGroup) {\n return null;\n }\n\n return (\n <ScrollableSlotProvider\n scrollableRecommendationGroup={scrollableRecommendationGroup}\n >\n <CardContainer background=\"base\">\n {showOfferSlot && heroRecommendationGroup ? (\n <s-box border=\"base\" borderWidth=\"none none base none\">\n <HeroOfferProvider recommendationGroup={heroRecommendationGroup}>\n <TrackedEssentialLayout onLastOffer={hideOfferSlot} />\n </HeroOfferProvider>\n </s-box>\n ) : (\n <s-box padding=\"base base none base\">\n <s-heading>{heading}</s-heading>\n </s-box>\n )}\n\n {scrollableRecommendationGroup && (\n <s-box\n padding=\"base none\"\n border=\"base\"\n borderWidth=\"none none base none\"\n >\n <RecommendationsOfferRow\n recommendations={scrollableRecommendationGroup.recommendations}\n padding=\"none base\"\n />\n </s-box>\n )}\n <Footer />\n </CardContainer>\n </ScrollableSlotProvider>\n );\n};\n\nconst TrackedEssentialLayout = ({\n onLastOffer,\n}: {\n onLastOffer: () => void;\n}) => {\n const { track } = useEventTracker();\n const { activeRecommendation } = useHeroOffer();\n const { insertionId, offer, advertiser } = activeRecommendation;\n\n useEffect(() => {\n track({\n type: \"BRAND_DISPLAY\",\n target: \"INLINE_SLOT\",\n brand: {\n offerId: offer.id,\n advertiserId: advertiser.id,\n insertionId,\n },\n });\n }, [track, insertionId, offer.id, advertiser.id]);\n\n return <EssentialLayoutType onLastOffer={onLastOffer} />;\n};\n\nexport default EssentialRecommendationsWidget;\n","import useRecommendationsCustomization from \"../../../hooks/useRecommendationsCustomization.js\";\nimport { useHeroOffer } from \"../HeroOfferProvider.js\";\n\nconst LeadGenHeader = () => {\n const { claimedOffers } = useHeroOffer();\n const { applyCustomizationOrFallback } = useRecommendationsCustomization();\n\n const numOffersClaimed = claimedOffers.length;\n const hasClaimedAnOffer = numOffersClaimed > 0;\n\n const heading = applyCustomizationOrFallback(\n \"widget_heading\",\n !hasClaimedAnOffer\n ? `Special offers just for you`\n : `Your special offer is claimed!`,\n );\n\n const subheading = applyCustomizationOrFallback(\n \"widget_subheading\",\n !hasClaimedAnOffer\n ? `As a thank you for your recent purchase`\n : \"Discover more deals to save on top brands\",\n );\n\n return (\n <s-stack gap=\"none\" padding=\"large-200\">\n <s-heading>{heading}</s-heading>\n <s-text color=\"subdued\">{subheading}</s-text>\n </s-stack>\n );\n};\n\nexport default LeadGenHeader;\n","import { getImageSources } from \"../../../utils/getImgUrl.js\";\nimport useDiscoEnv from \"../../../hooks/useDiscoEnv.js\";\nimport { useHeroOffer } from \"../HeroOfferProvider.js\";\nimport { OfferAsset } from \"../../../utils/recommendationsResponseMapper.js\";\n\nconst LeadGenAssetTile = ({ asset }: { asset: OfferAsset }) => {\n const env = useDiscoEnv();\n const image = getImageSources(asset.imageUrl, { env, size: 400 });\n\n return (\n <s-image\n aspectRatio=\"1\"\n src={image.src}\n srcSet={image.srcSet}\n alt=\"Offer product\"\n inlineSize=\"fill\"\n border=\"base\"\n borderRadius=\"base\"\n loading=\"lazy\"\n />\n );\n};\n\nconst LeadGenBrandProducts = () => {\n const { activeRecommendation } = useHeroOffer();\n const assets = activeRecommendation.offer.assets.slice(0, 4);\n\n if (assets.length === 0) return null;\n\n return (\n <s-query-container>\n <s-grid\n gridTemplateColumns=\"@container (inline-size > 450px) repeat(4, 1fr), repeat(3, 1fr)\"\n gap=\"small-200\"\n >\n {assets.map((asset) => (\n <LeadGenAssetTile key={asset.id} asset={asset} />\n ))}\n </s-grid>\n </s-query-container>\n );\n};\n\nconst LeadGenBrand = () => {\n const { activeRecommendation } = useHeroOffer();\n const { advertiser } = activeRecommendation;\n const env = useDiscoEnv();\n const logoSize = 56;\n const logo = getImageSources(advertiser.logoUrl, { env, size: logoSize });\n\n return (\n <s-stack gap=\"small-200\" padding=\"base large-200\">\n <s-grid\n gridTemplateColumns={`1fr ${logoSize}px`}\n gap=\"small-200\"\n alignItems=\"start\"\n >\n <s-stack gap=\"none\">\n <s-text type=\"strong\">{advertiser.name}</s-text>\n <s-paragraph>{advertiser.description}</s-paragraph>\n </s-stack>\n <s-box inlineSize={`${logoSize}px`} blockSize={`${logoSize}px`}>\n <s-image\n aspectRatio=\"1\"\n src={logo.src}\n srcSet={logo.srcSet}\n alt={`${advertiser.name} logo`}\n inlineSize=\"fill\"\n border=\"base\"\n borderRadius=\"max\"\n />\n </s-box>\n </s-grid>\n <LeadGenBrandProducts />\n </s-stack>\n );\n};\n\nexport default LeadGenBrand;\n","import { useState, useEffect, useCallback, useRef } from \"preact/hooks\";\n\ntype useResourceResultError = string | boolean;\n\ntype useResourceResult<T> = {\n loading: boolean;\n error: useResourceResultError;\n data?: T | null;\n headers?: HeadersInit | null;\n};\n\nconst initialResource: useResourceResult<null> = {\n loading: false,\n error: false,\n data: null,\n headers: null,\n};\n\n// Using \"interface\" instead of \"type\" because RequestInit is an \"interface\"\ninterface useResourceOptions extends RequestInit {\n url: RequestInfo | URL;\n data: unknown;\n}\n\n// T represents structure of the response payload expected from the backend;\nconst useResource = <T,>(\n options: useResourceOptions,\n autoLoad = true,\n debug = false,\n): [useResourceResult<T | null>, () => void, () => void] => {\n const [shouldLoad, setShouldLoad] = useState(autoLoad);\n const [resource, setResource] =\n useState<useResourceResult<T | null>>(initialResource);\n\n const reset = useCallback(() => {\n setResource(initialResource);\n setShouldLoad(false);\n }, []);\n\n const log = useCallback(\n (...msg: unknown[]) => {\n if (debug) console.log(...msg);\n },\n [debug],\n );\n\n const mounted = useRef(true);\n\n useEffect(() => {\n mounted.current = true;\n return () => {\n mounted.current = false;\n };\n }, []);\n\n const startLoad = useCallback(() => setShouldLoad(true), []);\n\n const load = useCallback(async () => {\n log(\"[uR]: Load called \");\n if (resource.loading || !shouldLoad || !options?.url) {\n log(\"[uR]: Load stopped \");\n return;\n }\n log(\"[uR]: Load started \");\n setShouldLoad(false);\n let resp;\n setResource({ loading: true, error: false, data: null, headers: null });\n\n try {\n let reqOptions = {\n headers: {\n \"Content-Type\": \"application/json\",\n },\n method: \"GET\",\n ...options,\n };\n if (\n (options?.method === \"POST\" || options?.method === \"PUT\") &&\n options.data\n ) {\n reqOptions = {\n ...reqOptions,\n body: JSON.stringify(options.data),\n };\n }\n resp = await fetch(options.url, reqOptions);\n\n if (resp.status !== 200 && resp.status !== 201) {\n throw new Error(\"RESP_ERR\");\n }\n try {\n resp = await resp.json();\n } catch {\n throw new Error(\"JSON_ERR\");\n }\n } catch (e) {\n if (typeof e === \"string\") {\n log(`[uR]: Load error! String => ${e}`);\n return;\n } else if (!(e instanceof Error)) {\n log(`[uR]: Load error! Unknown error =>`, e);\n return;\n }\n const { message: errMessage } = e;\n\n log(`[uR]: Load error! ${errMessage}`);\n if (mounted.current) {\n return setResource({\n loading: false,\n error:\n errMessage === \"RESP_ERR\" || errMessage === \"JSON_ERR\"\n ? \"An unknown error occured\"\n : \"Could not connect to the server\",\n data: null,\n });\n } else {\n return log(\"[uR]: Load error but NOT MOUNTED \");\n }\n }\n\n if (mounted.current) {\n log(\"[uR]: Load complete:\", resp);\n setResource({\n loading: false,\n error: false,\n data: resp,\n headers: null,\n });\n } else {\n log(\"[uR]: Load complete but NOT MOUNTED \");\n }\n }, [options, resource.loading, shouldLoad, log]);\n\n useEffect(() => {\n if (!resource.loading && shouldLoad) {\n load();\n }\n }, [resource.loading, shouldLoad, load]);\n\n return [resource, startLoad, reset];\n};\n\nexport default useResource;\n","import useResource from \"./useResource.js\";\nimport usePayload from \"./usePayload.js\";\nimport useDiscoEnv from \"./useDiscoEnv.js\";\nimport { getLeadGenRegisterUrl } from \"../conf/index.js\";\nimport { shopifyOrderIdFormatter } from \"../utils/dataManagerUtils.js\";\n\nconst useSendOfferEmail = ({\n shopGid,\n offerRemoteId,\n displayedOfferRemoteIds,\n sessionId,\n}: {\n shopGid: string;\n offerRemoteId: string;\n displayedOfferRemoteIds: string[];\n sessionId: string;\n}) => {\n const payload = usePayload();\n const env = useDiscoEnv();\n\n return useResource(\n {\n url: getLeadGenRegisterUrl(env),\n method: \"POST\",\n data: {\n email: payload.buyerEmail,\n first_name: payload.billingFirstName || \"\",\n last_name: payload.billingLastName || \"\",\n shop_gid: shopGid,\n offer_id: offerRemoteId,\n displayed_offer_ids: displayedOfferRemoteIds,\n session_id: sessionId,\n shopify_order_id: shopifyOrderIdFormatter(payload.orderId || null),\n },\n },\n false,\n );\n};\n\nexport default useSendOfferEmail;\n","import { useHeroOffer } from \"../HeroOfferProvider.js\";\nimport { useEventTracker } from \"../../../managers/RecommendationsTrackingManager/index.js\";\nimport useRecommendationsCustomization from \"../../../hooks/useRecommendationsCustomization.js\";\nimport useSendOfferEmail from \"../../../hooks/useSendOfferEmail.js\";\nimport usePayload from \"../../../hooks/usePayload.js\";\nimport useRecommendationsData from \"../../../hooks/useRecommendationsData.js\";\nimport { getShopIdentifier } from \"../../../utils/dataManagerUtils.js\";\n\nfunction LeadGenActionButton() {\n const {\n activeRecommendation,\n isOfferClaimed,\n handleOfferClaim,\n recommendations,\n } = useHeroOffer();\n const { track } = useEventTracker();\n const buttonText = useGetButtonText();\n\n const data = useRecommendationsData();\n const payload = usePayload();\n const [, sendOfferEmail] = useSendOfferEmail({\n shopGid: getShopIdentifier(payload.shopGid),\n displayedOfferRemoteIds: recommendations.map(\n (recommendation) => recommendation.offer.id,\n ),\n offerRemoteId: activeRecommendation.offer.id,\n sessionId: data.sessionId,\n });\n\n const handleClick = () => {\n track({\n type: \"BRAND_CLICK\",\n target: \"INLINE_ACTION_BUTTON\",\n brand: {\n offerId: activeRecommendation.offer.id,\n advertiserId: activeRecommendation.advertiser.id,\n insertionId: activeRecommendation.insertionId,\n },\n });\n if (isOfferClaimed) return;\n if (payload.buyerEmail) {\n sendOfferEmail();\n }\n handleOfferClaim();\n };\n\n return (\n <s-button\n href={activeRecommendation.offer.targetUrl}\n target=\"_blank\"\n inlineSize=\"fill\"\n variant={isOfferClaimed ? \"secondary\" : \"primary\"}\n key=\"lead-action-button\"\n onClick={handleClick}\n >\n {buttonText}\n </s-button>\n );\n}\n\nfunction useGetButtonText() {\n const { activeRecommendation, isOfferClaimed } = useHeroOffer();\n const { applyCustomizationOrFallback } = useRecommendationsCustomization();\n\n // No Promo Code\n if (activeRecommendation.offer.metadata.type === \"NO_PROMO_CODE\") {\n if (isOfferClaimed)\n return applyCustomizationOrFallback(\n \"widget_claimed_no_promo_cta_text\",\n \"Redeem onsite\",\n );\n return applyCustomizationOrFallback(\n \"widget_unclaimed_no_promo_cta_text\",\n \"Redeem onsite\",\n );\n }\n\n // Promo Code\n if (isOfferClaimed)\n return applyCustomizationOrFallback(\n \"widget_claimed_promo_cta_text\",\n \"Visit shop\",\n );\n return applyCustomizationOrFallback(\n \"widget_unclaimed_promo_cta_text\",\n \"Claim offer\",\n );\n}\n\nexport default LeadGenActionButton;\n","import useRecommendationsCustomization from \"../../../hooks/useRecommendationsCustomization.js\";\nimport RecommendationsOfferRow from \"../RecommendationsOfferRow.js\";\nimport { Recommendation } from \"../../../utils/recommendationsResponseMapper.js\";\n\nconst LeadGenOfferRow = ({\n recommendations,\n}: {\n recommendations: Recommendation[];\n}) => {\n const { applyCustomizationOrFallback } = useRecommendationsCustomization();\n\n const heading = applyCustomizationOrFallback(\n \"widget_bottom_slot_heading\",\n \"Trending brands we think you'll love\",\n );\n\n return (\n <s-stack gap=\"small-200\" padding=\"base none\">\n <s-box padding=\"none large-200\">\n <s-text type=\"strong\">{heading}</s-text>\n </s-box>\n\n <RecommendationsOfferRow\n recommendations={recommendations}\n padding=\"small-400 large-200\"\n />\n </s-stack>\n );\n};\n\nexport default LeadGenOfferRow;\n","import { useEffect } from \"preact/hooks\";\n\nimport LeadGenHeader from \"./LeadGenHeader.js\";\nimport LeadGenBrand from \"./LeadGenBrand.js\";\nimport HeroOfferProvider, { useHeroOffer } from \"../HeroOfferProvider.js\";\nimport { useEventTracker } from \"../../../managers/RecommendationsTrackingManager/index.js\";\nimport useRecommendationsCustomization from \"../../../hooks/useRecommendationsCustomization.js\";\nimport LeadGenActionButton from \"./LeadGenActionButton.js\";\nimport { RecommendationGroup } from \"../../../utils/recommendationsResponseMapper.js\";\nimport CardContainer from \"../../CardContainer.js\";\nimport Footer from \"../Footer.js\";\nimport LeadGenOfferRow from \"./LeadGenOfferRow.js\";\n\nconst LeadGen = ({\n heroRecommendationGroup,\n scrollableRecommendationGroup,\n}: {\n heroRecommendationGroup?: RecommendationGroup;\n scrollableRecommendationGroup?: RecommendationGroup;\n}) => {\n const { track } = useEventTracker();\n\n useEffect(() => {\n track({ type: \"WIDGET_LOAD\" });\n track({ type: \"WIDGET_DISPLAY\" });\n }, [track]);\n\n return (\n <CardContainer background=\"base\" padding=\"none none large-200 none\">\n {heroRecommendationGroup && (\n <HeroOfferProvider recommendationGroup={heroRecommendationGroup}>\n <LeadGenHeader />\n <s-divider />\n <s-box minBlockSize=\"230px\">\n <LeadGenBrand />\n </s-box>\n <s-stack padding=\"none large-200 large-200 large-200\" gap=\"base\">\n <LeadGenActionOffer />\n <LeadGenActionNav />\n </s-stack>\n <s-divider />\n </HeroOfferProvider>\n )}\n\n {scrollableRecommendationGroup && (\n <LeadGenOfferRow\n recommendations={scrollableRecommendationGroup.recommendations}\n />\n )}\n <Footer />\n </CardContainer>\n );\n};\n\nfunction LeadGenActionOffer() {\n const { activeRecommendation, isOfferClaimed } = useHeroOffer();\n const { heading, subheading, metadata } = activeRecommendation.offer;\n const primaryHeading = isOfferClaimed ? `You've got ${heading}` : heading;\n const secondaryHeading =\n isOfferClaimed && metadata.type === \"PROMO_CODE\" ? (\n <>\n Use code: <s-text type=\"strong\">{metadata.code}</s-text>\n </>\n ) : (\n subheading || \"On your next purchase\"\n );\n\n return (\n <s-stack\n padding=\"base\"\n background=\"subdued\"\n border=\"base base dashed\"\n borderRadius=\"base\"\n gap=\"base\"\n >\n <s-stack gap=\"none\">\n <s-heading>{primaryHeading}</s-heading>\n <s-text>{secondaryHeading}</s-text>\n </s-stack>\n <LeadGenActionButton />\n </s-stack>\n );\n}\n\nfunction LeadGenActionNav() {\n const {\n activeRecommendation,\n nextOffer,\n prevOffer,\n isFirstOffer,\n isLastOffer,\n isOfferClaimed,\n TOTAL_NUM_OFFERS,\n } = useHeroOffer();\n const { track } = useEventTracker();\n const { applyCustomizationOrFallback } = useRecommendationsCustomization();\n\n if (TOTAL_NUM_OFFERS <= 1) return null;\n\n const showPrevious = !isFirstOffer;\n const showNext = !isLastOffer;\n const hasSingleButton = !showNext || !showPrevious;\n const trackNavigation = () => ({\n offerId: activeRecommendation.offer.id,\n advertiserId: activeRecommendation.advertiser.id,\n insertionId: activeRecommendation.insertionId,\n });\n\n const handleNext = () => {\n track({\n type: \"ELEMENT_CLICK\",\n target: \"INLINE_NAV_FORWARD\",\n brand: trackNavigation(),\n });\n nextOffer();\n };\n\n const handlePrevious = () => {\n track({\n type: \"ELEMENT_CLICK\",\n target: \"INLINE_NAV_BACKWARD\",\n brand: trackNavigation(),\n });\n prevOffer();\n };\n\n return (\n <s-grid\n gridTemplateColumns={hasSingleButton ? \"1fr\" : \"1fr 11px 1fr\"}\n gap=\"base\"\n >\n {showPrevious && (\n <s-button\n variant={!isOfferClaimed || showNext ? \"secondary\" : \"primary\"}\n onClick={handlePrevious}\n >\n {applyCustomizationOrFallback(\n \"widget_nav_backward_cta_text\",\n \"Previous offer\",\n )}\n </s-button>\n )}\n {!hasSingleButton && <s-box />}\n {showNext && (\n <s-button\n variant={isOfferClaimed ? \"primary\" : \"secondary\"}\n onClick={handleNext}\n >\n {applyCustomizationOrFallback(\n \"widget_nav_forward_cta_text\",\n showPrevious ? \"Next offer\" : \"No thanks\",\n )}\n </s-button>\n )}\n </s-grid>\n );\n}\n\nexport default LeadGen;\n","import useRecommendationsData from \"../../hooks/useRecommendationsData.js\";\nimport CoverRecommendationsWidget from \"./Cover/index.js\";\nimport EssentialRecommendationsWidget from \"./Essential/index.js\";\nimport LeadGenRecommendationsWidget from \"./LeadGen/index.js\";\n\nconst ESSENTIAL_LAYOUT_IDS = [\n \"SHOPIFY_NATIVE_ESSENTIAL\",\n \"SHOPIFY_NATIVE_ESSENTIAL_0.22\",\n];\n\nconst Widget = () => {\n const recommendationsData = useRecommendationsData();\n\n const heroRecommendationGroup = recommendationsData.recommendationGroups.find(\n (group) => group.slotContext === \"HERO\",\n );\n\n const scrollableRecommendationGroup =\n recommendationsData.recommendationGroups.find(\n (group) => group.slotContext === \"SCROLLABLE\",\n );\n\n if (!heroRecommendationGroup && !scrollableRecommendationGroup) {\n return null;\n }\n\n const layoutId = recommendationsData.layoutId;\n\n if (ESSENTIAL_LAYOUT_IDS.includes(layoutId)) {\n return (\n <EssentialRecommendationsWidget\n heroRecommendationGroup={heroRecommendationGroup}\n scrollableRecommendationGroup={scrollableRecommendationGroup}\n />\n );\n }\n\n if (layoutId === \"SHOPIFY_NATIVE_COVER\") {\n if (!heroRecommendationGroup) {\n return null;\n }\n\n return (\n <CoverRecommendationsWidget\n heroRecommendationGroup={heroRecommendationGroup}\n />\n );\n }\n\n return (\n <LeadGenRecommendationsWidget\n heroRecommendationGroup={heroRecommendationGroup}\n scrollableRecommendationGroup={scrollableRecommendationGroup}\n />\n );\n};\n\nexport default Widget;\n","import type { RecommendationsRequest } from \"@disconetwork/core/internal\";\n\nimport Widget from \"./components/RecommendationsWidget/index.js\";\nimport {\n DataManager,\n PayloadManager,\n UserManager,\n type DataManagerAuth,\n type RecommendationsRequestSource,\n} from \"./managers/index.js\";\n\nexport type DiscoRecommendationsProps = {\n /**\n * The merchant's public API key (`disco_pk_live_…` / `disco_pk_sandbox_…`).\n * Recommendations are requested from the Shopify extension route,\n * authenticated by the key.\n */\n apiKey: string;\n} & (\n | {\n /** Select a configured widget on the current page. */\n widgetId?: string;\n request?: never;\n }\n | {\n /**\n * Replaces the entire recommendations request. When set, the widget\n * sends exactly this: none of the order or buyer details it reads from\n * Shopify (email, name, phone, order id, total, cart lines) go into the\n * request unless you include them here.\n *\n * Set `placement.view` (`\"THANK_YOU\"` or `\"ORDER_STATUS\"`) yourself;\n * without it the backend assumes the order status page. Put a widget id\n * in `placement.widgetId`.\n */\n request: RecommendationsRequest;\n widgetId?: never;\n }\n);\n\n/**\n * Disco post-purchase recommendations for a Shopify UI extension.\n *\n * Render it from a `purchase.thank-you.block.render` or\n * `customer-account.order-status.block.render` target; the order and buyer\n * details are read from that target's API.\n */\nexport function DiscoRecommendations({\n apiKey,\n ...source\n}: DiscoRecommendationsProps) {\n // Spread rather than destructure `widgetId`/`request`, so TypeScript keeps\n // them correlated as one branch of the union.\n return <Recommendations auth={{ apiKey }} {...source} />;\n}\n\n/**\n * The widget tree shared by the public (`apiKey`) and internal (`shop_gid`)\n * entry points.\n */\nexport function Recommendations({\n auth,\n ...source\n}: { auth: DataManagerAuth } & RecommendationsRequestSource) {\n return (\n <PayloadManager>\n <DataManager auth={auth} {...source}>\n <UserManager>\n <Widget />\n </UserManager>\n </DataManager>\n </PayloadManager>\n );\n}\n","import { INTERNAL_BASE_URL, type DiscoEnv } from \"@disconetwork/core/internal\";\n\nimport { SDK_IDENTITY } from \"../sdkIdentity.js\";\n\n/**\n * How a prepurchase widget authenticates. Disco's own extension passes the\n * backend `env` and is resolved from the shop (the `shop_gid` routes). A\n * partner passes its public API key, sent as `x-api-key` to the key routes on\n * production; like the public `DiscoRecommendations`, there is no `env` to set.\n */\nexport type PrepurchaseAuth = { env: DiscoEnv } | { apiKey: string };\n\n/** Where each prepurchase request goes, and the headers that authenticate it. */\nexport type PrepurchaseEndpoints = {\n incentiveUrl: (shopId: string) => string;\n orderUrl: (shopId: string) => string;\n orderIntentUrl: (shopId: string) => string;\n /** Unauthenticated: events are tied to the session the incentive issued. */\n eventUrl: string;\n /** Headers for the incentive, order and order-intent requests. */\n headers: Record<string, string>;\n};\n\n/** Headers for every prepurchase request, identifying this SDK to the backend. */\nexport const PREPURCHASE_REQUEST_HEADERS = {\n \"Content-Type\": \"application/json\",\n \"Disco-SDK-Name\": SDK_IDENTITY.name,\n \"Disco-SDK-Version\": SDK_IDENTITY.version,\n} as const;\n\nexport function getPrepurchaseEndpoints(\n auth: PrepurchaseAuth,\n): PrepurchaseEndpoints {\n if (\"apiKey\" in auth) {\n const base = INTERNAL_BASE_URL.production;\n return {\n incentiveUrl: () => `${base}/api/prepurchase/incentive/`,\n orderUrl: () => `${base}/api/prepurchase/order/`,\n orderIntentUrl: () => `${base}/api/prepurchase/order-intent/`,\n eventUrl: `${base}/track/partners_event/prepurchase/`,\n headers: { ...PREPURCHASE_REQUEST_HEADERS, \"x-api-key\": auth.apiKey },\n };\n }\n\n const base = INTERNAL_BASE_URL[auth.env];\n return {\n incentiveUrl: (shopId) =>\n `${base}/api/prepurchase/incentive/shop_gid/${shopId}/`,\n orderUrl: (shopId) => `${base}/api/prepurchase/order/shop_gid/${shopId}/`,\n orderIntentUrl: (shopId) =>\n `${base}/api/prepurchase/order-intent/shop_gid/${shopId}/`,\n eventUrl: `${base}/track/partners_event/prepurchase/`,\n headers: { ...PREPURCHASE_REQUEST_HEADERS },\n };\n}\n","import { createContext } from \"preact\";\nimport { useContext } from \"preact/hooks\";\n\nimport type { PrepurchaseEndpoints } from \"./conf.js\";\n\nexport const PrepurchaseEndpointsContext =\n createContext<PrepurchaseEndpoints | null>(null);\n\n/** Where every prepurchase request in this tree is sent, and how it authenticates. */\nexport function usePrepurchaseEndpoints(): PrepurchaseEndpoints {\n const endpoints = useContext(PrepurchaseEndpointsContext);\n\n if (!endpoints) {\n throw new Error(\n \"usePrepurchaseEndpoints must be used inside PrepurchaseProvider\",\n );\n }\n\n return endpoints;\n}\n","import type { ComponentChildren } from \"preact\";\nimport { useMemo, useState } from \"preact/hooks\";\nimport { QueryClient, QueryClientProvider } from \"@tanstack/preact-query\";\n\nimport { getPrepurchaseEndpoints, type PrepurchaseAuth } from \"./conf.js\";\nimport { PrepurchaseEndpointsContext } from \"./context.js\";\n\n/**\n * Everything the prepurchase widgets read from above: where to send requests\n * and how to authenticate them, and the query client their requests are cached\n * in. One client per mounted widget, since each extension target runs in its\n * own worker anyway.\n */\nexport function PrepurchaseProvider({\n auth,\n children,\n}: {\n auth: PrepurchaseAuth;\n children: ComponentChildren;\n}) {\n const [queryClient] = useState(() => new QueryClient());\n // Rebuilt only when `auth` changes. Nothing depends on the object's identity:\n // requests and the event tracker key off the URL strings.\n const endpoints = useMemo(() => getPrepurchaseEndpoints(auth), [auth]);\n\n return (\n <PrepurchaseEndpointsContext.Provider value={endpoints}>\n <QueryClientProvider client={queryClient}>{children}</QueryClientProvider>\n </PrepurchaseEndpointsContext.Provider>\n );\n}\n","import { type ComponentChildren, createContext } from \"preact\";\nimport { useContext, useMemo, useRef } from \"preact/hooks\";\n\nimport type { EventPayload, BrandProperties } from \"./types.js\";\nimport { PREPURCHASE_REQUEST_HEADERS } from \"../conf.js\";\nimport { usePrepurchaseEndpoints } from \"../context.js\";\n\ntype EventTracker = {\n track: (event: EventPayload) => void;\n};\n\nconst TrackingManagerContext = createContext<EventTracker | null>(null);\n\nexport function TrackingManager({\n children,\n enabled = true,\n sessionId,\n trackingTicketId,\n}: {\n children: ComponentChildren;\n enabled?: boolean;\n sessionId?: string;\n trackingTicketId?: string;\n}) {\n const { eventUrl } = usePrepurchaseEndpoints();\n const dedupeRef = useRef(new Set<string>());\n\n const tracker = useMemo<EventTracker>(\n () => ({\n track(event) {\n if (!enabled || !sessionId) return;\n if (isDeduped(event, dedupeRef.current)) return;\n\n // Events are tied to the session the incentive issued, so they carry no\n // API key.\n fetch(eventUrl, {\n method: \"POST\",\n headers: PREPURCHASE_REQUEST_HEADERS,\n keepalive: true,\n body: JSON.stringify(toBody(sessionId, trackingTicketId, event)),\n }).catch((error) => {\n console.error(\"Event tracking failed:\", error);\n });\n },\n }),\n [enabled, eventUrl, sessionId, trackingTicketId],\n );\n\n return (\n <TrackingManagerContext.Provider value={tracker}>\n {children}\n </TrackingManagerContext.Provider>\n );\n}\n\nexport function useEventTracker() {\n const ctx = useContext(TrackingManagerContext);\n\n if (!ctx) {\n throw new Error(\"useEventTracker must be used inside TrackingManager\");\n }\n\n return ctx;\n}\n\nfunction isDeduped(event: EventPayload, dedupe: Set<string>) {\n if (\n event.type === \"WIDGET_DISPLAY\" ||\n event.type === \"WIDGET_VIEW\" ||\n event.type === \"BRAND_DISPLAY\" ||\n event.type === \"BRAND_VIEW\"\n ) {\n const key =\n event.type + (\"brand\" in event ? event.brand.insertionId : \"widget\");\n if (dedupe.has(key)) return true;\n dedupe.add(key);\n }\n return false;\n}\n\nfunction toBody(\n sessionId: string,\n trackingTicketId: string | undefined,\n event: EventPayload,\n) {\n const getBrandProperties = (brand: BrandProperties) => {\n return {\n offer_id: brand.offerId,\n advertiser_id: brand.advertiserId,\n insertion_id: brand.insertionId,\n };\n };\n\n const eventDatetime = new Date();\n eventDatetime.setMilliseconds(0);\n\n const commonEventFields = {\n session_id: sessionId,\n tracking_ticket_id: trackingTicketId,\n event_name: event.type,\n event_datetime: eventDatetime.toISOString(),\n };\n\n switch (event.type) {\n case \"BRAND_CLICK\":\n return {\n ...commonEventFields,\n brand_properties: getBrandProperties(event.brand),\n initiating_target: event.target,\n };\n case \"BRAND_DISPLAY\":\n case \"BRAND_VIEW\":\n return {\n ...commonEventFields,\n brand_properties: getBrandProperties(event.brand),\n initiating_target: event.target,\n };\n case \"ELEMENT_CLICK\":\n return {\n ...commonEventFields,\n brand_properties: event.brand\n ? getBrandProperties(event.brand)\n : undefined,\n initiating_target: event.target,\n };\n default:\n return commonEventFields;\n }\n}\n","function isPortableTextSpan(node) {\n\treturn node._type === \"span\" && \"text\" in node && typeof node.text == \"string\" && (node.marks === void 0 || Array.isArray(node.marks) && node.marks.every((mark) => typeof mark == \"string\"));\n}\nfunction isPortableTextBlock(node) {\n\treturn typeof node._type == \"string\" && node._type[0] !== \"@\" && (!(\"markDefs\" in node) || !node.markDefs || Array.isArray(node.markDefs) && node.markDefs.every((def) => typeof def._key == \"string\")) && \"children\" in node && Array.isArray(node.children) && node.children.every((child) => typeof child == \"object\" && \"_type\" in child);\n}\nfunction isPortableTextListItemBlock(block) {\n\treturn isPortableTextBlock(block) && \"listItem\" in block && typeof block.listItem == \"string\" && (block.level === void 0 || typeof block.level == \"number\");\n}\nfunction isPortableTextToolkitList(block) {\n\treturn block._type === \"@list\";\n}\nfunction isPortableTextToolkitSpan(span) {\n\treturn span._type === \"@span\";\n}\nfunction isPortableTextToolkitTextNode(node) {\n\treturn node._type === \"@text\";\n}\nconst knownDecorators = [\n\t\"strong\",\n\t\"em\",\n\t\"code\",\n\t\"underline\",\n\t\"strike-through\"\n];\nfunction sortMarksByOccurences(span, index, blockChildren) {\n\tif (!isPortableTextSpan(span) || !span.marks || !span.marks.length) return [];\n\tlet marks = span.marks.slice(), occurences = {};\n\treturn marks.forEach((mark) => {\n\t\toccurences[mark] = 1;\n\t\tfor (let siblingIndex = index + 1; siblingIndex < blockChildren.length; siblingIndex++) {\n\t\t\tlet sibling = blockChildren[siblingIndex];\n\t\t\tif (sibling && isPortableTextSpan(sibling) && Array.isArray(sibling.marks) && sibling.marks.indexOf(mark) !== -1) occurences[mark]++;\n\t\t\telse break;\n\t\t}\n\t}), marks.sort((markA, markB) => sortMarks(occurences, markA, markB));\n}\nfunction sortMarks(occurences, markA, markB) {\n\tlet aOccurences = occurences[markA], bOccurences = occurences[markB];\n\tif (aOccurences !== bOccurences) return bOccurences - aOccurences;\n\tlet aKnownPos = knownDecorators.indexOf(markA), bKnownPos = knownDecorators.indexOf(markB);\n\treturn aKnownPos === bKnownPos ? markA.localeCompare(markB) : aKnownPos - bKnownPos;\n}\nfunction buildMarksTree(block) {\n\tlet { children } = block, markDefs = block.markDefs ?? [];\n\tif (!children || !children.length) return [];\n\tlet sortedMarks = children.map(sortMarksByOccurences), rootNode = {\n\t\t_type: \"@span\",\n\t\tchildren: [],\n\t\tmarkType: \"<unknown>\"\n\t}, nodeStack = [rootNode];\n\tfor (let i = 0; i < children.length; i++) {\n\t\tlet span = children[i];\n\t\tif (!span) continue;\n\t\tlet marksNeeded = sortedMarks[i] || [], pos = 1;\n\t\tif (nodeStack.length > 1) for (; pos < nodeStack.length; pos++) {\n\t\t\tlet mark = nodeStack[pos]?.markKey || \"\", index = marksNeeded.indexOf(mark);\n\t\t\tif (index === -1) break;\n\t\t\tmarksNeeded.splice(index, 1);\n\t\t}\n\t\tnodeStack = nodeStack.slice(0, pos);\n\t\tlet currentNode = nodeStack[nodeStack.length - 1];\n\t\tif (currentNode) {\n\t\t\tfor (let markKey of marksNeeded) {\n\t\t\t\tlet markDef = markDefs?.find((def) => def._key === markKey), node = {\n\t\t\t\t\t_type: \"@span\",\n\t\t\t\t\t_key: span._key,\n\t\t\t\t\tchildren: [],\n\t\t\t\t\tmarkDef,\n\t\t\t\t\tmarkType: markDef ? markDef._type : markKey,\n\t\t\t\t\tmarkKey\n\t\t\t\t};\n\t\t\t\tcurrentNode.children.push(node), nodeStack.push(node), currentNode = node;\n\t\t\t}\n\t\t\tif (isPortableTextSpan(span)) {\n\t\t\t\tlet lines = span.text.split(\"\\n\");\n\t\t\t\tfor (let line = lines.length; line-- > 1;) lines.splice(line, 0, \"\\n\");\n\t\t\t\tcurrentNode.children = currentNode.children.concat(lines.map((text) => ({\n\t\t\t\t\t_type: \"@text\",\n\t\t\t\t\ttext\n\t\t\t\t})));\n\t\t\t} else currentNode.children = currentNode.children.concat(span);\n\t\t}\n\t}\n\treturn rootNode.children;\n}\nfunction nestLists(blocks, mode) {\n\tlet tree = [], currentList;\n\tfor (let i = 0; i < blocks.length; i++) {\n\t\tlet block = blocks[i];\n\t\tif (block) {\n\t\t\tif (!isPortableTextListItemBlock(block)) {\n\t\t\t\ttree.push(block), currentList = void 0;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!currentList) {\n\t\t\t\tcurrentList = listFromBlock(block, i, mode), tree.push(currentList);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (blockMatchesList(block, currentList)) {\n\t\t\t\tcurrentList.children.push(block);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif ((block.level || 1) > currentList.level) {\n\t\t\t\tlet newList = listFromBlock(block, i, mode);\n\t\t\t\tif (mode === \"html\") {\n\t\t\t\t\tlet lastListItem = currentList.children[currentList.children.length - 1], newLastChild = {\n\t\t\t\t\t\t...lastListItem,\n\t\t\t\t\t\tchildren: [...lastListItem.children, newList]\n\t\t\t\t\t};\n\t\t\t\t\tcurrentList.children[currentList.children.length - 1] = newLastChild;\n\t\t\t\t} else currentList.children.push(newList);\n\t\t\t\tcurrentList = newList;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif ((block.level || 1) < currentList.level) {\n\t\t\t\tlet matchingBranch = tree[tree.length - 1], match = matchingBranch && findListMatching(matchingBranch, block);\n\t\t\t\tif (match) {\n\t\t\t\t\tcurrentList = match, currentList.children.push(block);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tcurrentList = listFromBlock(block, i, mode), tree.push(currentList);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (block.listItem !== currentList.listItem) {\n\t\t\t\tlet matchingBranch = tree[tree.length - 1], match = matchingBranch && findListMatching(matchingBranch, { level: block.level || 1 });\n\t\t\t\tif (match && match.listItem === block.listItem) {\n\t\t\t\t\tcurrentList = match, currentList.children.push(block);\n\t\t\t\t\tcontinue;\n\t\t\t\t} else {\n\t\t\t\t\tcurrentList = listFromBlock(block, i, mode), tree.push(currentList);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t\tconsole.warn(\"Unknown state encountered for block\", block), tree.push(block);\n\t\t}\n\t}\n\treturn tree;\n}\nfunction blockMatchesList(block, list) {\n\treturn (block.level || 1) === list.level && block.listItem === list.listItem;\n}\nfunction listFromBlock(block, index, mode) {\n\treturn {\n\t\t_type: \"@list\",\n\t\t_key: `${block._key || `${index}`}-parent`,\n\t\tmode,\n\t\tlevel: block.level || 1,\n\t\tlistItem: block.listItem,\n\t\tchildren: [block]\n\t};\n}\nfunction findListMatching(rootNode, matching) {\n\tlet level = matching.level || 1, style = matching.listItem || \"normal\", filterOnType = typeof matching.listItem == \"string\";\n\tif (isPortableTextToolkitList(rootNode) && (rootNode.level || 1) === level && filterOnType && (rootNode.listItem || \"normal\") === style) return rootNode;\n\tif (!(\"children\" in rootNode)) return;\n\tlet node = rootNode.children[rootNode.children.length - 1];\n\treturn node && !isPortableTextSpan(node) ? findListMatching(node, matching) : void 0;\n}\nfunction spanToPlainText(span) {\n\tlet text = \"\";\n\treturn span.children.forEach((current) => {\n\t\tisPortableTextToolkitTextNode(current) ? text += current.text : isPortableTextToolkitSpan(current) && (text += spanToPlainText(current));\n\t}), text;\n}\nconst leadingSpace = /^\\s/, trailingSpace = /\\s$/;\nfunction toPlainText(block) {\n\tlet blocks = Array.isArray(block) ? block : [block], text = \"\";\n\treturn blocks.forEach((current, index) => {\n\t\tif (!isPortableTextBlock(current)) return;\n\t\tlet pad = !1;\n\t\tcurrent.children.forEach((span) => {\n\t\t\tisPortableTextSpan(span) ? (text += pad && text && !trailingSpace.test(text) && !leadingSpace.test(span.text) ? \" \" : \"\", text += span.text, pad = !1) : pad = !0;\n\t\t}), index !== blocks.length - 1 && (text += \"\\n\\n\");\n\t}), text;\n}\nconst LIST_NEST_MODE_HTML = \"html\", LIST_NEST_MODE_DIRECT = \"direct\";\nexport { LIST_NEST_MODE_DIRECT, LIST_NEST_MODE_HTML, buildMarksTree, isPortableTextBlock, isPortableTextListItemBlock, isPortableTextSpan, isPortableTextToolkitList, isPortableTextToolkitSpan, isPortableTextToolkitTextNode, nestLists, sortMarksByOccurences, spanToPlainText, toPlainText };\n\n//# sourceMappingURL=index.js.map","import { Fragment, jsx } from \"react/jsx-runtime\";\nimport { LIST_NEST_MODE_HTML, buildMarksTree, isPortableTextBlock, isPortableTextListItemBlock, isPortableTextToolkitList, isPortableTextToolkitSpan, isPortableTextToolkitTextNode, nestLists, spanToPlainText, toPlainText } from \"@portabletext/toolkit\";\nimport { useMemo } from \"react\";\nconst defaultLists = {\n\tnumber: ({ children }) => /* @__PURE__ */ jsx(\"ol\", { children }),\n\tbullet: ({ children }) => /* @__PURE__ */ jsx(\"ul\", { children })\n}, DefaultListItem = ({ children }) => /* @__PURE__ */ jsx(\"li\", { children }), link = ({ children, value }) => /* @__PURE__ */ jsx(\"a\", {\n\thref: value?.href,\n\tchildren\n}), underlineStyle = { textDecoration: \"underline\" }, defaultMarks = {\n\tem: ({ children }) => /* @__PURE__ */ jsx(\"em\", { children }),\n\tstrong: ({ children }) => /* @__PURE__ */ jsx(\"strong\", { children }),\n\tcode: ({ children }) => /* @__PURE__ */ jsx(\"code\", { children }),\n\tunderline: ({ children }) => /* @__PURE__ */ jsx(\"span\", {\n\t\tstyle: underlineStyle,\n\t\tchildren\n\t}),\n\t\"strike-through\": ({ children }) => /* @__PURE__ */ jsx(\"del\", { children }),\n\tlink\n}, getTemplate = (type, prop) => `[@portabletext/react] Unknown ${type}, specify a component for it in the \\`components.${prop}\\` prop`, unknownTypeWarning = (typeName) => getTemplate(`block type \"${typeName}\"`, \"types\"), unknownMarkWarning = (markType) => getTemplate(`mark type \"${markType}\"`, \"marks\"), unknownBlockStyleWarning = (blockStyle) => getTemplate(`block style \"${blockStyle}\"`, \"block\"), unknownListStyleWarning = (listStyle) => getTemplate(`list style \"${listStyle}\"`, \"list\"), unknownListItemStyleWarning = (listStyle) => getTemplate(`list item style \"${listStyle}\"`, \"listItem\");\nfunction printWarning(message) {\n\tconsole.warn(message);\n}\nconst hidden = { display: \"none\" }, defaultComponents = {\n\ttypes: {},\n\tblock: {\n\t\tnormal: ({ children }) => /* @__PURE__ */ jsx(\"p\", { children }),\n\t\tblockquote: ({ children }) => /* @__PURE__ */ jsx(\"blockquote\", { children }),\n\t\th1: ({ children }) => /* @__PURE__ */ jsx(\"h1\", { children }),\n\t\th2: ({ children }) => /* @__PURE__ */ jsx(\"h2\", { children }),\n\t\th3: ({ children }) => /* @__PURE__ */ jsx(\"h3\", { children }),\n\t\th4: ({ children }) => /* @__PURE__ */ jsx(\"h4\", { children }),\n\t\th5: ({ children }) => /* @__PURE__ */ jsx(\"h5\", { children }),\n\t\th6: ({ children }) => /* @__PURE__ */ jsx(\"h6\", { children })\n\t},\n\tmarks: defaultMarks,\n\tlist: defaultLists,\n\tlistItem: DefaultListItem,\n\thardBreak: () => /* @__PURE__ */ jsx(\"br\", {}),\n\tunknownType: ({ value, isInline }) => {\n\t\tlet warning = unknownTypeWarning(value._type);\n\t\treturn jsx(isInline ? \"span\" : \"div\", {\n\t\t\tstyle: hidden,\n\t\t\tchildren: warning\n\t\t});\n\t},\n\tunknownMark: ({ markType, children }) => /* @__PURE__ */ jsx(\"span\", {\n\t\tclassName: `unknown__pt__mark__${markType}`,\n\t\tchildren\n\t}),\n\tunknownList: ({ children }) => /* @__PURE__ */ jsx(\"ul\", { children }),\n\tunknownListItem: ({ children }) => /* @__PURE__ */ jsx(\"li\", { children }),\n\tunknownBlockStyle: ({ children }) => /* @__PURE__ */ jsx(\"p\", { children })\n};\nfunction mergeComponents(parent, overrides) {\n\tlet { block: _block, list: _list, listItem: _listItem, marks: _marks, types: _types, ...rest } = overrides;\n\treturn {\n\t\t...parent,\n\t\tblock: mergeDeeply(parent, overrides, \"block\"),\n\t\tlist: mergeDeeply(parent, overrides, \"list\"),\n\t\tlistItem: mergeDeeply(parent, overrides, \"listItem\"),\n\t\tmarks: mergeDeeply(parent, overrides, \"marks\"),\n\t\ttypes: mergeDeeply(parent, overrides, \"types\"),\n\t\t...rest\n\t};\n}\nfunction mergeDeeply(parent, overrides, key) {\n\tlet override = overrides[key], parentVal = parent[key];\n\treturn typeof override == \"function\" || override && typeof parentVal == \"function\" ? override : override ? {\n\t\t...parentVal,\n\t\t...override\n\t} : parentVal;\n}\nfunction PortableText({ value: input, components: componentOverrides, listNestingMode, onMissingComponent: missingComponentHandler = printWarning }) {\n\tlet handleMissingComponent = missingComponentHandler || noop, blocks;\n\tblocks = Array.isArray(input) ? input : input == null ? [] : [input];\n\tlet nested = nestLists(blocks, listNestingMode || LIST_NEST_MODE_HTML), components = useMemo(() => componentOverrides ? mergeComponents(defaultComponents, componentOverrides) : defaultComponents, [componentOverrides]), renderNode = useMemo(() => getNodeRenderer(components, handleMissingComponent), [components, handleMissingComponent]);\n\treturn /* @__PURE__ */ jsx(Fragment, { children: nested.map((node, index) => renderNode({\n\t\tnode,\n\t\tindex,\n\t\tisInline: !1,\n\t\trenderNode\n\t})) });\n}\nconst getNodeRenderer = (components, handleMissingComponent) => {\n\tfunction renderNode(options) {\n\t\tlet { node, index, isInline } = options, key = node._key || `node-${index}`;\n\t\treturn isPortableTextToolkitList(node) ? renderList(node, index, key) : isPortableTextListItemBlock(node) ? renderListItem(node, index, key) : isPortableTextToolkitSpan(node) ? renderSpan(node, index, key) : hasCustomComponentForNode(node) ? renderCustomBlock(node, index, key, isInline) : isPortableTextBlock(node) ? renderBlock(node, index, key, isInline) : isPortableTextToolkitTextNode(node) ? renderText(node, key) : renderUnknownType(node, index, key, isInline);\n\t}\n\tfunction hasCustomComponentForNode(node) {\n\t\treturn node._type in components.types;\n\t}\n\tfunction renderListItem(node, index, key) {\n\t\tlet tree = serializeBlock({\n\t\t\tnode,\n\t\t\tindex,\n\t\t\tisInline: !1,\n\t\t\trenderNode\n\t\t}), renderer = components.listItem, Li = (typeof renderer == \"function\" ? renderer : renderer[node.listItem]) || components.unknownListItem;\n\t\tif (Li === components.unknownListItem) {\n\t\t\tlet style = node.listItem || \"bullet\";\n\t\t\thandleMissingComponent(unknownListItemStyleWarning(style), {\n\t\t\t\ttype: style,\n\t\t\t\tnodeType: \"listItemStyle\"\n\t\t\t});\n\t\t}\n\t\tlet children = tree.children;\n\t\tif (node.style && node.style !== \"normal\") {\n\t\t\tlet { listItem: _listItem, ...blockNode } = node;\n\t\t\tchildren = renderNode({\n\t\t\t\tnode: blockNode,\n\t\t\t\tindex,\n\t\t\t\tisInline: !1,\n\t\t\t\trenderNode\n\t\t\t});\n\t\t}\n\t\treturn /* @__PURE__ */ jsx(Li, {\n\t\t\tvalue: node,\n\t\t\tindex,\n\t\t\tisInline: !1,\n\t\t\trenderNode,\n\t\t\tchildren\n\t\t}, key);\n\t}\n\tfunction renderList(node, index, key) {\n\t\tlet children = node.children.map((child, childIndex) => renderNode({\n\t\t\tnode: child._key ? child : {\n\t\t\t\t...child,\n\t\t\t\t_key: `li-${index}-${childIndex}`\n\t\t\t},\n\t\t\tindex: childIndex,\n\t\t\tisInline: !1,\n\t\t\trenderNode\n\t\t})), component = components.list, List = (typeof component == \"function\" ? component : component[node.listItem]) || components.unknownList;\n\t\tif (List === components.unknownList) {\n\t\t\tlet style = node.listItem || \"bullet\";\n\t\t\thandleMissingComponent(unknownListStyleWarning(style), {\n\t\t\t\tnodeType: \"listStyle\",\n\t\t\t\ttype: style\n\t\t\t});\n\t\t}\n\t\treturn /* @__PURE__ */ jsx(List, {\n\t\t\tvalue: node,\n\t\t\tindex,\n\t\t\tisInline: !1,\n\t\t\trenderNode,\n\t\t\tchildren\n\t\t}, key);\n\t}\n\tfunction renderSpan(node, _index, key) {\n\t\tlet { markDef, markType, markKey } = node, Span = components.marks[markType] || components.unknownMark, children = node.children.map((child, childIndex) => renderNode({\n\t\t\tnode: child,\n\t\t\tindex: childIndex,\n\t\t\tisInline: !0,\n\t\t\trenderNode\n\t\t}));\n\t\treturn Span === components.unknownMark && handleMissingComponent(unknownMarkWarning(markType), {\n\t\t\tnodeType: \"mark\",\n\t\t\ttype: markType\n\t\t}), /* @__PURE__ */ jsx(Span, {\n\t\t\ttext: spanToPlainText(node),\n\t\t\tvalue: markDef,\n\t\t\tmarkType,\n\t\t\tmarkKey,\n\t\t\trenderNode,\n\t\t\tchildren\n\t\t}, key);\n\t}\n\tfunction renderBlock(node, index, key, isInline) {\n\t\tlet { _key, ...props } = serializeBlock({\n\t\t\tnode,\n\t\t\tindex,\n\t\t\tisInline,\n\t\t\trenderNode\n\t\t}), style = props.node.style || \"normal\", Block = (typeof components.block == \"function\" ? components.block : components.block[style]) || components.unknownBlockStyle;\n\t\treturn Block === components.unknownBlockStyle && handleMissingComponent(unknownBlockStyleWarning(style), {\n\t\t\tnodeType: \"blockStyle\",\n\t\t\ttype: style\n\t\t}), /* @__PURE__ */ jsx(Block, {\n\t\t\t...props,\n\t\t\tvalue: props.node,\n\t\t\trenderNode\n\t\t}, key);\n\t}\n\tfunction renderText(node, key) {\n\t\tif (node.text === \"\\n\") {\n\t\t\tlet HardBreak = components.hardBreak;\n\t\t\treturn HardBreak ? /* @__PURE__ */ jsx(HardBreak, {}, key) : \"\\n\";\n\t\t}\n\t\treturn node.text;\n\t}\n\tfunction renderUnknownType(node, index, key, isInline) {\n\t\tlet nodeOptions = {\n\t\t\tvalue: node,\n\t\t\tisInline,\n\t\t\tindex,\n\t\t\trenderNode\n\t\t};\n\t\thandleMissingComponent(unknownTypeWarning(node._type), {\n\t\t\tnodeType: \"block\",\n\t\t\ttype: node._type\n\t\t});\n\t\tlet UnknownType = components.unknownType;\n\t\treturn /* @__PURE__ */ jsx(UnknownType, { ...nodeOptions }, key);\n\t}\n\tfunction renderCustomBlock(node, index, key, isInline) {\n\t\tlet nodeOptions = {\n\t\t\tvalue: node,\n\t\t\tisInline,\n\t\t\tindex,\n\t\t\trenderNode\n\t\t}, Node = components.types[node._type];\n\t\treturn Node ? /* @__PURE__ */ jsx(Node, { ...nodeOptions }, key) : null;\n\t}\n\treturn renderNode;\n};\nfunction serializeBlock(options) {\n\tlet { node, index, isInline, renderNode } = options, children = buildMarksTree(node).map((child, i) => renderNode({\n\t\tnode: child,\n\t\tisInline: !0,\n\t\tindex: i,\n\t\trenderNode\n\t}));\n\treturn {\n\t\t_key: node._key || `block-${index}`,\n\t\tchildren,\n\t\tindex,\n\t\tisInline,\n\t\tnode\n\t};\n}\nfunction noop() {}\nexport { PortableText, defaultComponents, mergeComponents, toPlainText };\n\n//# sourceMappingURL=index.js.map","import { type ComponentChildren, createContext, createElement } from \"preact\";\nimport { useContext, useEffect, useMemo, useState } from \"preact/hooks\";\nimport {\n PortableText,\n type PortableTextComponents,\n type PortableTextProps,\n type PortableTextTypeComponentProps,\n} from \"@portabletext/react\";\n\n/**\n * Renders Portable Text (https://github.com/portabletext/react-portabletext) into\n * Shopify Checkout UI Extension components.\n *\n * The `@portabletext/react` library ships default renderers that emit HTML DOM\n * elements (`<p>`, `<strong>`, `<a>`, ...). Those are meaningless inside a checkout\n * extension, which only supports Shopify's registered Polaris web components.\n * We therefore override every relevant renderer so the tree is composed entirely of\n * Polaris web components.\n *\n * Everything is keyed by node `_type`: the static `uiComponents` map picks the UI, and\n * the caller's `handlers` prop supplies each type's behavior inputs. Interactive nodes\n * own their state locally (checked/error per component instance) and reach\n * their handlers through PortableTextContext — so adding a new interactive type means\n * a component, a `types` map entry, and a `handlers` entry; nothing else grows.\n *\n * The Portable Text comes from a partner's third-party API, so the content can't carry\n * behavior hints — a node's `_key` is its only stable handle. Checkbox toggles are\n * reported to `handlers.checkboxBlock.onChange` with that `_key`, and the caller\n * decides what the toggle means. The toggle applies optimistically; if the handler is\n * async and rejects, the checkbox rolls back and shows an error.\n */\n\n/** Emitted whenever a `checkboxBlock` checkbox is toggled. */\nexport interface CheckboxChangeEvent {\n /** The Portable Text node's `_key` — the content's only stable handle. */\n key: string;\n checked: boolean;\n}\n\n/** Caller inputs for `checkboxBlock` nodes (see PortableTextHandlers). */\nexport interface CheckboxBlockHandlers {\n /**\n * Controlled checked state per node `_key`, kept in sync with an external source of\n * truth. Whenever a listed key's value changes, that checkbox is updated to match —\n * on top of the optimistic local toggle, so a change driven from outside this tree\n * (e.g. the same opt-in toggled in another simultaneously-mounted extension instance,\n * propagated through shared checkout state) is reflected here. A listed key also seeds\n * the initial state. Unlisted keys stay purely local/uncontrolled and start unchecked.\n */\n checkedByKey?: Record<string, boolean>;\n /**\n * Called on every toggle with the node's `_key`; the caller decides what the\n * toggle means. May be async: the toggle applies optimistically, and if the returned\n * promise rejects the checkbox rolls back and shows an error.\n * Optional — without it checkboxes still toggle locally.\n */\n onChange?: (event: CheckboxChangeEvent) => void | Promise<void>;\n}\n\n/**\n * Caller inputs for interactive nodes, keyed by node `_type` — mirroring how the\n * `uiComponents.types` map is keyed. Supporting a new interactive type means adding\n * its entry here, its component, and its `types` map entry; nothing else grows.\n */\nexport interface PortableTextHandlers {\n checkboxBlock?: CheckboxBlockHandlers;\n}\n\ntype TextAppearance = \"subdued\" | \"info\" | \"success\" | \"warning\" | \"critical\";\ntype ParagraphType = \"paragraph\" | \"small\";\n\ntype PortableTextContextValue = PortableTextHandlers & {\n appearance?: TextAppearance;\n paragraphType?: ParagraphType;\n};\n\n/** Shape of a `checkboxBlock` node in the Portable Text value (see ./portable-text.ts). */\ninterface CheckboxBlockValue {\n _type: \"checkboxBlock\";\n _key: string;\n children: Array<{ _type: \"span\"; text: string; marks?: string[] }>;\n markDefs?: Array<{ _key: string; _type: string; [key: string]: unknown }>;\n}\n\n/**\n * Bridges the caller's handlers to the interactive block components. This is the only\n * shared surface — per-node interaction state lives inside each component instance.\n */\nconst PortableTextContext = createContext<PortableTextContextValue>({});\n\nfunction appearanceProps(appearance?: TextAppearance) {\n return appearance === \"subdued\"\n ? ({ color: \"subdued\" } as const)\n : ({ tone: appearance } as const);\n}\n\nfunction NormalBlock({ children }: { children?: ComponentChildren }) {\n const { appearance, paragraphType } = useContext(PortableTextContext);\n\n return (\n <s-paragraph type={paragraphType} {...appearanceProps(appearance)}>\n {children}\n </s-paragraph>\n );\n}\n\nfunction BlockquoteBlock({ children }: { children?: ComponentChildren }) {\n const { appearance, paragraphType } = useContext(PortableTextContext);\n\n return (\n <s-paragraph type={paragraphType} {...appearanceProps(appearance)}>\n <s-text type=\"emphasis\">{children}</s-text>\n </s-paragraph>\n );\n}\n\nfunction StrongMark({ children }: { children?: ComponentChildren }) {\n const { appearance } = useContext(PortableTextContext);\n\n return (\n <s-text type=\"strong\" {...appearanceProps(appearance)}>\n {children}\n </s-text>\n );\n}\n\nfunction EmphasisMark({ children }: { children?: ComponentChildren }) {\n const { appearance } = useContext(PortableTextContext);\n\n return (\n <s-text type=\"emphasis\" {...appearanceProps(appearance)}>\n {children}\n </s-text>\n );\n}\n\nfunction LinkMark({\n children,\n value,\n}: {\n children?: ComponentChildren;\n value?: { href?: string };\n}) {\n const { appearance } = useContext(PortableTextContext);\n\n return (\n <s-link\n href={value?.href}\n target=\"_blank\"\n tone={appearance ? \"neutral\" : undefined}\n >\n {children}\n </s-link>\n );\n}\n\nfunction UnknownMark({ children }: { children?: ComponentChildren }) {\n const { appearance } = useContext(PortableTextContext);\n\n return <s-text {...appearanceProps(appearance)}>{children}</s-text>;\n}\n\n/**\n * Renders a `checkboxBlock` node as a <Checkbox>. The component owns its own\n * checked/error state; toggles are reported to the caller's `onChange` optimistically —\n * a rejected handler rolls the checkbox back and shows an error.\n */\nfunction CheckboxBlock({\n value,\n index,\n renderNode,\n}: PortableTextTypeComponentProps<CheckboxBlockValue>) {\n const { checkedByKey, onChange } =\n useContext(PortableTextContext).checkboxBlock ?? {};\n // The externally-controlled value for this node, if any. `undefined` means this\n // checkbox is purely local (uncontrolled) and starts unchecked.\n const externalChecked = checkedByKey?.[value._key];\n const [checked, setChecked] = useState(externalChecked ?? false);\n const [error, setError] = useState<string | undefined>(undefined);\n\n // Reconcile with the external source of truth. A local toggle already updates\n // `checked` optimistically (and, for the controlling caller, flows back out to become\n // the next `externalChecked` — a no-op here); this effect exists for the other\n // direction: a change originating outside this tree, so the checkbox stays in sync.\n useEffect(() => {\n if (externalChecked !== undefined) {\n setChecked(externalChecked);\n }\n }, [externalChecked]);\n\n async function handleChange(next: boolean) {\n const previousChecked = checked;\n\n // Optimistic update; the handler's outcome settles it below.\n setChecked(next);\n\n if (!onChange) {\n return;\n }\n\n setError(undefined);\n\n try {\n await onChange({ key: value._key, checked: next });\n } catch {\n // Roll back if the handler fails.\n setChecked(previousChecked);\n setError(\"Something went wrong. Please try again.\");\n }\n }\n\n // Custom types aren't given a pre-rendered `children` tree, so build the label by\n // routing the node's spans back through `renderNode` as a normal block. That keeps\n // `strong`, links, etc. — e.g. the emphasized \"$10.00 Cash Back\" — instead of\n // flattening to plain text.\n const label = renderNode({\n node: { ...value, _type: \"block\" },\n index,\n isInline: false,\n renderNode,\n });\n\n return createElement(\n \"s-checkbox\",\n {\n checked,\n error,\n onChange: (event: Event) =>\n handleChange(\n (event.currentTarget as HTMLElementTagNameMap[\"s-checkbox\"])\n .checked ?? false,\n ),\n },\n <s-text slot=\"label\">{label}</s-text>,\n );\n}\n\n/**\n * The complete `_type` -> UI mapping. Static and module-level: interactive components\n * pull the caller's inputs from context and hold their own state, so this map is never\n * rebuilt. Includes safe fallbacks: the library's defaults for unknown marks/types/hard\n * breaks emit raw DOM (`<span>`, `<div>`, `<br>`), which would break the remote UI\n * reconciler.\n */\nconst uiComponents: PortableTextComponents = {\n // Block styles. Every Portable Text block carries a `style` (defaulting to\n // \"normal\"); each maps to a block-level Text container. Children are the already\n // rendered inline spans (plain strings and/or mark <Text>/<Link> elements).\n // Every standard style must be overridden here: the library merges this map\n // per-style with its DOM defaults, so an unlisted style (e.g. \"h1\") would render\n // a raw <h1> and crash the remote UI reconciler.\n block: {\n normal: NormalBlock,\n h1: ({ children }) => <s-heading>{children}</s-heading>,\n blockquote: BlockquoteBlock,\n },\n\n // Inline marks. Decorators (strong/em) have no `value`; annotations (link)\n // receive their markDef as `value`.\n marks: {\n strong: StrongMark,\n em: EmphasisMark,\n link: LinkMark,\n // Note: the `color` annotation is intentionally not declared. Checkout <Text>\n // can't take raw hex, and we're not mapping it to a semantic appearance for now,\n // so it falls through to `unknownMark` below and renders in the default color.\n // Revisit if honoring the author's color becomes a hard requirement.\n },\n\n // Custom object types (anything whose `_type` is not \"block\").\n types: {\n checkboxBlock: CheckboxBlock,\n },\n\n unknownMark: UnknownMark,\n unknownType: () => null,\n hardBreak: false,\n};\n\ninterface PortableTextRendererProps {\n /** Portable Text value: a single block or an array of blocks. */\n value: PortableTextProps[\"value\"];\n /**\n * Caller inputs for interactive nodes, keyed by node `_type`. Optional — without\n * it interactive nodes still work locally. Keep the reference stable (memoized or\n * module-level) to avoid re-rendering interactive nodes on unrelated re-renders.\n */\n handlers?: PortableTextHandlers;\n /** Gap between top-level blocks. Defaults to \"base\". */\n spacing?: \"none\" | \"extraTight\" | \"tight\" | \"base\" | \"loose\" | \"extraLoose\";\n /** Optional Shopify semantic tone applied to rendered text. */\n appearance?: TextAppearance;\n /** Optional Shopify paragraph size applied to rendered text blocks. */\n type?: ParagraphType;\n}\n\nconst gapBySpacing = {\n none: \"none\",\n extraTight: \"small-400\",\n tight: \"small-200\",\n base: \"base\",\n loose: \"large-200\",\n extraLoose: \"large-500\",\n} as const;\n\nexport default function PortableTextRenderer({\n value,\n handlers,\n spacing = \"base\",\n appearance,\n type,\n}: PortableTextRendererProps) {\n // Normalized so context consumers can assume an object even when the prop is\n // omitted, without falling back to a fresh {} identity per render.\n const contextValue = useMemo<PortableTextContextValue>(\n () => ({ ...(handlers ?? {}), appearance, paragraphType: type }),\n [handlers, appearance, type],\n );\n\n return (\n <PortableTextContext.Provider value={contextValue}>\n <s-stack gap={gapBySpacing[spacing]}>\n <PortableText\n value={value}\n components={uiComponents}\n // Portable Text usually comes from a CMS (Sanity); missing renderers\n // are a content/schema issue, not something to crash checkout over.\n onMissingComponent={false}\n />\n </s-stack>\n </PortableTextContext.Provider>\n );\n}\n","import { boolean, nullable, object, optional, string } from \"zod/mini\";\n\nexport const ATTRIBUTE_KEY = \"prepurchase_incentive_opted_in\";\n\nconst prepurchaseAttributeSchema = object({\n optedIn: boolean(),\n trackingTicketId: nullable(string()),\n idempotencyKey: nullable(string()),\n insertionId: nullable(string()),\n // The tracking session the opt-in happened in, carried across to the thank-you page\n // so the events fired there attribute to the same session as the checkout ones —\n // `session_id` is issued with the incentive and never re-fetched post-purchase.\n sessionId: optional(nullable(string())),\n});\n\nexport type PrepurchaseAttribute = {\n optedIn: boolean;\n trackingTicketId: string | null;\n idempotencyKey: string | null;\n insertionId: string | null;\n sessionId: string | null;\n};\n\nconst DEFAULT_ATTRIBUTE: PrepurchaseAttribute = {\n optedIn: false,\n trackingTicketId: null,\n idempotencyKey: null,\n insertionId: null,\n sessionId: null,\n};\n\nexport const encodePrepurchaseAttribute = (\n value: PrepurchaseAttribute,\n): string => JSON.stringify(value);\n\nexport const decodePrepurchaseAttribute = (\n raw: string | undefined,\n): PrepurchaseAttribute => {\n if (!raw) {\n return DEFAULT_ATTRIBUTE;\n }\n\n // JSON.parse throws on malformed input, and a non-object payload (e.g. `true`)\n // fails the object schema — both fall back to the default. `sessionId` remains\n // optional while decoding so attributes written before that field existed work.\n try {\n const parsed = prepurchaseAttributeSchema.safeParse(JSON.parse(raw));\n if (!parsed.success) {\n return DEFAULT_ATTRIBUTE;\n }\n\n return {\n optedIn: parsed.data.optedIn,\n trackingTicketId: parsed.data.trackingTicketId ?? null,\n idempotencyKey: parsed.data.idempotencyKey ?? null,\n insertionId: parsed.data.insertionId ?? null,\n sessionId: parsed.data.sessionId ?? null,\n };\n } catch {\n return DEFAULT_ATTRIBUTE;\n }\n};\n","import {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"preact/hooks\";\nimport {\n useApi,\n useApplyAttributeChange,\n useAttributeValues,\n} from \"@shopify/ui-extensions/checkout/preact\";\n\nimport { type PortableTextProps } from \"@portabletext/react\";\n\nimport { type EligibleIncentiveResponse } from \"./useGetIncentive.js\";\nimport {\n ATTRIBUTE_KEY,\n decodePrepurchaseAttribute,\n encodePrepurchaseAttribute,\n} from \"../attribute.js\";\nimport { useEventTracker } from \"../tracking/tracking-manager.js\";\n\n/** `_type` of the opt-in node in the partner's Portable Text content. */\nconst CHECKBOX_BLOCK_TYPE = \"checkboxBlock\";\n\nexport type PrepurchaseOptInInput = Pick<\n EligibleIncentiveResponse,\n \"incentive\" | \"tracking_ticket_id\" | \"idempotency_key\" | \"session_id\"\n>;\n\n/**\n * Everything a prepurchase widget variant needs: the opt-in state, the toggle that\n * persists it, and the copy derived from the incentive.\n *\n * This is the whole behavior of the widget — the attribute write, the optimistic\n * checkbox and its rollback, and the tracking. Variants differ only in how they lay\n * that out, so keeping it here is what stops one variant from silently getting a fix\n * (or a regression) the other doesn't.\n */\nexport type PrepurchaseOptIn = {\n checked: boolean;\n error: string | undefined;\n onToggle: (nextChecked: boolean) => Promise<void>;\n rewardText: string;\n rewardLabel: string;\n addedLabel: string;\n ctaLabel: string;\n yesCtaLabel: string;\n optInChoiceLabel: string;\n totalLabel: string;\n contentBlocks: PortableTextProps[\"value\"];\n logoUrl: string;\n};\n\nexport function usePrepurchaseOptIn({\n incentive,\n tracking_ticket_id,\n idempotency_key,\n session_id,\n}: PrepurchaseOptInInput): PrepurchaseOptIn {\n const applyAttributeChange = useApplyAttributeChange();\n const { i18n } = useApi();\n const { track } = useEventTracker();\n\n const [rawAttribute] = useAttributeValues([ATTRIBUTE_KEY]);\n const stored = decodePrepurchaseAttribute(rawAttribute);\n const optedIn =\n stored.optedIn && stored.trackingTicketId === tracking_ticket_id;\n\n // Optimistic checkbox state: the attribute write is async, so the box would otherwise\n // lag the tap. The attribute stays the source of truth — see the reconciling effect\n // below — and a failed write rolls this back.\n const [checked, setChecked] = useState(optedIn);\n const [error, setError] = useState<string | undefined>(undefined);\n\n // Reconcile with the attribute. A local toggle already set `checked` optimistically and\n // flows back through here as a no-op; this effect exists for the other direction — a\n // change made outside this tree, e.g. the same opt-in toggled in the other extension\n // target's copy of the widget, propagated through shared checkout state.\n useEffect(() => {\n setChecked(optedIn);\n }, [optedIn]);\n\n // `reward` is integer minor units plus a scale (e.g. { amount: 3000, scale: 2 } -> 30),\n // while `formatCurrency` takes major units. The currency is passed explicitly because\n // the reward is denominated by the partner, not by the checkout.\n const rewardAmount = incentive.reward.amount / 10 ** incentive.reward.scale;\n // A whole reward reads as \"$30\", not \"$30.00\". Only the minimum is set: the maximum\n // defaults to the currency's own precision, so a reward with cents still shows them\n // (\"$29.99\"), and pinning the minimum to 2 in that case keeps a trailing zero from\n // being dropped (\"$29.90\", not \"$29.9\").\n const rewardText = i18n.formatCurrency(rewardAmount, {\n currency: incentive.reward.currency,\n minimumFractionDigits: Number.isInteger(rewardAmount) ? 0 : 2,\n });\n const rewardLabel = `${rewardText} Cash Back from this order`;\n // Replaces the opt-in control once the buyer has opted in — the offer is no longer\n // something to take, so it's stated as done. Shown by the confirmation variants.\n const addedLabel = `${rewardText} Cash Back added`;\n // The button variant's call to action. Phrased as the action being taken, since\n // unlike a checkbox a button carries no state of its own for the buyer to read.\n const ctaLabel = `Get ${rewardText} cash back`;\n // The call to action for the variants that pair it with a decline control. The pair\n // poses a yes/no question the lone CTA doesn't, so this opens with the answer, and it\n // drops \"cash back\" because the heading above and the button beside it already frame\n // what is being taken — the two buttons share a row, so the shorter label is also what\n // keeps declining from being squeezed to the edge.\n const yesCtaLabel = `Yes, get ${rewardText}`;\n // The radio variant's affirmative choice. It answers a question rather than issuing\n // the call to action `ctaLabel` does, so it opens with the answer and names the reward\n // as the buyer's — the radio's own label is what a screen reader reads back, so \"Yes\"\n // alone would leave the selection meaningless out of context.\n const optInChoiceLabel = `Yes, get my ${rewardText} cash back`;\n\n // The total row reads as a checkout line item, so it keeps the currency's own precision\n // (\"$0.00\", \"$15.00\") rather than dropping a whole reward's cents like `rewardLabel`.\n // It's the reward only while the buyer is opted in — the total earned from this order,\n // which is zero until the box is checked.\n const totalLabel = i18n.formatCurrency(checked ? rewardAmount : 0, {\n currency: incentive.reward.currency,\n });\n\n // The partner content leads with the opt-in node (\"Get $30 Cash Back from Rakuten\"),\n // which the <Checkbox> replaces — so it's dropped from the copy we render. It has to be\n // filtered out here rather than left for the renderer to skip: the node carries a\n // `children` array of spans, and @portabletext/react classifies any such node as a text\n // block regardless of its `_type`, so an unhandled `checkboxBlock` renders its spans as\n // ordinary copy instead of falling through to `unknownType`.\n const contentBlocks = useMemo<PortableTextProps[\"value\"]>(() => {\n const blocks = incentive.display.blocks;\n return Array.isArray(blocks)\n ? blocks.filter((block) => block._type !== CHECKBOX_BLOCK_TYPE)\n : blocks;\n }, [incentive.display.blocks]);\n\n const brandProperties = useMemo(\n () => ({\n offerId: crypto.randomUUID(),\n advertiserId: incentive.advertiser_id,\n insertionId: incentive.insertion_id,\n }),\n [incentive.advertiser_id, incentive.insertion_id],\n );\n\n useEffect(() => {\n track({\n type: \"BRAND_DISPLAY\",\n target: \"INLINE_SLOT\",\n brand: brandProperties,\n });\n }, [track, brandProperties]);\n\n // The value of a write that hasn't landed yet, so a toggle that double-fires doesn't\n // send the same write twice. Only covers the in-flight window — once the write lands\n // `rawAttribute` carries the value and the dedupe below takes over. A ref (not state)\n // because a write must never trigger a re-render.\n const inFlightRef = useRef<string | null>(null);\n\n // Persist the opt-in choice (plus the tracking ticket) into the checkout attribute.\n // We write on toggle rather than in a buyer-journey interceptor: calling an update API\n // inside the interceptor mutates checkout data, which re-fires the interceptor, looping\n // until it trips Shopify's mutation rate limit. The thank-you page only acts when\n // `optedIn` is true, and that write carries the ticket, so there's nothing to persist\n // for a buyer who never toggles.\n //\n // Redundant writes are skipped by comparing against the attribute's live value, not a\n // memo of what this instance last wrote: both extension targets write this same key, so\n // one target's record of its own last write stops describing the attribute the moment\n // the other target writes — dropping a genuinely needed re-toggle and leaving the\n // attribute contradicting the checkbox.\n //\n // On failure we throw rather than swallow, so the caller rolls the checkbox back and\n // shows an error. Leaving it checked would show the buyer a checked box while the\n // attribute — the only thing the thank-you page reads — says they never opted in.\n // Throwing still doesn't block the purchase; it just marks the opt-in as not taken.\n const writeAttribute = useCallback(\n async (nextOptedIn: boolean) => {\n const value = encodePrepurchaseAttribute({\n optedIn: nextOptedIn,\n trackingTicketId: tracking_ticket_id,\n idempotencyKey: idempotency_key,\n insertionId: incentive.insertion_id,\n sessionId: session_id,\n });\n if (value === rawAttribute || value === inFlightRef.current) return;\n\n inFlightRef.current = value;\n try {\n const result = await applyAttributeChange({\n type: \"updateAttribute\",\n key: ATTRIBUTE_KEY,\n value,\n });\n // applyAttributeChange reports failure via the result rather than rejecting;\n // throw so `onToggle` rolls the checkbox back and shows an error.\n if (result.type !== \"success\") {\n console.error(result.message);\n throw new Error(result.message);\n }\n } finally {\n inFlightRef.current = null;\n }\n },\n [\n applyAttributeChange,\n tracking_ticket_id,\n idempotency_key,\n session_id,\n incentive.insertion_id,\n rawAttribute,\n ],\n );\n\n const onToggle = useCallback(\n async (nextChecked: boolean) => {\n const previousChecked = checked;\n\n setChecked(nextChecked);\n setError(undefined);\n\n track({\n type: \"ELEMENT_CLICK\",\n target: nextChecked ? \"OPT_IN\" : \"OPT_OUT\",\n brand: brandProperties,\n });\n\n try {\n await writeAttribute(nextChecked);\n } catch {\n // The attribute is the only thing the thank-you page reads, so a failed write\n // has to roll the checkbox back — leaving it checked would show the buyer an\n // opt-in that was never recorded. `writeAttribute` already logged the reason.\n setChecked(previousChecked);\n setError(\"Something went wrong. Please try again.\");\n }\n },\n [checked, track, brandProperties, writeAttribute],\n );\n\n return {\n checked,\n error,\n onToggle,\n rewardText,\n rewardLabel,\n addedLabel,\n ctaLabel,\n yesCtaLabel,\n optInChoiceLabel,\n totalLabel,\n contentBlocks,\n logoUrl: incentive.display.logo_url,\n };\n}\n","import { type ComponentChildren } from \"preact\";\n\n/**\n * The pieces every prepurchase widget variant is built from. A variant composes these\n * and decides what to show when; none of them holds state, so behavior stays in\n * `usePrepurchaseOptIn` and layout differences stay in the variant.\n */\n\n/**\n * The opt-in control: a checkbox with the reward beside it.\n *\n * The default row lets the Polaris checkbox own its visible label. The emphasized form\n * gives the checkbox an accessible label and renders matching strong, clickable text\n * beside it, while the checked state still comes from the persisted checkout attribute.\n */\nexport function OptInCheckboxRow({\n label,\n checked,\n onToggle,\n emphasized = false,\n}: {\n label: string;\n checked: boolean;\n onToggle: (next: boolean) => void;\n emphasized?: boolean;\n}) {\n if (emphasized) {\n return (\n <s-stack direction=\"inline\" gap=\"small-400\" alignItems=\"center\">\n <s-checkbox\n checked={checked}\n accessibilityLabel={label}\n onChange={(event) =>\n onToggle(\n (event.currentTarget as HTMLElementTagNameMap[\"s-checkbox\"])\n .checked ?? false,\n )\n }\n />\n <s-clickable type=\"button\" onClick={() => onToggle(!checked)}>\n <s-text type=\"strong\">{label}</s-text>\n </s-clickable>\n </s-stack>\n );\n }\n\n return (\n <s-checkbox\n checked={checked}\n label={label}\n onChange={(event) =>\n onToggle(\n (event.currentTarget as HTMLElementTagNameMap[\"s-checkbox\"])\n .checked ?? false,\n )\n }\n />\n );\n}\n\n/** The ids of the two choices, which are also what `ChoiceList`'s values are compared against. */\nconst OPT_IN_CHOICE = \"yes\";\nconst OPT_OUT_CHOICE = \"no\";\n\n/**\n * The pair of radios the yes/no variants are built from, selected and answered by\n * whichever of them renders it.\n *\n * `ChoiceList` renders radios unless `multiple` is enabled. Its `values` prop keeps the\n * current radio synchronized with the persisted checkout attribute, including after a\n * failed write rolls the buyer back, while each choice's `defaultSelected` initializes\n * the selection before the custom element has finished upgrading.\n *\n * \"No thanks\" carries no reward text of its own — it answers a question posed above it — so a\n * variant using either wrapper below must name the offer itself, the way the button\n * variants do with `RewardHeading`. `optInLabel` restates the reward on the affirmative\n * choice, which is the one whose wording a buyer has to be sure of before selecting it.\n */\nfunction YesNoChoiceList({\n label,\n optInLabel,\n value,\n onChange,\n}: {\n label: string;\n optInLabel: string;\n value: string;\n onChange: (value: string) => void;\n}) {\n // Both extension targets mount their own copy of the widget at every viewport — the\n // one that doesn't belong to the current breakpoint is hidden with `display`, not\n // unmounted — so a fixed `name` puts two separate copies' radios into one radio group,\n // where checking either copy's \"No thanks\" unchecks the other's. The copy that loses\n // is whichever the host renders first, which is why the selection is missing on one\n // breakpoint and correct on the other. Scoping the name to the target gives each copy\n // a group of its own.\n const { target } = shopify.extension;\n\n return (\n <s-choice-list\n name={`prepurchase-opt-in-${target}`}\n values={[value]}\n onChange={(event) =>\n onChange(\n (event.currentTarget as HTMLElementTagNameMap[\"s-choice-list\"])\n .values?.[0] ?? \"\",\n )\n }\n >\n {/* The affirmative choice names the reward in its own label, so it needs no\n\t\t\t `accessibilityLabel` — one would only override the visible wording with\n\t\t\t different words for the buyer navigating by voice. \"No thanks\" still needs one:\n\t\t\t the offer is stated above the radios, so on its own it tells a screen\n\t\t\t reader nothing about what is being declined. */}\n <s-choice value={OPT_IN_CHOICE} defaultSelected={value === OPT_IN_CHOICE}>\n {optInLabel}\n </s-choice>\n <s-choice\n value={OPT_OUT_CHOICE}\n defaultSelected={value === OPT_OUT_CHOICE}\n accessibilityLabel={`No thanks — ${label}`}\n >\n No thanks\n </s-choice>\n </s-choice-list>\n );\n}\n\n/**\n * The opt-in control as a yes/no question, for the variants where taking the offer is\n * one-way: a pair of radios pinned to \"No thanks\".\n *\n * The value is hardcoded to the declining choice because the control only renders while\n * the buyer has not opted in — the one selection that changes that unmounts the whole\n * control, and a write that fails rolls the buyer back to exactly this state, so there\n * is no third state for a selection to hold.\n *\n * Selecting \"No thanks\" runs nothing. It is already the state on screen, so opting out here\n * would write an attribute saying the buyer declined where previously there was no\n * attribute at all, and would report an `OPT_OUT` click for a choice that changed\n * nothing — neither of which the buyer's tap actually did.\n */\nexport function OptInYesNoChoice({\n label,\n optInLabel,\n onOptIn,\n}: {\n label: string;\n optInLabel: string;\n onOptIn: () => void;\n}) {\n return (\n <YesNoChoiceList\n label={label}\n optInLabel={optInLabel}\n value={OPT_OUT_CHOICE}\n onChange={(value) => {\n if (value === OPT_IN_CHOICE) {\n onOptIn();\n }\n }}\n />\n );\n}\n\n/**\n * The same yes/no question as radios that behave like radios: the selection tracks the\n * opt-in and either choice writes it, so the buyer can move between them as often as\n * they like.\n *\n * Both directions go through the one toggle — the same call `OptInCheckboxRow` makes —\n * so declining after opting in writes the attribute the thank-you page reads and tracks\n * its `OPT_OUT`, rather than only clearing the radio on screen. Unlike\n * `OptInYesNoChoice` there is no state the control is already sitting in for the\n * decline to be a no-op against: while the buyer is opted in, \"No thanks\" is a real\n * change.\n */\nexport function OptInYesNoRadios({\n label,\n optInLabel,\n checked,\n onToggle,\n}: {\n label: string;\n optInLabel: string;\n checked: boolean;\n onToggle: (next: boolean) => void;\n}) {\n return (\n <YesNoChoiceList\n label={label}\n optInLabel={optInLabel}\n value={checked ? OPT_IN_CHOICE : OPT_OUT_CHOICE}\n onChange={(value) => onToggle(value === OPT_IN_CHOICE)}\n />\n );\n}\n\n/**\n * Sets the partner's logo beside the content it belongs to, as a trailing column of its own.\n *\n * Wraps rather than sits above so the logo marks everything it encloses — offer and terms\n * together read as the partner's — instead of only the row it adjoins. What a variant\n * leaves outside the wrapper stays full width beneath it, which is where a closing total\n * row belongs: inside, it would stop short of the right margin and leave its divider cut\n * off at the logo's edge.\n *\n * The logo trails the copy, so the buyer reads the offer first and the brand second, and\n * the checkbox keeps the left margin it has in every other variant — the column order is\n * the only thing separating this from a leading-logo layout.\n *\n * The column fixes the logo's size, since `Image` fills the space it's given. Square\n * logos keep the original compact treatment; wordmarks get a wider column and matching\n * aspect ratio so their lettering remains legible.\n *\n * The rounding is the `View`'s, not the image's: `Image` takes no `cornerRadius`, so the\n * corners have to be clipped by a wrapper that does — which is why it carries\n * `overflow=\"hidden\"`, without which the radius is set but nothing is cut to it.\n *\n * `blockAlignment` must stay set to something — the value is a design choice, but the\n * default is not one of the options. A column left to default stretches to the row's full\n * height, so the wrapper's rounded bottom corners land at the foot of the terms copy, far\n * below the image, leaving the image's own square bottom edge on show while only its top\n * corners get clipped. Any explicit alignment shrinks the wrapper back onto the logo;\n * `center` then sets it against the middle of the offer and terms beside it.\n *\n * Renders the widget alone when there is no logo to show: the field is typed as always\n * present, but an `Image` with an empty source is a broken image in the checkout, which\n * is worse than the layout this variant is measured against.\n */\nexport function WithPartnerLogo({\n source,\n children,\n format = \"square\",\n logoWidth,\n}: {\n source?: string;\n children: ComponentChildren;\n format?: \"square\" | \"wordmark\";\n // Overrides the format's width, optionally switching on the nearest\n // `s-query-container`'s width: `wide` above `containerAbove`, `narrow` otherwise.\n logoWidth?:\n | `${number}px`\n | {\n containerAbove: `${number}px`;\n wide: `${number}px`;\n narrow: `${number}px`;\n };\n}) {\n if (!source) {\n return <>{children}</>;\n }\n\n const aspectRatio = format === \"wordmark\" ? \"5/2\" : \"1\";\n // The responsive form uses a bare `1fr` because the query's fallback is\n // comma-separated, and so is `minmax(0, 1fr)`.\n const gridTemplateColumns =\n typeof logoWidth === \"object\"\n ? `@container (inline-size > ${logoWidth.containerAbove}) 1fr ${logoWidth.wide}, 1fr ${logoWidth.narrow}`\n : `minmax(0, 1fr) ${logoWidth ?? (format === \"wordmark\" ? \"128px\" : \"48px\")}`;\n\n return (\n <s-grid\n gridTemplateColumns={gridTemplateColumns}\n gap=\"base\"\n alignItems=\"center\"\n >\n {children}\n <s-box borderRadius=\"small\" overflow=\"hidden\">\n <s-image\n src={source}\n alt=\"Cash Back partner logo\"\n aspectRatio={aspectRatio}\n objectFit=\"contain\"\n />\n </s-box>\n </s-grid>\n );\n}\n\n/**\n * A `logoWidth` for `wordmark` logos: full size in the desktop main column, smaller on a\n * phone. Checkout exposes no viewport, so this keys off the widget's own width, which\n * runs ~44px under the viewport: at most ~386px on a phone (430px viewport). The\n * two-column desktop main column measured under 500px, so the threshold sits just above\n * the widest phone. Only takes effect inside an `s-query-container` spanning the widget.\n */\nexport const RESPONSIVE_WORDMARK_WIDTH = {\n containerAbove: \"400px\",\n wide: \"112px\",\n narrow: \"96px\",\n} as const;\n\nexport const RAKUTEN_WORDMARK_URL =\n \"https://static.rakuten.com/static/svg/rakuten/rak-logo-brand-v1.svg\";\n\n/**\n * The logo for a `wordmark`-format `WithPartnerLogo`. Rakuten's incentive logo is its\n * square mark, which reads poorly at wordmark width, so it's swapped for the full\n * wordmark; any other partner's logo is used as served.\n */\nexport function partnerWordmarkSource(logoUrl: string) {\n return logoUrl.includes(\"static.rakuten.com\")\n ? RAKUTEN_WORDMARK_URL\n : logoUrl;\n}\n\n/**\n * The reward, stated as a heading. For variants whose control carries no label of its\n * own — a button says what it does, not what's on offer — this is what names the offer.\n */\nexport function RewardHeading({ label }: { label: string }) {\n return <s-text type=\"strong\">{label}</s-text>;\n}\n\n/**\n * The opt-in, once taken. Replaces the control in the variants where opting in is\n * one-way, so it only ever renders for a buyer who is already opted in — which is why\n * `success` is hardcoded rather than derived from the opt-in state.\n */\nexport function OptInConfirmation({ label }: { label: string }) {\n return (\n <s-stack direction=\"inline\" gap=\"small-400\" alignItems=\"center\">\n <s-icon type=\"check-circle\" tone=\"success\" />\n <s-text type=\"strong\" tone=\"success\">\n {label}\n </s-text>\n </s-stack>\n );\n}\n\n/**\n * Takes the opt-in back, for the variants that let the buyer reverse it.\n *\n * Sits below the copy rather than beside the confirmation, so the buyer reads what the\n * offer is worth before the way out is in reach — the variant places it, including\n * which margin it sits on. Small and quiet on purpose: the confirmation is the outcome\n * the buyer wanted, and this is only the way back.\n *\n * A `Link` rather than a `Button`, so it can't compete with a variant's call to action\n * for the same tap.\n *\n * The variant supplies the wording, and how quiet the link is, where the defaults read\n * wrong against the control above it — nothing smaller than `extraSmall`, which is the\n * floor for a tap target this text still has to be legible as. The accessibility label\n * stays fixed on the action instead of the wording, so what the link does is stated the\n * same way whatever it is captioned or sized.\n */\nexport function OptInUndoLink({\n label = \"No thanks\",\n onPress,\n}: {\n label?: string;\n onPress: () => void;\n}) {\n return (\n <s-link\n onClick={onPress}\n accessibilityLabel=\"Remove Cash Back from this order\"\n >\n <s-text type=\"small\">{label}</s-text>\n </s-link>\n );\n}\n\n/**\n * A failed attribute write. `Checkbox`'s own `error` would render inside the narrow\n * first column of the row above, so it's surfaced as its own line instead.\n */\nexport function OptInError({ message }: { message: string }) {\n return (\n <s-text tone=\"critical\" type=\"small\">\n {message}\n </s-text>\n );\n}\n\n/**\n * The running total for this order, closing out the widget.\n *\n * Owns its divider so a variant can't render the section without the rule that\n * separates it from the copy above. The icon and both labels turn green once the buyer\n * has opted in, so the row reads as earned rather than as a static footer — `success`\n * is the theme's positive color, the only green available here since these primitives\n * don't accept raw colors.\n */\nexport function TotalCashBack({\n total,\n earned,\n}: {\n total: string;\n earned: boolean;\n}) {\n const tone = earned ? \"success\" : undefined;\n const color = earned ? undefined : \"subdued\";\n\n return (\n <>\n <s-divider />\n <s-grid gridTemplateColumns=\"1fr auto\" alignItems=\"center\">\n {/* Icon and label are stacked together in the first column: one `spacing`\n\t\t\t\t on the layout can't set both the gap inside the pair and the gap\n\t\t\t\t before the amount, which the `fill` column pushes to the far edge. */}\n <s-stack direction=\"inline\" gap=\"small-400\" alignItems=\"center\">\n <s-icon type=\"cash-dollar\" tone={earned ? \"success\" : \"neutral\"} />\n <s-text type=\"strong\" tone={tone} color={color}>\n TOTAL CASH BACK\n </s-text>\n </s-stack>\n <s-text type=\"strong\" tone={tone} color={color}>\n {total}\n </s-text>\n </s-grid>\n </>\n );\n}\n","import PortableTextRenderer from \"../../portable-text-renderer.js\";\nimport {\n usePrepurchaseOptIn,\n type PrepurchaseOptInInput,\n} from \"../../hooks/usePrepurchaseOptIn.js\";\nimport { OptInCheckboxRow, OptInError, TotalCashBack } from \"./shared.js\";\n\n/**\n * The `inline_checkbox` variant — the shipping widget.\n *\n * The checkbox is always on screen: after opting in it stays, checked, and the buyer\n * can uncheck it to opt back out. Contrast `inline_checkbox_confirmation`, where\n * opting in replaces the control outright.\n */\nexport function InlineCheckboxWidget(props: PrepurchaseOptInInput) {\n const { checked, error, onToggle, rewardLabel, totalLabel, contentBlocks } =\n usePrepurchaseOptIn(props);\n\n return (\n <s-stack gap=\"small-200\">\n <OptInCheckboxRow\n label={rewardLabel}\n checked={checked}\n onToggle={onToggle}\n />\n {error && <OptInError message={error} />}\n <PortableTextRenderer value={contentBlocks} spacing=\"tight\" />\n <TotalCashBack total={totalLabel} earned={checked} />\n </s-stack>\n );\n}\n","import PortableTextRenderer from \"../../portable-text-renderer.js\";\nimport {\n usePrepurchaseOptIn,\n type PrepurchaseOptInInput,\n} from \"../../hooks/usePrepurchaseOptIn.js\";\nimport {\n OptInCheckboxRow,\n OptInError,\n TotalCashBack,\n WithPartnerLogo,\n} from \"./shared.js\";\n\n/**\n * The `inline_checkbox_with_logo` variant.\n *\n * `inline_checkbox` — the same always-on checkbox the buyer can toggle back off — with\n * the partner's logo leading the widget as a column of its own. The logo is the only\n * difference between the two, so the pair isolates what showing a brand the buyer\n * already recognizes does to opt-in, uncrossed with any change to the control itself.\n */\nexport function InlineCheckboxWithLogoWidget(props: PrepurchaseOptInInput) {\n const {\n checked,\n error,\n onToggle,\n rewardLabel,\n totalLabel,\n contentBlocks,\n logoUrl,\n } = usePrepurchaseOptIn(props);\n\n return (\n <s-stack gap=\"small-200\">\n {/* Only the offer and the terms share the row with the logo. The total row\n\t\t\t sits outside the wrapper so it — and the divider it owns — runs the full\n\t\t\t width, closing out the widget beneath the logo rather than stopping at\n\t\t\t the logo's edge and leaving the rule short of the right margin. */}\n <WithPartnerLogo source={logoUrl}>\n <s-stack gap=\"small-200\">\n <OptInCheckboxRow\n label={rewardLabel}\n checked={checked}\n onToggle={onToggle}\n emphasized\n />\n {error && <OptInError message={error} />}\n <PortableTextRenderer\n value={contentBlocks}\n spacing=\"tight\"\n appearance=\"subdued\"\n />\n </s-stack>\n </WithPartnerLogo>\n <TotalCashBack total={totalLabel} earned={checked} />\n </s-stack>\n );\n}\n","import PortableTextRenderer from \"../../portable-text-renderer.js\";\nimport {\n usePrepurchaseOptIn,\n type PrepurchaseOptInInput,\n} from \"../../hooks/usePrepurchaseOptIn.js\";\n// Always the Rakuten wordmark: this variant is assigned only to Rakuten incentives.\nimport { OptInError, RAKUTEN_WORDMARK_URL } from \"./shared.js\";\n\n/**\n * The screenshot-inspired, standalone checkbox offer card. It intentionally omits\n * tiers, recommendations and the separate total row; the amount and legal copy still\n * come from the eligible incentive response rather than from the reference image.\n * Opt-in, rollback and tracking remain shared with the other checkout variants.\n */\nexport function InlineCheckboxLogoCardWidget(props: PrepurchaseOptInInput) {\n const { checked, error, onToggle, rewardText, contentBlocks } =\n usePrepurchaseOptIn(props);\n const offerLabel = `Get ${rewardText} Cash Back with`;\n\n return (\n <s-box border=\"base\" borderRadius=\"large\" padding=\"base\">\n <s-stack gap=\"small-400\">\n <s-stack\n direction=\"inline\"\n columnGap=\"none\"\n rowGap=\"small-200\"\n alignItems=\"center\"\n justifyContent=\"start\"\n >\n <s-checkbox\n checked={checked}\n label={offerLabel}\n accessibilityLabel={`${offerLabel} Rakuten`}\n onChange={(event) =>\n onToggle(\n (event.currentTarget as HTMLElementTagNameMap[\"s-checkbox\"])\n .checked ?? false,\n )\n }\n />\n <s-box inlineSize=\"80px\">\n <s-image\n src={RAKUTEN_WORDMARK_URL}\n alt=\"\"\n aspectRatio=\"4/1\"\n objectFit=\"contain\"\n inlineSize=\"fill\"\n />\n </s-box>\n </s-stack>\n <s-stack gap=\"small-200\">\n {error && <OptInError message={error} />}\n <PortableTextRenderer\n value={contentBlocks}\n spacing=\"tight\"\n appearance=\"subdued\"\n type=\"small\"\n />\n </s-stack>\n </s-stack>\n </s-box>\n );\n}\n","import PortableTextRenderer from \"../../portable-text-renderer.js\";\nimport {\n usePrepurchaseOptIn,\n type PrepurchaseOptInInput,\n} from \"../../hooks/usePrepurchaseOptIn.js\";\nimport {\n OptInCheckboxRow,\n OptInConfirmation,\n OptInError,\n TotalCashBack,\n} from \"./shared.js\";\n\n/**\n * The `inline_checkbox_confirmation` variant.\n *\n * Opting in swaps the checkbox out for a green confirmation, and the swap is one-way:\n * the control unmounts and nothing takes its place that can write the attribute back,\n * so within this checkout the opt-in is final. Contrast `inline_checkbox`, where the\n * control persists and stays togglable.\n */\nexport function InlineCheckboxConfirmationWidget(props: PrepurchaseOptInInput) {\n const {\n checked,\n error,\n onToggle,\n rewardLabel,\n addedLabel,\n totalLabel,\n contentBlocks,\n } = usePrepurchaseOptIn(props);\n\n return (\n <s-stack gap=\"small-200\">\n {checked ? (\n <OptInConfirmation label={addedLabel} />\n ) : (\n <OptInCheckboxRow\n label={rewardLabel}\n checked={checked}\n onToggle={onToggle}\n />\n )}\n {error && <OptInError message={error} />}\n <PortableTextRenderer value={contentBlocks} spacing=\"tight\" />\n <TotalCashBack total={totalLabel} earned={checked} />\n </s-stack>\n );\n}\n","import PortableTextRenderer from \"../../portable-text-renderer.js\";\nimport {\n usePrepurchaseOptIn,\n type PrepurchaseOptInInput,\n} from \"../../hooks/usePrepurchaseOptIn.js\";\nimport {\n OptInConfirmation,\n OptInError,\n RewardHeading,\n TotalCashBack,\n} from \"./shared.js\";\n\n/**\n * The `inline_button_confirmation` variant.\n *\n * Same one-way opt-in as `inline_checkbox_confirmation`, and the same swap: the\n * heading turns into the confirmation. What differs is the control — a button below\n * the partner's copy rather than a checkbox above it, so the buyer reads the offer and\n * the terms before acting — and that the button simply goes away once used, leaving\n * the confirmed offer and its total.\n *\n * The reward is a heading of its own here rather than the control's label: a checkbox\n * is labelled with what's on offer, but a button is labelled with the action, so\n * without the heading nothing would name the offer above the copy.\n */\nexport function InlineButtonConfirmationWidget(props: PrepurchaseOptInInput) {\n const {\n checked,\n error,\n onToggle,\n rewardLabel,\n addedLabel,\n ctaLabel,\n totalLabel,\n contentBlocks,\n } = usePrepurchaseOptIn(props);\n\n return (\n <s-stack gap=\"small-200\">\n {checked ? (\n <OptInConfirmation label={addedLabel} />\n ) : (\n <RewardHeading label={rewardLabel} />\n )}\n <PortableTextRenderer value={contentBlocks} spacing=\"tight\" />\n {/* Opting in is all this button does, so it only ever sends `true`, and once\n\t\t\t it has it unmounts for good — the confirmation above is the state it\n\t\t\t leaves behind, and nothing takes the button's place. A failed write rolls\n\t\t\t `checked` back, which brings the button back alongside the error. */}\n {!checked && (\n <s-button tone=\"neutral\" onClick={() => onToggle(true)}>\n {ctaLabel}\n </s-button>\n )}\n {error && <OptInError message={error} />}\n <TotalCashBack total={totalLabel} earned={checked} />\n </s-stack>\n );\n}\n","import PortableTextRenderer from \"../../portable-text-renderer.js\";\nimport {\n usePrepurchaseOptIn,\n type PrepurchaseOptInInput,\n} from \"../../hooks/usePrepurchaseOptIn.js\";\nimport {\n OptInConfirmation,\n OptInError,\n OptInYesNoChoice,\n RewardHeading,\n TotalCashBack,\n} from \"./shared.js\";\n\n/**\n * The `inline_radio_confirmation` variant.\n *\n * The same one-way opt-in as the other confirmation variants, asked as a question: the\n * offer is stated as a heading and answered with a pair of radios that starts on \"No\n * thanks\". Taking the offer sends both radios with it — there is no control left to\n * answer the question a second time — leaving the confirmation in their place.\n *\n * What this isolates against `inline_checkbox_confirmation` is the cost of declining: an\n * unchecked box is the buyer doing nothing, while \"No thanks\" is a choice they have to\n * make on the record before the checkout will look settled.\n *\n * \"No thanks\" is inert, not an opt-out — see `OptInYesNoChoice`. It is where the control\n * already sits, including after a failed write rolls the buyer back.\n */\nexport function InlineRadioConfirmationWidget(props: PrepurchaseOptInInput) {\n const {\n checked,\n error,\n onToggle,\n rewardLabel,\n optInChoiceLabel,\n addedLabel,\n totalLabel,\n contentBlocks,\n } = usePrepurchaseOptIn(props);\n\n return (\n <s-stack gap=\"small-200\">\n {/* The heading goes with the radios it poses the question for: kept alongside\n\t\t\t the confirmation it would restate as an offer (\"$30 Cash Back from this\n\t\t\t order\") what the line below it already states as done. */}\n {checked ? (\n <OptInConfirmation label={addedLabel} />\n ) : (\n <>\n <RewardHeading label={rewardLabel} />\n <OptInYesNoChoice\n label={rewardLabel}\n optInLabel={optInChoiceLabel}\n onOptIn={() => onToggle(true)}\n />\n </>\n )}\n {error && <OptInError message={error} />}\n <PortableTextRenderer value={contentBlocks} spacing=\"tight\" />\n <TotalCashBack total={totalLabel} earned={checked} />\n </s-stack>\n );\n}\n","import PortableTextRenderer from \"../../portable-text-renderer.js\";\nimport {\n usePrepurchaseOptIn,\n type PrepurchaseOptInInput,\n} from \"../../hooks/usePrepurchaseOptIn.js\";\nimport {\n OptInCheckboxRow,\n OptInConfirmation,\n OptInError,\n OptInUndoLink,\n TotalCashBack,\n} from \"./shared.js\";\n\n/**\n * The `inline_checkbox_confirmation_undo` variant.\n *\n * `inline_checkbox_confirmation` — the checkbox swapped out for a green confirmation —\n * with the swap no longer one-way: a \"No thanks\" link below the copy brings the\n * checkbox back, unchecked, and writes the opt-out. It pairs against that variant to\n * measure what an unmistakable way out is worth on a control the buyer otherwise can't\n * take back, and against `inline_checkbox`, where the way out is the same box they\n * checked and nothing announces it.\n *\n * Undoing is not a dead end either: the checkbox that returns opts back in, so the\n * buyer can cross between the two states as often as they like.\n */\nexport function InlineCheckboxConfirmationUndoWidget(\n props: PrepurchaseOptInInput,\n) {\n const {\n checked,\n error,\n onToggle,\n rewardLabel,\n addedLabel,\n totalLabel,\n contentBlocks,\n } = usePrepurchaseOptIn(props);\n\n return (\n <s-stack gap=\"small-200\">\n {checked ? (\n <OptInConfirmation label={addedLabel} />\n ) : (\n <OptInCheckboxRow\n label={rewardLabel}\n checked={checked}\n onToggle={onToggle}\n />\n )}\n {error && <OptInError message={error} />}\n <PortableTextRenderer value={contentBlocks} spacing=\"tight\" />\n {/* Declining is the opt-out, so it goes through the same toggle the\n\t\t\t checkbox does — which writes the attribute the thank-you page reads,\n\t\t\t tracks the `OPT_OUT`, and surfaces its own failure above rather than\n\t\t\t silently leaving the buyer opted in. Below the copy, so the buyer reads\n\t\t\t what they'd be giving up before the way out is in reach.\n\n\t\t\t A `View` only to move the link off the left margin: a `BlockStack` child\n\t\t\t fills the row, so the link needs a container that positions it rather\n\t\t\t than a spacing value, and `end` puts it on the same edge the total below\n\t\t\t it ends on. */}\n {checked && (\n <s-stack alignItems=\"end\">\n <OptInUndoLink onPress={() => onToggle(false)} />\n </s-stack>\n )}\n <TotalCashBack total={totalLabel} earned={checked} />\n </s-stack>\n );\n}\n","import PortableTextRenderer from \"../../portable-text-renderer.js\";\nimport {\n usePrepurchaseOptIn,\n type PrepurchaseOptInInput,\n} from \"../../hooks/usePrepurchaseOptIn.js\";\nimport {\n OptInConfirmation,\n OptInError,\n RewardHeading,\n TotalCashBack,\n} from \"./shared.js\";\n\n/**\n * The `inline_button_confirmation_decline` variant.\n *\n * `inline_button_confirmation` with a \"No thanks\" button set beside the call to action.\n * The opt-in path is unchanged — the same one-way toggle, the same confirmation in the\n * heading's place, the same pair of buttons unmounting once it is taken — so the pair\n * isolates what putting a way to decline next to the offer does to the offer's uptake.\n *\n * Declining is deliberately inert: it writes nothing, opts nobody out, and leaves the\n * widget exactly as it is. A buyer who means it simply moves on with the checkout, and\n * the exposure row for this variant plus an absent opt-in already says so. Should the\n * decline need to be recorded, it wants a real `OPT_OUT` toggle rather than an `onPress`\n * added here for the tracking alone — the attribute and the event are written together\n * in `usePrepurchaseOptIn`, and splitting them is how the two start disagreeing.\n */\nexport function InlineButtonConfirmationDeclineWidget(\n props: PrepurchaseOptInInput,\n) {\n const {\n checked,\n error,\n onToggle,\n rewardLabel,\n addedLabel,\n yesCtaLabel,\n totalLabel,\n contentBlocks,\n } = usePrepurchaseOptIn(props);\n\n return (\n <s-stack gap=\"small-200\">\n {checked ? (\n <OptInConfirmation label={addedLabel} />\n ) : (\n <RewardHeading label={rewardLabel} />\n )}\n <PortableTextRenderer value={contentBlocks} spacing=\"tight\" />\n {/* Both buttons go together once the offer is taken: \"No thanks\" beside a\n\t\t\t confirmation would read as a way to give the Cash Back back, which is not\n\t\t\t what it does. The call to action takes the `fill` column so declining\n\t\t\t stays the smaller of the two targets, and `secondary` keeps it visually\n\t\t\t subordinate to the monochrome CTA. Its label answers the pair as a\n\t\t\t question (\"Yes, get $30\") rather than standing alone the way\n\t\t\t `inline_button_confirmation`'s `ctaLabel` does. */}\n {!checked && (\n <s-grid gridTemplateColumns=\"1fr auto\" gap=\"base\" alignItems=\"center\">\n <s-button tone=\"neutral\" onClick={() => onToggle(true)}>\n {yesCtaLabel}\n </s-button>\n {/* No `onPress`: pressing this is meant to do nothing at all. */}\n <s-button variant=\"secondary\" tone=\"neutral\">\n No thanks\n </s-button>\n </s-grid>\n )}\n {error && <OptInError message={error} />}\n <TotalCashBack total={totalLabel} earned={checked} />\n </s-stack>\n );\n}\n","import PortableTextRenderer from \"../../portable-text-renderer.js\";\nimport {\n usePrepurchaseOptIn,\n type PrepurchaseOptInInput,\n} from \"../../hooks/usePrepurchaseOptIn.js\";\nimport {\n OptInConfirmation,\n OptInError,\n OptInUndoLink,\n OptInYesNoChoice,\n RewardHeading,\n TotalCashBack,\n} from \"./shared.js\";\n\n/**\n * The `inline_radio_confirmation_undo` variant.\n *\n * `inline_radio_confirmation` — the offer posed as a question, answered by a pair of\n * radios sitting on \"No thanks\", with the confirmation replacing heading and radios\n * together — with the swap no longer one-way: a \"No cash back\" link below the copy\n * brings the question back and writes the opt-out. It pairs against that variant to\n * measure what an unmistakable way out is worth once the buyer has answered, the same\n * thing `inline_checkbox_confirmation_undo` measures against its checkbox.\n *\n * Undoing is not a dead end: the radios that return opt back in, so the buyer can cross\n * between the two states as often as they like. They return sitting on \"No thanks\" —\n * `OptInYesNoChoice` hardcodes that value, and the remount after an undo is one more\n * state it holds nothing local for — which is also the state the undo just put the\n * buyer in, so the control agrees with the attribute behind it.\n */\nexport function InlineRadioConfirmationUndoWidget(\n props: PrepurchaseOptInInput,\n) {\n const {\n checked,\n error,\n onToggle,\n rewardLabel,\n optInChoiceLabel,\n addedLabel,\n totalLabel,\n contentBlocks,\n } = usePrepurchaseOptIn(props);\n\n return (\n <s-stack gap=\"small-200\">\n {/* The heading goes with the radios it poses the question for: kept alongside\n\t\t\t the confirmation it would restate as an offer (\"$30 Cash Back from this\n\t\t\t order\") what the line below it already states as done. */}\n {checked ? (\n <OptInConfirmation label={addedLabel} />\n ) : (\n <>\n <RewardHeading label={rewardLabel} />\n <OptInYesNoChoice\n label={rewardLabel}\n optInLabel={optInChoiceLabel}\n onOptIn={() => onToggle(true)}\n />\n </>\n )}\n {error && <OptInError message={error} />}\n <PortableTextRenderer value={contentBlocks} spacing=\"tight\" />\n {/* Declining here is the opt-out, so it goes through the same toggle the\n\t\t\t radios do — which writes the attribute the thank-you page reads, tracks\n\t\t\t the `OPT_OUT`, and surfaces its own failure above rather than silently\n\t\t\t leaving the buyer opted in. It is captioned \"No cash back\" rather than\n\t\t\t the shared default so it doesn't read as the \"No thanks\" radio the buyer\n\t\t\t saw before opting in — that radio is inert, being the state already on\n\t\t\t screen, and this link is the one decline in the variant that writes\n\t\t\t anything.\n\n\t\t\t Below the copy, so the buyer reads what they'd be giving up before the way\n\t\t\t out is in reach. A `View` only to move the link off the left margin: a\n\t\t\t `BlockStack` child fills the row, so the link needs a container that\n\t\t\t positions it rather than a spacing value, and `end` puts it on the same\n\t\t\t edge the total below it ends on. */}\n {checked && (\n <s-stack alignItems=\"end\">\n <OptInUndoLink label=\"No cash back\" onPress={() => onToggle(false)} />\n </s-stack>\n )}\n <TotalCashBack total={totalLabel} earned={checked} />\n </s-stack>\n );\n}\n","import PortableTextRenderer from \"../../portable-text-renderer.js\";\nimport {\n usePrepurchaseOptIn,\n type PrepurchaseOptInInput,\n} from \"../../hooks/usePrepurchaseOptIn.js\";\nimport {\n OptInError,\n OptInYesNoRadios,\n RewardHeading,\n TotalCashBack,\n} from \"./shared.js\";\n\n/**\n * The `inline_radio` variant.\n *\n * `inline_radio_confirmation`'s layout — the offer stated as a heading, answered by a\n * pair of radios — with the radios behaving as radios ordinarily do: they stay on\n * screen, the selection sits on whichever answer the buyer has given, and moving it to\n * \"No thanks\" opts back out. Nothing is swapped out and nothing is final, so the\n * question the widget poses stays answerable for as long as the checkout is open.\n *\n * It is to `inline_radio_confirmation` what `inline_checkbox` is to\n * `inline_checkbox_confirmation`, and pairs against it to measure what the one-way\n * confirmation is worth on its own — the same opt-in, minus the swap.\n *\n * The heading stays put rather than giving way to `OptInConfirmation`: the radios never\n * leave, so a confirmation line would sit above a control still asking the question it\n * claims to have settled. What marks the opt-in as taken is the affirmative radio\n * holding the selection, plus the total below turning green.\n */\nexport function InlineRadioWidget(props: PrepurchaseOptInInput) {\n const {\n checked,\n error,\n onToggle,\n rewardLabel,\n optInChoiceLabel,\n totalLabel,\n contentBlocks,\n } = usePrepurchaseOptIn(props);\n\n return (\n <s-stack gap=\"small-200\">\n <RewardHeading label={rewardLabel} />\n <OptInYesNoRadios\n label={rewardLabel}\n optInLabel={optInChoiceLabel}\n checked={checked}\n onToggle={onToggle}\n />\n {error && <OptInError message={error} />}\n <PortableTextRenderer value={contentBlocks} spacing=\"tight\" />\n <TotalCashBack total={totalLabel} earned={checked} />\n </s-stack>\n );\n}\n","import PortableTextRenderer from \"../../portable-text-renderer.js\";\nimport {\n usePrepurchaseOptIn,\n type PrepurchaseOptInInput,\n} from \"../../hooks/usePrepurchaseOptIn.js\";\nimport {\n OptInError,\n OptInYesNoRadios,\n partnerWordmarkSource,\n RESPONSIVE_WORDMARK_WIDTH,\n RewardHeading,\n TotalCashBack,\n WithPartnerLogo,\n} from \"./shared.js\";\n\n/**\n * The `inline_radio_with_large_logo` variant.\n *\n * Keeps `inline_radio`'s reversible yes/no control and places the partner wordmark beside\n * the radio choices. The terms and total stay outside that two-column layout so both span\n * the full widget width beneath it.\n */\nexport function InlineRadioWithLargeLogoWidget(props: PrepurchaseOptInInput) {\n const {\n checked,\n error,\n onToggle,\n rewardLabel,\n optInChoiceLabel,\n totalLabel,\n contentBlocks,\n logoUrl,\n } = usePrepurchaseOptIn(props);\n\n // The query container wraps the whole widget so it measures the checkout column\n // rather than shrinking to the logo row; full-width rows below keep it at slot width.\n return (\n <s-query-container>\n <s-stack gap=\"small-200\">\n <RewardHeading label={rewardLabel} />\n <WithPartnerLogo\n source={partnerWordmarkSource(logoUrl)}\n format=\"wordmark\"\n logoWidth={RESPONSIVE_WORDMARK_WIDTH}\n >\n <OptInYesNoRadios\n label={rewardLabel}\n optInLabel={optInChoiceLabel}\n checked={checked}\n onToggle={onToggle}\n />\n </WithPartnerLogo>\n {error && <OptInError message={error} />}\n <PortableTextRenderer value={contentBlocks} spacing=\"tight\" />\n <TotalCashBack total={totalLabel} earned={checked} />\n </s-stack>\n </s-query-container>\n );\n}\n","const CASH_BACK_TIERS = [\n { minimumSubtotalCents: 0, cashBack: 5 },\n { minimumSubtotalCents: 2_500, cashBack: 10 },\n { minimumSubtotalCents: 7_000, cashBack: 15 },\n { minimumSubtotalCents: 10_000, cashBack: 20 },\n { minimumSubtotalCents: 14_000, cashBack: 25 },\n { minimumSubtotalCents: 17_500, cashBack: 30 },\n] as const;\n\nexport type CashBackTierProgress = {\n currentCashBack: number;\n currentMinimumCents: number;\n nextCashBack?: number;\n nextMinimumCents?: number;\n remainingCents: number;\n progressCents: number;\n progressMaximumCents: number;\n};\n\n/**\n * Calculates progress within the buyer's current tier using integer cents, avoiding\n * floating-point errors at exact boundaries such as $35 and $70.\n */\nexport function getCashBackTierProgress(\n subtotalCents: number,\n): CashBackTierProgress {\n const safeSubtotalCents = Math.max(0, Math.round(subtotalCents));\n let currentTierIndex = 0;\n\n for (let index = 1; index < CASH_BACK_TIERS.length; index += 1) {\n if (safeSubtotalCents < CASH_BACK_TIERS[index]!.minimumSubtotalCents) {\n break;\n }\n currentTierIndex = index;\n }\n\n const currentTier = CASH_BACK_TIERS[currentTierIndex]!;\n const nextTier = CASH_BACK_TIERS[currentTierIndex + 1];\n\n if (!nextTier) {\n return {\n currentCashBack: currentTier.cashBack,\n currentMinimumCents: currentTier.minimumSubtotalCents,\n remainingCents: 0,\n progressCents: 1,\n progressMaximumCents: 1,\n };\n }\n\n return {\n currentCashBack: currentTier.cashBack,\n currentMinimumCents: currentTier.minimumSubtotalCents,\n nextCashBack: nextTier.cashBack,\n nextMinimumCents: nextTier.minimumSubtotalCents,\n remainingCents: nextTier.minimumSubtotalCents - safeSubtotalCents,\n progressCents: safeSubtotalCents - currentTier.minimumSubtotalCents,\n progressMaximumCents:\n nextTier.minimumSubtotalCents - currentTier.minimumSubtotalCents,\n };\n}\n","import { getCashBackTierProgress } from \"./cash-back-tiers.js\";\n\n/** The spend-to-next-tier summary and progress bar used by the tier radio variant. */\nexport function TierProgress() {\n const { i18n } = shopify;\n const subtotal = shopify.cost.subtotalAmount.value;\n const subtotalCents = Math.round(subtotal.amount * 100);\n const tier = getCashBackTierProgress(subtotalCents);\n const formatMoney = (amount: number, keepCents = false) =>\n i18n.formatCurrency(amount, {\n currency: subtotal.currencyCode,\n minimumFractionDigits: keepCents ? 2 : Number.isInteger(amount) ? 0 : 2,\n });\n\n if (tier.nextCashBack === undefined || tier.nextMinimumCents === undefined) {\n const topCashBack = formatMoney(tier.currentCashBack);\n\n return (\n <s-stack gap=\"small-200\">\n <s-text type=\"strong\">\n Top tier unlocked: {topCashBack} cash back\n </s-text>\n <s-progress\n value={tier.progressCents}\n max={tier.progressMaximumCents}\n accessibilityLabel={`${topCashBack} top cash back tier unlocked`}\n />\n <s-text color=\"subdued\" type=\"small\">\n {topCashBack} back at {formatMoney(175)}+\n </s-text>\n </s-stack>\n );\n }\n\n const currentCashBack = formatMoney(tier.currentCashBack);\n const nextCashBack = formatMoney(tier.nextCashBack);\n const remaining = formatMoney(tier.remainingCents / 100, true);\n const currentSubtotal = formatMoney(subtotalCents / 100, true);\n const nextMinimum = formatMoney(tier.nextMinimumCents / 100);\n\n return (\n <s-stack gap=\"small-200\">\n <s-text type=\"strong\">\n Add {remaining} more to unlock {nextCashBack} cash back\n </s-text>\n <s-progress\n // Preact never forwards value={0} to s-progress, so checkout shows the indeterminate\n // animation at exact tier minimums. Floor at an invisible sliver until that's fixed.\n // https://community.shopify.dev/t/bug-s-progress-value-not-set-in-dom-when-value-passed-is-0/32637\n value={Math.max(tier.progressCents, 0.01)}\n max={tier.progressMaximumCents}\n accessibilityLabel={`${currentSubtotal} spent; ${remaining} more to unlock ${nextCashBack} cash back`}\n />\n <s-grid gridTemplateColumns=\"1fr auto\" gap=\"base\">\n <s-text color=\"subdued\" type=\"small\">\n {currentCashBack} back at {currentSubtotal}\n </s-text>\n <s-text color=\"subdued\" type=\"small\">\n {nextCashBack} back at {nextMinimum}\n </s-text>\n </s-grid>\n </s-stack>\n );\n}\n","import PortableTextRenderer from \"../../portable-text-renderer.js\";\nimport {\n usePrepurchaseOptIn,\n type PrepurchaseOptInInput,\n} from \"../../hooks/usePrepurchaseOptIn.js\";\nimport {\n OptInError,\n OptInYesNoRadios,\n RewardHeading,\n TotalCashBack,\n} from \"./shared.js\";\nimport { TierProgress } from \"./tier-progress.js\";\n\n/**\n * The `inline_radio_with_tier_progress` variant.\n *\n * Keeps `inline_radio`'s reversible yes/no control and adds the buyer's progress from\n * their current cash-back tier to the next one before the offer terms.\n */\nexport function InlineRadioWithTierProgressWidget(\n props: PrepurchaseOptInInput,\n) {\n const {\n checked,\n error,\n onToggle,\n rewardLabel,\n optInChoiceLabel,\n totalLabel,\n contentBlocks,\n } = usePrepurchaseOptIn(props);\n\n return (\n <s-stack gap=\"small-200\">\n <RewardHeading label={rewardLabel} />\n <OptInYesNoRadios\n label={rewardLabel}\n optInLabel={optInChoiceLabel}\n checked={checked}\n onToggle={onToggle}\n />\n {error && <OptInError message={error} />}\n <TierProgress />\n <PortableTextRenderer value={contentBlocks} spacing=\"tight\" />\n <TotalCashBack total={totalLabel} earned={checked} />\n </s-stack>\n );\n}\n","import PortableTextRenderer from \"../../portable-text-renderer.js\";\nimport {\n usePrepurchaseOptIn,\n type PrepurchaseOptInInput,\n} from \"../../hooks/usePrepurchaseOptIn.js\";\nimport {\n OptInError,\n OptInYesNoRadios,\n partnerWordmarkSource,\n RESPONSIVE_WORDMARK_WIDTH,\n RewardHeading,\n TotalCashBack,\n WithPartnerLogo,\n} from \"./shared.js\";\nimport { TierProgress } from \"./tier-progress.js\";\n\n/**\n * The `inline_radio_with_tier_progress_large_logo` variant.\n *\n * `inline_radio_with_tier_progress` with the partner wordmark beside the radio choices,\n * as in `inline_radio_with_large_logo`. Tier progress, the terms and the total stay\n * outside that two-column layout at full widget width.\n */\nexport function InlineRadioWithTierProgressWithLargeLogoWidget(\n props: PrepurchaseOptInInput,\n) {\n const {\n checked,\n error,\n onToggle,\n rewardLabel,\n optInChoiceLabel,\n totalLabel,\n contentBlocks,\n logoUrl,\n } = usePrepurchaseOptIn(props);\n\n // The query container wraps the whole widget so it measures the checkout column\n // rather than shrinking to the logo row; full-width rows below keep it at slot width.\n return (\n <s-query-container>\n <s-stack gap=\"small-200\">\n <RewardHeading label={rewardLabel} />\n <WithPartnerLogo\n source={partnerWordmarkSource(logoUrl)}\n format=\"wordmark\"\n logoWidth={RESPONSIVE_WORDMARK_WIDTH}\n >\n <OptInYesNoRadios\n label={rewardLabel}\n optInLabel={optInChoiceLabel}\n checked={checked}\n onToggle={onToggle}\n />\n </WithPartnerLogo>\n {error && <OptInError message={error} />}\n <TierProgress />\n <PortableTextRenderer value={contentBlocks} spacing=\"tight\" />\n <TotalCashBack total={totalLabel} earned={checked} />\n </s-stack>\n </s-query-container>\n );\n}\n","export type ApplyCartLinesChange = (change: {\n type: \"addCartLine\";\n merchandiseId: string;\n quantity: number;\n}) => Promise<{ type: \"success\" } | { type: \"error\"; message: string }>;\n\nexport async function addQuickAddProduct(\n applyCartLinesChange: ApplyCartLinesChange,\n merchandiseId: string,\n): Promise<void> {\n const result = await applyCartLinesChange({\n type: \"addCartLine\",\n merchandiseId,\n quantity: 1,\n });\n\n if (result.type === \"error\") {\n throw new Error(\"Product couldn't be added to the cart.\");\n }\n}\n","import { useCallback, useState } from \"preact/hooks\";\nimport { useApplyCartLinesChange } from \"@shopify/ui-extensions/checkout/preact\";\n\nimport { addQuickAddProduct } from \"../quick-add-cart.js\";\n\nexport function useAddCartProduct() {\n const applyCartLinesChange = useApplyCartLinesChange();\n const [addingVariantId, setAddingVariantId] = useState<string>();\n const [error, setError] = useState<string>();\n\n const addProduct = useCallback(\n async (variantId: string) => {\n if (addingVariantId) return;\n\n setAddingVariantId(variantId);\n setError(undefined);\n try {\n await addQuickAddProduct(applyCartLinesChange, variantId);\n } catch (caught) {\n console.error(caught);\n setError(\"This product couldn't be added. Please try again.\");\n } finally {\n setAddingVariantId(undefined);\n }\n },\n [addingVariantId, applyCartLinesChange],\n );\n\n return { addProduct, addingVariantId, error };\n}\n","export type QuickAddProduct = {\n id: string;\n title: string;\n productTitle: string;\n priceCents: number;\n currencyCode: string;\n availableForSale: boolean;\n imageUrl?: string;\n imageAlt?: string;\n};\n\nexport type QuickAddProductsQueryData = {\n products?: {\n nodes?: Array<{\n title?: string;\n featuredImage?: { url?: string; altText?: string | null } | null;\n variants?: {\n nodes?: Array<{\n id?: string;\n title?: string;\n availableForSale?: boolean;\n currentlyNotInStock?: boolean;\n price?: { amount?: string; currencyCode?: string } | null;\n image?: { url?: string; altText?: string | null } | null;\n }>;\n };\n }>;\n };\n};\n\nexport function parseQuickAddProducts(\n data: QuickAddProductsQueryData,\n): QuickAddProduct[] {\n return (data.products?.nodes ?? []).flatMap((product) => {\n const variant = product.variants?.nodes?.find(\n (candidate) =>\n candidate.availableForSale && !candidate.currentlyNotInStock,\n );\n const price = Number(variant?.price?.amount);\n\n if (\n !variant?.id ||\n !variant.title ||\n !product.title ||\n !variant.price?.currencyCode ||\n !Number.isFinite(price)\n ) {\n return [];\n }\n\n const image = variant.image ?? product.featuredImage;\n\n return [\n {\n id: variant.id,\n title: variant.title,\n productTitle: product.title,\n priceCents: Math.round(price * 100),\n currencyCode: variant.price.currencyCode,\n availableForSale: true,\n ...(image?.url ? { imageUrl: image.url } : {}),\n ...(image?.altText ? { imageAlt: image.altText } : {}),\n },\n ];\n });\n}\n\nexport function getQuickAddHeading(progress: {\n remainingCents: number;\n nextCashBack?: number;\n}): string | undefined {\n if (progress.nextCashBack === undefined || progress.remainingCents <= 0) {\n return undefined;\n }\n\n return \"Recommended products\";\n}\n\nexport function getQuickAddVariantLabel(\n productTitle: string,\n variantTitle: string,\n): string | undefined {\n if (variantTitle === \"Default Title\") return undefined;\n\n const normalize = (value: string) =>\n value\n .toLocaleLowerCase()\n .replace(/[^a-z0-9]+/g, \" \")\n .trim();\n const normalizedProductTitle = normalize(productTitle);\n const normalizedVariantTitle = normalize(variantTitle);\n\n if (\n normalizedVariantTitle === normalizedProductTitle ||\n normalizedVariantTitle.includes(normalizedProductTitle)\n ) {\n return undefined;\n }\n\n return variantTitle;\n}\n\nexport const QUICK_ADD_PRODUCTS_QUERY = `#graphql\n\tquery QuickAddProducts {\n\t\tproducts(first: 20, sortKey: BEST_SELLING) {\n\t\t\tnodes {\n\t\t\t\ttitle\n\t\t\t\tfeaturedImage {\n\t\t\t\t\turl\n\t\t\t\t\taltText\n\t\t\t\t}\n\t\t\t\tvariants(first: 10) {\n\t\t\t\t\tnodes {\n\t\t\t\t\t\tid\n\t\t\t\t\t\ttitle\n\t\t\t\t\t\tavailableForSale\n\t\t\t\t\t\tcurrentlyNotInStock\n\t\t\t\t\t\tprice {\n\t\t\t\t\t\t\tamount\n\t\t\t\t\t\t\tcurrencyCode\n\t\t\t\t\t\t}\n\t\t\t\t\t\timage {\n\t\t\t\t\t\t\turl\n\t\t\t\t\t\t\taltText\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n`;\n\nexport type LoadQuickAddProductsOptions = RankQuickAddProductsOptions & {\n remainingCents: number;\n};\n\nexport async function loadQuickAddProducts(\n query: (\n query: string,\n options: { version: \"2026-07\" },\n ) => Promise<{\n data?: QuickAddProductsQueryData;\n errors?: readonly unknown[];\n }>,\n options: LoadQuickAddProductsOptions,\n): Promise<QuickAddProduct[]> {\n const result = await query(QUICK_ADD_PRODUCTS_QUERY, {\n version: \"2026-07\",\n });\n\n if (result.errors?.length || !result.data) {\n throw new Error(\"Products couldn't be loaded.\");\n }\n\n return rankQuickAddProducts(\n parseQuickAddProducts(result.data),\n options.remainingCents,\n options,\n );\n}\n\nexport type RankQuickAddProductsOptions = {\n excludedVariantIds?: ReadonlySet<string>;\n maxProducts?: number;\n};\n\n/** Products may exceed the next-tier gap by at most $20. */\nconst MAX_QUICK_ADD_OVERSHOOT_CENTS = 2_000;\n\n/**\n * Ranks products against the amount needed for the next tier. Products that\n * reach the tier come first with the least overshoot, followed by products\n * below the gap with the closest price first. Products that overshoot the gap\n * by more than $20 are excluded as economically irrelevant.\n */\nexport function rankQuickAddProducts(\n products: readonly QuickAddProduct[],\n remainingCents: number,\n options: RankQuickAddProductsOptions = {},\n): QuickAddProduct[] {\n const gapCents = Math.max(0, Math.round(remainingCents));\n const { excludedVariantIds = new Set<string>(), maxProducts } = options;\n\n const ranked = products\n .filter(\n (product) =>\n product.availableForSale &&\n !excludedVariantIds.has(product.id) &&\n product.priceCents <= gapCents + MAX_QUICK_ADD_OVERSHOOT_CENTS,\n )\n .sort((left, right) => {\n const leftReachesTier = left.priceCents >= gapCents;\n const rightReachesTier = right.priceCents >= gapCents;\n\n if (leftReachesTier !== rightReachesTier) {\n return leftReachesTier ? -1 : 1;\n }\n\n if (leftReachesTier) {\n return left.priceCents - right.priceCents;\n }\n\n return right.priceCents - left.priceCents;\n });\n\n return maxProducts === undefined ? ranked : ranked.slice(0, maxProducts);\n}\n","import { useMemo } from \"preact/hooks\";\nimport { useQuery } from \"@tanstack/preact-query\";\nimport { useApi, useCartLines } from \"@shopify/ui-extensions/checkout/preact\";\n\nimport {\n loadQuickAddProducts,\n type QuickAddProductsQueryData,\n} from \"../quick-add-products.js\";\n\nconst MAX_QUICK_ADD_PRODUCTS = 8;\n\nexport function useQuickAddProducts(remainingCents: number, enabled: boolean) {\n const { query } = useApi();\n const cartLines = useCartLines();\n const cartVariantIds = useMemo(\n () => new Set(cartLines.map((line) => line.merchandise.id)),\n [cartLines],\n );\n\n return useQuery({\n queryKey: [\n \"quick-add-products\",\n remainingCents,\n ...Array.from(cartVariantIds).sort(),\n ],\n queryFn: () =>\n loadQuickAddProducts(\n (source, options) => query<QuickAddProductsQueryData>(source, options),\n {\n remainingCents,\n excludedVariantIds: cartVariantIds,\n maxProducts: MAX_QUICK_ADD_PRODUCTS,\n },\n ),\n enabled: enabled && remainingCents > 0,\n staleTime: 5 * 60 * 1_000,\n });\n}\n","import {\n useApi,\n useInstructions,\n} from \"@shopify/ui-extensions/checkout/preact\";\n\nimport { useAddCartProduct } from \"../../hooks/useAddCartProduct.js\";\nimport { useQuickAddProducts } from \"../../hooks/useQuickAddProducts.js\";\nimport {\n getQuickAddHeading,\n getQuickAddVariantLabel,\n type QuickAddProduct,\n} from \"../../quick-add-products.js\";\n\nexport function QuickAddProducts({\n remainingCents,\n nextCashBack,\n}: {\n remainingCents: number;\n nextCashBack?: number;\n}) {\n const { i18n } = useApi();\n // Some checkouts (draft orders, for example) don't allow adding lines at all, so\n // every \"Add to cart\" here would fail.\n const { canAddCartLine } = useInstructions().lines;\n const productsQuery = useQuickAddProducts(remainingCents, canAddCartLine);\n const { addProduct, addingVariantId, error } = useAddCartProduct();\n const heading = getQuickAddHeading({ remainingCents, nextCashBack });\n\n if (\n !canAddCartLine ||\n !heading ||\n productsQuery.isError ||\n (!productsQuery.isPending && !productsQuery.data?.length)\n ) {\n return null;\n }\n\n return (\n <s-box paddingBlock=\"base\">\n <s-stack gap=\"base\">\n <s-text type=\"strong\">{heading}</s-text>\n {productsQuery.isPending ? (\n <s-skeleton-paragraph content=\"Loading product suggestions\" />\n ) : productsQuery.data.length > 0 ? (\n <s-scroll-box overflow=\"hidden auto\">\n <s-grid\n gridTemplateColumns={`repeat(${productsQuery.data.length}, 304px)`}\n gap=\"small-400\"\n alignItems=\"stretch\"\n >\n {productsQuery.data.map((product) => (\n <QuickAddProductItem\n key={product.id}\n product={product}\n isAdding={addingVariantId === product.id}\n isDisabled={addingVariantId !== undefined}\n onAdd={() => addProduct(product.id)}\n formatCurrency={(amount, currency) =>\n i18n.formatCurrency(amount, {\n currency,\n })\n }\n />\n ))}\n </s-grid>\n </s-scroll-box>\n ) : null}\n {error ? (\n <s-text tone=\"critical\" type=\"small\">\n {error}\n </s-text>\n ) : null}\n </s-stack>\n </s-box>\n );\n}\n\nfunction QuickAddProductItem({\n product,\n isAdding,\n isDisabled,\n onAdd,\n formatCurrency,\n}: {\n product: QuickAddProduct;\n isAdding: boolean;\n isDisabled: boolean;\n onAdd: () => void;\n formatCurrency: (amount: number, currency: string) => string;\n}) {\n const price = formatCurrency(product.priceCents / 100, product.currencyCode);\n const variantTitle = getQuickAddVariantLabel(\n product.productTitle,\n product.title,\n );\n\n return (\n <s-box\n background=\"base\"\n border=\"base\"\n borderRadius=\"base\"\n padding=\"small-200\"\n blockSize=\"100%\"\n >\n <s-grid\n gridTemplateColumns=\"88px minmax(0, 1fr)\"\n gap=\"base\"\n alignItems=\"stretch\"\n blockSize=\"100%\"\n >\n <s-stack blockSize=\"100%\" justifyContent=\"center\">\n <ProductImage product={product} />\n </s-stack>\n <s-grid blockSize=\"100%\" gridTemplateRows=\"auto minmax(0, 1fr) auto\">\n <s-stack gap=\"small-100\">\n <s-text type=\"strong\">{product.productTitle}</s-text>\n {variantTitle ? (\n <s-text color=\"subdued\">{variantTitle}</s-text>\n ) : null}\n </s-stack>\n <s-box />\n <s-stack gap=\"small-300\">\n <s-text>{price}</s-text>\n <s-button\n accessibilityLabel={`Add ${product.productTitle} to cart`}\n disabled={isDisabled}\n loading={isAdding}\n onClick={onAdd}\n >\n Add to cart\n </s-button>\n </s-stack>\n </s-grid>\n </s-grid>\n </s-box>\n );\n}\n\nfunction ProductImage({ product }: { product: QuickAddProduct }) {\n return (\n <s-box\n background=\"subdued\"\n borderRadius=\"small\"\n blockSize=\"88px\"\n inlineSize=\"88px\"\n overflow=\"hidden\"\n >\n <s-image\n src={product.imageUrl ?? \"\"}\n alt={product.imageAlt ?? product.productTitle}\n aspectRatio=\"1\"\n objectFit=\"contain\"\n inlineSize=\"fill\"\n loading=\"lazy\"\n />\n </s-box>\n );\n}\n","import { useSubtotalAmount } from \"@shopify/ui-extensions/checkout/preact\";\n\nimport PortableTextRenderer from \"../../portable-text-renderer.js\";\nimport {\n usePrepurchaseOptIn,\n type PrepurchaseOptInInput,\n} from \"../../hooks/usePrepurchaseOptIn.js\";\nimport { getCashBackTierProgress } from \"./cash-back-tiers.js\";\nimport { QuickAddProducts } from \"./quick-add-products.js\";\nimport {\n OptInError,\n OptInYesNoRadios,\n RewardHeading,\n TotalCashBack,\n} from \"./shared.js\";\nimport { TierProgress } from \"./tier-progress.js\";\n\nexport function InlineRadioWithTierProgressAndQuickAddWidget(\n props: PrepurchaseOptInInput,\n) {\n const {\n checked,\n error,\n onToggle,\n rewardLabel,\n optInChoiceLabel,\n totalLabel,\n contentBlocks,\n } = usePrepurchaseOptIn(props);\n const subtotal =\n useSubtotalAmount<\"purchase.checkout.actions.render-before\">();\n const subtotalCents = Math.round(subtotal.amount * 100);\n const tier = getCashBackTierProgress(subtotalCents);\n\n return (\n <s-stack gap=\"small-200\">\n <RewardHeading label={rewardLabel} />\n <OptInYesNoRadios\n label={rewardLabel}\n optInLabel={optInChoiceLabel}\n checked={checked}\n onToggle={onToggle}\n />\n {error && <OptInError message={error} />}\n <TierProgress />\n <QuickAddProducts\n remainingCents={tier.remainingCents}\n nextCashBack={tier.nextCashBack}\n />\n <PortableTextRenderer value={contentBlocks} spacing=\"tight\" />\n <TotalCashBack total={totalLabel} earned={checked} />\n </s-stack>\n );\n}\n","import { useSubtotalAmount } from \"@shopify/ui-extensions/checkout/preact\";\n\nimport PortableTextRenderer from \"../../portable-text-renderer.js\";\nimport {\n usePrepurchaseOptIn,\n type PrepurchaseOptInInput,\n} from \"../../hooks/usePrepurchaseOptIn.js\";\nimport { getCashBackTierProgress } from \"./cash-back-tiers.js\";\nimport { QuickAddProducts } from \"./quick-add-products.js\";\nimport {\n OptInError,\n OptInYesNoRadios,\n partnerWordmarkSource,\n RESPONSIVE_WORDMARK_WIDTH,\n RewardHeading,\n TotalCashBack,\n WithPartnerLogo,\n} from \"./shared.js\";\nimport { TierProgress } from \"./tier-progress.js\";\n\n/**\n * The `inline_radio_with_tier_progress_quick_add_compact_large_logo` variant.\n *\n * `inline_radio_with_tier_progress_quick_add_compact` with the partner wordmark beside\n * the radio choices, as in `inline_radio_with_large_logo`. Tier progress, quick add, the\n * terms and the total stay outside that two-column layout at full widget width.\n */\nexport function InlineRadioWithTierProgressAndQuickAddWithLargeLogoWidget(\n props: PrepurchaseOptInInput,\n) {\n const {\n checked,\n error,\n onToggle,\n rewardLabel,\n optInChoiceLabel,\n totalLabel,\n contentBlocks,\n logoUrl,\n } = usePrepurchaseOptIn(props);\n const subtotal =\n useSubtotalAmount<\"purchase.checkout.actions.render-before\">();\n const subtotalCents = Math.round(subtotal.amount * 100);\n const tier = getCashBackTierProgress(subtotalCents);\n\n // The query container wraps the whole widget so it measures the checkout column\n // rather than shrinking to the logo row; full-width rows below keep it at slot width.\n return (\n <s-query-container>\n <s-stack gap=\"small-200\">\n <RewardHeading label={rewardLabel} />\n <WithPartnerLogo\n source={partnerWordmarkSource(logoUrl)}\n format=\"wordmark\"\n logoWidth={RESPONSIVE_WORDMARK_WIDTH}\n >\n <OptInYesNoRadios\n label={rewardLabel}\n optInLabel={optInChoiceLabel}\n checked={checked}\n onToggle={onToggle}\n />\n </WithPartnerLogo>\n {error && <OptInError message={error} />}\n <TierProgress />\n <QuickAddProducts\n remainingCents={tier.remainingCents}\n nextCashBack={tier.nextCashBack}\n />\n <PortableTextRenderer value={contentBlocks} spacing=\"tight\" />\n <TotalCashBack total={totalLabel} earned={checked} />\n </s-stack>\n </s-query-container>\n );\n}\n","import { type ComponentType } from \"preact\";\nimport { useEffect } from \"preact/hooks\";\n\nimport { type IncentiveResponse } from \"../hooks/useGetIncentive.js\";\nimport { type PrepurchaseOptInInput } from \"../hooks/usePrepurchaseOptIn.js\";\nimport { useEventTracker } from \"../tracking/tracking-manager.js\";\nimport { InlineCheckboxWidget } from \"./checkout/inline-checkbox.js\";\nimport { InlineCheckboxWithLogoWidget } from \"./checkout/inline-checkbox-with-logo.js\";\nimport { InlineCheckboxLogoCardWidget } from \"./checkout/inline-checkbox-logo-card.js\";\nimport { InlineCheckboxConfirmationWidget } from \"./checkout/inline-checkbox-confirmation.js\";\nimport { InlineButtonConfirmationWidget } from \"./checkout/inline-button-confirmation.js\";\nimport { InlineRadioConfirmationWidget } from \"./checkout/inline-radio-confirmation.js\";\nimport { InlineCheckboxConfirmationUndoWidget } from \"./checkout/inline-checkbox-confirmation-undo.js\";\nimport { InlineButtonConfirmationDeclineWidget } from \"./checkout/inline-button-confirmation-decline.js\";\nimport { InlineRadioConfirmationUndoWidget } from \"./checkout/inline-radio-confirmation-undo.js\";\nimport { InlineRadioWidget } from \"./checkout/inline-radio.js\";\nimport { InlineRadioWithLargeLogoWidget } from \"./checkout/inline-radio-with-large-logo.js\";\nimport { InlineRadioWithTierProgressWidget } from \"./checkout/inline-radio-with-tier-progress.js\";\nimport { InlineRadioWithTierProgressWithLargeLogoWidget } from \"./checkout/inline-radio-with-tier-progress-with-large-logo.js\";\nimport { InlineRadioWithTierProgressAndQuickAddWidget } from \"./checkout/inline-radio-with-tier-progress-and-quick-add.js\";\nimport { InlineRadioWithTierProgressAndQuickAddWithLargeLogoWidget } from \"./checkout/inline-radio-with-tier-progress-and-quick-add-with-large-logo.js\";\n\n/**\n * Maps the API's `widget_variant` onto a widget this bundle knows how to render.\n *\n * These cases are the only list of widget ids anywhere: the backend deliberately holds\n * none, passing the `prepurchase_widget_variant` flag value straight through — ids it\n * has never heard of included — so that shipping a new widget doesn't need a backend\n * deploy. The ids are append-only and name the widget's form rather than its position\n * in a test, because every value served is permanent in the warehouse's exposure rows;\n * redesigning a widget mints a new id (`inline_checkbox_v2`) instead of reusing one.\n */\nfunction resolveWidget(\n raw: string | undefined,\n): ComponentType<PrepurchaseOptInInput> {\n switch (raw) {\n case \"inline_checkbox_with_logo\":\n return InlineCheckboxWithLogoWidget;\n case \"inline_checkbox_rakuten_card\":\n return InlineCheckboxLogoCardWidget;\n case \"inline_checkbox_confirmation\":\n return InlineCheckboxConfirmationWidget;\n case \"inline_button_confirmation\":\n return InlineButtonConfirmationWidget;\n case \"inline_radio_confirmation\":\n return InlineRadioConfirmationWidget;\n case \"inline_checkbox_confirmation_undo\":\n return InlineCheckboxConfirmationUndoWidget;\n case \"inline_button_confirmation_decline\":\n return InlineButtonConfirmationDeclineWidget;\n case \"inline_radio_confirmation_undo\":\n return InlineRadioConfirmationUndoWidget;\n case \"inline_radio\":\n return InlineRadioWidget;\n case \"inline_radio_with_large_logo\":\n return InlineRadioWithLargeLogoWidget;\n case \"inline_radio_with_tier_progress\":\n return InlineRadioWithTierProgressWidget;\n case \"inline_radio_with_tier_progress_large_logo\":\n return InlineRadioWithTierProgressWithLargeLogoWidget;\n case \"inline_radio_with_tier_progress_quick_add_compact\":\n return InlineRadioWithTierProgressAndQuickAddWidget;\n case \"inline_radio_with_tier_progress_quick_add_compact_large_logo\":\n return InlineRadioWithTierProgressAndQuickAddWithLargeLogoWidget;\n // The fail-safe, covering both an id newer than this bundle and an absent field\n // — the backend omits `widget_variant` entirely when the flag yields nothing (an\n // uninitialized client, a missing flag, a prerequisite that gated the checkout\n // off), and records no exposure row for it, so rendering this widget claims no\n // assignment that GrowthBook never made. Must stay the same widget as the flag's\n // `defaultValue` in GrowthBook, currently `inline_checkbox` in every\n // environment: that default is what a live-but-unconfigured flag serves, and it\n // has a real exposure row behind it.\n default:\n return InlineCheckboxWidget;\n }\n}\n\nexport function PrepurchaseWidget({\n incentiveResponse,\n}: {\n incentiveResponse: IncentiveResponse;\n}) {\n const { track } = useEventTracker();\n\n useEffect(() => {\n track({ type: \"WIDGET_LOAD\" });\n track({ type: \"WIDGET_DISPLAY\" });\n }, [track]);\n\n // Narrow the union via the `in` operator: `incentive` can't act as a discriminant\n // (its non-null variant is a non-unit object type), so we key off the property\n // unique to the eligible member. Inside the guard the response is an\n // `EligibleIncentiveResponse` and carries the `tracking_ticket_id`.\n if (!(\"tracking_ticket_id\" in incentiveResponse)) {\n return null;\n }\n\n const Widget = resolveWidget(incentiveResponse.widget_variant);\n\n return (\n <Widget\n incentive={incentiveResponse.incentive}\n tracking_ticket_id={incentiveResponse.tracking_ticket_id}\n idempotency_key={incentiveResponse.idempotency_key}\n session_id={incentiveResponse.session_id}\n />\n );\n}\n","export const getShopIdentifier = (shopGid: string) => {\n return shopGid.replace(\"gid://shopify/Shop/\", \"\");\n};\n","import {\n useCustomer,\n useShop,\n useEmail,\n useSubtotalAmount,\n useCheckoutToken,\n useLocalizationCountry,\n} from \"@shopify/ui-extensions/checkout/preact\";\nimport { type PortableTextProps } from \"@portabletext/react\";\nimport { useQuery } from \"@tanstack/preact-query\";\nimport { email as emailSchema } from \"zod/mini\";\n\nimport { usePrepurchaseEndpoints } from \"../context.js\";\nimport { getShopIdentifier } from \"../utils.js\";\n\n// Integer minor units + scale + ISO-4217 currency (e.g. $49.99 -> { amount: 4999,\n// currency: \"USD\", scale: 2 }).\ntype Money = {\n amount: number;\n currency: string;\n scale: number;\n};\n\ntype Display = {\n blocks: PortableTextProps[\"value\"];\n logo_url: string;\n};\n\ntype Incentive = {\n reward: Money;\n display: Display;\n insertion_id: string;\n advertiser_id: string;\n};\n\nexport type IncentiveResponse =\n | IneligibleIncentiveResponse\n | EligibleIncentiveResponse;\n\ntype IneligibleIncentiveResponse = {\n incentive: null;\n session_id?: string;\n};\n\nexport type EligibleIncentiveResponse = {\n incentive: Incentive;\n tracking_ticket_id: string;\n session_id: string;\n // Backend-issued fingerprint of the state the ticket was minted under\n // (email, subtotal, checkout token). Persisted in the checkout attribute at\n // opt-in and echoed back on order submit for staleness detection.\n idempotency_key: string;\n widget_variant?: string;\n};\n\nconst SUPPORTED_COUNTRY_CODE = \"US\";\n\nexport type PrepurchaseWidgetPlacement = \"CHECKOUT\" | \"THANK_YOU\";\n\nexport const useGetIncentive = (\n widgetPlacement: PrepurchaseWidgetPlacement,\n) => {\n const endpoints = usePrepurchaseEndpoints();\n const { id: shopGid } = useShop();\n const incentiveUrl = endpoints.incentiveUrl(getShopIdentifier(shopGid));\n const customer = useCustomer();\n const contactEmail = useEmail();\n const subtotalAmount = useSubtotalAmount();\n const checkoutToken = useCheckoutToken();\n const country = useLocalizationCountry();\n const isEligibleCountry =\n country === undefined || country.isoCode === SUPPORTED_COUNTRY_CODE;\n\n const email = customer?.email ?? contactEmail;\n const validatedEmail = emailSchema().safeParse(email?.trim().toLowerCase());\n const validEmail = validatedEmail.success ? validatedEmail.data : null;\n\n const cartSubtotalAmount = Math.round(subtotalAmount.amount * 100);\n const cartSubtotalCurrency = subtotalAmount.currencyCode;\n\n return useQuery<IncentiveResponse>({\n // Everything that changes the response is part of the key, so React Query\n // refetches (and caches) per authentication/shop/customer/cart combination.\n queryKey: [\n \"prepurchase-incentive\",\n incentiveUrl,\n endpoints.headers[\"x-api-key\"],\n shopGid,\n validEmail,\n cartSubtotalAmount,\n cartSubtotalCurrency,\n checkoutToken,\n isEligibleCountry,\n widgetPlacement,\n ],\n queryFn: async ({ signal }) => {\n const response = await fetch(incentiveUrl, {\n method: \"POST\",\n headers: endpoints.headers,\n body: JSON.stringify({\n email: validEmail,\n cart_subtotal: {\n amount: cartSubtotalAmount,\n currency: cartSubtotalCurrency,\n },\n checkout_token: checkoutToken,\n widget_placement: widgetPlacement,\n }),\n signal,\n });\n if (!response.ok) {\n throw new Error(`Incentive request failed: ${response.status}`);\n }\n return (await response.json()) as IncentiveResponse;\n },\n enabled: !!validEmail && isEligibleCountry,\n // No caching: every key change fetches fresh and a prior key's result is\n // never reused. `gcTime: 0` drops a query as soon as it has no observer, so\n // returning to a previous key is a cache miss (not stale data + revalidate).\n gcTime: 0,\n staleTime: 0,\n refetchOnWindowFocus: false,\n });\n};\n\nexport const getTrackingIdentifiers = (data?: IncentiveResponse) => ({\n sessionId: data && \"session_id\" in data ? data.session_id : undefined,\n trackingTicketId:\n data && \"tracking_ticket_id\" in data ? data.tracking_ticket_id : undefined,\n});\n","import { useMemo } from \"preact/hooks\";\nimport { useExtensionEditor } from \"@shopify/ui-extensions/checkout/preact\";\n\nimport type { PrepurchaseAuth } from \"./conf.js\";\nimport { PrepurchaseProvider } from \"./PrepurchaseProvider.js\";\nimport { PrepurchaseWidget } from \"./components/prepurchase-widget.js\";\nimport { TrackingManager } from \"./tracking/tracking-manager.js\";\nimport {\n getTrackingIdentifiers,\n useGetIncentive,\n} from \"./hooks/useGetIncentive.js\";\n\nexport type DiscoPrepurchaseIncentiveProps = {\n /**\n * The merchant's public API key (a PUBLISHER_CHANNEL `disco_pk_live_…` key).\n * Requests go to Disco's production backend, authenticated by the key.\n */\n apiKey: string;\n};\n\n/**\n * Disco's prepurchase cash-back opt-in, shown in checkout.\n *\n * Render it from a `purchase.checkout.reductions.render-before` or\n * `purchase.checkout.actions.render-before` target. The opt-in is persisted to\n * a checkout attribute that `DiscoPrepurchaseThankYou` reads after purchase, so\n * render that too: it is what submits the order.\n *\n * Renders nothing when there is no incentive for this checkout, including when\n * the key is rejected.\n */\nexport function DiscoPrepurchaseIncentive({\n apiKey,\n}: DiscoPrepurchaseIncentiveProps) {\n const auth = useMemo(() => ({ apiKey }), [apiKey]);\n return <PrepurchaseIncentive auth={auth} />;\n}\n\n/**\n * The checkout widget shared by the public (`apiKey`) and internal (`env`)\n * entry points.\n */\nexport function PrepurchaseIncentive({ auth }: { auth: PrepurchaseAuth }) {\n return (\n <PrepurchaseProvider auth={auth}>\n <Incentive />\n </PrepurchaseProvider>\n );\n}\n\nfunction Incentive() {\n const editor = useExtensionEditor();\n const { data } = useGetIncentive(\"CHECKOUT\");\n const { sessionId, trackingTicketId } = getTrackingIdentifiers(data);\n\n if (!data || !sessionId) {\n return null;\n }\n\n return (\n <TrackingManager\n enabled={!editor}\n sessionId={sessionId}\n trackingTicketId={trackingTicketId}\n >\n <PrepurchaseWidget incentiveResponse={data} />\n </TrackingManager>\n );\n}\n","import { useCallback, useEffect, useRef } from \"preact/hooks\";\nimport {\n useCartLines,\n useCustomer,\n useEmail,\n useShop,\n useSubtotalAmount,\n useSubscription,\n useApi,\n useCheckoutToken,\n} from \"@shopify/ui-extensions/checkout/preact\";\nimport type { CartLine } from \"@shopify/ui-extensions/checkout\";\nimport { type PortableTextProps } from \"@portabletext/react\";\nimport { useMutation } from \"@tanstack/preact-query\";\nimport { email as emailSchema } from \"zod/mini\";\n\nimport { usePrepurchaseEndpoints } from \"../context.js\";\nimport { getShopIdentifier } from \"../utils.js\";\n\n// Integer minor units + ISO-4217 currency, matching the backend MoneySerializer\n// (scale defaults to 2). Shopify hands us amounts in major units, so we scale by 100.\ntype Money = {\n amount: number;\n currency: string;\n};\n\ntype OrderItem = {\n line_item_id: string;\n quantity: number;\n unit_price: Money;\n sku?: string;\n description?: string;\n category?: string;\n brand?: string;\n};\n\nexport type OrderRequest = {\n email: string;\n order_id: string;\n order_subtotal: Money;\n order_timestamp: string;\n tracking_ticket_id: string;\n order_items: OrderItem[];\n idempotency_key: string;\n checkout_token: string;\n insertion_id: string;\n};\n\n// Portable Text confirmation content Rakuten returns for the order (same shape as\n// the incentive `display`). Rendered verbatim on the thank-you page.\ntype Display = {\n blocks: PortableTextProps[\"value\"];\n logo_url: string;\n action: {\n href: string;\n label: string;\n };\n};\n\ntype OrderResponse = {\n order_status: string; // ORDER_CAPTURED | ORDER_ERROR\n display: Display | null;\n};\n\nconst toMinorUnits = (majorUnits: number): number =>\n Math.round(majorUnits * 100);\n\n// The optional item fields have `allow_blank=False` on the backend, so only\n// include them when there's a non-empty value to send.\nconst withOptional = (\n item: OrderItem,\n key: keyof OrderItem,\n value?: string,\n) => {\n if (value && value.trim()) {\n return { ...item, [key]: value };\n }\n return item;\n};\n\nconst toOrderItem = (line: CartLine): OrderItem => {\n const lineTotal = line.cost.totalAmount;\n // The cart line only exposes a line total; unit price is that total spread\n // across the quantity purchased.\n\n const lineItemId = line.id.split(\"/\").pop() ?? line.id;\n\n let item: OrderItem = {\n line_item_id: lineItemId,\n quantity: line.quantity,\n unit_price: {\n amount: toMinorUnits(lineTotal.amount / line.quantity),\n currency: lineTotal.currencyCode,\n },\n };\n\n if (line.merchandise.type === \"variant\") {\n const { sku, title, product } = line.merchandise;\n item = withOptional(item, \"sku\", sku);\n item = withOptional(item, \"description\", title);\n item = withOptional(item, \"category\", product.productType);\n item = withOptional(item, \"brand\", product.vendor);\n }\n\n return item;\n};\n\nexport const useOrderRequest = (\n trackingTicketId: string | null,\n idempotencyKey: string | null,\n insertionId: string | null,\n) => {\n const endpoints = usePrepurchaseEndpoints();\n const { id: shopGid } = useShop();\n const customer = useCustomer();\n const contactEmail = useEmail();\n const subtotalAmount = useSubtotalAmount();\n const cartLines = useCartLines();\n const checkoutToken = useCheckoutToken();\n\n const { orderConfirmation } = useApi<\"purchase.thank-you.block.render\">();\n const confirmation = useSubscription(orderConfirmation);\n\n const fullOrderId = confirmation.order.id;\n // const orderNumber = confirmation.number;\n\n const orderId = fullOrderId.split(\"/\").pop();\n\n const email = customer?.email ?? contactEmail;\n const validatedEmail = emailSchema().safeParse(email?.trim().toLowerCase());\n const validEmail = validatedEmail.success ? validatedEmail.data : null;\n\n const ready = Boolean(\n trackingTicketId &&\n idempotencyKey &&\n insertionId &&\n checkoutToken &&\n validEmail &&\n orderId &&\n cartLines.length > 0,\n );\n\n const buildPayload = useCallback((): OrderRequest => {\n if (\n !trackingTicketId ||\n !idempotencyKey ||\n !insertionId ||\n !checkoutToken ||\n !validEmail ||\n !orderId\n ) {\n throw new Error(\"Missing data required to submit the prepurchase order\");\n }\n\n return {\n email: validEmail,\n order_id: orderId,\n order_subtotal: {\n amount: toMinorUnits(subtotalAmount.amount),\n currency: subtotalAmount.currencyCode,\n },\n order_timestamp: new Date().toISOString(),\n tracking_ticket_id: trackingTicketId,\n order_items: cartLines.map(toOrderItem),\n idempotency_key: idempotencyKey,\n checkout_token: checkoutToken,\n insertion_id: insertionId,\n };\n }, [\n cartLines,\n checkoutToken,\n idempotencyKey,\n insertionId,\n orderId,\n subtotalAmount.amount,\n subtotalAmount.currencyCode,\n trackingTicketId,\n validEmail,\n ]);\n\n return {\n buildPayload,\n orderId,\n ready,\n endpoints,\n shopIdentifier: getShopIdentifier(shopGid),\n };\n};\n\n/**\n * Submits the completed order to the backend `OrderView` when the buyer opted\n * into the prepurchase incentive. Fires exactly once, as soon as the required\n * post-checkout data (order id + a valid email) is available.\n *\n * `useMutation` (not `useQuery`) because this is a one-shot, non-idempotent POST\n * that creates the order upstream — React Query must never retry or refetch it.\n */\nexport const useSubmitOrder = (\n trackingTicketId: string | null,\n // The qualify-time idempotency key persisted in the checkout attribute at\n // opt-in. Echoed to the backend, which recomputes it from the order's final\n // state and skips attribution if the opt-in went stale (e.g. the buyer\n // changed email after checking the box).\n idempotencyKey: string | null,\n insertionId: string | null,\n) => {\n const { buildPayload, endpoints, orderId, ready, shopIdentifier } =\n useOrderRequest(trackingTicketId, idempotencyKey, insertionId);\n\n const mutation = useMutation<OrderResponse, Error>({\n mutationKey: [\"prepurchase-order\", orderId, trackingTicketId],\n // No retries: a failed POST must not silently resubmit and create the order twice.\n retry: false,\n mutationFn: async () => {\n const response = await fetch(endpoints.orderUrl(shopIdentifier), {\n method: \"POST\",\n headers: endpoints.headers,\n body: JSON.stringify(buildPayload()),\n });\n\n if (!response.ok) {\n throw new Error(`Order submit failed: ${response.status}`);\n }\n\n return (await response.json()) as OrderResponse;\n },\n });\n\n // Fire once, when everything needed is present. A ref guards against React\n // re-renders (and StrictMode's double-invoked effect) re-submitting the order.\n const { mutate } = mutation;\n const firedRef = useRef(false);\n useEffect(() => {\n if (firedRef.current || !ready) {\n return;\n }\n firedRef.current = true;\n mutate();\n }, [ready, mutate]);\n\n return mutation;\n};\n","import { useEffect, useRef } from \"preact/hooks\";\nimport { useMutation } from \"@tanstack/preact-query\";\n\nimport { useOrderRequest } from \"./useSubmitOrder.js\";\n\ntype OrderIntentResponse = {\n launch_url: string;\n};\n\n/**\n * Stages the final order behind an opaque, short-lived URL. This never calls\n * the affiliate provider; that only happens after the buyer follows the URL.\n */\nexport const useCreateOrderIntent = (\n trackingTicketId: string | null,\n idempotencyKey: string | null,\n insertionId: string | null,\n enabled: boolean,\n) => {\n const { buildPayload, endpoints, orderId, ready, shopIdentifier } =\n useOrderRequest(trackingTicketId, idempotencyKey, insertionId);\n\n const mutation = useMutation<OrderIntentResponse, Error>({\n mutationKey: [\"prepurchase-order-intent\", orderId, trackingTicketId],\n retry: false,\n mutationFn: async () => {\n const response = await fetch(endpoints.orderIntentUrl(shopIdentifier), {\n method: \"POST\",\n headers: endpoints.headers,\n body: JSON.stringify(buildPayload()),\n });\n\n if (!response.ok) {\n throw new Error(`Order intent creation failed: ${response.status}`);\n }\n\n return (await response.json()) as OrderIntentResponse;\n },\n });\n\n const { mutate } = mutation;\n const firedRef = useRef(false);\n\n useEffect(() => {\n if (firedRef.current || !enabled || !ready) {\n return;\n }\n firedRef.current = true;\n mutate();\n }, [enabled, mutate, ready]);\n\n return mutation;\n};\n","import {\n useApi,\n useBillingAddress,\n useCustomer,\n useShippingAddress,\n useShop,\n useTotalAmount,\n} from \"@shopify/ui-extensions/checkout/preact\";\n\nimport PortableTextRenderer from \"../../portable-text-renderer.js\";\nimport { type ThankYouWidgetVariantProps } from \"./types.js\";\n\n/** The check-icon checklist layout, with a redeem/forfeit decision. */\nexport function CheckIconsThankYouWidget({\n rewardWithCents,\n compactReward,\n contentBlocks,\n launchUrl,\n claimed,\n onClaim,\n onDecline,\n}: ThankYouWidgetVariantProps) {\n const { i18n } = useApi<\"purchase.thank-you.block.render\">();\n const { name: merchantName } = useShop<\"purchase.thank-you.block.render\">();\n const total = useTotalAmount<\"purchase.thank-you.block.render\">();\n const customer = useCustomer<\"purchase.thank-you.block.render\">();\n const billingAddress = useBillingAddress<\"purchase.thank-you.block.render\">();\n const shippingAddress =\n useShippingAddress<\"purchase.thank-you.block.render\">();\n const firstName =\n customer?.firstName ??\n billingAddress?.firstName ??\n shippingAddress?.firstName;\n const orderTotal = i18n.formatCurrency(total.amount, {\n currency: total.currencyCode,\n });\n const heading = firstName\n ? `${firstName}, thank you for your ${merchantName} purchase`\n : `Thank you for your ${merchantName} purchase`;\n\n return (\n <s-stack gap=\"base\">\n <s-heading>{heading}</s-heading>\n <s-text>\n You unlocked {rewardWithCents} cash back on the order you just placed.\n </s-text>\n <s-stack gap=\"small-200\">\n <s-stack direction=\"inline\" gap=\"small-200\" alignItems=\"center\">\n <s-icon type=\"check-circle\" tone=\"success\" />\n <s-text>{orderTotal} order total</s-text>\n </s-stack>\n <s-stack direction=\"inline\" gap=\"small-200\" alignItems=\"center\">\n <s-icon type=\"check-circle\" tone=\"success\" />\n <s-text>{rewardWithCents} cash back</s-text>\n </s-stack>\n </s-stack>\n <PortableTextRenderer\n value={contentBlocks}\n spacing=\"extraTight\"\n appearance=\"subdued\"\n />\n {claimed ? (\n <s-text tone=\"success\" type=\"strong\">\n Congratulations! You claimed your {compactReward} cash back.\n </s-text>\n ) : (\n <s-grid gridTemplateColumns=\"1fr 1fr\" gap=\"base\" alignItems=\"center\">\n <s-button\n tone=\"neutral\"\n variant=\"primary\"\n inlineSize=\"fill\"\n href={launchUrl}\n onClick={onClaim}\n >\n Redeem my {compactReward}\n </s-button>\n <s-stack direction=\"inline\" justifyContent=\"center\" inlineSize=\"100%\">\n {/* Shopify replaced plain buttons with links. Without an\n * href, this remains an action control with button semantics. */}\n <s-link tone=\"neutral\" onClick={onDecline}>\n Forfeit my {compactReward}\n </s-link>\n </s-stack>\n </s-grid>\n )}\n </s-stack>\n );\n}\n","import { useApi, useTotalAmount } from \"@shopify/ui-extensions/checkout/preact\";\n\nimport PortableTextRenderer from \"../../portable-text-renderer.js\";\nimport { type ThankYouWidgetVariantProps } from \"./types.js\";\n\n/** The order-cost comparison layout. */\nexport function CashBackCostThankYouWidget({\n rewardWithCents,\n compactReward,\n rewardAmount,\n contentBlocks,\n launchUrl,\n claimed,\n onClaim,\n}: ThankYouWidgetVariantProps) {\n const { i18n } = useApi<\"purchase.thank-you.block.render\">();\n const total = useTotalAmount<\"purchase.thank-you.block.render\">();\n const orderTotal = i18n.formatCurrency(total.amount, {\n currency: total.currencyCode,\n });\n const cashBackAdjustedTotal = i18n.formatCurrency(\n Math.max(total.amount - rewardAmount, 0),\n { currency: total.currencyCode },\n );\n\n return (\n <s-box padding=\"large-200\">\n <s-stack gap=\"base\">\n <s-grid gridTemplateColumns=\"1fr auto\" alignItems=\"center\">\n <s-text>Order total</s-text>\n <s-text type=\"strong\">{orderTotal}</s-text>\n </s-grid>\n <s-grid gridTemplateColumns=\"1fr auto\" alignItems=\"center\">\n <s-text type=\"strong\" color=\"subdued\">\n Your cost with {rewardWithCents} cash back\n </s-text>\n <s-heading>\n <s-text color=\"subdued\">{cashBackAdjustedTotal}</s-text>\n </s-heading>\n </s-grid>\n <PortableTextRenderer\n value={contentBlocks}\n spacing=\"extraTight\"\n appearance=\"subdued\"\n />\n {claimed ? (\n <s-text tone=\"success\" type=\"strong\">\n Congratulations! You claimed your {compactReward} cash back.\n </s-text>\n ) : (\n <s-button\n tone=\"neutral\"\n variant=\"primary\"\n inlineSize=\"fill\"\n href={launchUrl}\n onClick={onClaim}\n >\n Get {compactReward} cash back\n </s-button>\n )}\n </s-stack>\n </s-box>\n );\n}\n","import { useEffect, useState } from \"preact/hooks\";\n\nexport const FINAL_MINUTE_SECONDS = 60;\n\n/** Returns a drift-resistant countdown that stops when it reaches zero. */\nexport function useCountdown(durationSeconds: number) {\n const [secondsRemaining, setSecondsRemaining] = useState(durationSeconds);\n\n useEffect(() => {\n const deadline = Date.now() + durationSeconds * 1000;\n const updateCountdown = () => {\n const nextSeconds = Math.max(\n 0,\n Math.ceil((deadline - Date.now()) / 1000),\n );\n\n setSecondsRemaining(nextSeconds);\n if (nextSeconds === 0) {\n clearInterval(interval);\n }\n };\n const interval = setInterval(updateCountdown, 1000);\n\n return () => clearInterval(interval);\n }, [durationSeconds]);\n\n return secondsRemaining;\n}\n\nexport function formatCountdown(seconds: number) {\n const minutes = Math.floor(seconds / 60);\n const remainingSeconds = seconds % 60;\n\n return `${minutes}:${remainingSeconds.toString().padStart(2, \"0\")}`;\n}\n","import {\n useBillingAddress,\n useCustomer,\n useShippingAddress,\n useShop,\n} from \"@shopify/ui-extensions/checkout/preact\";\n\nimport PortableTextRenderer from \"../../portable-text-renderer.js\";\nimport { formatCountdown, useCountdown } from \"./countdown.js\";\nimport { type ThankYouWidgetVariantProps } from \"./types.js\";\n\nconst COUNTDOWN_SECONDS = 10 * 60;\n\n/** The order-confirmation layout with a ten-minute claim countdown. */\nexport function TenMinuteCountdownThankYouWidget({\n rewardWithCents,\n compactReward,\n contentBlocks,\n launchUrl,\n claimed,\n onClaim,\n}: ThankYouWidgetVariantProps) {\n const { name: merchantName } = useShop<\"purchase.thank-you.block.render\">();\n const customer = useCustomer<\"purchase.thank-you.block.render\">();\n const billingAddress = useBillingAddress<\"purchase.thank-you.block.render\">();\n const shippingAddress =\n useShippingAddress<\"purchase.thank-you.block.render\">();\n const firstName =\n customer?.firstName ??\n billingAddress?.firstName ??\n shippingAddress?.firstName;\n const secondsRemaining = useCountdown(COUNTDOWN_SECONDS);\n\n if (secondsRemaining === 0) {\n return null;\n }\n\n const timer = formatCountdown(secondsRemaining);\n const heading = firstName\n ? `${firstName}, thank you for your ${merchantName} purchase`\n : `Thank you for your ${merchantName} purchase`;\n\n return (\n <s-box padding=\"large-200\">\n <s-stack gap=\"base\">\n <s-heading>{heading}</s-heading>\n <s-text>\n You earned <s-text type=\"strong\">{rewardWithCents} cash back</s-text>{\" \"}\n on the order you just placed.\n </s-text>\n <s-stack gap=\"small-200\">\n <s-paragraph accessibilityVisibility=\"hidden\">\n <s-text type=\"strong\" tone={\"critical\"}>\n {timer}\n </s-text>{\" \"}\n <s-text color=\"base\">left to claim your offer.</s-text>\n </s-paragraph>\n <s-text accessibilityVisibility=\"exclusive\">\n {timer} left to claim your {rewardWithCents} cash back on the order\n you just placed.\n </s-text>\n </s-stack>\n <PortableTextRenderer\n value={contentBlocks}\n spacing=\"extraTight\"\n appearance=\"subdued\"\n />\n {claimed ? (\n <s-text tone=\"success\" type=\"strong\">\n Congratulations! You claimed your {compactReward} cash back.\n </s-text>\n ) : (\n <s-button\n tone=\"neutral\"\n variant=\"primary\"\n inlineSize=\"fill\"\n href={launchUrl}\n onClick={onClaim}\n >\n Claim my {compactReward}\n </s-button>\n )}\n </s-stack>\n </s-box>\n );\n}\n","import {\n useApi,\n useBillingAddress,\n useCustomer,\n useShippingAddress,\n useShop,\n useTotalAmount,\n} from \"@shopify/ui-extensions/checkout/preact\";\n\nimport PortableTextRenderer from \"../../portable-text-renderer.js\";\nimport { type ThankYouWidgetVariantProps } from \"./types.js\";\n\n/** The two-step earned-to-collect reward progress layout. */\nexport function EarnedProgressThankYouWidget({\n rewardWithCents,\n compactReward,\n contentBlocks,\n launchUrl,\n claimed,\n onClaim,\n}: ThankYouWidgetVariantProps) {\n const { i18n } = useApi<\"purchase.thank-you.block.render\">();\n const { name: merchantName } = useShop<\"purchase.thank-you.block.render\">();\n const total = useTotalAmount<\"purchase.thank-you.block.render\">();\n const customer = useCustomer<\"purchase.thank-you.block.render\">();\n const billingAddress = useBillingAddress<\"purchase.thank-you.block.render\">();\n const shippingAddress =\n useShippingAddress<\"purchase.thank-you.block.render\">();\n const firstName =\n customer?.firstName ??\n billingAddress?.firstName ??\n shippingAddress?.firstName;\n const orderTotal = i18n.formatCurrency(total.amount, {\n currency: total.currencyCode,\n });\n const summary = firstName\n ? `${firstName}, your ${orderTotal} order at ${merchantName} earned you`\n : `Your ${orderTotal} order at ${merchantName} earned you`;\n\n return (\n <s-stack gap=\"base\">\n <s-heading>{summary}</s-heading>\n <s-stack gap=\"small-200\">\n <s-heading>\n <s-text>{rewardWithCents} cash back</s-text>\n </s-heading>\n <s-progress\n value={1}\n max={2}\n accessibilityLabel={`${rewardWithCents} earned; next step is to collect it`}\n />\n <s-grid gridTemplateColumns=\"1fr auto\" gap=\"base\" alignItems=\"center\">\n <s-stack direction=\"inline\" gap=\"small-200\" alignItems=\"center\">\n <s-icon type=\"check-circle\" size=\"small\" tone=\"info\" />\n <s-text type=\"strong\">Earned</s-text>\n </s-stack>\n <s-text color=\"subdued\">Next: collect it</s-text>\n </s-grid>\n </s-stack>\n <PortableTextRenderer\n value={contentBlocks}\n spacing=\"extraTight\"\n appearance=\"subdued\"\n />\n {claimed ? (\n <s-text tone=\"success\" type=\"strong\">\n Congratulations! You claimed your {compactReward} cash back.\n </s-text>\n ) : (\n <s-button\n tone=\"neutral\"\n variant=\"primary\"\n inlineSize=\"fill\"\n href={launchUrl}\n onClick={onClaim}\n >\n Collect my {compactReward}\n </s-button>\n )}\n </s-stack>\n );\n}\n","import {\n useApi,\n useBillingAddress,\n useCustomer,\n useShippingAddress,\n useSubscription,\n} from \"@shopify/ui-extensions/checkout/preact\";\n\nimport PortableTextRenderer from \"../../portable-text-renderer.js\";\nimport { type ThankYouWidgetVariantProps } from \"./types.js\";\n\n/** The order-number layout that leads with the earned reward. */\nexport function OrderEarnedThankYouWidget({\n rewardWithCents,\n compactReward,\n contentBlocks,\n launchUrl,\n claimed,\n onClaim,\n}: ThankYouWidgetVariantProps) {\n const { orderConfirmation } = useApi<\"purchase.thank-you.block.render\">();\n const { number: orderNumber } = useSubscription(orderConfirmation);\n const customer = useCustomer<\"purchase.thank-you.block.render\">();\n const billingAddress = useBillingAddress<\"purchase.thank-you.block.render\">();\n const shippingAddress =\n useShippingAddress<\"purchase.thank-you.block.render\">();\n const firstName =\n customer?.firstName ??\n billingAddress?.firstName ??\n shippingAddress?.firstName;\n const heading = firstName\n ? `${firstName}, this order earned you`\n : \"This order earned you\";\n\n return (\n <s-box padding=\"large-200\">\n <s-stack gap=\"base\">\n {orderNumber && (\n <s-text color=\"subdued\">\n ORDER #{orderNumber.replace(/^#/, \"\")}\n </s-text>\n )}\n <s-grid gridTemplateColumns=\"1fr auto\" gap=\"base\" alignItems=\"center\">\n <s-text type=\"strong\">{heading}</s-text>\n <s-heading>\n <s-text tone=\"success\">{rewardWithCents}</s-text>\n </s-heading>\n </s-grid>\n <PortableTextRenderer\n value={contentBlocks}\n spacing=\"extraTight\"\n appearance=\"subdued\"\n />\n {claimed ? (\n <s-text tone=\"success\" type=\"strong\">\n Congratulations! You claimed your {compactReward} cash back.\n </s-text>\n ) : (\n <s-button\n tone=\"neutral\"\n variant=\"primary\"\n inlineSize=\"fill\"\n href={launchUrl}\n onClick={onClaim}\n >\n Claim the {compactReward} from this order\n </s-button>\n )}\n </s-stack>\n </s-box>\n );\n}\n","import {\n useApi,\n useBillingAddress,\n useCustomer,\n useShippingAddress,\n useShop,\n} from \"@shopify/ui-extensions/checkout/preact\";\nimport { useMemo } from \"preact/hooks\";\n\nimport PortableTextRenderer from \"../../portable-text-renderer.js\";\nimport { type ThankYouWidgetVariantProps } from \"./types.js\";\n\nconst TEN_MINUTES_MS = 10 * 60 * 1000;\nconst WEEK_MS = 7 * 24 * 60 * 60 * 1000;\nconst MONDAY_EPOCH_MS = Date.UTC(1970, 0, 5);\nconst MIN_WEEKLY_CLAIM_COUNT = 850;\nconst WEEKLY_BASE_VARIATION = 100;\n\nfunction getWeeklyClaimCount(timestamp: number) {\n const millisecondsSinceEpoch = timestamp - MONDAY_EPOCH_MS;\n const weekIndex = Math.floor(millisecondsSinceEpoch / WEEK_MS);\n const weekStart = MONDAY_EPOCH_MS + weekIndex * WEEK_MS;\n const tenMinuteBuckets = Math.floor((timestamp - weekStart) / TEN_MINUTES_MS);\n // Give each week a deterministic starting offset while keeping the count\n // monotonic within the week.\n const weeklyOffset =\n (((weekIndex * 47) % (WEEKLY_BASE_VARIATION + 1)) +\n (WEEKLY_BASE_VARIATION + 1)) %\n (WEEKLY_BASE_VARIATION + 1);\n\n return MIN_WEEKLY_CLAIM_COUNT + weeklyOffset + tenMinuteBuckets;\n}\n\n/** The order-confirmation layout that reinforces the offer with social proof. */\nexport function SocialProofThankYouWidget({\n rewardWithCents,\n compactReward,\n contentBlocks,\n launchUrl,\n claimed,\n onClaim,\n}: ThankYouWidgetVariantProps) {\n const { i18n } = useApi<\"purchase.thank-you.block.render\">();\n const { name: merchantName } = useShop<\"purchase.thank-you.block.render\">();\n const customer = useCustomer<\"purchase.thank-you.block.render\">();\n const billingAddress = useBillingAddress<\"purchase.thank-you.block.render\">();\n const shippingAddress =\n useShippingAddress<\"purchase.thank-you.block.render\">();\n const firstName =\n customer?.firstName ??\n billingAddress?.firstName ??\n shippingAddress?.firstName;\n const claimCount = useMemo(() => getWeeklyClaimCount(Date.now()), []);\n const formattedClaimCount = i18n.formatNumber(claimCount);\n const heading = firstName\n ? `${firstName}, thank you for your ${merchantName} purchase`\n : `Thank you for your ${merchantName} purchase`;\n\n return (\n <s-stack gap=\"base\">\n <s-heading>{heading}</s-heading>\n <s-grid\n gridTemplateColumns=\"auto 1fr\"\n gap=\"small-200\"\n alignItems=\"center\"\n >\n <s-icon type=\"check-circle\" tone=\"success\" />\n <s-text>\n You earned <s-text type=\"strong\">{rewardWithCents} cash back</s-text>{\" \"}\n on the order you just placed.\n </s-text>\n </s-grid>\n <s-stack gap=\"small-200\">\n <s-grid\n gridTemplateColumns=\"auto 1fr\"\n gap=\"small-200\"\n alignItems=\"center\"\n >\n <s-icon type=\"check-circle\" tone=\"success\" />\n <s-text>\n {formattedClaimCount} shoppers claimed theirs at {merchantName} this\n week\n </s-text>\n </s-grid>\n {/* <s-grid\n\t\t\t\t\tgridTemplateColumns=\"auto 1fr\"\n\t\t\t\t\tgap=\"small-200\"\n\t\t\t\t\talignItems=\"center\"\n\t\t\t\t>\n\t\t\t\t\t<s-icon type=\"info\" tone=\"critical\" size=\"small\" />\n\t\t\t\t\t<s-text color=\"subdued\">\n\t\t\t\t\t\tOne claim per order, and this order is already placed\n\t\t\t\t\t</s-text>\n\t\t\t\t</s-grid> */}\n </s-stack>\n <PortableTextRenderer\n value={contentBlocks}\n spacing=\"extraTight\"\n appearance=\"subdued\"\n />\n {claimed ? (\n <s-text tone=\"success\" type=\"strong\">\n Congratulations! You claimed your {compactReward} cash back.\n </s-text>\n ) : (\n <s-button\n tone=\"neutral\"\n variant=\"primary\"\n inlineSize=\"fill\"\n href={launchUrl}\n onClick={onClaim}\n >\n Claim my {compactReward}\n </s-button>\n )}\n </s-stack>\n );\n}\n","import { type ComponentType } from \"preact\";\nimport { useEffect, useMemo, useState } from \"preact/hooks\";\nimport { useApi } from \"@shopify/ui-extensions/checkout/preact\";\n\nimport { type EligibleIncentiveResponse } from \"../hooks/useGetIncentive.js\";\nimport { useEventTracker } from \"../tracking/tracking-manager.js\";\nimport { CheckIconsThankYouWidget } from \"./thank-you/check-icons.js\";\nimport { CashBackCostThankYouWidget } from \"./thank-you/cash-back-cost.js\";\nimport { TenMinuteCountdownThankYouWidget } from \"./thank-you/countdown-10-minute.js\";\nimport { EarnedProgressThankYouWidget } from \"./thank-you/earned-progress.js\";\nimport { OrderEarnedThankYouWidget } from \"./thank-you/order-earned.js\";\nimport { SocialProofThankYouWidget } from \"./thank-you/social-proof.js\";\nimport { type ThankYouWidgetVariantProps } from \"./thank-you/types.js\";\n\n/**\n * Maps the API's `widget_variant` onto a thank-you layout this bundle can render.\n *\n * The thank-you page's counterpart to `resolveWidget` in prepurchase-widget.tsx, and\n * it follows that file's contract exactly: these cases are the only list of valid ids\n * anywhere, because the backend holds none and passes whatever\n * `prepurchase_thank_you_widget_variant` serves straight through -- ids it has never\n * heard of included -- so a new layout ships without a backend deploy. The ids are\n * append-only and name the layout's FORM rather than its position in a test, since\n * every value served is permanent in the warehouse's exposure rows; redesigning a\n * layout mints a new id (`check-icons-v2`) instead of reusing one.\n *\n * Note this is a DIFFERENT flag from the checkout surface's `prepurchase_widget_variant`\n * and a different id space: the backend picks the flag off `widget_placement`, so a\n * checkout id (`inline_radio`) can never arrive here, nor a thank-you id there.\n */\nfunction resolveWidget(\n raw: string | undefined,\n): ComponentType<ThankYouWidgetVariantProps> {\n switch (raw) {\n case \"cash-back-cost\":\n return CashBackCostThankYouWidget;\n case \"countdown-10-minute\":\n return TenMinuteCountdownThankYouWidget;\n case \"earned-progress\":\n return EarnedProgressThankYouWidget;\n case \"order-earned\":\n return OrderEarnedThankYouWidget;\n case \"social-proof\":\n return SocialProofThankYouWidget;\n // The fail-safe, covering both an id newer than this bundle and an absent\n // field -- the backend omits `widget_variant` entirely when the flag yields\n // nothing (an uninitialized client, a missing flag, a provider that declined\n // the shopper), and records no exposure row for it, so rendering this layout\n // claims no assignment that GrowthBook never made. Must stay the same layout\n // as the flag's `defaultValue` in GrowthBook, currently `check-icons` in\n // every environment: that default is what a live-but-unconfigured flag serves,\n // and it has a real exposure row behind it.\n default:\n return CheckIconsThankYouWidget;\n }\n}\n\nexport function ThankYouClaimWidget({\n incentive,\n launchUrl,\n}: {\n incentive: EligibleIncentiveResponse;\n launchUrl: string;\n}) {\n const { track } = useEventTracker();\n const { i18n } = useApi<\"purchase.thank-you.block.render\">();\n const [status, setStatus] = useState<\"idle\" | \"claimed\" | \"declined\">(\"idle\");\n const display = incentive.incentive.display;\n const reward = incentive.incentive.reward;\n const rewardAmount = reward.amount / 10 ** reward.scale;\n const rewardWithCents = i18n.formatCurrency(rewardAmount, {\n currency: reward.currency,\n });\n const compactReward = i18n.formatCurrency(rewardAmount, {\n currency: reward.currency,\n minimumFractionDigits: Number.isInteger(rewardAmount) ? 0 : 2,\n });\n const brandProperties = useMemo(\n () => ({\n offerId: crypto.randomUUID(),\n advertiserId: incentive.incentive.advertiser_id,\n insertionId: incentive.incentive.insertion_id,\n }),\n [incentive.incentive.advertiser_id, incentive.incentive.insertion_id],\n );\n const contentBlocks = Array.isArray(display.blocks)\n ? display.blocks.filter((block) => block._type !== \"checkboxBlock\")\n : display.blocks;\n\n useEffect(() => {\n track({\n type: \"BRAND_DISPLAY\",\n target: \"INLINE_SLOT\",\n brand: brandProperties,\n });\n }, [track, brandProperties]);\n\n if (status === \"declined\") {\n return null;\n }\n\n const Widget = resolveWidget(incentive.widget_variant);\n\n return (\n <Widget\n rewardWithCents={rewardWithCents}\n compactReward={compactReward}\n rewardAmount={rewardAmount}\n contentBlocks={contentBlocks}\n launchUrl={launchUrl}\n claimed={status === \"claimed\"}\n onClaim={() => {\n track({\n type: \"ELEMENT_CLICK\",\n target: \"OPT_IN\",\n brand: brandProperties,\n });\n setStatus(\"claimed\");\n }}\n onDecline={() => {\n track({\n type: \"ELEMENT_CLICK\",\n target: \"INLINE_NAV_FORWARD\",\n brand: brandProperties,\n });\n setStatus(\"declined\");\n }}\n />\n );\n}\n","import { useEffect, useMemo } from \"preact/hooks\";\nimport {\n useAttributeValues,\n useExtensionEditor,\n} from \"@shopify/ui-extensions/checkout/preact\";\n\nimport type { PrepurchaseAuth } from \"./conf.js\";\nimport { PrepurchaseProvider } from \"./PrepurchaseProvider.js\";\nimport PortableTextRenderer from \"./portable-text-renderer.js\";\nimport { useSubmitOrder } from \"./hooks/useSubmitOrder.js\";\nimport { useCreateOrderIntent } from \"./hooks/useCreateOrderIntent.js\";\nimport {\n type IncentiveResponse,\n getTrackingIdentifiers,\n useGetIncentive,\n} from \"./hooks/useGetIncentive.js\";\nimport { ATTRIBUTE_KEY, decodePrepurchaseAttribute } from \"./attribute.js\";\nimport {\n TrackingManager,\n useEventTracker,\n} from \"./tracking/tracking-manager.js\";\nimport { ThankYouClaimWidget } from \"./components/thank-you-widget.js\";\n\nexport type DiscoPrepurchaseThankYouProps = {\n /**\n * The merchant's public API key (a PUBLISHER_CHANNEL `disco_pk_live_…` key).\n * Requests go to Disco's production backend, authenticated by the key.\n */\n apiKey: string;\n};\n\n/**\n * Disco's prepurchase incentive on the thank-you page.\n *\n * Render it from a `purchase.thank-you.block.render` target. A buyer who opted\n * in at checkout (via `DiscoPrepurchaseIncentive`) has their order submitted\n * and sees the partner's confirmation; anyone else is offered the incentive\n * post-purchase instead.\n *\n * Renders nothing when there is nothing to show, including when the key is\n * rejected.\n */\nexport function DiscoPrepurchaseThankYou({\n apiKey,\n}: DiscoPrepurchaseThankYouProps) {\n const auth = useMemo(() => ({ apiKey }), [apiKey]);\n return <PrepurchaseThankYou auth={auth} />;\n}\n\n/**\n * The thank-you widget shared by the public (`apiKey`) and internal (`env`)\n * entry points.\n */\nexport function PrepurchaseThankYou({ auth }: { auth: PrepurchaseAuth }) {\n return (\n <PrepurchaseProvider auth={auth}>\n <ThankYou />\n </PrepurchaseProvider>\n );\n}\n\nfunction ThankYou() {\n const editor = useExtensionEditor();\n const [rawAttribute] = useAttributeValues([ATTRIBUTE_KEY]);\n const { optedIn, trackingTicketId, idempotencyKey, insertionId, sessionId } =\n decodePrepurchaseAttribute(rawAttribute);\n\n if (!optedIn) {\n return <ThankYouIncentive enabled={!editor} />;\n }\n\n if (!trackingTicketId || !idempotencyKey || !insertionId) {\n return null;\n }\n\n return (\n <TrackingManager\n enabled={!editor}\n sessionId={sessionId ?? undefined}\n trackingTicketId={trackingTicketId}\n >\n <OrderSubmitter\n trackingTicketId={trackingTicketId}\n idempotencyKey={idempotencyKey}\n insertionId={insertionId}\n />\n </TrackingManager>\n );\n}\n\nfunction ThankYouIncentive({ enabled }: { enabled: boolean }) {\n const { data } = useGetIncentive(\"THANK_YOU\");\n const { sessionId, trackingTicketId } = getTrackingIdentifiers(data);\n\n if (!data || !sessionId) {\n return null;\n }\n\n return (\n <TrackingManager\n enabled={enabled}\n sessionId={sessionId}\n trackingTicketId={trackingTicketId}\n >\n <ThankYouWidget incentiveResponse={data} enabled={enabled} />\n </TrackingManager>\n );\n}\n\nfunction ThankYouWidget({\n incentiveResponse,\n enabled,\n}: {\n incentiveResponse: IncentiveResponse;\n enabled: boolean;\n}) {\n const { track } = useEventTracker();\n const incentive =\n \"tracking_ticket_id\" in incentiveResponse ? incentiveResponse : undefined;\n const { data: intent } = useCreateOrderIntent(\n incentive?.tracking_ticket_id ?? null,\n incentive?.idempotency_key ?? null,\n incentive?.incentive.insertion_id ?? null,\n enabled && Boolean(incentive),\n );\n\n useEffect(() => {\n track({ type: \"WIDGET_LOAD\" });\n track({ type: \"WIDGET_DISPLAY\" });\n }, [track]);\n\n if (!incentive || !intent?.launch_url) {\n return null;\n }\n\n return (\n <ThankYouClaimWidget incentive={incentive} launchUrl={intent.launch_url} />\n );\n}\n\nfunction OrderSubmitter({\n trackingTicketId,\n idempotencyKey,\n insertionId,\n}: {\n trackingTicketId: string;\n idempotencyKey: string;\n insertionId: string;\n}) {\n const { data } = useSubmitOrder(\n trackingTicketId,\n idempotencyKey,\n insertionId,\n );\n const { track } = useEventTracker();\n\n const display = data?.display;\n if (!display) {\n return null;\n }\n\n return (\n <s-box borderRadius=\"large\" background=\"subdued\" padding=\"large-200\">\n <s-grid\n gridTemplateColumns=\"36px 1fr auto\"\n gap=\"base\"\n alignItems=\"center\"\n >\n <s-image src={display.logo_url} alt=\"Rakuten Logo\" aspectRatio=\"1\" />\n <PortableTextRenderer value={display.blocks} spacing=\"extraTight\" />\n <s-button\n href={display.action.href}\n target=\"_blank\"\n tone=\"neutral\"\n variant=\"primary\"\n onClick={() =>\n track({\n type: \"ELEMENT_CLICK\",\n target: \"CONSUMER_REDIRECT\",\n })\n }\n >\n {display.action.label}\n </s-button>\n </s-grid>\n </s-box>\n );\n}\n"],"x_google_ignoreList":[54,55],"mappings":";;;;;;;;;;;;;;;;;;;;;AAaA,SAAS,yBAAyB;;;;;CAKjC,MAAM,qBAAqBA,gBAAc,IAAI;;;;;;;;;CAS7C,SAAS,iBAAiB;EACzB,MAAM,SAASC,aAAW,kBAAkB;EAC5C,IAAI,CAAC,QAAQ,MAAM,IAAI,MAAM,uDAAuD;EACpF,OAAO;CACR;CACA,MAAM,UAAU;EACf,QAAQ;EACR,MAAM,KAAK;EACX,OAAO,KAAK;CACb;;;;;;;;;;;;;;CAcA,SAAS,wBAAwB,SAAS;EACzC,MAAM,SAAS,eAAe;EAC9B,MAAM,CAAC,OAAO,YAAYC,WAAS,OAAO;EAC1C,MAAM,CAAC,SAAS,cAAcA,WAAS,IAAI;EAC3C,MAAM,aAAaC,gBAAc,KAAK,UAAU,OAAO,GAAG,CAAC,OAAO,CAAC;EACnE,MAAM,CAAC,aAAa,kBAAkBD,WAAS,CAAC;EAChD,MAAM,UAAUE,oBAAkB,gBAAgB,MAAM,IAAI,CAAC,GAAG,CAAC,CAAC;EACl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