web-push-notifications 3.90.1 → 3.91.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var o in n)("object"==typeof exports?exports:e)[o]=n[o]}}(this,()=>(()=>{"use strict";const e={d:(t,n)=>{for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}};let t={};e.r(t),e.d(t,{WebPopupsWidget:()=>ni});const n=/^(https?:|mailto:|tel:)/i,o="#101828",i="#667085",r="#FFFFFF",s="#FFFFFF",a="#2970FF",l=o,c=i,u="#FFFFFF",d={h1:{fontSize:24,fontWeight:600,lineHeight:1.25},h2:{fontSize:18,fontWeight:600,lineHeight:1.3},h3:{fontSize:16,fontWeight:600,lineHeight:1.35},body:{fontSize:14,fontWeight:"normal",lineHeight:1.5},caption:{fontSize:12,fontWeight:"normal",lineHeight:1.4},eyebrow:{fontSize:11,fontWeight:600,letterSpacing:"0.08em",lineHeight:1.4},icon:{fontSize:24,lineHeight:1.2}},p={h1:1,h2:1,h3:1,icon:1,eyebrow:.8,body:.9,caption:.75};function f(e,t,n){return n?function(e,t){if(t>=1)return e;const n=/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.exec(e)?.[1];if(!n)return e;const o=3===n.length?n.split("").map(e=>e+e).join(""):n,[i,r,s]=[0,2,4].map(e=>parseInt(o.slice(e,e+2),16));return`rgba(${i}, ${r}, ${s}, ${t})`}(t.textInverse,p[e]??1):"icon"!==e?"caption"===e||"eyebrow"===e?t.textSecondary:t.text:void 0}const h=["h1","h2","h3","icon"];function _(e){return"glyph"===e.type?"heading":"text"!==e.type?"action":h.includes(e.variant)?"heading":"text"}const m="8px 0 4px";function y(e,t){return{display:"block",boxSizing:"border-box",width:"100%",padding:"10px 25px",borderRadius:6,fontSize:14,fontWeight:600,fontFamily:"inherit",lineHeight:1.5,textAlign:"center",textDecoration:"none",cursor:"pointer",..."secondary"===e?{backgroundColor:t.surface,color:t.accent,border:`1px solid ${t.accent}`}:{backgroundColor:t.accent,color:t.onAccent,border:"none"}}}function g(e,t=e.border){return{display:"block",boxSizing:"border-box",width:"100%",padding:"10px 12px",borderRadius:6,fontSize:14,fontFamily:"inherit",lineHeight:1.5,backgroundColor:e.surface,color:e.surfaceText,border:`1px solid ${t}`,outline:"none"}}const b="Subscribe",v="Thanks for subscribing!",k="Please check your inbox and confirm your email.",w="Save",S="Thanks! Your choice is saved.",x="Send",C="Thanks for the feedback!";const M="Something went wrong. Please try again.",P="\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",$={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",gift:"M3 11h18v9a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1zM2.5 7h19v4h-19zM12 7v14M12 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",cart:"M2 4h2.2l2.4 11.2A2 2 0 0 0 8.6 17H19M6 7h15l-2.2 7.5H8M10.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",chart:"M3 21h18M7 21V11M12 21V6M17 21v-8",lock:"M5 11h14v10H5zM8 11V8a4 4 0 0 1 8 0v3",calendar:"M4 6h16v15H4zM4 10h16M9 3v4M15 3v4",check:"M4 13l5 5L20 6",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",clock:"M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0M12 7v5l4 2",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.6l7 7a2 2 0 0 1 0 2.8zM9 8a1 1 0 1 1-2 0 1 1 0 0 1 2 0",mail:"M3 6h18v12H3zM3 7l9 6 9-6",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",download:"M12 3v12M7 11l5 5 5-5M4 20h16",play:"M8 5l12 7-12 7z",shield:"M12 3l8 3v6c0 5-3.4 8.6-8 10-4.6-1.4-8-5-8-10V6z",sparkle:"M12 3l1.8 5.2L19 10l-5.2 1.8L12 17l-1.8-5.2L5 10l5.2-1.8zM18 15l.9 2.1 2.1.9-2.1.9-.9 2.1-.9-2.1L15 18l2.1-.9z",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",truck:"M2 7h12v10H2zM14 10h4l3 3v4h-7M8.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",ticket:"M4 7h16v4a2 2 0 0 0 0 4v3H4v-3a2 2 0 0 0 0-4zM14 7v12",user:"M20 21a8 8 0 0 0-16 0M16 7a4 4 0 1 1-8 0 4 4 0 0 1 8 0"},R=Object.keys($),A=[24,32,48],I=["Vertical","Horizontal","Columns","Rows"],F=["normal","reverse"],E=["start","center","end","stretch"],T=["start","center","end","space-between"],j=["left","center","right"],N=["default","inverse"],O=2e3,D={px:O,"%":100,em:125,rem:125},L=/^(\d{1,4}(?:\.\d+)?)(px|%|em|rem)$/,q={px:O,"%":100,fr:100},H=/^(\d{1,4}(?:\.\d+)?)(px|%|fr)$/,z=["auto","min-content","max-content"];function B(e,t){return t.includes(e)?e:void 0}function W(e){if("number"==typeof e&&Number.isFinite(e))return Math.min(Math.max(e,0),O);if("string"!=typeof e)return;const t=L.exec(e.trim());if(!t)return;const[,n,o]=t;return`${Math.min(parseFloat(n),D[o])}${o}`}const U=["top","right","bottom","left"];function V(e){if(z.includes(e))return e;const t=H.exec(e);if(!t)return;const[,n,o]=t;return`${Math.min(parseFloat(n),q[o])}${o}`}function K(e){return"string"==typeof e&&e.length>0?e:void 0}function Z(e){const t={},n=W(e.gap);void 0!==n&&(t.gap=n);const o=function(e){const t=W(e);if(void 0!==t)return t;if("object"!=typeof e||null===e)return;const n={};for(const t of U){const o=W(e[t]);void 0!==o&&(n[t]=o)}return Object.keys(n).length>0?n:void 0}(e.padding);void 0!==o&&(t.padding=o);const i=B(e.alignItems,E);i&&(t.alignItems=i);const r=B(e.justifyContent,T);r&&(t.justifyContent=r);const s=B(e.alignContent,T);s&&(t.alignContent=s);const a=K(e.backgroundImage);a&&(t.backgroundImage=a);const l=function(e){if("number"==typeof e)return Number.isInteger(e)&&e>=1&&e<=12?e:void 0;if("string"!=typeof e)return;const t=e.trim().split(/\s+/);if(t.length<1||t.length>12)return;const n=t.map(V);return n.every(e=>void 0!==e)?n.join(" "):void 0}(e.sizes);return void 0!==l&&(t.sizes=l),t}function J(e,t,n){if(t>10||n.nodes<=0)return null;if("object"!=typeof e||null===e)return null;n.nodes-=1;const o=e,i="object"==typeof o.props&&null!==o.props?o.props:{};if("Content"===o.type){const e=K(i.content);if(!e)return null;const t={type:"Content",props:{content:e}},n=B(i.align,j);n&&(t.props.align=n);const o=B(i.tone,N);return o&&"default"!==o&&(t.props.tone=o),t}if("Image"===o.type){const e=K(i.image);if(!e)return null;return{type:"Image",props:{image:e}}}if(!Array.isArray(o.children))return null;const r=B(o.type,I)??"Vertical",s=[];for(const e of o.children){const o=J(e,t+1,n);o&&s.push(o)}const a=Z(i);return"reverse"===B(i.order,F)&&(s.reverse(),"string"==typeof a.sizes&&(a.sizes=a.sizes.split(" ").reverse().join(" "))),{type:r,props:a,children:s}}function G(e){return J(e,0,{nodes:100})}const Q=/^[a-zA-Z][a-zA-Z0-9-]*$/,Y=/^\$([a-zA-Z][a-zA-Z0-9-]*)$/;function X(e,t){return e.includes("$")?e.split(/(\s+)/).map(e=>{const n=Y.exec(e)?.[1];return void 0!==n&&Object.prototype.hasOwnProperty.call(t,n)?t[n]:e}).join(""):e}function ee(e,t){return"object"!=typeof e||null===e||0===Object.keys(t).length?e:ne(e,t,0)}const te=new Set(["content","image","backgroundImage"]);function ne(e,t,n){if(n>10||"object"!=typeof e||null===e)return e;const o=e,i={...o};if("object"==typeof o.props&&null!==o.props){const e={...o.props};for(const[n,o]of Object.entries(e))if(!te.has(n))if("string"==typeof o)e[n]=X(o,t);else if("object"==typeof o&&null!==o&&!Array.isArray(o)){const i={...o};for(const[e,n]of Object.entries(i))"string"==typeof n&&(i[e]=X(n,t));e[n]=i}i.props=e}return Array.isArray(o.children)&&(i.children=o.children.map(e=>ne(e,t,n+1))),i}function oe(e){return"number"==typeof e?`${e}px`:e}function ie(e,t){if("string"==typeof e)return e;return`repeat(${"number"==typeof e?e:Math.max(t,1)}, 1fr)`}function re(e=0){if(!(e>0))return null;const t=`rgba(16, 24, 40, ${Math.min(e,1)})`;return`linear-gradient(${t}, ${t})`}function se(e,t=0){const n=`url(${JSON.stringify(e)})`,o=re(t);return{backgroundImage:o?`${o}, ${n}`:n,backgroundSize:"cover",backgroundPosition:"center"}}function ae(e,t,n=0){const o=e.props??{},i={display:"grid",minWidth:0};return"Horizontal"===e.type&&(i.gridAutoFlow="column"),"Columns"===e.type&&(i.gridTemplateColumns=ie(o.sizes,e.children.length)),"Rows"===e.type&&(i.gridTemplateRows=ie(o.sizes,e.children.length)),void 0!==o.gap&&(i.gap=oe(o.gap)),void 0!==o.padding&&(i.padding=function(e){if("number"==typeof e||"string"==typeof e)return oe(e);const t=e=>void 0===e?"0":oe(e);return`${t(e.top)} ${t(e.right)} ${t(e.bottom)} ${t(e.left)}`}(o.padding)),o.alignItems&&(i.alignItems=o.alignItems),o.justifyContent&&(i.justifyContent=o.justifyContent),o.alignContent&&(i.alignContent=o.alignContent),t&&Object.assign(i,se(t,n)),i}const le=/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;function ce(e){const t=le.exec(e.trim())?.[1];if(!t)return null;const n=3===t.length?t.split("").map(e=>e+e).join(""):t;return[0,2,4].map(e=>parseInt(n.slice(e,e+2),16))}function ue([e,t,n]){return`#${[e,t,n].map(e=>Math.max(0,Math.min(255,Math.round(e))).toString(16).padStart(2,"0")).join("")}`}function de(e,t,n){let o=n;return o<0&&(o+=1),o>1&&(o-=1),o<1/6?e+6*(t-e)*o:o<.5?t:o<2/3?e+(t-e)*(2/3-o)*6:e}function pe(e){return e>.5?.07+.86*(1-e):e}function fe(e){return e<.5?.93-e*((.93-.5)/.5):e}function he(e,t){const n=ce(e);if(!n)return e;const[o,i,r]=function([e,t,n]){const[o,i,r]=[e/255,t/255,n/255],s=Math.max(o,i,r),a=Math.min(o,i,r),l=(s+a)/2;if(s===a)return[0,0,l];const c=s-a;let u;return u=s===o?(i-r)/c+(i<r?6:0):s===i?(r-o)/c+2:(o-i)/c+4,[u/6,l>.5?c/(2-s-a):c/(s+a),l]}(n);return ue(function([e,t,n]){if(0===t){const e=255*n;return[e,e,e]}const o=n<.5?n*(1+t):n+t-n*t,i=2*n-o;return[255*de(i,o,e+1/3),255*de(i,o,e),255*de(i,o,e-1/3)]}([o,i,"fold"===t?pe(r):fe(r)]))}function _e(e,t,n){const o=ce(e),i=ce(t);return o&&i?ue(o.map((e,t)=>e+(i[t]-e)*n)):e}function me(e,t){const n=ce(e);if(!n||t>=1)return e;const[o,i,r]=n;return`rgba(${o}, ${i}, ${r}, ${t})`}function ye(e){const t=ce(e);if(!t)return!1;const[n,o,i]=t;return(.299*n+.587*o+.114*i)/255>.6}function ge(e){return{background:he(e.background,"fold"),accent:e.accent,text:he(e.text,"lift"),textSecondary:he(e.textSecondary,"lift"),textInverse:e.textInverse}}function be(e,t){return"light"===t?{surface:s,surfaceText:o,border:"#D0D5DD",onAccent:r,error:"#D92D20",chromeIcon:i}:{surface:_e(e.background,e.text,.08),surfaceText:e.text,border:_e(e.background,e.text,.24),onAccent:ye(e.accent)?o:r,error:"#FDA29B",chromeIcon:e.textSecondary}}function ve(e){return!0===e.dark?.enabled}function ke(e,t="light"){return"dark"===t&&ve(e)?"dark":"light"}function we(e,t="light"){const n=ke(e,t),o="dark"===n?(i=e.colors,r=e.dark,{...ge(i),...r?.colors??{}}):e.colors;var i,r;return{...o,scheme:n,...be(o,n)}}function Se(e,t="light"){return"dark"===t&&e.srcDark?e.srcDark:e.src}function xe(e,t="light"){return"light"===ke(e,t)?{overlay:e.overlay,boxShadow:e.boxShadow}:{overlay:e.dark?.overlay??e.overlay,boxShadow:e.dark?.boxShadow??e.boxShadow}}const Ce=/^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2}))?$/,Me=new Map;function Pe(e){const t=Me.get(e);if(t)return t;try{const t=new Intl.DateTimeFormat("en-US",{timeZone:e,hour12:!1,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"});return Me.set(e,t),t}catch{return null}}function $e(e){return!e||null!==Pe(e)}function Re(e,t){const n=t.formatToParts(new Date(e)),o=e=>Number(n.find(t=>t.type===e)?.value??"0");return Date.UTC(o("year"),o("month")-1,o("day"),o("hour")%24,o("minute"),o("second"))-e}const Ae=864e5;const Ie=new Map;function Fe(e,t){const n=`${e}|${t}`,o=Ie.get(n);if(void 0!==o)return o;const i=function(e,t){const n=Ce.exec((e||"").trim());if(!n)return null;const[,o,i,r,s,a,l]=n.map(Number),c=Number.isNaN(l)?0:l;if(i<1||i>12||r<1||r>31)return null;if(s>23||a>59||c>59)return null;const u=Date.UTC(o,i-1,r,s,a,c),d=new Date(u);if(d.getUTCMonth()!==i-1||d.getUTCDate()!==r)return null;if(!t)return u;const p=Pe(t);if(!p)return null;const f=function(e,t){const n=[];for(const o of[e-Ae,e,e+Ae]){const e=Re(o,t);n.includes(e)||n.push(e)}return n}(u,p),h=f.filter(e=>Re(u-e,p)===e).map(e=>u-e);return h.length>0?Math.min(...h):u-Math.min(...f)}(e,t);return Ie.size>100&&Ie.clear(),Ie.set(n,i),i}const Ee={en:{days:"Days",hours:"Hours",minutes:"Minutes",seconds:"Seconds"},ru:{days:"Дни",hours:"Часы",minutes:"Минуты",seconds:"Секунды"},de:{days:"Tage",hours:"Stunden",minutes:"Minuten",seconds:"Sekunden"},es:{days:"Días",hours:"Horas",minutes:"Minutos",seconds:"Segundos"},fr:{days:"Jours",hours:"Heures",minutes:"Minutes",seconds:"Secondes"},pt:{days:"Dias",hours:"Horas",minutes:"Minutos",seconds:"Segundos"},ja:{days:"日",hours:"時間",minutes:"分",seconds:"秒"},ko:{days:"일",hours:"시간",minutes:"분",seconds:"초"},zh:{days:"天",hours:"小时",minutes:"分",seconds:"秒"},hi:{days:"दिन",hours:"घंटे",minutes:"मिनट",seconds:"सेकंड"},bn:{days:"দিন",hours:"ঘণ্টা",minutes:"মিনিট",seconds:"সেকেন্ড"},ar:{days:"أيام",hours:"ساعات",minutes:"دقائق",seconds:"ثوان"},he:{days:"ימים",hours:"שעות",minutes:"דקות",seconds:"שניות"},th:{days:"วัน",hours:"ชั่วโมง",minutes:"นาที",seconds:"วินาที"}};function Te(e){const t=(e||"").trim();if(t)return t.startsWith("#")||t.startsWith("/")||t.startsWith("?")||n.test(t)?t:void 0}function je(e){return"_self"===e?{target:"_self"}:{target:"_blank",rel:"noreferrer"}}const Ne=new Set(["STRONG","B","EM","I","U","BR","A"]);function Oe(e,t,n){for(const o of Array.from(e.childNodes)){if(3===o.nodeType){t.appendChild(n.createTextNode(o.textContent??""));continue}if(1!==o.nodeType)continue;const e=o;if(!Ne.has(e.tagName)){Oe(e,t,n);continue}const i=n.createElement(e.tagName.toLowerCase());if("A"===e.tagName){const t=Te(e.getAttribute("href")??void 0);t&&i.setAttribute("href",t);const{target:n,rel:o}=je(e.getAttribute("target"));i.setAttribute("target",n),o&&i.setAttribute("rel",o)}t.appendChild(i),Oe(e,i,n)}}function De(e){if(!e.includes("<"))return e;const t=(new DOMParser).parseFromString(e,"text/html"),n=t.createElement("div");return Oe(t.body,n,t),n.innerHTML}function Le(e){return"string"==typeof e&&e?e:void 0}function qe(e,t){const n=e.dark;if("object"!=typeof n||null===n)return;const o=n,i="object"==typeof o.colors&&null!==o.colors?o.colors:{},r=ge(t),s=function(e){if("object"!=typeof e||null===e)return;const t=e,n=Le(t.color);if(!n)return;return{color:n,opacity:"number"==typeof t.opacity&&Number.isFinite(t.opacity)?Math.max(0,Math.min(1,t.opacity)):1}}(o.overlay);return{enabled:!0===o.enabled,colors:{background:Le(i.background)??r.background,accent:Le(i.accent)??r.accent,text:Le(i.text)??r.text,textSecondary:Le(i.textSecondary)??r.textSecondary,textInverse:Le(i.textInverse)??r.textInverse},...s?{overlay:s}:{},...Le(o.boxShadow)?{boxShadow:o.boxShadow}:{}}}function He(e){let t;try{t=JSON.parse(e)}catch{return null}if("object"!=typeof t||null===t)return null;const n=t;if(2!==n.version)return null;const o=n.params;if("object"!=typeof o||null===o)return null;if(!Array.isArray(o.pages)||0===o.pages.length)return null;const i=function(e){const t="object"==typeof e.colors&&null!==e.colors?e.colors:{};return{background:Le(t.background)??Le(e.background)??s,accent:Le(t.accent)??Le(e.accent)??a,text:Le(t.text)??l,textSecondary:Le(t.textSecondary)??c,textInverse:Le(t.textInverse)??u}}(o),r=qe(o,i);return{version:2,params:{...o,colors:i,...r?{dark:r}:{}}}}const ze=["cover","contain"];function Be(e){if("object"!=typeof e||null===e)return;const t=e,n=Te("string"==typeof t.src?t.src:void 0);return n?{src:n,...!0===t.controls?{controls:!0}:{},...!1===t.loop?{loop:!1}:{}}:void 0}function We(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(t.length>=20)break;if("object"!=typeof n||null===n)continue;if("string"!=typeof n.key||!n.key)continue;if("string"!=typeof n.src)continue;const e=Be(n.video);t.push({key:n.key,label:"string"==typeof n.label?n.label:"",src:n.src,..."string"==typeof n.srcDark&&n.srcDark?{srcDark:n.srcDark}:{},...e?{video:e}:{},..."string"==typeof n.mediaId&&n.mediaId?{mediaId:n.mediaId}:{},..."string"==typeof n.mediaIdDark&&n.mediaIdDark?{mediaIdDark:n.mediaIdDark}:{},...ze.includes(n.fit)?{fit:n.fit}:{},..."number"==typeof n.blur&&Number.isFinite(n.blur)&&n.blur>0?{blur:Math.min(n.blur,100)}:{},..."number"==typeof n.dim&&Number.isFinite(n.dim)&&n.dim>0?{dim:Math.min(n.dim,1)}:{}})}return t}const Ue=["px","%","em","rem","fr"];function Ve(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function Ke(e){if("object"!=typeof e||null===e)return;const t=e;if("text"===t.kind)return{kind:"text"};if("length"===t.kind||"percent"===t.kind){const e=Ve(t.min),n=Ve(t.max),o="length"===t.kind&&Array.isArray(t.units)?t.units.filter(e=>Ue.includes(e)):[],i="length"===t.kind?function(e){if("object"!=typeof e||null===e)return;const t={};for(const n of Ue){const o=e[n];if("object"!=typeof o||null===o)continue;const i=Ve(o.min),r=Ve(o.max);void 0===i&&void 0===r||(t[n]={...void 0!==i?{min:i}:{},...void 0!==r?{max:r}:{}})}return Object.keys(t).length>0?t:void 0}(t.ranges):void 0;return{kind:t.kind,...void 0!==e?{min:e}:{},...void 0!==n?{max:n}:{},...o.length>0?{units:o}:{},...i?{ranges:i}:{}}}if("select"===t.kind&&Array.isArray(t.options)){const e=[];for(const n of t.options){if(e.length>=20)break;"object"==typeof n&&null!==n&&("string"!=typeof n.value||n.value.length>64||e.push({value:n.value,label:"string"==typeof n.label?n.label:n.value}))}if(e.length>0)return{kind:"select",options:e}}}function Ze(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(t.length>=20)break;if("object"!=typeof n||null===n)continue;if("string"!=typeof n.key||!Q.test(n.key))continue;if("string"!=typeof n.value||n.value.length>64||n.value.includes("$"))continue;if(t.some(e=>e.key===n.key))continue;const e=Ke(n.control);t.push({key:n.key,label:"string"==typeof n.label?n.label:"",value:n.value,...e?{control:e}:{}})}return t}function Je(e){return Object.fromEntries(e.map(e=>[e.key,e.value]))}const Ge=["email","firstName","lastName","phone","custom"],Qe=["primary","secondary"];function Ye(e){const t=[];if(Array.isArray(e))for(const n of e){if(t.length>=10)break;"object"==typeof n&&null!==n&&("string"==typeof n.key&&n.key&&Ge.includes(n.kind)&&(t.some(e=>e.key===n.key)||t.push({key:n.key,kind:n.kind,label:"string"==typeof n.label?n.label:"",placeholder:"string"==typeof n.placeholder?n.placeholder:"",required:"email"===n.kind||!0===n.required,..."custom"===n.kind&&"string"==typeof n.tag&&n.tag?{tag:n.tag}:{}})))}if(!t.some(e=>"email"===e.kind)){let e="field-email";for(;t.some(t=>t.key===e);)e=`${e}-1`;t.unshift({key:e,kind:"email",label:"Email",placeholder:"",required:!0})}return t.slice(0,10)}const Xe=["checkbox","chips"],et=["nps","stars","thumbs"],tt=["instant","button"],nt=["keep","hide-popup","page"],ot=/^[a-z]{2}$/i,it=/^#[0-9a-fA-F]{6}$/;function rt(e,t=120){return"string"==typeof e?e.trim().slice(0,t):""}function st(e,t,n=120){return rt(e,n)||t}function at(e){const t=rt(e,8);return ot.test(t)?t.toLowerCase():""}function lt(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(t.length>=12)break;if("object"!=typeof n||null===n)continue;const e=rt(n.value);if(!e)continue;if(t.some(t=>t.value===e))continue;const o=rt(n.tagValue);t.push({value:e,label:st(n.label,e),...o?{tagValue:o}:{}})}return t}function ct(e,t){const n=e=>{const n=Ve(e);return void 0===n||n<=0?0:Math.min(Math.floor(n),t)},o=n(e.min),i=n(e.max);return{min:o,max:i>0?Math.max(o,i):0}}function ut(e){const t=[];for(const n of e){if(t.length>=50)break;if("object"==typeof n&&null!==n&&("string"==typeof n.key&&n.key))if("text"!==n.type)if("button"!==n.type){if("timer"===n.type){const e=rt(n.timezone,64),o=$e(e)?e:"",i=rt(n.endTime,32);if(null===Fe(i,o))continue;const r=rt(n.expirePage),s=nt.includes(n.onExpire)?n.onExpire:"keep",a="page"!==s||r?s:"keep";t.push({type:"timer",key:n.key,endTime:i,timezone:o,language:at(n.language),showLabels:!1!==n.showLabels,onExpire:a,..."page"===a?{expirePage:r}:{}});continue}if("choice"===n.type){const e=lt(n.options),{min:o,max:i}=ct(n,e.length);t.push({type:"choice",key:n.key,control:Xe.includes(n.control)?n.control:"checkbox",tagName:rt(n.tagName),options:e,min:o,max:i,submitLabel:st(n.submitLabel,w),submitVariant:Qe.includes(n.submitVariant)?n.submitVariant:"primary",successMessage:st(n.successMessage,S,500)});continue}if("rating"===n.type){const e="object"==typeof n.labels&&null!==n.labels?n.labels:{};t.push({type:"rating",key:n.key,scale:et.includes(n.scale)?n.scale:"stars",labels:{low:rt(e.low),high:rt(e.high)},submitMode:tt.includes(n.submitMode)?n.submitMode:"instant",submitLabel:st(n.submitLabel,x),eventName:rt(n.eventName),successMessage:st(n.successMessage,C,500)});continue}if("glyph"!==n.type)"email-subscription-form"===n.type&&t.push({type:"email-subscription-form",key:n.key,formCode:"string"==typeof n.formCode?n.formCode:"",fields:Ye(n.fields),submitLabel:"string"==typeof n.submitLabel&&n.submitLabel?n.submitLabel:b,submitVariant:Qe.includes(n.submitVariant)?n.submitVariant:"primary",..."object"==typeof n.privacy&&null!==n.privacy&&"string"==typeof n.privacy.checkboxLabel?{privacy:{checkboxLabel:n.privacy.checkboxLabel,url:"string"==typeof n.privacy.url?n.privacy.url:"",linkLabel:"string"==typeof n.privacy.linkLabel?n.privacy.linkLabel:""}}:{},successMessage:"string"==typeof n.successMessage&&n.successMessage?n.successMessage:v,confirmEmailMessage:"string"==typeof n.confirmEmailMessage&&n.confirmEmailMessage?n.confirmEmailMessage:k});else{if(!R.includes(n.name))continue;t.push({type:"glyph",key:n.key,name:n.name,size:A.includes(n.size)?n.size:A[0],color:"string"==typeof n.color&&it.test(n.color)?n.color:""})}}else"object"==typeof n.action&&null!==n.action&&"string"==typeof n.action.type&&t.push(n);else"string"==typeof n.html&&t.push(n)}return t}function dt(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(t.length>=20)break;"object"==typeof n&&null!==n&&("string"==typeof n.key&&n.key&&Array.isArray(n.slots)&&t.push({key:n.key,label:"string"==typeof n.label?n.label:"",slots:ut(n.slots)}))}return t}function pt(e){return"number"==typeof e&&Number.isFinite(e)&&e>0?Math.min(e,2e3):void 0}function ft(e,t,n){if(null===e)return;let o;return o="stretch"===e?"stretch":pt(e)??("stretch"===t?"stretch":pt(t)),"width"===n&&"stretch"===o?void 0:o}function ht(e){const t=[];for(const n of e.pages){const o=Ze(n.values),i=G(ee(n.layout,Je(o)));if(!i)continue;const r=ft(n.width,e.width,"width"),s=ft(n.height,e.height,"height");t.push({key:n.key,layout:i,images:We(n.images),contents:dt(n.contents),...void 0!==r?{width:r}:{},...void 0!==s?{height:s}:{}})}return t}function _t(e){return`calc(100% - ${2*e.offset}px)`}const mt="pushwoosh-web-popups",yt="[WebPopups]",gt="keyValue",bt="messages",vt="inboxMessages";function kt(e,t){return function(n){n.objectStoreNames.contains(e)||t(n)}}const wt=[kt(gt,function(e){e.createObjectStore(gt,{keyPath:"key"})}),kt("log",function(e){const t=e.createObjectStore("log",{keyPath:"id",autoIncrement:!0});t.createIndex("environment","environment",{unique:!1}),t.createIndex("date","date",{unique:!1}),t.createIndex("type","type",{unique:!1})}),kt(bt,function(e){e.createObjectStore(bt,{keyPath:"id",autoIncrement:!0}).createIndex("date","date",{unique:!1})}),kt(vt,function(e){const t="status",n=e.createObjectStore(vt,{keyPath:"inbox_id",autoIncrement:!1});n.createIndex(t,t,{unique:!1,multiEntry:!0}),n.createIndex("rt","rt",{unique:!1,multiEntry:!0})})];class St{get all(){return wt}}class xt{constructor(e,t=new St){this.db=e,this.migrationsBuilder=t}applyMigrations(){this.applyMigrationsPack(this.migrationsBuilder.all)}applyMigrationsPack(e){e.forEach(e=>{e(this.db)})}}function Ct(e,t){console.info("onversionchange",t),e.close()}let Mt;function Pt(e){return(Mt||(Mt=new Promise((e,t)=>{const n=indexedDB.open("PUSHWOOSH_SDK_STORE",7);n.onsuccess=n=>{const o=n.target.result;o.onversionchange=Ct.bind(null,o,t),e(o)},n.onerror=()=>t(n.error),n.onupgradeneeded=e=>{const n=e.target.result;n.onversionchange=Ct.bind(null,n,t),new xt(n).applyMigrations()}})),Mt).then(t=>new Promise((n,o)=>e(t,n,o)))}class $t{_add(e){return Pt((t,n,o)=>{const i=t.transaction([this.name],"readwrite").objectStore(this.name).add(e);i.onsuccess=()=>{n(e)},i.onerror=()=>{o(i.error)}}).then(e=>this.getAll().then(t=>{if(Array.isArray(t)){const n=t.map(e=>e.id).sort((e,t)=>e==t?0:e<t?1:-1);if(n.length>this.maxItems)return Promise.all(n.slice(this.maxItems).map(e=>this.delete(e))).then(()=>e)}return e}))}delete(e){return Pt((t,n,o)=>{const i=t.transaction([this.name],"readwrite").objectStore(this.name).delete(e);i.onsuccess=()=>{n(i.result)},i.onerror=()=>{o(i.error)}})}getAll(){return Pt((e,t,n)=>{const o=[],i=e.transaction(this.name).objectStore(this.name).openCursor();i.onsuccess=e=>{const n=e.target.result;n?(n.value&&o.push(n.value),n.continue()):t(o)},i.onerror=()=>{n(i.error)}})}}Rt=gt;var Rt;const At=new class extends $t{constructor(){super(...arguments),this.name="log",this.maxItems=100,this.environment="undefined"!=typeof self&&self.registration?"worker":"browser"}add(e,t,n){const o={type:e,environment:this.environment,message:`${t}`,date:new Date};return t instanceof Error&&(o.stack=t.stack),n&&(o.additional=n),this._add(o)}},It=(new class extends $t{constructor(){super(...arguments),this.name=bt,this.maxItems=25}add(e){return this._add({...e,date:new Date})}},{error:1,info:2,debug:3});let Ft=3;const Et={setLevel(e){It[e]||(e="error"),Ft=It[e]},write(e,t,n){return"error"===e?this.error(t):this.info(t),At.add(e,t,n)}};function Tt(e){return async({slotKey:t,tagName:n,values:o})=>{try{await e.api.setTags({[n]:{operation:"append",value:o}})}catch(e){throw Et.error(e,`Failed to write web popup choice "${t}" to tag "${n}"`),e}}}function jt(e){return async({slotKey:t,eventName:n,score:o,scale:i})=>{try{await e.api.postEvent(n,{score:o,scale:i,slotKey:t})}catch(e){throw Et.error(e,`Failed to post web popup rating "${t}" as event "${n}"`),e}}}function Nt(e){return async()=>{try{await e.subscribe()}catch(e){Et.error(e,"Failed to subscribe from a web popup")}return e.driver?.getPermission()??"default"}}Object.keys(It).forEach(e=>{const t=It[e];Et[e]=(...n)=>{t<=Ft&&(console.groupCollapsed(e),console.info("",...n),console.trace("trace"),console.groupEnd())}});var Ot,Dt,Lt,qt,Ht,zt,Bt,Wt,Ut,Vt,Kt,Zt,Jt,Gt,Qt={},Yt=[],Xt=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,en=Array.isArray;function tn(e,t){for(var n in t)e[n]=t[n];return e}function nn(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function on(e,t,n){var o,i,r,s={};for(r in t)"key"==r?o=t[r]:"ref"==r?i=t[r]:s[r]=t[r];if(arguments.length>2&&(s.children=arguments.length>3?Ot.call(arguments,2):n),"function"==typeof e&&null!=e.defaultProps)for(r in e.defaultProps)void 0===s[r]&&(s[r]=e.defaultProps[r]);return rn(e,s,o,i,null)}function rn(e,t,n,o,i){var r={type:e,props:t,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++Lt,__i:-1,__u:0};return null==i&&null!=Dt.vnode&&Dt.vnode(r),r}function sn(e){return e.children}function an(e,t){this.props=e,this.context=t}function ln(e,t){if(null==t)return e.__?ln(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e)return n.__e;return"function"==typeof e.type?ln(e):null}function cn(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,o=[],i=[],r=tn({},t);r.__v=t.__v+1,Dt.vnode&&Dt.vnode(r),kn(e.__P,r,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,o,n??ln(t),!!(32&t.__u),i),r.__v=t.__v,r.__.__k[r.__i]=r,Sn(o,r,i),t.__e=t.__=null,r.__e!=n&&un(r)}}function un(e){if(null!=(e=e.__)&&null!=e.__c)return e.__e=e.__c.base=null,e.__k.some(function(t){if(null!=t&&null!=t.__e)return e.__e=e.__c.base=t.__e}),un(e)}function dn(e){(!e.__d&&(e.__d=!0)&&qt.push(e)&&!pn.__r++||Ht!=Dt.debounceRendering)&&((Ht=Dt.debounceRendering)||zt)(pn)}function pn(){try{for(var e,t=1;qt.length;)qt.length>t&&qt.sort(Bt),e=qt.shift(),t=qt.length,cn(e)}finally{qt.length=pn.__r=0}}function fn(e,t,n,o,i,r,s,a,l,c,u){var d,p,f,h,_,m,y=o&&o.__k||Yt,g=t.length;for(l=hn(n,t,y,l,g),d=0;d<g;d++)null!=(f=n.__k[d])&&(p=-1!=f.__i&&y[f.__i]||Qt,f.__i=d,m=kn(e,f,p,i,r,s,a,l,c,u),h=f.__e,f.ref&&p.ref!=f.ref&&(p.ref&&Mn(p.ref,null,f),u.push(f.ref,f.__c||h,f)),null==_&&null!=h&&(_=h),4&f.__u?(l=_n(f,l,e),p.__e&&(p.__e=null)):"function"==typeof f.type&&void 0!==m?l=m:h&&(l=h.nextSibling),f.__u&=-7);return n.__e=_,l}function hn(e,t,n,o,i){var r,s,a,l,c,u=n.length,d=u,p=0;for(e.__k=new Array(i),r=0;r<i;r++)null!=(s=t[r])&&"boolean"!=typeof s&&"function"!=typeof s?("string"==typeof s||"number"==typeof s||"bigint"==typeof s||s.constructor==String?s=e.__k[r]=rn(null,s,null,null,null):en(s)?s=e.__k[r]=rn(sn,{children:s},null,null,null):void 0===s.constructor&&s.__b>0?s=e.__k[r]=rn(s.type,s.props,s.key,s.ref?s.ref:null,s.__v):e.__k[r]=s,l=r+p,s.__=e,s.__b=e.__b+1,a=null,-1!=(c=s.__i=yn(s,n,l,d))&&(d--,(a=n[c])&&(a.__u|=2)),null==a||null==a.__v?(-1==c&&(i>u?p--:i<u&&p++),"function"!=typeof s.type&&(s.__u|=4)):c!=l&&(c==l-1?p--:c==l+1?p++:(c>l?p--:p++,s.__u|=4))):e.__k[r]=null;if(d)for(r=0;r<u;r++)null!=(a=n[r])&&!(2&a.__u)&&(a.__e==o&&(o=ln(a)),Pn(a,a));return o}function _n(e,t,n){var o,i;if("function"==typeof e.type){for(o=e.__k,i=0;o&&i<o.length;i++)o[i]&&(o[i].__=e,t=_n(o[i],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=ln(e)),t=n.insertBefore(e.__e,t||null));do{t=t&&t.nextSibling}while(null!=t&&8==t.nodeType);return t}function mn(e,t){return t=t||[],null==e||"boolean"==typeof e||(en(e)?e.some(function(e){mn(e,t)}):t.push(e)),t}function yn(e,t,n,o){var i,r,s,a=e.key,l=e.type,c=t[n],u=null!=c&&!(2&c.__u);if(null===c&&null==a||u&&a==c.key&&l==c.type)return n;if(o>(u?1:0))for(i=n-1,r=n+1;i>=0||r<t.length;)if(null!=(c=t[s=i>=0?i--:r++])&&!(2&c.__u)&&a==c.key&&l==c.type)return s;return-1}function gn(e,t,n){"-"==t[0]?e.setProperty(t,n??""):e[t]=null==n?"":"number"!=typeof n||Xt.test(t)?n:n+"px"}function bn(e,t,n,o,i){var r,s;e:if("style"==t)if("string"==typeof n)e.style.cssText=n;else{if("string"==typeof o&&(e.style.cssText=o=""),o)for(t in o)n&&t in n||gn(e.style,t,"");if(n)for(t in n)o&&n[t]==o[t]||gn(e.style,t,n[t])}else if("o"==t[0]&&"n"==t[1])r=t!=(t=t.replace(Kt,"$1")),s=t.toLowerCase(),t=s in e||"onFocusOut"==t||"onFocusIn"==t?s.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+r]=n,n?o?n[Vt]=o[Vt]:(n[Vt]=Zt,e.addEventListener(t,r?Gt:Jt,r)):e.removeEventListener(t,r?Gt:Jt,r);else{if("http://www.w3.org/2000/svg"==i)t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!=t&&"height"!=t&&"href"!=t&&"list"!=t&&"form"!=t&&"tabIndex"!=t&&"download"!=t&&"rowSpan"!=t&&"colSpan"!=t&&"role"!=t&&"popover"!=t&&t in e)try{e[t]=n??"";break e}catch(e){}"function"==typeof n||(null==n||!1===n&&"-"!=t[4]?e.removeAttribute(t):e.setAttribute(t,"popover"==t&&1==n?"":n))}}function vn(e){return function(t){if(this.l){var n=this.l[t.type+e];if(null==t[Ut])t[Ut]=Zt++;else if(t[Ut]<n[Vt])return;return n(Dt.event?Dt.event(t):t)}}}function kn(e,t,n,o,i,r,s,a,l,c){var u,d,p,f,h,_,m,y,g,b,v,k,w,S,x,C,M=t.type;if(void 0!==t.constructor)return null;128&n.__u&&(l=!!(32&n.__u),r=[a=t.__e=n.__e]),(u=Dt.__b)&&u(t);e:if("function"==typeof M){d=s.length;try{if(g=t.props,b=M.prototype&&M.prototype.render,v=(u=M.contextType)&&o[u.__c],k=u?v?v.props.value:u.__:o,n.__c?y=(p=t.__c=n.__c).__=p.__E:(b?t.__c=p=new M(g,k):(t.__c=p=new an(g,k),p.constructor=M,p.render=$n),v&&v.sub(p),p.state||(p.state={}),p.__n=o,f=p.__d=!0,p.__h=[],p._sb=[]),b&&null==p.__s&&(p.__s=p.state),b&&null!=M.getDerivedStateFromProps&&(p.__s==p.state&&(p.__s=tn({},p.__s)),tn(p.__s,M.getDerivedStateFromProps(g,p.__s))),h=p.props,_=p.state,p.__v=t,f)b&&null==M.getDerivedStateFromProps&&null!=p.componentWillMount&&p.componentWillMount(),b&&null!=p.componentDidMount&&p.__h.push(p.componentDidMount);else{if(b&&null==M.getDerivedStateFromProps&&g!==h&&null!=p.componentWillReceiveProps&&p.componentWillReceiveProps(g,k),t.__v==n.__v||!p.__e&&null!=p.shouldComponentUpdate&&!1===p.shouldComponentUpdate(g,p.__s,k)){t.__v!=n.__v&&(p.props=g,p.state=p.__s,p.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),Yt.push.apply(p.__h,p._sb),p._sb=[],p.__h.length&&s.push(p),a=ln(n);break e}null!=p.componentWillUpdate&&p.componentWillUpdate(g,p.__s,k),b&&null!=p.componentDidUpdate&&p.__h.push(function(){p.componentDidUpdate(h,_,m)})}if(p.context=k,p.props=g,p.__P=e,p.__e=!1,w=Dt.__r,S=0,b)p.state=p.__s,p.__d=!1,w&&w(t),u=p.render(p.props,p.state,p.context),Yt.push.apply(p.__h,p._sb),p._sb=[];else do{p.__d=!1,w&&w(t),u=p.render(p.props,p.state,p.context),p.state=p.__s}while(p.__d&&++S<25);p.state=p.__s,null!=p.getChildContext&&(o=tn(tn({},o),p.getChildContext())),b&&!f&&null!=p.getSnapshotBeforeUpdate&&(m=p.getSnapshotBeforeUpdate(h,_)),x=null!=u&&u.type===sn&&null==u.key?xn(u.props.children):u,a=fn(e,en(x)?x:[x],t,n,o,i,r,s,a,l,c),p.base=t.__e,t.__u&=-161,p.__h.length&&s.push(p),y&&(p.__E=p.__=null)}catch(e){if(s.length=d,t.__v=null,l||null!=r){if(e.then){for(t.__u|=l?160:128;a&&8==a.nodeType&&a.nextSibling;)a=a.nextSibling;null!=r&&(r[r.indexOf(a)]=null),t.__e=a}else if(null!=r)for(C=r.length;C--;)nn(r[C])}else t.__e=n.__e;null==t.__k&&(t.__k=n.__k||[]),e.then||wn(t),Dt.__e(e,t,n)}}else null==r&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):a=t.__e=Cn(n.__e,t,n,o,i,r,s,l,c);return(u=Dt.diffed)&&u(t),128&t.__u?void 0:a}function wn(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(wn))}function Sn(e,t,n){for(var o=0;o<n.length;o++)Mn(n[o],n[++o],n[++o]);Dt.__c&&Dt.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){Dt.__e(e,t.__v)}})}function xn(e){return"object"!=typeof e||null==e||e.__b>0?e:en(e)?e.map(xn):void 0!==e.constructor?null:tn({},e)}function Cn(e,t,n,o,i,r,s,a,l){var c,u,d,p,f,h,_,m=n.props||Qt,y=t.props,g=t.type;if("svg"==g?i="http://www.w3.org/2000/svg":"math"==g?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),null!=r)for(c=0;c<r.length;c++)if((f=r[c])&&"setAttribute"in f==!!g&&(g?f.localName==g:3==f.nodeType)){e=f,r[c]=null;break}if(null==e){if(null==g)return document.createTextNode(y);e=document.createElementNS(i,g,y.is&&y),a&&(Dt.__m&&Dt.__m(t,r),a=!1),r=null}if(null==g)m===y||a&&e.data==y||(e.data=y);else{if(r="textarea"==g&&null!=y.defaultValue?null:r&&Ot.call(e.childNodes),!a&&null!=r)for(m={},c=0;c<e.attributes.length;c++)m[(f=e.attributes[c]).name]=f.value;for(c in m)f=m[c],"dangerouslySetInnerHTML"==c?d=f:"children"==c||c in y||"value"==c&&"defaultValue"in y||"checked"==c&&"defaultChecked"in y||bn(e,c,null,f,i);for(c in y)f=y[c],"children"==c?p=f:"dangerouslySetInnerHTML"==c?u=f:"value"==c?h=f:"checked"==c?_=f:a&&"function"!=typeof f||m[c]===f||bn(e,c,f,m[c],i);if(u)a||d&&(u.__html==d.__html||u.__html==e.innerHTML)||(e.innerHTML=u.__html),t.__k=[];else if(d&&(e.innerHTML=""),fn("template"==t.type?e.content:e,en(p)?p:[p],t,n,o,"foreignObject"==g?"http://www.w3.org/1999/xhtml":i,r,s,r?r[0]:n.__k&&ln(n,0),a,l),null!=r)for(c=r.length;c--;)nn(r[c]);a&&"textarea"!=g||(c="value","progress"==g&&null==h?e.removeAttribute("value"):null!=h&&(h!==e[c]||"progress"==g&&!h||"option"==g&&h!=m[c])&&bn(e,c,h,m[c],i),c="checked",null!=_&&_!=e[c]&&bn(e,c,_,m[c],i))}return e}function Mn(e,t,n){try{if("function"==typeof e){var o="function"==typeof e.__u;o&&e.__u(),o&&null==t||(e.__u=e(t))}else e.current=t}catch(e){Dt.__e(e,n)}}function Pn(e,t,n){var o,i;if(Dt.unmount&&Dt.unmount(e),(o=e.ref)&&(o.current&&o.current!=e.__e||Mn(o,null,t)),null!=(o=e.__c)){if(o.componentWillUnmount)try{o.componentWillUnmount()}catch(e){Dt.__e(e,t)}o.base=o.__P=o.__n=null}if(o=e.__k)for(i=0;i<o.length;i++)o[i]&&Pn(o[i],t,n||"function"!=typeof e.type);n||nn(e.__e),e.__c=e.__=e.__e=void 0}function $n(e,t,n){return this.constructor(e,n)}function Rn(e,t,n){var o,i,r,s;t==document&&(t=document.documentElement),Dt.__&&Dt.__(e,t),i=(o="function"==typeof n)?null:n&&n.__k||t.__k,r=[],s=[],kn(t,e=(!o&&n||t).__k=on(sn,null,[e]),i||Qt,Qt,t.namespaceURI,!o&&n?[n]:i?null:t.firstChild?Ot.call(t.childNodes):null,r,!o&&n?n:i?i.__e:t.firstChild,o,s),Sn(r,e,s),e.props.children=null}Ot=Yt.slice,Dt={__e:function(e,t,n,o){for(var i,r,s;t=t.__;)if((i=t.__c)&&!i.__)try{if((r=i.constructor)&&null!=r.getDerivedStateFromError&&(i.setState(r.getDerivedStateFromError(e)),s=i.__d),null!=i.componentDidCatch&&(i.componentDidCatch(e,o||{}),s=i.__d),s)return i.__E=i}catch(t){e=t}throw e}},Lt=0,an.prototype.setState=function(e,t){var n;n=null!=this.__s&&this.__s!=this.state?this.__s:this.__s=tn({},this.state),"function"==typeof e&&(e=e(tn({},n),this.props)),e&&tn(n,e),null!=e&&this.__v&&(t&&this._sb.push(t),dn(this))},an.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),dn(this))},an.prototype.render=sn,qt=[],zt="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Bt=function(e,t){return e.__v.__b-t.__v.__b},pn.__r=0,Wt=Math.random().toString(8),Ut="__d"+Wt,Vt="__a"+Wt,Kt=/(PointerCapture)$|Capture$/i,Zt=0,Jt=vn(!1),Gt=vn(!0);var An=0;Array.isArray;function In(e,t,n,o,i,r){t||(t={});var s,a,l=t;if("ref"in l)for(a in l={},t)"ref"==a?s=t[a]:l[a]=t[a];var c={type:e,props:l,key:n,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--An,__i:-1,__u:0,__source:i,__self:r};if("function"==typeof e&&(s=e.defaultProps))for(a in s)void 0===l[a]&&(l[a]=s[a]);return Dt.vnode&&Dt.vnode(c),c}var Fn,En,Tn,jn,Nn=0,On=[],Dn=Dt,Ln=Dn.__b,qn=Dn.__r,Hn=Dn.diffed,zn=Dn.__c,Bn=Dn.unmount,Wn=Dn.__;function Un(e,t){Dn.__h&&Dn.__h(En,e,Nn||t),Nn=0;var n=En.__H||(En.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function Vn(e){return Nn=1,function(e,t,n){var o=Un(Fn++,2);if(o.t=e,!o.__c&&(o.__=[n?n(t):eo(void 0,t),function(e){var t=o.__N?o.__N[0]:o.__[0],n=o.t(t,e);t!==n&&(o.__N=[n,o.__[1]],o.__c.setState({}))}],o.__c=En,!En.__f)){var i=function(e,t,n){if(!o.__c.__H)return!0;var i=!1,s=o.__c.props!==e;if(o.__c.__H.__.some(function(e){if(e.__N){i=!0;var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(s=!0)}}),r){var a=r.call(this,e,t,n);return i?a||s:a}return!i||s};En.__f=!0;var r=En.shouldComponentUpdate,s=En.componentWillUpdate;En.componentWillUpdate=function(e,t,n){if(this.__e){var o=r;r=void 0,i(e,t,n),r=o}s&&s.call(this,e,t,n)},En.shouldComponentUpdate=i}return o.__N||o.__}(eo,e)}function Kn(e,t){var n=Un(Fn++,3);!Dn.__s&&Xn(n.__H,t)&&(n.__=e,n.u=t,En.__H.__h.push(n))}function Zn(){for(var e;e=On.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Qn),t.__h.some(Yn),t.__h=[]}catch(n){t.__h=[],Dn.__e(n,e.__v)}}}Dn.__b=function(e){En=null,Ln&&Ln(e)},Dn.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Wn&&Wn(e,t)},Dn.__r=function(e){qn&&qn(e),Fn=0;var t=(En=e.__c).__H;t&&(Tn===En?(t.__h=[],En.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.some(Qn),t.__h.some(Yn),t.__h=[],Fn=0)),Tn=En},Dn.diffed=function(e){Hn&&Hn(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(1!==On.push(t)&&jn===Dn.requestAnimationFrame||((jn=Dn.requestAnimationFrame)||Gn)(Zn)),t.__H.__.some(function(e){e.u&&(e.__H=e.u,e.u=void 0)})),Tn=En=null},Dn.__c=function(e,t){t.some(function(e){try{e.__h.some(Qn),e.__h=e.__h.filter(function(e){return!e.__||Yn(e)})}catch(n){t.some(function(e){e.__h&&(e.__h=[])}),t=[],Dn.__e(n,e.__v)}}),zn&&zn(e,t)},Dn.unmount=function(e){Bn&&Bn(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(e){try{Qn(e)}catch(e){t=e}}),n.__H=void 0,t&&Dn.__e(t,n.__v))};var Jn="function"==typeof requestAnimationFrame;function Gn(e){var t,n=function(){clearTimeout(o),Jn&&cancelAnimationFrame(t),setTimeout(e)},o=setTimeout(n,35);Jn&&(t=requestAnimationFrame(n))}function Qn(e){var t=En,n=e.__c;"function"==typeof n&&(e.__c=void 0,n()),En=t}function Yn(e){var t=En;e.__c=e.__(),En=t}function Xn(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function eo(e,t){return"function"==typeof t?t(e):t}function to(e,t){for(var n in t)e[n]=t[n];return e}function no(e,t){for(var n in e)if("__source"!==n&&!(n in t))return!0;for(var o in t)if("__source"!==o&&e[o]!==t[o])return!0;return!1}function oo(e,t){this.props=e,this.context=t}(oo.prototype=new an).isPureReactComponent=!0,oo.prototype.shouldComponentUpdate=function(e,t){return no(this.props,e)||no(this.state,t)};var io=Dt.__b;Dt.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),io&&io(e)};"undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.forward_ref");var ro=Dt.__e;Dt.__e=function(e,t,n,o){if(e.then)for(var i,r=t;r=r.__;)if((i=r.__c)&&i.__c)return null==t.__e&&(t.__e=n.__e,t.__k=n.__k||[]),i.__c(e,t);ro(e,t,n,o)};var so=Dt.unmount;function ao(e,t,n){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(e){"function"==typeof e.__c&&e.__c()}),e.__c.__H=null),null!=(e=to({},e)).__c&&(e.__c.__P===n&&(e.__c.__P=t),e.__c.__e=!0,e.__c=null),e.__k=e.__k&&e.__k.map(function(e){return ao(e,t,n)})),e}function lo(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(e){return lo(e,t,n)}),e.__c&&e.__c.__P===t&&(e.__e&&n.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=n)),e}function co(){this.__u=0,this.o=null,this.__b=null}function uo(e){var t=e.__&&e.__.__c;return t&&t.__a&&t.__a(e)}function po(){this.i=null,this.l=null}Dt.unmount=function(e){var t=e.__c;t&&(t.__z=!0),t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),so&&so(e)},(co.prototype=new an).__c=function(e,t){var n=t.__c,o=this;null==o.o&&(o.o=[]),o.o.push(n);var i=uo(o.__v),r=!1,s=function(){r||o.__z||(r=!0,n.__R=null,i?i(l):l())};n.__R=s;var a=n.__P;n.__P=null;var l=function(){if(! --o.__u){if(o.state.__a){var e=o.state.__a;o.__v.__k[0]=lo(e,e.__c.__P,e.__c.__O)}var t;for(o.setState({__a:o.__b=null});t=o.o.pop();)t.__P=a,t.forceUpdate()}};o.__u++||32&t.__u||o.setState({__a:o.__b=o.__v.__k[0]}),e.then(s,s)},co.prototype.componentWillUnmount=function(){this.o=[]},co.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var n=document.createElement("div"),o=this.__v.__k[0].__c;this.__v.__k[0]=ao(this.__b,n,o.__O=o.__P)}this.__b=null}var i=t.__a&&on(sn,null,e.fallback);return i&&(i.__u&=-33),[on(sn,null,t.__a?null:e.children),i]};var fo=function(e,t,n){if(++n[1]===n[0]&&e.l.delete(t),e.props.revealOrder&&("t"!==e.props.revealOrder[0]||!e.l.size))for(n=e.i;n;){for(;n.length>3;)n.pop()();if(n[1]<n[0])break;e.i=n=n[2]}};(po.prototype=new an).__a=function(e){var t=this,n=uo(t.__v),o=t.l.get(e);return o[0]++,function(i){var r=function(){t.props.revealOrder?(o.push(i),fo(t,e,o)):i()};n?n(r):r()}},po.prototype.render=function(e){this.i=null,this.l=new Map;var t=mn(e.children);e.revealOrder&&"b"===e.revealOrder[0]&&t.reverse();for(var n=t.length;n--;)this.l.set(t[n],this.i=[1,0,this.i]);return e.children},po.prototype.componentDidUpdate=po.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){fo(e,n,t)})};var ho="undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,_o=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,mo=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,yo=/[A-Z0-9]/g,go="undefined"!=typeof document,bo=function(e){return("undefined"!=typeof Symbol&&"symbol"==typeof Symbol()?/fil|che|rad/:/fil|che|ra/).test(e)};an.prototype.isReactComponent=!0,["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(e){Object.defineProperty(an.prototype,e,{configurable:!0,get:function(){return this["UNSAFE_"+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var vo=Dt.event;Dt.event=function(e){return vo&&(e=vo(e)),e.persist=function(){},e.isPropagationStopped=function(){return this.cancelBubble},e.isDefaultPrevented=function(){return this.defaultPrevented},e.nativeEvent=e};var ko={configurable:!0,get:function(){return this.class}},wo=Dt.vnode;Dt.vnode=function(e){"string"==typeof e.type&&function(e){var t=e.props,n=e.type,o={},i=-1==n.indexOf("-");for(var r in t){var s=t[r];if(!("value"===r&&"defaultValue"in t&&null==s||go&&"children"===r&&"noscript"===n||"class"===r||"className"===r)){var a=r.toLowerCase();"defaultValue"===r&&"value"in t&&null==t.value?r="value":"download"===r&&!0===s?s="":"translate"===a&&"no"===s?s=!1:"o"===a[0]&&"n"===a[1]?"ondoubleclick"===a?r="ondblclick":"onchange"!==a||"input"!==n&&"textarea"!==n||bo(t.type)?"onfocus"===a?r="onfocusin":"onblur"===a?r="onfocusout":mo.test(r)&&(r=a):a=r="oninput":i&&_o.test(r)?r=r.replace(yo,"-$&").toLowerCase():null===s&&(s=void 0),"oninput"===a&&o[r=a]&&(r="oninputCapture"),o[r]=s}}"select"==n&&(o.multiple&&Array.isArray(o.value)&&(o.value=mn(t.children).forEach(function(e){e.props.selected=-1!=o.value.indexOf(e.props.value)})),null!=o.defaultValue&&(o.value=mn(t.children).forEach(function(e){e.props.selected=o.multiple?-1!=o.defaultValue.indexOf(e.props.value):o.defaultValue==e.props.value}))),t.class&&!t.className?(o.class=t.class,Object.defineProperty(o,"className",ko)):t.className&&(o.class=o.className=t.className),e.props=o}(e),e.$$typeof=ho,wo&&wo(e)};var So=Dt.__r;Dt.__r=function(e){So&&So(e),e.__c};var xo=Dt.diffed;Dt.diffed=function(e){xo&&xo(e);var t=e.props,n=e.__e;null!=n&&"textarea"===e.type&&"value"in t&&t.value!==n.value&&(n.value=null==t.value?"":t.value)};const Co="(prefers-color-scheme: dark)";function Mo(e,t){const[n,o]=Vn(()=>"auto"===e&&t&&"undefined"!=typeof window&&"function"==typeof window.matchMedia&&window.matchMedia(Co).matches);return Kn(()=>{if("auto"!==e||!t||"undefined"==typeof window||"function"!=typeof window.matchMedia)return;const n=window.matchMedia(Co),i=e=>o(e.matches);return o(n.matches),n.addEventListener("change",i),()=>n.removeEventListener("change",i)},[e,t]),"auto"!==e?e:n?"dark":"light"}const Po={none:void 0,fade:"pw-vpopup-fade 0.35s ease-out backwards",slide:"pw-vpopup-slide 0.35s ease-out backwards"};function $o({slot:e,align:t,inverse:n,colors:o}){const i={...d[e.variant],textAlign:e.align??t},r=f(e.variant,o,n);return r&&(i.color=r),In("div",{style:i,dangerouslySetInnerHTML:{__html:De(e.html)}})}function Ro({slot:e,colors:t,onRequestClose:n,onPageChange:o,onRequestSubscribe:i}){const[r,s]=Vn("idle"),a=y(e.variant,t),l={};if("close"===e.action.type)return In("div",{style:l,children:In("button",{type:"button",style:a,onClick:n,children:e.label})});if("page"===e.action.type){const t=e.action.page;return In("div",{style:l,children:In("button",{type:"button",style:a,onClick:()=>o(t),children:e.label})})}if("subscribe"===e.action.type){const t="idle"!==r,o=()=>{i&&!t&&(s("asking"),i().then(e=>{"granted"!==e?s("denied"===e?"denied":"idle"):n?.()}).catch(()=>s("idle")))};return In("div",{style:l,children:In("button",{type:"button",disabled:t,style:{...a,...t?{opacity:.7}:{}},onClick:o,children:e.label})})}const c=Te(e.action.url);return In("div",c?{style:l,children:In("a",{href:c,...je(e.action.target),style:a,children:e.label})}:{style:l,children:In("button",{type:"button",style:a,children:e.label})})}function Ao({message:e,align:t,inverse:n,colors:o}){const i=f("body",o,n);return In("div",{style:{...d.body,padding:"4px 0",textAlign:t,...i?{color:i}:{}},children:e})}const Io=/^\S+@\S+\.\S+$/,Fo={email:"email",phone:"tel"},Eo={email:"email",firstName:"given-name",lastName:"family-name",phone:"tel"},To="__privacy";function jo({slot:e,align:t,inverse:n,colors:o,onSubmitForm:i}){const[r,s]=Vn({}),[a,l]=Vn(!1),[c,u]=Vn(null),[p,h]=Vn({}),[_,b]=Vn("idle"),v=f("caption",o,n),k={...d.caption,...v?{color:v}:{}},w={fontSize:12,lineHeight:1.4,color:o.error,paddingTop:2};if("success"===_||"confirm"===_)return In(Ao,{message:"confirm"===_?e.confirmEmailMessage:e.successMessage,align:t,inverse:n,colors:o});const S="submitting"===_,x=e.privacy?Te(e.privacy.url):void 0,C={...y(e.submitVariant,o),...S?{opacity:.6,cursor:"default"}:{}};return In("form",{noValidate:!0,style:{margin:0,textAlign:"left"},onSubmit:t=>{t.preventDefault(),(()=>{if(!i||!e.formCode||"submitting"===_)return;const t={};for(const n of e.fields){const e=(r[n.key]??"").trim();n.required&&!e?t[n.key]="Required":"email"===n.kind&&e&&!Io.test(e)&&(t[n.key]="Enter a valid email")}if(e.privacy&&!a&&(t[To]="Please accept the privacy policy"),h(t),Object.keys(t).length>0)return;const n={email:"",policyAccepted:!e.privacy||a},o={};for(const t of e.fields){const e=(r[t.key]??"").trim();e&&("email"===t.kind?n.email=n.email||e:"firstName"===t.kind?n.firstName=e:"lastName"===t.kind?n.lastName=e:"phone"===t.kind?n.phone=e:o[t.tag||t.key]=e)}Object.keys(o).length>0&&(n.customFields=o),b("submitting"),Promise.resolve().then(()=>i(e.formCode,n)).then(e=>b("confirm-email"===e?"confirm":"success"),()=>b("error"))})()},children:[e.fields.map(e=>{const t=p[e.key];let n;return t?n=o.error:c===e.key&&(n=o.accent),In("div",{style:{padding:"4px 0"},children:[e.label&&In("div",{style:{...k,paddingBottom:4},children:e.label}),In("input",{type:Fo[e.kind]??"text",autoComplete:Eo[e.kind],placeholder:e.placeholder||void 0,value:r[e.key]??"",disabled:S,style:g(o,n),onFocus:()=>u(e.key),onBlur:()=>u(t=>t===e.key?null:t),onChange:t=>{return n=e.key,o=t.currentTarget.value,s(e=>({...e,[n]:o})),void h(e=>e[n]?Object.fromEntries(Object.entries(e).filter(([e])=>e!==n)):e);var n,o}}),t&&In("div",{style:w,children:t})]},e.key)}),e.privacy&&In("div",{style:{padding:"4px 0"},children:[In("label",{style:{...k,display:"flex",alignItems:"flex-start",gap:8,cursor:"pointer"},children:[In("input",{type:"checkbox",checked:a,disabled:S,style:{margin:"2px 0 0",flexShrink:0},onChange:e=>{l(e.currentTarget.checked),h(e=>e[To]?Object.fromEntries(Object.entries(e).filter(([e])=>e!==To)):e)}}),In("span",{children:[e.privacy.checkboxLabel,x&&In(sn,{children:[" ",In("a",{href:x,...je(void 0),style:{color:o.accent},children:e.privacy.linkLabel||e.privacy.url})]})]})]}),p[To]&&In("div",{style:w,children:p[To]})]}),In("div",{style:{padding:m},children:In("button",{type:"submit",disabled:S,style:C,children:e.submitLabel})}),"error"===_&&In("div",{style:{...w,textAlign:t},children:M})]})}function No({value:e,label:t,digitStyle:n,labelStyle:o}){return In("div",{style:{minWidth:44},children:[In("div",{style:n,children:String(e).padStart(2,"0")}),t?In("div",{style:o,children:t}):null]})}function Oo({slot:e,align:t,inverse:n,colors:o,mode:i,onRequestClose:r,onPageChange:s}){const[a,l]=Vn(()=>Date.now()),c=function(e,t,n){const o=Fe(e,t),i=null===o?0:Math.max(0,o-n),r=Math.floor(i/1e3);return{total:i,days:Math.floor(r/86400),hours:Math.floor(r/3600)%24,minutes:Math.floor(r/60)%60,seconds:r%60}}(e.endTime,e.timezone,a),u=0===c.total;Kn(()=>{if("live"!==i||u)return;const e=setInterval(()=>l(Date.now()),1e3);return()=>clearInterval(e)},[i,u,e.endTime,e.timezone]),Kn(()=>{"live"===i&&u&&("hide-popup"===e.onExpire?r?.():"page"===e.onExpire&&e.expirePage&&s(e.expirePage))},[i,u,e.onExpire,e.expirePage,r,s]);const p=f("h2",o,n),h=f("caption",o,n),_={fontSize:28,fontWeight:700,lineHeight:1.2,fontVariantNumeric:"tabular-nums",...p?{color:p}:{}},m={...d.caption,...h?{color:h}:{}},y=(g=e.language,Ee[g]??Ee.en);var g;return In("div",{style:{padding:"4px 0",textAlign:t},children:In("div",{style:{display:"inline-flex",gap:12,textAlign:"center"},children:[{value:c.days,label:y.days},{value:c.hours,label:y.hours},{value:c.minutes,label:y.minutes},{value:c.seconds,label:y.seconds}].map(t=>In(No,{value:t.value,label:e.showLabels?t.label:"",digitStyle:_,labelStyle:m},t.label||t.value))})})}function Do({slot:e,align:t,inverse:n,colors:o,onSubmitChoice:i}){const[r,s]=Vn([]),[a,l]=Vn("idle"),[c,u]=Vn("");if("success"===a)return In(Ao,{message:e.successMessage,align:t,inverse:n,colors:o});const p=t=>{u(""),s(n=>n.includes(t)?n.filter(e=>e!==t):e.max>0&&n.length>=e.max?(u(`Pick up to ${e.max}`),n):[...n,t])},h="submitting"===a,_=f("body",o,n),g={...d.body,..._?{color:_}:{}};return In("div",{style:{padding:"4px 0"},children:["chips"===e.control?In("div",{style:{display:"flex",flexWrap:"wrap",gap:8,justifyContent:"center"===t?"center":"flex-start"},children:e.options.map(e=>{return In("button",{type:"button","aria-pressed":r.includes(e.value),style:(t=r.includes(e.value),{padding:"6px 14px",borderRadius:999,border:`1px solid ${o.accent}`,backgroundColor:t?o.accent:"transparent",color:t?o.onAccent:o.accent,fontFamily:"inherit",fontSize:14,lineHeight:1.4,cursor:"pointer"}),onClick:()=>p(e.value),children:e.label},e.value);var t})}):In("div",{style:{display:"grid",gap:6},children:e.options.map(e=>In("label",{style:{...g,display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[In("input",{type:"checkbox",checked:r.includes(e.value),onChange:()=>p(e.value),style:{accentColor:o.accent,width:16,height:16,margin:0}}),e.label]},e.value))}),c?In("div",{style:{...d.caption,color:o.error,paddingTop:4},children:c}):null,"error"===a?In("div",{style:{...d.caption,color:o.error,paddingTop:4},children:M}):null,In("div",{style:{padding:m},children:In("button",{type:"button",style:{...y(e.submitVariant,o),...h?{opacity:.7}:{}},onClick:()=>{if(!i||!e.tagName||"submitting"===a)return;const t=Math.max(e.min,1);if(r.length<t)return void u(1===t?"Pick at least one":`Pick at least ${t}`);const n=e.options.filter(e=>r.includes(e.value)).map(e=>e.tagValue||e.value);u(""),l("submitting"),Promise.resolve().then(()=>i({slotKey:e.key,tagName:e.tagName,values:n})).then(()=>l("success"),()=>l("error"))},children:e.submitLabel})})]})}function Lo({score:e,scale:t,selected:n,colors:o,onPick:i}){const r={display:"inline-flex",alignItems:"center",justifyContent:"center",padding:0,border:`1px solid ${o.accent}`,backgroundColor:n?o.accent:"transparent",color:n?o.onAccent:o.accent,fontFamily:"inherit",fontSize:14,lineHeight:1,cursor:"pointer"};if("nps"===t)return In("button",{type:"button","aria-label":`Rate ${e}`,"aria-pressed":n,style:{...r,width:30,height:32,borderRadius:6},onClick:i,children:e});const s="thumbs"===t;let a=`Rate ${e}`;return s&&(a=1===e?"Thumbs up":"Thumbs down"),In("button",{type:"button","aria-label":a,"aria-pressed":n,style:{...r,width:s?44:34,height:s?40:34,borderRadius:s?8:6},onClick:i,children:In("svg",{width:s?22:20,height:s?22:20,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:In("path",{d:s?"M8 21V10l3.5-7A2 2 0 0 1 14 5v5h4.5a2 2 0 0 1 2 2.4l-1.3 6A2 2 0 0 1 17.2 21zM8 10H3.5v11H8":$.star,...s&&0===e?{transform:"rotate(180 12 12)"}:{}})})})}function qo({slot:e,align:t,inverse:n,colors:o,onSubmitRating:i}){const[r,s]=Vn(null),[a,l]=Vn("idle");if("success"===a)return In(Ao,{message:e.successMessage,align:t,inverse:n,colors:o});const c=t=>{i&&e.eventName&&"submitting"!==a&&(l("submitting"),Promise.resolve().then(()=>i({slotKey:e.key,eventName:e.eventName,score:t,scale:e.scale})).then(()=>l("success"),()=>l("error")))},u="nps"===(p=e.scale)?[0,1,2,3,4,5,6,7,8,9,10]:"stars"===p?[1,2,3,4,5]:[0,1];var p;const h=f("caption",o,n),_={...d.caption,...h?{color:h}:{}},g=t=>"stars"===e.scale?null!==r&&t<=r:r===t;return In("div",{style:{padding:"4px 0"},children:[In("div",{style:{display:"flex",flexWrap:"wrap",gap:6,justifyContent:"center"===t?"center":"flex-start"},children:u.map(t=>In(Lo,{score:t,scale:e.scale,selected:g(t),colors:o,onPick:()=>(t=>{"submitting"!==a&&(s(t),"instant"===e.submitMode&&c(t))})(t)},t))}),e.labels.low||e.labels.high?In("div",{style:{display:"flex",justifyContent:"space-between",gap:8,paddingTop:4},children:[In("span",{style:_,children:e.labels.low}),In("span",{style:_,children:e.labels.high})]}):null,"error"===a?In("div",{style:{...d.caption,color:o.error,paddingTop:4},children:M}):null,"button"===e.submitMode?In("div",{style:{padding:m},children:In("button",{type:"button",style:{...y("primary",o),..."submitting"===a?{opacity:.7}:{}},onClick:()=>null===r?void 0:c(r),children:e.submitLabel})}):null]})}function Ho({slot:e,align:t,inverse:n,colors:o}){const i=e.color||(n?o.textInverse:o.accent);return In("div",{style:{padding:"4px 0",textAlign:t,lineHeight:0},children:In("svg",{width:e.size,height:e.size,viewBox:"0 0 24 24",fill:"none",stroke:i,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{display:"inline-block"},children:In("path",{d:$[e.name]})})})}function zo({slot:e,align:t,inverse:n,colors:o,mode:i="live",onRequestClose:r,onPageChange:s,onSubmitForm:a,onSubmitChoice:l,onSubmitRating:c,onRequestSubscribe:u}){const d=s??(()=>{});switch(e.type){case"text":return In($o,{slot:e,align:t,inverse:n,colors:o});case"button":return In(Ro,{slot:e,colors:o,onRequestClose:r,onPageChange:d,onRequestSubscribe:u});case"email-subscription-form":return In(jo,{slot:e,align:t,inverse:n,colors:o,onSubmitForm:a});case"timer":return In(Oo,{slot:e,align:t,inverse:n,colors:o,mode:i,onRequestClose:r,onPageChange:d});case"choice":return In(Do,{slot:e,align:t,inverse:n,colors:o,onSubmitChoice:l});case"rating":return In(qo,{slot:e,align:t,inverse:n,colors:o,onSubmitRating:c});case"glyph":return In(Ho,{slot:e,align:t,inverse:n,colors:o})}}function Bo({node:e,page:t,colors:n,mode:o,leaf:i,onRequestClose:r,onPageChange:s,onSubmitForm:a,onSubmitChoice:l,onSubmitRating:c,onRequestSubscribe:u}){const d=t.contents.find(t=>t.key===e.props.content);if(!d)return null;if(i?.renderZone)return In("div",{style:{minWidth:0},children:i.renderZone(d,e)});const p=e.props.align??"left",f="inverse"===e.props.tone;return In("div",{style:{minWidth:0},children:d.slots.map((e,t)=>{const i=d.slots[t-1],h=i?(m=_(i),"action"===(y=_(e))?"action"===m?6:16:"text"===y&&"heading"===m?4:8):0;var m,y;return In("div",{style:h?{marginTop:h}:void 0,children:In(zo,{slot:e,align:p,inverse:f,colors:n,mode:o,onRequestClose:r,onPageChange:s,onSubmitForm:a,onSubmitChoice:l,onSubmitRating:c,onRequestSubscribe:u})},e.key)})})}function Wo(e){return e?.video?Te(e.video.src):void 0}function Uo({image:e,poster:t,src:n,style:o,mode:i}){return In("video",{src:n,poster:t||void 0,style:o,autoPlay:"live"===i,muted:!0,playsInline:!0,preload:"metadata",loop:!1!==e.video?.loop,controls:!0===e.video?.controls})}function Vo({node:e,page:t,leaf:n,mode:o,scheme:i}){const r=t.images.find(t=>t.key===e.props.image);if(!r)return null;if(n?.renderImage)return In(sn,{children:n.renderImage(r,e)});const s=Wo(r),a=Se(r,i);if(!a&&!s)return null;const l={display:"block",width:"100%",minWidth:0};return r.fit?(l.height="100%",l.objectFit=r.fit):l.height="auto",r.blur&&(l.filter=`blur(${r.blur}px)`),s?In(Uo,{image:r,poster:a,src:s,style:l,mode:o}):In("img",{src:a,alt:"",style:l})}function Ko({style:e,outer:t,inner:n,layer:o,children:i}){const{backgroundColor:r,...s}=e;return In("div",{style:{display:"grid",minWidth:0,backgroundColor:r,...t},children:[o,In("div",{style:{...s,...n},children:i})]})}function Zo({node:e,page:t,colors:n,mode:o,scheme:i,leaf:r,onRequestClose:s,onPageChange:a,onSubmitForm:l,onSubmitChoice:c,onSubmitRating:u,onRequestSubscribe:d}){if("Content"===e.type)return In(Bo,{node:e,page:t,colors:n,mode:o,scheme:i,leaf:r,onRequestClose:s,onPageChange:a,onSubmitForm:l,onSubmitChoice:c,onSubmitRating:u,onRequestSubscribe:d});if("Image"===e.type)return In(Vo,{node:e,page:t,leaf:r,mode:o,scheme:i});const p=e.props?.backgroundImage,f=p?t.images.find(e=>e.key===p):void 0,h=f?.blur??0,_=f?.dim??0,m=Wo(f),y=f?Se(f,i):void 0,g=ae(e,h>0||m?void 0:y||void 0,_);p&&(g.backgroundColor="#1D2939");const b=e.children.map((e,p)=>In(Zo,{node:e,page:t,colors:n,mode:o,scheme:i,leaf:r,onRequestClose:s,onPageChange:a,onSubmitForm:l,onSubmitChoice:c,onSubmitRating:u,onRequestSubscribe:d},p));if(m&&f){const e=re(_);return In(Ko,{style:g,outer:{position:"relative",overflow:"hidden",...y?se(y):{}},inner:{position:"relative",...e?{backgroundImage:e}:{}},layer:In(Uo,{image:f,poster:y??"",src:m,mode:o,style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover",...h>0?{filter:`blur(${h}px)`}:{}}}),children:b})}return h>0?In(Ko,{style:g,outer:y?se(y,_):void 0,inner:{backdropFilter:`blur(${h}px)`,WebkitBackdropFilter:`blur(${h}px)`},children:b}):In("div",{style:g,children:b})}function Jo({page:e,params:t,mode:n="live",colorScheme:o="light",leafRenderers:i,animatePage:r=!1,onRequestClose:s,onPageChange:a,onSubmitForm:l,onSubmitChoice:c,onSubmitRating:u,onRequestSubscribe:d}){const p=we(t,o),f=xe(t,o),h={position:"relative",boxSizing:"border-box",overflow:"hidden",backgroundColor:p.background,colorScheme:p.scheme,fontFamily:'Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',color:p.text,borderRadius:t.borderRadius>0?t.borderRadius:void 0,boxShadow:f.boxShadow&&"none"!==f.boxShadow?f.boxShadow:void 0,transition:"height 300ms ease"};e.height&&(h.height="stretch"===e.height?"100%":e.height,h.overflowY="auto");return In("div",{style:h,children:In("div",{style:{...r?{animation:"pw-vpopup-page 300ms ease-out backwards"}:{},..."stretch"===e.height?{display:"grid",minHeight:"100%"}:{}},children:In(Zo,{node:e.layout,page:e,colors:p,mode:n,scheme:p.scheme,leaf:i,onRequestClose:s,onPageChange:a??(()=>{}),onSubmitForm:l,onSubmitChoice:c,onSubmitRating:u,onRequestSubscribe:d})},e.key)})}function Go({colors:e,onRequestClose:t}){return In("button",{type:"button","aria-label":"Close",onClick:t,style:{position:"absolute",top:10,right:10,width:24,height:24,padding:0,border:"none",borderRadius:"50%",background:me(e.surface,.92),boxShadow:"0 1px 3px rgba(16, 24, 40, 0.25)",color:e.chromeIcon,fontSize:13,lineHeight:1,cursor:"pointer"},children:"✕"})}function Qo(e,t,n){const{placement:o}=e,i={position:"fixed",boxSizing:"border-box",maxWidth:_t(o),maxHeight:_t(o),pointerEvents:"auto"};if(t){i.width=t;const e=o.h;"left"===e?i.left=o.offset:"right"===e?i.right=o.offset:i.left="50%"}else i.left=o.offset,i.right=o.offset;"stretch"===n?(i.top=o.offset,i.bottom=o.offset):"top"===o.v?i.top=o.offset:"bottom"===o.v?i.bottom=o.offset:i.top="50%";const r=t&&"center"===o.h?"-50%":"0",s="middle"===o.v&&"stretch"!==n?"-50%":"0";"0"===r&&"0"===s||(i.transform=`translate(${r}, ${s})`);const a=Po[e.animation];return a&&(i.animation=a),i.transition="width 300ms ease",i}function Yo({params:e,mode:t="live",colorScheme:n="auto",onRequestClose:o,onSubmitForm:i,onSubmitChoice:r,onSubmitRating:s,onRequestSubscribe:a,leafRenderers:l}){const[c,u]=Vn(null);Kn(()=>{ht(e).forEach(e=>e.images.forEach(({src:e,srcDark:t})=>{[e,t].forEach(e=>{e&&((new Image).src=e)})}))},[e]);const d=Mo(n,ve(e)),p=ht(e);if(0===p.length)return null;const f=p.find(e=>e.key===c)??function(e,t){return t.find(t=>t.key===e.startPage)??t[0]}(e,p),h=null!==c;if("preview"===t)return In("div",{style:{position:"relative",width:f.width??"100%",transition:"width 300ms ease"},children:[In("style",{children:P}),In(Jo,{page:f,params:e,mode:t,colorScheme:d,leafRenderers:l,animatePage:h,onRequestClose:o,onPageChange:u,onSubmitForm:i,onSubmitChoice:r,onSubmitRating:s,onRequestSubscribe:a})]});const{overlay:_}=xe(e,d);return In(sn,{children:[In("style",{children:P}),_&&In("div",{style:{position:"fixed",inset:0,backgroundColor:_.color,opacity:_.opacity,animation:"pw-vpopup-overlay 0.2s ease-out backwards",pointerEvents:"auto"},onClick:o}),In("div",{style:Qo(e,f.width,f.height),children:[In(Jo,{page:f,params:e,mode:t,colorScheme:d,leafRenderers:l,animatePage:h,onRequestClose:o,onPageChange:u,onSubmitForm:i,onSubmitChoice:r,onSubmitRating:s,onRequestSubscribe:a}),In(Go,{colors:we(e,d),onRequestClose:o})]})]})}const Xo={SUBMIT_FORM_RESULT_SUBSCRIBED:"subscribed",SUBMIT_FORM_RESULT_CONFIRM_EMAIL:"confirm-email",SUBMIT_FORM_RESULT_ALREADY_SUBSCRIBED:"already-subscribed"},ei=(e,t)=>`https://subscription-form.svc-nue.pushwoosh.com/api/v1/forms/code/${encodeURIComponent(e)}${t}`,ti=async(e,t)=>{try{const n=await fetch(ei(e,"/submit"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...t,userId:t.email})});if(!n.ok)throw new Error(`Subscription form submit failed: HTTP ${n.status}`);const o=await n.json(),i=Xo[o.result??""];if(!i)throw new Error(`Subscription form submit failed: unexpected result "${o.result}"`);return i}catch(t){throw Et.error(t,`Failed to submit subscription form "${e}"`),t}};class ni{constructor(e){this.isRecurringVisitor=!1,this.entries=new Map,this.queue=[],this.visible=null,this.drainTimeoutId=null,this.autoShowEnabled=!0,this.colorScheme="auto",this.isNavigationSubscribed=!1,this.openPopupsCount=0,this.bodyOverflowBeforeLock=null,this.readyPromise=new Promise(e=>{this.readyResolve=e}),this.pw=e,this.submitHandlers={onSubmitChoice:Tt(e),onSubmitRating:jt(e),onRequestSubscribe:Nt(e)},e.moduleRegistry.webPopups=this}async run(){const{pw:e}=this;try{this.autoShowEnabled=!1!==e.initParams.webPopups?.autoShow,this.colorScheme=e.initParams.webPopups?.colorScheme??"auto";const t=await e.data.getFeatures();if(!1===t?.popup_forms?.enabled)return void Et.debug(`${yt} application has no active popup forms, skipping`);await e.api.ensureDeviceRegistered(),this.isRecurringVisitor=await e.data.getIsRecurringVisitor();const n=await e.api.getPopupForms();Et.debug(`${yt} Received ${n.length} popup(s) from server:`,n.map(e=>e.code)),n.forEach((e,t)=>{this.entries.set(e.code,{popup:e,order:t,state:"idle",content:null,loading:null,passedStrongConditions:!1,timeoutId:null,visitRecorded:!1})}),await Promise.allSettled(Array.from(this.entries.values()).map(async e=>{e.passedStrongConditions=await this.checkStrongCondition(e.popup),e.passedStrongConditions&&await this.ensureContent(e)}));const o=this.loadedCodes();Et.debug(`${yt} ${o.length} popup(s) passed strong conditions and loaded:`,o),this.subscribeToNavigation(),this.renderForCurrentPage(),await e.data.setIsRecurringVisitor(!0)}finally{this.readyResolve(),e.dispatchEvent("web-popups-ready",{})}}async show(e){await this.readyPromise;const t=this.entries.get(e);if(!t)return Et.error(new Error("Unknown web popup code"),`${yt} show("${e}"): no such popup`),!1;if(this.visible?.code===e)return!0;return await this.ensureContent(t)?this.visible?.code===e||!!this.checkNotExpired(t)&&(this.visible&&(Et.debug(`${yt} show("${e}") preempting "${this.visible.code}"`),this.visible.close("preempted")),this.detachFromAutoPipeline(t),this.present(t,"api"),!0):(Et.error(new Error("Web popup content unavailable"),`${yt} show("${e}"): content unavailable`),!1)}hide(e){return!!this.visible&&((void 0===e||this.visible.code===e)&&(this.visible.close("api"),!0))}hideAll(){const e=this.hide();return this.entries.forEach(e=>{"waiting"!==e.state&&"queued"!==e.state||(this.detachFromAutoPipeline(e),e.state="done")}),this.cancelScheduledDrain(),e}isVisible(e){return!!this.visible&&(void 0===e||this.visible.code===e)}getVisibleCode(){return this.visible?.code??null}getAvailableCodes(){return Array.from(this.entries.keys())}getState(){const e=[];return this.entries.forEach((t,n)=>{"waiting"===t.state&&e.push(n)}),{visible:this.getVisibleCode(),queued:[...this.queue],waiting:e,available:this.getAvailableCodes()}}ensureContent(e){return e.content?Promise.resolve(e.content):(e.loading||(e.loading=this.loadContent(e.popup).then(t=>(e.content=t,t)).catch(t=>(Et.error(t,`${yt} Failed to load web popup "${e.popup.code}"`),null)).finally(()=>{e.content||(e.loading=null)})),e.loading)}async loadContent(e){const t=(e=>{const t=He(e);return t?0===ht(t.params).length?null:t.params:null})((await this.pw.api.getPopupFormContent(e.popup_form_content_code)).json);return t||(Et.error(new Error("Unsupported popup content format"),`${yt} Web popup "${e.code}" content is not a supported {version, params} popup; skipping`),null)}loadedCodes(){const e=[];return this.entries.forEach((t,n)=>{t.content&&e.push(n)}),e}renderForCurrentPage(){this.releaseUnmatchedPending();const e=[];this.entries.forEach((t,n)=>{this.canAutoDisplay(t)&&(this.armDelay(t),e.push(n))}),Et.debug(`${yt} ${e.length} popup(s) selected for display on "${window.location.pathname}":`,e),this.drain()}canAutoDisplay(e){return this.autoShowEnabled&&"idle"===e.state&&e.passedStrongConditions&&this.isAutoTrigger(e.popup)&&null!==e.content&&this.checkSoftCondition(e.popup)&&this.checkNotExpired(e)}isAutoTrigger(e){const t=e.trigger_type;return!t||"PAGE_LOAD"===t}armDelay(e){const{popup:t}=e;Et.debug(`${yt} Popup "${t.code}" armed for display in ${t.delay}s`),e.state="waiting",this.recordVisit(e),e.timeoutId=window.setTimeout(()=>{e.timeoutId=null,e.state="queued",this.insertIntoQueue(e),Et.debug(`${yt} Popup "${t.code}" delay elapsed; queued at position ${this.queue.indexOf(t.code)+1} of ${this.queue.length}`),this.drain()},1e3*t.delay)}recordVisit(e){e.visitRecorded||(e.visitRecorded=!0,this.pw.api.recordPopupFormEvent(e.popup.code,1).catch(t=>{Et.error(t,`${yt} Failed to record web popup visit event for "${e.popup.code}"`)}))}insertIntoQueue(e){const t=this.queue.findIndex(t=>{const n=this.entries.get(t);return!!n&&(n.popup.delay!==e.popup.delay?n.popup.delay>e.popup.delay:n.order>e.order)});-1!==t?this.queue.splice(t,0,e.popup.code):this.queue.push(e.popup.code)}releaseUnmatchedPending(){this.entries.forEach(e=>{"waiting"!==e.state&&"queued"!==e.state||this.checkSoftCondition(e.popup)&&this.checkNotExpired(e)||(this.detachFromAutoPipeline(e),e.state="idle",Et.debug(`${yt} Released popup "${e.popup.code}": page no longer matches, or its countdown passed`))})}detachFromAutoPipeline(e){null!==e.timeoutId&&(window.clearTimeout(e.timeoutId),e.timeoutId=null);const t=this.queue.indexOf(e.popup.code);-1!==t&&this.queue.splice(t,1)}drain(){if(this.visible||null!==this.drainTimeoutId)return;const e=this.queue.shift();if(void 0===e)return;const t=this.entries.get(e);if(t&&"queued"===t.state){if(!this.checkSoftCondition(t.popup)||!this.checkNotExpired(t))return t.state="idle",void this.drain();if(!t.content)return t.state="done",void this.drain();Et.debug(`${yt} Display slot free; showing "${e}"`),this.present(t,"auto")}else this.drain()}scheduleDrain(){null===this.drainTimeoutId&&(this.drainTimeoutId=window.setTimeout(()=>{this.drainTimeoutId=null,this.drain()},400))}cancelScheduledDrain(){null!==this.drainTimeoutId&&(window.clearTimeout(this.drainTimeoutId),this.drainTimeoutId=null)}present(e,t){this.cancelScheduledDrain();const{popup:n,content:o}=e;if(!o)return void(e.state="done");const i=document.createElement("div");i.id=`${mt}-${n.code}`,i.style.position="fixed",i.style.inset="0",i.style.zIndex=String(2147483647),i.style.pointerEvents="none",document.body.appendChild(i);const r=i.attachShadow({mode:"open"}),s=document.createElement("div");r.appendChild(s);const a=!!o.overlay;a&&this.lockBodyScroll();let l=!1;const c=t=>{l||(l=!0,a&&this.unlockBodyScroll(),(e=>{Rn(null,e)})(s),i.remove(),this.visible?.code===n.code&&(this.visible=null),e.state="done",this.pw.dispatchEvent("hide-web-popup",{code:n.code,reason:t}),this.scheduleDrain())};this.visible={code:n.code,host:i,modal:a,close:c},e.state="visible",((e,t,n,o,i="auto")=>{Rn(In(Yo,{params:t,mode:"live",colorScheme:i,onRequestClose:n,onSubmitForm:ti,onSubmitChoice:o.onSubmitChoice,onSubmitRating:o.onSubmitRating,onRequestSubscribe:o.onRequestSubscribe}),e)})(s,o,()=>c("user"),this.submitHandlers,this.colorScheme);const u=function(e){const t=new Set;for(const n of e.pages)if(Array.isArray(n?.contents))for(const e of n.contents)if(Array.isArray(e?.slots))for(const n of e.slots)"object"==typeof n&&null!==n&&"email-subscription-form"===n.type&&"string"==typeof n.formCode&&n.formCode&&t.add(n.formCode);return[...t]}(o);u.length>0&&this.pw.data.getHwid().then(e=>u.forEach(t=>((e,t)=>{fetch(ei(e,"/view"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:e,userId:t,hwid:t})}).catch(t=>{Et.error(t,`Failed to record subscription form view for "${e}"`)})})(t,e))).catch(e=>{Et.error(e,`${yt} Failed to record subscription form views for web popup "${n.code}"`)}),Et.debug(`${yt} Popup "${n.code}" shown (trigger: ${t})`),this.recordVisit(e),this.markAsShown(n).catch(e=>{Et.error(e,`${yt} Failed to mark web popup "${n.code}" as shown`)}),this.pw.dispatchEvent("show-web-popup",{code:n.code,trigger:t})}lockBodyScroll(){0===this.openPopupsCount&&(this.bodyOverflowBeforeLock=document.body.style.overflow,document.body.style.overflow="hidden"),this.openPopupsCount+=1}unlockBodyScroll(){this.openPopupsCount=Math.max(0,this.openPopupsCount-1),0===this.openPopupsCount&&null!==this.bodyOverflowBeforeLock&&(document.body.style.overflow=this.bodyOverflowBeforeLock,this.bodyOverflowBeforeLock=null)}subscribeToNavigation(){if(this.isNavigationSubscribed)return;this.isNavigationSubscribed=!0;const e=()=>this.renderForCurrentPage(),t=window.navigation;if(t&&"function"==typeof t.addEventListener)return void t.addEventListener("currententrychange",e);window.addEventListener("popstate",e),window.addEventListener("hashchange",e);let n=window.location.href;window.setInterval(()=>{window.location.href!==n&&(n=window.location.href,e())},500)}async checkStrongCondition(e){return(await Promise.all([this.checkCanBeShownByDeviceTypeCondition(e),this.checkCanBeShownByFrequencyCondition(e),this.checkCanBeShownByVisitorsTypeCondition(e)])).every(e=>e)}checkSoftCondition(e){return this.checkCanBeShownByMatchingPagesCondition(e)}checkNotExpired(e){return!e.content||(!function(e,t){for(const n of e.pages)if(Array.isArray(n?.contents))for(const e of n.contents)if(Array.isArray(e?.slots))for(const n of e.slots){if("object"!=typeof n||null===n)continue;if("timer"!==n.type||"hide-popup"!==n.onExpire)continue;if("string"!=typeof n.endTime)continue;const e="string"==typeof n.timezone?n.timezone:"",o=Fe(n.endTime,e);if(null!==o&&o<=t)return!0}return!1}(e.content,Date.now())||(Et.debug(`${yt} Popup "${e.popup.code}" not shown: its countdown has passed`),!1))}checkCanBeShownByDeviceTypeCondition(e){const{device_type:t}=e,n=this.pw.platformChecker.formFactor;return"ALL"===t||t===n}async checkCanBeShownByFrequencyCondition(e){const{frequency:t,code:n}=e;if("ONCE"===t){return!(await this.pw.data.getShownWebPopups()).includes(n)}return"ONCE_PER_SESSION"!==t||null===sessionStorage.getItem(this.getSessionStorageKey(n))}checkCanBeShownByMatchingPagesCondition(e){const{matching_pages:t,matching_page_rules:n,excluded_pages:o}=e,i=window.location.pathname;return n&&n.length>0?n.some(e=>this.matchPageRule(i,e)):t&&t.length>0?t.includes(i):!(o&&o.length>0)||!o.some(e=>this.matchPageRule(i,e))}matchPageRule(e,t){switch(t.operator){case"EQUALS":return e===t.path;case"STARTS_WITH":return e.startsWith(t.path);default:return!1}}checkCanBeShownByVisitorsTypeCondition(e){const{visitors_type:t}=e;return"NEW"===t?!this.isRecurringVisitor:"RECURRING"!==t||this.isRecurringVisitor}async markAsShown(e){this.pw.api.recordPopupFormEvent(e.code,2).catch(t=>{Et.error(t,`${yt} Failed to record web popup shown event for "${e.code}"`)});const{frequency:t,code:n}=e;"ONCE"!==t?"ONCE_PER_SESSION"===t&&sessionStorage.setItem(this.getSessionStorageKey(n),"1"):await this.pw.data.addShownWebPopup(n)}getSessionStorageKey(e){return`${mt}.shown.${e}`}}return t})());
1
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("preact"),require("preact/compat"),require("preact/jsx-runtime"));else if("function"==typeof define&&define.amd)define(["preact","preact/compat","preact/jsx-runtime"],t);else{var n="object"==typeof exports?t(require("preact"),require("preact/compat"),require("preact/jsx-runtime")):t(e.preact,e.preactCompat,e.jsxRuntime);for(var o in n)("object"==typeof exports?exports:e)[o]=n[o]}}(this,(e,t,n)=>(()=>{"use strict";var o={524(t){t.exports=e},873(e){e.exports=t},247(e){e.exports=n}};const i={};function r(e){const t=i[e];if(void 0!==t)return t.exports;const n=i[e]={exports:{}};return o[e](n,n.exports,r),n.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};let s={};r.r(s),r.d(s,{WebPopupsWidget:()=>Sn});const a=/^(https?:|mailto:|tel:)/i,c="#101828",l="#667085",u="#FFFFFF",d="#FFFFFF",p="#2970FF",h=c,f=l,m="#FFFFFF",g={h1:{fontSize:24,fontWeight:600,lineHeight:1.25},h2:{fontSize:18,fontWeight:600,lineHeight:1.3},h3:{fontSize:16,fontWeight:600,lineHeight:1.35},body:{fontSize:14,fontWeight:"normal",lineHeight:1.5},caption:{fontSize:12,fontWeight:"normal",lineHeight:1.4},eyebrow:{fontSize:11,fontWeight:600,letterSpacing:"0.08em",lineHeight:1.4},icon:{fontSize:24,lineHeight:1.2}},y={h1:1,h2:1,h3:1,icon:1,eyebrow:.8,body:.9,caption:.75};function b(e,t,n){return n?function(e,t){if(t>=1)return e;const n=/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.exec(e)?.[1];if(!n)return e;const o=3===n.length?n.split("").map(e=>e+e).join(""):n,[i,r,s]=[0,2,4].map(e=>parseInt(o.slice(e,e+2),16));return`rgba(${i}, ${r}, ${s}, ${t})`}(t.textInverse,y[e]??1):"icon"!==e?"caption"===e||"eyebrow"===e?t.textSecondary:t.text:void 0}const v=["h1","h2","h3","icon"];function x(e){return"glyph"===e.type?"heading":"text"!==e.type?"action":v.includes(e.variant)?"heading":"text"}const k="8px 0 4px";function w(e,t){return{display:"block",boxSizing:"border-box",width:"100%",padding:"10px 25px",borderRadius:6,fontSize:14,fontWeight:600,fontFamily:"inherit",lineHeight:1.5,textAlign:"center",textDecoration:"none",cursor:"pointer",..."secondary"===e?{backgroundColor:t.surface,color:t.accent,border:`1px solid ${t.accent}`}:{backgroundColor:t.accent,color:t.onAccent,border:"none"}}}function S(e,t=e.border){return{display:"block",boxSizing:"border-box",width:"100%",padding:"10px 12px",borderRadius:6,fontSize:14,fontFamily:"inherit",lineHeight:1.5,backgroundColor:e.surface,color:e.surfaceText,border:`1px solid ${t}`,outline:"none"}}const j="Subscribe",C="Thanks for subscribing!",M="Please check your inbox and confirm your email.",$="Save",R="Thanks! Your choice is saved.",P="Send",I="Thanks for the feedback!";const A="Something went wrong. Please try again.",F="\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",E={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",gift:"M3 11h18v9a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1zM2.5 7h19v4h-19zM12 7v14M12 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",cart:"M2 4h2.2l2.4 11.2A2 2 0 0 0 8.6 17H19M6 7h15l-2.2 7.5H8M10.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",chart:"M3 21h18M7 21V11M12 21V6M17 21v-8",lock:"M5 11h14v10H5zM8 11V8a4 4 0 0 1 8 0v3",calendar:"M4 6h16v15H4zM4 10h16M9 3v4M15 3v4",check:"M4 13l5 5L20 6",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",clock:"M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0M12 7v5l4 2",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.6l7 7a2 2 0 0 1 0 2.8zM9 8a1 1 0 1 1-2 0 1 1 0 0 1 2 0",mail:"M3 6h18v12H3zM3 7l9 6 9-6",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",download:"M12 3v12M7 11l5 5 5-5M4 20h16",play:"M8 5l12 7-12 7z",shield:"M12 3l8 3v6c0 5-3.4 8.6-8 10-4.6-1.4-8-5-8-10V6z",sparkle:"M12 3l1.8 5.2L19 10l-5.2 1.8L12 17l-1.8-5.2L5 10l5.2-1.8zM18 15l.9 2.1 2.1.9-2.1.9-.9 2.1-.9-2.1L15 18l2.1-.9z",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",truck:"M2 7h12v10H2zM14 10h4l3 3v4h-7M8.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",ticket:"M4 7h16v4a2 2 0 0 0 0 4v3H4v-3a2 2 0 0 0 0-4zM14 7v12",user:"M20 21a8 8 0 0 0-16 0M16 7a4 4 0 1 1-8 0 4 4 0 0 1 8 0"},T=Object.keys(E),q=[24,32,48],N=["Vertical","Horizontal","Columns","Rows"],z=["normal","reverse"],L=["start","center","end","stretch"],D=["start","center","end","space-between"],O=["left","center","right"],B=["default","inverse"],H=2e3,_={px:H,"%":100,em:125,rem:125},V=/^(\d{1,4}(?:\.\d+)?)(px|%|em|rem)$/,W={px:H,"%":100,fr:100},U=/^(\d{1,4}(?:\.\d+)?)(px|%|fr)$/,K=["auto","min-content","max-content"];function Z(e,t){return t.includes(e)?e:void 0}function J(e){if("number"==typeof e&&Number.isFinite(e))return Math.min(Math.max(e,0),H);if("string"!=typeof e)return;const t=V.exec(e.trim());if(!t)return;const[,n,o]=t;return`${Math.min(parseFloat(n),_[o])}${o}`}const G=["top","right","bottom","left"];function Q(e){if(K.includes(e))return e;const t=U.exec(e);if(!t)return;const[,n,o]=t;return`${Math.min(parseFloat(n),W[o])}${o}`}function Y(e){return"string"==typeof e&&e.length>0?e:void 0}function X(e){const t={},n=J(e.gap);void 0!==n&&(t.gap=n);const o=function(e){const t=J(e);if(void 0!==t)return t;if("object"!=typeof e||null===e)return;const n={};for(const t of G){const o=J(e[t]);void 0!==o&&(n[t]=o)}return Object.keys(n).length>0?n:void 0}(e.padding);void 0!==o&&(t.padding=o);const i=Z(e.alignItems,L);i&&(t.alignItems=i);const r=Z(e.justifyContent,D);r&&(t.justifyContent=r);const s=Z(e.alignContent,D);s&&(t.alignContent=s);const a=Y(e.backgroundImage);a&&(t.backgroundImage=a);const c=function(e){if("number"==typeof e)return Number.isInteger(e)&&e>=1&&e<=12?e:void 0;if("string"!=typeof e)return;const t=e.trim().split(/\s+/);if(t.length<1||t.length>12)return;const n=t.map(Q);return n.every(e=>void 0!==e)?n.join(" "):void 0}(e.sizes);return void 0!==c&&(t.sizes=c),t}function ee(e,t,n){if(t>10||n.nodes<=0)return null;if("object"!=typeof e||null===e)return null;n.nodes-=1;const o=e,i="object"==typeof o.props&&null!==o.props?o.props:{};if("Content"===o.type){const e=Y(i.content);if(!e)return null;const t={type:"Content",props:{content:e}},n=Z(i.align,O);n&&(t.props.align=n);const o=Z(i.tone,B);return o&&"default"!==o&&(t.props.tone=o),t}if("Image"===o.type){const e=Y(i.image);if(!e)return null;return{type:"Image",props:{image:e}}}if(!Array.isArray(o.children))return null;const r=Z(o.type,N)??"Vertical",s=[];for(const e of o.children){const o=ee(e,t+1,n);o&&s.push(o)}const a=X(i);return"reverse"===Z(i.order,z)&&(s.reverse(),"string"==typeof a.sizes&&(a.sizes=a.sizes.split(" ").reverse().join(" "))),{type:r,props:a,children:s}}function te(e){return ee(e,0,{nodes:100})}const ne=/^[a-zA-Z][a-zA-Z0-9-]*$/,oe=/^\$([a-zA-Z][a-zA-Z0-9-]*)$/;function ie(e,t){return e.includes("$")?e.split(/(\s+)/).map(e=>{const n=oe.exec(e)?.[1];return void 0!==n&&Object.prototype.hasOwnProperty.call(t,n)?t[n]:e}).join(""):e}function re(e,t){return"object"!=typeof e||null===e||0===Object.keys(t).length?e:ae(e,t,0)}const se=new Set(["content","image","backgroundImage"]);function ae(e,t,n){if(n>10||"object"!=typeof e||null===e)return e;const o=e,i={...o};if("object"==typeof o.props&&null!==o.props){const e={...o.props};for(const[n,o]of Object.entries(e))if(!se.has(n))if("string"==typeof o)e[n]=ie(o,t);else if("object"==typeof o&&null!==o&&!Array.isArray(o)){const i={...o};for(const[e,n]of Object.entries(i))"string"==typeof n&&(i[e]=ie(n,t));e[n]=i}i.props=e}return Array.isArray(o.children)&&(i.children=o.children.map(e=>ae(e,t,n+1))),i}function ce(e){return"number"==typeof e?`${e}px`:e}function le(e,t){if("string"==typeof e)return e;return`repeat(${"number"==typeof e?e:Math.max(t,1)}, 1fr)`}function ue(e=0){if(!(e>0))return null;const t=`rgba(16, 24, 40, ${Math.min(e,1)})`;return`linear-gradient(${t}, ${t})`}function de(e,t=0){const n=`url(${JSON.stringify(e)})`,o=ue(t);return{backgroundImage:o?`${o}, ${n}`:n,backgroundSize:"cover",backgroundPosition:"center"}}function pe(e,t,n=0){const o=e.props??{},i={display:"grid",minWidth:0};return"Horizontal"===e.type&&(i.gridAutoFlow="column"),"Columns"===e.type&&(i.gridTemplateColumns=le(o.sizes,e.children.length)),"Rows"===e.type&&(i.gridTemplateRows=le(o.sizes,e.children.length)),void 0!==o.gap&&(i.gap=ce(o.gap)),void 0!==o.padding&&(i.padding=function(e){if("number"==typeof e||"string"==typeof e)return ce(e);const t=e=>void 0===e?"0":ce(e);return`${t(e.top)} ${t(e.right)} ${t(e.bottom)} ${t(e.left)}`}(o.padding)),o.alignItems&&(i.alignItems=o.alignItems),o.justifyContent&&(i.justifyContent=o.justifyContent),o.alignContent&&(i.alignContent=o.alignContent),t&&Object.assign(i,de(t,n)),i}const he=/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;function fe(e){const t=he.exec(e.trim())?.[1];if(!t)return null;const n=3===t.length?t.split("").map(e=>e+e).join(""):t;return[0,2,4].map(e=>parseInt(n.slice(e,e+2),16))}function me([e,t,n]){return`#${[e,t,n].map(e=>Math.max(0,Math.min(255,Math.round(e))).toString(16).padStart(2,"0")).join("")}`}function ge(e,t,n){let o=n;return o<0&&(o+=1),o>1&&(o-=1),o<1/6?e+6*(t-e)*o:o<.5?t:o<2/3?e+(t-e)*(2/3-o)*6:e}function ye(e){return e>.5?.07+.86*(1-e):e}function be(e){return e<.5?.93-e*((.93-.5)/.5):e}function ve(e,t){const n=fe(e);if(!n)return e;const[o,i,r]=function([e,t,n]){const[o,i,r]=[e/255,t/255,n/255],s=Math.max(o,i,r),a=Math.min(o,i,r),c=(s+a)/2;if(s===a)return[0,0,c];const l=s-a;let u;return u=s===o?(i-r)/l+(i<r?6:0):s===i?(r-o)/l+2:(o-i)/l+4,[u/6,c>.5?l/(2-s-a):l/(s+a),c]}(n);return me(function([e,t,n]){if(0===t){const e=255*n;return[e,e,e]}const o=n<.5?n*(1+t):n+t-n*t,i=2*n-o;return[255*ge(i,o,e+1/3),255*ge(i,o,e),255*ge(i,o,e-1/3)]}([o,i,"fold"===t?ye(r):be(r)]))}function xe(e,t,n){const o=fe(e),i=fe(t);return o&&i?me(o.map((e,t)=>e+(i[t]-e)*n)):e}function ke(e,t){const n=fe(e);if(!n||t>=1)return e;const[o,i,r]=n;return`rgba(${o}, ${i}, ${r}, ${t})`}function we(e){const t=fe(e);if(!t)return!1;const[n,o,i]=t;return(.299*n+.587*o+.114*i)/255>.6}function Se(e){return{background:ve(e.background,"fold"),accent:e.accent,text:ve(e.text,"lift"),textSecondary:ve(e.textSecondary,"lift"),textInverse:e.textInverse}}function je(e,t){return"light"===t?{surface:d,surfaceText:c,border:"#D0D5DD",onAccent:u,error:"#D92D20",chromeIcon:l}:{surface:xe(e.background,e.text,.08),surfaceText:e.text,border:xe(e.background,e.text,.24),onAccent:we(e.accent)?c:u,error:"#FDA29B",chromeIcon:e.textSecondary}}function Ce(e){return!0===e.dark?.enabled}function Me(e,t="light"){return"dark"===t&&Ce(e)?"dark":"light"}function $e(e,t="light"){const n=Me(e,t),o="dark"===n?(i=e.colors,r=e.dark,{...Se(i),...r?.colors??{}}):e.colors;var i,r;return{...o,scheme:n,...je(o,n)}}function Re(e,t="light"){return"dark"===t&&e.srcDark?e.srcDark:e.src}function Pe(e,t="light"){return"light"===Me(e,t)?{overlay:e.overlay,boxShadow:e.boxShadow}:{overlay:e.dark?.overlay??e.overlay,boxShadow:e.dark?.boxShadow??e.boxShadow}}const Ie=/^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2}))?$/,Ae=new Map;function Fe(e){const t=Ae.get(e);if(t)return t;try{const t=new Intl.DateTimeFormat("en-US",{timeZone:e,hour12:!1,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"});return Ae.set(e,t),t}catch{return null}}function Ee(e){return!e||null!==Fe(e)}function Te(e,t){const n=t.formatToParts(new Date(e)),o=e=>Number(n.find(t=>t.type===e)?.value??"0");return Date.UTC(o("year"),o("month")-1,o("day"),o("hour")%24,o("minute"),o("second"))-e}const qe=864e5;const Ne=new Map;function ze(e,t){const n=`${e}|${t}`,o=Ne.get(n);if(void 0!==o)return o;const i=function(e,t){const n=Ie.exec((e||"").trim());if(!n)return null;const[,o,i,r,s,a,c]=n.map(Number),l=Number.isNaN(c)?0:c;if(i<1||i>12||r<1||r>31)return null;if(s>23||a>59||l>59)return null;const u=Date.UTC(o,i-1,r,s,a,l),d=new Date(u);if(d.getUTCMonth()!==i-1||d.getUTCDate()!==r)return null;if(!t)return u;const p=Fe(t);if(!p)return null;const h=function(e,t){const n=[];for(const o of[e-qe,e,e+qe]){const e=Te(o,t);n.includes(e)||n.push(e)}return n}(u,p),f=h.filter(e=>Te(u-e,p)===e).map(e=>u-e);return f.length>0?Math.min(...f):u-Math.min(...h)}(e,t);return Ne.size>100&&Ne.clear(),Ne.set(n,i),i}const Le={en:{days:"Days",hours:"Hours",minutes:"Minutes",seconds:"Seconds"},ru:{days:"Дни",hours:"Часы",minutes:"Минуты",seconds:"Секунды"},de:{days:"Tage",hours:"Stunden",minutes:"Minuten",seconds:"Sekunden"},es:{days:"Días",hours:"Horas",minutes:"Minutos",seconds:"Segundos"},fr:{days:"Jours",hours:"Heures",minutes:"Minutes",seconds:"Secondes"},pt:{days:"Dias",hours:"Horas",minutes:"Minutos",seconds:"Segundos"},ja:{days:"日",hours:"時間",minutes:"分",seconds:"秒"},ko:{days:"일",hours:"시간",minutes:"분",seconds:"초"},zh:{days:"天",hours:"小时",minutes:"分",seconds:"秒"},hi:{days:"दिन",hours:"घंटे",minutes:"मिनट",seconds:"सेकंड"},bn:{days:"দিন",hours:"ঘণ্টা",minutes:"মিনিট",seconds:"সেকেন্ড"},ar:{days:"أيام",hours:"ساعات",minutes:"دقائق",seconds:"ثوان"},he:{days:"ימים",hours:"שעות",minutes:"דקות",seconds:"שניות"},th:{days:"วัน",hours:"ชั่วโมง",minutes:"นาที",seconds:"วินาที"}};function De(e){const t=(e||"").trim();if(t)return t.startsWith("#")||t.startsWith("/")||t.startsWith("?")||a.test(t)?t:void 0}function Oe(e){return"_self"===e?{target:"_self"}:{target:"_blank",rel:"noreferrer"}}const Be=new Set(["STRONG","B","EM","I","U","BR","A"]);function He(e,t,n){for(const o of Array.from(e.childNodes)){if(3===o.nodeType){t.appendChild(n.createTextNode(o.textContent??""));continue}if(1!==o.nodeType)continue;const e=o;if(!Be.has(e.tagName)){He(e,t,n);continue}const i=n.createElement(e.tagName.toLowerCase());if("A"===e.tagName){const t=De(e.getAttribute("href")??void 0);t&&i.setAttribute("href",t);const{target:n,rel:o}=Oe(e.getAttribute("target"));i.setAttribute("target",n),o&&i.setAttribute("rel",o)}t.appendChild(i),He(e,i,n)}}function _e(e){if(!e.includes("<"))return e;const t=(new DOMParser).parseFromString(e,"text/html"),n=t.createElement("div");return He(t.body,n,t),n.innerHTML}function Ve(e){return"string"==typeof e&&e?e:void 0}function We(e,t){const n=e.dark;if("object"!=typeof n||null===n)return;const o=n,i="object"==typeof o.colors&&null!==o.colors?o.colors:{},r=Se(t),s=function(e){if("object"!=typeof e||null===e)return;const t=e,n=Ve(t.color);if(!n)return;return{color:n,opacity:"number"==typeof t.opacity&&Number.isFinite(t.opacity)?Math.max(0,Math.min(1,t.opacity)):1}}(o.overlay);return{enabled:!0===o.enabled,colors:{background:Ve(i.background)??r.background,accent:Ve(i.accent)??r.accent,text:Ve(i.text)??r.text,textSecondary:Ve(i.textSecondary)??r.textSecondary,textInverse:Ve(i.textInverse)??r.textInverse},...s?{overlay:s}:{},...Ve(o.boxShadow)?{boxShadow:o.boxShadow}:{}}}function Ue(e){let t;try{t=JSON.parse(e)}catch{return null}if("object"!=typeof t||null===t)return null;const n=t;if(2!==n.version)return null;const o=n.params;if("object"!=typeof o||null===o)return null;if(!Array.isArray(o.pages)||0===o.pages.length)return null;const i=function(e){const t="object"==typeof e.colors&&null!==e.colors?e.colors:{};return{background:Ve(t.background)??Ve(e.background)??d,accent:Ve(t.accent)??Ve(e.accent)??p,text:Ve(t.text)??h,textSecondary:Ve(t.textSecondary)??f,textInverse:Ve(t.textInverse)??m}}(o),r=We(o,i);return{version:2,params:{...o,colors:i,...r?{dark:r}:{}}}}const Ke=["cover","contain"];function Ze(e){if("object"!=typeof e||null===e)return;const t=e,n=De("string"==typeof t.src?t.src:void 0);return n?{src:n,...!0===t.controls?{controls:!0}:{},...!1===t.loop?{loop:!1}:{}}:void 0}function Je(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(t.length>=20)break;if("object"!=typeof n||null===n)continue;if("string"!=typeof n.key||!n.key)continue;if("string"!=typeof n.src)continue;const e=Ze(n.video);t.push({key:n.key,label:"string"==typeof n.label?n.label:"",src:n.src,..."string"==typeof n.srcDark&&n.srcDark?{srcDark:n.srcDark}:{},...e?{video:e}:{},..."string"==typeof n.mediaId&&n.mediaId?{mediaId:n.mediaId}:{},..."string"==typeof n.mediaIdDark&&n.mediaIdDark?{mediaIdDark:n.mediaIdDark}:{},...Ke.includes(n.fit)?{fit:n.fit}:{},..."number"==typeof n.blur&&Number.isFinite(n.blur)&&n.blur>0?{blur:Math.min(n.blur,100)}:{},..."number"==typeof n.dim&&Number.isFinite(n.dim)&&n.dim>0?{dim:Math.min(n.dim,1)}:{}})}return t}const Ge=["px","%","em","rem","fr"];function Qe(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function Ye(e){if("object"!=typeof e||null===e)return;const t=e;if("text"===t.kind)return{kind:"text"};if("length"===t.kind||"percent"===t.kind){const e=Qe(t.min),n=Qe(t.max),o="length"===t.kind&&Array.isArray(t.units)?t.units.filter(e=>Ge.includes(e)):[],i="length"===t.kind?function(e){if("object"!=typeof e||null===e)return;const t={};for(const n of Ge){const o=e[n];if("object"!=typeof o||null===o)continue;const i=Qe(o.min),r=Qe(o.max);void 0===i&&void 0===r||(t[n]={...void 0!==i?{min:i}:{},...void 0!==r?{max:r}:{}})}return Object.keys(t).length>0?t:void 0}(t.ranges):void 0;return{kind:t.kind,...void 0!==e?{min:e}:{},...void 0!==n?{max:n}:{},...o.length>0?{units:o}:{},...i?{ranges:i}:{}}}if("select"===t.kind&&Array.isArray(t.options)){const e=[];for(const n of t.options){if(e.length>=20)break;"object"==typeof n&&null!==n&&("string"!=typeof n.value||n.value.length>64||e.push({value:n.value,label:"string"==typeof n.label?n.label:n.value}))}if(e.length>0)return{kind:"select",options:e}}}function Xe(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(t.length>=20)break;if("object"!=typeof n||null===n)continue;if("string"!=typeof n.key||!ne.test(n.key))continue;if("string"!=typeof n.value||n.value.length>64||n.value.includes("$"))continue;if(t.some(e=>e.key===n.key))continue;const e=Ye(n.control);t.push({key:n.key,label:"string"==typeof n.label?n.label:"",value:n.value,...e?{control:e}:{}})}return t}function et(e){return Object.fromEntries(e.map(e=>[e.key,e.value]))}const tt=["email","firstName","lastName","phone","custom"],nt=["primary","secondary"];function ot(e){const t=[];if(Array.isArray(e))for(const n of e){if(t.length>=10)break;"object"==typeof n&&null!==n&&("string"==typeof n.key&&n.key&&tt.includes(n.kind)&&(t.some(e=>e.key===n.key)||t.push({key:n.key,kind:n.kind,label:"string"==typeof n.label?n.label:"",placeholder:"string"==typeof n.placeholder?n.placeholder:"",required:"email"===n.kind||!0===n.required,..."custom"===n.kind&&"string"==typeof n.tag&&n.tag?{tag:n.tag}:{}})))}if(!t.some(e=>"email"===e.kind)){let e="field-email";for(;t.some(t=>t.key===e);)e=`${e}-1`;t.unshift({key:e,kind:"email",label:"Email",placeholder:"",required:!0})}return t.slice(0,10)}const it=["checkbox","chips"],rt=["nps","stars","thumbs"],st=["instant","button"],at=["keep","hide-popup","page"],ct=/^[a-z]{2}$/i,lt=/^#[0-9a-fA-F]{6}$/;function ut(e,t=120){return"string"==typeof e?e.trim().slice(0,t):""}function dt(e,t,n=120){return ut(e,n)||t}function pt(e){const t=ut(e,8);return ct.test(t)?t.toLowerCase():""}function ht(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(t.length>=12)break;if("object"!=typeof n||null===n)continue;const e=ut(n.value);if(!e)continue;if(t.some(t=>t.value===e))continue;const o=ut(n.tagValue);t.push({value:e,label:dt(n.label,e),...o?{tagValue:o}:{}})}return t}function ft(e,t){const n=e=>{const n=Qe(e);return void 0===n||n<=0?0:Math.min(Math.floor(n),t)},o=n(e.min),i=n(e.max);return{min:o,max:i>0?Math.max(o,i):0}}function mt(e){const t=[];for(const n of e){if(t.length>=50)break;if("object"==typeof n&&null!==n&&("string"==typeof n.key&&n.key))if("text"!==n.type)if("button"!==n.type){if("timer"===n.type){const e=ut(n.timezone,64),o=Ee(e)?e:"",i=ut(n.endTime,32);if(null===ze(i,o))continue;const r=ut(n.expirePage),s=at.includes(n.onExpire)?n.onExpire:"keep",a="page"!==s||r?s:"keep";t.push({type:"timer",key:n.key,endTime:i,timezone:o,language:pt(n.language),showLabels:!1!==n.showLabels,onExpire:a,..."page"===a?{expirePage:r}:{}});continue}if("choice"===n.type){const e=ht(n.options),{min:o,max:i}=ft(n,e.length);t.push({type:"choice",key:n.key,control:it.includes(n.control)?n.control:"checkbox",tagName:ut(n.tagName),options:e,min:o,max:i,submitLabel:dt(n.submitLabel,$),submitVariant:nt.includes(n.submitVariant)?n.submitVariant:"primary",successMessage:dt(n.successMessage,R,500)});continue}if("rating"===n.type){const e="object"==typeof n.labels&&null!==n.labels?n.labels:{};t.push({type:"rating",key:n.key,scale:rt.includes(n.scale)?n.scale:"stars",labels:{low:ut(e.low),high:ut(e.high)},submitMode:st.includes(n.submitMode)?n.submitMode:"instant",submitLabel:dt(n.submitLabel,P),eventName:ut(n.eventName),successMessage:dt(n.successMessage,I,500)});continue}if("glyph"!==n.type)"email-subscription-form"===n.type&&t.push({type:"email-subscription-form",key:n.key,formCode:"string"==typeof n.formCode?n.formCode:"",fields:ot(n.fields),submitLabel:"string"==typeof n.submitLabel&&n.submitLabel?n.submitLabel:j,submitVariant:nt.includes(n.submitVariant)?n.submitVariant:"primary",..."object"==typeof n.privacy&&null!==n.privacy&&"string"==typeof n.privacy.checkboxLabel?{privacy:{checkboxLabel:n.privacy.checkboxLabel,url:"string"==typeof n.privacy.url?n.privacy.url:"",linkLabel:"string"==typeof n.privacy.linkLabel?n.privacy.linkLabel:""}}:{},successMessage:"string"==typeof n.successMessage&&n.successMessage?n.successMessage:C,confirmEmailMessage:"string"==typeof n.confirmEmailMessage&&n.confirmEmailMessage?n.confirmEmailMessage:M});else{if(!T.includes(n.name))continue;t.push({type:"glyph",key:n.key,name:n.name,size:q.includes(n.size)?n.size:q[0],color:"string"==typeof n.color&&lt.test(n.color)?n.color:""})}}else"object"==typeof n.action&&null!==n.action&&"string"==typeof n.action.type&&t.push(n);else"string"==typeof n.html&&t.push(n)}return t}function gt(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(t.length>=20)break;"object"==typeof n&&null!==n&&("string"==typeof n.key&&n.key&&Array.isArray(n.slots)&&t.push({key:n.key,label:"string"==typeof n.label?n.label:"",slots:mt(n.slots)}))}return t}function yt(e){return"number"==typeof e&&Number.isFinite(e)&&e>0?Math.min(e,2e3):void 0}function bt(e,t,n){if(null===e)return;let o;return o="stretch"===e?"stretch":yt(e)??("stretch"===t?"stretch":yt(t)),"width"===n&&"stretch"===o?void 0:o}function vt(e){const t=[];for(const n of e.pages){const o=Xe(n.values),i=te(re(n.layout,et(o)));if(!i)continue;const r=bt(n.width,e.width,"width"),s=bt(n.height,e.height,"height");t.push({key:n.key,layout:i,images:Je(n.images),contents:gt(n.contents),...void 0!==r?{width:r}:{},...void 0!==s?{height:s}:{}})}return t}function xt(e){return`calc(100% - ${2*e.offset}px)`}const kt="pushwoosh-web-popups",wt="[WebPopups]",St="keyValue",jt="messages",Ct="inboxMessages";function Mt(e,t){return function(n){n.objectStoreNames.contains(e)||t(n)}}const $t=[Mt(St,function(e){e.createObjectStore(St,{keyPath:"key"})}),Mt("log",function(e){const t=e.createObjectStore("log",{keyPath:"id",autoIncrement:!0});t.createIndex("environment","environment",{unique:!1}),t.createIndex("date","date",{unique:!1}),t.createIndex("type","type",{unique:!1})}),Mt(jt,function(e){e.createObjectStore(jt,{keyPath:"id",autoIncrement:!0}).createIndex("date","date",{unique:!1})}),Mt(Ct,function(e){const t="status",n=e.createObjectStore(Ct,{keyPath:"inbox_id",autoIncrement:!1});n.createIndex(t,t,{unique:!1,multiEntry:!0}),n.createIndex("rt","rt",{unique:!1,multiEntry:!0})})];class Rt{get all(){return $t}}class Pt{constructor(e,t=new Rt){this.db=e,this.migrationsBuilder=t}applyMigrations(){this.applyMigrationsPack(this.migrationsBuilder.all)}applyMigrationsPack(e){e.forEach(e=>{e(this.db)})}}function It(e,t){console.info("onversionchange",t),e.close()}let At;function Ft(e){return(At||(At=new Promise((e,t)=>{const n=indexedDB.open("PUSHWOOSH_SDK_STORE",7);n.onsuccess=n=>{const o=n.target.result;o.onversionchange=It.bind(null,o,t),e(o)},n.onerror=()=>t(n.error),n.onupgradeneeded=e=>{const n=e.target.result;n.onversionchange=It.bind(null,n,t),new Pt(n).applyMigrations()}})),At).then(t=>new Promise((n,o)=>e(t,n,o)))}class Et{_add(e){return Ft((t,n,o)=>{const i=t.transaction([this.name],"readwrite").objectStore(this.name).add(e);i.onsuccess=()=>{n(e)},i.onerror=()=>{o(i.error)}}).then(e=>this.getAll().then(t=>{if(Array.isArray(t)){const n=t.map(e=>e.id).sort((e,t)=>e==t?0:e<t?1:-1);if(n.length>this.maxItems)return Promise.all(n.slice(this.maxItems).map(e=>this.delete(e))).then(()=>e)}return e}))}delete(e){return Ft((t,n,o)=>{const i=t.transaction([this.name],"readwrite").objectStore(this.name).delete(e);i.onsuccess=()=>{n(i.result)},i.onerror=()=>{o(i.error)}})}getAll(){return Ft((e,t,n)=>{const o=[],i=e.transaction(this.name).objectStore(this.name).openCursor();i.onsuccess=e=>{const n=e.target.result;n?(n.value&&o.push(n.value),n.continue()):t(o)},i.onerror=()=>{n(i.error)}})}}Tt=St;var Tt;const qt=new class extends Et{constructor(){super(...arguments),this.name="log",this.maxItems=100,this.environment="undefined"!=typeof self&&self.registration?"worker":"browser"}add(e,t,n){const o={type:e,environment:this.environment,message:`${t}`,date:new Date};return t instanceof Error&&(o.stack=t.stack),n&&(o.additional=n),this._add(o)}},Nt=(new class extends Et{constructor(){super(...arguments),this.name=jt,this.maxItems=25}add(e){return this._add({...e,date:new Date})}},{error:1,info:2,debug:3});let zt=3;const Lt={setLevel(e){Nt[e]||(e="error"),zt=Nt[e]},write(e,t,n){return"error"===e?this.error(t):this.info(t),qt.add(e,t,n)}};function Dt(e){return async({slotKey:t,tagName:n,values:o})=>{try{await e.api.setTags({[n]:{operation:"append",value:o}})}catch(e){throw Lt.error(e,`Failed to write web popup choice "${t}" to tag "${n}"`),e}}}function Ot(e){return async({slotKey:t,eventName:n,score:o,scale:i})=>{try{await e.api.postEvent(n,{score:o,scale:i,slotKey:t})}catch(e){throw Lt.error(e,`Failed to post web popup rating "${t}" as event "${n}"`),e}}}function Bt(e){return async()=>{try{await e.subscribe()}catch(e){Lt.error(e,"Failed to subscribe from a web popup")}return e.driver?.getPermission()??"default"}}Object.keys(Nt).forEach(e=>{const t=Nt[e];Lt[e]=(...n)=>{t<=zt&&(console.groupCollapsed(e),console.info("",...n),console.trace("trace"),console.groupEnd())}});var Ht=r(247),_t=r(524),Vt=r(873);const Wt="(prefers-color-scheme: dark)";function Ut(e,t){const[n,o]=(0,Vt.useState)(()=>"auto"===e&&t&&"undefined"!=typeof window&&"function"==typeof window.matchMedia&&window.matchMedia(Wt).matches);return(0,Vt.useEffect)(()=>{if("auto"!==e||!t||"undefined"==typeof window||"function"!=typeof window.matchMedia)return;const n=window.matchMedia(Wt),i=e=>o(e.matches);return o(n.matches),n.addEventListener("change",i),()=>n.removeEventListener("change",i)},[e,t]),"auto"!==e?e:n?"dark":"light"}const Kt={none:void 0,fade:"pw-vpopup-fade 0.35s ease-out backwards",slide:"pw-vpopup-slide 0.35s ease-out backwards"};function Zt({slot:e,align:t,inverse:n,colors:o}){const i={...g[e.variant],textAlign:e.align??t},r=b(e.variant,o,n);return r&&(i.color=r),(0,Ht.jsx)("div",{style:i,dangerouslySetInnerHTML:{__html:_e(e.html)}})}function Jt({slot:e,colors:t,onRequestClose:n,onPageChange:o,onRequestSubscribe:i}){const[r,s]=(0,Vt.useState)("idle"),a=w(e.variant,t),c={};if("close"===e.action.type)return(0,Ht.jsx)("div",{style:c,children:(0,Ht.jsx)("button",{type:"button",style:a,onClick:n,children:e.label})});if("page"===e.action.type){const t=e.action.page;return(0,Ht.jsx)("div",{style:c,children:(0,Ht.jsx)("button",{type:"button",style:a,onClick:()=>o(t),children:e.label})})}if("subscribe"===e.action.type){const t="idle"!==r,o=()=>{i&&!t&&(s("asking"),i().then(e=>{"granted"!==e?s("denied"===e?"denied":"idle"):n?.()}).catch(()=>s("idle")))};return(0,Ht.jsx)("div",{style:c,children:(0,Ht.jsx)("button",{type:"button",disabled:t,style:{...a,...t?{opacity:.7}:{}},onClick:o,children:e.label})})}const l=De(e.action.url);return l?(0,Ht.jsx)("div",{style:c,children:(0,Ht.jsx)("a",{href:l,...Oe(e.action.target),style:a,children:e.label})}):(0,Ht.jsx)("div",{style:c,children:(0,Ht.jsx)("button",{type:"button",style:a,children:e.label})})}function Gt({message:e,align:t,inverse:n,colors:o}){const i=b("body",o,n);return(0,Ht.jsx)("div",{style:{...g.body,padding:"4px 0",textAlign:t,...i?{color:i}:{}},children:e})}const Qt=/^\S+@\S+\.\S+$/,Yt={email:"email",phone:"tel"},Xt={email:"email",firstName:"given-name",lastName:"family-name",phone:"tel"},en="__privacy";function tn({slot:e,align:t,inverse:n,colors:o,onSubmitForm:i}){const[r,s]=(0,Vt.useState)({}),[a,c]=(0,Vt.useState)(!1),[l,u]=(0,Vt.useState)(null),[d,p]=(0,Vt.useState)({}),[h,f]=(0,Vt.useState)("idle"),m=b("caption",o,n),y={...g.caption,...m?{color:m}:{}},v={fontSize:12,lineHeight:1.4,color:o.error,paddingTop:2};if("success"===h||"confirm"===h)return(0,Ht.jsx)(Gt,{message:"confirm"===h?e.confirmEmailMessage:e.successMessage,align:t,inverse:n,colors:o});const x="submitting"===h,j=e.privacy?De(e.privacy.url):void 0,C={...w(e.submitVariant,o),...x?{opacity:.6,cursor:"default"}:{}};return(0,Ht.jsxs)("form",{noValidate:!0,style:{margin:0,textAlign:"left"},onSubmit:t=>{t.preventDefault(),(()=>{if(!i||!e.formCode||"submitting"===h)return;const t={};for(const n of e.fields){const e=(r[n.key]??"").trim();n.required&&!e?t[n.key]="Required":"email"===n.kind&&e&&!Qt.test(e)&&(t[n.key]="Enter a valid email")}if(e.privacy&&!a&&(t[en]="Please accept the privacy policy"),p(t),Object.keys(t).length>0)return;const n={email:"",policyAccepted:!e.privacy||a},o={};for(const t of e.fields){const e=(r[t.key]??"").trim();e&&("email"===t.kind?n.email=n.email||e:"firstName"===t.kind?n.firstName=e:"lastName"===t.kind?n.lastName=e:"phone"===t.kind?n.phone=e:o[t.tag||t.key]=e)}Object.keys(o).length>0&&(n.customFields=o),f("submitting"),Promise.resolve().then(()=>i(e.formCode,n)).then(e=>f("confirm-email"===e?"confirm":"success"),()=>f("error"))})()},children:[e.fields.map(e=>{const t=d[e.key];let n;return t?n=o.error:l===e.key&&(n=o.accent),(0,Ht.jsxs)("div",{style:{padding:"4px 0"},children:[e.label&&(0,Ht.jsx)("div",{style:{...y,paddingBottom:4},children:e.label}),(0,Ht.jsx)("input",{type:Yt[e.kind]??"text",autoComplete:Xt[e.kind],placeholder:e.placeholder||void 0,value:r[e.key]??"",disabled:x,style:S(o,n),onFocus:()=>u(e.key),onBlur:()=>u(t=>t===e.key?null:t),onChange:t=>{return n=e.key,o=t.currentTarget.value,s(e=>({...e,[n]:o})),void p(e=>e[n]?Object.fromEntries(Object.entries(e).filter(([e])=>e!==n)):e);var n,o}}),t&&(0,Ht.jsx)("div",{style:v,children:t})]},e.key)}),e.privacy&&(0,Ht.jsxs)("div",{style:{padding:"4px 0"},children:[(0,Ht.jsxs)("label",{style:{...y,display:"flex",alignItems:"flex-start",gap:8,cursor:"pointer"},children:[(0,Ht.jsx)("input",{type:"checkbox",checked:a,disabled:x,style:{margin:"2px 0 0",flexShrink:0},onChange:e=>{c(e.currentTarget.checked),p(e=>e[en]?Object.fromEntries(Object.entries(e).filter(([e])=>e!==en)):e)}}),(0,Ht.jsxs)("span",{children:[e.privacy.checkboxLabel,j&&(0,Ht.jsxs)(Ht.Fragment,{children:[" ",(0,Ht.jsx)("a",{href:j,...Oe(void 0),style:{color:o.accent},children:e.privacy.linkLabel||e.privacy.url})]})]})]}),d[en]&&(0,Ht.jsx)("div",{style:v,children:d[en]})]}),(0,Ht.jsx)("div",{style:{padding:k},children:(0,Ht.jsx)("button",{type:"submit",disabled:x,style:C,children:e.submitLabel})}),"error"===h&&(0,Ht.jsx)("div",{style:{...v,textAlign:t},children:A})]})}function nn({value:e,label:t,digitStyle:n,labelStyle:o}){return(0,Ht.jsxs)("div",{style:{minWidth:44},children:[(0,Ht.jsx)("div",{style:n,children:String(e).padStart(2,"0")}),t?(0,Ht.jsx)("div",{style:o,children:t}):null]})}function on({slot:e,align:t,inverse:n,colors:o,mode:i,onRequestClose:r,onPageChange:s}){const[a,c]=(0,Vt.useState)(()=>Date.now()),l=function(e,t,n){const o=ze(e,t),i=null===o?0:Math.max(0,o-n),r=Math.floor(i/1e3);return{total:i,days:Math.floor(r/86400),hours:Math.floor(r/3600)%24,minutes:Math.floor(r/60)%60,seconds:r%60}}(e.endTime,e.timezone,a),u=0===l.total;(0,Vt.useEffect)(()=>{if("live"!==i||u)return;const e=setInterval(()=>c(Date.now()),1e3);return()=>clearInterval(e)},[i,u,e.endTime,e.timezone]),(0,Vt.useEffect)(()=>{"live"===i&&u&&("hide-popup"===e.onExpire?r?.():"page"===e.onExpire&&e.expirePage&&s(e.expirePage))},[i,u,e.onExpire,e.expirePage,r,s]);const d=b("h2",o,n),p=b("caption",o,n),h={fontSize:28,fontWeight:700,lineHeight:1.2,fontVariantNumeric:"tabular-nums",...d?{color:d}:{}},f={...g.caption,...p?{color:p}:{}},m=(y=e.language,Le[y]??Le.en);var y;const v=[{value:l.days,label:m.days},{value:l.hours,label:m.hours},{value:l.minutes,label:m.minutes},{value:l.seconds,label:m.seconds}];return(0,Ht.jsx)("div",{style:{padding:"4px 0",textAlign:t},children:(0,Ht.jsx)("div",{style:{display:"inline-flex",gap:12,textAlign:"center"},children:v.map(t=>(0,Ht.jsx)(nn,{value:t.value,label:e.showLabels?t.label:"",digitStyle:h,labelStyle:f},t.label||t.value))})})}function rn({slot:e,align:t,inverse:n,colors:o,onSubmitChoice:i}){const[r,s]=(0,Vt.useState)([]),[a,c]=(0,Vt.useState)("idle"),[l,u]=(0,Vt.useState)("");if("success"===a)return(0,Ht.jsx)(Gt,{message:e.successMessage,align:t,inverse:n,colors:o});const d=t=>{u(""),s(n=>n.includes(t)?n.filter(e=>e!==t):e.max>0&&n.length>=e.max?(u(`Pick up to ${e.max}`),n):[...n,t])},p="submitting"===a,h=b("body",o,n),f={...g.body,...h?{color:h}:{}};return(0,Ht.jsxs)("div",{style:{padding:"4px 0"},children:["chips"===e.control?(0,Ht.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:8,justifyContent:"center"===t?"center":"flex-start"},children:e.options.map(e=>{return(0,Ht.jsx)("button",{type:"button","aria-pressed":r.includes(e.value),style:(t=r.includes(e.value),{padding:"6px 14px",borderRadius:999,border:`1px solid ${o.accent}`,backgroundColor:t?o.accent:"transparent",color:t?o.onAccent:o.accent,fontFamily:"inherit",fontSize:14,lineHeight:1.4,cursor:"pointer"}),onClick:()=>d(e.value),children:e.label},e.value);var t})}):(0,Ht.jsx)("div",{style:{display:"grid",gap:6},children:e.options.map(e=>(0,Ht.jsxs)("label",{style:{...f,display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[(0,Ht.jsx)("input",{type:"checkbox",checked:r.includes(e.value),onChange:()=>d(e.value),style:{accentColor:o.accent,width:16,height:16,margin:0}}),e.label]},e.value))}),l?(0,Ht.jsx)("div",{style:{...g.caption,color:o.error,paddingTop:4},children:l}):null,"error"===a?(0,Ht.jsx)("div",{style:{...g.caption,color:o.error,paddingTop:4},children:A}):null,(0,Ht.jsx)("div",{style:{padding:k},children:(0,Ht.jsx)("button",{type:"button",style:{...w(e.submitVariant,o),...p?{opacity:.7}:{}},onClick:()=>{if(!i||!e.tagName||"submitting"===a)return;const t=Math.max(e.min,1);if(r.length<t)return void u(1===t?"Pick at least one":`Pick at least ${t}`);const n=e.options.filter(e=>r.includes(e.value)).map(e=>e.tagValue||e.value);u(""),c("submitting"),Promise.resolve().then(()=>i({slotKey:e.key,tagName:e.tagName,values:n})).then(()=>c("success"),()=>c("error"))},children:e.submitLabel})})]})}function sn({score:e,scale:t,selected:n,colors:o,onPick:i}){const r={display:"inline-flex",alignItems:"center",justifyContent:"center",padding:0,border:`1px solid ${o.accent}`,backgroundColor:n?o.accent:"transparent",color:n?o.onAccent:o.accent,fontFamily:"inherit",fontSize:14,lineHeight:1,cursor:"pointer"};if("nps"===t)return(0,Ht.jsx)("button",{type:"button","aria-label":`Rate ${e}`,"aria-pressed":n,style:{...r,width:30,height:32,borderRadius:6},onClick:i,children:e});const s="thumbs"===t;let a=`Rate ${e}`;return s&&(a=1===e?"Thumbs up":"Thumbs down"),(0,Ht.jsx)("button",{type:"button","aria-label":a,"aria-pressed":n,style:{...r,width:s?44:34,height:s?40:34,borderRadius:s?8:6},onClick:i,children:(0,Ht.jsx)("svg",{width:s?22:20,height:s?22:20,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,Ht.jsx)("path",{d:s?"M8 21V10l3.5-7A2 2 0 0 1 14 5v5h4.5a2 2 0 0 1 2 2.4l-1.3 6A2 2 0 0 1 17.2 21zM8 10H3.5v11H8":E.star,...s&&0===e?{transform:"rotate(180 12 12)"}:{}})})})}function an({slot:e,align:t,inverse:n,colors:o,onSubmitRating:i}){const[r,s]=(0,Vt.useState)(null),[a,c]=(0,Vt.useState)("idle");if("success"===a)return(0,Ht.jsx)(Gt,{message:e.successMessage,align:t,inverse:n,colors:o});const l=t=>{i&&e.eventName&&"submitting"!==a&&(c("submitting"),Promise.resolve().then(()=>i({slotKey:e.key,eventName:e.eventName,score:t,scale:e.scale})).then(()=>c("success"),()=>c("error")))},u="nps"===(d=e.scale)?[0,1,2,3,4,5,6,7,8,9,10]:"stars"===d?[1,2,3,4,5]:[0,1];var d;const p=b("caption",o,n),h={...g.caption,...p?{color:p}:{}},f=t=>"stars"===e.scale?null!==r&&t<=r:r===t;return(0,Ht.jsxs)("div",{style:{padding:"4px 0"},children:[(0,Ht.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:6,justifyContent:"center"===t?"center":"flex-start"},children:u.map(t=>(0,Ht.jsx)(sn,{score:t,scale:e.scale,selected:f(t),colors:o,onPick:()=>(t=>{"submitting"!==a&&(s(t),"instant"===e.submitMode&&l(t))})(t)},t))}),e.labels.low||e.labels.high?(0,Ht.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",gap:8,paddingTop:4},children:[(0,Ht.jsx)("span",{style:h,children:e.labels.low}),(0,Ht.jsx)("span",{style:h,children:e.labels.high})]}):null,"error"===a?(0,Ht.jsx)("div",{style:{...g.caption,color:o.error,paddingTop:4},children:A}):null,"button"===e.submitMode?(0,Ht.jsx)("div",{style:{padding:k},children:(0,Ht.jsx)("button",{type:"button",style:{...w("primary",o),..."submitting"===a?{opacity:.7}:{}},onClick:()=>null===r?void 0:l(r),children:e.submitLabel})}):null]})}function cn({slot:e,align:t,inverse:n,colors:o}){const i=e.color||(n?o.textInverse:o.accent);return(0,Ht.jsx)("div",{style:{padding:"4px 0",textAlign:t,lineHeight:0},children:(0,Ht.jsx)("svg",{width:e.size,height:e.size,viewBox:"0 0 24 24",fill:"none",stroke:i,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{display:"inline-block"},children:(0,Ht.jsx)("path",{d:E[e.name]})})})}function ln({slot:e,align:t,inverse:n,colors:o,mode:i="live",onRequestClose:r,onPageChange:s,onSubmitForm:a,onSubmitChoice:c,onSubmitRating:l,onRequestSubscribe:u}){const d=s??(()=>{});switch(e.type){case"text":return(0,Ht.jsx)(Zt,{slot:e,align:t,inverse:n,colors:o});case"button":return(0,Ht.jsx)(Jt,{slot:e,colors:o,onRequestClose:r,onPageChange:d,onRequestSubscribe:u});case"email-subscription-form":return(0,Ht.jsx)(tn,{slot:e,align:t,inverse:n,colors:o,onSubmitForm:a});case"timer":return(0,Ht.jsx)(on,{slot:e,align:t,inverse:n,colors:o,mode:i,onRequestClose:r,onPageChange:d});case"choice":return(0,Ht.jsx)(rn,{slot:e,align:t,inverse:n,colors:o,onSubmitChoice:c});case"rating":return(0,Ht.jsx)(an,{slot:e,align:t,inverse:n,colors:o,onSubmitRating:l});case"glyph":return(0,Ht.jsx)(cn,{slot:e,align:t,inverse:n,colors:o})}}function un({node:e,page:t,colors:n,mode:o,leaf:i,onRequestClose:r,onPageChange:s,onSubmitForm:a,onSubmitChoice:c,onSubmitRating:l,onRequestSubscribe:u}){const d=t.contents.find(t=>t.key===e.props.content);if(!d)return null;if(i?.renderZone)return(0,Ht.jsx)("div",{style:{minWidth:0},children:i.renderZone(d,e)});const p=e.props.align??"left",h="inverse"===e.props.tone;return(0,Ht.jsx)("div",{style:{minWidth:0},children:d.slots.map((e,t)=>{const i=d.slots[t-1],f=i?(m=x(i),"action"===(g=x(e))?"action"===m?6:16:"text"===g&&"heading"===m?4:8):0;var m,g;return(0,Ht.jsx)("div",{style:f?{marginTop:f}:void 0,children:(0,Ht.jsx)(ln,{slot:e,align:p,inverse:h,colors:n,mode:o,onRequestClose:r,onPageChange:s,onSubmitForm:a,onSubmitChoice:c,onSubmitRating:l,onRequestSubscribe:u})},e.key)})})}function dn(e){return e?.video?De(e.video.src):void 0}function pn({image:e,poster:t,src:n,style:o,mode:i}){return(0,Ht.jsx)("video",{src:n,poster:t||void 0,style:o,autoPlay:"live"===i,muted:!0,playsInline:!0,preload:"metadata",loop:!1!==e.video?.loop,controls:!0===e.video?.controls})}function hn({node:e,page:t,leaf:n,mode:o,scheme:i}){const r=t.images.find(t=>t.key===e.props.image);if(!r)return null;if(n?.renderImage)return(0,Ht.jsx)(Ht.Fragment,{children:n.renderImage(r,e)});const s=dn(r),a=Re(r,i);if(!a&&!s)return null;const c={display:"block",width:"100%",minWidth:0};return r.fit?(c.height="100%",c.objectFit=r.fit):c.height="auto",r.blur&&(c.filter=`blur(${r.blur}px)`),s?(0,Ht.jsx)(pn,{image:r,poster:a,src:s,style:c,mode:o}):(0,Ht.jsx)("img",{src:a,alt:"",style:c})}function fn({style:e,outer:t,inner:n,layer:o,children:i}){const{backgroundColor:r,...s}=e;return(0,Ht.jsxs)("div",{style:{display:"grid",minWidth:0,backgroundColor:r,...t},children:[o,(0,Ht.jsx)("div",{style:{...s,...n},children:i})]})}function mn({node:e,page:t,colors:n,mode:o,scheme:i,leaf:r,onRequestClose:s,onPageChange:a,onSubmitForm:c,onSubmitChoice:l,onSubmitRating:u,onRequestSubscribe:d}){if("Content"===e.type)return(0,Ht.jsx)(un,{node:e,page:t,colors:n,mode:o,scheme:i,leaf:r,onRequestClose:s,onPageChange:a,onSubmitForm:c,onSubmitChoice:l,onSubmitRating:u,onRequestSubscribe:d});if("Image"===e.type)return(0,Ht.jsx)(hn,{node:e,page:t,leaf:r,mode:o,scheme:i});const p=e.props?.backgroundImage,h=p?t.images.find(e=>e.key===p):void 0,f=h?.blur??0,m=h?.dim??0,g=dn(h),y=h?Re(h,i):void 0,b=pe(e,f>0||g?void 0:y||void 0,m);p&&(b.backgroundColor="#1D2939");const v=e.children.map((e,p)=>(0,Ht.jsx)(mn,{node:e,page:t,colors:n,mode:o,scheme:i,leaf:r,onRequestClose:s,onPageChange:a,onSubmitForm:c,onSubmitChoice:l,onSubmitRating:u,onRequestSubscribe:d},p));if(g&&h){const e=ue(m);return(0,Ht.jsx)(fn,{style:b,outer:{position:"relative",overflow:"hidden",...y?de(y):{}},inner:{position:"relative",...e?{backgroundImage:e}:{}},layer:(0,Ht.jsx)(pn,{image:h,poster:y??"",src:g,mode:o,style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover",...f>0?{filter:`blur(${f}px)`}:{}}}),children:v})}return f>0?(0,Ht.jsx)(fn,{style:b,outer:y?de(y,m):void 0,inner:{backdropFilter:`blur(${f}px)`,WebkitBackdropFilter:`blur(${f}px)`},children:v}):(0,Ht.jsx)("div",{style:b,children:v})}function gn({page:e,params:t,mode:n="live",colorScheme:o="light",leafRenderers:i,animatePage:r=!1,onRequestClose:s,onPageChange:a,onSubmitForm:c,onSubmitChoice:l,onSubmitRating:u,onRequestSubscribe:d}){const p=$e(t,o),h=Pe(t,o),f={position:"relative",boxSizing:"border-box",overflow:"hidden",backgroundColor:p.background,colorScheme:p.scheme,fontFamily:'Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',color:p.text,borderRadius:t.borderRadius>0?t.borderRadius:void 0,boxShadow:h.boxShadow&&"none"!==h.boxShadow?h.boxShadow:void 0,transition:"height 300ms ease"};e.height&&(f.height="stretch"===e.height?"100%":e.height,f.overflowY="auto");const m={...r?{animation:"pw-vpopup-page 300ms ease-out backwards"}:{},..."stretch"===e.height?{display:"grid",minHeight:"100%"}:{}};return(0,Ht.jsx)("div",{style:f,children:(0,Ht.jsx)("div",{style:m,children:(0,Ht.jsx)(mn,{node:e.layout,page:e,colors:p,mode:n,scheme:p.scheme,leaf:i,onRequestClose:s,onPageChange:a??(()=>{}),onSubmitForm:c,onSubmitChoice:l,onSubmitRating:u,onRequestSubscribe:d})},e.key)})}function yn({colors:e,onRequestClose:t}){return(0,Ht.jsx)("button",{type:"button","aria-label":"Close",onClick:t,style:{position:"absolute",top:10,right:10,width:24,height:24,padding:0,border:"none",borderRadius:"50%",background:ke(e.surface,.92),boxShadow:"0 1px 3px rgba(16, 24, 40, 0.25)",color:e.chromeIcon,fontSize:13,lineHeight:1,cursor:"pointer"},children:"✕"})}function bn(e,t,n){const{placement:o}=e,i={position:"fixed",boxSizing:"border-box",maxWidth:xt(o),maxHeight:xt(o),pointerEvents:"auto"};if(t){i.width=t;const e=o.h;"left"===e?i.left=o.offset:"right"===e?i.right=o.offset:i.left="50%"}else i.left=o.offset,i.right=o.offset;"stretch"===n?(i.top=o.offset,i.bottom=o.offset):"top"===o.v?i.top=o.offset:"bottom"===o.v?i.bottom=o.offset:i.top="50%";const r=t&&"center"===o.h?"-50%":"0",s="middle"===o.v&&"stretch"!==n?"-50%":"0";"0"===r&&"0"===s||(i.transform=`translate(${r}, ${s})`);const a=Kt[e.animation];return a&&(i.animation=a),i.transition="width 300ms ease",i}function vn({params:e,mode:t="live",colorScheme:n="auto",onRequestClose:o,onSubmitForm:i,onSubmitChoice:r,onSubmitRating:s,onRequestSubscribe:a,leafRenderers:c}){const[l,u]=(0,Vt.useState)(null);(0,Vt.useEffect)(()=>{vt(e).forEach(e=>e.images.forEach(({src:e,srcDark:t})=>{[e,t].forEach(e=>{e&&((new Image).src=e)})}))},[e]);const d=Ut(n,Ce(e)),p=vt(e);if(0===p.length)return null;const h=p.find(e=>e.key===l)??function(e,t){return t.find(t=>t.key===e.startPage)??t[0]}(e,p),f=null!==l;if("preview"===t)return(0,Ht.jsxs)("div",{style:{position:"relative",width:h.width??"100%",transition:"width 300ms ease"},children:[(0,Ht.jsx)("style",{children:F}),(0,Ht.jsx)(gn,{page:h,params:e,mode:t,colorScheme:d,leafRenderers:c,animatePage:f,onRequestClose:o,onPageChange:u,onSubmitForm:i,onSubmitChoice:r,onSubmitRating:s,onRequestSubscribe:a})]});const{overlay:m}=Pe(e,d);return(0,Ht.jsxs)(Ht.Fragment,{children:[(0,Ht.jsx)("style",{children:F}),m&&(0,Ht.jsx)("div",{style:{position:"fixed",inset:0,backgroundColor:m.color,opacity:m.opacity,animation:"pw-vpopup-overlay 0.2s ease-out backwards",pointerEvents:"auto"},onClick:o}),(0,Ht.jsxs)("div",{style:bn(e,h.width,h.height),children:[(0,Ht.jsx)(gn,{page:h,params:e,mode:t,colorScheme:d,leafRenderers:c,animatePage:f,onRequestClose:o,onPageChange:u,onSubmitForm:i,onSubmitChoice:r,onSubmitRating:s,onRequestSubscribe:a}),(0,Ht.jsx)(yn,{colors:$e(e,d),onRequestClose:o})]})]})}const xn={SUBMIT_FORM_RESULT_SUBSCRIBED:"subscribed",SUBMIT_FORM_RESULT_CONFIRM_EMAIL:"confirm-email",SUBMIT_FORM_RESULT_ALREADY_SUBSCRIBED:"already-subscribed"},kn=(e,t)=>`https://subscription-form.svc-nue.pushwoosh.com/api/v1/forms/code/${encodeURIComponent(e)}${t}`,wn=async(e,t)=>{try{const n=await fetch(kn(e,"/submit"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...t,userId:t.email})});if(!n.ok)throw new Error(`Subscription form submit failed: HTTP ${n.status}`);const o=await n.json(),i=xn[o.result??""];if(!i)throw new Error(`Subscription form submit failed: unexpected result "${o.result}"`);return i}catch(t){throw Lt.error(t,`Failed to submit subscription form "${e}"`),t}};class Sn{constructor(e){this.isRecurringVisitor=!1,this.entries=new Map,this.queue=[],this.visible=null,this.drainTimeoutId=null,this.autoShowEnabled=!0,this.colorScheme="auto",this.isNavigationSubscribed=!1,this.openPopupsCount=0,this.bodyOverflowBeforeLock=null,this.readyPromise=new Promise(e=>{this.readyResolve=e}),this.pw=e,this.submitHandlers={onSubmitChoice:Dt(e),onSubmitRating:Ot(e),onRequestSubscribe:Bt(e)},e.moduleRegistry.webPopups=this}async run(){const{pw:e}=this;try{this.autoShowEnabled=!1!==e.initParams.webPopups?.autoShow,this.colorScheme=e.initParams.webPopups?.colorScheme??"auto";const t=await e.data.getFeatures();if(!1===t?.popup_forms?.enabled)return void Lt.debug(`${wt} application has no active popup forms, skipping`);await e.api.ensureDeviceRegistered(),this.isRecurringVisitor=await e.data.getIsRecurringVisitor();const n=await e.api.getPopupForms();Lt.debug(`${wt} Received ${n.length} popup(s) from server:`,n.map(e=>e.code)),n.forEach((e,t)=>{this.entries.set(e.code,{popup:e,order:t,state:"idle",content:null,loading:null,passedStrongConditions:!1,timeoutId:null,visitRecorded:!1})}),await Promise.allSettled(Array.from(this.entries.values()).map(async e=>{e.passedStrongConditions=await this.checkStrongCondition(e.popup),e.passedStrongConditions&&await this.ensureContent(e)}));const o=this.loadedCodes();Lt.debug(`${wt} ${o.length} popup(s) passed strong conditions and loaded:`,o),this.subscribeToNavigation(),this.renderForCurrentPage(),await e.data.setIsRecurringVisitor(!0)}finally{this.readyResolve(),e.dispatchEvent("web-popups-ready",{})}}async show(e){await this.readyPromise;const t=this.entries.get(e);if(!t)return Lt.error(new Error("Unknown web popup code"),`${wt} show("${e}"): no such popup`),!1;if(this.visible?.code===e)return!0;return await this.ensureContent(t)?this.visible?.code===e||!!this.checkNotExpired(t)&&(this.visible&&(Lt.debug(`${wt} show("${e}") preempting "${this.visible.code}"`),this.visible.close("preempted")),this.detachFromAutoPipeline(t),this.present(t,"api"),!0):(Lt.error(new Error("Web popup content unavailable"),`${wt} show("${e}"): content unavailable`),!1)}hide(e){return!!this.visible&&((void 0===e||this.visible.code===e)&&(this.visible.close("api"),!0))}hideAll(){const e=this.hide();return this.entries.forEach(e=>{"waiting"!==e.state&&"queued"!==e.state||(this.detachFromAutoPipeline(e),e.state="done")}),this.cancelScheduledDrain(),e}isVisible(e){return!!this.visible&&(void 0===e||this.visible.code===e)}getVisibleCode(){return this.visible?.code??null}getAvailableCodes(){return Array.from(this.entries.keys())}getState(){const e=[];return this.entries.forEach((t,n)=>{"waiting"===t.state&&e.push(n)}),{visible:this.getVisibleCode(),queued:[...this.queue],waiting:e,available:this.getAvailableCodes()}}ensureContent(e){return e.content?Promise.resolve(e.content):(e.loading||(e.loading=this.loadContent(e.popup).then(t=>(e.content=t,t)).catch(t=>(Lt.error(t,`${wt} Failed to load web popup "${e.popup.code}"`),null)).finally(()=>{e.content||(e.loading=null)})),e.loading)}async loadContent(e){const t=(e=>{const t=Ue(e);return t?0===vt(t.params).length?null:t.params:null})((await this.pw.api.getPopupFormContent(e.popup_form_content_code)).json);return t||(Lt.error(new Error("Unsupported popup content format"),`${wt} Web popup "${e.code}" content is not a supported {version, params} popup; skipping`),null)}loadedCodes(){const e=[];return this.entries.forEach((t,n)=>{t.content&&e.push(n)}),e}renderForCurrentPage(){this.releaseUnmatchedPending();const e=[];this.entries.forEach((t,n)=>{this.canAutoDisplay(t)&&(this.armDelay(t),e.push(n))}),Lt.debug(`${wt} ${e.length} popup(s) selected for display on "${window.location.pathname}":`,e),this.drain()}canAutoDisplay(e){return this.autoShowEnabled&&"idle"===e.state&&e.passedStrongConditions&&this.isAutoTrigger(e.popup)&&null!==e.content&&this.checkSoftCondition(e.popup)&&this.checkNotExpired(e)}isAutoTrigger(e){const t=e.trigger_type;return!t||"PAGE_LOAD"===t}armDelay(e){const{popup:t}=e;Lt.debug(`${wt} Popup "${t.code}" armed for display in ${t.delay}s`),e.state="waiting",this.recordVisit(e),e.timeoutId=window.setTimeout(()=>{e.timeoutId=null,e.state="queued",this.insertIntoQueue(e),Lt.debug(`${wt} Popup "${t.code}" delay elapsed; queued at position ${this.queue.indexOf(t.code)+1} of ${this.queue.length}`),this.drain()},1e3*t.delay)}recordVisit(e){e.visitRecorded||(e.visitRecorded=!0,this.pw.api.recordPopupFormEvent(e.popup.code,1).catch(t=>{Lt.error(t,`${wt} Failed to record web popup visit event for "${e.popup.code}"`)}))}insertIntoQueue(e){const t=this.queue.findIndex(t=>{const n=this.entries.get(t);return!!n&&(n.popup.delay!==e.popup.delay?n.popup.delay>e.popup.delay:n.order>e.order)});-1!==t?this.queue.splice(t,0,e.popup.code):this.queue.push(e.popup.code)}releaseUnmatchedPending(){this.entries.forEach(e=>{"waiting"!==e.state&&"queued"!==e.state||this.checkSoftCondition(e.popup)&&this.checkNotExpired(e)||(this.detachFromAutoPipeline(e),e.state="idle",Lt.debug(`${wt} Released popup "${e.popup.code}": page no longer matches, or its countdown passed`))})}detachFromAutoPipeline(e){null!==e.timeoutId&&(window.clearTimeout(e.timeoutId),e.timeoutId=null);const t=this.queue.indexOf(e.popup.code);-1!==t&&this.queue.splice(t,1)}drain(){if(this.visible||null!==this.drainTimeoutId)return;const e=this.queue.shift();if(void 0===e)return;const t=this.entries.get(e);if(t&&"queued"===t.state){if(!this.checkSoftCondition(t.popup)||!this.checkNotExpired(t))return t.state="idle",void this.drain();if(!t.content)return t.state="done",void this.drain();Lt.debug(`${wt} Display slot free; showing "${e}"`),this.present(t,"auto")}else this.drain()}scheduleDrain(){null===this.drainTimeoutId&&(this.drainTimeoutId=window.setTimeout(()=>{this.drainTimeoutId=null,this.drain()},400))}cancelScheduledDrain(){null!==this.drainTimeoutId&&(window.clearTimeout(this.drainTimeoutId),this.drainTimeoutId=null)}present(e,t){this.cancelScheduledDrain();const{popup:n,content:o}=e;if(!o)return void(e.state="done");const i=document.createElement("div");i.id=`${kt}-${n.code}`,i.style.position="fixed",i.style.inset="0",i.style.zIndex=String(2147483647),i.style.pointerEvents="none",document.body.appendChild(i);const r=i.attachShadow({mode:"open"}),s=document.createElement("div");r.appendChild(s);const a=!!o.overlay;a&&this.lockBodyScroll();let c=!1;const l=t=>{c||(c=!0,a&&this.unlockBodyScroll(),(e=>{(0,_t.render)(null,e)})(s),i.remove(),this.visible?.code===n.code&&(this.visible=null),e.state="done",this.pw.dispatchEvent("hide-web-popup",{code:n.code,reason:t}),this.scheduleDrain())};this.visible={code:n.code,host:i,modal:a,close:l},e.state="visible",((e,t,n,o,i="auto")=>{(0,_t.render)((0,Ht.jsx)(vn,{params:t,mode:"live",colorScheme:i,onRequestClose:n,onSubmitForm:wn,onSubmitChoice:o.onSubmitChoice,onSubmitRating:o.onSubmitRating,onRequestSubscribe:o.onRequestSubscribe}),e)})(s,o,()=>l("user"),this.submitHandlers,this.colorScheme);const u=function(e){const t=new Set;for(const n of e.pages)if(Array.isArray(n?.contents))for(const e of n.contents)if(Array.isArray(e?.slots))for(const n of e.slots)"object"==typeof n&&null!==n&&"email-subscription-form"===n.type&&"string"==typeof n.formCode&&n.formCode&&t.add(n.formCode);return[...t]}(o);u.length>0&&this.pw.data.getHwid().then(e=>u.forEach(t=>((e,t)=>{fetch(kn(e,"/view"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:e,userId:t,hwid:t})}).catch(t=>{Lt.error(t,`Failed to record subscription form view for "${e}"`)})})(t,e))).catch(e=>{Lt.error(e,`${wt} Failed to record subscription form views for web popup "${n.code}"`)}),Lt.debug(`${wt} Popup "${n.code}" shown (trigger: ${t})`),this.recordVisit(e),this.markAsShown(n).catch(e=>{Lt.error(e,`${wt} Failed to mark web popup "${n.code}" as shown`)}),this.pw.dispatchEvent("show-web-popup",{code:n.code,trigger:t})}lockBodyScroll(){0===this.openPopupsCount&&(this.bodyOverflowBeforeLock=document.body.style.overflow,document.body.style.overflow="hidden"),this.openPopupsCount+=1}unlockBodyScroll(){this.openPopupsCount=Math.max(0,this.openPopupsCount-1),0===this.openPopupsCount&&null!==this.bodyOverflowBeforeLock&&(document.body.style.overflow=this.bodyOverflowBeforeLock,this.bodyOverflowBeforeLock=null)}subscribeToNavigation(){if(this.isNavigationSubscribed)return;this.isNavigationSubscribed=!0;const e=()=>this.renderForCurrentPage(),t=window.navigation;if(t&&"function"==typeof t.addEventListener)return void t.addEventListener("currententrychange",e);window.addEventListener("popstate",e),window.addEventListener("hashchange",e);let n=window.location.href;window.setInterval(()=>{window.location.href!==n&&(n=window.location.href,e())},500)}async checkStrongCondition(e){return(await Promise.all([this.checkCanBeShownByDeviceTypeCondition(e),this.checkCanBeShownByFrequencyCondition(e),this.checkCanBeShownByVisitorsTypeCondition(e)])).every(e=>e)}checkSoftCondition(e){return this.checkCanBeShownByMatchingPagesCondition(e)}checkNotExpired(e){return!e.content||(!function(e,t){for(const n of e.pages)if(Array.isArray(n?.contents))for(const e of n.contents)if(Array.isArray(e?.slots))for(const n of e.slots){if("object"!=typeof n||null===n)continue;if("timer"!==n.type||"hide-popup"!==n.onExpire)continue;if("string"!=typeof n.endTime)continue;const e="string"==typeof n.timezone?n.timezone:"",o=ze(n.endTime,e);if(null!==o&&o<=t)return!0}return!1}(e.content,Date.now())||(Lt.debug(`${wt} Popup "${e.popup.code}" not shown: its countdown has passed`),!1))}checkCanBeShownByDeviceTypeCondition(e){const{device_type:t}=e,n=this.pw.platformChecker.formFactor;return"ALL"===t||t===n}async checkCanBeShownByFrequencyCondition(e){const{frequency:t,code:n}=e;if("ONCE"===t){return!(await this.pw.data.getShownWebPopups()).includes(n)}return"ONCE_PER_SESSION"!==t||null===sessionStorage.getItem(this.getSessionStorageKey(n))}checkCanBeShownByMatchingPagesCondition(e){const{matching_pages:t,matching_page_rules:n,excluded_pages:o}=e,i=window.location.pathname;return n&&n.length>0?n.some(e=>this.matchPageRule(i,e)):t&&t.length>0?t.includes(i):!(o&&o.length>0)||!o.some(e=>this.matchPageRule(i,e))}matchPageRule(e,t){switch(t.operator){case"EQUALS":return e===t.path;case"STARTS_WITH":return e.startsWith(t.path);default:return!1}}checkCanBeShownByVisitorsTypeCondition(e){const{visitors_type:t}=e;return"NEW"===t?!this.isRecurringVisitor:"RECURRING"!==t||this.isRecurringVisitor}async markAsShown(e){this.pw.api.recordPopupFormEvent(e.code,2).catch(t=>{Lt.error(t,`${wt} Failed to record web popup shown event for "${e.code}"`)});const{frequency:t,code:n}=e;"ONCE"!==t?"ONCE_PER_SESSION"===t&&sessionStorage.setItem(this.getSessionStorageKey(n),"1"):await this.pw.data.addShownWebPopup(n)}getSessionStorageKey(e){return`${kt}.shown.${e}`}}return s})());
2
2
  //# sourceMappingURL=widget-web-popups.js.map