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,{PWSubscriptionWidget:()=>tn});const n=/^(https?:|mailto:|tel:)/i,o="#101828",r="#667085",i="#FFFFFF",l={background:"#FFFFFF",accent:"#2970FF",text:o,textSecondary:r,textInverse:"#FFFFFF"};function s(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"}}}const a={card:["top","bottom","top-left","top-right","bottom-left","bottom-right"],bar:["top","bottom"],modal:["center"]},c=Object.keys(a),u=["bottom-right","bottom-left","top-right","top-left"],_=["auto","launcher","manual"],d={delay:[0,3600],cappingCount:[0,100],cappingInterval:[0,8760],borderRadius:[0,32],offset:[0,100],launcherSize:[16,200],zIndex:[0,2147483647]},p={enable:!1,prompt:{enabled:!1,layout:"card",position:"top",borderRadius:12,overlay:!1},launcher:{enabled:!1,position:"bottom-right",offset:20,width:48,height:48},display:{trigger:"auto",delay:5,cappingCount:3,cappingInterval:4},texts:{title:"Stay in the loop",message:"Allow notifications to get our news and special offers first.",acceptText:"Allow",declineText:"Not now",closeText:"Got it",blockedTitle:"Notifications are blocked",blockedMessage:"To get our notifications, allow them for this site in your browser settings.",launcherLabel:"Subscribe to notifications",launcherBlockedLabel:"Notifications are blocked"},colors:l,fontFamily:'Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',zIndex:2147483e3},f=/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;function h(e){const t=f.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 m([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 y(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 v(e){return e>.5?.07+.86*(1-e):e}function b(e){return e<.5?.93-e*((.93-.5)/.5):e}function g(e,t){const n=h(e);if(!n)return e;const[o,r,i]=function([e,t,n]){const[o,r,i]=[e/255,t/255,n/255],l=Math.max(o,r,i),s=Math.min(o,r,i),a=(l+s)/2;if(l===s)return[0,0,a];const c=l-s;let u;return u=l===o?(r-i)/c+(r<i?6:0):l===r?(i-o)/c+2:(o-r)/c+4,[u/6,a>.5?c/(2-l-s):c/(l+s),a]}(n);return m(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,r=2*n-o;return[255*y(r,o,e+1/3),255*y(r,o,e),255*y(r,o,e-1/3)]}([o,r,"fold"===t?v(i):b(i)]))}function w(e,t,n){const o=h(e),r=h(t);return o&&r?m(o.map((e,t)=>e+(r[t]-e)*n)):e}function k(e){const t=h(e);if(!t)return!1;const[n,o,r]=t;return(.299*n+.587*o+.114*r)/255>.6}function x(e){return{background:g(e.background,"fold"),accent:e.accent,text:g(e.text,"lift"),textSecondary:g(e.textSecondary,"lift"),textInverse:e.textInverse}}function S(e,t){return"light"===t?{surface:l.background,surfaceText:o,border:"#D0D5DD",onAccent:i,error:"#D92D20",chromeIcon:r}:{surface:w(e.background,e.text,.08),surfaceText:e.text,border:w(e.background,e.text,.24),onAccent:k(e.accent)?o:i,error:"#FDA29B",chromeIcon:e.textSecondary}}function M(e){return!0===e.dark?.enabled}function C(e,t="light"){return"dark"===t&&M(e)?"dark":"light"}function P(e,t="light"){const n=C(e,t),o="dark"===n?(r=e.colors,i=e.dark,{...x(r),...i?.colors??{}}):e.colors;var r,i;return{...o,scheme:n,...S(o,n)}}function I(e){const t=(e||"").trim();if(t)return t.startsWith("#")||t.startsWith("/")||t.startsWith("?")||n.test(t)?t:void 0}new Set(["STRONG","B","EM","I","U","BR","A"]);function A(e){return"string"==typeof e&&e?e:void 0}function F(e){const t="object"==typeof e.colors&&null!==e.colors?e.colors:{};return{background:A(t.background)??A(e.background)??l.background,accent:A(t.accent)??A(e.accent)??l.accent,text:A(t.text)??l.text,textSecondary:A(t.textSecondary)??l.textSecondary,textInverse:A(t.textInverse)??l.textInverse}}function H(e,t){const n=e.dark;if("object"!=typeof n||null===n)return;const o=n,r="object"==typeof o.colors&&null!==o.colors?o.colors:{},i=x(t),l=function(e){if("object"!=typeof e||null===e)return;const t=e,n=A(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:A(r.background)??i.background,accent:A(r.accent)??i.accent,text:A(r.text)??i.text,textSecondary:A(r.textSecondary)??i.textSecondary,textInverse:A(r.textInverse)??i.textInverse},...l?{overlay:l}:{},...A(o.boxShadow)?{boxShadow:o.boxShadow}:{}}}function z(e){return"object"!=typeof e||null===e||Array.isArray(e)?{}:e}function T(e,t,n){return t.includes(e)?e:n}function E(e,[t,n],o){return"number"==typeof e&&Number.isFinite(e)?Math.max(t,Math.min(n,Math.round(e))):o}function j(e,t){if("string"!=typeof e)return t;const n=e.trim();return n?n.slice(0,300):t}function D(e){const t=I("string"==typeof e?e:void 0);return t&&/^(https?:\/\/|\/)/i.test(t)?t:void 0}function U(e,t){const n="string"==typeof t?t.trim().slice(0,64):"";return n?{[e]:n}:{}}function O(e){const t=p.texts,n=Object.keys(t);return Object.fromEntries(n.map(n=>[n,j(e[n],t[n])]))}function N(e){return"default"===e||"denied"===e}function L(e){return"denied"===e?"blocked":"ask"}function W(e,t){return e.launcher.enabled&&N(t)}var R,B,V,$,q,G,Z,K,X,J,Q,Y,ee,te,ne={},oe=[],re=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,ie=Array.isArray;function le(e,t){for(var n in t)e[n]=t[n];return e}function se(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function ae(e,t,n){var o,r,i,l={};for(i in t)"key"==i?o=t[i]:"ref"==i?r=t[i]:l[i]=t[i];if(arguments.length>2&&(l.children=arguments.length>3?R.call(arguments,2):n),"function"==typeof e&&null!=e.defaultProps)for(i in e.defaultProps)void 0===l[i]&&(l[i]=e.defaultProps[i]);return ce(e,l,o,r,null)}function ce(e,t,n,o,r){var i={type:e,props:t,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:r??++V,__i:-1,__u:0};return null==r&&null!=B.vnode&&B.vnode(i),i}function ue(e){return e.children}function _e(e,t){this.props=e,this.context=t}function de(e,t){if(null==t)return e.__?de(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?de(e):null}function pe(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,o=[],r=[],i=le({},t);i.__v=t.__v+1,B.vnode&&B.vnode(i),Me(e.__P,i,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,o,n??de(t),!!(32&t.__u),r),i.__v=t.__v,i.__.__k[i.__i]=i,Pe(o,i,r),t.__e=t.__=null,i.__e!=n&&fe(i)}}function fe(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}),fe(e)}function he(e){(!e.__d&&(e.__d=!0)&&$.push(e)&&!me.__r++||q!=B.debounceRendering)&&((q=B.debounceRendering)||G)(me)}function me(){try{for(var e,t=1;$.length;)$.length>t&&$.sort(Z),e=$.shift(),t=$.length,pe(e)}finally{$.length=me.__r=0}}function ye(e,t,n,o,r,i,l,s,a,c,u){var _,d,p,f,h,m,y=o&&o.__k||oe,v=t.length;for(a=ve(n,t,y,a,v),_=0;_<v;_++)null!=(p=n.__k[_])&&(d=-1!=p.__i&&y[p.__i]||ne,p.__i=_,m=Me(e,p,d,r,i,l,s,a,c,u),f=p.__e,p.ref&&d.ref!=p.ref&&(d.ref&&Fe(d.ref,null,p),u.push(p.ref,p.__c||f,p)),null==h&&null!=f&&(h=f),4&p.__u?(a=be(p,a,e),d.__e&&(d.__e=null)):"function"==typeof p.type&&void 0!==m?a=m:f&&(a=f.nextSibling),p.__u&=-7);return n.__e=h,a}function ve(e,t,n,o,r){var i,l,s,a,c,u=n.length,_=u,d=0;for(e.__k=new Array(r),i=0;i<r;i++)null!=(l=t[i])&&"boolean"!=typeof l&&"function"!=typeof l?("string"==typeof l||"number"==typeof l||"bigint"==typeof l||l.constructor==String?l=e.__k[i]=ce(null,l,null,null,null):ie(l)?l=e.__k[i]=ce(ue,{children:l},null,null,null):void 0===l.constructor&&l.__b>0?l=e.__k[i]=ce(l.type,l.props,l.key,l.ref?l.ref:null,l.__v):e.__k[i]=l,a=i+d,l.__=e,l.__b=e.__b+1,s=null,-1!=(c=l.__i=we(l,n,a,_))&&(_--,(s=n[c])&&(s.__u|=2)),null==s||null==s.__v?(-1==c&&(r>u?d--:r<u&&d++),"function"!=typeof l.type&&(l.__u|=4)):c!=a&&(c==a-1?d--:c==a+1?d++:(c>a?d--:d++,l.__u|=4))):e.__k[i]=null;if(_)for(i=0;i<u;i++)null!=(s=n[i])&&!(2&s.__u)&&(s.__e==o&&(o=de(s)),He(s,s));return o}function be(e,t,n){var o,r;if("function"==typeof e.type){for(o=e.__k,r=0;o&&r<o.length;r++)o[r]&&(o[r].__=e,t=be(o[r],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=de(e)),t=n.insertBefore(e.__e,t||null));do{t=t&&t.nextSibling}while(null!=t&&8==t.nodeType);return t}function ge(e,t){return t=t||[],null==e||"boolean"==typeof e||(ie(e)?e.some(function(e){ge(e,t)}):t.push(e)),t}function we(e,t,n,o){var r,i,l,s=e.key,a=e.type,c=t[n],u=null!=c&&!(2&c.__u);if(null===c&&null==s||u&&s==c.key&&a==c.type)return n;if(o>(u?1:0))for(r=n-1,i=n+1;r>=0||i<t.length;)if(null!=(c=t[l=r>=0?r--:i++])&&!(2&c.__u)&&s==c.key&&a==c.type)return l;return-1}function ke(e,t,n){"-"==t[0]?e.setProperty(t,n??""):e[t]=null==n?"":"number"!=typeof n||re.test(t)?n:n+"px"}function xe(e,t,n,o,r){var i,l;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||ke(e.style,t,"");if(n)for(t in n)o&&n[t]==o[t]||ke(e.style,t,n[t])}else if("o"==t[0]&&"n"==t[1])i=t!=(t=t.replace(Q,"$1")),l=t.toLowerCase(),t=l in e||"onFocusOut"==t||"onFocusIn"==t?l.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+i]=n,n?o?n[J]=o[J]:(n[J]=Y,e.addEventListener(t,i?te:ee,i)):e.removeEventListener(t,i?te:ee,i);else{if("http://www.w3.org/2000/svg"==r)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 Se(e){return function(t){if(this.l){var n=this.l[t.type+e];if(null==t[X])t[X]=Y++;else if(t[X]<n[J])return;return n(B.event?B.event(t):t)}}}function Me(e,t,n,o,r,i,l,s,a,c){var u,_,d,p,f,h,m,y,v,b,g,w,k,x,S,M,C=t.type;if(void 0!==t.constructor)return null;128&n.__u&&(a=!!(32&n.__u),i=[s=t.__e=n.__e]),(u=B.__b)&&u(t);e:if("function"==typeof C){_=l.length;try{if(v=t.props,b=C.prototype&&C.prototype.render,g=(u=C.contextType)&&o[u.__c],w=u?g?g.props.value:u.__:o,n.__c?y=(d=t.__c=n.__c).__=d.__E:(b?t.__c=d=new C(v,w):(t.__c=d=new _e(v,w),d.constructor=C,d.render=ze),g&&g.sub(d),d.state||(d.state={}),d.__n=o,p=d.__d=!0,d.__h=[],d._sb=[]),b&&null==d.__s&&(d.__s=d.state),b&&null!=C.getDerivedStateFromProps&&(d.__s==d.state&&(d.__s=le({},d.__s)),le(d.__s,C.getDerivedStateFromProps(v,d.__s))),f=d.props,h=d.state,d.__v=t,p)b&&null==C.getDerivedStateFromProps&&null!=d.componentWillMount&&d.componentWillMount(),b&&null!=d.componentDidMount&&d.__h.push(d.componentDidMount);else{if(b&&null==C.getDerivedStateFromProps&&v!==f&&null!=d.componentWillReceiveProps&&d.componentWillReceiveProps(v,w),t.__v==n.__v||!d.__e&&null!=d.shouldComponentUpdate&&!1===d.shouldComponentUpdate(v,d.__s,w)){t.__v!=n.__v&&(d.props=v,d.state=d.__s,d.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),oe.push.apply(d.__h,d._sb),d._sb=[],d.__h.length&&l.push(d),s=de(n);break e}null!=d.componentWillUpdate&&d.componentWillUpdate(v,d.__s,w),b&&null!=d.componentDidUpdate&&d.__h.push(function(){d.componentDidUpdate(f,h,m)})}if(d.context=w,d.props=v,d.__P=e,d.__e=!1,k=B.__r,x=0,b)d.state=d.__s,d.__d=!1,k&&k(t),u=d.render(d.props,d.state,d.context),oe.push.apply(d.__h,d._sb),d._sb=[];else do{d.__d=!1,k&&k(t),u=d.render(d.props,d.state,d.context),d.state=d.__s}while(d.__d&&++x<25);d.state=d.__s,null!=d.getChildContext&&(o=le(le({},o),d.getChildContext())),b&&!p&&null!=d.getSnapshotBeforeUpdate&&(m=d.getSnapshotBeforeUpdate(f,h)),S=null!=u&&u.type===ue&&null==u.key?Ie(u.props.children):u,s=ye(e,ie(S)?S:[S],t,n,o,r,i,l,s,a,c),d.base=t.__e,t.__u&=-161,d.__h.length&&l.push(d),y&&(d.__E=d.__=null)}catch(e){if(l.length=_,t.__v=null,a||null!=i){if(e.then){for(t.__u|=a?160:128;s&&8==s.nodeType&&s.nextSibling;)s=s.nextSibling;null!=i&&(i[i.indexOf(s)]=null),t.__e=s}else if(null!=i)for(M=i.length;M--;)se(i[M])}else t.__e=n.__e;null==t.__k&&(t.__k=n.__k||[]),e.then||Ce(t),B.__e(e,t,n)}}else null==i&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=Ae(n.__e,t,n,o,r,i,l,a,c);return(u=B.diffed)&&u(t),128&t.__u?void 0:s}function Ce(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(Ce))}function Pe(e,t,n){for(var o=0;o<n.length;o++)Fe(n[o],n[++o],n[++o]);B.__c&&B.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){B.__e(e,t.__v)}})}function Ie(e){return"object"!=typeof e||null==e||e.__b>0?e:ie(e)?e.map(Ie):void 0!==e.constructor?null:le({},e)}function Ae(e,t,n,o,r,i,l,s,a){var c,u,_,d,p,f,h,m=n.props||ne,y=t.props,v=t.type;if("svg"==v?r="http://www.w3.org/2000/svg":"math"==v?r="http://www.w3.org/1998/Math/MathML":r||(r="http://www.w3.org/1999/xhtml"),null!=i)for(c=0;c<i.length;c++)if((p=i[c])&&"setAttribute"in p==!!v&&(v?p.localName==v:3==p.nodeType)){e=p,i[c]=null;break}if(null==e){if(null==v)return document.createTextNode(y);e=document.createElementNS(r,v,y.is&&y),s&&(B.__m&&B.__m(t,i),s=!1),i=null}if(null==v)m===y||s&&e.data==y||(e.data=y);else{if(i="textarea"==v&&null!=y.defaultValue?null:i&&R.call(e.childNodes),!s&&null!=i)for(m={},c=0;c<e.attributes.length;c++)m[(p=e.attributes[c]).name]=p.value;for(c in m)p=m[c],"dangerouslySetInnerHTML"==c?_=p:"children"==c||c in y||"value"==c&&"defaultValue"in y||"checked"==c&&"defaultChecked"in y||xe(e,c,null,p,r);for(c in y)p=y[c],"children"==c?d=p:"dangerouslySetInnerHTML"==c?u=p:"value"==c?f=p:"checked"==c?h=p:s&&"function"!=typeof p||m[c]===p||xe(e,c,p,m[c],r);if(u)s||_&&(u.__html==_.__html||u.__html==e.innerHTML)||(e.innerHTML=u.__html),t.__k=[];else if(_&&(e.innerHTML=""),ye("template"==t.type?e.content:e,ie(d)?d:[d],t,n,o,"foreignObject"==v?"http://www.w3.org/1999/xhtml":r,i,l,i?i[0]:n.__k&&de(n,0),s,a),null!=i)for(c=i.length;c--;)se(i[c]);s&&"textarea"!=v||(c="value","progress"==v&&null==f?e.removeAttribute("value"):null!=f&&(f!==e[c]||"progress"==v&&!f||"option"==v&&f!=m[c])&&xe(e,c,f,m[c],r),c="checked",null!=h&&h!=e[c]&&xe(e,c,h,m[c],r))}return e}function Fe(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){B.__e(e,n)}}function He(e,t,n){var o,r;if(B.unmount&&B.unmount(e),(o=e.ref)&&(o.current&&o.current!=e.__e||Fe(o,null,t)),null!=(o=e.__c)){if(o.componentWillUnmount)try{o.componentWillUnmount()}catch(e){B.__e(e,t)}o.base=o.__P=o.__n=null}if(o=e.__k)for(r=0;r<o.length;r++)o[r]&&He(o[r],t,n||"function"!=typeof e.type);n||se(e.__e),e.__c=e.__=e.__e=void 0}function ze(e,t,n){return this.constructor(e,n)}function Te(e,t,n){var o,r,i,l;t==document&&(t=document.documentElement),B.__&&B.__(e,t),r=(o="function"==typeof n)?null:n&&n.__k||t.__k,i=[],l=[],Me(t,e=(!o&&n||t).__k=ae(ue,null,[e]),r||ne,ne,t.namespaceURI,!o&&n?[n]:r?null:t.firstChild?R.call(t.childNodes):null,i,!o&&n?n:r?r.__e:t.firstChild,o,l),Pe(i,e,l),e.props.children=null}R=oe.slice,B={__e:function(e,t,n,o){for(var r,i,l;t=t.__;)if((r=t.__c)&&!r.__)try{if((i=r.constructor)&&null!=i.getDerivedStateFromError&&(r.setState(i.getDerivedStateFromError(e)),l=r.__d),null!=r.componentDidCatch&&(r.componentDidCatch(e,o||{}),l=r.__d),l)return r.__E=r}catch(t){e=t}throw e}},V=0,_e.prototype.setState=function(e,t){var n;n=null!=this.__s&&this.__s!=this.state?this.__s:this.__s=le({},this.state),"function"==typeof e&&(e=e(le({},n),this.props)),e&&le(n,e),null!=e&&this.__v&&(t&&this._sb.push(t),he(this))},_e.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),he(this))},_e.prototype.render=ue,$=[],G="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Z=function(e,t){return e.__v.__b-t.__v.__b},me.__r=0,K=Math.random().toString(8),X="__d"+K,J="__a"+K,Q=/(PointerCapture)$|Capture$/i,Y=0,ee=Se(!1),te=Se(!0);var Ee=0;Array.isArray;function je(e,t,n,o,r,i){t||(t={});var l,s,a=t;if("ref"in a)for(s in a={},t)"ref"==s?l=t[s]:a[s]=t[s];var c={type:e,props:a,key:n,ref:l,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Ee,__i:-1,__u:0,__source:r,__self:i};if("function"==typeof e&&(l=e.defaultProps))for(s in l)void 0===a[s]&&(a[s]=l[s]);return B.vnode&&B.vnode(c),c}var De,Ue,Oe,Ne,Le=0,We=[],Re=B,Be=Re.__b,Ve=Re.__r,$e=Re.diffed,qe=Re.__c,Ge=Re.unmount,Ze=Re.__;function Ke(e,t){Re.__h&&Re.__h(Ue,e,Le||t),Le=0;var n=Ue.__H||(Ue.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function Xe(e){return Le=1,function(e,t,n){var o=Ke(De++,2);if(o.t=e,!o.__c&&(o.__=[n?n(t):ot(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=Ue,!Ue.__f)){var r=function(e,t,n){if(!o.__c.__H)return!0;var r=!1,l=o.__c.props!==e;if(o.__c.__H.__.some(function(e){if(e.__N){r=!0;var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(l=!0)}}),i){var s=i.call(this,e,t,n);return r?s||l:s}return!r||l};Ue.__f=!0;var i=Ue.shouldComponentUpdate,l=Ue.componentWillUpdate;Ue.componentWillUpdate=function(e,t,n){if(this.__e){var o=i;i=void 0,r(e,t,n),i=o}l&&l.call(this,e,t,n)},Ue.shouldComponentUpdate=r}return o.__N||o.__}(ot,e)}function Je(){for(var e;e=We.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(et),t.__h.some(tt),t.__h=[]}catch(n){t.__h=[],Re.__e(n,e.__v)}}}Re.__b=function(e){Ue=null,Be&&Be(e)},Re.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Ze&&Ze(e,t)},Re.__r=function(e){Ve&&Ve(e),De=0;var t=(Ue=e.__c).__H;t&&(Oe===Ue?(t.__h=[],Ue.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.some(et),t.__h.some(tt),t.__h=[],De=0)),Oe=Ue},Re.diffed=function(e){$e&&$e(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(1!==We.push(t)&&Ne===Re.requestAnimationFrame||((Ne=Re.requestAnimationFrame)||Ye)(Je)),t.__H.__.some(function(e){e.u&&(e.__H=e.u,e.u=void 0)})),Oe=Ue=null},Re.__c=function(e,t){t.some(function(e){try{e.__h.some(et),e.__h=e.__h.filter(function(e){return!e.__||tt(e)})}catch(n){t.some(function(e){e.__h&&(e.__h=[])}),t=[],Re.__e(n,e.__v)}}),qe&&qe(e,t)},Re.unmount=function(e){Ge&&Ge(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(e){try{et(e)}catch(e){t=e}}),n.__H=void 0,t&&Re.__e(t,n.__v))};var Qe="function"==typeof requestAnimationFrame;function Ye(e){var t,n=function(){clearTimeout(o),Qe&&cancelAnimationFrame(t),setTimeout(e)},o=setTimeout(n,35);Qe&&(t=requestAnimationFrame(n))}function et(e){var t=Ue,n=e.__c;"function"==typeof n&&(e.__c=void 0,n()),Ue=t}function tt(e){var t=Ue;e.__c=e.__(),Ue=t}function nt(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function ot(e,t){return"function"==typeof t?t(e):t}function rt(e,t){for(var n in t)e[n]=t[n];return e}function it(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 lt(e,t){this.props=e,this.context=t}(lt.prototype=new _e).isPureReactComponent=!0,lt.prototype.shouldComponentUpdate=function(e,t){return it(this.props,e)||it(this.state,t)};var st=B.__b;B.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),st&&st(e)};"undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.forward_ref");var at=B.__e;B.__e=function(e,t,n,o){if(e.then)for(var r,i=t;i=i.__;)if((r=i.__c)&&r.__c)return null==t.__e&&(t.__e=n.__e,t.__k=n.__k||[]),r.__c(e,t);at(e,t,n,o)};var ct=B.unmount;function ut(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=rt({},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 ut(e,t,n)})),e}function _t(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(e){return _t(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 dt(){this.__u=0,this.o=null,this.__b=null}function pt(e){var t=e.__&&e.__.__c;return t&&t.__a&&t.__a(e)}function ft(){this.i=null,this.l=null}B.unmount=function(e){var t=e.__c;t&&(t.__z=!0),t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),ct&&ct(e)},(dt.prototype=new _e).__c=function(e,t){var n=t.__c,o=this;null==o.o&&(o.o=[]),o.o.push(n);var r=pt(o.__v),i=!1,l=function(){i||o.__z||(i=!0,n.__R=null,r?r(a):a())};n.__R=l;var s=n.__P;n.__P=null;var a=function(){if(! --o.__u){if(o.state.__a){var e=o.state.__a;o.__v.__k[0]=_t(e,e.__c.__P,e.__c.__O)}var t;for(o.setState({__a:o.__b=null});t=o.o.pop();)t.__P=s,t.forceUpdate()}};o.__u++||32&t.__u||o.setState({__a:o.__b=o.__v.__k[0]}),e.then(l,l)},dt.prototype.componentWillUnmount=function(){this.o=[]},dt.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]=ut(this.__b,n,o.__O=o.__P)}this.__b=null}var r=t.__a&&ae(ue,null,e.fallback);return r&&(r.__u&=-33),[ae(ue,null,t.__a?null:e.children),r]};var ht=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]}};(ft.prototype=new _e).__a=function(e){var t=this,n=pt(t.__v),o=t.l.get(e);return o[0]++,function(r){var i=function(){t.props.revealOrder?(o.push(r),ht(t,e,o)):r()};n?n(i):i()}},ft.prototype.render=function(e){this.i=null,this.l=new Map;var t=ge(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},ft.prototype.componentDidUpdate=ft.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){ht(e,n,t)})};var mt="undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,yt=/^(?: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]/,vt=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,bt=/[A-Z0-9]/g,gt="undefined"!=typeof document,wt=function(e){return("undefined"!=typeof Symbol&&"symbol"==typeof Symbol()?/fil|che|rad/:/fil|che|ra/).test(e)};_e.prototype.isReactComponent=!0,["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(e){Object.defineProperty(_e.prototype,e,{configurable:!0,get:function(){return this["UNSAFE_"+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var kt=B.event;B.event=function(e){return kt&&(e=kt(e)),e.persist=function(){},e.isPropagationStopped=function(){return this.cancelBubble},e.isDefaultPrevented=function(){return this.defaultPrevented},e.nativeEvent=e};var xt={configurable:!0,get:function(){return this.class}},St=B.vnode;B.vnode=function(e){"string"==typeof e.type&&function(e){var t=e.props,n=e.type,o={},r=-1==n.indexOf("-");for(var i in t){var l=t[i];if(!("value"===i&&"defaultValue"in t&&null==l||gt&&"children"===i&&"noscript"===n||"class"===i||"className"===i)){var s=i.toLowerCase();"defaultValue"===i&&"value"in t&&null==t.value?i="value":"download"===i&&!0===l?l="":"translate"===s&&"no"===l?l=!1:"o"===s[0]&&"n"===s[1]?"ondoubleclick"===s?i="ondblclick":"onchange"!==s||"input"!==n&&"textarea"!==n||wt(t.type)?"onfocus"===s?i="onfocusin":"onblur"===s?i="onfocusout":vt.test(i)&&(i=s):s=i="oninput":r&&yt.test(i)?i=i.replace(bt,"-$&").toLowerCase():null===l&&(l=void 0),"oninput"===s&&o[i=s]&&(i="oninputCapture"),o[i]=l}}"select"==n&&(o.multiple&&Array.isArray(o.value)&&(o.value=ge(t.children).forEach(function(e){e.props.selected=-1!=o.value.indexOf(e.props.value)})),null!=o.defaultValue&&(o.value=ge(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",xt)):t.className&&(o.class=o.className=t.className),e.props=o}(e),e.$$typeof=mt,St&&St(e)};var Mt=B.__r;B.__r=function(e){Mt&&Mt(e),e.__c};var Ct=B.diffed;B.diffed=function(e){Ct&&Ct(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 Pt="(prefers-color-scheme: dark)";function It(e,t){const[n,o]=Xe(()=>"auto"===e&&t&&"undefined"!=typeof window&&"function"==typeof window.matchMedia&&window.matchMedia(Pt).matches);return function(e,t){var n=Ke(De++,3);!Re.__s&&nt(n.__H,t)&&(n.__=e,n.u=t,Ue.__H.__h.push(n))}(()=>{if("auto"!==e||!t||"undefined"==typeof window||"function"!=typeof window.matchMedia)return;const n=window.matchMedia(Pt),r=e=>o(e.matches);return o(n.matches),n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[e,t]),"auto"!==e?e:n?"dark":"light"}const At={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"},Ft=(Object.keys(At),"0 12px 32px rgba(16, 24, 40, 0.18)");function Ht(e,t){const[n,o]=e.split("-");return{[n]:t,[o]:t}}function zt(e,t){return t?(e?"pw-subw-drop":"pw-subw-rise")+" 0.3s ease-out backwards":void 0}function Tt(e,t,n){const{layout:o,position:r}=e.prompt,i={position:t,zIndex:e.zIndex,boxSizing:"border-box",pointerEvents:"auto"};if("bar"===o)return{...i,left:0,right:0,[r]:0,animation:zt("top"===r,n)};if("modal"===o)return{...i,top:"50%",left:"50%",width:"min(420px, calc(100% - 32px))",transform:"translate(-50%, -50%)",animation:n?"pw-subw-fade 0.25s ease-out backwards":void 0};const l="min(360px, calc(100% - 32px))",s=zt(r.startsWith("top"),n);return"top"===r||"bottom"===r?{...i,[r]:16,left:"50%",width:l,transform:"translateX(-50%)",animation:s}:{...i,...Ht(r,16),width:l,animation:s}}function Et({label:e,primary:t,colors:n,disabled:o,onClick:r}){return je("button",{type:"button",disabled:o,onClick:r,style:{...s(t?"primary":"secondary",n),display:"inline-block",width:"auto",padding:"8px 18px",whiteSpace:"nowrap",opacity:o?.6:1,cursor:o?"default":"pointer"},children:e})}function jt({config:e,variant:t,colors:n,busy:o,onAccept:r,onDecline:i}){const{prompt:l,texts:s}=e,a="bar"===l.layout,c="blocked"===t;return je("div",{role:"dialog","aria-label":c?s.blockedTitle:s.title,style:{display:"flex",flexDirection:a?"row":"column",alignItems:a?"center":"stretch",flexWrap:a?"wrap":"nowrap",gap:16,padding:a?"12px 20px":20,boxSizing:"border-box",width:"100%",borderRadius:a?0:l.borderRadius,boxShadow:Ft,backgroundColor:n.background,color:n.text,fontFamily:e.fontFamily,colorScheme:n.scheme},children:[je("div",{style:{display:"flex",alignItems:"flex-start",gap:12,flex:a?"1 1 240px":void 0},children:[l.iconUrl&&je("img",{src:l.iconUrl,alt:"",width:48,height:48,style:{flex:"none",borderRadius:8,objectFit:"cover"}}),je("div",{style:{display:"flex",flexDirection:"column",gap:4,minWidth:0},children:[je("div",{style:{fontSize:16,fontWeight:600,lineHeight:1.4},children:c?s.blockedTitle:s.title}),je("div",{style:{fontSize:14,lineHeight:1.5,color:n.textSecondary},children:c?s.blockedMessage:s.message})]})]}),je("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,flex:"none"},children:c?je(Et,{label:s.closeText,primary:!0,colors:n,onClick:i}):je(ue,{children:[je(Et,{label:s.declineText,primary:!1,colors:n,onClick:i}),je(Et,{label:s.acceptText,primary:!0,colors:n,disabled:o,onClick:r})]})})]})}function Dt({config:e,blocked:t,colors:n,onClick:o}){const{width:r,height:i,imageUrl:l}=e.launcher,s=t?e.texts.launcherBlockedLabel:e.texts.launcherLabel,a=Math.round(Math.min(r,i)/2),c={display:"flex",alignItems:"center",justifyContent:"center",width:r,height:i,padding:0,border:"none",cursor:"pointer",opacity:t?.7:1};return je("button",l?{type:"button","aria-label":s,title:s,onClick:o,style:{...c,background:"none"},children:je("img",{src:l,alt:"",width:r,height:i,style:{display:"block",objectFit:"contain"}})}:{type:"button","aria-label":s,title:s,onClick:o,style:{...c,borderRadius:"50%",backgroundColor:e.launcher.background??n.accent,color:e.launcher.iconColor??n.onAccent,boxShadow:Ft},children:je("svg",{width:a,height:a,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[je("path",{d:At.bell}),t&&je("path",{d:"M4 4l16 16"})]})})}function Ut({config:e,permission:t,open:n,mode:o="live",colorScheme:r="auto",busy:i,onAccept:l,onDecline:s,onLauncherClick:a}){const c=P(e,It(r,M(e))),u="live"===o,_=u?"fixed":"absolute",d=n&&e.prompt.enabled,p=W(e,t);return d||p?je(ue,{children:[u&&je("style",{children:"\n@keyframes pw-subw-fade { from { opacity: 0; } }\n@keyframes pw-subw-drop { from { opacity: 0; translate: 0 -16px; } }\n@keyframes pw-subw-rise { from { opacity: 0; translate: 0 16px; } }\n"}),d&&e.prompt.overlay&&je("div",{style:{position:_,inset:0,zIndex:e.zIndex,backgroundColor:"rgba(16, 24, 40, 0.5)",animation:u?"pw-subw-fade 0.2s ease-out backwards":void 0,pointerEvents:"auto"},onClick:s}),d&&je("div",{style:Tt(e,_,u),children:je(jt,{config:e,variant:L(t),colors:c,busy:i,onAccept:l,onDecline:s})}),p&&je("div",{style:{position:_,zIndex:e.zIndex,pointerEvents:"auto",...Ht(e.launcher.position,e.launcher.offset)},children:je(Dt,{config:e,blocked:"denied"===t,colors:c,onClick:a})})]}):null}const Ot="keyValue",Nt="messages",Lt="inboxMessages";function Wt(e,t){return function(n){n.objectStoreNames.contains(e)||t(n)}}const Rt=[Wt(Ot,function(e){e.createObjectStore(Ot,{keyPath:"key"})}),Wt("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})}),Wt(Nt,function(e){e.createObjectStore(Nt,{keyPath:"id",autoIncrement:!0}).createIndex("date","date",{unique:!1})}),Wt(Lt,function(e){const t="status",n=e.createObjectStore(Lt,{keyPath:"inbox_id",autoIncrement:!1});n.createIndex(t,t,{unique:!1,multiEntry:!0}),n.createIndex("rt","rt",{unique:!1,multiEntry:!0})})];class Bt{get all(){return Rt}}class Vt{constructor(e,t=new Bt){this.db=e,this.migrationsBuilder=t}applyMigrations(){this.applyMigrationsPack(this.migrationsBuilder.all)}applyMigrationsPack(e){e.forEach(e=>{e(this.db)})}}function $t(e,t){console.info("onversionchange",t),e.close()}let qt;function Gt(e){return(qt||(qt=new Promise((e,t)=>{const n=indexedDB.open("PUSHWOOSH_SDK_STORE",7);n.onsuccess=n=>{const o=n.target.result;o.onversionchange=$t.bind(null,o,t),e(o)},n.onerror=()=>t(n.error),n.onupgradeneeded=e=>{const n=e.target.result;n.onversionchange=$t.bind(null,n,t),new Vt(n).applyMigrations()}})),qt).then(t=>new Promise((n,o)=>e(t,n,o)))}class Zt{_add(e){return Gt((t,n,o)=>{const r=t.transaction([this.name],"readwrite").objectStore(this.name).add(e);r.onsuccess=()=>{n(e)},r.onerror=()=>{o(r.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 Gt((t,n,o)=>{const r=t.transaction([this.name],"readwrite").objectStore(this.name).delete(e);r.onsuccess=()=>{n(r.result)},r.onerror=()=>{o(r.error)}})}getAll(){return Gt((e,t,n)=>{const o=[],r=e.transaction(this.name).objectStore(this.name).openCursor();r.onsuccess=e=>{const n=e.target.result;n?(n.value&&o.push(n.value),n.continue()):t(o)},r.onerror=()=>{n(r.error)}})}}Kt=Ot;var Kt;const Xt=new class extends Zt{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)}},Jt=(new class extends Zt{constructor(){super(...arguments),this.name=Nt,this.maxItems=25}add(e){return this._add({...e,date:new Date})}},{error:1,info:2,debug:3});let Qt=3;const Yt={setLevel(e){Jt[e]||(e="error"),Qt=Jt[e]},write(e,t,n){return"error"===e?this.error(t):this.info(t),Xt.add(e,t,n)}};Object.keys(Jt).forEach(e=>{const t=Jt[e];Yt[e]=(...n)=>{t<=Qt&&(console.groupCollapsed(e),console.info("",...n),console.trace("trace"),console.groupEnd())}});const en="Pushwoosh subscription widget:";class tn{constructor(e){this.permission="unsupported",this.open=!1,this.busy=!1,this.container=null,this.autoShowTimer=null,this.pw=e,this.config=function(e){const t=p,n=z(e),o=z(n.prompt),r=z(n.launcher),i=z(n.display),l=d,s=T(o.layout,c,t.prompt.layout),f=a[s],h=T(i.trigger,_,t.display.trigger),m=D(o.iconUrl),y=D(r.imageUrl),v=F({colors:n.colors}),b=H({dark:n.dark},v),g=!0===o.enabled,w=!0===r.enabled;return{enable:g||w,prompt:{enabled:g,layout:s,position:T(o.position,f,f[0]),...m?{iconUrl:m}:{},borderRadius:E(o.borderRadius,l.borderRadius,t.prompt.borderRadius),overlay:"modal"===s||!0===o.overlay},launcher:{enabled:w,position:T(r.position,u,t.launcher.position),offset:E(r.offset,l.offset,t.launcher.offset),width:E(r.width,l.launcherSize,t.launcher.width),height:E(r.height,l.launcherSize,t.launcher.height),...y?{imageUrl:y}:{},...U("background",r.background),...U("iconColor",r.iconColor)},display:{trigger:h,delay:E(i.delay,l.delay,t.display.delay),cappingCount:E(i.cappingCount,l.cappingCount,t.display.cappingCount),cappingInterval:E(i.cappingInterval,l.cappingInterval,t.display.cappingInterval)},texts:O(z(n.texts)),colors:v,...b?{dark:b}:{},fontFamily:j(n.fontFamily,t.fontFamily),zIndex:E(n.zIndex,l.zIndex,t.zIndex)}}(e.initParams.subscriptionWidget),this.accept=this.accept.bind(this),this.decline=this.decline.bind(this),this.toggle=this.toggle.bind(this),this.launcherClick=this.launcherClick.bind(this),e.moduleRegistry.subscriptionWidget=this}async run(){const{pw:e,config:t}=this;t.enable&&e.isPushAvailable()&&(this.permission=await this.readPermission(),this.mount(),this.listenSubscriptionChanges(),await this.scheduleAutoShow())}show(){this.container&&this.config.prompt.enabled&&N(this.permission)&&!this.open&&(this.open=!0,this.render(),this.pw.dispatchEvent("show-subscription-widget",{}))}hide(){this.open&&(this.open=!1,this.busy=!1,this.render(),this.pw.dispatchEvent("hide-subscription-widget",{}))}toggle(e){e??!this.open?this.show():this.hide()}isVisible(){return this.open}async readPermission(){const e=this.pw.driver?.getPermission();return"denied"===e?"denied":await this.pw.isSubscribed()?"granted":"default"}mount(){const e=document.createElement("div");e.id="pushwoosh-subscription-widget",e.style.position="fixed",e.style.inset="0",e.style.zIndex=String(this.config.zIndex),e.style.pointerEvents="none",document.body.appendChild(e),this.container=document.createElement("div"),e.attachShadow({mode:"open"}).appendChild(this.container),this.render()}render(){this.container&&(this.open||W(this.config,this.permission)?((e,t)=>{Te(je(Ut,{...t,mode:"live"}),e)})(this.container,{config:this.config,permission:this.permission,open:this.open,busy:this.busy,onAccept:this.accept,onDecline:this.decline,onLauncherClick:this.launcherClick}):Te(null,this.container))}async scheduleAutoShow(){const e=await this.pw.data.getSubscriptionWidgetHistory();(function(e,t,n,o){const{trigger:r,cappingCount:i,cappingInterval:l}=e.display;return!(!e.prompt.enabled||"auto"!==r||"default"!==t||i>0&&n.shownCount>=i||!(null===n.lastShownAt||o-n.lastShownAt>=36e5*l))})(this.config,this.permission,e,Date.now())&&(this.autoShowTimer=setTimeout(async()=>{this.autoShowTimer=null,this.open||"default"!==this.permission||(this.show(),await this.pw.data.setSubscriptionWidgetHistory(function(e,t){return{shownCount:e.shownCount+1,lastShownAt:t}}(e,Date.now())))},1e3*this.config.display.delay))}launcherClick(){const e=(t=this.config,n=this.permission,t.prompt.enabled?"prompt":"default"===n?"subscribe":"none");var t,n;"prompt"===e?this.toggle():"subscribe"===e&&this.subscribeFromLauncher()}async subscribeFromLauncher(){try{await this.pw.subscribe()}catch(e){Yt.error(e,`${en} failed to subscribe`)}this.permission=await this.readPermission(),this.render()}async accept(){this.busy=!0,this.render();try{await this.pw.subscribe()}catch(e){Yt.error(e,`${en} failed to subscribe`)}if(this.permission=await this.readPermission(),"denied"===this.permission)return this.busy=!1,void this.render();this.hide()}decline(){this.hide()}listenSubscriptionChanges(){const e=async()=>{this.permission=await this.readPermission(),"granted"===this.permission&&(this.cancelAutoShow(),this.hide()),this.render()};this.pw.addEventHandler("subscribe",e),this.pw.addEventHandler("unsubscribe",e),this.pw.addEventHandler("permission-denied",e)}cancelAutoShow(){null!==this.autoShowTimer&&(clearTimeout(this.autoShowTimer),this.autoShowTimer=null)}}return t})());
1
+ !function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("preact"),require("preact/compat"),require("preact/jsx-runtime"));else if("function"==typeof define&&define.amd)define(["preact","preact/compat","preact/jsx-runtime"],e);else{var n="object"==typeof exports?e(require("preact"),require("preact/compat"),require("preact/jsx-runtime")):e(t.preact,t.preactCompat,t.jsxRuntime);for(var o in n)("object"==typeof exports?exports:t)[o]=n[o]}}(this,(t,e,n)=>(()=>{"use strict";var o={524(e){e.exports=t},873(t){t.exports=e},247(t){t.exports=n}};const i={};function r(t){const e=i[t];if(void 0!==e)return e.exports;const n=i[t]={exports:{}};return o[t](n,n.exports,r),n.exports}r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};let s={};r.r(s),r.d(s,{PWSubscriptionWidget:()=>St});const a=/^(https?:|mailto:|tel:)/i,c="#101828",l="#667085",d="#FFFFFF",u={background:"#FFFFFF",accent:"#2970FF",text:c,textSecondary:l,textInverse:"#FFFFFF"};function h(t,e){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"===t?{backgroundColor:e.surface,color:e.accent,border:`1px solid ${e.accent}`}:{backgroundColor:e.accent,color:e.onAccent,border:"none"}}}const p={card:["top","bottom","top-left","top-right","bottom-left","bottom-right"],bar:["top","bottom"],modal:["center"]},f=Object.keys(p),b=["bottom-right","bottom-left","top-right","top-left"],m=["auto","launcher","manual"],g={delay:[0,3600],cappingCount:[0,100],cappingInterval:[0,8760],borderRadius:[0,32],offset:[0,100],launcherSize:[16,200],zIndex:[0,2147483647]},y={enable:!1,prompt:{enabled:!1,layout:"card",position:"top",borderRadius:12,overlay:!1},launcher:{enabled:!1,position:"bottom-right",offset:20,width:48,height:48},display:{trigger:"auto",delay:5,cappingCount:3,cappingInterval:4},texts:{title:"Stay in the loop",message:"Allow notifications to get our news and special offers first.",acceptText:"Allow",declineText:"Not now",closeText:"Got it",blockedTitle:"Notifications are blocked",blockedMessage:"To get our notifications, allow them for this site in your browser settings.",launcherLabel:"Subscribe to notifications",launcherBlockedLabel:"Notifications are blocked"},colors:u,fontFamily:'Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',zIndex:2147483e3},x=/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;function w(t){const e=x.exec(t.trim())?.[1];if(!e)return null;const n=3===e.length?e.split("").map(t=>t+t).join(""):e;return[0,2,4].map(t=>parseInt(n.slice(t,t+2),16))}function v([t,e,n]){return`#${[t,e,n].map(t=>Math.max(0,Math.min(255,Math.round(t))).toString(16).padStart(2,"0")).join("")}`}function k(t,e,n){let o=n;return o<0&&(o+=1),o>1&&(o-=1),o<1/6?t+6*(e-t)*o:o<.5?e:o<2/3?t+(e-t)*(2/3-o)*6:t}function M(t){return t>.5?.07+.86*(1-t):t}function S(t){return t<.5?.93-t*((.93-.5)/.5):t}function j(t,e){const n=w(t);if(!n)return t;const[o,i,r]=function([t,e,n]){const[o,i,r]=[t/255,e/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 d;return d=s===o?(i-r)/l+(i<r?6:0):s===i?(r-o)/l+2:(o-i)/l+4,[d/6,c>.5?l/(2-s-a):l/(s+a),c]}(n);return v(function([t,e,n]){if(0===e){const t=255*n;return[t,t,t]}const o=n<.5?n*(1+e):n+e-n*e,i=2*n-o;return[255*k(i,o,t+1/3),255*k(i,o,t),255*k(i,o,t-1/3)]}([o,i,"fold"===e?M(r):S(r)]))}function I(t,e,n){const o=w(t),i=w(e);return o&&i?v(o.map((t,e)=>t+(i[e]-t)*n)):t}function C(t){const e=w(t);if(!e)return!1;const[n,o,i]=e;return(.299*n+.587*o+.114*i)/255>.6}function F(t){return{background:j(t.background,"fold"),accent:t.accent,text:j(t.text,"lift"),textSecondary:j(t.textSecondary,"lift"),textInverse:t.textInverse}}function z(t,e){return"light"===e?{surface:u.background,surfaceText:c,border:"#D0D5DD",onAccent:d,error:"#D92D20",chromeIcon:l}:{surface:I(t.background,t.text,.08),surfaceText:t.text,border:I(t.background,t.text,.24),onAccent:C(t.accent)?c:d,error:"#FDA29B",chromeIcon:t.textSecondary}}function A(t){return!0===t.dark?.enabled}function P(t,e="light"){return"dark"===e&&A(t)?"dark":"light"}function E(t,e="light"){const n=P(t,e),o="dark"===n?(i=t.colors,r=t.dark,{...F(i),...r?.colors??{}}):t.colors;var i,r;return{...o,scheme:n,...z(o,n)}}function T(t){const e=(t||"").trim();if(e)return e.startsWith("#")||e.startsWith("/")||e.startsWith("?")||a.test(e)?e:void 0}new Set(["STRONG","B","EM","I","U","BR","A"]);function D(t){return"string"==typeof t&&t?t:void 0}function H(t){const e="object"==typeof t.colors&&null!==t.colors?t.colors:{};return{background:D(e.background)??D(t.background)??u.background,accent:D(e.accent)??D(t.accent)??u.accent,text:D(e.text)??u.text,textSecondary:D(e.textSecondary)??u.textSecondary,textInverse:D(e.textInverse)??u.textInverse}}function L(t,e){const n=t.dark;if("object"!=typeof n||null===n)return;const o=n,i="object"==typeof o.colors&&null!==o.colors?o.colors:{},r=F(e),s=function(t){if("object"!=typeof t||null===t)return;const e=t,n=D(e.color);if(!n)return;return{color:n,opacity:"number"==typeof e.opacity&&Number.isFinite(e.opacity)?Math.max(0,Math.min(1,e.opacity)):1}}(o.overlay);return{enabled:!0===o.enabled,colors:{background:D(i.background)??r.background,accent:D(i.accent)??r.accent,text:D(i.text)??r.text,textSecondary:D(i.textSecondary)??r.textSecondary,textInverse:D(i.textInverse)??r.textInverse},...s?{overlay:s}:{},...D(o.boxShadow)?{boxShadow:o.boxShadow}:{}}}function O(t){return"object"!=typeof t||null===t||Array.isArray(t)?{}:t}function R(t,e,n){return e.includes(t)?t:n}function W(t,[e,n],o){return"number"==typeof t&&Number.isFinite(t)?Math.max(e,Math.min(n,Math.round(t))):o}function q(t,e){if("string"!=typeof t)return e;const n=t.trim();return n?n.slice(0,300):e}function B(t){const e=T("string"==typeof t?t:void 0);return e&&/^(https?:\/\/|\/)/i.test(e)?e:void 0}function U(t,e){const n="string"==typeof e?e.trim().slice(0,64):"";return n?{[t]:n}:{}}function V(t){const e=y.texts,n=Object.keys(e);return Object.fromEntries(n.map(n=>[n,q(t[n],e[n])]))}function _(t){return"default"===t||"denied"===t}function N(t){return"denied"===t?"blocked":"ask"}function $(t,e){return t.launcher.enabled&&_(e)}var G=r(247),K=r(524),X=r(873);const J="(prefers-color-scheme: dark)";function Q(t,e){const[n,o]=(0,X.useState)(()=>"auto"===t&&e&&"undefined"!=typeof window&&"function"==typeof window.matchMedia&&window.matchMedia(J).matches);return(0,X.useEffect)(()=>{if("auto"!==t||!e||"undefined"==typeof window||"function"!=typeof window.matchMedia)return;const n=window.matchMedia(J),i=t=>o(t.matches);return o(n.matches),n.addEventListener("change",i),()=>n.removeEventListener("change",i)},[t,e]),"auto"!==t?t:n?"dark":"light"}const Y={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"},Z=(Object.keys(Y),"0 12px 32px rgba(16, 24, 40, 0.18)");function tt(t,e){const[n,o]=t.split("-");return{[n]:e,[o]:e}}function et(t,e){return e?(t?"pw-subw-drop":"pw-subw-rise")+" 0.3s ease-out backwards":void 0}function nt(t,e,n){const{layout:o,position:i}=t.prompt,r={position:e,zIndex:t.zIndex,boxSizing:"border-box",pointerEvents:"auto"};if("bar"===o)return{...r,left:0,right:0,[i]:0,animation:et("top"===i,n)};if("modal"===o)return{...r,top:"50%",left:"50%",width:"min(420px, calc(100% - 32px))",transform:"translate(-50%, -50%)",animation:n?"pw-subw-fade 0.25s ease-out backwards":void 0};const s="min(360px, calc(100% - 32px))",a=et(i.startsWith("top"),n);return"top"===i||"bottom"===i?{...r,[i]:16,left:"50%",width:s,transform:"translateX(-50%)",animation:a}:{...r,...tt(i,16),width:s,animation:a}}function ot({label:t,primary:e,colors:n,disabled:o,onClick:i}){return(0,G.jsx)("button",{type:"button",disabled:o,onClick:i,style:{...h(e?"primary":"secondary",n),display:"inline-block",width:"auto",padding:"8px 18px",whiteSpace:"nowrap",opacity:o?.6:1,cursor:o?"default":"pointer"},children:t})}function it({config:t,variant:e,colors:n,busy:o,onAccept:i,onDecline:r}){const{prompt:s,texts:a}=t,c="bar"===s.layout,l="blocked"===e;return(0,G.jsxs)("div",{role:"dialog","aria-label":l?a.blockedTitle:a.title,style:{display:"flex",flexDirection:c?"row":"column",alignItems:c?"center":"stretch",flexWrap:c?"wrap":"nowrap",gap:16,padding:c?"12px 20px":20,boxSizing:"border-box",width:"100%",borderRadius:c?0:s.borderRadius,boxShadow:Z,backgroundColor:n.background,color:n.text,fontFamily:t.fontFamily,colorScheme:n.scheme},children:[(0,G.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:12,flex:c?"1 1 240px":void 0},children:[s.iconUrl&&(0,G.jsx)("img",{src:s.iconUrl,alt:"",width:48,height:48,style:{flex:"none",borderRadius:8,objectFit:"cover"}}),(0,G.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4,minWidth:0},children:[(0,G.jsx)("div",{style:{fontSize:16,fontWeight:600,lineHeight:1.4},children:l?a.blockedTitle:a.title}),(0,G.jsx)("div",{style:{fontSize:14,lineHeight:1.5,color:n.textSecondary},children:l?a.blockedMessage:a.message})]})]}),(0,G.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,flex:"none"},children:l?(0,G.jsx)(ot,{label:a.closeText,primary:!0,colors:n,onClick:r}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(ot,{label:a.declineText,primary:!1,colors:n,onClick:r}),(0,G.jsx)(ot,{label:a.acceptText,primary:!0,colors:n,disabled:o,onClick:i})]})})]})}function rt({config:t,blocked:e,colors:n,onClick:o}){const{width:i,height:r,imageUrl:s}=t.launcher,a=e?t.texts.launcherBlockedLabel:t.texts.launcherLabel,c=Math.round(Math.min(i,r)/2),l={display:"flex",alignItems:"center",justifyContent:"center",width:i,height:r,padding:0,border:"none",cursor:"pointer",opacity:e?.7:1};return s?(0,G.jsx)("button",{type:"button","aria-label":a,title:a,onClick:o,style:{...l,background:"none"},children:(0,G.jsx)("img",{src:s,alt:"",width:i,height:r,style:{display:"block",objectFit:"contain"}})}):(0,G.jsx)("button",{type:"button","aria-label":a,title:a,onClick:o,style:{...l,borderRadius:"50%",backgroundColor:t.launcher.background??n.accent,color:t.launcher.iconColor??n.onAccent,boxShadow:Z},children:(0,G.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,G.jsx)("path",{d:Y.bell}),e&&(0,G.jsx)("path",{d:"M4 4l16 16"})]})})}function st({config:t,permission:e,open:n,mode:o="live",colorScheme:i="auto",busy:r,onAccept:s,onDecline:a,onLauncherClick:c}){const l=E(t,Q(i,A(t))),d="live"===o,u=d?"fixed":"absolute",h=n&&t.prompt.enabled,p=$(t,e);return h||p?(0,G.jsxs)(G.Fragment,{children:[d&&(0,G.jsx)("style",{children:"\n@keyframes pw-subw-fade { from { opacity: 0; } }\n@keyframes pw-subw-drop { from { opacity: 0; translate: 0 -16px; } }\n@keyframes pw-subw-rise { from { opacity: 0; translate: 0 16px; } }\n"}),h&&t.prompt.overlay&&(0,G.jsx)("div",{style:{position:u,inset:0,zIndex:t.zIndex,backgroundColor:"rgba(16, 24, 40, 0.5)",animation:d?"pw-subw-fade 0.2s ease-out backwards":void 0,pointerEvents:"auto"},onClick:a}),h&&(0,G.jsx)("div",{style:nt(t,u,d),children:(0,G.jsx)(it,{config:t,variant:N(e),colors:l,busy:r,onAccept:s,onDecline:a})}),p&&(0,G.jsx)("div",{style:{position:u,zIndex:t.zIndex,pointerEvents:"auto",...tt(t.launcher.position,t.launcher.offset)},children:(0,G.jsx)(rt,{config:t,blocked:"denied"===e,colors:l,onClick:c})})]}):null}const at="keyValue",ct="messages",lt="inboxMessages";function dt(t,e){return function(n){n.objectStoreNames.contains(t)||e(n)}}const ut=[dt(at,function(t){t.createObjectStore(at,{keyPath:"key"})}),dt("log",function(t){const e=t.createObjectStore("log",{keyPath:"id",autoIncrement:!0});e.createIndex("environment","environment",{unique:!1}),e.createIndex("date","date",{unique:!1}),e.createIndex("type","type",{unique:!1})}),dt(ct,function(t){t.createObjectStore(ct,{keyPath:"id",autoIncrement:!0}).createIndex("date","date",{unique:!1})}),dt(lt,function(t){const e="status",n=t.createObjectStore(lt,{keyPath:"inbox_id",autoIncrement:!1});n.createIndex(e,e,{unique:!1,multiEntry:!0}),n.createIndex("rt","rt",{unique:!1,multiEntry:!0})})];class ht{get all(){return ut}}class pt{constructor(t,e=new ht){this.db=t,this.migrationsBuilder=e}applyMigrations(){this.applyMigrationsPack(this.migrationsBuilder.all)}applyMigrationsPack(t){t.forEach(t=>{t(this.db)})}}function ft(t,e){console.info("onversionchange",e),t.close()}let bt;function mt(t){return(bt||(bt=new Promise((t,e)=>{const n=indexedDB.open("PUSHWOOSH_SDK_STORE",7);n.onsuccess=n=>{const o=n.target.result;o.onversionchange=ft.bind(null,o,e),t(o)},n.onerror=()=>e(n.error),n.onupgradeneeded=t=>{const n=t.target.result;n.onversionchange=ft.bind(null,n,e),new pt(n).applyMigrations()}})),bt).then(e=>new Promise((n,o)=>t(e,n,o)))}class gt{_add(t){return mt((e,n,o)=>{const i=e.transaction([this.name],"readwrite").objectStore(this.name).add(t);i.onsuccess=()=>{n(t)},i.onerror=()=>{o(i.error)}}).then(t=>this.getAll().then(e=>{if(Array.isArray(e)){const n=e.map(t=>t.id).sort((t,e)=>t==e?0:t<e?1:-1);if(n.length>this.maxItems)return Promise.all(n.slice(this.maxItems).map(t=>this.delete(t))).then(()=>t)}return t}))}delete(t){return mt((e,n,o)=>{const i=e.transaction([this.name],"readwrite").objectStore(this.name).delete(t);i.onsuccess=()=>{n(i.result)},i.onerror=()=>{o(i.error)}})}getAll(){return mt((t,e,n)=>{const o=[],i=t.transaction(this.name).objectStore(this.name).openCursor();i.onsuccess=t=>{const n=t.target.result;n?(n.value&&o.push(n.value),n.continue()):e(o)},i.onerror=()=>{n(i.error)}})}}yt=at;var yt;const xt=new class extends gt{constructor(){super(...arguments),this.name="log",this.maxItems=100,this.environment="undefined"!=typeof self&&self.registration?"worker":"browser"}add(t,e,n){const o={type:t,environment:this.environment,message:`${e}`,date:new Date};return e instanceof Error&&(o.stack=e.stack),n&&(o.additional=n),this._add(o)}},wt=(new class extends gt{constructor(){super(...arguments),this.name=ct,this.maxItems=25}add(t){return this._add({...t,date:new Date})}},{error:1,info:2,debug:3});let vt=3;const kt={setLevel(t){wt[t]||(t="error"),vt=wt[t]},write(t,e,n){return"error"===t?this.error(e):this.info(e),xt.add(t,e,n)}};Object.keys(wt).forEach(t=>{const e=wt[t];kt[t]=(...n)=>{e<=vt&&(console.groupCollapsed(t),console.info("",...n),console.trace("trace"),console.groupEnd())}});const Mt="Pushwoosh subscription widget:";class St{constructor(t){this.permission="unsupported",this.open=!1,this.busy=!1,this.container=null,this.autoShowTimer=null,this.pw=t,this.config=function(t){const e=y,n=O(t),o=O(n.prompt),i=O(n.launcher),r=O(n.display),s=g,a=R(o.layout,f,e.prompt.layout),c=p[a],l=R(r.trigger,m,e.display.trigger),d=B(o.iconUrl),u=B(i.imageUrl),h=H({colors:n.colors}),x=L({dark:n.dark},h),w=!0===o.enabled,v=!0===i.enabled;return{enable:w||v,prompt:{enabled:w,layout:a,position:R(o.position,c,c[0]),...d?{iconUrl:d}:{},borderRadius:W(o.borderRadius,s.borderRadius,e.prompt.borderRadius),overlay:"modal"===a||!0===o.overlay},launcher:{enabled:v,position:R(i.position,b,e.launcher.position),offset:W(i.offset,s.offset,e.launcher.offset),width:W(i.width,s.launcherSize,e.launcher.width),height:W(i.height,s.launcherSize,e.launcher.height),...u?{imageUrl:u}:{},...U("background",i.background),...U("iconColor",i.iconColor)},display:{trigger:l,delay:W(r.delay,s.delay,e.display.delay),cappingCount:W(r.cappingCount,s.cappingCount,e.display.cappingCount),cappingInterval:W(r.cappingInterval,s.cappingInterval,e.display.cappingInterval)},texts:V(O(n.texts)),colors:h,...x?{dark:x}:{},fontFamily:q(n.fontFamily,e.fontFamily),zIndex:W(n.zIndex,s.zIndex,e.zIndex)}}(t.initParams.subscriptionWidget),this.accept=this.accept.bind(this),this.decline=this.decline.bind(this),this.toggle=this.toggle.bind(this),this.launcherClick=this.launcherClick.bind(this),t.moduleRegistry.subscriptionWidget=this}async run(){const{pw:t,config:e}=this;e.enable&&t.isPushAvailable()&&(this.permission=await this.readPermission(),this.mount(),this.listenSubscriptionChanges(),await this.scheduleAutoShow())}show(){this.container&&this.config.prompt.enabled&&_(this.permission)&&!this.open&&(this.open=!0,this.render(),this.pw.dispatchEvent("show-subscription-widget",{}))}hide(){this.open&&(this.open=!1,this.busy=!1,this.render(),this.pw.dispatchEvent("hide-subscription-widget",{}))}toggle(t){t??!this.open?this.show():this.hide()}isVisible(){return this.open}async readPermission(){const t=this.pw.driver?.getPermission();return"denied"===t?"denied":await this.pw.isSubscribed()?"granted":"default"}mount(){const t=document.createElement("div");t.id="pushwoosh-subscription-widget",t.style.position="fixed",t.style.inset="0",t.style.zIndex=String(this.config.zIndex),t.style.pointerEvents="none",document.body.appendChild(t),this.container=document.createElement("div"),t.attachShadow({mode:"open"}).appendChild(this.container),this.render()}render(){var t;if(this.container)return this.open||$(this.config,this.permission)?void((t,e)=>{(0,K.render)((0,G.jsx)(st,{...e,mode:"live"}),t)})(this.container,{config:this.config,permission:this.permission,open:this.open,busy:this.busy,onAccept:this.accept,onDecline:this.decline,onLauncherClick:this.launcherClick}):(t=this.container,void(0,K.render)(null,t))}async scheduleAutoShow(){const t=await this.pw.data.getSubscriptionWidgetHistory();(function(t,e,n,o){const{trigger:i,cappingCount:r,cappingInterval:s}=t.display;return!(!t.prompt.enabled||"auto"!==i||"default"!==e||r>0&&n.shownCount>=r||!(null===n.lastShownAt||o-n.lastShownAt>=36e5*s))})(this.config,this.permission,t,Date.now())&&(this.autoShowTimer=setTimeout(async()=>{this.autoShowTimer=null,this.open||"default"!==this.permission||(this.show(),await this.pw.data.setSubscriptionWidgetHistory(function(t,e){return{shownCount:t.shownCount+1,lastShownAt:e}}(t,Date.now())))},1e3*this.config.display.delay))}launcherClick(){const t=(e=this.config,n=this.permission,e.prompt.enabled?"prompt":"default"===n?"subscribe":"none");var e,n;"prompt"===t?this.toggle():"subscribe"===t&&this.subscribeFromLauncher()}async subscribeFromLauncher(){try{await this.pw.subscribe()}catch(t){kt.error(t,`${Mt} failed to subscribe`)}this.permission=await this.readPermission(),this.render()}async accept(){this.busy=!0,this.render();try{await this.pw.subscribe()}catch(t){kt.error(t,`${Mt} failed to subscribe`)}if(this.permission=await this.readPermission(),"denied"===this.permission)return this.busy=!1,void this.render();this.hide()}decline(){this.hide()}listenSubscriptionChanges(){const t=async()=>{this.permission=await this.readPermission(),"granted"===this.permission&&(this.cancelAutoShow(),this.hide()),this.render()};this.pw.addEventHandler("subscribe",t),this.pw.addEventHandler("unsubscribe",t),this.pw.addEventHandler("permission-denied",t)}cancelAutoShow(){null!==this.autoShowTimer&&(clearTimeout(this.autoShowTimer),this.autoShowTimer=null)}}return s})());
2
2
  //# sourceMappingURL=widget-subscription.js.map