web-push-notifications 3.104.1 → 3.107.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/core/Pushwoosh.d.ts +8 -0
- package/core/Pushwoosh.types.d.ts +3 -1
- package/core/__tests__/unknownInitKeys.test.d.ts +1 -0
- package/core/events.types.d.ts +4 -1
- package/core/unknownInitKeys.d.ts +6 -0
- package/modules/Api/Api.d.ts +3 -1
- package/modules/ApiClient/ApiClient.d.ts +2 -0
- package/modules/ApiClient/ApiClient.types.d.ts +16 -2
- package/modules/Recommendations/Recommendations.types.d.ts +1 -1
- package/npm.js +1 -1
- package/npm.js.map +1 -1
- package/package.json +2 -2
- package/service-worker.js +1 -1
- package/service-worker.js.map +1 -1
- package/widget-subscription.js.map +1 -1
- package/widget-web-popups.js +1 -1
- package/widget-web-popups.js.map +1 -1
- package/widgets/WebPopups/EmbeddedWebPopups.d.ts +3 -0
- package/widgets/WebPopups/WebPopupsWidget.d.ts +32 -0
- package/widgets/WebPopups/__tests__/placements.test.d.ts +1 -0
- package/widgets/WebPopups/__tests__/productsHost.test.d.ts +1 -0
- package/widgets/WebPopups/constants.d.ts +2 -0
- package/widgets/WebPopups/productsHost.d.ts +6 -0
- package/widgets/WebPopups/renderer.d.ts +2 -1
- package/widgets/WebPopups/types.d.ts +27 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"widget-subscription.js","mappings":"CAAA,SAAAA,EAAAC,GACA,oBAAAC,SAAA,iBAAAC,OACAA,OAAAD,QAAAD,EAAAG,QAAA,UAAAA,QAAA,iBAAAA,QAAA,4BACA,sBAAAC,QAAAA,OAAAC,IACAD,OAAA,gDAAAJ,OACA,CACA,IAAAM,EAAA,iBAAAL,QAAAD,EAAAG,QAAA,UAAAA,QAAA,iBAAAA,QAAA,uBAAAH,EAAAD,EAAA,OAAAA,EAAA,aAAAA,EAAA,YACA,QAAAQ,KAAAD,GAAA,i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GAAOnO,MAAMA,EAAO,GAAG6O,yBACzB,CAIA,GAFA5X,KAAKwL,iBAAmBxL,KAAKgZ,iBAEL,WAApBhZ,KAAKwL,WAIP,OAHAxL,KAAKgP,MAAO,OACZhP,KAAKqZ,SAKPrZ,KAAKuZ,MACP,CAEQ,OAAAb,GACN1Y,KAAKuZ,MACP,CAEQ,yBAAAL,GACN,MAAMoC,EAASN,UACbhb,KAAKwL,iBAAmBxL,KAAKgZ,iBAEL,YAApBhZ,KAAKwL,aACPxL,KAAKub,iBACLvb,KAAKuZ,QAGPvZ,KAAKqZ,UAGPrZ,KAAK8X,GAAG0D,mBAAmB,YAAaF,GACxCtb,KAAK8X,GAAG0D,mBAAmB,cAAeF,GAC1Ctb,KAAK8X,GAAG0D,mBAAmB,oBAAqBF,EAClD,CAEQ,cAAAC,GACqB,OAAvBvb,KAAKgY,gBACPyD,aAAazb,KAAKgY,eAClBhY,KAAKgY,cAAgB,KAEzB","sources":["webpack://web-push-notifications/webpack/universalModuleDefinition","webpack://web-push-notifications/external umd {\"commonjs\":\"preact\",\"commonjs2\":\"preact\",\"amd\":\"preact\",\"root\":\"preact\"}","webpack://web-push-notifications/external umd {\"commonjs\":\"preact/compat\",\"commonjs2\":\"preact/compat\",\"amd\":\"preact/compat\",\"root\":\"preactCompat\"}","webpack://web-push-notifications/external umd {\"commonjs\":\"preact/jsx-runtime\",\"commonjs2\":\"preact/jsx-runtime\",\"amd\":\"preact/jsx-runtime\",\"root\":\"jsxRuntime\"}","webpack://web-push-notifications/webpack/bootstrap","webpack://web-push-notifications/webpack/runtime/define property getters","webpack://web-push-notifications/webpack/runtime/hasOwnProperty shorthand","webpack://web-push-notifications/webpack/runtime/make namespace object","webpack://web-push-notifications/./node_modules/@pushwoosh/websdk-common/web-popups/constants.js","webpack://web-push-notifications/./node_modules/@pushwoosh/websdk-common/subscription-widget/constants.js","webpack://web-push-notifications/./node_modules/@pushwoosh/websdk-common/web-popups/palette.js","webpack://web-push-notifications/./node_modules/@pushwoosh/websdk-common/web-popups/helpers.js","webpack://web-push-notifications/./node_modules/@pushwoosh/websdk-common/subscription-widget/helpers.js","webpack://web-push-notifications/./node_modules/@pushwoosh/websdk-common/web-popups/colorScheme.js","webpack://web-push-notifications/./node_modules/@pushwoosh/websdk-common/web-popups/glyphs.js","webpack://web-push-notifications/./node_modules/@pushwoosh/websdk-common/subscription-widget/SubscriptionWidgetReader.js","webpack://web-push-notifications/./src/widgets/SubscriptionWidget/renderer.tsx","webpack://web-push-notifications/./src/modules/storage/migrations/constants.ts","webpack://web-push-notifications/./src/modules/storage/migrations/helpers.ts","webpack://web-push-notifications/./src/modules/storage/migrations/initial.ts","webpack://web-push-notifications/./src/modules/storage/migrations/Migrations.ts","webpack://web-push-notifications/./src/modules/storage/migrations/MigrationExecutor.ts","webpack://web-push-notifications/./src/core/storage.ts","webpack://web-push-notifications/./src/core/logger.ts","webpack://web-push-notifications/./src/widgets/SubscriptionWidget/SubscriptionWidget.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"preact\"), require(\"preact/compat\"), require(\"preact/jsx-runtime\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"preact\", \"preact/compat\", \"preact/jsx-runtime\"], factory);\n\telse {\n\t\tvar a = typeof exports === 'object' ? factory(require(\"preact\"), require(\"preact/compat\"), require(\"preact/jsx-runtime\")) : factory(root[\"preact\"], root[\"preactCompat\"], root[\"jsxRuntime\"]);\n\t\tfor(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];\n\t}\n})(this, (__WEBPACK_EXTERNAL_MODULE__524__, __WEBPACK_EXTERNAL_MODULE__873__, __WEBPACK_EXTERNAL_MODULE__247__) => {\nreturn ","module.exports = __WEBPACK_EXTERNAL_MODULE__524__;","module.exports = __WEBPACK_EXTERNAL_MODULE__873__;","module.exports = __WEBPACK_EXTERNAL_MODULE__247__;","// The module cache\nconst __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tconst cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tconst module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter/value functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop));","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","/**\n * Current stored-format version (WebPopupJson.version). Version 2 = the\n * layout-tree format (nested containers + Content/Image leaves, named content\n * zones). Version 1 (flat layout + single slot list) is retired without a\n * migration path — v1 popups are treated as broken, same as the pre-engine\n * ai-builder format.\n */\nexport const WEB_POPUP_VERSION = 2;\n// Bomb protection for the embedded layout tree — the json travels through a\n// public API, so the parser refuses to walk pathological trees.\nexport const WEB_POPUP_LAYOUT_MAX_DEPTH = 10;\nexport const WEB_POPUP_LAYOUT_MAX_NODES = 100;\n/** Protocols allowed in button hrefs (plus relative `#`/`/`/`?` prefixes). */\nexport const SAFE_URL_PROTOCOL = /^(https?:|mailto:|tel:)/i;\nexport const WEB_POPUP_FONT_STACK = 'Inter, system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif';\n// Palette defaults (mirror the editor's popup theme) — what a popup gets for\n// any WebPopupColors entry its json doesn't set.\nexport const WEB_POPUP_TEXT_COLOR = '#101828';\nexport const WEB_POPUP_TEXT_SECONDARY_COLOR = '#667085';\nexport const WEB_POPUP_ACCENT_COLOR = '#2970FF';\nexport const WEB_POPUP_BACKGROUND_COLOR = '#FFFFFF';\n/** Label over an accent fill in the light scheme; dark picks it by accent luminance. */\nexport const WEB_POPUP_ON_ACCENT_COLOR = '#FFFFFF';\nexport const WEB_POPUP_DEFAULT_COLORS = {\n background: WEB_POPUP_BACKGROUND_COLOR,\n accent: WEB_POPUP_ACCENT_COLOR,\n text: WEB_POPUP_TEXT_COLOR,\n textSecondary: WEB_POPUP_TEXT_SECONDARY_COLOR,\n textInverse: '#FFFFFF'\n};\n/** Fallback width used when a fixed-width context needs a number anyway. */\nexport const WEB_POPUP_DEFAULT_WIDTH = 360;\n/** Max height of an `<img>` in an Inline block: at full container width a side image would be too tall. */\nexport const WEB_POPUP_INLINE_IMAGE_MAX_HEIGHT = 360;\n// Per-variant text styles — the same numbers the editor's canvas derives from\n// its theme presets. No colors here: those come from the popup palette via\n// webPopupTextColor below.\nexport const WEB_POPUP_TEXT_VARIANT_STYLES = {\n h1: {\n fontSize: 24,\n fontWeight: 600,\n lineHeight: 1.25\n },\n h2: {\n fontSize: 18,\n fontWeight: 600,\n lineHeight: 1.3\n },\n h3: {\n fontSize: 16,\n fontWeight: 600,\n lineHeight: 1.35\n },\n body: {\n fontSize: 14,\n fontWeight: 'normal',\n lineHeight: 1.5\n },\n caption: {\n fontSize: 12,\n fontWeight: 'normal',\n lineHeight: 1.4\n },\n eyebrow: {\n fontSize: 11,\n fontWeight: 600,\n letterSpacing: '0.08em',\n lineHeight: 1.4\n },\n icon: {\n fontSize: 24,\n lineHeight: 1.2\n }\n};\n// Inverse-tone translucency per text style: headings full-strength, the\n// secondary variants toned down — same rhythm the palette's default white\n// set always had.\nconst INVERSE_TEXT_ALPHAS = {\n h1: 1,\n h2: 1,\n h3: 1,\n icon: 1,\n eyebrow: 0.8,\n body: 0.9,\n caption: 0.75\n};\n// colors.textInverse at the given opacity. Only #rgb/#rrggbb can be blended;\n// any other author-supplied css color renders full-strength rather than\n// being guessed at.\nfunction inverseColorAt(color, alpha) {\n if (alpha >= 1) return color;\n const hex = /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.exec(color)?.[1];\n if (!hex) return color;\n const full = hex.length === 3 ? hex.split('').map(c => c + c).join('') : hex;\n const [r, g, b] = [0, 2, 4].map(i => parseInt(full.slice(i, i + 2), 16));\n return `rgba(${r}, ${g}, ${b}, ${alpha})`;\n}\n/**\n * A text slot's color: the palette's main/secondary role by variant; in an\n * 'inverse' zone (over a background image) — colors.textInverse, with the\n * secondary variants toned translucent. Undefined for a non-inverse 'icon'\n * (an emoji line inherits — its glyphs aren't recolorable anyway).\n */\nexport function webPopupTextColor(variant, colors, inverse) {\n if (inverse) return inverseColorAt(colors.textInverse, INVERSE_TEXT_ALPHAS[variant] ?? 1);\n if (variant === 'icon') return undefined;\n return variant === 'caption' || variant === 'eyebrow' ? colors.textSecondary : colors.text;\n}\n/** The dark fill under a container's background image while it loads. */\nexport const WEB_POPUP_BG_SECTION_FALLBACK = '#1D2939';\nconst HEADING_VARIANTS = ['h1', 'h2', 'h3', 'icon'];\nexport function webPopupSlotRole(slot) {\n // An icon reads as the line above a title, so it hugs what follows; a\n // countdown wants a block's air, which the 'action' fallback gives it.\n if (slot.type === 'glyph') return 'heading';\n if (slot.type !== 'text') return 'action';\n return HEADING_VARIANTS.includes(slot.variant) ? 'heading' : 'text';\n}\nexport function webPopupSlotGap(prev, next) {\n if (next === 'action') return prev === 'action' ? 6 : 16;\n if (next === 'text' && prev === 'heading') return 4;\n return 8;\n}\n// Paddings INSIDE a form slot (field rows, submit pill); the rhythm above\n// owns the space BETWEEN slots.\nexport const WEB_POPUP_TEXT_SLOT_PADDING = '4px 0';\nexport const WEB_POPUP_BUTTON_SLOT_PADDING = '8px 0 4px';\n/**\n * The button pill both button slots and a form slot's submit button render\n * with — buttons pair the accent with white (primary = accent fill + white\n * label, secondary = white fill + accent outline). Shared with the editor's\n * canvas (parity contract).\n */\nexport function webPopupButtonPillStyle(variant, colors) {\n return {\n display: 'block',\n boxSizing: 'border-box',\n width: '100%',\n padding: '10px 25px',\n borderRadius: 6,\n fontSize: 14,\n fontWeight: 600,\n fontFamily: 'inherit',\n lineHeight: 1.5,\n textAlign: 'center',\n textDecoration: 'none',\n cursor: 'pointer',\n ...(variant === 'secondary' ? {\n backgroundColor: colors.surface,\n color: colors.accent,\n border: `1px solid ${colors.accent}`\n } : {\n backgroundColor: colors.accent,\n color: colors.onAccent,\n border: 'none'\n })\n };\n}\n// Form-slot input chrome, shared with the editor's canvas (parity contract):\n// a `surface` card whatever the zone tone, only the border varies.\nexport const WEB_POPUP_FORM_INPUT_BORDER = '#D0D5DD';\nexport const WEB_POPUP_FORM_ERROR_COLOR = '#D92D20';\n/** The error red lifted for a dark background — the same Untitled UI ramp, three steps up. */\nexport const WEB_POPUP_FORM_ERROR_COLOR_DARK = '#FDA29B';\nexport function webPopupFormInputStyle(colors, borderColor = colors.border) {\n return {\n display: 'block',\n boxSizing: 'border-box',\n width: '100%',\n padding: '10px 12px',\n borderRadius: 6,\n fontSize: 14,\n fontFamily: 'inherit',\n lineHeight: 1.5,\n backgroundColor: colors.surface,\n color: colors.surfaceText,\n border: `1px solid ${borderColor}`,\n outline: 'none'\n };\n}\n// What a normalized form slot falls back to when the json omits the copy —\n// also the editor's defaults for a freshly added slot.\nexport const WEB_POPUP_FORM_DEFAULTS = {\n submitLabel: 'Subscribe',\n successMessage: 'Thanks for subscribing!',\n confirmEmailMessage: 'Please check your inbox and confirm your email.'\n};\n// What a normalized choice slot falls back to when the json omits the copy.\nexport const WEB_POPUP_CHOICE_DEFAULTS = {\n submitLabel: 'Save',\n successMessage: 'Thanks! Your choice is saved.'\n};\n// Same, for a rating slot.\nexport const WEB_POPUP_RATING_DEFAULTS = {\n submitLabel: 'Send',\n successMessage: 'Thanks for the feedback!'\n};\n// The scores a scale offers, in display order; thumbs are 0/1 so `score` stays\n// \"higher is better\" everywhere. Shared with the editor canvas (parity).\nexport function webPopupRatingScores(scale) {\n if (scale === 'nps') return [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];\n if (scale === 'stars') return [1, 2, 3, 4, 5];\n return [0, 1];\n}\n/** Options a `choice` slot may carry; exported so the editor can't offer one normalization drops. */\nexport const WEB_POPUP_MAX_CHOICE_OPTIONS = 12;\n/** What a slot says when the host callback rejected: nothing actionable, so it's retryable. */\nexport const WEB_POPUP_RETRY_ERROR = 'Something went wrong. Please try again.';\n/** Email shape both form paths accept; the server runs the real check. */\nexport const WEB_POPUP_EMAIL_PATTERN = /^\\S+@\\S+\\.\\S+$/;\n/** Copy a Form's Email input falls back to — also the editor's defaults for a fresh block. */\nexport const WEB_POPUP_EMAIL_INPUT_DEFAULTS = {\n invalidMessage: 'Enter a valid email',\n requiredMessage: 'Required'\n};\n/** Copy a Form's Tag input falls back to. */\nexport const WEB_POPUP_TAG_INPUT_DEFAULTS = {\n requiredMessage: 'Required'\n};\n/** Copy a Form's Consent falls back to. */\nexport const WEB_POPUP_CONSENT_DEFAULTS = {\n requiredMessage: 'Please accept the privacy policy'\n};\n/** Copy a Form's Submit falls back to; the error is the retry line every submitting slot shows. */\nexport const WEB_POPUP_SUBMIT_DEFAULTS = {\n label: 'Submit',\n errorMessage: WEB_POPUP_RETRY_ERROR\n};\nexport const WEB_POPUP_KEYFRAMES = `\n@keyframes pw-vpopup-fade { from { opacity: 0; } }\n@keyframes pw-vpopup-slide { from { opacity: 0; translate: 0 28px; } }\n@keyframes pw-vpopup-overlay { from { opacity: 0; } }\n@keyframes pw-vpopup-page { from { opacity: 0; } }\n`;\n// Page-switch transition: the incoming page's content fades in while explicit\n// px sizes glide instead of jumping (auto sizes still snap — 'auto' can't be\n// transitioned). One duration for both so they read as a single move.\nexport const WEB_POPUP_PAGE_TRANSITION_MS = 300;","import { WEB_POPUP_DEFAULT_COLORS, WEB_POPUP_FONT_STACK } from '../web-popups/constants';\n/** Positions each layout accepts; the first one is the layout's default. */\nexport const SUBSCRIPTION_WIDGET_POSITIONS = {\n card: ['top', 'bottom', 'top-left', 'top-right', 'bottom-left', 'bottom-right'],\n bar: ['top', 'bottom'],\n modal: ['center']\n};\nexport const SUBSCRIPTION_WIDGET_LAYOUTS = Object.keys(SUBSCRIPTION_WIDGET_POSITIONS);\nexport const SUBSCRIPTION_WIDGET_CORNERS = ['bottom-right', 'bottom-left', 'top-right', 'top-left'];\nexport const SUBSCRIPTION_WIDGET_TRIGGERS = ['auto', 'launcher', 'manual'];\n/** Inclusive bounds every numeric field is clamped to. */\nexport const SUBSCRIPTION_WIDGET_LIMITS = {\n delay: [0, 3600],\n cappingCount: [0, 100],\n cappingInterval: [0, 8760],\n borderRadius: [0, 32],\n offset: [0, 100],\n launcherSize: [16, 200],\n zIndex: [0, 2147483647]\n};\nexport const SUBSCRIPTION_WIDGET_TEXT_MAX_LENGTH = 300;\nexport const SUBSCRIPTION_WIDGET_COLOR_MAX_LENGTH = 64;\nexport const SUBSCRIPTION_WIDGET_DEFAULT_CONFIG = {\n enable: false,\n prompt: {\n enabled: false,\n layout: 'card',\n position: 'top',\n borderRadius: 12,\n overlay: false\n },\n launcher: {\n enabled: false,\n position: 'bottom-right',\n offset: 20,\n width: 48,\n height: 48\n },\n display: {\n trigger: 'auto',\n delay: 5,\n cappingCount: 3,\n cappingInterval: 4\n },\n texts: {\n title: 'Stay in the loop',\n message: 'Allow notifications to get our news and special offers first.',\n acceptText: 'Allow',\n declineText: 'Not now',\n closeText: 'Got it',\n blockedTitle: 'Notifications are blocked',\n blockedMessage: 'To get our notifications, allow them for this site in your browser settings.',\n launcherLabel: 'Subscribe to notifications',\n launcherBlockedLabel: 'Notifications are blocked'\n },\n colors: WEB_POPUP_DEFAULT_COLORS,\n fontFamily: WEB_POPUP_FONT_STACK,\n zIndex: 2147483000\n};\nexport const SUBSCRIPTION_WIDGET_KEYFRAMES = `\n@keyframes pw-subw-fade { from { opacity: 0; } }\n@keyframes pw-subw-drop { from { opacity: 0; translate: 0 -16px; } }\n@keyframes pw-subw-rise { from { opacity: 0; translate: 0 16px; } }\n`;","// Scheme resolution for the popup palette: the authored light/dark roles plus\n// the derived ones (input surface, borders, the label over an accent fill).\nimport { WEB_POPUP_DEFAULT_COLORS, WEB_POPUP_FORM_ERROR_COLOR, WEB_POPUP_FORM_ERROR_COLOR_DARK, WEB_POPUP_FORM_INPUT_BORDER, WEB_POPUP_ON_ACCENT_COLOR, WEB_POPUP_TEXT_COLOR, WEB_POPUP_TEXT_SECONDARY_COLOR } from './constants';\nconst HEX_RE = /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;\nfunction parseHex(color) {\n const hex = HEX_RE.exec(color.trim())?.[1];\n if (!hex) return null;\n const full = hex.length === 3 ? hex.split('').map(c => c + c).join('') : hex;\n return [0, 2, 4].map(i => parseInt(full.slice(i, i + 2), 16));\n}\nfunction toHex([r, g, b]) {\n return `#${[r, g, b].map(v => Math.max(0, Math.min(255, Math.round(v))).toString(16).padStart(2, '0')).join('')}`;\n}\nfunction rgbToHsl([r, g, b]) {\n const [rn, gn, bn] = [r / 255, g / 255, b / 255];\n const max = Math.max(rn, gn, bn);\n const min = Math.min(rn, gn, bn);\n const l = (max + min) / 2;\n if (max === min) return [0, 0, l];\n const d = max - min;\n const s = l > 0.5 ? d / (2 - max - min) : d / (max + min);\n let h;\n if (max === rn) h = (gn - bn) / d + (gn < bn ? 6 : 0);else if (max === gn) h = (bn - rn) / d + 2;else h = (rn - gn) / d + 4;\n return [h / 6, s, l];\n}\nfunction hueToChannel(p, q, t) {\n let tn = t;\n if (tn < 0) tn += 1;\n if (tn > 1) tn -= 1;\n if (tn < 1 / 6) return p + (q - p) * 6 * tn;\n if (tn < 1 / 2) return q;\n if (tn < 2 / 3) return p + (q - p) * (2 / 3 - tn) * 6;\n return p;\n}\nfunction hslToRgb([h, s, l]) {\n if (s === 0) {\n const v = l * 255;\n return [v, v, v];\n }\n const q = l < 0.5 ? l * (1 + s) : l + s - l * s;\n const p = 2 * l - q;\n return [hueToChannel(p, q, h + 1 / 3) * 255, hueToChannel(p, q, h) * 255, hueToChannel(p, q, h - 1 / 3) * 255];\n}\n// Mirror the light half onto [0.07, 0.5]: #FFFFFF lands on the dark canvas\n// tone and near-whites stay apart instead of collapsing into one floor.\nfunction foldLightness(l) {\n return l > 0.5 ? 0.07 + (1 - l) * ((0.5 - 0.07) / 0.5) : l;\n}\n// Mirror the dark half onto [0.5, 0.93]: #000000 lands short of glaring white.\nfunction liftLightness(l) {\n return l < 0.5 ? 0.93 - l * ((0.93 - 0.5) / 0.5) : l;\n}\n/** Hue and saturation survive; only lightness moves. Non-hex colors pass through. */\nexport function webPopupShiftColor(color, direction) {\n const rgb = parseHex(color);\n if (!rgb) return color;\n const [h, s, l] = rgbToHsl(rgb);\n return toHex(hslToRgb([h, s, direction === 'fold' ? foldLightness(l) : liftLightness(l)]));\n}\n/** `ratio` of `over` blended into `base`; either color non-hex = `base` unchanged. */\nexport function webPopupMixColor(base, over, ratio) {\n const a = parseHex(base);\n const b = parseHex(over);\n if (!a || !b) return base;\n return toHex(a.map((v, i) => v + (b[i] - v) * ratio));\n}\n/** `color` at `alpha` as rgba(); a non-hex color renders full-strength instead of being guessed at. */\nexport function webPopupColorAlpha(color, alpha) {\n const rgb = parseHex(color);\n if (!rgb || alpha >= 1) return color;\n const [r, g, b] = rgb;\n return `rgba(${r}, ${g}, ${b}, ${alpha})`;\n}\nfunction isLightColor(color) {\n const rgb = parseHex(color);\n if (!rgb) return false;\n // Perceived luminance, not HSL lightness: #FFFF00 and #0000FF share l = 0.5.\n const [r, g, b] = rgb;\n return (0.299 * r + 0.587 * g + 0.114 * b) / 255 > 0.6;\n}\n// The dark counterpart of a light palette: text lifts, surfaces fold, the\n// accent and the over-image inverse color stay as authored.\nexport function autoDarkWebPopupColors(light) {\n return {\n background: webPopupShiftColor(light.background, 'fold'),\n accent: light.accent,\n text: webPopupShiftColor(light.text, 'lift'),\n textSecondary: webPopupShiftColor(light.textSecondary, 'lift'),\n textInverse: light.textInverse\n };\n}\n// Light keeps the values the popup shipped with before dark mode existed\n// (white cards, grey border, white label) — enabling dark must not restyle it.\nfunction derivedColors(colors, scheme) {\n if (scheme === 'light') {\n return {\n surface: WEB_POPUP_DEFAULT_COLORS.background,\n surfaceText: WEB_POPUP_TEXT_COLOR,\n border: WEB_POPUP_FORM_INPUT_BORDER,\n onAccent: WEB_POPUP_ON_ACCENT_COLOR,\n error: WEB_POPUP_FORM_ERROR_COLOR,\n chromeIcon: WEB_POPUP_TEXT_SECONDARY_COLOR\n };\n }\n return {\n surface: webPopupMixColor(colors.background, colors.text, 0.08),\n surfaceText: colors.text,\n border: webPopupMixColor(colors.background, colors.text, 0.24),\n onAccent: isLightColor(colors.accent) ? WEB_POPUP_TEXT_COLOR : WEB_POPUP_ON_ACCENT_COLOR,\n error: WEB_POPUP_FORM_ERROR_COLOR_DARK,\n chromeIcon: colors.textSecondary\n };\n}\n/** The dark palette a popup renders with: authored roles over the autogenerated ones. */\nexport function webPopupDarkColors(light, dark) {\n return {\n ...autoDarkWebPopupColors(light),\n ...(dark?.colors ?? {})\n };\n}\n/** True when the popup opts into dark mode at all — the host's cue to watch the media query. */\nexport function webPopupDarkEnabled(chrome) {\n return chrome.dark?.enabled === true;\n}\n/** The scheme a popup actually draws with: 'dark' only when it opts in. */\nexport function webPopupEffectiveScheme(chrome, scheme = 'light') {\n return scheme === 'dark' && webPopupDarkEnabled(chrome) ? 'dark' : 'light';\n}\n// Every color a renderer needs, for the scheme actually drawn. Asking for\n// 'dark' on a popup without dark mode returns the light palette.\nexport function resolveWebPopupColors(chrome, scheme = 'light') {\n const effective = webPopupEffectiveScheme(chrome, scheme);\n const colors = effective === 'dark' ? webPopupDarkColors(chrome.colors, chrome.dark) : chrome.colors;\n return {\n ...colors,\n scheme: effective,\n ...derivedColors(colors, effective)\n };\n}\n/** The url drawn for `scheme`; a dark source only exists when authored. */\nexport function webPopupImageSrc(image, scheme = 'light') {\n return scheme === 'dark' && image.srcDark ? image.srcDark : image.src;\n}\n/** The page dim and box shadow for the scheme actually drawn; the light ones\n * stand in wherever the dark palette authored no override. */\nexport function resolveWebPopupBoxChrome(chrome, scheme = 'light') {\n if (webPopupEffectiveScheme(chrome, scheme) === 'light') {\n return {\n overlay: chrome.overlay,\n boxShadow: chrome.boxShadow\n };\n }\n return {\n overlay: chrome.dark?.overlay ?? chrome.overlay,\n boxShadow: chrome.dark?.boxShadow ?? chrome.boxShadow\n };\n}","import { SAFE_URL_PROTOCOL, WEB_POPUP_CHOICE_DEFAULTS, WEB_POPUP_CONSENT_DEFAULTS, WEB_POPUP_DEFAULT_COLORS, WEB_POPUP_EMAIL_INPUT_DEFAULTS, WEB_POPUP_FORM_DEFAULTS, WEB_POPUP_MAX_CHOICE_OPTIONS, WEB_POPUP_RATING_DEFAULTS, WEB_POPUP_SUBMIT_DEFAULTS, WEB_POPUP_TAG_INPUT_DEFAULTS, WEB_POPUP_VERSION } from './constants';\nimport { WEB_POPUP_GLYPH_NAMES, WEB_POPUP_GLYPH_SIZES } from './glyphs';\nimport { normalizeWebPopupLayout, substituteWebPopupLayoutValues, WEB_POPUP_VALUE_KEY_PATTERN } from './layout';\nimport { autoDarkWebPopupColors } from './palette';\nimport { webPopupTimeZoneSupported, webPopupWallClockMs } from './timer';\n// Sanitize a user-entered button URL before it lands in an href: https/http/\n// mailto/tel and page-relative links only.\nexport function safeUrl(url) {\n const trimmed = (url || '').trim();\n if (!trimmed) return undefined;\n if (trimmed.startsWith('#') || trimmed.startsWith('/') || trimmed.startsWith('?')) return trimmed;\n if (SAFE_URL_PROTOCOL.test(trimmed)) return trimmed;\n return undefined;\n}\n/**\n * The target/rel pair a popup link renders with: only an exact '_self' opts\n * out of the default new tab (and of its noreferrer, which same-tab\n * navigation doesn't need). One rule for both link kinds — the reader's\n * button anchors and the sanitizer's inline text links.\n */\nexport function webPopupLinkTargetAttrs(target) {\n return target === '_self' ? {\n target: '_self'\n } : {\n target: '_blank',\n rel: 'noreferrer'\n };\n}\n/**\n * Carries out a subscribe button's setting for the visitor's answer; true = the content closes.\n * A new tab opens with noopener, so `window.open` returns null and a blocked tab goes unnoticed.\n */\nexport function applyWebPopupSubscribeOutcome(action, result, logger) {\n const outcome = result === 'granted' ? action.onGranted : action.onDenied;\n if (outcome?.type === 'href') openWebPopupSubscribeLink(outcome, logger);\n // Granted always closes, as before the setting; denied closes only when set to.\n if (result === 'granted') return true;\n return outcome?.type === 'close';\n}\nfunction openWebPopupSubscribeLink(outcome, logger) {\n const href = typeof outcome.url === 'string' ? safeUrl(outcome.url) : undefined;\n if (!href) {\n logger?.warn('Subscribe button: the link to open after the answer is empty or unsafe, it was not opened');\n return;\n }\n if (outcome.target === '_self') {\n window.location.assign(href);\n return;\n }\n window.open(href, '_blank', 'noopener,noreferrer');\n}\nconst SANITIZE_ALLOWED_TAGS = new Set(['STRONG', 'B', 'EM', 'I', 'U', 'BR', 'A']);\nfunction copySanitized(from, to, doc) {\n for (const child of Array.from(from.childNodes)) {\n if (child.nodeType === 3 /* text */) {\n to.appendChild(doc.createTextNode(child.textContent ?? ''));\n continue;\n }\n if (child.nodeType !== 1 /* element */) continue;\n const el = child;\n // Unknown tags are unwrapped — their children survive as plain content.\n if (!SANITIZE_ALLOWED_TAGS.has(el.tagName)) {\n copySanitized(el, to, doc);\n continue;\n }\n const clean = doc.createElement(el.tagName.toLowerCase());\n if (el.tagName === 'A') {\n const href = safeUrl(el.getAttribute('href') ?? undefined);\n if (href) clean.setAttribute('href', href);\n const {\n target,\n rel\n } = webPopupLinkTargetAttrs(el.getAttribute('target'));\n clean.setAttribute('target', target);\n if (rel) clean.setAttribute('rel', rel);\n }\n to.appendChild(clean);\n copySanitized(el, clean, doc);\n }\n}\n/**\n * Sanitize a text slot's html before it's injected into the page. The editor\n * only ever writes inline formatting, but the json travels through a public\n * API and renders on customers' sites — so on render only the inline tags\n * survive (anything else is unwrapped to its text), every attribute is\n * dropped, and links keep only a safeUrl-approved href plus their tab choice\n * (target=\"_self\" stays; everything else opens in a new tab).\n */\nexport function sanitizeWebPopupHtml(html) {\n // No '<' → no elements can form; entities in plain text are already-valid\n // html and pass through untouched.\n if (!html.includes('<')) return html;\n const parsed = new DOMParser().parseFromString(html, 'text/html');\n const out = parsed.createElement('div');\n copySanitized(parsed.body, out, parsed);\n return out.innerHTML;\n}\nfunction colorString(value) {\n return typeof value === 'string' && value ? value : undefined;\n}\n/**\n * The popup palette from API-writable params: `colors` entries when present,\n * the legacy top-level background/accent underneath, palette defaults for the\n * rest — always a complete WebPopupColors.\n */\nexport function normalizeWebPopupColors(params) {\n const colors = typeof params.colors === 'object' && params.colors !== null ? params.colors : {};\n return {\n background: colorString(colors.background) ?? colorString(params.background) ?? WEB_POPUP_DEFAULT_COLORS.background,\n accent: colorString(colors.accent) ?? colorString(params.accent) ?? WEB_POPUP_DEFAULT_COLORS.accent,\n text: colorString(colors.text) ?? WEB_POPUP_DEFAULT_COLORS.text,\n textSecondary: colorString(colors.textSecondary) ?? WEB_POPUP_DEFAULT_COLORS.textSecondary,\n textInverse: colorString(colors.textInverse) ?? WEB_POPUP_DEFAULT_COLORS.textInverse\n };\n}\n// A page dim from API-writable json: both fields or nothing, opacity clamped.\nfunction normalizeOverlay(raw) {\n if (typeof raw !== 'object' || raw === null) return undefined;\n const overlay = raw;\n const color = colorString(overlay.color);\n if (!color) return undefined;\n const opacity = typeof overlay.opacity === 'number' && Number.isFinite(overlay.opacity) ? Math.max(0, Math.min(1, overlay.opacity)) : 1;\n return {\n color,\n opacity\n };\n}\n// Authored dark entries over the ones autogenerated from the light palette.\n// Absent `dark` = no dark mode; an authored palette switched off is not that.\nexport function normalizeWebPopupDark(params, light) {\n const raw = params.dark;\n if (typeof raw !== 'object' || raw === null) return undefined;\n const dark = raw;\n const authored = typeof dark.colors === 'object' && dark.colors !== null ? dark.colors : {};\n const auto = autoDarkWebPopupColors(light);\n const overlay = normalizeOverlay(dark.overlay);\n return {\n enabled: dark.enabled === true,\n colors: {\n background: colorString(authored.background) ?? auto.background,\n accent: colorString(authored.accent) ?? auto.accent,\n text: colorString(authored.text) ?? auto.text,\n textSecondary: colorString(authored.textSecondary) ?? auto.textSecondary,\n textInverse: colorString(authored.textInverse) ?? auto.textInverse\n },\n ...(overlay ? {\n overlay\n } : {}),\n ...(colorString(dark.boxShadow) ? {\n boxShadow: dark.boxShadow\n } : {})\n };\n}\n// Parse stored PopupFormContent.json into the popup model. Returns null for\n// anything that isn't a version-2 popup with at least one page — including\n// the retired version-1 flat-layout format and pre-engine content with no\n// `version` field at all, which callers should treat as broken. The palette\n// comes out complete: colors entries → legacy top-level background/accent →\n// defaults.\nexport function parseWebPopupJson(json) {\n let raw;\n try {\n raw = JSON.parse(json);\n } catch {\n return null;\n }\n if (typeof raw !== 'object' || raw === null) return null;\n const candidate = raw;\n if (candidate.version !== WEB_POPUP_VERSION) return null;\n const params = candidate.params;\n if (typeof params !== 'object' || params === null) return null;\n if (!Array.isArray(params.pages) || params.pages.length === 0) return null;\n const colors = normalizeWebPopupColors(params);\n const dark = normalizeWebPopupDark(params, colors);\n return {\n version: WEB_POPUP_VERSION,\n params: {\n ...params,\n colors,\n ...(dark ? {\n dark\n } : {})\n }\n };\n}\n/** The editor's save path: model → PopupFormContent.json string. */\nexport function stringifyWebPopup(params) {\n const compat = {\n ...params,\n background: params.colors.background,\n accent: params.colors.accent\n };\n const payload = {\n version: WEB_POPUP_VERSION,\n params: compat\n };\n return JSON.stringify(payload);\n}\nconst IMAGE_FITS = ['cover', 'contain'];\nconst MAX_IMAGE_BLUR = 100;\n// Bomb protection for the page content, mirroring the layout tree's\n// depth/node caps: the tree allows up to ~100 Content nodes and several may\n// reference the same zone, so unbounded zones/slots would amplify into\n// thousands of sanitize+render passes on the customer's page.\nconst MAX_IMAGES = 20;\nconst MAX_ZONES = 20;\nconst MAX_ZONE_SLOTS = 50;\n// A media param's video, or undefined when it has none / an unusable url —\n// then the param stays a plain image and the poster is all that renders.\nfunction normalizeVideo(raw) {\n if (typeof raw !== 'object' || raw === null) return undefined;\n const video = raw;\n const src = safeUrl(typeof video.src === 'string' ? video.src : undefined);\n if (!src) return undefined;\n return {\n src,\n ...(video.controls === true ? {\n controls: true\n } : {}),\n ...(video.loop === false ? {\n loop: false\n } : {})\n };\n}\n// The images come from API-writable json — keep only well-formed entries,\n// with the presentation props (fit/blur) validated like the layout tree's.\nfunction normalizeImages(raw) {\n if (!Array.isArray(raw)) return [];\n const out = [];\n for (const img of raw) {\n if (out.length >= MAX_IMAGES) break;\n if (typeof img !== 'object' || img === null) continue;\n if (typeof img.key !== 'string' || !img.key) continue;\n if (typeof img.src !== 'string') continue;\n const video = normalizeVideo(img.video);\n out.push({\n key: img.key,\n label: typeof img.label === 'string' ? img.label : '',\n src: img.src,\n ...(typeof img.srcDark === 'string' && img.srcDark ? {\n srcDark: img.srcDark\n } : {}),\n ...(video ? {\n video\n } : {}),\n ...(typeof img.mediaId === 'string' && img.mediaId ? {\n mediaId: img.mediaId\n } : {}),\n ...(typeof img.mediaIdDark === 'string' && img.mediaIdDark ? {\n mediaIdDark: img.mediaIdDark\n } : {}),\n ...(IMAGE_FITS.includes(img.fit) ? {\n fit: img.fit\n } : {}),\n ...(typeof img.blur === 'number' && Number.isFinite(img.blur) && img.blur > 0 ? {\n blur: Math.min(img.blur, MAX_IMAGE_BLUR)\n } : {}),\n ...(typeof img.dim === 'number' && Number.isFinite(img.dim) && img.dim > 0 ? {\n dim: Math.min(img.dim, 1)\n } : {})\n });\n }\n return out;\n}\nconst MAX_VALUES = 20;\nconst MAX_VALUE_LENGTH = 64;\nconst MAX_SELECT_OPTIONS = 20;\nconst LENGTH_CONTROL_UNITS = ['px', '%', 'em', 'rem', 'fr'];\nfunction finiteNumber(value) {\n return typeof value === 'number' && Number.isFinite(value) ? value : undefined;\n}\n// Per-unit { min?, max? } overrides for a length control, keyed by a\n// whitelisted unit. Non-object input, unknown unit keys and non-finite bounds\n// are dropped; an all-empty map returns undefined so the field is omitted.\nfunction normalizeControlRanges(raw) {\n if (typeof raw !== 'object' || raw === null) return undefined;\n const out = {};\n for (const unit of LENGTH_CONTROL_UNITS) {\n const entry = raw[unit];\n if (typeof entry !== 'object' || entry === null) continue;\n const min = finiteNumber(entry.min);\n const max = finiteNumber(entry.max);\n if (min === undefined && max === undefined) continue;\n out[unit] = {\n ...(min !== undefined ? {\n min\n } : {}),\n ...(max !== undefined ? {\n max\n } : {})\n };\n }\n return Object.keys(out).length > 0 ? out : undefined;\n}\n// The control is editor metadata from API-writable json: enum-whitelisted\n// kind, clamped numbers, capped options. Anything malformed drops to\n// undefined — the editor falls back to a plain text input.\nfunction normalizeValueControl(raw) {\n if (typeof raw !== 'object' || raw === null) return undefined;\n const control = raw;\n if (control.kind === 'text') return {\n kind: 'text'\n };\n if (control.kind === 'length' || control.kind === 'percent') {\n const min = finiteNumber(control.min);\n const max = finiteNumber(control.max);\n const units = control.kind === 'length' && Array.isArray(control.units) ? control.units.filter(u => LENGTH_CONTROL_UNITS.includes(u)) : [];\n // Per-unit min/max overrides: whitelisted unit keys, finite bounds. Any\n // malformed entry is skipped; an empty result drops the whole field.\n const ranges = control.kind === 'length' ? normalizeControlRanges(control.ranges) : undefined;\n return {\n kind: control.kind,\n ...(min !== undefined ? {\n min\n } : {}),\n ...(max !== undefined ? {\n max\n } : {}),\n ...(units.length > 0 ? {\n units\n } : {}),\n ...(ranges ? {\n ranges\n } : {})\n };\n }\n if (control.kind === 'select' && Array.isArray(control.options)) {\n const options = [];\n for (const option of control.options) {\n if (options.length >= MAX_SELECT_OPTIONS) break;\n if (typeof option !== 'object' || option === null) continue;\n if (typeof option.value !== 'string' || option.value.length > MAX_VALUE_LENGTH) continue;\n options.push({\n value: option.value,\n label: typeof option.label === 'string' ? option.label : option.value\n });\n }\n if (options.length > 0) return {\n kind: 'select',\n options\n };\n }\n return undefined;\n}\n/**\n * The page's named layout values from API-writable json: capped count,\n * whitelisted keys, short '$'-free value strings (substitution is single-pass\n * and this keeps refs from even *looking* chainable), validated controls.\n */\nexport function normalizeWebPopupValues(raw) {\n if (!Array.isArray(raw)) return [];\n const out = [];\n for (const value of raw) {\n if (out.length >= MAX_VALUES) break;\n if (typeof value !== 'object' || value === null) continue;\n if (typeof value.key !== 'string' || !WEB_POPUP_VALUE_KEY_PATTERN.test(value.key)) continue;\n if (typeof value.value !== 'string' || value.value.length > MAX_VALUE_LENGTH || value.value.includes('$')) continue;\n if (out.some(v => v.key === value.key)) continue;\n const control = normalizeValueControl(value.control);\n out.push({\n key: value.key,\n label: typeof value.label === 'string' ? value.label : '',\n value: value.value,\n ...(control ? {\n control\n } : {})\n });\n }\n return out;\n}\n/** The values as a substitution map (see substituteWebPopupLayoutValues). */\nexport function webPopupValuesMap(values) {\n return Object.fromEntries(values.map(v => [v.key, v.value]));\n}\nconst FORM_FIELD_KINDS = ['email', 'firstName', 'lastName', 'phone', 'custom'];\nconst BUTTON_VARIANTS = ['primary', 'secondary'];\nconst MAX_FORM_FIELDS = 10;\n// A form slot's fields from API-writable json: capped, whitelisted kinds,\n// deduped keys. The submit contract needs an email — when none survives, one\n// is injected up front (the slot stays renderable/editable rather than being\n// dropped: the editor canvas resolves through this same pipeline). Email\n// fields are always required — the payload can't form without a value.\nfunction normalizeFormFields(raw) {\n const out = [];\n if (Array.isArray(raw)) {\n for (const field of raw) {\n if (out.length >= MAX_FORM_FIELDS) break;\n if (typeof field !== 'object' || field === null) continue;\n if (typeof field.key !== 'string' || !field.key) continue;\n if (!FORM_FIELD_KINDS.includes(field.kind)) continue;\n if (out.some(f => f.key === field.key)) continue;\n out.push({\n key: field.key,\n kind: field.kind,\n label: typeof field.label === 'string' ? field.label : '',\n placeholder: typeof field.placeholder === 'string' ? field.placeholder : '',\n required: field.kind === 'email' || field.required === true,\n ...(field.kind === 'custom' && typeof field.tag === 'string' && field.tag ? {\n tag: field.tag\n } : {})\n });\n }\n }\n if (!out.some(f => f.kind === 'email')) {\n let key = 'field-email';\n while (out.some(f => f.key === key)) key = `${key}-1`;\n out.unshift({\n key,\n kind: 'email',\n label: 'Email',\n placeholder: '',\n required: true\n });\n }\n return out.slice(0, MAX_FORM_FIELDS);\n}\nconst CHOICE_CONTROLS = ['checkbox', 'chips'];\nconst RATING_SCALES = ['nps', 'stars', 'thumbs'];\nconst RATING_SUBMIT_MODES = ['instant', 'button'];\nconst TIMER_EXPIRE_ACTIONS = ['keep', 'hide-popup', 'page'];\nconst LANGUAGE_CODE = /^[a-z]{2}$/i;\nconst HEX_COLOR = /^#[0-9a-fA-F]{6}$/;\n// Authored strings from API-writable json land in the popup's own markup on a\n// customer's page — capped so a 100kB \"label\" can't be one.\nconst MAX_SLOT_STRING = 120;\nconst MAX_SLOT_MESSAGE = 500;\nfunction slotString(value, max = MAX_SLOT_STRING) {\n return typeof value === 'string' ? value.trim().slice(0, max) : '';\n}\n// A capped string with a fallback for when the json omits it (or sends blanks).\nfunction slotStringOr(value, fallback, max = MAX_SLOT_STRING) {\n return slotString(value, max) || fallback;\n}\n/** An ISO 639-1 code, lowercased; anything else = '' (the renderer's 'en'). */\nfunction normalizeLanguage(value) {\n const code = slotString(value, 8);\n return LANGUAGE_CODE.test(code) ? code.toLowerCase() : '';\n}\n// Capped, non-empty values, deduped, label falling back to the value. An\n// option-less slot survives, like an unbound form: the editor must still edit it.\nfunction normalizeChoiceOptions(raw) {\n if (!Array.isArray(raw)) return [];\n const out = [];\n for (const option of raw) {\n if (out.length >= WEB_POPUP_MAX_CHOICE_OPTIONS) break;\n if (typeof option !== 'object' || option === null) continue;\n const value = slotString(option.value);\n if (!value) continue;\n if (out.some(existing => existing.value === value)) continue;\n const tagValue = slotString(option.tagValue);\n out.push({\n value,\n label: slotStringOr(option.label, value),\n ...(tagValue ? {\n tagValue\n } : {})\n });\n }\n return out;\n}\n// The selection bounds against the surviving option count: 0 = unbounded, and\n// a max under the min would leave the slot unsubmittable — the min wins.\nfunction normalizeChoiceBounds(slot, options) {\n const bound = value => {\n const n = finiteNumber(value);\n return n === undefined || n <= 0 ? 0 : Math.min(Math.floor(n), options);\n };\n const min = bound(slot.min);\n const max = bound(slot.max);\n return {\n min,\n max: max > 0 ? Math.max(min, max) : 0\n };\n}\n// Per-type slot validation. Text and button entries pass through UNTOUCHED\n// when well-formed (stored popups predate this check — don't rewrite them);\n// a form slot is rebuilt field by field; an unknown slot type is dropped so\n// slot types added after this engine build degrade to absence, not a crash.\nfunction normalizeSlots(raw) {\n const out = [];\n for (const slot of raw) {\n if (out.length >= MAX_ZONE_SLOTS) break;\n if (typeof slot !== 'object' || slot === null) continue;\n if (typeof slot.key !== 'string' || !slot.key) continue;\n if (slot.type === 'text') {\n if (typeof slot.html === 'string') out.push(slot);\n continue;\n }\n if (slot.type === 'button') {\n // An action-less button would crash the renderer on the action switch.\n if (typeof slot.action === 'object' && slot.action !== null && typeof slot.action.type === 'string') {\n out.push(slot);\n }\n continue;\n }\n if (slot.type === 'timer') {\n // An unsupported zone name degrades to the contract's UTC rather than\n // dropping the countdown.\n const zone = slotString(slot.timezone, 64);\n const timezone = webPopupTimeZoneSupported(zone) ? zone : '';\n const endTime = slotString(slot.endTime, 32);\n // No computable deadline = nothing to count down to.\n if (webPopupWallClockMs(endTime, timezone) === null) continue;\n const expirePage = slotString(slot.expirePage);\n const onExpire = TIMER_EXPIRE_ACTIONS.includes(slot.onExpire) ? slot.onExpire : 'keep';\n // 'page' without a target page is 'keep' — the renderer never has to\n // guess where a pageless jump should land.\n const expires = onExpire === 'page' && !expirePage ? 'keep' : onExpire;\n out.push({\n type: 'timer',\n key: slot.key,\n endTime,\n timezone,\n language: normalizeLanguage(slot.language),\n showLabels: slot.showLabels !== false,\n onExpire: expires,\n ...(expires === 'page' ? {\n expirePage\n } : {})\n });\n continue;\n }\n if (slot.type === 'choice') {\n const options = normalizeChoiceOptions(slot.options);\n const {\n min,\n max\n } = normalizeChoiceBounds(slot, options.length);\n out.push({\n type: 'choice',\n key: slot.key,\n control: CHOICE_CONTROLS.includes(slot.control) ? slot.control : 'checkbox',\n tagName: slotString(slot.tagName),\n options,\n min,\n max,\n submitLabel: slotStringOr(slot.submitLabel, WEB_POPUP_CHOICE_DEFAULTS.submitLabel),\n submitVariant: BUTTON_VARIANTS.includes(slot.submitVariant) ? slot.submitVariant : 'primary',\n successMessage: slotStringOr(slot.successMessage, WEB_POPUP_CHOICE_DEFAULTS.successMessage, MAX_SLOT_MESSAGE)\n });\n continue;\n }\n if (slot.type === 'rating') {\n const labels = typeof slot.labels === 'object' && slot.labels !== null ? slot.labels : {};\n out.push({\n type: 'rating',\n key: slot.key,\n // A malformed scale renders as stars: five buttons read the same in\n // every language, which an 0..10 row does not.\n scale: RATING_SCALES.includes(slot.scale) ? slot.scale : 'stars',\n labels: {\n low: slotString(labels.low),\n high: slotString(labels.high)\n },\n submitMode: RATING_SUBMIT_MODES.includes(slot.submitMode) ? slot.submitMode : 'instant',\n submitLabel: slotStringOr(slot.submitLabel, WEB_POPUP_RATING_DEFAULTS.submitLabel),\n eventName: slotString(slot.eventName),\n successMessage: slotStringOr(slot.successMessage, WEB_POPUP_RATING_DEFAULTS.successMessage, MAX_SLOT_MESSAGE)\n });\n continue;\n }\n if (slot.type === 'glyph') {\n // An unknown icon name has no geometry to draw — dropped, exactly like\n // an unknown slot type.\n if (!WEB_POPUP_GLYPH_NAMES.includes(slot.name)) continue;\n out.push({\n type: 'glyph',\n key: slot.key,\n name: slot.name,\n size: WEB_POPUP_GLYPH_SIZES.includes(slot.size) ? slot.size : WEB_POPUP_GLYPH_SIZES[0],\n color: typeof slot.color === 'string' && HEX_COLOR.test(slot.color) ? slot.color : ''\n });\n continue;\n }\n if (slot.type === 'email-input') {\n out.push({\n type: 'email-input',\n key: slot.key,\n label: slotString(slot.label),\n placeholder: slotString(slot.placeholder),\n invalidMessage: slotStringOr(slot.invalidMessage, WEB_POPUP_EMAIL_INPUT_DEFAULTS.invalidMessage),\n requiredMessage: slotStringOr(slot.requiredMessage, WEB_POPUP_EMAIL_INPUT_DEFAULTS.requiredMessage)\n });\n continue;\n }\n if (slot.type === 'tag-input') {\n out.push({\n type: 'tag-input',\n key: slot.key,\n tagName: slotString(slot.tagName),\n label: slotString(slot.label),\n placeholder: slotString(slot.placeholder),\n required: slot.required === true,\n requiredMessage: slotStringOr(slot.requiredMessage, WEB_POPUP_TAG_INPUT_DEFAULTS.requiredMessage)\n });\n continue;\n }\n if (slot.type === 'consent') {\n out.push({\n type: 'consent',\n key: slot.key,\n checkboxLabel: slotString(slot.checkboxLabel, MAX_SLOT_MESSAGE),\n linkLabel: slotString(slot.linkLabel),\n url: slotString(slot.url, MAX_SLOT_MESSAGE),\n requiredMessage: slotStringOr(slot.requiredMessage, WEB_POPUP_CONSENT_DEFAULTS.requiredMessage)\n });\n continue;\n }\n if (slot.type === 'submit') {\n out.push({\n type: 'submit',\n key: slot.key,\n variant: BUTTON_VARIANTS.includes(slot.variant) ? slot.variant : 'primary',\n label: slotStringOr(slot.label, WEB_POPUP_SUBMIT_DEFAULTS.label),\n errorMessage: slotStringOr(slot.errorMessage, WEB_POPUP_SUBMIT_DEFAULTS.errorMessage, MAX_SLOT_MESSAGE)\n });\n continue;\n }\n if (slot.type === 'email-subscription-form') {\n out.push({\n type: 'email-subscription-form',\n key: slot.key,\n formCode: typeof slot.formCode === 'string' ? slot.formCode : '',\n fields: normalizeFormFields(slot.fields),\n submitLabel: typeof slot.submitLabel === 'string' && slot.submitLabel ? slot.submitLabel : WEB_POPUP_FORM_DEFAULTS.submitLabel,\n submitVariant: BUTTON_VARIANTS.includes(slot.submitVariant) ? slot.submitVariant : 'primary',\n ...(typeof slot.privacy === 'object' && slot.privacy !== null && typeof slot.privacy.checkboxLabel === 'string' ? {\n privacy: {\n checkboxLabel: slot.privacy.checkboxLabel,\n url: typeof slot.privacy.url === 'string' ? slot.privacy.url : '',\n linkLabel: typeof slot.privacy.linkLabel === 'string' ? slot.privacy.linkLabel : ''\n }\n } : {}),\n successMessage: typeof slot.successMessage === 'string' && slot.successMessage ? slot.successMessage : WEB_POPUP_FORM_DEFAULTS.successMessage,\n confirmEmailMessage: typeof slot.confirmEmailMessage === 'string' && slot.confirmEmailMessage ? slot.confirmEmailMessage : WEB_POPUP_FORM_DEFAULTS.confirmEmailMessage\n });\n }\n // Unknown slot type → dropped.\n }\n return out;\n}\n// The zones come from API-writable json — keep only well-formed entries\n// (capped, see above) so the renderer can trust the shape.\nfunction normalizeContents(raw) {\n if (!Array.isArray(raw)) return [];\n const out = [];\n for (const zone of raw) {\n if (out.length >= MAX_ZONES) break;\n if (typeof zone !== 'object' || zone === null) continue;\n if (typeof zone.key !== 'string' || !zone.key) continue;\n if (!Array.isArray(zone.slots)) continue;\n out.push({\n key: zone.key,\n label: typeof zone.label === 'string' ? zone.label : '',\n slots: normalizeSlots(zone.slots)\n });\n }\n return out;\n}\n/**\n * Every subscription form code the popup's form slots reference (unique,\n * empty codes skipped) — what a host records view stats for. Reads the RAW\n * params (tolerant of malformed slots), so it works on parsed-but-unresolved\n * json.\n */\nexport function collectWebPopupFormCodes(params) {\n const out = new Set();\n for (const page of params.pages) {\n if (!Array.isArray(page?.contents)) continue;\n for (const zone of page.contents) {\n if (!Array.isArray(zone?.slots)) continue;\n for (const slot of zone.slots) {\n if (typeof slot !== 'object' || slot === null) continue;\n if (slot.type !== 'email-subscription-form') continue;\n if (typeof slot.formCode === 'string' && slot.formCode) out.add(slot.formCode);\n }\n }\n }\n return [...out];\n}\n// Has a 'hide-popup' countdown run out? The HOST asks before showing, at SHOW\n// time; any page counts, and a malformed timer reads as 'not expired'.\nexport function webPopupExpired(params, nowMs) {\n for (const page of params.pages) {\n if (!Array.isArray(page?.contents)) continue;\n for (const zone of page.contents) {\n if (!Array.isArray(zone?.slots)) continue;\n for (const slot of zone.slots) {\n if (typeof slot !== 'object' || slot === null) continue;\n if (slot.type !== 'timer' || slot.onExpire !== 'hide-popup') continue;\n if (typeof slot.endTime !== 'string') continue;\n const timezone = typeof slot.timezone === 'string' ? slot.timezone : '';\n const deadline = webPopupWallClockMs(slot.endTime, timezone);\n if (deadline !== null && deadline <= nowMs) return true;\n }\n }\n }\n return false;\n}\n/**\n * The popup box-size ceiling px, mirroring the layout tree's px clamp: the\n * json is API-writable and the size lands as inline style on the customer's\n * page. The editor clamps its Width/Height inputs to it too.\n */\nexport const WEB_POPUP_MAX_SIZE_PX = 2000;\nfunction validSize(value) {\n return typeof value === 'number' && Number.isFinite(value) && value > 0 ? Math.min(value, WEB_POPUP_MAX_SIZE_PX) : undefined;\n}\nexport function resolveWebPopupPageSize(own, shared, axis) {\n if (own === null) return undefined;\n let resolved;\n if (own === 'stretch') resolved = 'stretch';else resolved = validSize(own) ?? (shared === 'stretch' ? 'stretch' : validSize(shared));\n return axis === 'width' && resolved === 'stretch' ? undefined : resolved;\n}\n/**\n * The renderable pages: each page carries its own embedded layout tree — no\n * kind catalog at runtime. The page's named values are substituted into the\n * tree first ($key tokens), then the result is validated/normalized\n * (whitelisted props, unknown container types degrade to a Vertical stack) —\n * so substituted values pass the same clamps as literals; pages whose layout\n * isn't a tree at all are dropped. An empty result means the popup can't be\n * rendered. width/height come out FINAL (page override ?? chrome, validated)\n * — the renderer never falls back itself.\n */\nexport function resolveWebPopupPages(params) {\n const out = [];\n for (const page of params.pages) {\n const values = normalizeWebPopupValues(page.values);\n const layout = normalizeWebPopupLayout(substituteWebPopupLayoutValues(page.layout, webPopupValuesMap(values)));\n if (!layout) continue;\n const width = resolveWebPopupPageSize(page.width, params.width, 'width');\n const height = resolveWebPopupPageSize(page.height, params.height, 'height');\n out.push({\n key: page.key,\n layout,\n images: normalizeImages(page.images),\n contents: normalizeContents(page.contents),\n ...(width !== undefined ? {\n width\n } : {}),\n ...(height !== undefined ? {\n height\n } : {}),\n ...(page.role === 'success' ? {\n role: 'success'\n } : {})\n });\n }\n return out;\n}\n/** The page shown first: startPage when it exists, else the first page. */\nexport function startPageOf(params, pages) {\n return pages.find(p => p.key === params.startPage) ?? pages[0];\n}\nexport function placementMaxSize(placement) {\n return `calc(100% - ${placement.offset * 2}px)`;\n}\n/** Whether a slot is a button with the `close` action; anything malformed reads as false. */\nexport function isWebPopupCloseButton(slot) {\n const candidate = slot;\n return candidate?.type === 'button' && candidate.action?.type === 'close';\n}\nfunction zoneWithoutCloseButtons(zone) {\n if (!Array.isArray(zone?.slots)) return zone;\n return {\n ...zone,\n slots: zone.slots.filter(slot => !isWebPopupCloseButton(slot))\n };\n}\n/** A copy of one page without close-action buttons; tolerant of non-normalized json. */\nexport function webPopupPageWithoutCloseButtons(page) {\n if (!Array.isArray(page?.contents)) return page;\n return {\n ...page,\n contents: page.contents.map(zoneWithoutCloseButtons)\n };\n}\n/** A copy of the params without close-action buttons — an Inline (EMBEDDED) block has nothing to close. */\nexport function webPopupParamsWithoutCloseButtons(params) {\n if (!Array.isArray(params?.pages)) return params;\n return {\n ...params,\n pages: params.pages.map(webPopupPageWithoutCloseButtons)\n };\n}","import { SUBSCRIPTION_WIDGET_CORNERS, SUBSCRIPTION_WIDGET_DEFAULT_CONFIG, SUBSCRIPTION_WIDGET_LAYOUTS, SUBSCRIPTION_WIDGET_LIMITS, SUBSCRIPTION_WIDGET_POSITIONS, SUBSCRIPTION_WIDGET_TEXT_MAX_LENGTH, SUBSCRIPTION_WIDGET_TRIGGERS, SUBSCRIPTION_WIDGET_COLOR_MAX_LENGTH } from './constants';\nimport { normalizeWebPopupColors, normalizeWebPopupDark, safeUrl } from '../web-popups/helpers';\nconst HOUR_MS = 3600 * 1000;\nfunction record(value) {\n return typeof value === 'object' && value !== null && !Array.isArray(value) ? value : {};\n}\nfunction oneOf(value, allowed, fallback) {\n return allowed.includes(value) ? value : fallback;\n}\nfunction clamped(value, [min, max], fallback) {\n if (typeof value !== 'number' || !Number.isFinite(value)) return fallback;\n return Math.max(min, Math.min(max, Math.round(value)));\n}\nfunction text(value, fallback) {\n if (typeof value !== 'string') return fallback;\n const trimmed = value.trim();\n return trimmed ? trimmed.slice(0, SUBSCRIPTION_WIDGET_TEXT_MAX_LENGTH) : fallback;\n}\nfunction imageUrl(value) {\n const url = safeUrl(typeof value === 'string' ? value : undefined);\n return url && /^(https?:\\/\\/|\\/)/i.test(url) ? url : undefined;\n}\nfunction optionalColor(key, value) {\n const color = typeof value === 'string' ? value.trim().slice(0, SUBSCRIPTION_WIDGET_COLOR_MAX_LENGTH) : '';\n return color ? {\n [key]: color\n } : {};\n}\nfunction normalizeTexts(raw) {\n const defaults = SUBSCRIPTION_WIDGET_DEFAULT_CONFIG.texts;\n const keys = Object.keys(defaults);\n return Object.fromEntries(keys.map(key => [key, text(raw[key], defaults[key])]));\n}\n/**\n * The widget configuration from API-writable json: enums whitelisted, numbers\n * clamped, strings trimmed and capped, urls sanitized, defaults for the rest.\n */\nexport function normalizeSubscriptionWidgetConfig(raw) {\n const defaults = SUBSCRIPTION_WIDGET_DEFAULT_CONFIG;\n const config = record(raw);\n const prompt = record(config.prompt);\n const launcher = record(config.launcher);\n const display = record(config.display);\n const limits = SUBSCRIPTION_WIDGET_LIMITS;\n const layout = oneOf(prompt.layout, SUBSCRIPTION_WIDGET_LAYOUTS, defaults.prompt.layout);\n const positions = SUBSCRIPTION_WIDGET_POSITIONS[layout];\n const trigger = oneOf(display.trigger, SUBSCRIPTION_WIDGET_TRIGGERS, defaults.display.trigger);\n const iconUrl = imageUrl(prompt.iconUrl);\n const launcherImageUrl = imageUrl(launcher.imageUrl);\n const colors = normalizeWebPopupColors({\n colors: config.colors\n });\n const dark = normalizeWebPopupDark({\n dark: config.dark\n }, colors);\n const promptEnabled = prompt.enabled === true;\n const launcherEnabled = launcher.enabled === true;\n return {\n enable: promptEnabled || launcherEnabled,\n prompt: {\n enabled: promptEnabled,\n layout,\n position: oneOf(prompt.position, positions, positions[0]),\n ...(iconUrl ? {\n iconUrl\n } : {}),\n borderRadius: clamped(prompt.borderRadius, limits.borderRadius, defaults.prompt.borderRadius),\n overlay: layout === 'modal' || prompt.overlay === true\n },\n launcher: {\n enabled: launcherEnabled,\n position: oneOf(launcher.position, SUBSCRIPTION_WIDGET_CORNERS, defaults.launcher.position),\n offset: clamped(launcher.offset, limits.offset, defaults.launcher.offset),\n width: clamped(launcher.width, limits.launcherSize, defaults.launcher.width),\n height: clamped(launcher.height, limits.launcherSize, defaults.launcher.height),\n ...(launcherImageUrl ? {\n imageUrl: launcherImageUrl\n } : {}),\n ...optionalColor('background', launcher.background),\n ...optionalColor('iconColor', launcher.iconColor)\n },\n display: {\n trigger,\n delay: clamped(display.delay, limits.delay, defaults.display.delay),\n cappingCount: clamped(display.cappingCount, limits.cappingCount, defaults.display.cappingCount),\n cappingInterval: clamped(display.cappingInterval, limits.cappingInterval, defaults.display.cappingInterval)\n },\n texts: normalizeTexts(record(config.texts)),\n colors,\n ...(dark ? {\n dark\n } : {}),\n fontFamily: text(config.fontFamily, defaults.fontFamily),\n zIndex: clamped(config.zIndex, limits.zIndex, defaults.zIndex)\n };\n}\n/** True when the visitor can still act on the ask: not subscribed and push is supported. */\nexport function subscriptionWidgetActionable(permission) {\n return permission === 'default' || permission === 'denied';\n}\n/** Which prompt a visitor gets for their permission state. */\nexport function subscriptionWidgetPromptVariant(permission) {\n return permission === 'denied' ? 'blocked' : 'ask';\n}\n/** Whether the launcher is on screen. */\nexport function subscriptionWidgetLauncherVisible(config, permission) {\n return config.launcher.enabled && subscriptionWidgetActionable(permission);\n}\n/** What a launcher click does for this visitor. */\nexport function subscriptionWidgetLauncherAction(config, permission) {\n if (config.prompt.enabled) return 'prompt';\n return permission === 'default' ? 'subscribe' : 'none';\n}\n/** Whether the prompt may open by itself now; the host still waits `display.delay` before showing it. */\nexport function subscriptionWidgetCanAutoShow(config, permission, history, nowMs) {\n const {\n trigger,\n cappingCount,\n cappingInterval\n } = config.display;\n if (!config.prompt.enabled || trigger !== 'auto' || permission !== 'default') return false;\n if (cappingCount > 0 && history.shownCount >= cappingCount) return false;\n return history.lastShownAt === null || nowMs - history.lastShownAt >= cappingInterval * HOUR_MS;\n}\n/** The history after one more auto show at `nowMs`. */\nexport function nextSubscriptionWidgetHistory(history, nowMs) {\n return {\n shownCount: history.shownCount + 1,\n lastShownAt: nowMs\n };\n}","import { useEffect, useState } from 'react';\nconst DARK_MEDIA_QUERY = '(prefers-color-scheme: dark)';\nfunction prefersDark() {\n return typeof window !== 'undefined' && typeof window.matchMedia === 'function' && window.matchMedia(DARK_MEDIA_QUERY).matches;\n}\n// 'auto' follows the visitor's OS setting and keeps following it: a popup can\n// be on screen when the theme flips, and a stale palette is the visible half.\nexport function useColorScheme(pref, watch) {\n const [dark, setDark] = useState(() => pref === 'auto' && watch && prefersDark());\n const watchDeps = [pref, watch];\n const [prevWatchDeps, setPrevWatchDeps] = useState(null);\n if (prevWatchDeps === null || watchDeps.some((dep, index) => dep !== prevWatchDeps[index])) {\n setPrevWatchDeps(watchDeps);\n if (pref === 'auto' && watch) {\n setDark(prefersDark());\n }\n }\n useEffect(() => {\n if (pref !== 'auto' || !watch || typeof window === 'undefined' || typeof window.matchMedia !== 'function') {\n return undefined;\n }\n const media = window.matchMedia(DARK_MEDIA_QUERY);\n const onChange = event => setDark(event.matches);\n media.addEventListener('change', onChange);\n return () => media.removeEventListener('change', onChange);\n }, [pref, watch]);\n if (pref !== 'auto') return pref;\n return dark ? 'dark' : 'light';\n}","// Hand-authored 24×24 stroke geometry, inline (no icon package in a script that\n// loads on the customer's site). EXHAUSTIVE: a name without geometry won't compile.\nexport const WEB_POPUP_GLYPH_PATHS = {\n bell: 'M6 10a6 6 0 0 1 12 0c0 4 1.5 5.5 2 6H4c.5-.5 2-2 2-6M10 20a2 2 0 0 0 4 0',\n gift: 'M3 11h18v9a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1zM2.5 7h19v4h-19zM12 7v14' + 'M12 7c-1 0-3-.2-3.5-1a2 2 0 0 1 3.5-1 2 2 0 0 1 3.5 1c-.5.8-2.5 1-3.5 1z',\n cart: 'M2 4h2.2l2.4 11.2A2 2 0 0 0 8.6 17H19M6 7h15l-2.2 7.5H8' + 'M10.5 20a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0M19.5 20a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0',\n chart: 'M3 21h18M7 21V11M12 21V6M17 21v-8',\n lock: 'M5 11h14v10H5zM8 11V8a4 4 0 0 1 8 0v3',\n calendar: 'M4 6h16v15H4zM4 10h16M9 3v4M15 3v4',\n check: 'M4 13l5 5L20 6',\n star: 'M12 3l2.9 5.9 6.5.9-4.7 4.6 1.1 6.5-5.8-3.1-5.8 3.1 1.1-6.5L2.6 9.8l6.5-.9z',\n clock: 'M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0M12 7v5l4 2',\n tag: 'M20.6 13.4l-7.2 7.2a2 2 0 0 1-2.8 0l-7-7A2 2 0 0 1 3 12.2V5a2 2 0 0 1 2-2h7.2a2 2 0 0 1 1.4.6' + 'l7 7a2 2 0 0 1 0 2.8zM9 8a1 1 0 1 1-2 0 1 1 0 0 1 2 0',\n mail: 'M3 6h18v12H3zM3 7l9 6 9-6',\n phone: 'M7 2h10a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1M10 19h4',\n download: 'M12 3v12M7 11l5 5 5-5M4 20h16',\n play: 'M8 5l12 7-12 7z',\n shield: 'M12 3l8 3v6c0 5-3.4 8.6-8 10-4.6-1.4-8-5-8-10V6z',\n sparkle: 'M12 3l1.8 5.2L19 10l-5.2 1.8L12 17l-1.8-5.2L5 10l5.2-1.8z' + 'M18 15l.9 2.1 2.1.9-2.1.9-.9 2.1-.9-2.1L15 18l2.1-.9z',\n percent: 'M19 5L5 19M8.5 8.5a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0M20.5 15.5a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0',\n truck: 'M2 7h12v10H2zM14 10h4l3 3v4h-7' + 'M8.5 19a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0M20 19a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0',\n ticket: 'M4 7h16v4a2 2 0 0 0 0 4v3H4v-3a2 2 0 0 0 0-4zM14 7v12',\n user: 'M20 21a8 8 0 0 0-16 0M16 7a4 4 0 1 1-8 0 4 4 0 0 1 8 0'\n};\n/** The icon names a `glyph` slot may carry — derived, never a second list. */\nexport const WEB_POPUP_GLYPH_NAMES = Object.keys(WEB_POPUP_GLYPH_PATHS);\n/** The sizes a glyph slot may take, px; the first is the normalization default. */\nexport const WEB_POPUP_GLYPH_SIZES = [24, 32, 48];\n/** The thumb a 'thumbs' rating draws; not author-selectable, so not in the whitelist. */\nexport const WEB_POPUP_THUMB_UP_PATH = 'M8 21V10l3.5-7A2 2 0 0 1 14 5v5h4.5a2 2 0 0 1 2 2.4' + 'l-1.3 6A2 2 0 0 1 17.2 21zM8 10H3.5v11H8';","import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from \"react/jsx-runtime\";\nimport { SUBSCRIPTION_WIDGET_KEYFRAMES } from './constants';\nimport { subscriptionWidgetLauncherVisible, subscriptionWidgetPromptVariant } from './helpers';\nimport { useColorScheme } from '../web-popups/colorScheme';\nimport { webPopupButtonPillStyle } from '../web-popups/constants';\nimport { WEB_POPUP_GLYPH_PATHS } from '../web-popups/glyphs';\nimport { resolveWebPopupColors, webPopupDarkEnabled } from '../web-popups/palette';\nconst CARD_WIDTH = 360;\nconst MODAL_WIDTH = 420;\nconst EDGE_GAP = 16;\nconst BOX_SHADOW = '0 12px 32px rgba(16, 24, 40, 0.18)';\nconst BELL_SLASH_PATH = 'M4 4l16 16';\nfunction cornerStyle(corner, offset) {\n const [v, h] = corner.split('-');\n return {\n [v]: offset,\n [h]: offset\n };\n}\nfunction enterAnimation(fromTop, animate) {\n return animate ? `${fromTop ? 'pw-subw-drop' : 'pw-subw-rise'} 0.3s ease-out backwards` : undefined;\n}\nfunction promptFrameStyle(config, position, animate) {\n const {\n layout,\n position: at\n } = config.prompt;\n const base = {\n position,\n zIndex: config.zIndex,\n boxSizing: 'border-box',\n pointerEvents: 'auto'\n };\n if (layout === 'bar') {\n return {\n ...base,\n left: 0,\n right: 0,\n [at]: 0,\n animation: enterAnimation(at === 'top', animate)\n };\n }\n if (layout === 'modal') {\n return {\n ...base,\n top: '50%',\n left: '50%',\n width: `min(${MODAL_WIDTH}px, calc(100% - ${EDGE_GAP * 2}px))`,\n transform: 'translate(-50%, -50%)',\n animation: animate ? 'pw-subw-fade 0.25s ease-out backwards' : undefined\n };\n }\n const width = `min(${CARD_WIDTH}px, calc(100% - ${EDGE_GAP * 2}px))`;\n const animation = enterAnimation(at.startsWith('top'), animate);\n if (at === 'top' || at === 'bottom') {\n return {\n ...base,\n [at]: EDGE_GAP,\n left: '50%',\n width,\n transform: 'translateX(-50%)',\n animation\n };\n }\n return {\n ...base,\n ...cornerStyle(at, EDGE_GAP),\n width,\n animation\n };\n}\nfunction Button({\n label,\n primary,\n colors,\n disabled,\n onClick\n}) {\n return _jsx(\"button\", {\n type: \"button\",\n disabled: disabled,\n onClick: onClick,\n style: {\n ...webPopupButtonPillStyle(primary ? 'primary' : 'secondary', colors),\n display: 'inline-block',\n width: 'auto',\n padding: '8px 18px',\n whiteSpace: 'nowrap',\n opacity: disabled ? 0.6 : 1,\n cursor: disabled ? 'default' : 'pointer'\n },\n children: label\n });\n}\n/** The prompt box without placement, for CP forms that show it beside their fields. */\nexport function SubscriptionPromptBox({\n config,\n variant,\n colors,\n busy,\n onAccept,\n onDecline\n}) {\n const {\n prompt,\n texts\n } = config;\n const bar = prompt.layout === 'bar';\n const blocked = variant === 'blocked';\n return _jsxs(\"div\", {\n role: \"dialog\",\n \"aria-label\": blocked ? texts.blockedTitle : texts.title,\n style: {\n display: 'flex',\n flexDirection: bar ? 'row' : 'column',\n alignItems: bar ? 'center' : 'stretch',\n flexWrap: bar ? 'wrap' : 'nowrap',\n gap: 16,\n padding: bar ? '12px 20px' : 20,\n boxSizing: 'border-box',\n width: '100%',\n borderRadius: bar ? 0 : prompt.borderRadius,\n boxShadow: BOX_SHADOW,\n backgroundColor: colors.background,\n color: colors.text,\n fontFamily: config.fontFamily,\n colorScheme: colors.scheme\n },\n children: [_jsxs(\"div\", {\n style: {\n display: 'flex',\n alignItems: 'flex-start',\n gap: 12,\n flex: bar ? '1 1 240px' : undefined\n },\n children: [prompt.iconUrl && _jsx(\"img\", {\n src: prompt.iconUrl,\n alt: \"\",\n width: 48,\n height: 48,\n style: {\n flex: 'none',\n borderRadius: 8,\n objectFit: 'cover'\n }\n }), _jsxs(\"div\", {\n style: {\n display: 'flex',\n flexDirection: 'column',\n gap: 4,\n minWidth: 0\n },\n children: [_jsx(\"div\", {\n style: {\n fontSize: 16,\n fontWeight: 600,\n lineHeight: 1.4\n },\n children: blocked ? texts.blockedTitle : texts.title\n }), _jsx(\"div\", {\n style: {\n fontSize: 14,\n lineHeight: 1.5,\n color: colors.textSecondary\n },\n children: blocked ? texts.blockedMessage : texts.message\n })]\n })]\n }), _jsx(\"div\", {\n style: {\n display: 'flex',\n justifyContent: 'flex-end',\n gap: 8,\n flex: 'none'\n },\n children: blocked ? _jsx(Button, {\n label: texts.closeText,\n primary: true,\n colors: colors,\n onClick: onDecline\n }) : _jsxs(_Fragment, {\n children: [_jsx(Button, {\n label: texts.declineText,\n primary: false,\n colors: colors,\n onClick: onDecline\n }), _jsx(Button, {\n label: texts.acceptText,\n primary: true,\n colors: colors,\n disabled: busy,\n onClick: onAccept\n })]\n })\n })]\n });\n}\n/** The launcher without placement: the authored picture, or the round bell button. */\nexport function SubscriptionLauncherButton({\n config,\n blocked,\n colors,\n onClick\n}) {\n const {\n width,\n height,\n imageUrl\n } = config.launcher;\n const label = blocked ? config.texts.launcherBlockedLabel : config.texts.launcherLabel;\n const iconSize = Math.round(Math.min(width, height) / 2);\n const base = {\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n width,\n height,\n padding: 0,\n border: 'none',\n cursor: 'pointer',\n opacity: blocked ? 0.7 : 1\n };\n if (imageUrl) {\n return _jsx(\"button\", {\n type: \"button\",\n \"aria-label\": label,\n title: label,\n onClick: onClick,\n style: {\n ...base,\n background: 'none'\n },\n children: _jsx(\"img\", {\n src: imageUrl,\n alt: \"\",\n width: width,\n height: height,\n style: {\n display: 'block',\n objectFit: 'contain'\n }\n })\n });\n }\n return _jsx(\"button\", {\n type: \"button\",\n \"aria-label\": label,\n title: label,\n onClick: onClick,\n style: {\n ...base,\n borderRadius: '50%',\n backgroundColor: config.launcher.background ?? colors.accent,\n color: config.launcher.iconColor ?? colors.onAccent,\n boxShadow: BOX_SHADOW\n },\n children: _jsxs(\"svg\", {\n width: iconSize,\n height: iconSize,\n viewBox: \"0 0 24 24\",\n fill: \"none\",\n stroke: \"currentColor\",\n strokeWidth: 2,\n strokeLinecap: \"round\",\n strokeLinejoin: \"round\",\n \"aria-hidden\": \"true\",\n children: [_jsx(\"path\", {\n d: WEB_POPUP_GLYPH_PATHS.bell\n }), blocked && _jsx(\"path\", {\n d: BELL_SLASH_PATH\n })]\n })\n });\n}\n/**\n * The prompt while `open` and the launcher, each only when switched on; 'live' pins them to the viewport,\n * 'preview' to the nearest positioned parent with no enter animation. The host owns `open` and every side effect.\n */\nexport function SubscriptionWidgetReader({\n config,\n permission,\n open,\n mode = 'live',\n colorScheme = 'auto',\n busy,\n onAccept,\n onDecline,\n onLauncherClick\n}) {\n const scheme = useColorScheme(colorScheme, webPopupDarkEnabled(config));\n const colors = resolveWebPopupColors(config, scheme);\n const live = mode === 'live';\n const position = live ? 'fixed' : 'absolute';\n const prompt = open && config.prompt.enabled;\n const launcher = subscriptionWidgetLauncherVisible(config, permission);\n if (!prompt && !launcher) return null;\n return _jsxs(_Fragment, {\n children: [live && _jsx(\"style\", {\n children: SUBSCRIPTION_WIDGET_KEYFRAMES\n }), prompt && config.prompt.overlay && _jsx(\"div\", {\n style: {\n position,\n inset: 0,\n zIndex: config.zIndex,\n backgroundColor: 'rgba(16, 24, 40, 0.5)',\n animation: live ? 'pw-subw-fade 0.2s ease-out backwards' : undefined,\n pointerEvents: 'auto'\n },\n onClick: onDecline\n }), prompt && _jsx(\"div\", {\n style: promptFrameStyle(config, position, live),\n children: _jsx(SubscriptionPromptBox, {\n config: config,\n variant: subscriptionWidgetPromptVariant(permission),\n colors: colors,\n busy: busy,\n onAccept: onAccept,\n onDecline: onDecline\n })\n }), launcher && _jsx(\"div\", {\n style: {\n position,\n zIndex: config.zIndex,\n pointerEvents: 'auto',\n ...cornerStyle(config.launcher.position, config.launcher.offset)\n },\n children: _jsx(SubscriptionLauncherButton, {\n config: config,\n blocked: permission === 'denied',\n colors: colors,\n onClick: onLauncherClick\n })\n })]\n });\n}","import { render } from 'preact';\n\nimport {\n SubscriptionWidgetReader, type SubscriptionWidgetReaderProps,\n} from '@pushwoosh/websdk-common/subscription-widget';\n\nexport const renderSubscriptionWidget = (container: HTMLElement, props: SubscriptionWidgetReaderProps): void => {\n render(<SubscriptionWidgetReader {...props} mode=\"live\" />, container);\n};\n\nexport const unmountSubscriptionWidget = (container: HTMLElement): void => {\n render(null, container);\n};\n","import { type TInboxMessagesStoreName, type TKeyValueStoreName, type TMainLogStoreName, type TMessageLogStoreName } from '../Storage.types';\n\nexport const STORE_NAME_KEY_VALUE: TKeyValueStoreName = 'keyValue';\nexport const STORE_NAME_MESSAGE_LOG: TMessageLogStoreName = 'messages';\nexport const STORE_NAME_MAIN_LOG: TMainLogStoreName = 'log';\nexport const STORE_NAME_INBOX_MESSAGES: TInboxMessagesStoreName = 'inboxMessages';\n\nexport const KEY_PATH_BASE_INCREMENT = 'id';\n","import { type TMigrationType, type TSdkStoreName } from '../Storage.types';\n\n/**\n * Check existed store, before create\n * @param name\n * @param storeCreator\n */\nexport function storeCreatorDecorator(name: TSdkStoreName, storeCreator: TMigrationType): TMigrationType {\n return function (database: IDBDatabase) {\n if (database.objectStoreNames.contains(name)) {\n return;\n }\n\n storeCreator(database);\n };\n}\n","import {\n STORE_NAME_INBOX_MESSAGES,\n STORE_NAME_KEY_VALUE,\n STORE_NAME_MAIN_LOG,\n STORE_NAME_MESSAGE_LOG,\n KEY_PATH_BASE_INCREMENT,\n} from './constants';\nimport { storeCreatorDecorator } from './helpers';\nimport {\n type TInboxMessagesIDBKeyPath,\n type TInboxMessagesIDBRemovalTimeIndex,\n type TInboxMessagesIDBStatusIndex,\n} from '../../../models/InboxMessages.types';\n\n/**\n * Create keyValue store migration\n * @param database\n */\nfunction createKeyValueStore(database: IDBDatabase) {\n database.createObjectStore(STORE_NAME_KEY_VALUE, { keyPath: 'key' });\n}\n\n/**\n * Create log store migration\n * @param database\n */\nfunction createLogStore(database: IDBDatabase) {\n const logStore = database.createObjectStore(\n STORE_NAME_MAIN_LOG,\n { keyPath: KEY_PATH_BASE_INCREMENT, autoIncrement: true },\n );\n logStore.createIndex('environment', 'environment', { unique: false });\n logStore.createIndex('date', 'date', { unique: false });\n logStore.createIndex('type', 'type', { unique: false });\n}\n\n/**\n * Create message log store migration\n * @param database\n */\nfunction createMessageLogStore(database: IDBDatabase) {\n const messagesStore = database.createObjectStore(\n STORE_NAME_MESSAGE_LOG,\n { keyPath: KEY_PATH_BASE_INCREMENT, autoIncrement: true },\n );\n messagesStore.createIndex('date', 'date', { unique: false });\n}\n\n/**\n * Create inbox messages store migration\n * @param database\n */\nfunction createInboxMessagesStore(database: IDBDatabase) {\n const keyPath: TInboxMessagesIDBKeyPath = 'inbox_id';\n const statusIndex: TInboxMessagesIDBStatusIndex = 'status';\n const removalTimeIndex: TInboxMessagesIDBRemovalTimeIndex = 'rt';\n\n const store = database.createObjectStore(STORE_NAME_INBOX_MESSAGES,\n { keyPath, autoIncrement: false },\n );\n store.createIndex(statusIndex, statusIndex, { unique: false, multiEntry: true });\n store.createIndex(removalTimeIndex, removalTimeIndex, { unique: false, multiEntry: true });\n}\n\nexport default [\n storeCreatorDecorator(STORE_NAME_KEY_VALUE, createKeyValueStore),\n storeCreatorDecorator(STORE_NAME_MAIN_LOG, createLogStore),\n storeCreatorDecorator(STORE_NAME_MESSAGE_LOG, createMessageLogStore),\n storeCreatorDecorator(STORE_NAME_INBOX_MESSAGES, createInboxMessagesStore),\n];\n","import { default as migrationsInitial } from './initial';\nimport { type TMigrationType } from '../Storage.types';\n\nexport default class Migrations {\n get all(): Array<TMigrationType> {\n return migrationsInitial;\n }\n}\n","import Migrations from './Migrations';\nimport { type TMigrationType } from '../Storage.types';\n\nexport default class MigrationExecutor {\n db: IDBDatabase;\n migrationsBuilder: Migrations;\n\n constructor(\n db: IDBDatabase,\n migrationsBuilder: Migrations = new Migrations(),\n ) {\n this.db = db;\n this.migrationsBuilder = migrationsBuilder;\n }\n\n applyMigrations() {\n this.applyMigrationsPack(this.migrationsBuilder.all);\n }\n\n applyMigrationsPack(migrationsPack: Array<TMigrationType>) {\n migrationsPack.forEach((migration) => {\n migration(this.db);\n });\n }\n}\n","import {\n STORE_NAME_KEY_VALUE,\n STORE_NAME_MAIN_LOG,\n STORE_NAME_MESSAGE_LOG,\n} from '../modules/storage/migrations/constants';\nimport MigrationExecutor from '../modules/storage/migrations/MigrationExecutor';\nimport { type IIDBOpenEventTargetWithResult } from '../modules/storage/Storage.types';\nimport version from '../modules/storage/version';\n\ndeclare const self: ServiceWorkerGlobalScope;\n\nfunction onversionchange(database: IDBDatabase, event: Event) {\n console.info('onversionchange', event);\n database.close();\n}\n\nlet databasePromise: Promise<IDBDatabase>;\nexport function getInstance(): Promise<IDBDatabase> {\n if (!databasePromise) {\n databasePromise = new Promise<IDBDatabase>((resolve, reject) => {\n const request: IDBOpenDBRequest = indexedDB.open('PUSHWOOSH_SDK_STORE', version);\n request.onsuccess = (event) => {\n const database: IDBDatabase = (event.target as IIDBOpenEventTargetWithResult).result;\n database.onversionchange = onversionchange.bind(null, database, reject);\n resolve(database);\n };\n\n request.onerror = () => reject(request.error);\n\n request.onupgradeneeded = (event) => {\n const database: IDBDatabase = (event.target as IIDBOpenEventTargetWithResult).result;\n database.onversionchange = onversionchange.bind(null, database, reject);\n\n const migrationExecutor = new MigrationExecutor(database);\n migrationExecutor.applyMigrations();\n };\n });\n }\n return databasePromise;\n}\n\nfunction getInstanceWithPromise(executor: any): any {\n return getInstance().then((database) => (\n new Promise((resolve, reject) => executor(database, resolve, reject))\n ));\n}\n\nfunction createKeyValue(name: string) {\n return {\n get<K extends string, D>(key: K, defaultValue?: D) {\n return getInstanceWithPromise((database: IDBDatabase, resolve: any, reject: any) => {\n const request = database.transaction(name).objectStore(name).get(key);\n\n /** @TODO\n * we cant invoke \"resolve\" or \"reject\" in onsuccess or onerror because\n * it leads to bugs in Safari when we try to get permissions for notifications\n *\n * Checking status of request in setTimeout fixes this bug\n */\n let isComplete = false;\n let isError = false;\n let timeout: any;\n\n const check = () => {\n clearTimeout(timeout);\n if (isComplete) {\n resolve(request.result?.value || defaultValue);\n } else if (isError) {\n reject(request.error);\n } else {\n timeout = setTimeout(check, 0);\n }\n };\n\n request.onsuccess = () => isComplete = true;\n request.onerror = () => isError = true;\n check();\n });\n },\n\n getAll() {\n return getInstanceWithPromise((database: IDBDatabase, resolve: any, reject: any) => {\n const result: { [key: string]: any } = {};\n const cursor = database.transaction(name).objectStore(name).openCursor();\n let isComplete = false;\n let isError = false;\n let timeout: any;\n\n /** @TODO\n * we cant invoke \"resolve\" or \"reject\" in onsuccess or onerror because\n * it leads to bugs in Safari when we try to get permissions for notifications\n *\n * Checking status of request in setTimeout fixes this bug\n */\n const check = () => {\n clearTimeout(timeout);\n if (isComplete) {\n resolve(result);\n } else if (isError) {\n reject(cursor.error);\n } else {\n timeout = setTimeout(check, 0);\n }\n };\n\n cursor.onsuccess = (event) => {\n const cursorResult = (event.target as any).result;\n if (cursorResult) {\n result[cursorResult.key] = cursorResult.value.value;\n cursorResult.continue();\n } else {\n isComplete = true;\n }\n };\n cursor.onerror = () => isError = true;\n check();\n });\n },\n\n async extend(key: string, value: any) {\n const oldValues = await this.get(key);\n const { ...newValues } = value;\n await this.set(key, { ...oldValues, ...newValues });\n },\n\n set<K, D>(key: K, value: D) {\n return getInstanceWithPromise((database: IDBDatabase, resolve: any, reject: any) => {\n const request = database.transaction([name], 'readwrite').objectStore(name).put({ key, value });\n let isComplete = false;\n let isError = false;\n let timeout: any;\n\n /** @TODO\n * we cant invoke \"resolve\" or \"reject\" in onsuccess or onerror because\n * it leads to bugs in Safari when we try to get permissions for notifications\n *\n * Checking status of request in setTimeout fixes this bug\n */\n const check = () => {\n clearTimeout(timeout);\n if (isComplete) {\n resolve(key);\n } else if (isError) {\n reject(request.error);\n } else {\n timeout = setTimeout(check, 0);\n }\n };\n\n request.onsuccess = () => isComplete = true;\n request.onerror = () => isError = true;\n check();\n });\n },\n };\n}\n\nexport abstract class LogBase {\n protected abstract name: string;\n protected abstract maxItems: number;\n _add(obj: any) {\n return getInstanceWithPromise((database: IDBDatabase, resolve: any, reject: any) => {\n const request = database.transaction([this.name], 'readwrite').objectStore(this.name).add(obj);\n request.onsuccess = () => {\n resolve(obj);\n };\n request.onerror = () => {\n reject(request.error);\n };\n }).then((obj: any) => {\n return this.getAll().then((items: { id: number }[]) => {\n if (Array.isArray(items)) {\n const ids = items.map((i) => i.id).sort((a, b) => {\n if (a == b) return 0;\n return a < b ? 1 : -1;\n });\n if (ids.length > this.maxItems) {\n return Promise.all(ids.slice(this.maxItems).map((id) => this.delete(id))).then(() => obj);\n }\n }\n return obj;\n });\n });\n }\n\n delete(key: any) {\n return getInstanceWithPromise((database: IDBDatabase, resolve: any, reject: any) => {\n const request = database.transaction([this.name], 'readwrite').objectStore(this.name).delete(key);\n request.onsuccess = () => {\n resolve(request.result);\n };\n request.onerror = () => {\n reject(request.error);\n };\n });\n }\n\n getAll() {\n return getInstanceWithPromise((database: IDBDatabase, resolve: any, reject: any) => {\n const result: any[] = [];\n const cursor = database.transaction(this.name).objectStore(this.name).openCursor();\n cursor.onsuccess = (ev) => {\n const cursorResult = (ev.target as any).result;\n if (cursorResult) {\n if (cursorResult.value) {\n result.push(cursorResult.value);\n }\n cursorResult.continue();\n } else {\n resolve(result);\n }\n };\n cursor.onerror = () => {\n reject(cursor.error);\n };\n });\n }\n}\n\nexport class LogLog extends LogBase {\n protected name = STORE_NAME_MAIN_LOG;\n protected maxItems = 100;\n protected environment = (typeof self !== 'undefined' && self.registration) ? 'worker' : 'browser';\n add(type: string, message: any, additional?: any) {\n const obj: any = {\n type,\n environment: this.environment,\n message: `${message}`,\n date: new Date(),\n };\n if (message instanceof Error) {\n obj.stack = message.stack;\n }\n if (additional) {\n obj.additional = additional;\n }\n return this._add(obj);\n }\n}\n\nexport class LogMessage extends LogBase {\n protected name = STORE_NAME_MESSAGE_LOG;\n protected maxItems = 25;\n add(log: any) {\n return this._add({\n ...log,\n date: new Date(),\n });\n }\n}\n\nexport const keyValue = createKeyValue(STORE_NAME_KEY_VALUE);\nexport const log = new LogLog();\nexport const message = new LogMessage();\n","import { log as logStorage } from './storage';\n\nconst levels: { [key: string]: number } = {\n error: 1,\n info: 2,\n debug: 3,\n};\n\nlet limitLevel = 3;\n\ntype TWriteType = 'error' | 'apirequest' | 'info';\n\ninterface ILogger {\n setLevel(level: string): void;\n error(...args: any[]): void;\n info(...args: any[]): void;\n debug(...args: any[]): void;\n write(type: TWriteType, message: any, additional?: any): Promise<void>;\n isManualLevel(): boolean;\n [key: string]: any;\n}\n\nconst Logger: ILogger = {\n setLevel(level) {\n if (!levels[level]) {\n level = 'error';\n }\n limitLevel = levels[level];\n },\n write(type: TWriteType, message: any, additional?: any) {\n if (type === 'error') {\n this.error(message);\n } else {\n this.info(message);\n }\n return logStorage.add(type, message, additional);\n },\n} as ILogger;\n\nObject.keys(levels).forEach((levelName: string) => {\n const levelNumber = levels[levelName];\n Logger[levelName] = (...args: any[]) => {\n if (levelNumber <= limitLevel) {\n console.groupCollapsed(levelName);\n console.info('', ...args);\n console.trace('trace');\n console.groupEnd();\n }\n };\n});\n\nexport function logAndThrowError(error: string) {\n const logText = new Error(error);\n Logger.write('error', logText, 'logAndThrowError');\n throw logText;\n}\n\nexport function logAndRejectError(error: string, reject: (e: any) => void) {\n const logText = new Error(error);\n Logger.write('error', logText, 'logAndRejectError');\n reject(logText);\n}\n\nexport { Logger };\n","import {\n nextSubscriptionWidgetHistory, normalizeSubscriptionWidgetConfig, subscriptionWidgetActionable,\n subscriptionWidgetCanAutoShow, subscriptionWidgetLauncherAction, subscriptionWidgetLauncherVisible,\n type SubscriptionWidgetConfig, type SubscriptionWidgetPermission,\n} from '@pushwoosh/websdk-common/subscription-widget';\n\nimport { renderSubscriptionWidget, unmountSubscriptionWidget } from './renderer';\nimport { type ISubscriptionWidgetPublicApi } from './types';\nimport * as CONSTANTS from '../../core/constants';\nimport { Logger } from '../../core/logger';\nimport { type Pushwoosh } from '../../core/Pushwoosh';\n\nconst LOG_PREFIX = 'Pushwoosh subscription widget:';\nconst HOST_ID = 'pushwoosh-subscription-widget';\n\n/** The unified subscription widget: launcher bell + prompt, configured by `subscriptionWidget`. */\nexport class PWSubscriptionWidget implements ISubscriptionWidgetPublicApi {\n private readonly pw: Pushwoosh;\n private readonly config: SubscriptionWidgetConfig;\n private permission: SubscriptionWidgetPermission = 'unsupported';\n private open = false;\n private busy = false;\n private container: HTMLElement | null = null;\n private autoShowTimer: ReturnType<typeof setTimeout> | null = null;\n\n constructor(pw: Pushwoosh) {\n this.pw = pw;\n this.config = normalizeSubscriptionWidgetConfig(pw.initParams.subscriptionWidget);\n this.accept = this.accept.bind(this);\n this.decline = this.decline.bind(this);\n this.toggle = this.toggle.bind(this);\n this.launcherClick = this.launcherClick.bind(this);\n pw.moduleRegistry.subscriptionWidget = this;\n }\n\n public async run(): Promise<void> {\n const { pw, config } = this;\n\n if (!config.enable || !pw.isPushAvailable()) {\n return;\n }\n\n this.permission = await this.readPermission();\n this.mount();\n this.listenSubscriptionChanges();\n await this.scheduleAutoShow();\n }\n\n public show(): void {\n if (!this.container || !this.config.prompt.enabled || !subscriptionWidgetActionable(this.permission) || this.open) {\n return;\n }\n\n this.open = true;\n this.render();\n this.pw.dispatchEvent('show-subscription-widget', {});\n }\n\n public hide(): void {\n if (!this.open) {\n return;\n }\n\n this.open = false;\n this.busy = false;\n this.render();\n this.pw.dispatchEvent('hide-subscription-widget', {});\n }\n\n public toggle(isShown?: boolean): void {\n const shouldShow = isShown ?? !this.open;\n\n if (shouldShow) {\n this.show();\n } else {\n this.hide();\n }\n }\n\n public isVisible(): boolean {\n return this.open;\n }\n\n private async readPermission(): Promise<SubscriptionWidgetPermission> {\n const permission = this.pw.driver?.getPermission();\n\n if (permission === CONSTANTS.PERMISSION_DENIED) {\n return 'denied';\n }\n\n return await this.pw.isSubscribed() ? 'granted' : 'default';\n }\n\n private mount(): void {\n const host = document.createElement('div');\n host.id = HOST_ID;\n host.style.position = 'fixed';\n host.style.inset = '0';\n host.style.zIndex = String(this.config.zIndex);\n host.style.pointerEvents = 'none';\n document.body.appendChild(host);\n\n this.container = document.createElement('div');\n host.attachShadow({ mode: 'open' }).appendChild(this.container);\n this.render();\n }\n\n private render(): void {\n if (!this.container) {\n return;\n }\n\n if (!this.open && !subscriptionWidgetLauncherVisible(this.config, this.permission)) {\n unmountSubscriptionWidget(this.container);\n\n return;\n }\n\n renderSubscriptionWidget(this.container, {\n config: this.config,\n permission: this.permission,\n open: this.open,\n busy: this.busy,\n onAccept: this.accept,\n onDecline: this.decline,\n onLauncherClick: this.launcherClick,\n });\n }\n\n private async scheduleAutoShow(): Promise<void> {\n const history = await this.pw.data.getSubscriptionWidgetHistory();\n\n if (!subscriptionWidgetCanAutoShow(this.config, this.permission, history, Date.now())) {\n return;\n }\n\n this.autoShowTimer = setTimeout(async () => {\n this.autoShowTimer = null;\n\n if (this.open || this.permission !== 'default') {\n return;\n }\n\n this.show();\n await this.pw.data.setSubscriptionWidgetHistory(nextSubscriptionWidgetHistory(history, Date.now()));\n }, this.config.display.delay * 1000);\n }\n\n private launcherClick(): void {\n const action = subscriptionWidgetLauncherAction(this.config, this.permission);\n\n if (action === 'prompt') {\n this.toggle();\n } else if (action === 'subscribe') {\n this.subscribeFromLauncher();\n }\n }\n\n // Without a prompt the bell asks the browser itself; synchronous up to pw.subscribe() for Firefox.\n private async subscribeFromLauncher(): Promise<void> {\n try {\n await this.pw.subscribe();\n } catch (error) {\n Logger.error(error, `${LOG_PREFIX} failed to subscribe`);\n }\n\n this.permission = await this.readPermission();\n this.render();\n }\n\n // Kept synchronous up to pw.subscribe(): Firefox only honours a permission request inside the click's own task.\n private async accept(): Promise<void> {\n this.busy = true;\n this.render();\n\n try {\n await this.pw.subscribe();\n } catch (error) {\n Logger.error(error, `${LOG_PREFIX} failed to subscribe`);\n }\n\n this.permission = await this.readPermission();\n\n if (this.permission === 'denied') {\n this.busy = false;\n this.render();\n\n return;\n }\n\n this.hide();\n }\n\n private decline(): void {\n this.hide();\n }\n\n private listenSubscriptionChanges(): void {\n const update = async () => {\n this.permission = await this.readPermission();\n\n if (this.permission === 'granted') {\n this.cancelAutoShow();\n this.hide();\n }\n\n this.render();\n };\n\n this.pw.addSdkEventHandler('subscribe', update);\n this.pw.addSdkEventHandler('unsubscribe', update);\n this.pw.addSdkEventHandler('permission-denied', update);\n }\n\n private cancelAutoShow(): void {\n if (this.autoShowTimer !== null) {\n clearTimeout(this.autoShowTimer);\n this.autoShowTimer = null;\n }\n }\n}\n"],"names":["root","factory","exports","module","require","define","amd","a","i","this","__WEBPACK_EXTERNAL_MODULE__524__","__WEBPACK_EXTERNAL_MODULE__873__","__WEBPACK_EXTERNAL_MODULE__247__","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","d","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","r","Symbol","toStringTag","value","SAFE_URL_PROTOCOL","WEB_POPUP_TEXT_COLOR","WEB_POPUP_TEXT_SECONDARY_COLOR","WEB_POPUP_ON_ACCENT_COLOR","WEB_POPUP_DEFAULT_COLORS","background","accent","text","textSecondary","textInverse","webPopupButtonPillStyle","variant","colors","display","boxSizing","width","padding","borderRadius","fontSize","fontWeight","fontFamily","lineHeight","textAlign","textDecoration","cursor","backgroundColor","surface","color","border","onAccent","SUBSCRIPTION_WIDGET_POSITIONS","card","bar","modal","SUBSCRIPTION_WIDGET_LAYOUTS","keys","SUBSCRIPTION_WIDGET_CORNERS","SUBSCRIPTION_WIDGET_TRIGGERS","SUBSCRIPTION_WIDGET_LIMITS","delay","cappingCount","cappingInterval","offset","launcherSize","zIndex","SUBSCRIPTION_WIDGET_DEFAULT_CONFIG","enable","prompt","enabled","layout","position","overlay","launcher","height","trigger","texts","title","message","acceptText","declineText","closeText","blockedTitle","blockedMessage","launcherLabel","launcherBlockedLabel","HEX_RE","parseHex","hex","exec","trim","full","length","split","map","c","join","parseInt","slice","toHex","g","b","v","Math","max","min","round","toString","padStart","hueToChannel","p","q","t","tn","foldLightness","l","liftLightness","webPopupShiftColor","direction","rgb","h","s","rn","gn","bn","rgbToHsl","hslToRgb","webPopupMixColor","base","over","ratio","isLightColor","autoDarkWebPopupColors","light","derivedColors","scheme","surfaceText","error","chromeIcon","webPopupDarkEnabled","chrome","dark","webPopupEffectiveScheme","resolveWebPopupColors","effective","safeUrl","url","trimmed","startsWith","test","Set","colorString","normalizeWebPopupColors","params","normalizeWebPopupDark","raw","authored","auto","opacity","Number","isFinite","normalizeOverlay","boxShadow","record","Array","isArray","oneOf","allowed","fallback","includes","clamped","helpers_text","imageUrl","optionalColor","normalizeTexts","defaults","fromEntries","subscriptionWidgetActionable","permission","subscriptionWidgetPromptVariant","subscriptionWidgetLauncherVisible","config","DARK_MEDIA_QUERY","prefersDark","window","matchMedia","matches","WEB_POPUP_GLYPH_PATHS","bell","gift","cart","chart","lock","calendar","check","star","clock","tag","mail","phone","download","play","shield","sparkle","percent","truck","ticket","user","BOX_SHADOW","cornerStyle","corner","enterAnimation","fromTop","animate","promptFrameStyle","at","pointerEvents","left","right","animation","top","transform","Button","label","primary","disabled","onClick","jsx_runtime_root_jsxRuntime_","jsx","type","style","whiteSpace","children","SubscriptionPromptBox","busy","onAccept","onDecline","blocked","jsxs","role","flexDirection","alignItems","flexWrap","gap","colorScheme","flex","iconUrl","src","alt","objectFit","minWidth","justifyContent","Fragment","SubscriptionLauncherButton","iconSize","iconColor","viewBox","fill","stroke","strokeWidth","strokeLinecap","strokeLinejoin","SubscriptionWidgetReader","open","mode","onLauncherClick","pref","watch","setDark","compat_root_preactCompat_","useState","watchDeps","prevWatchDeps","setPrevWatchDeps","some","dep","index","useEffect","media","onChange","event","addEventListener","removeEventListener","useColorScheme","live","inset","STORE_NAME_KEY_VALUE","STORE_NAME_MESSAGE_LOG","STORE_NAME_INBOX_MESSAGES","storeCreatorDecorator","name","storeCreator","database","objectStoreNames","contains","initial","createObjectStore","keyPath","logStore","autoIncrement","createIndex","unique","statusIndex","store","multiEntry","Migrations","all","MigrationExecutor","constructor","db","migrationsBuilder","applyMigrations","applyMigrationsPack","migrationsPack","forEach","migration","onversionchange","console","info","close","databasePromise","getInstanceWithPromise","executor","Promise","resolve","reject","request","indexedDB","onsuccess","target","result","bind","onerror","onupgradeneeded","then","LogBase","_add","transaction","objectStore","add","getAll","items","ids","id","sort","maxItems","delete","openCursor","ev","cursorResult","push","continue","log","environment","self","registration","additional","date","Date","Error","stack","levels","debug","limitLevel","Logger","setLevel","level","write","levelName","levelNumber","args","groupCollapsed","trace","groupEnd","LOG_PREFIX","PWSubscriptionWidget","pw","container","autoShowTimer","limits","positions","launcherImageUrl","promptEnabled","launcherEnabled","normalizeSubscriptionWidgetConfig","initParams","subscriptionWidget","accept","decline","toggle","launcherClick","moduleRegistry","run","isPushAvailable","readPermission","mount","listenSubscriptionChanges","scheduleAutoShow","show","render","dispatchEvent","hide","isShown","isVisible","driver","getPermission","isSubscribed","host","document","createElement","String","body","appendChild","attachShadow","props","external_commonjs_preact_commonjs2_preact_amd_preact_root_preact_","renderSubscriptionWidget","history","data","getSubscriptionWidgetHistory","nowMs","shownCount","lastShownAt","subscriptionWidgetCanAutoShow","now","setTimeout","async","setSubscriptionWidgetHistory","nextSubscriptionWidgetHistory","action","subscribeFromLauncher","subscribe","update","cancelAutoShow","addSdkEventHandler","clearTimeout"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"widget-subscription.js","mappings":"CAAA,SAAAA,EAAAC,GACA,oBAAAC,SAAA,iBAAAC,OACAA,OAAAD,QAAAD,EAAAG,QAAA,UAAAA,QAAA,iBAAAA,QAAA,4BACA,sBAAAC,QAAAA,OAAAC,IACAD,OAAA,gDAAAJ,OACA,CACA,IAAAM,EAAA,iBAAAL,QAAAD,EAAAG,QAAA,UAAAA,QAAA,iBAAAA,QAAA,uBAAAH,EAAAD,EAAA,OAAAA,EAAA,aAAAA,EAAA,YACA,QAAAQ,KAAAD,GAAA,iBAAAL,QAAAA,QAAAF,GAAAQ,GAAAD,EAAAC,EACA,CACC,CATD,CASCC,KAAA,CAAAC,EAAAC,EAAAC,qCCTDT,EAAAD,QAAAQ,UCAAP,EAAAD,QAAAS,UCAAR,EAAAD,QAAAU,ICCA,MAAAC,EAAA,GAGA,SAAAC,EAAAC,GAEA,MAAAC,EAAAH,EAAAE,GACA,QAAAE,IAAAD,EACA,OAAAA,EAAAd,QAGA,MAAAC,EAAAU,EAAAE,GAAA,CAGAb,QAAA,IAOA,OAHAgB,EAAAH,GAAAZ,EAAAA,EAAAD,QAAAY,GAGAX,EAAAD,OACA,CCrBAY,EAAAK,EAAA,CAAAjB,EAAAkB,KACA,QAAAC,KAAAD,EACAN,EAAAQ,EAAAF,EAAAC,KAAAP,EAAAQ,EAAApB,EAAAmB,IACAE,OAAAC,eAAAtB,EAAAmB,EAAA,CAAyCI,YAAA,EAAAC,IAAAN,EAAAC,MCJzCP,EAAAQ,EAAA,CAAAK,EAAAC,IAAAL,OAAAM,UAAAC,eAAAC,KAAAJ,EAAAC,GCCAd,EAAAkB,EAAA9B,IACAqB,OAAAC,eAAAtB,EAAA+B,OAAAC,YAAA,CAAsDC,MAAA,WACtDZ,OAAAC,eAAAtB,EAAA,cAAgDiC,OAAA,0DCIzC,MAMA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KAAKwL,WZvCtEG,EAAAjH,OAAAC,QAAA,SACA,YAAA6G,EAAA,oBAFO,IAAAG,EAAAH,EY0CY,WAAX2P,EACFnb,KAAK2Y,SACe,cAAXwC,GACTnb,KAAKob,uBAET,CAGQ,2BAAMA,GACZ,UACQpb,KAAK8X,GAAGuD,WAChB,CAAE,MAAOtS,GACPmO,GAAOnO,MAAMA,EAAO,GAAG6O,yBACzB,CAEA5X,KAAKwL,iBAAmBxL,KAAKgZ,iBAC7BhZ,KAAKqZ,QACP,CAGQ,YAAMZ,GACZzY,KAAKgP,MAAO,EACZhP,KAAKqZ,SAEL,UACQrZ,KAAK8X,GAAGuD,WAChB,CAAE,MAAOtS,GACPmO,GAAOnO,MAAMA,EAAO,GAAG6O,yBACzB,CAIA,GAFA5X,KAAKwL,iBAAmBxL,KAAKgZ,iBAEL,WAApBhZ,KAAKwL,WAIP,OAHAxL,KAAKgP,MAAO,OACZhP,KAAKqZ,SAKPrZ,KAAKuZ,MACP,CAEQ,OAAAb,GACN1Y,KAAKuZ,MACP,CAEQ,yBAAAL,GACN,MAAMoC,EAASN,UACbhb,KAAKwL,iBAAmBxL,KAAKgZ,iBAEL,YAApBhZ,KAAKwL,aACPxL,KAAKub,iBACLvb,KAAKuZ,QAGPvZ,KAAKqZ,UAGPrZ,KAAK8X,GAAG0D,mBAAmB,YAAaF,GACxCtb,KAAK8X,GAAG0D,mBAAmB,cAAeF,GAC1Ctb,KAAK8X,GAAG0D,mBAAmB,oBAAqBF,EAClD,CAEQ,cAAAC,GACqB,OAAvBvb,KAAKgY,gBACPyD,aAAazb,KAAKgY,eAClBhY,KAAKgY,cAAgB,KAEzB","sources":["webpack://web-push-notifications/webpack/universalModuleDefinition","webpack://web-push-notifications/external umd {\"commonjs\":\"preact\",\"commonjs2\":\"preact\",\"amd\":\"preact\",\"root\":\"preact\"}","webpack://web-push-notifications/external umd {\"commonjs\":\"preact/compat\",\"commonjs2\":\"preact/compat\",\"amd\":\"preact/compat\",\"root\":\"preactCompat\"}","webpack://web-push-notifications/external umd {\"commonjs\":\"preact/jsx-runtime\",\"commonjs2\":\"preact/jsx-runtime\",\"amd\":\"preact/jsx-runtime\",\"root\":\"jsxRuntime\"}","webpack://web-push-notifications/webpack/bootstrap","webpack://web-push-notifications/webpack/runtime/define property getters","webpack://web-push-notifications/webpack/runtime/hasOwnProperty shorthand","webpack://web-push-notifications/webpack/runtime/make namespace object","webpack://web-push-notifications/./node_modules/@pushwoosh/websdk-common/web-popups/constants.js","webpack://web-push-notifications/./node_modules/@pushwoosh/websdk-common/subscription-widget/constants.js","webpack://web-push-notifications/./node_modules/@pushwoosh/websdk-common/web-popups/palette.js","webpack://web-push-notifications/./node_modules/@pushwoosh/websdk-common/web-popups/helpers.js","webpack://web-push-notifications/./node_modules/@pushwoosh/websdk-common/subscription-widget/helpers.js","webpack://web-push-notifications/./node_modules/@pushwoosh/websdk-common/web-popups/colorScheme.js","webpack://web-push-notifications/./node_modules/@pushwoosh/websdk-common/web-popups/glyphs.js","webpack://web-push-notifications/./node_modules/@pushwoosh/websdk-common/subscription-widget/SubscriptionWidgetReader.js","webpack://web-push-notifications/./src/widgets/SubscriptionWidget/renderer.tsx","webpack://web-push-notifications/./src/modules/storage/migrations/constants.ts","webpack://web-push-notifications/./src/modules/storage/migrations/helpers.ts","webpack://web-push-notifications/./src/modules/storage/migrations/initial.ts","webpack://web-push-notifications/./src/modules/storage/migrations/Migrations.ts","webpack://web-push-notifications/./src/modules/storage/migrations/MigrationExecutor.ts","webpack://web-push-notifications/./src/core/storage.ts","webpack://web-push-notifications/./src/core/logger.ts","webpack://web-push-notifications/./src/widgets/SubscriptionWidget/SubscriptionWidget.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"preact\"), require(\"preact/compat\"), require(\"preact/jsx-runtime\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"preact\", \"preact/compat\", \"preact/jsx-runtime\"], factory);\n\telse {\n\t\tvar a = typeof exports === 'object' ? factory(require(\"preact\"), require(\"preact/compat\"), require(\"preact/jsx-runtime\")) : factory(root[\"preact\"], root[\"preactCompat\"], root[\"jsxRuntime\"]);\n\t\tfor(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];\n\t}\n})(this, (__WEBPACK_EXTERNAL_MODULE__524__, __WEBPACK_EXTERNAL_MODULE__873__, __WEBPACK_EXTERNAL_MODULE__247__) => {\nreturn ","module.exports = __WEBPACK_EXTERNAL_MODULE__524__;","module.exports = __WEBPACK_EXTERNAL_MODULE__873__;","module.exports = __WEBPACK_EXTERNAL_MODULE__247__;","// The module cache\nconst __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tconst cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tconst module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter/value functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop));","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","/**\n * Current stored-format version (WebPopupJson.version). Version 2 = the\n * layout-tree format (nested containers + Content/Image leaves, named content\n * zones). Version 1 (flat layout + single slot list) is retired without a\n * migration path — v1 popups are treated as broken, same as the pre-engine\n * ai-builder format.\n */\nexport const WEB_POPUP_VERSION = 2;\n// Bomb protection for the embedded layout tree — the json travels through a\n// public API, so the parser refuses to walk pathological trees.\nexport const WEB_POPUP_LAYOUT_MAX_DEPTH = 10;\nexport const WEB_POPUP_LAYOUT_MAX_NODES = 100;\n/** Protocols allowed in button hrefs (plus relative `#`/`/`/`?` prefixes). */\nexport const SAFE_URL_PROTOCOL = /^(https?:|mailto:|tel:)/i;\nexport const WEB_POPUP_FONT_STACK = 'Inter, system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif';\n// Palette defaults (mirror the editor's popup theme) — what a popup gets for\n// any WebPopupColors entry its json doesn't set.\nexport const WEB_POPUP_TEXT_COLOR = '#101828';\nexport const WEB_POPUP_TEXT_SECONDARY_COLOR = '#667085';\nexport const WEB_POPUP_ACCENT_COLOR = '#2970FF';\nexport const WEB_POPUP_BACKGROUND_COLOR = '#FFFFFF';\n/** Label over an accent fill in the light scheme; dark picks it by accent luminance. */\nexport const WEB_POPUP_ON_ACCENT_COLOR = '#FFFFFF';\nexport const WEB_POPUP_DEFAULT_COLORS = {\n background: WEB_POPUP_BACKGROUND_COLOR,\n accent: WEB_POPUP_ACCENT_COLOR,\n text: WEB_POPUP_TEXT_COLOR,\n textSecondary: WEB_POPUP_TEXT_SECONDARY_COLOR,\n textInverse: '#FFFFFF'\n};\n/** Fallback width used when a fixed-width context needs a number anyway. */\nexport const WEB_POPUP_DEFAULT_WIDTH = 360;\n/** Max height of an `<img>` in an Inline block: at full container width a side image would be too tall. */\nexport const WEB_POPUP_INLINE_IMAGE_MAX_HEIGHT = 360;\n// Per-variant text styles — the same numbers the editor's canvas derives from\n// its theme presets. No colors here: those come from the popup palette via\n// webPopupTextColor below.\nexport const WEB_POPUP_TEXT_VARIANT_STYLES = {\n h1: {\n fontSize: 24,\n fontWeight: 600,\n lineHeight: 1.25\n },\n h2: {\n fontSize: 18,\n fontWeight: 600,\n lineHeight: 1.3\n },\n h3: {\n fontSize: 16,\n fontWeight: 600,\n lineHeight: 1.35\n },\n body: {\n fontSize: 14,\n fontWeight: 'normal',\n lineHeight: 1.5\n },\n caption: {\n fontSize: 12,\n fontWeight: 'normal',\n lineHeight: 1.4\n },\n eyebrow: {\n fontSize: 11,\n fontWeight: 600,\n letterSpacing: '0.08em',\n lineHeight: 1.4\n },\n icon: {\n fontSize: 24,\n lineHeight: 1.2\n }\n};\n// Inverse-tone translucency per text style: headings full-strength, the\n// secondary variants toned down — same rhythm the palette's default white\n// set always had.\nconst INVERSE_TEXT_ALPHAS = {\n h1: 1,\n h2: 1,\n h3: 1,\n icon: 1,\n eyebrow: 0.8,\n body: 0.9,\n caption: 0.75\n};\n// colors.textInverse at the given opacity. Only #rgb/#rrggbb can be blended;\n// any other author-supplied css color renders full-strength rather than\n// being guessed at.\nfunction inverseColorAt(color, alpha) {\n if (alpha >= 1) return color;\n const hex = /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.exec(color)?.[1];\n if (!hex) return color;\n const full = hex.length === 3 ? hex.split('').map(c => c + c).join('') : hex;\n const [r, g, b] = [0, 2, 4].map(i => parseInt(full.slice(i, i + 2), 16));\n return `rgba(${r}, ${g}, ${b}, ${alpha})`;\n}\n/**\n * A text slot's color: the palette's main/secondary role by variant; in an\n * 'inverse' zone (over a background image) — colors.textInverse, with the\n * secondary variants toned translucent. Undefined for a non-inverse 'icon'\n * (an emoji line inherits — its glyphs aren't recolorable anyway).\n */\nexport function webPopupTextColor(variant, colors, inverse) {\n if (inverse) return inverseColorAt(colors.textInverse, INVERSE_TEXT_ALPHAS[variant] ?? 1);\n if (variant === 'icon') return undefined;\n return variant === 'caption' || variant === 'eyebrow' ? colors.textSecondary : colors.text;\n}\n/** The dark fill under a container's background image while it loads. */\nexport const WEB_POPUP_BG_SECTION_FALLBACK = '#1D2939';\nconst HEADING_VARIANTS = ['h1', 'h2', 'h3', 'icon'];\nexport function webPopupSlotRole(slot) {\n // An icon reads as the line above a title, so it hugs what follows; a\n // countdown wants a block's air, which the 'action' fallback gives it.\n if (slot.type === 'glyph') return 'heading';\n if (slot.type !== 'text') return 'action';\n return HEADING_VARIANTS.includes(slot.variant) ? 'heading' : 'text';\n}\nexport function webPopupSlotGap(prev, next) {\n if (next === 'action') return prev === 'action' ? 6 : 16;\n if (next === 'text' && prev === 'heading') return 4;\n return 8;\n}\n// Paddings INSIDE a form slot (field rows, submit pill); the rhythm above\n// owns the space BETWEEN slots.\nexport const WEB_POPUP_TEXT_SLOT_PADDING = '4px 0';\nexport const WEB_POPUP_BUTTON_SLOT_PADDING = '8px 0 4px';\n/**\n * The button pill both button slots and a form slot's submit button render\n * with — buttons pair the accent with white (primary = accent fill + white\n * label, secondary = white fill + accent outline). Shared with the editor's\n * canvas (parity contract).\n */\nexport function webPopupButtonPillStyle(variant, colors) {\n return {\n display: 'block',\n boxSizing: 'border-box',\n width: '100%',\n padding: '10px 25px',\n borderRadius: 6,\n fontSize: 14,\n fontWeight: 600,\n fontFamily: 'inherit',\n lineHeight: 1.5,\n textAlign: 'center',\n textDecoration: 'none',\n cursor: 'pointer',\n ...(variant === 'secondary' ? {\n backgroundColor: colors.surface,\n color: colors.accent,\n border: `1px solid ${colors.accent}`\n } : {\n backgroundColor: colors.accent,\n color: colors.onAccent,\n border: 'none'\n })\n };\n}\n// Form-slot input chrome, shared with the editor's canvas (parity contract):\n// a `surface` card whatever the zone tone, only the border varies.\nexport const WEB_POPUP_FORM_INPUT_BORDER = '#D0D5DD';\nexport const WEB_POPUP_FORM_ERROR_COLOR = '#D92D20';\n/** The error red lifted for a dark background — the same Untitled UI ramp, three steps up. */\nexport const WEB_POPUP_FORM_ERROR_COLOR_DARK = '#FDA29B';\nexport function webPopupFormInputStyle(colors, borderColor = colors.border) {\n return {\n display: 'block',\n boxSizing: 'border-box',\n width: '100%',\n padding: '10px 12px',\n borderRadius: 6,\n fontSize: 14,\n fontFamily: 'inherit',\n lineHeight: 1.5,\n backgroundColor: colors.surface,\n color: colors.surfaceText,\n border: `1px solid ${borderColor}`,\n outline: 'none'\n };\n}\n// What a normalized form slot falls back to when the json omits the copy —\n// also the editor's defaults for a freshly added slot.\nexport const WEB_POPUP_FORM_DEFAULTS = {\n submitLabel: 'Subscribe',\n successMessage: 'Thanks for subscribing!',\n confirmEmailMessage: 'Please check your inbox and confirm your email.'\n};\n// What a normalized choice slot falls back to when the json omits the copy.\nexport const WEB_POPUP_CHOICE_DEFAULTS = {\n submitLabel: 'Save',\n successMessage: 'Thanks! Your choice is saved.'\n};\nexport const WEB_POPUP_PRODUCTS_DEFAULTS = {\n ctaText: 'Shop now',\n limit: 4\n};\nexport const WEB_POPUP_PRODUCTS_MAX_LIMIT = 12;\n/** Cards a products slot draws without a host: enough to read as a row, never the full limit. */\nexport const WEB_POPUP_PRODUCTS_PLACEHOLDERS = 3;\n/** How long one products answer serves both the host's pre-show check and the render. */\nexport const WEB_POPUP_PRODUCTS_CACHE_MS = 60 * 1000;\n// Same, for a rating slot.\nexport const WEB_POPUP_RATING_DEFAULTS = {\n submitLabel: 'Send',\n successMessage: 'Thanks for the feedback!'\n};\n// The scores a scale offers, in display order; thumbs are 0/1 so `score` stays\n// \"higher is better\" everywhere. Shared with the editor canvas (parity).\nexport function webPopupRatingScores(scale) {\n if (scale === 'nps') return [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];\n if (scale === 'stars') return [1, 2, 3, 4, 5];\n return [0, 1];\n}\n/** Options a `choice` slot may carry; exported so the editor can't offer one normalization drops. */\nexport const WEB_POPUP_MAX_CHOICE_OPTIONS = 12;\n/** What a slot says when the host callback rejected: nothing actionable, so it's retryable. */\nexport const WEB_POPUP_RETRY_ERROR = 'Something went wrong. Please try again.';\n/** Email shape both form paths accept; the server runs the real check. */\nexport const WEB_POPUP_EMAIL_PATTERN = /^\\S+@\\S+\\.\\S+$/;\n/** Copy a Form's Email input falls back to — also the editor's defaults for a fresh block. */\nexport const WEB_POPUP_EMAIL_INPUT_DEFAULTS = {\n invalidMessage: 'Enter a valid email',\n requiredMessage: 'Required'\n};\n/** Copy a Form's Tag input falls back to. */\nexport const WEB_POPUP_TAG_INPUT_DEFAULTS = {\n requiredMessage: 'Required'\n};\n/** Copy a Form's Consent falls back to. */\nexport const WEB_POPUP_CONSENT_DEFAULTS = {\n requiredMessage: 'Please accept the privacy policy'\n};\n/** Copy a Form's Submit falls back to; the error is the retry line every submitting slot shows. */\nexport const WEB_POPUP_SUBMIT_DEFAULTS = {\n label: 'Submit',\n errorMessage: WEB_POPUP_RETRY_ERROR\n};\nexport const WEB_POPUP_KEYFRAMES = `\n@keyframes pw-vpopup-fade { from { opacity: 0; } }\n@keyframes pw-vpopup-slide { from { opacity: 0; translate: 0 28px; } }\n@keyframes pw-vpopup-overlay { from { opacity: 0; } }\n@keyframes pw-vpopup-page { from { opacity: 0; } }\n`;\n// Page-switch transition: the incoming page's content fades in while explicit\n// px sizes glide instead of jumping (auto sizes still snap — 'auto' can't be\n// transitioned). One duration for both so they read as a single move.\nexport const WEB_POPUP_PAGE_TRANSITION_MS = 300;","import { WEB_POPUP_DEFAULT_COLORS, WEB_POPUP_FONT_STACK } from '../web-popups/constants';\n/** Positions each layout accepts; the first one is the layout's default. */\nexport const SUBSCRIPTION_WIDGET_POSITIONS = {\n card: ['top', 'bottom', 'top-left', 'top-right', 'bottom-left', 'bottom-right'],\n bar: ['top', 'bottom'],\n modal: ['center']\n};\nexport const SUBSCRIPTION_WIDGET_LAYOUTS = Object.keys(SUBSCRIPTION_WIDGET_POSITIONS);\nexport const SUBSCRIPTION_WIDGET_CORNERS = ['bottom-right', 'bottom-left', 'top-right', 'top-left'];\nexport const SUBSCRIPTION_WIDGET_TRIGGERS = ['auto', 'launcher', 'manual'];\n/** Inclusive bounds every numeric field is clamped to. */\nexport const SUBSCRIPTION_WIDGET_LIMITS = {\n delay: [0, 3600],\n cappingCount: [0, 100],\n cappingInterval: [0, 8760],\n borderRadius: [0, 32],\n offset: [0, 100],\n launcherSize: [16, 200],\n zIndex: [0, 2147483647]\n};\nexport const SUBSCRIPTION_WIDGET_TEXT_MAX_LENGTH = 300;\nexport const SUBSCRIPTION_WIDGET_COLOR_MAX_LENGTH = 64;\nexport const SUBSCRIPTION_WIDGET_DEFAULT_CONFIG = {\n enable: false,\n prompt: {\n enabled: false,\n layout: 'card',\n position: 'top',\n borderRadius: 12,\n overlay: false\n },\n launcher: {\n enabled: false,\n position: 'bottom-right',\n offset: 20,\n width: 48,\n height: 48\n },\n display: {\n trigger: 'auto',\n delay: 5,\n cappingCount: 3,\n cappingInterval: 4\n },\n texts: {\n title: 'Stay in the loop',\n message: 'Allow notifications to get our news and special offers first.',\n acceptText: 'Allow',\n declineText: 'Not now',\n closeText: 'Got it',\n blockedTitle: 'Notifications are blocked',\n blockedMessage: 'To get our notifications, allow them for this site in your browser settings.',\n launcherLabel: 'Subscribe to notifications',\n launcherBlockedLabel: 'Notifications are blocked'\n },\n colors: WEB_POPUP_DEFAULT_COLORS,\n fontFamily: WEB_POPUP_FONT_STACK,\n zIndex: 2147483000\n};\nexport const SUBSCRIPTION_WIDGET_KEYFRAMES = `\n@keyframes pw-subw-fade { from { opacity: 0; } }\n@keyframes pw-subw-drop { from { opacity: 0; translate: 0 -16px; } }\n@keyframes pw-subw-rise { from { opacity: 0; translate: 0 16px; } }\n`;","// Scheme resolution for the popup palette: the authored light/dark roles plus\n// the derived ones (input surface, borders, the label over an accent fill).\nimport { WEB_POPUP_DEFAULT_COLORS, WEB_POPUP_FORM_ERROR_COLOR, WEB_POPUP_FORM_ERROR_COLOR_DARK, WEB_POPUP_FORM_INPUT_BORDER, WEB_POPUP_ON_ACCENT_COLOR, WEB_POPUP_TEXT_COLOR, WEB_POPUP_TEXT_SECONDARY_COLOR } from './constants';\nconst HEX_RE = /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;\nfunction parseHex(color) {\n const hex = HEX_RE.exec(color.trim())?.[1];\n if (!hex) return null;\n const full = hex.length === 3 ? hex.split('').map(c => c + c).join('') : hex;\n return [0, 2, 4].map(i => parseInt(full.slice(i, i + 2), 16));\n}\nfunction toHex([r, g, b]) {\n return `#${[r, g, b].map(v => Math.max(0, Math.min(255, Math.round(v))).toString(16).padStart(2, '0')).join('')}`;\n}\nfunction rgbToHsl([r, g, b]) {\n const [rn, gn, bn] = [r / 255, g / 255, b / 255];\n const max = Math.max(rn, gn, bn);\n const min = Math.min(rn, gn, bn);\n const l = (max + min) / 2;\n if (max === min) return [0, 0, l];\n const d = max - min;\n const s = l > 0.5 ? d / (2 - max - min) : d / (max + min);\n let h;\n if (max === rn) h = (gn - bn) / d + (gn < bn ? 6 : 0);else if (max === gn) h = (bn - rn) / d + 2;else h = (rn - gn) / d + 4;\n return [h / 6, s, l];\n}\nfunction hueToChannel(p, q, t) {\n let tn = t;\n if (tn < 0) tn += 1;\n if (tn > 1) tn -= 1;\n if (tn < 1 / 6) return p + (q - p) * 6 * tn;\n if (tn < 1 / 2) return q;\n if (tn < 2 / 3) return p + (q - p) * (2 / 3 - tn) * 6;\n return p;\n}\nfunction hslToRgb([h, s, l]) {\n if (s === 0) {\n const v = l * 255;\n return [v, v, v];\n }\n const q = l < 0.5 ? l * (1 + s) : l + s - l * s;\n const p = 2 * l - q;\n return [hueToChannel(p, q, h + 1 / 3) * 255, hueToChannel(p, q, h) * 255, hueToChannel(p, q, h - 1 / 3) * 255];\n}\n// Mirror the light half onto [0.07, 0.5]: #FFFFFF lands on the dark canvas\n// tone and near-whites stay apart instead of collapsing into one floor.\nfunction foldLightness(l) {\n return l > 0.5 ? 0.07 + (1 - l) * ((0.5 - 0.07) / 0.5) : l;\n}\n// Mirror the dark half onto [0.5, 0.93]: #000000 lands short of glaring white.\nfunction liftLightness(l) {\n return l < 0.5 ? 0.93 - l * ((0.93 - 0.5) / 0.5) : l;\n}\n/** Hue and saturation survive; only lightness moves. Non-hex colors pass through. */\nexport function webPopupShiftColor(color, direction) {\n const rgb = parseHex(color);\n if (!rgb) return color;\n const [h, s, l] = rgbToHsl(rgb);\n return toHex(hslToRgb([h, s, direction === 'fold' ? foldLightness(l) : liftLightness(l)]));\n}\n/** `ratio` of `over` blended into `base`; either color non-hex = `base` unchanged. */\nexport function webPopupMixColor(base, over, ratio) {\n const a = parseHex(base);\n const b = parseHex(over);\n if (!a || !b) return base;\n return toHex(a.map((v, i) => v + (b[i] - v) * ratio));\n}\n/** `color` at `alpha` as rgba(); a non-hex color renders full-strength instead of being guessed at. */\nexport function webPopupColorAlpha(color, alpha) {\n const rgb = parseHex(color);\n if (!rgb || alpha >= 1) return color;\n const [r, g, b] = rgb;\n return `rgba(${r}, ${g}, ${b}, ${alpha})`;\n}\nfunction isLightColor(color) {\n const rgb = parseHex(color);\n if (!rgb) return false;\n // Perceived luminance, not HSL lightness: #FFFF00 and #0000FF share l = 0.5.\n const [r, g, b] = rgb;\n return (0.299 * r + 0.587 * g + 0.114 * b) / 255 > 0.6;\n}\n// The dark counterpart of a light palette: text lifts, surfaces fold, the\n// accent and the over-image inverse color stay as authored.\nexport function autoDarkWebPopupColors(light) {\n return {\n background: webPopupShiftColor(light.background, 'fold'),\n accent: light.accent,\n text: webPopupShiftColor(light.text, 'lift'),\n textSecondary: webPopupShiftColor(light.textSecondary, 'lift'),\n textInverse: light.textInverse\n };\n}\n// Light keeps the values the popup shipped with before dark mode existed\n// (white cards, grey border, white label) — enabling dark must not restyle it.\nfunction derivedColors(colors, scheme) {\n if (scheme === 'light') {\n return {\n surface: WEB_POPUP_DEFAULT_COLORS.background,\n surfaceText: WEB_POPUP_TEXT_COLOR,\n border: WEB_POPUP_FORM_INPUT_BORDER,\n onAccent: WEB_POPUP_ON_ACCENT_COLOR,\n error: WEB_POPUP_FORM_ERROR_COLOR,\n chromeIcon: WEB_POPUP_TEXT_SECONDARY_COLOR\n };\n }\n return {\n surface: webPopupMixColor(colors.background, colors.text, 0.08),\n surfaceText: colors.text,\n border: webPopupMixColor(colors.background, colors.text, 0.24),\n onAccent: isLightColor(colors.accent) ? WEB_POPUP_TEXT_COLOR : WEB_POPUP_ON_ACCENT_COLOR,\n error: WEB_POPUP_FORM_ERROR_COLOR_DARK,\n chromeIcon: colors.textSecondary\n };\n}\n/** The dark palette a popup renders with: authored roles over the autogenerated ones. */\nexport function webPopupDarkColors(light, dark) {\n return {\n ...autoDarkWebPopupColors(light),\n ...(dark?.colors ?? {})\n };\n}\n/** True when the popup opts into dark mode at all — the host's cue to watch the media query. */\nexport function webPopupDarkEnabled(chrome) {\n return chrome.dark?.enabled === true;\n}\n/** The scheme a popup actually draws with: 'dark' only when it opts in. */\nexport function webPopupEffectiveScheme(chrome, scheme = 'light') {\n return scheme === 'dark' && webPopupDarkEnabled(chrome) ? 'dark' : 'light';\n}\n// Every color a renderer needs, for the scheme actually drawn. Asking for\n// 'dark' on a popup without dark mode returns the light palette.\nexport function resolveWebPopupColors(chrome, scheme = 'light') {\n const effective = webPopupEffectiveScheme(chrome, scheme);\n const colors = effective === 'dark' ? webPopupDarkColors(chrome.colors, chrome.dark) : chrome.colors;\n return {\n ...colors,\n scheme: effective,\n ...derivedColors(colors, effective)\n };\n}\n/** The url drawn for `scheme`; a dark source only exists when authored. */\nexport function webPopupImageSrc(image, scheme = 'light') {\n return scheme === 'dark' && image.srcDark ? image.srcDark : image.src;\n}\n/** The page dim and box shadow for the scheme actually drawn; the light ones\n * stand in wherever the dark palette authored no override. */\nexport function resolveWebPopupBoxChrome(chrome, scheme = 'light') {\n if (webPopupEffectiveScheme(chrome, scheme) === 'light') {\n return {\n overlay: chrome.overlay,\n boxShadow: chrome.boxShadow\n };\n }\n return {\n overlay: chrome.dark?.overlay ?? chrome.overlay,\n boxShadow: chrome.dark?.boxShadow ?? chrome.boxShadow\n };\n}","import { SAFE_URL_PROTOCOL, WEB_POPUP_CHOICE_DEFAULTS, WEB_POPUP_CONSENT_DEFAULTS, WEB_POPUP_DEFAULT_COLORS, WEB_POPUP_EMAIL_INPUT_DEFAULTS, WEB_POPUP_FORM_DEFAULTS, WEB_POPUP_MAX_CHOICE_OPTIONS, WEB_POPUP_PRODUCTS_DEFAULTS, WEB_POPUP_PRODUCTS_MAX_LIMIT, WEB_POPUP_RATING_DEFAULTS, WEB_POPUP_SUBMIT_DEFAULTS, WEB_POPUP_TAG_INPUT_DEFAULTS, WEB_POPUP_VERSION } from './constants';\nimport { WEB_POPUP_GLYPH_NAMES, WEB_POPUP_GLYPH_SIZES } from './glyphs';\nimport { normalizeWebPopupLayout, substituteWebPopupLayoutValues, WEB_POPUP_VALUE_KEY_PATTERN } from './layout';\nimport { autoDarkWebPopupColors } from './palette';\nimport { webPopupTimeZoneSupported, webPopupWallClockMs } from './timer';\n// Sanitize a user-entered button URL before it lands in an href: https/http/\n// mailto/tel and page-relative links only.\nexport function safeUrl(url) {\n const trimmed = (url || '').trim();\n if (!trimmed) return undefined;\n if (trimmed.startsWith('#') || trimmed.startsWith('/') || trimmed.startsWith('?')) return trimmed;\n if (SAFE_URL_PROTOCOL.test(trimmed)) return trimmed;\n return undefined;\n}\n/**\n * The target/rel pair a popup link renders with: only an exact '_self' opts\n * out of the default new tab (and of its noreferrer, which same-tab\n * navigation doesn't need). One rule for both link kinds — the reader's\n * button anchors and the sanitizer's inline text links.\n */\nexport function webPopupLinkTargetAttrs(target) {\n return target === '_self' ? {\n target: '_self'\n } : {\n target: '_blank',\n rel: 'noreferrer'\n };\n}\n/**\n * Carries out a subscribe button's setting for the visitor's answer; true = the content closes.\n * A new tab opens with noopener, so `window.open` returns null and a blocked tab goes unnoticed.\n */\nexport function applyWebPopupSubscribeOutcome(action, result, logger) {\n const outcome = result === 'granted' ? action.onGranted : action.onDenied;\n if (outcome?.type === 'href') openWebPopupSubscribeLink(outcome, logger);\n // Granted always closes, as before the setting; denied closes only when set to.\n if (result === 'granted') return true;\n return outcome?.type === 'close';\n}\nfunction openWebPopupSubscribeLink(outcome, logger) {\n const href = typeof outcome.url === 'string' ? safeUrl(outcome.url) : undefined;\n if (!href) {\n logger?.warn('Subscribe button: the link to open after the answer is empty or unsafe, it was not opened');\n return;\n }\n if (outcome.target === '_self') {\n window.location.assign(href);\n return;\n }\n window.open(href, '_blank', 'noopener,noreferrer');\n}\nconst SANITIZE_ALLOWED_TAGS = new Set(['STRONG', 'B', 'EM', 'I', 'U', 'BR', 'A']);\nfunction copySanitized(from, to, doc) {\n for (const child of Array.from(from.childNodes)) {\n if (child.nodeType === 3 /* text */) {\n to.appendChild(doc.createTextNode(child.textContent ?? ''));\n continue;\n }\n if (child.nodeType !== 1 /* element */) continue;\n const el = child;\n // Unknown tags are unwrapped — their children survive as plain content.\n if (!SANITIZE_ALLOWED_TAGS.has(el.tagName)) {\n copySanitized(el, to, doc);\n continue;\n }\n const clean = doc.createElement(el.tagName.toLowerCase());\n if (el.tagName === 'A') {\n const href = safeUrl(el.getAttribute('href') ?? undefined);\n if (href) clean.setAttribute('href', href);\n const {\n target,\n rel\n } = webPopupLinkTargetAttrs(el.getAttribute('target'));\n clean.setAttribute('target', target);\n if (rel) clean.setAttribute('rel', rel);\n }\n to.appendChild(clean);\n copySanitized(el, clean, doc);\n }\n}\n/**\n * Sanitize a text slot's html before it's injected into the page. The editor\n * only ever writes inline formatting, but the json travels through a public\n * API and renders on customers' sites — so on render only the inline tags\n * survive (anything else is unwrapped to its text), every attribute is\n * dropped, and links keep only a safeUrl-approved href plus their tab choice\n * (target=\"_self\" stays; everything else opens in a new tab).\n */\nexport function sanitizeWebPopupHtml(html) {\n // No '<' → no elements can form; entities in plain text are already-valid\n // html and pass through untouched.\n if (!html.includes('<')) return html;\n const parsed = new DOMParser().parseFromString(html, 'text/html');\n const out = parsed.createElement('div');\n copySanitized(parsed.body, out, parsed);\n return out.innerHTML;\n}\nfunction colorString(value) {\n return typeof value === 'string' && value ? value : undefined;\n}\n/**\n * The popup palette from API-writable params: `colors` entries when present,\n * the legacy top-level background/accent underneath, palette defaults for the\n * rest — always a complete WebPopupColors.\n */\nexport function normalizeWebPopupColors(params) {\n const colors = typeof params.colors === 'object' && params.colors !== null ? params.colors : {};\n return {\n background: colorString(colors.background) ?? colorString(params.background) ?? WEB_POPUP_DEFAULT_COLORS.background,\n accent: colorString(colors.accent) ?? colorString(params.accent) ?? WEB_POPUP_DEFAULT_COLORS.accent,\n text: colorString(colors.text) ?? WEB_POPUP_DEFAULT_COLORS.text,\n textSecondary: colorString(colors.textSecondary) ?? WEB_POPUP_DEFAULT_COLORS.textSecondary,\n textInverse: colorString(colors.textInverse) ?? WEB_POPUP_DEFAULT_COLORS.textInverse\n };\n}\n// A page dim from API-writable json: both fields or nothing, opacity clamped.\nfunction normalizeOverlay(raw) {\n if (typeof raw !== 'object' || raw === null) return undefined;\n const overlay = raw;\n const color = colorString(overlay.color);\n if (!color) return undefined;\n const opacity = typeof overlay.opacity === 'number' && Number.isFinite(overlay.opacity) ? Math.max(0, Math.min(1, overlay.opacity)) : 1;\n return {\n color,\n opacity\n };\n}\n// Authored dark entries over the ones autogenerated from the light palette.\n// Absent `dark` = no dark mode; an authored palette switched off is not that.\nexport function normalizeWebPopupDark(params, light) {\n const raw = params.dark;\n if (typeof raw !== 'object' || raw === null) return undefined;\n const dark = raw;\n const authored = typeof dark.colors === 'object' && dark.colors !== null ? dark.colors : {};\n const auto = autoDarkWebPopupColors(light);\n const overlay = normalizeOverlay(dark.overlay);\n return {\n enabled: dark.enabled === true,\n colors: {\n background: colorString(authored.background) ?? auto.background,\n accent: colorString(authored.accent) ?? auto.accent,\n text: colorString(authored.text) ?? auto.text,\n textSecondary: colorString(authored.textSecondary) ?? auto.textSecondary,\n textInverse: colorString(authored.textInverse) ?? auto.textInverse\n },\n ...(overlay ? {\n overlay\n } : {}),\n ...(colorString(dark.boxShadow) ? {\n boxShadow: dark.boxShadow\n } : {})\n };\n}\n// Parse stored PopupFormContent.json into the popup model. Returns null for\n// anything that isn't a version-2 popup with at least one page — including\n// the retired version-1 flat-layout format and pre-engine content with no\n// `version` field at all, which callers should treat as broken. The palette\n// comes out complete: colors entries → legacy top-level background/accent →\n// defaults.\nexport function parseWebPopupJson(json) {\n let raw;\n try {\n raw = JSON.parse(json);\n } catch {\n return null;\n }\n if (typeof raw !== 'object' || raw === null) return null;\n const candidate = raw;\n if (candidate.version !== WEB_POPUP_VERSION) return null;\n const params = candidate.params;\n if (typeof params !== 'object' || params === null) return null;\n if (!Array.isArray(params.pages) || params.pages.length === 0) return null;\n const colors = normalizeWebPopupColors(params);\n const dark = normalizeWebPopupDark(params, colors);\n return {\n version: WEB_POPUP_VERSION,\n params: {\n ...params,\n colors,\n ...(dark ? {\n dark\n } : {})\n }\n };\n}\n/** The editor's save path: model → PopupFormContent.json string. */\nexport function stringifyWebPopup(params) {\n const compat = {\n ...params,\n background: params.colors.background,\n accent: params.colors.accent\n };\n const payload = {\n version: WEB_POPUP_VERSION,\n params: compat\n };\n return JSON.stringify(payload);\n}\nconst IMAGE_FITS = ['cover', 'contain'];\nconst MAX_IMAGE_BLUR = 100;\n// Bomb protection for the page content, mirroring the layout tree's\n// depth/node caps: the tree allows up to ~100 Content nodes and several may\n// reference the same zone, so unbounded zones/slots would amplify into\n// thousands of sanitize+render passes on the customer's page.\nconst MAX_IMAGES = 20;\nconst MAX_ZONES = 20;\nconst MAX_ZONE_SLOTS = 50;\n// A media param's video, or undefined when it has none / an unusable url —\n// then the param stays a plain image and the poster is all that renders.\nfunction normalizeVideo(raw) {\n if (typeof raw !== 'object' || raw === null) return undefined;\n const video = raw;\n const src = safeUrl(typeof video.src === 'string' ? video.src : undefined);\n if (!src) return undefined;\n return {\n src,\n ...(video.controls === true ? {\n controls: true\n } : {}),\n ...(video.loop === false ? {\n loop: false\n } : {})\n };\n}\n// The images come from API-writable json — keep only well-formed entries,\n// with the presentation props (fit/blur) validated like the layout tree's.\nfunction normalizeImages(raw) {\n if (!Array.isArray(raw)) return [];\n const out = [];\n for (const img of raw) {\n if (out.length >= MAX_IMAGES) break;\n if (typeof img !== 'object' || img === null) continue;\n if (typeof img.key !== 'string' || !img.key) continue;\n if (typeof img.src !== 'string') continue;\n const video = normalizeVideo(img.video);\n out.push({\n key: img.key,\n label: typeof img.label === 'string' ? img.label : '',\n src: img.src,\n ...(typeof img.srcDark === 'string' && img.srcDark ? {\n srcDark: img.srcDark\n } : {}),\n ...(video ? {\n video\n } : {}),\n ...(typeof img.mediaId === 'string' && img.mediaId ? {\n mediaId: img.mediaId\n } : {}),\n ...(typeof img.mediaIdDark === 'string' && img.mediaIdDark ? {\n mediaIdDark: img.mediaIdDark\n } : {}),\n ...(IMAGE_FITS.includes(img.fit) ? {\n fit: img.fit\n } : {}),\n ...(typeof img.blur === 'number' && Number.isFinite(img.blur) && img.blur > 0 ? {\n blur: Math.min(img.blur, MAX_IMAGE_BLUR)\n } : {}),\n ...(typeof img.dim === 'number' && Number.isFinite(img.dim) && img.dim > 0 ? {\n dim: Math.min(img.dim, 1)\n } : {})\n });\n }\n return out;\n}\nconst MAX_VALUES = 20;\nconst MAX_VALUE_LENGTH = 64;\nconst MAX_SELECT_OPTIONS = 20;\nconst LENGTH_CONTROL_UNITS = ['px', '%', 'em', 'rem', 'fr'];\nfunction finiteNumber(value) {\n return typeof value === 'number' && Number.isFinite(value) ? value : undefined;\n}\n// Per-unit { min?, max? } overrides for a length control, keyed by a\n// whitelisted unit. Non-object input, unknown unit keys and non-finite bounds\n// are dropped; an all-empty map returns undefined so the field is omitted.\nfunction normalizeControlRanges(raw) {\n if (typeof raw !== 'object' || raw === null) return undefined;\n const out = {};\n for (const unit of LENGTH_CONTROL_UNITS) {\n const entry = raw[unit];\n if (typeof entry !== 'object' || entry === null) continue;\n const min = finiteNumber(entry.min);\n const max = finiteNumber(entry.max);\n if (min === undefined && max === undefined) continue;\n out[unit] = {\n ...(min !== undefined ? {\n min\n } : {}),\n ...(max !== undefined ? {\n max\n } : {})\n };\n }\n return Object.keys(out).length > 0 ? out : undefined;\n}\n// The control is editor metadata from API-writable json: enum-whitelisted\n// kind, clamped numbers, capped options. Anything malformed drops to\n// undefined — the editor falls back to a plain text input.\nfunction normalizeValueControl(raw) {\n if (typeof raw !== 'object' || raw === null) return undefined;\n const control = raw;\n if (control.kind === 'text') return {\n kind: 'text'\n };\n if (control.kind === 'length' || control.kind === 'percent') {\n const min = finiteNumber(control.min);\n const max = finiteNumber(control.max);\n const units = control.kind === 'length' && Array.isArray(control.units) ? control.units.filter(u => LENGTH_CONTROL_UNITS.includes(u)) : [];\n // Per-unit min/max overrides: whitelisted unit keys, finite bounds. Any\n // malformed entry is skipped; an empty result drops the whole field.\n const ranges = control.kind === 'length' ? normalizeControlRanges(control.ranges) : undefined;\n return {\n kind: control.kind,\n ...(min !== undefined ? {\n min\n } : {}),\n ...(max !== undefined ? {\n max\n } : {}),\n ...(units.length > 0 ? {\n units\n } : {}),\n ...(ranges ? {\n ranges\n } : {})\n };\n }\n if (control.kind === 'select' && Array.isArray(control.options)) {\n const options = [];\n for (const option of control.options) {\n if (options.length >= MAX_SELECT_OPTIONS) break;\n if (typeof option !== 'object' || option === null) continue;\n if (typeof option.value !== 'string' || option.value.length > MAX_VALUE_LENGTH) continue;\n options.push({\n value: option.value,\n label: typeof option.label === 'string' ? option.label : option.value\n });\n }\n if (options.length > 0) return {\n kind: 'select',\n options\n };\n }\n return undefined;\n}\n/**\n * The page's named layout values from API-writable json: capped count,\n * whitelisted keys, short '$'-free value strings (substitution is single-pass\n * and this keeps refs from even *looking* chainable), validated controls.\n */\nexport function normalizeWebPopupValues(raw) {\n if (!Array.isArray(raw)) return [];\n const out = [];\n for (const value of raw) {\n if (out.length >= MAX_VALUES) break;\n if (typeof value !== 'object' || value === null) continue;\n if (typeof value.key !== 'string' || !WEB_POPUP_VALUE_KEY_PATTERN.test(value.key)) continue;\n if (typeof value.value !== 'string' || value.value.length > MAX_VALUE_LENGTH || value.value.includes('$')) continue;\n if (out.some(v => v.key === value.key)) continue;\n const control = normalizeValueControl(value.control);\n out.push({\n key: value.key,\n label: typeof value.label === 'string' ? value.label : '',\n value: value.value,\n ...(control ? {\n control\n } : {})\n });\n }\n return out;\n}\n/** The values as a substitution map (see substituteWebPopupLayoutValues). */\nexport function webPopupValuesMap(values) {\n return Object.fromEntries(values.map(v => [v.key, v.value]));\n}\nconst FORM_FIELD_KINDS = ['email', 'firstName', 'lastName', 'phone', 'custom'];\nconst BUTTON_VARIANTS = ['primary', 'secondary'];\nconst MAX_FORM_FIELDS = 10;\n// A form slot's fields from API-writable json: capped, whitelisted kinds,\n// deduped keys. The submit contract needs an email — when none survives, one\n// is injected up front (the slot stays renderable/editable rather than being\n// dropped: the editor canvas resolves through this same pipeline). Email\n// fields are always required — the payload can't form without a value.\nfunction normalizeFormFields(raw) {\n const out = [];\n if (Array.isArray(raw)) {\n for (const field of raw) {\n if (out.length >= MAX_FORM_FIELDS) break;\n if (typeof field !== 'object' || field === null) continue;\n if (typeof field.key !== 'string' || !field.key) continue;\n if (!FORM_FIELD_KINDS.includes(field.kind)) continue;\n if (out.some(f => f.key === field.key)) continue;\n out.push({\n key: field.key,\n kind: field.kind,\n label: typeof field.label === 'string' ? field.label : '',\n placeholder: typeof field.placeholder === 'string' ? field.placeholder : '',\n required: field.kind === 'email' || field.required === true,\n ...(field.kind === 'custom' && typeof field.tag === 'string' && field.tag ? {\n tag: field.tag\n } : {})\n });\n }\n }\n if (!out.some(f => f.kind === 'email')) {\n let key = 'field-email';\n while (out.some(f => f.key === key)) key = `${key}-1`;\n out.unshift({\n key,\n kind: 'email',\n label: 'Email',\n placeholder: '',\n required: true\n });\n }\n return out.slice(0, MAX_FORM_FIELDS);\n}\nconst CHOICE_CONTROLS = ['checkbox', 'chips'];\nconst PRODUCTS_STRATEGIES = ['viewed', 'bestsellers_30d', 'also_bought', 'cart'];\nfunction productsStrategy(value) {\n return PRODUCTS_STRATEGIES.includes(value) ? value : undefined;\n}\nconst PRODUCTS_LAYOUTS = ['row', 'grid'];\nconst RATING_SCALES = ['nps', 'stars', 'thumbs'];\nconst RATING_SUBMIT_MODES = ['instant', 'button'];\nconst TIMER_EXPIRE_ACTIONS = ['keep', 'hide-popup', 'page'];\nconst LANGUAGE_CODE = /^[a-z]{2}$/i;\nconst HEX_COLOR = /^#[0-9a-fA-F]{6}$/;\n// Authored strings from API-writable json land in the popup's own markup on a\n// customer's page — capped so a 100kB \"label\" can't be one.\nconst MAX_SLOT_STRING = 120;\nconst MAX_SLOT_MESSAGE = 500;\nfunction slotString(value, max = MAX_SLOT_STRING) {\n return typeof value === 'string' ? value.trim().slice(0, max) : '';\n}\n// A capped string with a fallback for when the json omits it (or sends blanks).\nfunction slotStringOr(value, fallback, max = MAX_SLOT_STRING) {\n return slotString(value, max) || fallback;\n}\n/** An ISO 639-1 code, lowercased; anything else = '' (the renderer's 'en'). */\nfunction normalizeLanguage(value) {\n const code = slotString(value, 8);\n return LANGUAGE_CODE.test(code) ? code.toLowerCase() : '';\n}\n// Capped, non-empty values, deduped, label falling back to the value. An\n// option-less slot survives, like an unbound form: the editor must still edit it.\nfunction normalizeChoiceOptions(raw) {\n if (!Array.isArray(raw)) return [];\n const out = [];\n for (const option of raw) {\n if (out.length >= WEB_POPUP_MAX_CHOICE_OPTIONS) break;\n if (typeof option !== 'object' || option === null) continue;\n const value = slotString(option.value);\n if (!value) continue;\n if (out.some(existing => existing.value === value)) continue;\n const tagValue = slotString(option.tagValue);\n out.push({\n value,\n label: slotStringOr(option.label, value),\n ...(tagValue ? {\n tagValue\n } : {})\n });\n }\n return out;\n}\n// The selection bounds against the surviving option count: 0 = unbounded, and\n// a max under the min would leave the slot unsubmittable — the min wins.\nfunction normalizeChoiceBounds(slot, options) {\n const bound = value => {\n const n = finiteNumber(value);\n return n === undefined || n <= 0 ? 0 : Math.min(Math.floor(n), options);\n };\n const min = bound(slot.min);\n const max = bound(slot.max);\n return {\n min,\n max: max > 0 ? Math.max(min, max) : 0\n };\n}\n// Per-type slot validation. Text and button entries pass through UNTOUCHED\n// when well-formed (stored popups predate this check — don't rewrite them);\n// a form slot is rebuilt field by field; an unknown slot type is dropped so\n// slot types added after this engine build degrade to absence, not a crash.\nfunction normalizeSlots(raw) {\n const out = [];\n for (const slot of raw) {\n if (out.length >= MAX_ZONE_SLOTS) break;\n if (typeof slot !== 'object' || slot === null) continue;\n if (typeof slot.key !== 'string' || !slot.key) continue;\n if (slot.type === 'text') {\n if (typeof slot.html === 'string') out.push(slot);\n continue;\n }\n if (slot.type === 'button') {\n // An action-less button would crash the renderer on the action switch.\n if (typeof slot.action === 'object' && slot.action !== null && typeof slot.action.type === 'string') {\n out.push(slot);\n }\n continue;\n }\n if (slot.type === 'timer') {\n // An unsupported zone name degrades to the contract's UTC rather than\n // dropping the countdown.\n const zone = slotString(slot.timezone, 64);\n const timezone = webPopupTimeZoneSupported(zone) ? zone : '';\n const endTime = slotString(slot.endTime, 32);\n // No computable deadline = nothing to count down to.\n if (webPopupWallClockMs(endTime, timezone) === null) continue;\n const expirePage = slotString(slot.expirePage);\n const onExpire = TIMER_EXPIRE_ACTIONS.includes(slot.onExpire) ? slot.onExpire : 'keep';\n // 'page' without a target page is 'keep' — the renderer never has to\n // guess where a pageless jump should land.\n const expires = onExpire === 'page' && !expirePage ? 'keep' : onExpire;\n out.push({\n type: 'timer',\n key: slot.key,\n endTime,\n timezone,\n language: normalizeLanguage(slot.language),\n showLabels: slot.showLabels !== false,\n onExpire: expires,\n ...(expires === 'page' ? {\n expirePage\n } : {})\n });\n continue;\n }\n if (slot.type === 'choice') {\n const options = normalizeChoiceOptions(slot.options);\n const {\n min,\n max\n } = normalizeChoiceBounds(slot, options.length);\n out.push({\n type: 'choice',\n key: slot.key,\n control: CHOICE_CONTROLS.includes(slot.control) ? slot.control : 'checkbox',\n tagName: slotString(slot.tagName),\n options,\n min,\n max,\n submitLabel: slotStringOr(slot.submitLabel, WEB_POPUP_CHOICE_DEFAULTS.submitLabel),\n submitVariant: BUTTON_VARIANTS.includes(slot.submitVariant) ? slot.submitVariant : 'primary',\n successMessage: slotStringOr(slot.successMessage, WEB_POPUP_CHOICE_DEFAULTS.successMessage, MAX_SLOT_MESSAGE)\n });\n continue;\n }\n if (slot.type === 'rating') {\n const labels = typeof slot.labels === 'object' && slot.labels !== null ? slot.labels : {};\n out.push({\n type: 'rating',\n key: slot.key,\n // A malformed scale renders as stars: five buttons read the same in\n // every language, which an 0..10 row does not.\n scale: RATING_SCALES.includes(slot.scale) ? slot.scale : 'stars',\n labels: {\n low: slotString(labels.low),\n high: slotString(labels.high)\n },\n submitMode: RATING_SUBMIT_MODES.includes(slot.submitMode) ? slot.submitMode : 'instant',\n submitLabel: slotStringOr(slot.submitLabel, WEB_POPUP_RATING_DEFAULTS.submitLabel),\n eventName: slotString(slot.eventName),\n successMessage: slotStringOr(slot.successMessage, WEB_POPUP_RATING_DEFAULTS.successMessage, MAX_SLOT_MESSAGE)\n });\n continue;\n }\n if (slot.type === 'glyph') {\n // An unknown icon name has no geometry to draw — dropped, exactly like\n // an unknown slot type.\n if (!WEB_POPUP_GLYPH_NAMES.includes(slot.name)) continue;\n out.push({\n type: 'glyph',\n key: slot.key,\n name: slot.name,\n size: WEB_POPUP_GLYPH_SIZES.includes(slot.size) ? slot.size : WEB_POPUP_GLYPH_SIZES[0],\n color: typeof slot.color === 'string' && HEX_COLOR.test(slot.color) ? slot.color : ''\n });\n continue;\n }\n if (slot.type === 'products') {\n const fields = typeof slot.fields === 'object' && slot.fields !== null ? slot.fields : {};\n const limit = Number.isFinite(slot.limit) ? Math.round(slot.limit) : WEB_POPUP_PRODUCTS_DEFAULTS.limit;\n // A strategy this build doesn't know would ask the feed for nothing — bestsellers always answer.\n const strategy = productsStrategy(slot.strategy) ?? 'bestsellers_30d';\n // The same as the strategy = no fallback: a second identical request finds nothing new.\n const fallback = productsStrategy(slot.fallbackStrategy);\n out.push({\n type: 'products',\n key: slot.key,\n strategy,\n ...(fallback && fallback !== strategy ? {\n fallbackStrategy: fallback\n } : {}),\n limit: Math.min(Math.max(limit, 1), WEB_POPUP_PRODUCTS_MAX_LIMIT),\n layout: PRODUCTS_LAYOUTS.includes(slot.layout) ? slot.layout : 'row',\n fields: {\n title: fields.title !== false,\n price: fields.price !== false,\n image: fields.image !== false,\n cta: fields.cta !== false\n },\n ctaText: slotString(slot.ctaText),\n hideWhenEmpty: slot.hideWhenEmpty === true\n });\n continue;\n }\n if (slot.type === 'email-input') {\n out.push({\n type: 'email-input',\n key: slot.key,\n label: slotString(slot.label),\n placeholder: slotString(slot.placeholder),\n invalidMessage: slotStringOr(slot.invalidMessage, WEB_POPUP_EMAIL_INPUT_DEFAULTS.invalidMessage),\n requiredMessage: slotStringOr(slot.requiredMessage, WEB_POPUP_EMAIL_INPUT_DEFAULTS.requiredMessage)\n });\n continue;\n }\n if (slot.type === 'tag-input') {\n out.push({\n type: 'tag-input',\n key: slot.key,\n tagName: slotString(slot.tagName),\n label: slotString(slot.label),\n placeholder: slotString(slot.placeholder),\n required: slot.required === true,\n requiredMessage: slotStringOr(slot.requiredMessage, WEB_POPUP_TAG_INPUT_DEFAULTS.requiredMessage)\n });\n continue;\n }\n if (slot.type === 'consent') {\n out.push({\n type: 'consent',\n key: slot.key,\n checkboxLabel: slotString(slot.checkboxLabel, MAX_SLOT_MESSAGE),\n linkLabel: slotString(slot.linkLabel),\n url: slotString(slot.url, MAX_SLOT_MESSAGE),\n requiredMessage: slotStringOr(slot.requiredMessage, WEB_POPUP_CONSENT_DEFAULTS.requiredMessage)\n });\n continue;\n }\n if (slot.type === 'submit') {\n out.push({\n type: 'submit',\n key: slot.key,\n variant: BUTTON_VARIANTS.includes(slot.variant) ? slot.variant : 'primary',\n label: slotStringOr(slot.label, WEB_POPUP_SUBMIT_DEFAULTS.label),\n errorMessage: slotStringOr(slot.errorMessage, WEB_POPUP_SUBMIT_DEFAULTS.errorMessage, MAX_SLOT_MESSAGE)\n });\n continue;\n }\n if (slot.type === 'email-subscription-form') {\n out.push({\n type: 'email-subscription-form',\n key: slot.key,\n formCode: typeof slot.formCode === 'string' ? slot.formCode : '',\n fields: normalizeFormFields(slot.fields),\n submitLabel: typeof slot.submitLabel === 'string' && slot.submitLabel ? slot.submitLabel : WEB_POPUP_FORM_DEFAULTS.submitLabel,\n submitVariant: BUTTON_VARIANTS.includes(slot.submitVariant) ? slot.submitVariant : 'primary',\n ...(typeof slot.privacy === 'object' && slot.privacy !== null && typeof slot.privacy.checkboxLabel === 'string' ? {\n privacy: {\n checkboxLabel: slot.privacy.checkboxLabel,\n url: typeof slot.privacy.url === 'string' ? slot.privacy.url : '',\n linkLabel: typeof slot.privacy.linkLabel === 'string' ? slot.privacy.linkLabel : ''\n }\n } : {}),\n successMessage: typeof slot.successMessage === 'string' && slot.successMessage ? slot.successMessage : WEB_POPUP_FORM_DEFAULTS.successMessage,\n confirmEmailMessage: typeof slot.confirmEmailMessage === 'string' && slot.confirmEmailMessage ? slot.confirmEmailMessage : WEB_POPUP_FORM_DEFAULTS.confirmEmailMessage\n });\n }\n // Unknown slot type → dropped.\n }\n return out;\n}\n// The zones come from API-writable json — keep only well-formed entries\n// (capped, see above) so the renderer can trust the shape.\nfunction normalizeContents(raw) {\n if (!Array.isArray(raw)) return [];\n const out = [];\n for (const zone of raw) {\n if (out.length >= MAX_ZONES) break;\n if (typeof zone !== 'object' || zone === null) continue;\n if (typeof zone.key !== 'string' || !zone.key) continue;\n if (!Array.isArray(zone.slots)) continue;\n out.push({\n key: zone.key,\n label: typeof zone.label === 'string' ? zone.label : '',\n slots: normalizeSlots(zone.slots)\n });\n }\n return out;\n}\n/**\n * Every subscription form code the popup's form slots reference (unique,\n * empty codes skipped) — what a host records view stats for. Reads the RAW\n * params (tolerant of malformed slots), so it works on parsed-but-unresolved\n * json.\n */\nexport function collectWebPopupFormCodes(params) {\n const out = new Set();\n for (const page of params.pages) {\n if (!Array.isArray(page?.contents)) continue;\n for (const zone of page.contents) {\n if (!Array.isArray(zone?.slots)) continue;\n for (const slot of zone.slots) {\n if (typeof slot !== 'object' || slot === null) continue;\n if (slot.type !== 'email-subscription-form') continue;\n if (typeof slot.formCode === 'string' && slot.formCode) out.add(slot.formCode);\n }\n }\n }\n return [...out];\n}\n/** Every products slot of the popup, normalized: the host's pre-show question for `hideWhenEmpty`. */\nexport function collectWebPopupProductSlots(params) {\n const out = [];\n for (const page of params.pages) {\n if (!Array.isArray(page?.contents)) continue;\n for (const zone of page.contents) {\n if (!Array.isArray(zone?.slots)) continue;\n for (const slot of normalizeSlots(zone.slots)) {\n if (slot.type === 'products') out.push(slot);\n }\n }\n }\n return out;\n}\n// Has a 'hide-popup' countdown run out? The HOST asks before showing, at SHOW\n// time; any page counts, and a malformed timer reads as 'not expired'.\nexport function webPopupExpired(params, nowMs) {\n for (const page of params.pages) {\n if (!Array.isArray(page?.contents)) continue;\n for (const zone of page.contents) {\n if (!Array.isArray(zone?.slots)) continue;\n for (const slot of zone.slots) {\n if (typeof slot !== 'object' || slot === null) continue;\n if (slot.type !== 'timer' || slot.onExpire !== 'hide-popup') continue;\n if (typeof slot.endTime !== 'string') continue;\n const timezone = typeof slot.timezone === 'string' ? slot.timezone : '';\n const deadline = webPopupWallClockMs(slot.endTime, timezone);\n if (deadline !== null && deadline <= nowMs) return true;\n }\n }\n }\n return false;\n}\n/**\n * The popup box-size ceiling px, mirroring the layout tree's px clamp: the\n * json is API-writable and the size lands as inline style on the customer's\n * page. The editor clamps its Width/Height inputs to it too.\n */\nexport const WEB_POPUP_MAX_SIZE_PX = 2000;\nfunction validSize(value) {\n return typeof value === 'number' && Number.isFinite(value) && value > 0 ? Math.min(value, WEB_POPUP_MAX_SIZE_PX) : undefined;\n}\nexport function resolveWebPopupPageSize(own, shared, axis) {\n if (own === null) return undefined;\n let resolved;\n if (own === 'stretch') resolved = 'stretch';else resolved = validSize(own) ?? (shared === 'stretch' ? 'stretch' : validSize(shared));\n return axis === 'width' && resolved === 'stretch' ? undefined : resolved;\n}\n/**\n * The renderable pages: each page carries its own embedded layout tree — no\n * kind catalog at runtime. The page's named values are substituted into the\n * tree first ($key tokens), then the result is validated/normalized\n * (whitelisted props, unknown container types degrade to a Vertical stack) —\n * so substituted values pass the same clamps as literals; pages whose layout\n * isn't a tree at all are dropped. An empty result means the popup can't be\n * rendered. width/height come out FINAL (page override ?? chrome, validated)\n * — the renderer never falls back itself.\n */\nexport function resolveWebPopupPages(params) {\n const out = [];\n for (const page of params.pages) {\n const values = normalizeWebPopupValues(page.values);\n const layout = normalizeWebPopupLayout(substituteWebPopupLayoutValues(page.layout, webPopupValuesMap(values)));\n if (!layout) continue;\n const width = resolveWebPopupPageSize(page.width, params.width, 'width');\n const height = resolveWebPopupPageSize(page.height, params.height, 'height');\n out.push({\n key: page.key,\n layout,\n images: normalizeImages(page.images),\n contents: normalizeContents(page.contents),\n ...(width !== undefined ? {\n width\n } : {}),\n ...(height !== undefined ? {\n height\n } : {}),\n ...(page.role === 'success' ? {\n role: 'success'\n } : {})\n });\n }\n return out;\n}\n/** The page shown first: startPage when it exists, else the first page. */\nexport function startPageOf(params, pages) {\n return pages.find(p => p.key === params.startPage) ?? pages[0];\n}\nexport function placementMaxSize(placement) {\n return `calc(100% - ${placement.offset * 2}px)`;\n}\n/** Whether a slot is a button with the `close` action; anything malformed reads as false. */\nexport function isWebPopupCloseButton(slot) {\n const candidate = slot;\n return candidate?.type === 'button' && candidate.action?.type === 'close';\n}\nfunction zoneWithoutCloseButtons(zone) {\n if (!Array.isArray(zone?.slots)) return zone;\n return {\n ...zone,\n slots: zone.slots.filter(slot => !isWebPopupCloseButton(slot))\n };\n}\n/** A copy of one page without close-action buttons; tolerant of non-normalized json. */\nexport function webPopupPageWithoutCloseButtons(page) {\n if (!Array.isArray(page?.contents)) return page;\n return {\n ...page,\n contents: page.contents.map(zoneWithoutCloseButtons)\n };\n}\n/** A copy of the params without close-action buttons — an Inline (EMBEDDED) block has nothing to close. */\nexport function webPopupParamsWithoutCloseButtons(params) {\n if (!Array.isArray(params?.pages)) return params;\n return {\n ...params,\n pages: params.pages.map(webPopupPageWithoutCloseButtons)\n };\n}","import { SUBSCRIPTION_WIDGET_CORNERS, SUBSCRIPTION_WIDGET_DEFAULT_CONFIG, SUBSCRIPTION_WIDGET_LAYOUTS, SUBSCRIPTION_WIDGET_LIMITS, SUBSCRIPTION_WIDGET_POSITIONS, SUBSCRIPTION_WIDGET_TEXT_MAX_LENGTH, SUBSCRIPTION_WIDGET_TRIGGERS, SUBSCRIPTION_WIDGET_COLOR_MAX_LENGTH } from './constants';\nimport { normalizeWebPopupColors, normalizeWebPopupDark, safeUrl } from '../web-popups/helpers';\nconst HOUR_MS = 3600 * 1000;\nfunction record(value) {\n return typeof value === 'object' && value !== null && !Array.isArray(value) ? value : {};\n}\nfunction oneOf(value, allowed, fallback) {\n return allowed.includes(value) ? value : fallback;\n}\nfunction clamped(value, [min, max], fallback) {\n if (typeof value !== 'number' || !Number.isFinite(value)) return fallback;\n return Math.max(min, Math.min(max, Math.round(value)));\n}\nfunction text(value, fallback) {\n if (typeof value !== 'string') return fallback;\n const trimmed = value.trim();\n return trimmed ? trimmed.slice(0, SUBSCRIPTION_WIDGET_TEXT_MAX_LENGTH) : fallback;\n}\nfunction imageUrl(value) {\n const url = safeUrl(typeof value === 'string' ? value : undefined);\n return url && /^(https?:\\/\\/|\\/)/i.test(url) ? url : undefined;\n}\nfunction optionalColor(key, value) {\n const color = typeof value === 'string' ? value.trim().slice(0, SUBSCRIPTION_WIDGET_COLOR_MAX_LENGTH) : '';\n return color ? {\n [key]: color\n } : {};\n}\nfunction normalizeTexts(raw) {\n const defaults = SUBSCRIPTION_WIDGET_DEFAULT_CONFIG.texts;\n const keys = Object.keys(defaults);\n return Object.fromEntries(keys.map(key => [key, text(raw[key], defaults[key])]));\n}\n/**\n * The widget configuration from API-writable json: enums whitelisted, numbers\n * clamped, strings trimmed and capped, urls sanitized, defaults for the rest.\n */\nexport function normalizeSubscriptionWidgetConfig(raw) {\n const defaults = SUBSCRIPTION_WIDGET_DEFAULT_CONFIG;\n const config = record(raw);\n const prompt = record(config.prompt);\n const launcher = record(config.launcher);\n const display = record(config.display);\n const limits = SUBSCRIPTION_WIDGET_LIMITS;\n const layout = oneOf(prompt.layout, SUBSCRIPTION_WIDGET_LAYOUTS, defaults.prompt.layout);\n const positions = SUBSCRIPTION_WIDGET_POSITIONS[layout];\n const trigger = oneOf(display.trigger, SUBSCRIPTION_WIDGET_TRIGGERS, defaults.display.trigger);\n const iconUrl = imageUrl(prompt.iconUrl);\n const launcherImageUrl = imageUrl(launcher.imageUrl);\n const colors = normalizeWebPopupColors({\n colors: config.colors\n });\n const dark = normalizeWebPopupDark({\n dark: config.dark\n }, colors);\n const promptEnabled = prompt.enabled === true;\n const launcherEnabled = launcher.enabled === true;\n return {\n enable: promptEnabled || launcherEnabled,\n prompt: {\n enabled: promptEnabled,\n layout,\n position: oneOf(prompt.position, positions, positions[0]),\n ...(iconUrl ? {\n iconUrl\n } : {}),\n borderRadius: clamped(prompt.borderRadius, limits.borderRadius, defaults.prompt.borderRadius),\n overlay: layout === 'modal' || prompt.overlay === true\n },\n launcher: {\n enabled: launcherEnabled,\n position: oneOf(launcher.position, SUBSCRIPTION_WIDGET_CORNERS, defaults.launcher.position),\n offset: clamped(launcher.offset, limits.offset, defaults.launcher.offset),\n width: clamped(launcher.width, limits.launcherSize, defaults.launcher.width),\n height: clamped(launcher.height, limits.launcherSize, defaults.launcher.height),\n ...(launcherImageUrl ? {\n imageUrl: launcherImageUrl\n } : {}),\n ...optionalColor('background', launcher.background),\n ...optionalColor('iconColor', launcher.iconColor)\n },\n display: {\n trigger,\n delay: clamped(display.delay, limits.delay, defaults.display.delay),\n cappingCount: clamped(display.cappingCount, limits.cappingCount, defaults.display.cappingCount),\n cappingInterval: clamped(display.cappingInterval, limits.cappingInterval, defaults.display.cappingInterval)\n },\n texts: normalizeTexts(record(config.texts)),\n colors,\n ...(dark ? {\n dark\n } : {}),\n fontFamily: text(config.fontFamily, defaults.fontFamily),\n zIndex: clamped(config.zIndex, limits.zIndex, defaults.zIndex)\n };\n}\n/** True when the visitor can still act on the ask: not subscribed and push is supported. */\nexport function subscriptionWidgetActionable(permission) {\n return permission === 'default' || permission === 'denied';\n}\n/** Which prompt a visitor gets for their permission state. */\nexport function subscriptionWidgetPromptVariant(permission) {\n return permission === 'denied' ? 'blocked' : 'ask';\n}\n/** Whether the launcher is on screen. */\nexport function subscriptionWidgetLauncherVisible(config, permission) {\n return config.launcher.enabled && subscriptionWidgetActionable(permission);\n}\n/** What a launcher click does for this visitor. */\nexport function subscriptionWidgetLauncherAction(config, permission) {\n if (config.prompt.enabled) return 'prompt';\n return permission === 'default' ? 'subscribe' : 'none';\n}\n/** Whether the prompt may open by itself now; the host still waits `display.delay` before showing it. */\nexport function subscriptionWidgetCanAutoShow(config, permission, history, nowMs) {\n const {\n trigger,\n cappingCount,\n cappingInterval\n } = config.display;\n if (!config.prompt.enabled || trigger !== 'auto' || permission !== 'default') return false;\n if (cappingCount > 0 && history.shownCount >= cappingCount) return false;\n return history.lastShownAt === null || nowMs - history.lastShownAt >= cappingInterval * HOUR_MS;\n}\n/** The history after one more auto show at `nowMs`. */\nexport function nextSubscriptionWidgetHistory(history, nowMs) {\n return {\n shownCount: history.shownCount + 1,\n lastShownAt: nowMs\n };\n}","import { useEffect, useState } from 'react';\nconst DARK_MEDIA_QUERY = '(prefers-color-scheme: dark)';\nfunction prefersDark() {\n return typeof window !== 'undefined' && typeof window.matchMedia === 'function' && window.matchMedia(DARK_MEDIA_QUERY).matches;\n}\n// 'auto' follows the visitor's OS setting and keeps following it: a popup can\n// be on screen when the theme flips, and a stale palette is the visible half.\nexport function useColorScheme(pref, watch) {\n const [dark, setDark] = useState(() => pref === 'auto' && watch && prefersDark());\n const watchDeps = [pref, watch];\n const [prevWatchDeps, setPrevWatchDeps] = useState(null);\n if (prevWatchDeps === null || watchDeps.some((dep, index) => dep !== prevWatchDeps[index])) {\n setPrevWatchDeps(watchDeps);\n if (pref === 'auto' && watch) {\n setDark(prefersDark());\n }\n }\n useEffect(() => {\n if (pref !== 'auto' || !watch || typeof window === 'undefined' || typeof window.matchMedia !== 'function') {\n return undefined;\n }\n const media = window.matchMedia(DARK_MEDIA_QUERY);\n const onChange = event => setDark(event.matches);\n media.addEventListener('change', onChange);\n return () => media.removeEventListener('change', onChange);\n }, [pref, watch]);\n if (pref !== 'auto') return pref;\n return dark ? 'dark' : 'light';\n}","// Hand-authored 24×24 stroke geometry, inline (no icon package in a script that\n// loads on the customer's site). EXHAUSTIVE: a name without geometry won't compile.\nexport const WEB_POPUP_GLYPH_PATHS = {\n bell: 'M6 10a6 6 0 0 1 12 0c0 4 1.5 5.5 2 6H4c.5-.5 2-2 2-6M10 20a2 2 0 0 0 4 0',\n gift: 'M3 11h18v9a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1zM2.5 7h19v4h-19zM12 7v14' + 'M12 7c-1 0-3-.2-3.5-1a2 2 0 0 1 3.5-1 2 2 0 0 1 3.5 1c-.5.8-2.5 1-3.5 1z',\n cart: 'M2 4h2.2l2.4 11.2A2 2 0 0 0 8.6 17H19M6 7h15l-2.2 7.5H8' + 'M10.5 20a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0M19.5 20a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0',\n chart: 'M3 21h18M7 21V11M12 21V6M17 21v-8',\n lock: 'M5 11h14v10H5zM8 11V8a4 4 0 0 1 8 0v3',\n calendar: 'M4 6h16v15H4zM4 10h16M9 3v4M15 3v4',\n check: 'M4 13l5 5L20 6',\n star: 'M12 3l2.9 5.9 6.5.9-4.7 4.6 1.1 6.5-5.8-3.1-5.8 3.1 1.1-6.5L2.6 9.8l6.5-.9z',\n clock: 'M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0M12 7v5l4 2',\n tag: 'M20.6 13.4l-7.2 7.2a2 2 0 0 1-2.8 0l-7-7A2 2 0 0 1 3 12.2V5a2 2 0 0 1 2-2h7.2a2 2 0 0 1 1.4.6' + 'l7 7a2 2 0 0 1 0 2.8zM9 8a1 1 0 1 1-2 0 1 1 0 0 1 2 0',\n mail: 'M3 6h18v12H3zM3 7l9 6 9-6',\n phone: 'M7 2h10a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1M10 19h4',\n download: 'M12 3v12M7 11l5 5 5-5M4 20h16',\n play: 'M8 5l12 7-12 7z',\n shield: 'M12 3l8 3v6c0 5-3.4 8.6-8 10-4.6-1.4-8-5-8-10V6z',\n sparkle: 'M12 3l1.8 5.2L19 10l-5.2 1.8L12 17l-1.8-5.2L5 10l5.2-1.8z' + 'M18 15l.9 2.1 2.1.9-2.1.9-.9 2.1-.9-2.1L15 18l2.1-.9z',\n percent: 'M19 5L5 19M8.5 8.5a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0M20.5 15.5a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0',\n truck: 'M2 7h12v10H2zM14 10h4l3 3v4h-7' + 'M8.5 19a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0M20 19a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0',\n ticket: 'M4 7h16v4a2 2 0 0 0 0 4v3H4v-3a2 2 0 0 0 0-4zM14 7v12',\n user: 'M20 21a8 8 0 0 0-16 0M16 7a4 4 0 1 1-8 0 4 4 0 0 1 8 0'\n};\n/** The icon names a `glyph` slot may carry — derived, never a second list. */\nexport const WEB_POPUP_GLYPH_NAMES = Object.keys(WEB_POPUP_GLYPH_PATHS);\n/** The sizes a glyph slot may take, px; the first is the normalization default. */\nexport const WEB_POPUP_GLYPH_SIZES = [24, 32, 48];\n/** The thumb a 'thumbs' rating draws; not author-selectable, so not in the whitelist. */\nexport const WEB_POPUP_THUMB_UP_PATH = 'M8 21V10l3.5-7A2 2 0 0 1 14 5v5h4.5a2 2 0 0 1 2 2.4' + 'l-1.3 6A2 2 0 0 1 17.2 21zM8 10H3.5v11H8';","import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from \"react/jsx-runtime\";\nimport { SUBSCRIPTION_WIDGET_KEYFRAMES } from './constants';\nimport { subscriptionWidgetLauncherVisible, subscriptionWidgetPromptVariant } from './helpers';\nimport { useColorScheme } from '../web-popups/colorScheme';\nimport { webPopupButtonPillStyle } from '../web-popups/constants';\nimport { WEB_POPUP_GLYPH_PATHS } from '../web-popups/glyphs';\nimport { resolveWebPopupColors, webPopupDarkEnabled } from '../web-popups/palette';\nconst CARD_WIDTH = 360;\nconst MODAL_WIDTH = 420;\nconst EDGE_GAP = 16;\nconst BOX_SHADOW = '0 12px 32px rgba(16, 24, 40, 0.18)';\nconst BELL_SLASH_PATH = 'M4 4l16 16';\nfunction cornerStyle(corner, offset) {\n const [v, h] = corner.split('-');\n return {\n [v]: offset,\n [h]: offset\n };\n}\nfunction enterAnimation(fromTop, animate) {\n return animate ? `${fromTop ? 'pw-subw-drop' : 'pw-subw-rise'} 0.3s ease-out backwards` : undefined;\n}\nfunction promptFrameStyle(config, position, animate) {\n const {\n layout,\n position: at\n } = config.prompt;\n const base = {\n position,\n zIndex: config.zIndex,\n boxSizing: 'border-box',\n pointerEvents: 'auto'\n };\n if (layout === 'bar') {\n return {\n ...base,\n left: 0,\n right: 0,\n [at]: 0,\n animation: enterAnimation(at === 'top', animate)\n };\n }\n if (layout === 'modal') {\n return {\n ...base,\n top: '50%',\n left: '50%',\n width: `min(${MODAL_WIDTH}px, calc(100% - ${EDGE_GAP * 2}px))`,\n transform: 'translate(-50%, -50%)',\n animation: animate ? 'pw-subw-fade 0.25s ease-out backwards' : undefined\n };\n }\n const width = `min(${CARD_WIDTH}px, calc(100% - ${EDGE_GAP * 2}px))`;\n const animation = enterAnimation(at.startsWith('top'), animate);\n if (at === 'top' || at === 'bottom') {\n return {\n ...base,\n [at]: EDGE_GAP,\n left: '50%',\n width,\n transform: 'translateX(-50%)',\n animation\n };\n }\n return {\n ...base,\n ...cornerStyle(at, EDGE_GAP),\n width,\n animation\n };\n}\nfunction Button({\n label,\n primary,\n colors,\n disabled,\n onClick\n}) {\n return _jsx(\"button\", {\n type: \"button\",\n disabled: disabled,\n onClick: onClick,\n style: {\n ...webPopupButtonPillStyle(primary ? 'primary' : 'secondary', colors),\n display: 'inline-block',\n width: 'auto',\n padding: '8px 18px',\n whiteSpace: 'nowrap',\n opacity: disabled ? 0.6 : 1,\n cursor: disabled ? 'default' : 'pointer'\n },\n children: label\n });\n}\n/** The prompt box without placement, for CP forms that show it beside their fields. */\nexport function SubscriptionPromptBox({\n config,\n variant,\n colors,\n busy,\n onAccept,\n onDecline\n}) {\n const {\n prompt,\n texts\n } = config;\n const bar = prompt.layout === 'bar';\n const blocked = variant === 'blocked';\n return _jsxs(\"div\", {\n role: \"dialog\",\n \"aria-label\": blocked ? texts.blockedTitle : texts.title,\n style: {\n display: 'flex',\n flexDirection: bar ? 'row' : 'column',\n alignItems: bar ? 'center' : 'stretch',\n flexWrap: bar ? 'wrap' : 'nowrap',\n gap: 16,\n padding: bar ? '12px 20px' : 20,\n boxSizing: 'border-box',\n width: '100%',\n borderRadius: bar ? 0 : prompt.borderRadius,\n boxShadow: BOX_SHADOW,\n backgroundColor: colors.background,\n color: colors.text,\n fontFamily: config.fontFamily,\n colorScheme: colors.scheme\n },\n children: [_jsxs(\"div\", {\n style: {\n display: 'flex',\n alignItems: 'flex-start',\n gap: 12,\n flex: bar ? '1 1 240px' : undefined\n },\n children: [prompt.iconUrl && _jsx(\"img\", {\n src: prompt.iconUrl,\n alt: \"\",\n width: 48,\n height: 48,\n style: {\n flex: 'none',\n borderRadius: 8,\n objectFit: 'cover'\n }\n }), _jsxs(\"div\", {\n style: {\n display: 'flex',\n flexDirection: 'column',\n gap: 4,\n minWidth: 0\n },\n children: [_jsx(\"div\", {\n style: {\n fontSize: 16,\n fontWeight: 600,\n lineHeight: 1.4\n },\n children: blocked ? texts.blockedTitle : texts.title\n }), _jsx(\"div\", {\n style: {\n fontSize: 14,\n lineHeight: 1.5,\n color: colors.textSecondary\n },\n children: blocked ? texts.blockedMessage : texts.message\n })]\n })]\n }), _jsx(\"div\", {\n style: {\n display: 'flex',\n justifyContent: 'flex-end',\n gap: 8,\n flex: 'none'\n },\n children: blocked ? _jsx(Button, {\n label: texts.closeText,\n primary: true,\n colors: colors,\n onClick: onDecline\n }) : _jsxs(_Fragment, {\n children: [_jsx(Button, {\n label: texts.declineText,\n primary: false,\n colors: colors,\n onClick: onDecline\n }), _jsx(Button, {\n label: texts.acceptText,\n primary: true,\n colors: colors,\n disabled: busy,\n onClick: onAccept\n })]\n })\n })]\n });\n}\n/** The launcher without placement: the authored picture, or the round bell button. */\nexport function SubscriptionLauncherButton({\n config,\n blocked,\n colors,\n onClick\n}) {\n const {\n width,\n height,\n imageUrl\n } = config.launcher;\n const label = blocked ? config.texts.launcherBlockedLabel : config.texts.launcherLabel;\n const iconSize = Math.round(Math.min(width, height) / 2);\n const base = {\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n width,\n height,\n padding: 0,\n border: 'none',\n cursor: 'pointer',\n opacity: blocked ? 0.7 : 1\n };\n if (imageUrl) {\n return _jsx(\"button\", {\n type: \"button\",\n \"aria-label\": label,\n title: label,\n onClick: onClick,\n style: {\n ...base,\n background: 'none'\n },\n children: _jsx(\"img\", {\n src: imageUrl,\n alt: \"\",\n width: width,\n height: height,\n style: {\n display: 'block',\n objectFit: 'contain'\n }\n })\n });\n }\n return _jsx(\"button\", {\n type: \"button\",\n \"aria-label\": label,\n title: label,\n onClick: onClick,\n style: {\n ...base,\n borderRadius: '50%',\n backgroundColor: config.launcher.background ?? colors.accent,\n color: config.launcher.iconColor ?? colors.onAccent,\n boxShadow: BOX_SHADOW\n },\n children: _jsxs(\"svg\", {\n width: iconSize,\n height: iconSize,\n viewBox: \"0 0 24 24\",\n fill: \"none\",\n stroke: \"currentColor\",\n strokeWidth: 2,\n strokeLinecap: \"round\",\n strokeLinejoin: \"round\",\n \"aria-hidden\": \"true\",\n children: [_jsx(\"path\", {\n d: WEB_POPUP_GLYPH_PATHS.bell\n }), blocked && _jsx(\"path\", {\n d: BELL_SLASH_PATH\n })]\n })\n });\n}\n/**\n * The prompt while `open` and the launcher, each only when switched on; 'live' pins them to the viewport,\n * 'preview' to the nearest positioned parent with no enter animation. The host owns `open` and every side effect.\n */\nexport function SubscriptionWidgetReader({\n config,\n permission,\n open,\n mode = 'live',\n colorScheme = 'auto',\n busy,\n onAccept,\n onDecline,\n onLauncherClick\n}) {\n const scheme = useColorScheme(colorScheme, webPopupDarkEnabled(config));\n const colors = resolveWebPopupColors(config, scheme);\n const live = mode === 'live';\n const position = live ? 'fixed' : 'absolute';\n const prompt = open && config.prompt.enabled;\n const launcher = subscriptionWidgetLauncherVisible(config, permission);\n if (!prompt && !launcher) return null;\n return _jsxs(_Fragment, {\n children: [live && _jsx(\"style\", {\n children: SUBSCRIPTION_WIDGET_KEYFRAMES\n }), prompt && config.prompt.overlay && _jsx(\"div\", {\n style: {\n position,\n inset: 0,\n zIndex: config.zIndex,\n backgroundColor: 'rgba(16, 24, 40, 0.5)',\n animation: live ? 'pw-subw-fade 0.2s ease-out backwards' : undefined,\n pointerEvents: 'auto'\n },\n onClick: onDecline\n }), prompt && _jsx(\"div\", {\n style: promptFrameStyle(config, position, live),\n children: _jsx(SubscriptionPromptBox, {\n config: config,\n variant: subscriptionWidgetPromptVariant(permission),\n colors: colors,\n busy: busy,\n onAccept: onAccept,\n onDecline: onDecline\n })\n }), launcher && _jsx(\"div\", {\n style: {\n position,\n zIndex: config.zIndex,\n pointerEvents: 'auto',\n ...cornerStyle(config.launcher.position, config.launcher.offset)\n },\n children: _jsx(SubscriptionLauncherButton, {\n config: config,\n blocked: permission === 'denied',\n colors: colors,\n onClick: onLauncherClick\n })\n })]\n });\n}","import { render } from 'preact';\n\nimport {\n SubscriptionWidgetReader, type SubscriptionWidgetReaderProps,\n} from '@pushwoosh/websdk-common/subscription-widget';\n\nexport const renderSubscriptionWidget = (container: HTMLElement, props: SubscriptionWidgetReaderProps): void => {\n render(<SubscriptionWidgetReader {...props} mode=\"live\" />, container);\n};\n\nexport const unmountSubscriptionWidget = (container: HTMLElement): void => {\n render(null, container);\n};\n","import { type TInboxMessagesStoreName, type TKeyValueStoreName, type TMainLogStoreName, type TMessageLogStoreName } from '../Storage.types';\n\nexport const STORE_NAME_KEY_VALUE: TKeyValueStoreName = 'keyValue';\nexport const STORE_NAME_MESSAGE_LOG: TMessageLogStoreName = 'messages';\nexport const STORE_NAME_MAIN_LOG: TMainLogStoreName = 'log';\nexport const STORE_NAME_INBOX_MESSAGES: TInboxMessagesStoreName = 'inboxMessages';\n\nexport const KEY_PATH_BASE_INCREMENT = 'id';\n","import { type TMigrationType, type TSdkStoreName } from '../Storage.types';\n\n/**\n * Check existed store, before create\n * @param name\n * @param storeCreator\n */\nexport function storeCreatorDecorator(name: TSdkStoreName, storeCreator: TMigrationType): TMigrationType {\n return function (database: IDBDatabase) {\n if (database.objectStoreNames.contains(name)) {\n return;\n }\n\n storeCreator(database);\n };\n}\n","import {\n STORE_NAME_INBOX_MESSAGES,\n STORE_NAME_KEY_VALUE,\n STORE_NAME_MAIN_LOG,\n STORE_NAME_MESSAGE_LOG,\n KEY_PATH_BASE_INCREMENT,\n} from './constants';\nimport { storeCreatorDecorator } from './helpers';\nimport {\n type TInboxMessagesIDBKeyPath,\n type TInboxMessagesIDBRemovalTimeIndex,\n type TInboxMessagesIDBStatusIndex,\n} from '../../../models/InboxMessages.types';\n\n/**\n * Create keyValue store migration\n * @param database\n */\nfunction createKeyValueStore(database: IDBDatabase) {\n database.createObjectStore(STORE_NAME_KEY_VALUE, { keyPath: 'key' });\n}\n\n/**\n * Create log store migration\n * @param database\n */\nfunction createLogStore(database: IDBDatabase) {\n const logStore = database.createObjectStore(\n STORE_NAME_MAIN_LOG,\n { keyPath: KEY_PATH_BASE_INCREMENT, autoIncrement: true },\n );\n logStore.createIndex('environment', 'environment', { unique: false });\n logStore.createIndex('date', 'date', { unique: false });\n logStore.createIndex('type', 'type', { unique: false });\n}\n\n/**\n * Create message log store migration\n * @param database\n */\nfunction createMessageLogStore(database: IDBDatabase) {\n const messagesStore = database.createObjectStore(\n STORE_NAME_MESSAGE_LOG,\n { keyPath: KEY_PATH_BASE_INCREMENT, autoIncrement: true },\n );\n messagesStore.createIndex('date', 'date', { unique: false });\n}\n\n/**\n * Create inbox messages store migration\n * @param database\n */\nfunction createInboxMessagesStore(database: IDBDatabase) {\n const keyPath: TInboxMessagesIDBKeyPath = 'inbox_id';\n const statusIndex: TInboxMessagesIDBStatusIndex = 'status';\n const removalTimeIndex: TInboxMessagesIDBRemovalTimeIndex = 'rt';\n\n const store = database.createObjectStore(STORE_NAME_INBOX_MESSAGES,\n { keyPath, autoIncrement: false },\n );\n store.createIndex(statusIndex, statusIndex, { unique: false, multiEntry: true });\n store.createIndex(removalTimeIndex, removalTimeIndex, { unique: false, multiEntry: true });\n}\n\nexport default [\n storeCreatorDecorator(STORE_NAME_KEY_VALUE, createKeyValueStore),\n storeCreatorDecorator(STORE_NAME_MAIN_LOG, createLogStore),\n storeCreatorDecorator(STORE_NAME_MESSAGE_LOG, createMessageLogStore),\n storeCreatorDecorator(STORE_NAME_INBOX_MESSAGES, createInboxMessagesStore),\n];\n","import { default as migrationsInitial } from './initial';\nimport { type TMigrationType } from '../Storage.types';\n\nexport default class Migrations {\n get all(): Array<TMigrationType> {\n return migrationsInitial;\n }\n}\n","import Migrations from './Migrations';\nimport { type TMigrationType } from '../Storage.types';\n\nexport default class MigrationExecutor {\n db: IDBDatabase;\n migrationsBuilder: Migrations;\n\n constructor(\n db: IDBDatabase,\n migrationsBuilder: Migrations = new Migrations(),\n ) {\n this.db = db;\n this.migrationsBuilder = migrationsBuilder;\n }\n\n applyMigrations() {\n this.applyMigrationsPack(this.migrationsBuilder.all);\n }\n\n applyMigrationsPack(migrationsPack: Array<TMigrationType>) {\n migrationsPack.forEach((migration) => {\n migration(this.db);\n });\n }\n}\n","import {\n STORE_NAME_KEY_VALUE,\n STORE_NAME_MAIN_LOG,\n STORE_NAME_MESSAGE_LOG,\n} from '../modules/storage/migrations/constants';\nimport MigrationExecutor from '../modules/storage/migrations/MigrationExecutor';\nimport { type IIDBOpenEventTargetWithResult } from '../modules/storage/Storage.types';\nimport version from '../modules/storage/version';\n\ndeclare const self: ServiceWorkerGlobalScope;\n\nfunction onversionchange(database: IDBDatabase, event: Event) {\n console.info('onversionchange', event);\n database.close();\n}\n\nlet databasePromise: Promise<IDBDatabase>;\nexport function getInstance(): Promise<IDBDatabase> {\n if (!databasePromise) {\n databasePromise = new Promise<IDBDatabase>((resolve, reject) => {\n const request: IDBOpenDBRequest = indexedDB.open('PUSHWOOSH_SDK_STORE', version);\n request.onsuccess = (event) => {\n const database: IDBDatabase = (event.target as IIDBOpenEventTargetWithResult).result;\n database.onversionchange = onversionchange.bind(null, database, reject);\n resolve(database);\n };\n\n request.onerror = () => reject(request.error);\n\n request.onupgradeneeded = (event) => {\n const database: IDBDatabase = (event.target as IIDBOpenEventTargetWithResult).result;\n database.onversionchange = onversionchange.bind(null, database, reject);\n\n const migrationExecutor = new MigrationExecutor(database);\n migrationExecutor.applyMigrations();\n };\n });\n }\n return databasePromise;\n}\n\nfunction getInstanceWithPromise(executor: any): any {\n return getInstance().then((database) => (\n new Promise((resolve, reject) => executor(database, resolve, reject))\n ));\n}\n\nfunction createKeyValue(name: string) {\n return {\n get<K extends string, D>(key: K, defaultValue?: D) {\n return getInstanceWithPromise((database: IDBDatabase, resolve: any, reject: any) => {\n const request = database.transaction(name).objectStore(name).get(key);\n\n /** @TODO\n * we cant invoke \"resolve\" or \"reject\" in onsuccess or onerror because\n * it leads to bugs in Safari when we try to get permissions for notifications\n *\n * Checking status of request in setTimeout fixes this bug\n */\n let isComplete = false;\n let isError = false;\n let timeout: any;\n\n const check = () => {\n clearTimeout(timeout);\n if (isComplete) {\n resolve(request.result?.value || defaultValue);\n } else if (isError) {\n reject(request.error);\n } else {\n timeout = setTimeout(check, 0);\n }\n };\n\n request.onsuccess = () => isComplete = true;\n request.onerror = () => isError = true;\n check();\n });\n },\n\n getAll() {\n return getInstanceWithPromise((database: IDBDatabase, resolve: any, reject: any) => {\n const result: { [key: string]: any } = {};\n const cursor = database.transaction(name).objectStore(name).openCursor();\n let isComplete = false;\n let isError = false;\n let timeout: any;\n\n /** @TODO\n * we cant invoke \"resolve\" or \"reject\" in onsuccess or onerror because\n * it leads to bugs in Safari when we try to get permissions for notifications\n *\n * Checking status of request in setTimeout fixes this bug\n */\n const check = () => {\n clearTimeout(timeout);\n if (isComplete) {\n resolve(result);\n } else if (isError) {\n reject(cursor.error);\n } else {\n timeout = setTimeout(check, 0);\n }\n };\n\n cursor.onsuccess = (event) => {\n const cursorResult = (event.target as any).result;\n if (cursorResult) {\n result[cursorResult.key] = cursorResult.value.value;\n cursorResult.continue();\n } else {\n isComplete = true;\n }\n };\n cursor.onerror = () => isError = true;\n check();\n });\n },\n\n async extend(key: string, value: any) {\n const oldValues = await this.get(key);\n const { ...newValues } = value;\n await this.set(key, { ...oldValues, ...newValues });\n },\n\n set<K, D>(key: K, value: D) {\n return getInstanceWithPromise((database: IDBDatabase, resolve: any, reject: any) => {\n const request = database.transaction([name], 'readwrite').objectStore(name).put({ key, value });\n let isComplete = false;\n let isError = false;\n let timeout: any;\n\n /** @TODO\n * we cant invoke \"resolve\" or \"reject\" in onsuccess or onerror because\n * it leads to bugs in Safari when we try to get permissions for notifications\n *\n * Checking status of request in setTimeout fixes this bug\n */\n const check = () => {\n clearTimeout(timeout);\n if (isComplete) {\n resolve(key);\n } else if (isError) {\n reject(request.error);\n } else {\n timeout = setTimeout(check, 0);\n }\n };\n\n request.onsuccess = () => isComplete = true;\n request.onerror = () => isError = true;\n check();\n });\n },\n };\n}\n\nexport abstract class LogBase {\n protected abstract name: string;\n protected abstract maxItems: number;\n _add(obj: any) {\n return getInstanceWithPromise((database: IDBDatabase, resolve: any, reject: any) => {\n const request = database.transaction([this.name], 'readwrite').objectStore(this.name).add(obj);\n request.onsuccess = () => {\n resolve(obj);\n };\n request.onerror = () => {\n reject(request.error);\n };\n }).then((obj: any) => {\n return this.getAll().then((items: { id: number }[]) => {\n if (Array.isArray(items)) {\n const ids = items.map((i) => i.id).sort((a, b) => {\n if (a == b) return 0;\n return a < b ? 1 : -1;\n });\n if (ids.length > this.maxItems) {\n return Promise.all(ids.slice(this.maxItems).map((id) => this.delete(id))).then(() => obj);\n }\n }\n return obj;\n });\n });\n }\n\n delete(key: any) {\n return getInstanceWithPromise((database: IDBDatabase, resolve: any, reject: any) => {\n const request = database.transaction([this.name], 'readwrite').objectStore(this.name).delete(key);\n request.onsuccess = () => {\n resolve(request.result);\n };\n request.onerror = () => {\n reject(request.error);\n };\n });\n }\n\n getAll() {\n return getInstanceWithPromise((database: IDBDatabase, resolve: any, reject: any) => {\n const result: any[] = [];\n const cursor = database.transaction(this.name).objectStore(this.name).openCursor();\n cursor.onsuccess = (ev) => {\n const cursorResult = (ev.target as any).result;\n if (cursorResult) {\n if (cursorResult.value) {\n result.push(cursorResult.value);\n }\n cursorResult.continue();\n } else {\n resolve(result);\n }\n };\n cursor.onerror = () => {\n reject(cursor.error);\n };\n });\n }\n}\n\nexport class LogLog extends LogBase {\n protected name = STORE_NAME_MAIN_LOG;\n protected maxItems = 100;\n protected environment = (typeof self !== 'undefined' && self.registration) ? 'worker' : 'browser';\n add(type: string, message: any, additional?: any) {\n const obj: any = {\n type,\n environment: this.environment,\n message: `${message}`,\n date: new Date(),\n };\n if (message instanceof Error) {\n obj.stack = message.stack;\n }\n if (additional) {\n obj.additional = additional;\n }\n return this._add(obj);\n }\n}\n\nexport class LogMessage extends LogBase {\n protected name = STORE_NAME_MESSAGE_LOG;\n protected maxItems = 25;\n add(log: any) {\n return this._add({\n ...log,\n date: new Date(),\n });\n }\n}\n\nexport const keyValue = createKeyValue(STORE_NAME_KEY_VALUE);\nexport const log = new LogLog();\nexport const message = new LogMessage();\n","import { log as logStorage } from './storage';\n\nconst levels: { [key: string]: number } = {\n error: 1,\n info: 2,\n debug: 3,\n};\n\nlet limitLevel = 3;\n\ntype TWriteType = 'error' | 'apirequest' | 'info';\n\ninterface ILogger {\n setLevel(level: string): void;\n error(...args: any[]): void;\n info(...args: any[]): void;\n debug(...args: any[]): void;\n write(type: TWriteType, message: any, additional?: any): Promise<void>;\n isManualLevel(): boolean;\n [key: string]: any;\n}\n\nconst Logger: ILogger = {\n setLevel(level) {\n if (!levels[level]) {\n level = 'error';\n }\n limitLevel = levels[level];\n },\n write(type: TWriteType, message: any, additional?: any) {\n if (type === 'error') {\n this.error(message);\n } else {\n this.info(message);\n }\n return logStorage.add(type, message, additional);\n },\n} as ILogger;\n\nObject.keys(levels).forEach((levelName: string) => {\n const levelNumber = levels[levelName];\n Logger[levelName] = (...args: any[]) => {\n if (levelNumber <= limitLevel) {\n console.groupCollapsed(levelName);\n console.info('', ...args);\n console.trace('trace');\n console.groupEnd();\n }\n };\n});\n\nexport function logAndThrowError(error: string) {\n const logText = new Error(error);\n Logger.write('error', logText, 'logAndThrowError');\n throw logText;\n}\n\nexport function logAndRejectError(error: string, reject: (e: any) => void) {\n const logText = new Error(error);\n Logger.write('error', logText, 'logAndRejectError');\n reject(logText);\n}\n\nexport { Logger };\n","import {\n nextSubscriptionWidgetHistory, normalizeSubscriptionWidgetConfig, subscriptionWidgetActionable,\n subscriptionWidgetCanAutoShow, subscriptionWidgetLauncherAction, subscriptionWidgetLauncherVisible,\n type SubscriptionWidgetConfig, type SubscriptionWidgetPermission,\n} from '@pushwoosh/websdk-common/subscription-widget';\n\nimport { renderSubscriptionWidget, unmountSubscriptionWidget } from './renderer';\nimport { type ISubscriptionWidgetPublicApi } from './types';\nimport * as CONSTANTS from '../../core/constants';\nimport { Logger } from '../../core/logger';\nimport { type Pushwoosh } from '../../core/Pushwoosh';\n\nconst LOG_PREFIX = 'Pushwoosh subscription widget:';\nconst HOST_ID = 'pushwoosh-subscription-widget';\n\n/** The unified subscription widget: launcher bell + prompt, configured by `subscriptionWidget`. */\nexport class PWSubscriptionWidget implements ISubscriptionWidgetPublicApi {\n private readonly pw: Pushwoosh;\n private readonly config: SubscriptionWidgetConfig;\n private permission: SubscriptionWidgetPermission = 'unsupported';\n private open = false;\n private busy = false;\n private container: HTMLElement | null = null;\n private autoShowTimer: ReturnType<typeof setTimeout> | null = null;\n\n constructor(pw: Pushwoosh) {\n this.pw = pw;\n this.config = normalizeSubscriptionWidgetConfig(pw.initParams.subscriptionWidget);\n this.accept = this.accept.bind(this);\n this.decline = this.decline.bind(this);\n this.toggle = this.toggle.bind(this);\n this.launcherClick = this.launcherClick.bind(this);\n pw.moduleRegistry.subscriptionWidget = this;\n }\n\n public async run(): Promise<void> {\n const { pw, config } = this;\n\n if (!config.enable || !pw.isPushAvailable()) {\n return;\n }\n\n this.permission = await this.readPermission();\n this.mount();\n this.listenSubscriptionChanges();\n await this.scheduleAutoShow();\n }\n\n public show(): void {\n if (!this.container || !this.config.prompt.enabled || !subscriptionWidgetActionable(this.permission) || this.open) {\n return;\n }\n\n this.open = true;\n this.render();\n this.pw.dispatchEvent('show-subscription-widget', {});\n }\n\n public hide(): void {\n if (!this.open) {\n return;\n }\n\n this.open = false;\n this.busy = false;\n this.render();\n this.pw.dispatchEvent('hide-subscription-widget', {});\n }\n\n public toggle(isShown?: boolean): void {\n const shouldShow = isShown ?? !this.open;\n\n if (shouldShow) {\n this.show();\n } else {\n this.hide();\n }\n }\n\n public isVisible(): boolean {\n return this.open;\n }\n\n private async readPermission(): Promise<SubscriptionWidgetPermission> {\n const permission = this.pw.driver?.getPermission();\n\n if (permission === CONSTANTS.PERMISSION_DENIED) {\n return 'denied';\n }\n\n return await this.pw.isSubscribed() ? 'granted' : 'default';\n }\n\n private mount(): void {\n const host = document.createElement('div');\n host.id = HOST_ID;\n host.style.position = 'fixed';\n host.style.inset = '0';\n host.style.zIndex = String(this.config.zIndex);\n host.style.pointerEvents = 'none';\n document.body.appendChild(host);\n\n this.container = document.createElement('div');\n host.attachShadow({ mode: 'open' }).appendChild(this.container);\n this.render();\n }\n\n private render(): void {\n if (!this.container) {\n return;\n }\n\n if (!this.open && !subscriptionWidgetLauncherVisible(this.config, this.permission)) {\n unmountSubscriptionWidget(this.container);\n\n return;\n }\n\n renderSubscriptionWidget(this.container, {\n config: this.config,\n permission: this.permission,\n open: this.open,\n busy: this.busy,\n onAccept: this.accept,\n onDecline: this.decline,\n onLauncherClick: this.launcherClick,\n });\n }\n\n private async scheduleAutoShow(): Promise<void> {\n const history = await this.pw.data.getSubscriptionWidgetHistory();\n\n if (!subscriptionWidgetCanAutoShow(this.config, this.permission, history, Date.now())) {\n return;\n }\n\n this.autoShowTimer = setTimeout(async () => {\n this.autoShowTimer = null;\n\n if (this.open || this.permission !== 'default') {\n return;\n }\n\n this.show();\n await this.pw.data.setSubscriptionWidgetHistory(nextSubscriptionWidgetHistory(history, Date.now()));\n }, this.config.display.delay * 1000);\n }\n\n private launcherClick(): void {\n const action = subscriptionWidgetLauncherAction(this.config, this.permission);\n\n if (action === 'prompt') {\n this.toggle();\n } else if (action === 'subscribe') {\n this.subscribeFromLauncher();\n }\n }\n\n // Without a prompt the bell asks the browser itself; synchronous up to pw.subscribe() for Firefox.\n private async subscribeFromLauncher(): Promise<void> {\n try {\n await this.pw.subscribe();\n } catch (error) {\n Logger.error(error, `${LOG_PREFIX} failed to subscribe`);\n }\n\n this.permission = await this.readPermission();\n this.render();\n }\n\n // Kept synchronous up to pw.subscribe(): Firefox only honours a permission request inside the click's own task.\n private async accept(): Promise<void> {\n this.busy = true;\n this.render();\n\n try {\n await this.pw.subscribe();\n } catch (error) {\n Logger.error(error, `${LOG_PREFIX} failed to subscribe`);\n }\n\n this.permission = await this.readPermission();\n\n if (this.permission === 'denied') {\n this.busy = false;\n this.render();\n\n return;\n }\n\n this.hide();\n }\n\n private decline(): void {\n this.hide();\n }\n\n private listenSubscriptionChanges(): void {\n const update = async () => {\n this.permission = await this.readPermission();\n\n if (this.permission === 'granted') {\n this.cancelAutoShow();\n this.hide();\n }\n\n this.render();\n };\n\n this.pw.addSdkEventHandler('subscribe', update);\n this.pw.addSdkEventHandler('unsubscribe', update);\n this.pw.addSdkEventHandler('permission-denied', update);\n }\n\n private cancelAutoShow(): void {\n if (this.autoShowTimer !== null) {\n clearTimeout(this.autoShowTimer);\n this.autoShowTimer = null;\n }\n }\n}\n"],"names":["root","factory","exports","module","require","define","amd","a","i","this","__WEBPACK_EXTERNAL_MODULE__524__","__WEBPACK_EXTERNAL_MODULE__873__","__WEBPACK_EXTERNAL_MODULE__247__","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","d","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","r","Symbol","toStringTag","value","SAFE_URL_PROTOCOL","WEB_POPUP_TEXT_COLOR","WEB_POPUP_TEXT_SECONDARY_COLOR","WEB_POPUP_ON_ACCENT_COLOR","WEB_POPUP_DEFAULT_COLORS","background","accent","text","textSecondary","textInverse","webPopupButtonPillStyle","variant","colors","display","boxSizing","width","padding","borderRadius","fontSize","fontWeight","fontFamily","lineHeight","textAlign","textDecoration","cursor","backgroundColor","surface","color","border","onAccent","SUBSCRIPTION_WIDGET_POSITIONS","card","bar","modal","SUBSCRIPTION_WIDGET_LAYOUTS","keys","SUBSCRIPTION_WIDGET_CORNERS","SUBSCRIPTION_WIDGET_TRIGGERS","SUBSCRIPTION_WIDGET_LIMITS","delay","cappingCount","cappingInterval","offset","launcherSize","zIndex","SUBSCRIPTION_WIDGET_DEFAULT_CONFIG","enable","prompt","enabled","layout","position","overlay","launcher","height","trigger","texts","title","message","acceptText","declineText","closeText","blockedTitle","blockedMessage","launcherLabel","launcherBlockedLabel","HEX_RE","parseHex","hex","exec","trim","full","length","split","map","c","join","parseInt","slice","toHex","g","b","v","Math","max","min","round","toString","padStart","hueToChannel","p","q","t","tn","foldLightness","l","liftLightness","webPopupShiftColor","direction","rgb","h","s","rn","gn","bn","rgbToHsl","hslToRgb","webPopupMixColor","base","over","ratio","isLightColor","autoDarkWebPopupColors","light","derivedColors","scheme","surfaceText","error","chromeIcon","webPopupDarkEnabled","chrome","dark","webPopupEffectiveScheme","resolveWebPopupColors","effective","safeUrl","url","trimmed","startsWith","test","Set","colorString","normalizeWebPopupColors","params","normalizeWebPopupDark","raw","authored","auto","opacity","Number","isFinite","normalizeOverlay","boxShadow","record","Array","isArray","oneOf","allowed","fallback","includes","clamped","helpers_text","imageUrl","optionalColor","normalizeTexts","defaults","fromEntries","subscriptionWidgetActionable","permission","subscriptionWidgetPromptVariant","subscriptionWidgetLauncherVisible","config","DARK_MEDIA_QUERY","prefersDark","window","matchMedia","matches","WEB_POPUP_GLYPH_PATHS","bell","gift","cart","chart","lock","calendar","check","star","clock","tag","mail","phone","download","play","shield","sparkle","percent","truck","ticket","user","BOX_SHADOW","cornerStyle","corner","enterAnimation","fromTop","animate","promptFrameStyle","at","pointerEvents","left","right","animation","top","transform","Button","label","primary","disabled","onClick","jsx_runtime_root_jsxRuntime_","jsx","type","style","whiteSpace","children","SubscriptionPromptBox","busy","onAccept","onDecline","blocked","jsxs","role","flexDirection","alignItems","flexWrap","gap","colorScheme","flex","iconUrl","src","alt","objectFit","minWidth","justifyContent","Fragment","SubscriptionLauncherButton","iconSize","iconColor","viewBox","fill","stroke","strokeWidth","strokeLinecap","strokeLinejoin","SubscriptionWidgetReader","open","mode","onLauncherClick","pref","watch","setDark","compat_root_preactCompat_","useState","watchDeps","prevWatchDeps","setPrevWatchDeps","some","dep","index","useEffect","media","onChange","event","addEventListener","removeEventListener","useColorScheme","live","inset","STORE_NAME_KEY_VALUE","STORE_NAME_MESSAGE_LOG","STORE_NAME_INBOX_MESSAGES","storeCreatorDecorator","name","storeCreator","database","objectStoreNames","contains","initial","createObjectStore","keyPath","logStore","autoIncrement","createIndex","unique","statusIndex","store","multiEntry","Migrations","all","MigrationExecutor","constructor","db","migrationsBuilder","applyMigrations","applyMigrationsPack","migrationsPack","forEach","migration","onversionchange","console","info","close","databasePromise","getInstanceWithPromise","executor","Promise","resolve","reject","request","indexedDB","onsuccess","target","result","bind","onerror","onupgradeneeded","then","LogBase","_add","transaction","objectStore","add","getAll","items","ids","id","sort","maxItems","delete","openCursor","ev","cursorResult","push","continue","log","environment","self","registration","additional","date","Date","Error","stack","levels","debug","limitLevel","Logger","setLevel","level","write","levelName","levelNumber","args","groupCollapsed","trace","groupEnd","LOG_PREFIX","PWSubscriptionWidget","pw","container","autoShowTimer","limits","positions","launcherImageUrl","promptEnabled","launcherEnabled","normalizeSubscriptionWidgetConfig","initParams","subscriptionWidget","accept","decline","toggle","launcherClick","moduleRegistry","run","isPushAvailable","readPermission","mount","listenSubscriptionChanges","scheduleAutoShow","show","render","dispatchEvent","hide","isShown","isVisible","driver","getPermission","isSubscribed","host","document","createElement","String","body","appendChild","attachShadow","props","external_commonjs_preact_commonjs2_preact_amd_preact_root_preact_","renderSubscriptionWidget","history","data","getSubscriptionWidgetHistory","nowMs","shownCount","lastShownAt","subscriptionWidgetCanAutoShow","now","setTimeout","async","setSubscriptionWidgetHistory","nextSubscriptionWidgetHistory","action","subscribeFromLauncher","subscribe","update","cancelAutoShow","addSdkEventHandler","clearTimeout"],"sourceRoot":""}
|