@abtasty/countdown
Advanced tools
Comparing version 2.0.1-16 to 2.0.1-17
@@ -1,1 +0,1 @@ | ||
!function(){"use strict";var t=function(t,e){return t(e={exports:{}},e.exports),e.exports}((function(t){var e=function(t){var e=Object.prototype,n=e.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},s=i.iterator||"@@iterator",o=i.asyncIterator||"@@asyncIterator",r=i.toStringTag||"@@toStringTag";function a(t,e,n,i){var s=e&&e.prototype instanceof d?e:d,o=Object.create(s.prototype),r=new T(i||[]);return o._invoke=function(t,e,n){var i="suspendedStart";return function(s,o){if("executing"===i)throw new Error("Generator is already running");if("completed"===i){if("throw"===s)throw o;return E()}for(n.method=s,n.arg=o;;){var r=n.delegate;if(r){var a=w(r,n);if(a){if(a===l)continue;return a}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===i)throw i="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i="executing";var d=c(t,e,n);if("normal"===d.type){if(i=n.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:n.done}}"throw"===d.type&&(i="completed",n.method="throw",n.arg=d.arg)}}}(t,n,r),o}function c(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}t.wrap=a;var l={};function d(){}function h(){}function u(){}var m={};m[s]=function(){return this};var g=Object.getPrototypeOf,p=g&&g(g(x([])));p&&p!==e&&n.call(p,s)&&(m=p);var y=u.prototype=d.prototype=Object.create(m);function v(t){["next","throw","return"].forEach((function(e){t[e]=function(t){return this._invoke(e,t)}}))}function f(t,e){var i;this._invoke=function(s,o){function r(){return new e((function(i,r){!function i(s,o,r,a){var l=c(t[s],t,o);if("throw"!==l.type){var d=l.arg,h=d.value;return h&&"object"==typeof h&&n.call(h,"__await")?e.resolve(h.__await).then((function(t){i("next",t,r,a)}),(function(t){i("throw",t,r,a)})):e.resolve(h).then((function(t){d.value=t,r(d)}),(function(t){return i("throw",t,r,a)}))}a(l.arg)}(s,o,i,r)}))}return i=i?i.then(r,r):r()}}function w(t,e){var n=t.iterator[e.method];if(void 0===n){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,w(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var i=c(n,t.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,l;var s=i.arg;return s?s.done?(e[t.resultName]=s.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):s:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function b(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function S(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(b,this),this.reset(!0)}function x(t){if(t){var e=t[s];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function e(){for(;++i<t.length;)if(n.call(t,i))return e.value=t[i],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:E}}function E(){return{value:void 0,done:!0}}return h.prototype=y.constructor=u,u.constructor=h,u[r]=h.displayName="GeneratorFunction",t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,u):(t.__proto__=u,r in t||(t[r]="GeneratorFunction")),t.prototype=Object.create(y),t},t.awrap=function(t){return{__await:t}},v(f.prototype),f.prototype[o]=function(){return this},t.AsyncIterator=f,t.async=function(e,n,i,s,o){void 0===o&&(o=Promise);var r=new f(a(e,n,i,s),o);return t.isGeneratorFunction(n)?r:r.next().then((function(t){return t.done?t.value:r.next()}))},v(y),y[r]="Generator",y[s]=function(){return this},y.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var n in t)e.push(n);return e.reverse(),function n(){for(;e.length;){var i=e.pop();if(i in t)return n.value=i,n.done=!1,n}return n.done=!0,n}},t.values=x,T.prototype={constructor:T,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(S),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function i(n,i){return r.type="throw",r.arg=t,e.next=n,i&&(e.method="next",e.arg=void 0),!!i}for(var s=this.tryEntries.length-1;s>=0;--s){var o=this.tryEntries[s],r=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var a=n.call(o,"catchLoc"),c=n.call(o,"finallyLoc");if(a&&c){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(a){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(t,e){for(var i=this.tryEntries.length-1;i>=0;--i){var s=this.tryEntries[i];if(s.tryLoc<=this.prev&&n.call(s,"finallyLoc")&&this.prev<s.finallyLoc){var o=s;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var r=o?o.completion:{};return r.type=t,r.arg=e,o?(this.method="next",this.next=o.finallyLoc,l):this.complete(r)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),S(n),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var i=n.completion;if("throw"===i.type){var s=i.arg;S(n)}return s}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:x(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),l}},t}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}}));function e(t,e,n,i,s,o,r){try{var a=t[o](r),c=a.value}catch(t){return void n(t)}a.done?e(c):Promise.resolve(c).then(i,s)}var n=function(t){return function(){var n=this,i=arguments;return new Promise((function(s,o){var r=t.apply(n,i);function a(t){e(r,s,o,a,c,"next",t)}function c(t){e(r,s,o,a,c,"throw",t)}a(void 0)}))}};const i=()=>Object.prototype.hasOwnProperty.call(window,"ABTastyEditor");const s=()=>{let t;return window.ABTasty||window.ABTASTY_S?(window.ABTASTY_S&&window.ABTASTY_S.USER&&window.ABTASTY_S.USER.accountIdentifier&&window.ABTASTY_S.USER.accountIdentifier.length?t=window.ABTASTY_S.USER.accountIdentifier:window.ABTasty&&window.ABTasty.getAccountSettings&&"function"==typeof window.ABTasty.getAccountSettings?t=window.ABTasty.getAccountSettings().identifier:window.ABTasty&&window.ABTasty.accountSettings&&(t=window.ABTasty.accountSettings.identifier),t):t},o=()=>{const t=!!document.getElementById("ABTastyPreviewBar"),e=location.href.includes("ab_project=preview");return t||e},r=()=>o()||!!window.ABTasty.getTestsOnPage()[TEST_ID],a=()=>{if(i()||o())return!1;const t=ABTasty.getTestsOnPage()[TEST_ID];return!!t&&Object.keys(t.targetings.qaParameters).length>0},c="conditions",l="https://social-proof-api.abtasty.com/clients/",d=()=>{const{type:t}=DATA;return`${PACKAGE.replace("@abtasty/","")}${t?"_"+t:""}`},h=()=>{const t=d();return`${t.charAt(0).toUpperCase()}${t.slice(1)}`.split("-").join(" ")},u=()=>`${PLUGIN_ID.split("-")[0]}_${TEST_ID}`,m=(...t)=>{t.unshift(`[AB Tasty Widget] ${PACKAGE}:`),console.log(...t)},g=t=>{if(a()){const e=h();window.console.log(`%c${e} - QA Mode for campaign ${TEST_ID}\n${t}`,"background-color: rgba(0, 127, 145, 1); color: rgba(247, 247, 247, 1)")}},p=t=>{const e={promise:null,resolve:null,reject:null,name:t};return e.promise=new Promise((t,n)=>{e.resolve=t,e.reject=n}),e},y=(t,e,n)=>{let i=0,s=0;try{document.querySelector(t)}catch(e){const i=`Selector «${t}» not valid.`;return m(i),"function"==typeof n&&n(i)}function o(){clearInterval(s),clearTimeout(i)}return i=setTimeout(()=>{o();const e=`Can't find element «${t}».`;return m(e),"function"==typeof n&&n(e)},1e4),s=setInterval(()=>{const n=document.querySelector(t);return null!==n?(o(),"function"==typeof e&&e(n)):n},200),{clear:o}};async function v(t){let e;switch(t){case"IntersectionObserver":e=await("IntersectionObserver"in window&&"IntersectionObserverEntry"in window&&"intersectionRatio"in window.IntersectionObserverEntry.prototype||function(t){return new Promise((e,n)=>{const i=window.document.getElementsByTagName("script")[0],s=window.document.createElement("script");s.src=t,i.parentNode.insertBefore(s,i),s.onload=e,s.onerror=n})}("https://polyfill.io/v3/polyfill.min.js?flags=gated&features=IntersectionObserver"));break;default:e=!0}return e}class f{constructor(){this.targets=[],this.existingTargets=[],this.inViewportTargets=[],this.visibilityObserver=this.startVisibilityObserver(),this.mutationObserver=this.startMutationObserver(),this.mouseOverEvent=this.mouseOverHandler()}intersectionHandler(t){t.forEach(t=>{t.isIntersecting?(this.existingTargets.forEach(e=>{e.element.isSameNode(t.target)&&(this.inViewportTargets.push(e),this.mouseOverEvent.start())}),this.checkElements()):this.inViewportTargets=this.inViewportTargets.filter(e=>!e.element.isSameNode(t.target)||(this.mouseOverEvent.clear(),!1))})}startVisibilityObserver(){return new IntersectionObserver(this.intersectionHandler.bind(this),{root:null,rootMargin:"0px",threshold:0})}startMutationObserver(){const t=this.mutationObserver||new MutationObserver(this.checkElements.bind(this));return document.body&&t.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),t}onMouseOver({target:t,path:e}){const n=this.inViewportTargets.find(({element:n,selector:i})=>{if(n.isSameNode(t))return!0;const s=[...t.querySelectorAll(i)];if(s.length&&s.includes(n))return!0;if(e.includes(n))return!0;const o=[...t.parentElement.children],r=o.findIndex(e=>e.isSameNode(t)),a=o.filter((t,e)=>e>r);if(a.length){if(a.includes(n))return!0;if(a.some(t=>[...t.querySelectorAll(i)].includes(n)))return!0}return!1});if(n&&this.isElementVisible(n.element)){const{selector:t,element:e,uniqueId:i}=n,s=this.targets.find(e=>e.selector===t&&e.uniqueId===i);s&&s.resolve(e),this.clear(t,i)}}mouseOverHandler(){const t=["mouseover",t=>setTimeout(()=>this.onMouseOver(t),50),!0];return{start:()=>document.addEventListener(...t),clear:()=>document.removeEventListener(...t)}}isElementVisible(t){return this.isElementTopmost(t)&&this.isElementOpaque(t)}isElementOpaque(t){return"HTML"===function t(e,n){return n(e)||!e.parentElement?e:t(e.parentElement,n)}(t,t=>"0"===window.getComputedStyle(t).opacity).nodeName}isElementTopmost(t){const e=t.getBoundingClientRect(),n=[[e.left,e.top],[e.right,e.top],[e.left,e.bottom],[e.right,e.bottom],[e.left+e.width/2,e.top],[e.left+e.width/2,e.bottom],[e.left,e.height/2],[e.right,e.height/2],[e.left+e.left/2,e.height/2]];let i=!1,s=0;for(;!i&&s<n.length;){const e=document.elementFromPoint(...n[s]);i=t===e||t.contains(e),s+=1}return i}checkElements(){this.targets.forEach(({selector:t,uniqueId:e})=>{const n=document.querySelector(t);n&&!this.existingTargets.find(n=>n.element.matches(t)&&n.uniqueId===e)&&(this.existingTargets.push({element:n,selector:t,uniqueId:e}),this.visibilityObserver.observe(n))}),this.existingTargets=this.existingTargets.filter(({selector:t,element:e})=>!!document.querySelector(t)||(this.visibilityObserver.unobserve(e),!1)),this.inViewportTargets=this.inViewportTargets.filter(({selector:t,element:e,uniqueId:n})=>{if(e.matches(t)&&this.isElementVisible(e)){const i=this.targets.find(e=>e.selector===t&&e.uniqueId===n);return i&&i.resolve(e),this.clear(t,n),!1}return!0})}watch(t,e,n){this.targets.push({selector:t,resolve:e,uniqueId:n});const i=()=>{this.startMutationObserver(),this.checkElements()};document.body?i():y("body",i)}clear(t,e){[this.targets,this.existingTargets,this.inViewportTargets]=[this.targets,this.existingTargets,this.inViewportTargets].map(n=>n.filter(({selector:n,uniqueId:i})=>n!==t&&i!==e)),this.visibilityObserver.unobserve(document.querySelector(t)),0===this.targets.length&&this.mutationObserver.disconnect(),0===this.inViewportTargets.length&&this.mouseOverEvent.clear()}}class w{constructor({triggerEvent:t,triggerSelector:e,triggerDelay:n}){this.event=t,this.selector=e&&e.length?e:"body",this.delay=1e3*n,this.elementsSelectors=[],this.eventsListeners=[],this.timeouts=[],this.intervals=[],this.observers=[],this.promises=[],this.visibilityObservers=[],this.elementsWaiters=[]}async onElementVisible({promise:t,resolve:e}){const n=p(this.event+"DomReady");this.promises.push(n);const i=await this.onPageLoad(n),s=await v("IntersectionObserver"),o=function(t,e){return ABTasty.widgetUtils||(ABTasty.widgetUtils={}),ABTasty.widgetUtils[t]||Object.assign(ABTasty.widgetUtils,{[t]:new e}),ABTasty.widgetUtils[t]}("VisibilityObserver",f);if(this.visibilityObservers.push(o),s&&i){const t=u();o.watch(this.selector,e,t)}return t}onPageLoad({promise:t,resolve:e}){const n=()=>"complete"===document.readyState;if(!n()){const i=["readystatechange",()=>n()&&e(!0),{passive:!0}];return this.eventsListeners.push(i),document.addEventListener(...i),t}return e(!0),t}onClick({promise:t,resolve:e}){const n=document.createElement("style");n.type="text/css",n.id="Click_"+u(),n.innerHTML=this.selector+" {\n\t\t\tcursor: pointer !important;\n\t\t\tpointer-events: all !important;\n\t\t}",document.head.appendChild(n),this.elementsSelectors.push("#"+n.id);const i=t=>[...document.querySelectorAll(this.selector)].some(e=>e.isSameNode(t)||!!t.closest(this.selector)),s=["click",({target:t})=>i(t)&&e(!0),{passive:!0,capture:!0}];return this.eventsListeners.push(s),document.addEventListener(...s),t}onExitIntent({promise:t,resolve:e}){const n=["mouseleave",async({clientY:t})=>{t<=0&&e(!0)},{passive:!0}],i=y("body",t=>{t.addEventListener(...n),this.eventsListeners.push([t,...n]),this.elementsWaiters=this.elementsWaiters.filter(t=>t!==i)});return this.elementsWaiters.push(i),t}onReengage({promise:t,resolve:e}){const n=this.delay;let i=n;const s=[()=>(i=n,i),{passive:!0}];["click","mousemove","scroll","keypress"].forEach(t=>{document.addEventListener(t,...s),this.eventsListeners.push([t,...s])});const o=setInterval(()=>{i<=0?e(!0):i-=100},100);return this.intervals.push(o),t}onCustomTrigger({promise:t,resolve:e}){const{triggerEventCustomScript:n}=DATA;return new Function(`return new Promise(async resolve => {${n}})`)().then(t=>t&&e(!0)),t}getSocialProofPurchases({promise:t,resolve:e}){const n=window.ABTastyProductKey,i=s(),{viewInterval:o,triggerSocialProofMinPurchases:r,spNoTrim:a}=DATA;return n||(g("Not able to find ABTastyProductKey, impossible to call the API."),e(!1)),n&&i?fetch(`${l}${i}/metrics/i?key=${n}${a?"&noTrim=true":""}`).then(t=>t.ok&&t.json()).then(t=>(t=>{if(void 0===o||void 0===r)return!1;const e=void 0!==t[o]&&t[o]>=r;return e||g(`Widget will not be shown, product has been purchased ${t[o]} times while ${r} are required`),e})(t)&&e(""+t[o])).catch(()=>g("Failed to fetch datas from server.")):e(!1),t}getSocialProofPageViews({promise:t,resolve:e}){const{viewInterval:n,triggerSocialProofMinPageViews:i,spNoTrim:o}=DATA,r=encodeURIComponent(o?window.location.href.replace(window.location.origin,""):""+window.location.pathname),a=s();return r&&a?fetch(`${l}${a}/metrics/pv?key=${r}${o?"&noTrim=true":""}`).then(t=>t.ok&&t.json()).then(t=>(t=>{if(void 0===n||void 0===i)return!1;const e=void 0!==t[n]&&t[n]>=i;return e||g(`Widget will not be shown, page has been seen ${t[n]} times while ${i} are required`),e})(t)&&e(""+t[n])).catch(()=>g("Failed to fetch datas from server.")):e(!1),t}onConsent({promise:t,resolve:e}){if(!window.ABTasty.cnilReady){const n=["consentValid",()=>e(!0)];return this.eventsListeners.push(n),document.addEventListener(...n),t}return e(!0),t}clear(){if(this.elementsSelectors.length&&(this.elementsSelectors.forEach(t=>{document.querySelector(t)&&document.querySelector(t).remove()}),this.elementsSelectors=[]),this.eventsListeners.length&&(this.eventsListeners.forEach(t=>{const[e,...n]="string"==typeof t[0]?[document,...t]:t;e&&n.length>1&&e.removeEventListener(...n)}),this.eventsListeners=[]),this.timeouts.length&&(this.timeouts.forEach(t=>clearTimeout(t)),this.timeouts=[]),this.intervals.length&&(this.intervals.forEach(t=>clearInterval(t)),this.intervals=[]),this.observers.length&&(this.observers.forEach(t=>t.disconnect()),this.observers=[]),this.visibilityObservers.length){const t=u();this.visibilityObservers.forEach(e=>e.clear(this.selector,t)),this.visibilityObservers=[]}return this.promises.length&&(this.promises.forEach(t=>t.resolve(!1)),this.promises=[]),this.elementsWaiters.length&&(this.elementsWaiters.forEach(t=>t.clear()),this.elementsWaiters=[]),this}async isTriggered(){this.clear();const t=p(this.event);this.promises.push(t);const e={consent:()=>this.onConsent(t),direct:()=>!0,pageLoad:()=>this.onPageLoad(t),click:()=>this.onClick(t),exitIntent:()=>this.onExitIntent(t),reengage:()=>this.onReengage(t),elementVisible:()=>this.onElementVisible(t),script:()=>this.onCustomTrigger(t),socialProofPurchases:()=>this.getSocialProofPurchases(t),socialProofPageViews:()=>this.getSocialProofPageViews(t)},n=!Object.prototype.hasOwnProperty.call(e,this.event)||await e[this.event]();return this.clear(),"reengage"!==this.event&&this.delay?n&&await(async()=>{const t=p(this.event+"Delay");return this.promises.push(t),setTimeout(()=>{t.resolve(!0),this.clear()},this.delay),t.promise})():n}}class b{constructor({displayRecurrence:t,closingRecurrence:e,validationRecurrence:n},i){this.displayRecurrence=parseFloat(t),this.closingRecurrence=parseFloat(e),this.validationRecurrence=parseFloat(n),this.onSetCallback=i,this.widgetName=d(),this.uniqueId=u(),this.recurrenceKey=`${this.widgetName}_${this.uniqueId}`,this.isListeningStorageEvent=this.listenStorageEvent(),this.pendingRecurrence=!1}onStorage({key:t}){const e=localStorage.getItem("ABTastyWidgetsTemporary"),n=sessionStorage.getItem("ABTastyWidgets");"ABTastyData"===t&&!e&&n&&localStorage.setItem("ABTastyWidgetsTemporary",n)}listenStorageEvent(){return this.isListeningStorageEvent||window.addEventListener("storage",this.onStorage.bind(this)),!0}getGivenRecurrenceStorageParsed(t){try{const e=t.getItem("ABTastyWidgets");return JSON.parse(e)}catch(e){return t.removeItem("ABTastyWidgets"),!1}}getSessionRecurrenceStorageParsed(){return this.getGivenRecurrenceStorageParsed(window.sessionStorage)}getLocalRecurrenceStorageParsed(){return this.getGivenRecurrenceStorageParsed(window.localStorage)}removeGivenStorage(t,e){const{[this.recurrenceKey]:n,...i}=e;return Object.entries(i).length?(t.setItem("ABTastyWidgets",JSON.stringify(i)),i):(t.removeItem("ABTastyWidgets"),!1)}removeSessionRecurrenceStorage(){const t=this.getSessionRecurrenceStorageParsed();return!!t&&this.removeGivenStorage(window.sessionStorage,t)}removeLocalRecurrenceStorage(){const t=this.getLocalRecurrenceStorageParsed();return!!t&&this.removeGivenStorage(window.localStorage,t)}getSessionRecurrence(){const t=this.getSessionRecurrenceStorageParsed();return!!t&&t[this.recurrenceKey]}getLocalRecurrence(){const t=this.getLocalRecurrenceStorageParsed();return!!t&&t[this.recurrenceKey]}getCurrentRecurrence(){const t=this.getSessionRecurrence(),e=this.getLocalRecurrence();return t||e||{type:!1}}isOver(){const t=localStorage.getItem("ABTastyWidgetsTemporary"),e=!(!t||!t.includes(this.recurrenceKey))||this.getSessionRecurrence();t&&(sessionStorage.setItem("ABTastyWidgets",t),localStorage.removeItem("ABTastyWidgetsTemporary"));const n=this.getLocalRecurrence(),i=(n?parseFloat(n.stamp):0)<(new Date).getTime();return i&&this.removeLocalRecurrenceStorage(),!this.pendingRecurrence&&i&&!this.getLocalRecurrence()&&!e}setRecurrence(t,e){0!==t&&(window.removeEventListener("storage",this.onStorage.bind(this)),this.isListeningStorageEvent=!1);const n=this.getTypeOfStorage(t);if(o()||!n&&"object"!=typeof n)return!1;const{storageString:i,storageMethod:s}=n,r=this.getStamp(t),a={type:e,stamp:r},{type:c}=this.getCurrentRecurrence(),l=async()=>{const t=this.getSessionRecurrence(),e=this.getLocalRecurrence();let n;"session"===i?t?n=this.removeSessionRecurrenceStorage():(this.removeLocalRecurrenceStorage(),n=this.getSessionRecurrenceStorageParsed()):"local"===i&&(e?n=this.removeLocalRecurrenceStorage():(this.removeSessionRecurrenceStorage(),n=this.getLocalRecurrenceStorageParsed()));const o=n?{[this.recurrenceKey]:a,...n}:{[this.recurrenceKey]:a};if(!window.ABTasty.cnilReady){this.pendingRecurrence=!0;const t=new w({triggerEvent:"consent"});await t.isTriggered(),this.pendingRecurrence=!1}s.setItem("ABTastyWidgets",JSON.stringify(o)),this.onSetCallback&&"function"==typeof this.onSetCallback&&this.onSetCallback()};if(!s)return!1;if(c&&"validation"!==e)if("closing"===e&&"validation"!==c)l();else{if("display"!==e||"validation"===c||"closing"===c)return!1;l()}else l();return r}setDisplayRecurrence(){this.setRecurrence(this.displayRecurrence,"display")}setClosingRecurrence(){this.setRecurrence(this.closingRecurrence,"closing")}setValidationRecurrence(){this.setRecurrence(this.validationRecurrence,"validation")}getStamp(t){return(new Date).getTime()+864e5*t}getTypeOfStorage(t){return!(isNaN(t)||t<0||0!==t&&!t)&&(t>0?{storageString:"local",storageMethod:window.localStorage}:0===t&&{storageString:"session",storageMethod:window.sessionStorage})}}class S{constructor(t,e,n){this.recurrence=t,this.isWidgetApplied=e,this.callback=n,this.observer=new MutationObserver(this.observerHandler.bind(this)),this.eventListenerParams=["abtasty_resetActionTracking",this.eventHandler.bind(this),{passive:!0}],this.elementsWaiters=[]}recurrenceIsDone(){return!this.recurrence||this.recurrence.isOver()}decisionHandler(t){const e=r(),{type:n}=this.recurrence?this.recurrence.getCurrentRecurrence():{type:!1},i=()=>t&&"display"===n||this.recurrenceIsDone();return!this.isWidgetApplied()&&e&&i()?(this.clearWatcher(),this.callback("rebuild",t)):(!this.isWidgetApplied()||e&&i())&&(this.isWidgetApplied()||e)||(this.clearWatcher(),this.callback("remove",t),this.watch()),this}eventHandler(){let t=r();return[250,500].forEach(e=>setTimeout(()=>500===e&&r()===t?this:(t=r(),this.decisionHandler(!1)),e)),this}observerHandler(t){const e=t.some(({removedNodes:t})=>t&&t.length),n=t.some(({addedNodes:t})=>t&&t.length);return e||n?(this.decisionHandler(!0),this):this}watch(){if(i())return this;this.clearWatcher(),document.addEventListener(...this.eventListenerParams);const t=y("body",e=>{const n=[e,{childList:!0,subtree:!0}];this.observer.observe(...n),this.elementsWaiters=this.elementsWaiters.filter(e=>e!==t)});return this.elementsWaiters.push(t),this}clearWatcher(){return document.removeEventListener(...this.eventListenerParams),this.elementsWaiters.length&&(this.elementsWaiters.forEach(t=>t.clear()),this.elementsWaiters=[]),this.observer.disconnect(),this}}class T{constructor(){this.children=void 0,this.uniqueId=u(),this.widgetName=d(),this.prettyName=h(),this.recurrenceParams=(()=>{const{displayRecurrence:t,closingRecurrence:e,validationRecurrence:n}=DATA;if(i()||!t&&!e&&!n)return!1;const s={everytime:()=>-1,session:()=>0,once:()=>395,day:t=>DATA[t+"_day"],week:t=>7*DATA[t+"_week"],month:t=>30.5*DATA[t+"_month"]},o={};return t&&(o.displayRecurrence=s[t]("displayRecurrence")),e&&(o.closingRecurrence=s[e]("closingRecurrence")),n&&(o.validationRecurrence=s[n]("validationRecurrence")),o})(),this.triggerParams=(()=>{let{triggerEvent:t}=DATA;const{triggerEventClick:e,triggerEventReengageDelay:n,socialProofContentType:s,triggerEventElementVisible:o,triggerEventDelay:r}=DATA;if(i()||!t&&!s)return!1;const a={click:()=>e,elementVisible:()=>o},c=Object.prototype.hasOwnProperty.call(a,t)?a[t]():"body",l="reengage"===t?n:r;return s&&(t=1===s?"socialProofPurchases":"socialProofPageViews"),{triggerEvent:t,triggerSelector:c,triggerDelay:l}})(),this.recurrence=!!this.recurrenceParams&&new b(this.recurrenceParams,this.clearGivenClearables.bind(this)),this.trigger=!!this.triggerParams&&new w(this.triggerParams),this.pageWatcher=new S(this.recurrence,this.isWidgetApplied.bind(this),this.onPageChange.bind(this)),this.hasOncePerPageTrigger=(()=>{const{isOncePerPageTrigger:t,triggerEvent:e}=DATA;return!(!t||!["click","script"].includes(e))||["pageLoad","direct","reengage","socialProofPurchases","socialProofPageViews","elementVisible"].some(t=>t===e)})(),this.basicClassName="ab_widget_container_"+this.widgetName,this.widgetContainerId=`${this.basicClassName}_${this.uniqueId}`,this.contentClassName=this.basicClassName+"_content",this.overlayClassName=this.basicClassName+"_overlay",this.closeButtonClassName=this.basicClassName+"_close_button",this.hideClassName="ab_hide_"+this.uniqueId,this.domElement=this.getDom(),this.hasBeenShown=!1,this.closedByUser=!1,this.eventsListeners=[],this.timeouts=[],this.intervals=[],this.observers=[],this.promises=[],this.elementsWaiters=[]}clearGivenClearables(){this.eventsListeners.length&&(this.eventsListeners.forEach(t=>document.removeEventListener(...t)),this.eventsListeners=[]),this.timeouts.length&&(this.timeouts.forEach(t=>clearTimeout(t)),this.timeouts=[]),this.intervals.length&&(this.intervals.forEach(t=>clearInterval(t)),this.intervals=[]),this.observers.length&&(this.observers.forEach(t=>t.disconnect()),this.observers=[]),this.promises.length&&(this.promises.forEach(t=>t.resolve(!1)),this.promises=[]),this.elementsWaiters.length&&(this.elementsWaiters.forEach(t=>t.clear()),this.elementsWaiters=[])}isWidgetApplied(){return this.domElement&&!!this.domElement.closest("html")}removeOldDomElement(){const t=document.getElementById(this.widgetContainerId);return t&&t.remove(),this}async insert(){const t=(t,e,n)=>{this.elementsWaiters=this.elementsWaiters.filter(t=>t!==e),g(t),n(t)},e=new Promise((e,n)=>{const i=y("head",t=>{this.elementsWaiters=this.elementsWaiters.filter(t=>t!==i),e(t.appendChild(this.styleElement))},e=>t(e,i,n));this.elementsWaiters.push(i)}),n=new Promise((e,n)=>{const{layout:i,elementReferrer:s,referrerInsertType:o}=DATA,{selector:r,position:a}="string"==typeof i&&"free"===i&&"string"==typeof s&&"string"==typeof o?{selector:s,position:o}:{selector:"body",position:"beforeend"},c=y(r,t=>{this.elementsWaiters=this.elementsWaiters.filter(t=>t!==c),this.removeOldDomElement(),e(t.insertAdjacentElement(a,this.domElement))},e=>t(e,c,n));this.elementsWaiters.push(c)});return Promise.all([n,e]).then(()=>this)}remove(){return this.pageWatcher.clearWatcher(),this.domElement&&this.domElement.closest("html")&&this.domElement.remove(),this.styleElement&&this.styleElement.closest("html")&&this.styleElement.remove(),this.hasOncePerPageTrigger?this.pageWatcher.watch():i()||this.init().then(({response:t})=>t?this.show():this),this}show(){return this.hasBeenShown||i()||window.ABTastyEvent(this.prettyName+" displayed",null,TEST_ID),this.closedByUser=!1,this.domElement.classList.remove(this.hideClassName),this.recurrence&&this.recurrence.setDisplayRecurrence(),this.hasBeenShown=!0,this.pageWatcher.watch(),this}hide(){return this.hasBeenShown&&!i()&&window.ABTastyEvent(this.prettyName+" closed",null,TEST_ID),this.closedByUser=!0,this.domElement.classList.add(this.hideClassName),this}async init(t){if(!i()&&!r())return!1;if(this.trigger&&this.trigger.promises.length)return!1;const e=this.recurrence&&this.recurrence.isOver();if(this.recurrence&&!e)return this.pageWatcher.watch(),!1;this.pageWatcher.watch();const n=i()||!this.trigger||this.trigger&&await this.trigger.isTriggered();return!!n&&(await this.insert(),this.addCloseEvent(),i()||t||this.hasBeenShown||void 0===this.children||"function"!=typeof this.children.refreshContent||this.children.refreshContent(n),{container:this,response:n})}onPageChange(t,e){const n=()=>this.init().then(({response:t})=>t&&this.show());switch(e||(this.hasBeenShown=!1),t){case"remove":this.isWidgetApplied()?this.remove():(this.trigger&&this.trigger.clear(),this.pageWatcher.watch());break;case"rebuild":this.hasBeenShown?this.closedByUser?this.pageWatcher.watch():this.insert().then(t=>t.show()):n()}}addCloseEvent(...t){const{closeButton:e,overlayClickable:n,layout:s}=DATA,o=[];if(void 0!==n&&n&&void 0!==s&&"popin"===s&&o.push("."+this.overlayClassName),void 0!==e&&e&&o.push("."+this.closeButtonClassName),!o.length)return this;const r=this.domElement.querySelectorAll(o.join(", "));return r.length?(t.push(...r),t.forEach(t=>{i()&&(t.dataset.abtastyActionnable="true"),t.addEventListener("click",()=>{this.recurrence&&this.recurrence.setClosingRecurrence(),this.hide(),setTimeout(()=>this.remove(),1e3)},{passive:!0,once:!0})}),this):this}getDom(){const{closeButton:t,layout:e}=DATA,n=document.createElement("div");return n.className=`${this.basicClassName} ${this.hideClassName}`,n.id=this.widgetContainerId,n.innerHTML=`\n\t\t\t${void 0!==e&&"popin"===e?`<div class="${this.overlayClassName}"></div>`:""}\n\t\t\t<div class="${this.contentClassName}">\n\t\t\t${t?`<button class="${this.closeButtonClassName}"><svg viewBox="0 0 16 16">\n\t<defs><path id="prefix__a" d="M12 4.991L11.009 4 8 7.009 4.991 4 4 4.991 7.009 8 4 11.009 4.991 12 8 8.991 11.009 12 12 11.009 8.991 8z"></path></defs>\n\t<g><use xlink:href="#prefix__a"></use></g>\n</svg></button>`:""}\n\t\t\t</div>`,n}loadFont(t,e){if(!t||"inherit"===t)return;const n=document.createElement("style");n.appendChild(document.createTextNode(`\t\t\t@font-face { \t\t\tfont-family: '${t}'; \t\t\tsrc: url('${e}');\t\t\t}\t\t`)),document.head.appendChild(n)}getStyleTag(t=""){const{noStyles:e,layout:n}=DATA,{backgroundColor:s,isBackgroundImage:o,backgroundImage:r,backgroundSize:a,backgroundPosition:c,backgroundRepeat:l,borderColor:d,borderRadius:h,borderWidth:u,textColor:m,textAlign:g,fontName:p,fontStyle:y,fontSize:v,overlayColor:f,dropShadow:w,dropShadowColor:b,dropShadowBlur:S,containerMargin:T,containerPadding:x,closeButton:E,buttonsBorderWidth:_,buttonsBorderColor:A,buttonsBorderRadius:C,buttonsBackgroundColor:$,buttonsTextColor:N,buttonsFontName:L,buttonsFontStyle:B,buttonsFontSize:k}=e?{}:DATA,I=document.createElement("style");I.type="text/css",i()&&I.setAttribute("abtasty-script-added","true"),this.loadFont(p,y);const R=`background: ${["string"==typeof s?s:"rgba(255, 255, 255, 1)",o&&"string"==typeof r&&r.length?`url(${r})`:"",o&&"string"==typeof c&&"100% 100%"!==a?c:"0 0",o&&"string"==typeof a?"/ "+a:"/ auto",o&&l&&!["cover","100% 100%"].includes(a)?"repeat":"no-repeat"].join(" ").trim()};`,P="number"==typeof u&&u>0,O=`border: ${[P?u+"px":"unset",P?"solid":"",P&&"string"==typeof d&&d.length?d:""].join(" ").trim()};`,W=void 0!==h?`border-radius: ${h}px;`:"",D=void 0!==m?`color: ${m}; fill: ${m};`:"",j=void 0!==g?`text-align: ${g};`:"",q=p&&"inherit"!==p?`font-family:${p};`:y||"",V=v?`font-size: ${v}px;`:"",M=void 0!==w&&w?`box-shadow: 0 5px ${S}px 0 ${b};`:"",H=T instanceof Array&&1===T.length&&T[0],F=H?`margin: ${H.top}px ${H.right}px ${H.bottom}px ${H.left}px;`:"",U=H?`margin: calc(${H.top}px * 0.5) calc(${H.right}px * 0.5) calc(${H.bottom}px * 0.5) calc(${H.left}px * 0.5);`:"",G=x instanceof Array&&1===x.length&&x[0],z=G?`padding: ${G.top}px ${G.right}px ${G.bottom}px ${G.left}px;`:"",Y=G?`padding: calc(${G.top}px * 0.5) calc(${G.right}px * 0.5) calc(${G.bottom}px * 0.5) calc(${G.left}px * 0.5);`:"",K=void 0!==_&&_?`border-width: ${_}px; border-style: solid;`:"",J=[A,_].every(t=>void 0!==t)&&_?`border-color: ${A};`:"",X=void 0!==C?`border-radius: ${C}px;`:"",Q=void 0!==$?`background-color: ${$};`:"",Z=void 0!==N?`color: ${N};`:"",tt=L&&"inherit"!==L?`font-family:${L};`:B||"",et=k?`font-size: ${k}px;`:"",nt=void 0!==n&&"popin"===n?[`#${this.widgetContainerId} .${this.overlayClassName} {`,`background-color: ${void 0!==f?f:"rgba(0, 0, 0, 0.6)"};`,"}"].join(""):"",it=e||void 0!==E&&E?[`#${this.widgetContainerId} .${this.contentClassName} .${this.closeButtonClassName} {`,"position: absolute;","top: 8px;","right: 8px;","width: auto;","height: auto;","background: none;","border: none;","cursor: pointer;","outline: none;","padding: 0;","margin: 0;","}",`#${this.widgetContainerId} .${this.contentClassName} .${this.closeButtonClassName} svg {`,"pointer-events: none;","width: 16px;","height: 16px;",D,q,V,"}"].join(""):"";return I.textContent=[`.${this.hideClassName} {`,"opacity: 0 !important;","pointer-events: none;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,R,W,O,D,j,M,F,q,V,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,"display: block;","line-height: 1;","text-indent: unset;",z,q,V,"}",`#${this.widgetContainerId} .${this.contentClassName} > * a, `,`#${this.widgetContainerId} .${this.contentClassName} > * button {`,K,J,X,Q,Z,tt,et,"}","@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,U,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,Y,"}","}",nt,it,""+t].join(""),I}}class x extends T{constructor(){super(),this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){return[`#${this.widgetContainerId} {`,"position: fixed;","top: 0;","left: 0;","width: 100%;","height: 100%;","z-index: 9999;","opacity: 1;","transition: opacity 0.25s ease;","}",`#${this.widgetContainerId} .${this.overlayClassName} {`,"position: absolute;","z-index: -1;","top: 0;","left: 0;","width: 100%;","height: 100%;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: absolute;","left: 50%;","top: 50%;","transform: translate(-50%, -50%);","width: auto;","height: auto;","}","@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,"max-width: 94vw;","}","}"].join("")}}class E extends T{constructor(){super(),this.position="string"==typeof DATA.layout&&"bannerTop"===DATA.layout?"top":"bottom",this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){return[`#${this.widgetContainerId} {`,"position: fixed;",this.position+": 0;","left: 0;","width: 100%;","height: auto;","z-index: 9999;","opacity: 1;","transition: opacity 0.25s ease;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: relative;","}"].join("")}}class _ extends T{constructor(){super(),this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){return[`#${this.widgetContainerId} {`,"width: auto;","height: auto;","margin: 0;","padding: 0;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: relative;","}"].join("")}}const A=()=>{const{layout:t}=DATA;let e;switch(t){case"popin":e=new x;break;case"bannerTop":case"bannerBottom":e=new E;break;case"free":e=new _;break;default:e=new T}return e},C={category:c,type:"slider",min:1},$=[{...C,propName:"day",label:"widget_common_conditions_recurrence_ifOptionVariable_labelDays",value:5,max:395},{...C,propName:"week",label:"widget_common_conditions_recurrence_ifOptionVariable_labelWeeks",value:2,max:56},{...C,propName:"month",label:"widget_common_conditions_recurrence_ifOptionVariable_labelMonths",value:1,max:13}],N={category:c,type:"select",options:[{label:"widget_common_conditions_recurrence_option_everyTime",value:"everytime"},{label:"widget_common_conditions_recurrence_option_everySession",value:"session"},{label:"widget_common_conditions_recurrence_option_everyXDays",value:"day"},{label:"widget_common_conditions_recurrence_option_everyXWeeks",value:"week"},{label:"widget_common_conditions_recurrence_option_everyXMonths",value:"month"},{label:"widget_common_conditions_recurrence_option_once",value:"once"}],value:"everytime"},L={...N,label:"widget_common_conditions_recurrence_label_widgetDisplayed",propName:"displayRecurrence"},B=($.map(t=>({...t,propName:`${L.propName}_${t.propName}`,conditions:[{field:L.propName,value:t.propName}]})),{...N,label:"widget_common_conditions_recurrence_label_widgetDisplayedAfterClosure",propName:"closingRecurrence"}),k=($.map(t=>({...t,propName:`${B.propName}_${t.propName}`,conditions:[{field:B.propName,value:t.propName}]})),{...N,label:"widget_common_conditions_recurrence_label_widgetDisplayedAfterSubmission",propName:"validationRecurrence"});$.map(t=>({...t,propName:`${k.propName}_${t.propName}`,conditions:[{field:k.propName,value:t.propName}]}));B.condition=({closeButton:t,layout:e,overlayClickable:n})=>!("popin"===e&&!1===t&&!1===n||void 0!==e&&"popin"!==e&&!1===t);const I={pageLoad:{label:"widget_common_conditions_triggering_option_pageload",value:"pageLoad"},direct:{label:"widget_common_conditions_triggering_option_asap",value:"direct"},exitIntent:{label:"widget_common_conditions_triggering_option_exitIntent",value:"exitIntent"},reengage:{label:"widget_common_conditions_triggering_option_afterXSecondsOfInactivity",value:"reengage"},click:{label:"widget_common_conditions_triggering_option_click",value:"click"},elementVisible:{label:"widget_common_conditions_triggering_option_elementVisible",value:"elementVisible"},customScript:{label:"widget_common_conditions_triggering_option_customTrigger",value:"script"}};Object.keys(I).map(t=>I[t]);var R=function(t){if(Array.isArray(t))return t};var P=function(t,e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t)){var n=[],i=!0,s=!1,o=void 0;try{for(var r,a=t[Symbol.iterator]();!(i=(r=a.next()).done)&&(n.push(r.value),!e||n.length!==e);i=!0);}catch(t){s=!0,o=t}finally{try{i||null==a.return||a.return()}finally{if(s)throw o}}return n}};var O=function(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i};var W=function(t,e){if(t){if("string"==typeof t)return O(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?O(t,e):void 0}};var D=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")};var j=function(t,e){return R(t)||P(t,e)||W(t,e)||D()};var q=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")};function V(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}var M=function(t,e,n){return e&&V(t.prototype,e),n&&V(t,n),t},H=["fr","en","de","es"],F=["day","hour","minute","second"],U={day:{en:"Day",fr:"Jour",es:"Dia",de:"Tag"},days:{en:"Days",fr:"Jours",es:"Dias",de:"Tage"},hour:{en:"Hour",fr:"Heure",es:"Hora",de:"Zeit"},hours:{en:"Hours",fr:"Heures",es:"Horas",de:"Stunden"},minute:"Min",second:{en:"Sec",fr:"Sec",es:"Seg",de:"Sek"}},G=window.ABTASTY_S&&ABTASTY_S.USER&&ABTASTY_S.USER.lang?ABTASTY_S.USER.lang.split("_")[0]:navigator.language.substr(0,2)||"en",z=function(t){return H.indexOf(t)>-1}(G)?G:"en",Y={day:U.day[z],days:U.days[z],hour:U.hour[z],hours:U.hours[z],minute:U.minute,minutes:U.minute,second:U.second[z],seconds:U.second[z]};var K=function(){function t(e,n){q(this,t),this.testId=e,this.data=n,this.targetselector=n.selector,this.container=document.createElement("abtasty-countdown"),this.digitElements={},this.textElements={},this.timeElements={},this.timeLoop=null,this.maxWidth=0,this.previewTime=172799,this.unitsText=Y,this.data.customTexts&&(this.unitsText={day:this.data.customDaysLabel,days:this.data.customDaysLabel,hour:this.data.customHoursLabel,hours:this.data.customHoursLabel,minute:this.data.customMinutesLabel,minutes:this.data.customMinutesLabel,second:this.data.customSecondsLabel,seconds:this.data.customSecondsLabel})}return M(t,[{key:"insert",value:function(t,e){return t.insertAdjacentElement(e,this.container),this}},{key:"setText",value:function(t){var e=this;F.forEach((function(n){var i=t[n];String(i).length<2&&(i="0".concat(i)),e.digitElements[n].textContent=i,e.textElements[n].textContent=1===i?e.unitsText[n]:e.unitsText["".concat(n,"s")],e.maxWidth<e.digitElements[n].offsetWidth&&(e.maxWidth=e.digitElements[n].offsetWidth,e.digitElements[n].style.minWidth="".concat(e.maxWidth,"px"),window.requestAnimationFrame((function(){e.setText(t)}))),e.digitElements[n].style.minWidth="".concat(e.maxWidth,"px")}))}},{key:"onTimeEnd",value:function(){if("hideWidget"===this.data.endSettings)return this.parentContainer.hide(),void(this.parentContainer.domElement.style.display="none");var t={};"showText"===this.data.endSettings&&(t.endText=!0,t.endCountdown=!0,t.endButton=!1),"showTextAndButton"===this.data.endSettings&&(t.endText=!0,t.endButton=!0,t.endCountdown=!0),"hideCountdownAndShowText"===this.data.endSettings&&(t.endText=!0,t.endCountdown=!1,t.endButton=!1),"hideCountdownAndShowTextAndButton"===this.data.endSettings&&(t.endText=!0,t.endCountdown=!1,t.endButton=!0);var e=[" abtasty-countdown-".concat(this.data.endSettings),"abtasty-countdown-finish"];for(var n in t)t[n]?e.push("abtasty-countdown-".concat(n,"-show")):e.push("abtasty-countdown-".concat(n,"-hide"));this.container.className+=" ".concat(e.join(" "))}},{key:"setCountdown",value:function(){var t,e=(new Date).getTime(),n=((t=this.data).dateTimeStart+(t.timezoneOffset||0)-e)/1e3;if(window.ABTastyEditor&&("ifEnded"===this.data.previewBlock&&(n=-1),this.previewTime-=1),n<=0)return this.setText({day:0,hour:0,minute:0,second:0}),void this.onTimeEnd();var i=Math.floor(n/86400);n-=86400*i;var s=Math.floor(n/3600);n-=3600*s;var o=Math.floor(n/60);n-=60*o;var r=Math.floor(n);this.setText({day:i,hour:s,minute:o,second:r})}},{key:"getStyle",value:function(){return"\n abtasty-countdown .abtasty-countdown-finish-text,\n abtasty-countdown .abtasty-countdown-top-message {\n text-align: ".concat(this.data.textAlign,"!important;\n color: ").concat(this.data.msgTextColor,";\n ").concat(this.data.fontName&&"inherit"!==this.data.fontName?"font-family:".concat(this.data.fontName,";"):this.data.fontStyle||"",";\n }\n \n abtasty-countdown .abtasty-countdown-elm-number{\n font-size: ").concat(this.data.numbersfontSize,"px; \n color: ").concat(this.data.numberstextColor,";\n text-align: ").concat(this.data.numberstextAlign,"; \n font-weight: initial;\n ").concat(this.data.numbersfontName&&"inherit"!==this.data.numbersfontName?"font-family:".concat(this.data.numbersfontName,";"):this.data.numbersfontStyle||"",";\n }\n\n abtasty-countdown .abtasty-countdown-elm-text{\n ").concat(this.data.legendfontName&&"inherit"!==this.data.legendfontName?"font-family:".concat(this.data.legendfontName,";"):this.data.legendfontStyle||"",";\n font-size: ").concat(this.data.legendfontSize,"px; \n color: ").concat(this.data.legendtextColor,";\n text-align: ").concat(this.data.textAlign,"; \n }\n \n abtasty-countdown .abtasty-countdown-elm-time {\n border-radius: ").concat(this.data.countdownBorderRadius,"px;\n border: ").concat(this.data.countdownBorderWidth,"px solid ").concat(this.data.countdownBorderColor,";\n background-color: ").concat(this.data.numbersBackgroundColor,"; \n } \n ")}},{key:"setButton",value:function(){if(this.data.button){var t=this.container.querySelector(".abtasty-countdown-bottom-button"),e=document.createElement("a");e.href=this.data.btnLink,e.innerHTML=this.data.btnLabel,this.data.btnTargetBlank&&(e.target="_blank"),t.appendChild(e)}var n=this.container.querySelector(".abtasty-countdown-finish-button"),i=document.createElement("a");i.href=this.data.endBtnLink,this.data.endBtnTargetBlank&&(i.target="_blank"),i.innerHTML=this.data.endBtnLabel,n.appendChild(i)}},{key:"setContent",value:function(){window.testt=this;var t=this.container.querySelector(".abtasty-countdown-top-message"),e=document.createElement("div");e.innerHTML=this.data.message,t.appendChild(e),t=this.container.querySelector(".abtasty-countdown-finish-text"),(e=document.createElement("div")).innerHTML=this.data.endMessage,t.appendChild(e)}},{key:"init",value:function(t){var e,n,i=this;try{this.parentContainer=t,this.container.className="abtasty-countdown-layout-block","bannerTop"!==this.data.layout&&"bannerBottom"!==this.data.layout||(this.container.className="abtasty-countdown-layout-line",t.domElement.querySelectorAll(".".concat(t.closeButtonClassName)).forEach((function(t){t.className+=" abtasty-countdown-close-inline"}))),this.container.innerHTML='\n <div class="abtasty-countdown-layout-'.concat(this.data.layout,'">\n <div class="abtasty-countdown-clock">\n <div class="abtasty-countdown-days abtasty-countdown-elm-time">\n <div class="abtasty-countdown-days__digit abtasty-countdown-elm-number"></div>\n <div class="abtasty-countdown-days__text abtasty-countdown-elm-text"></div>\n </div>\n <div class="abtasty-countdown-hours abtasty-countdown-elm-time">\n <div class="abtasty-countdown-hours__digit abtasty-countdown-elm-number"></div>\n <div class="abtasty-countdown-hours__text abtasty-countdown-elm-text"></div>\n </div>\n <div class="abtasty-countdown-minutes abtasty-countdown-elm-time">\n <div class="abtasty-countdown-minutes__digit abtasty-countdown-elm-number"></div>\n <div class="abtasty-countdown-minutes__text abtasty-countdown-elm-text"></div>\n </div>\n <div class="abtasty-countdown-seconds abtasty-countdown-elm-time">\n <div class="abtasty-countdown-seconds__digit abtasty-countdown-elm-number"></div>\n <div class="abtasty-countdown-seconds__text abtasty-countdown-elm-text"></div>\n </div>\n </div>\n <div class="abtasty-countdown-top-message"></div>\n <div class="abtasty-countdown-finish-text"></div>\n <div class="abtasty-countdown-finish-button"></div>\n <div class="abtasty-countdown-bottom-button"></div>\n </div>'),this.container.insertAdjacentElement("afterbegin",(e="".concat("abtasty-countdown{display:inline-block}abtasty-countdown>div{display:inline-block;text-align:center;margin:10px}abtasty-countdown .abtasty-countdown-finish-text,abtasty-countdown .abtasty-countdown-top-message{margin-bottom:15px}abtasty-countdown .abtasty-countdown-elm-time{display:inline-block;padding:6px;margin:6px 6px 15px}abtasty-countdown .abtasty-countdown-elm-text{text-align:center}abtasty-countdown .abtasty-countdown-elm-number,abtasty-countdown .abtasty-countdown-elm-text{font-weight:700;font-stretch:normal;font-style:normal;line-height:normal;letter-spacing:normal}abtasty-countdown .abtasty-countdown-bottom-button a,abtasty-countdown .abtasty-countdown-finish-button a{cursor:pointer;text-decoration:none;display:block;border:1px solid #57b8c7;text-align:center;display:inline-block;padding:6px 10px}.abtasty-countdown-layout-line.abtasty-countdown-finish .abtasty-countdown-finish-text{display:table-cell;padding:0 25px;vertical-align:middle}.abtasty-countdown-layout-line.abtasty-countdown-finish .abtasty-countdown-finish-button{display:table-cell;vertical-align:middle}.abtasty-countdown-layout-line>div{display:inline-block;margin:0}.abtasty-countdown-layout-line .abtasty-countdown-top-message{display:table-cell;vertical-align:middle;padding-left:30px}.abtasty-countdown-layout-line .abtasty-countdown-bottom-button{display:table-cell;vertical-align:middle}.abtasty-countdown-layout-line .abtasty-countdown-bottom-button a{margin-left:30px}.abtasty-countdown-layout-line .abtasty-countdown-elm-time{margin:0}.abtasty-countdown-layout-line .abtasty-countdown-clock{display:table-cell}.abtasty-countdown-close-inline{top:calc(50% - 13px)!important}.abtasty-countdown-layout-line{display:table;width:100%}.abtasty-countdown-finish-button,.abtasty-countdown-finish-text{display:none}.abtasty-countdown-endButton-show .abtasty-countdown-finish-button,.abtasty-countdown-endCountdown-show.abtasty-countdown-clock,.abtasty-countdown-endText-show .abtasty-countdown-finish-text{display:block}.abtasty-countdown-layout-line.abtasty-countdown-endButton-show .abtasty-countdown-finish-button,.abtasty-countdown-layout-line.abtasty-countdown-endCountdown-show .abtasty-countdown-clock,.abtasty-countdown-layout-line.abtasty-countdown-endText-show .abtasty-countdown-finish-text{display:table-cell}.abtasty-countdown-endButton-hide .abtasty-countdown-finish-button,.abtasty-countdown-endCountdown-hide .abtasty-countdown-clock,.abtasty-countdown-endText-hide .abtasty-countdown-finish-text,.abtasty-countdown-finish .abtasty-countdown-bottom-button,.abtasty-countdown-finish .abtasty-countdown-top-message{display:none!important}"," ").concat(this.getStyle()),(n=document.createElement("style")).type="text/css",n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e)),n)),F.forEach((function(t){var e=i.container.querySelector(".abtasty-countdown-".concat(t,"s")),n=j(e.children,2),s=n[0],o=n[1];i.digitElements[t]=s,i.textElements[t]=o,i.timeElements[t]=e})),this.setContent(),this.setButton(),this.timeLoop=setInterval(this.setCountdown.bind(this),1e3),setTimeout((function(){i.setCountdown()}),100),this.setCountdown()}catch(t){console.warn("Countdown error occured during widget rendering:",t)}}}]),t}();function J(){return(J=n(t.mark((function e(){var n,i,s;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=A(),t.next=3,n.init();case 3:if(t.sent){t.next=6;break}return t.abrupt("return",!1);case 6:return i=n.domElement.querySelector(".".concat(n.contentClassName)),(s=new K(TEST_ID,DATA)).init(n),s.insert(i,"beforeend"),n.show(),t.abrupt("return",s);case 12:case"end":return t.stop()}}),e)})))).apply(this,arguments)}!function(){J.apply(this,arguments)}()}(); | ||
!function(){"use strict";var t=function(t,e){return t(e={exports:{}},e.exports),e.exports}((function(t){var e=function(t){var e=Object.prototype,n=e.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},s=i.iterator||"@@iterator",o=i.asyncIterator||"@@asyncIterator",r=i.toStringTag||"@@toStringTag";function a(t,e,n,i){var s=e&&e.prototype instanceof d?e:d,o=Object.create(s.prototype),r=new T(i||[]);return o._invoke=function(t,e,n){var i="suspendedStart";return function(s,o){if("executing"===i)throw new Error("Generator is already running");if("completed"===i){if("throw"===s)throw o;return _()}for(n.method=s,n.arg=o;;){var r=n.delegate;if(r){var a=w(r,n);if(a){if(a===l)continue;return a}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===i)throw i="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i="executing";var d=c(t,e,n);if("normal"===d.type){if(i=n.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:n.done}}"throw"===d.type&&(i="completed",n.method="throw",n.arg=d.arg)}}}(t,n,r),o}function c(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}t.wrap=a;var l={};function d(){}function h(){}function u(){}var m={};m[s]=function(){return this};var g=Object.getPrototypeOf,p=g&&g(g(x([])));p&&p!==e&&n.call(p,s)&&(m=p);var y=u.prototype=d.prototype=Object.create(m);function v(t){["next","throw","return"].forEach((function(e){t[e]=function(t){return this._invoke(e,t)}}))}function f(t,e){var i;this._invoke=function(s,o){function r(){return new e((function(i,r){!function i(s,o,r,a){var l=c(t[s],t,o);if("throw"!==l.type){var d=l.arg,h=d.value;return h&&"object"==typeof h&&n.call(h,"__await")?e.resolve(h.__await).then((function(t){i("next",t,r,a)}),(function(t){i("throw",t,r,a)})):e.resolve(h).then((function(t){d.value=t,r(d)}),(function(t){return i("throw",t,r,a)}))}a(l.arg)}(s,o,i,r)}))}return i=i?i.then(r,r):r()}}function w(t,e){var n=t.iterator[e.method];if(void 0===n){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,w(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var i=c(n,t.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,l;var s=i.arg;return s?s.done?(e[t.resultName]=s.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):s:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function b(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function S(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(b,this),this.reset(!0)}function x(t){if(t){var e=t[s];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function e(){for(;++i<t.length;)if(n.call(t,i))return e.value=t[i],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:_}}function _(){return{value:void 0,done:!0}}return h.prototype=y.constructor=u,u.constructor=h,u[r]=h.displayName="GeneratorFunction",t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,u):(t.__proto__=u,r in t||(t[r]="GeneratorFunction")),t.prototype=Object.create(y),t},t.awrap=function(t){return{__await:t}},v(f.prototype),f.prototype[o]=function(){return this},t.AsyncIterator=f,t.async=function(e,n,i,s,o){void 0===o&&(o=Promise);var r=new f(a(e,n,i,s),o);return t.isGeneratorFunction(n)?r:r.next().then((function(t){return t.done?t.value:r.next()}))},v(y),y[r]="Generator",y[s]=function(){return this},y.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var n in t)e.push(n);return e.reverse(),function n(){for(;e.length;){var i=e.pop();if(i in t)return n.value=i,n.done=!1,n}return n.done=!0,n}},t.values=x,T.prototype={constructor:T,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(S),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function i(n,i){return r.type="throw",r.arg=t,e.next=n,i&&(e.method="next",e.arg=void 0),!!i}for(var s=this.tryEntries.length-1;s>=0;--s){var o=this.tryEntries[s],r=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var a=n.call(o,"catchLoc"),c=n.call(o,"finallyLoc");if(a&&c){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(a){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(t,e){for(var i=this.tryEntries.length-1;i>=0;--i){var s=this.tryEntries[i];if(s.tryLoc<=this.prev&&n.call(s,"finallyLoc")&&this.prev<s.finallyLoc){var o=s;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var r=o?o.completion:{};return r.type=t,r.arg=e,o?(this.method="next",this.next=o.finallyLoc,l):this.complete(r)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),S(n),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var i=n.completion;if("throw"===i.type){var s=i.arg;S(n)}return s}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:x(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),l}},t}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}}));function e(t,e,n,i,s,o,r){try{var a=t[o](r),c=a.value}catch(t){return void n(t)}a.done?e(c):Promise.resolve(c).then(i,s)}var n=function(t){return function(){var n=this,i=arguments;return new Promise((function(s,o){var r=t.apply(n,i);function a(t){e(r,s,o,a,c,"next",t)}function c(t){e(r,s,o,a,c,"throw",t)}a(void 0)}))}};const i=()=>Object.prototype.hasOwnProperty.call(window,"ABTastyEditor");const s=()=>{let t;return window.ABTasty||window.ABTASTY_S?(window.ABTASTY_S&&window.ABTASTY_S.USER&&window.ABTASTY_S.USER.accountIdentifier&&window.ABTASTY_S.USER.accountIdentifier.length?t=window.ABTASTY_S.USER.accountIdentifier:window.ABTasty&&window.ABTasty.getAccountSettings&&"function"==typeof window.ABTasty.getAccountSettings?t=window.ABTasty.getAccountSettings().identifier:window.ABTasty&&window.ABTasty.accountSettings&&(t=window.ABTasty.accountSettings.identifier),t):t},o=()=>{const t=!!document.getElementById("ABTastyPreviewBar"),e=location.href.includes("ab_project=preview");return t||e},r=()=>o()||!!window.ABTasty.getTestsOnPage()[TEST_ID],a=()=>{if(i()||o())return!1;const t=ABTasty.getTestsOnPage()[TEST_ID];return!!t&&Object.keys(t.targetings.qaParameters).length>0},c="conditions",l="https://social-proof-api.abtasty.com/clients/",d=()=>{const{type:t}=DATA;return`${PACKAGE.replace("@abtasty/","")}${t?"_"+t:""}`},h=()=>{const t=d();return`${t.charAt(0).toUpperCase()}${t.slice(1)}`.split("-").join(" ")},u=()=>`${PLUGIN_ID.split("-")[0]}_${TEST_ID}`,m=(...t)=>{t.unshift(`[AB Tasty Widget] ${PACKAGE}:`),console.log(...t)},g=t=>{if(a()){const e=h();window.console.log(`%c${e} - QA Mode for campaign ${TEST_ID}\n${t}`,"background-color: rgba(0, 127, 145, 1); color: rgba(247, 247, 247, 1)")}},p=t=>{const e={promise:null,resolve:null,reject:null,name:t};return e.promise=new Promise((t,n)=>{e.resolve=t,e.reject=n}),e},y=(t,e,n)=>{let i=0,s=0;try{document.querySelector(t)}catch(e){const i=`Selector «${t}» not valid.`;return m(i),"function"==typeof n&&n(i)}function o(){clearInterval(s),clearTimeout(i)}return i=setTimeout(()=>{o();const e=`Can't find element «${t}».`;return m(e),"function"==typeof n&&n(e)},1e4),s=setInterval(()=>{const n=document.querySelector(t);return null!==n?(o(),"function"==typeof e&&e(n)):n},200),{clear:o}};const v=t=>{i()||(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation())};async function f(t){let e;switch(t){case"IntersectionObserver":e=await("IntersectionObserver"in window&&"IntersectionObserverEntry"in window&&"intersectionRatio"in window.IntersectionObserverEntry.prototype||function(t){return new Promise((e,n)=>{const i=window.document.getElementsByTagName("script")[0],s=window.document.createElement("script");s.src=t,i.parentNode.insertBefore(s,i),s.onload=e,s.onerror=n})}("https://polyfill.io/v3/polyfill.min.js?flags=gated&features=IntersectionObserver"));break;default:e=!0}return e}class w{constructor(){this.targets=[],this.existingTargets=[],this.inViewportTargets=[],this.visibilityObserver=this.startVisibilityObserver(),this.mutationObserver=this.startMutationObserver(),this.mouseOverEvent=this.mouseOverHandler()}intersectionHandler(t){t.forEach(t=>{t.isIntersecting?(this.existingTargets.forEach(e=>{e.element.isSameNode(t.target)&&(this.inViewportTargets.push(e),this.mouseOverEvent.start())}),this.checkElements()):this.inViewportTargets=this.inViewportTargets.filter(e=>!e.element.isSameNode(t.target)||(this.mouseOverEvent.clear(),!1))})}startVisibilityObserver(){return new IntersectionObserver(this.intersectionHandler.bind(this),{root:null,rootMargin:"0px",threshold:0})}startMutationObserver(){const t=this.mutationObserver||new MutationObserver(this.checkElements.bind(this));return document.body&&t.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),t}onMouseOver({target:t,path:e}){const n=this.inViewportTargets.find(({element:n,selector:i})=>{if(n.isSameNode(t))return!0;const s=[...t.querySelectorAll(i)];if(s.length&&s.includes(n))return!0;if(e.includes(n))return!0;const o=[...t.parentElement.children],r=o.findIndex(e=>e.isSameNode(t)),a=o.filter((t,e)=>e>r);if(a.length){if(a.includes(n))return!0;if(a.some(t=>[...t.querySelectorAll(i)].includes(n)))return!0}return!1});if(n&&this.isElementVisible(n.element)){const{selector:t,element:e,uniqueId:i}=n,s=this.targets.find(e=>e.selector===t&&e.uniqueId===i);s&&s.resolve(e),this.clear(t,i)}}mouseOverHandler(){const t=["mouseover",t=>setTimeout(()=>this.onMouseOver(t),50),!0];return{start:()=>document.addEventListener(...t),clear:()=>document.removeEventListener(...t)}}isElementVisible(t){return this.isElementTopmost(t)&&this.isElementOpaque(t)}isElementOpaque(t){return"HTML"===function t(e,n){return n(e)||!e.parentElement?e:t(e.parentElement,n)}(t,t=>"0"===window.getComputedStyle(t).opacity).nodeName}isElementTopmost(t){const e=t.getBoundingClientRect(),n=[[e.left,e.top],[e.right,e.top],[e.left,e.bottom],[e.right,e.bottom],[e.left+e.width/2,e.top],[e.left+e.width/2,e.bottom],[e.left,e.height/2],[e.right,e.height/2],[e.left+e.left/2,e.height/2]];let i=!1,s=0;for(;!i&&s<n.length;){const e=document.elementFromPoint(...n[s]);i=t===e||t.contains(e),s+=1}return i}checkElements(){this.targets.forEach(({selector:t,uniqueId:e})=>{const n=document.querySelector(t);n&&!this.existingTargets.find(n=>n.element.matches(t)&&n.uniqueId===e)&&(this.existingTargets.push({element:n,selector:t,uniqueId:e}),this.visibilityObserver.observe(n))}),this.existingTargets=this.existingTargets.filter(({selector:t,element:e})=>!!document.querySelector(t)||(this.visibilityObserver.unobserve(e),!1)),this.inViewportTargets=this.inViewportTargets.filter(({selector:t,element:e,uniqueId:n})=>{if(e.matches(t)&&this.isElementVisible(e)){const i=this.targets.find(e=>e.selector===t&&e.uniqueId===n);return i&&i.resolve(e),this.clear(t,n),!1}return!0})}watch(t,e,n){this.targets.push({selector:t,resolve:e,uniqueId:n});const i=()=>{this.startMutationObserver(),this.checkElements()};document.body?i():y("body",i)}clear(t,e){[this.targets,this.existingTargets,this.inViewportTargets]=[this.targets,this.existingTargets,this.inViewportTargets].map(n=>n.filter(({selector:n,uniqueId:i})=>n!==t&&i!==e)),this.visibilityObserver.unobserve(document.querySelector(t)),0===this.targets.length&&this.mutationObserver.disconnect(),0===this.inViewportTargets.length&&this.mouseOverEvent.clear()}}class b{constructor({triggerEvent:t,triggerSelector:e,triggerDelay:n}){this.event=t,this.selector=e&&e.length?e:"body",this.delay=1e3*n,this.elementsSelectors=[],this.eventsListeners=[],this.timeouts=[],this.intervals=[],this.observers=[],this.promises=[],this.visibilityObservers=[],this.elementsWaiters=[]}async onElementVisible({promise:t,resolve:e}){const n=p(this.event+"DomReady");this.promises.push(n);const i=await this.onPageLoad(n),s=await f("IntersectionObserver"),o=function(t,e){return ABTasty.widgetUtils||(ABTasty.widgetUtils={}),ABTasty.widgetUtils[t]||Object.assign(ABTasty.widgetUtils,{[t]:new e}),ABTasty.widgetUtils[t]}("VisibilityObserver",w);if(this.visibilityObservers.push(o),s&&i){const t=u();o.watch(this.selector,e,t)}return t}onPageLoad({promise:t,resolve:e}){const n=()=>"complete"===document.readyState;if(!n()){const i=["readystatechange",()=>n()&&e(!0),{passive:!0}];return this.eventsListeners.push(i),document.addEventListener(...i),t}return e(!0),t}onClick({promise:t,resolve:e}){const n=document.createElement("style");n.type="text/css",n.id="Click_"+u(),n.innerHTML=this.selector+" {\n\t\t\tcursor: pointer !important;\n\t\t\tpointer-events: all !important;\n\t\t}",document.head.appendChild(n),this.elementsSelectors.push("#"+n.id);const i=t=>[...document.querySelectorAll(this.selector)].some(e=>e.isSameNode(t)||!!t.closest(this.selector)),s=["click",({target:t})=>i(t)&&e(!0),{passive:!0,capture:!0}];return this.eventsListeners.push(s),document.addEventListener(...s),t}onExitIntent({promise:t,resolve:e}){const n=["mouseleave",async({clientY:t})=>{t<=0&&e(!0)},{passive:!0}],i=y("body",t=>{t.addEventListener(...n),this.eventsListeners.push([t,...n]),this.elementsWaiters=this.elementsWaiters.filter(t=>t!==i)});return this.elementsWaiters.push(i),t}onReengage({promise:t,resolve:e}){const n=this.delay;let i=n;const s=[()=>(i=n,i),{passive:!0}];["click","mousemove","scroll","keypress"].forEach(t=>{document.addEventListener(t,...s),this.eventsListeners.push([t,...s])});const o=setInterval(()=>{i<=0?e(!0):i-=100},100);return this.intervals.push(o),t}onCustomTrigger({promise:t,resolve:e}){const{triggerEventCustomScript:n}=DATA;return new Function(`return new Promise(async resolve => {${n}})`)().then(t=>t&&e(!0)),t}getSocialProofPurchases({promise:t,resolve:e}){const n=window.ABTastyProductKey,i=s(),{viewInterval:o,triggerSocialProofMinPurchases:r,spNoTrim:a}=DATA;return n||(g("Not able to find ABTastyProductKey, impossible to call the API."),e(!1)),n&&i?fetch(`${l}${i}/metrics/i?key=${n}${a?"&noTrim=true":""}`).then(t=>t.ok&&t.json()).then(t=>(t=>{if(void 0===o||void 0===r)return!1;const e=void 0!==t[o]&&t[o]>=r;return e||g(`Widget will not be shown, product has been purchased ${t[o]} times while ${r} are required`),e})(t)&&e(""+t[o])).catch(()=>g("Failed to fetch datas from server.")):e(!1),t}getSocialProofPageViews({promise:t,resolve:e}){const{viewInterval:n,triggerSocialProofMinPageViews:i,spNoTrim:o}=DATA,r=encodeURIComponent(o?window.location.href.replace(window.location.origin,""):""+window.location.pathname),a=s();return r&&a?fetch(`${l}${a}/metrics/pv?key=${r}${o?"&noTrim=true":""}`).then(t=>t.ok&&t.json()).then(t=>(t=>{if(void 0===n||void 0===i)return!1;const e=void 0!==t[n]&&t[n]>=i;return e||g(`Widget will not be shown, page has been seen ${t[n]} times while ${i} are required`),e})(t)&&e(""+t[n])).catch(()=>g("Failed to fetch datas from server.")):e(!1),t}onConsent({promise:t,resolve:e}){if(!window.ABTasty.cnilReady){const n=["consentValid",()=>e(!0)];return this.eventsListeners.push(n),document.addEventListener(...n),t}return e(!0),t}clear(){if(this.elementsSelectors.length&&(this.elementsSelectors.forEach(t=>{document.querySelector(t)&&document.querySelector(t).remove()}),this.elementsSelectors=[]),this.eventsListeners.length&&(this.eventsListeners.forEach(t=>{const[e,...n]="string"==typeof t[0]?[document,...t]:t;e&&n.length>1&&e.removeEventListener(...n)}),this.eventsListeners=[]),this.timeouts.length&&(this.timeouts.forEach(t=>clearTimeout(t)),this.timeouts=[]),this.intervals.length&&(this.intervals.forEach(t=>clearInterval(t)),this.intervals=[]),this.observers.length&&(this.observers.forEach(t=>t.disconnect()),this.observers=[]),this.visibilityObservers.length){const t=u();this.visibilityObservers.forEach(e=>e.clear(this.selector,t)),this.visibilityObservers=[]}return this.promises.length&&(this.promises.forEach(t=>t.resolve(!1)),this.promises=[]),this.elementsWaiters.length&&(this.elementsWaiters.forEach(t=>t.clear()),this.elementsWaiters=[]),this}async isTriggered(){this.clear();const t=p(this.event);this.promises.push(t);const e={consent:()=>this.onConsent(t),direct:()=>!0,pageLoad:()=>this.onPageLoad(t),click:()=>this.onClick(t),exitIntent:()=>this.onExitIntent(t),reengage:()=>this.onReengage(t),elementVisible:()=>this.onElementVisible(t),script:()=>this.onCustomTrigger(t),socialProofPurchases:()=>this.getSocialProofPurchases(t),socialProofPageViews:()=>this.getSocialProofPageViews(t)},n=!Object.prototype.hasOwnProperty.call(e,this.event)||await e[this.event]();return this.clear(),"reengage"!==this.event&&this.delay?n&&await(async()=>{const t=p(this.event+"Delay");return this.promises.push(t),setTimeout(()=>{t.resolve(!0),this.clear()},this.delay),t.promise})():n}}class S{constructor({displayRecurrence:t,closingRecurrence:e,validationRecurrence:n},i){this.displayRecurrence=parseFloat(t),this.closingRecurrence=parseFloat(e),this.validationRecurrence=parseFloat(n),this.onSetCallback=i,this.widgetName=d(),this.uniqueId=u(),this.recurrenceKey=`${this.widgetName}_${this.uniqueId}`,this.isListeningStorageEvent=this.listenStorageEvent(),this.pendingRecurrence=!1}onStorage({key:t}){const e=localStorage.getItem("ABTastyWidgetsTemporary"),n=sessionStorage.getItem("ABTastyWidgets");"ABTastyData"===t&&!e&&n&&localStorage.setItem("ABTastyWidgetsTemporary",n)}listenStorageEvent(){return this.isListeningStorageEvent||window.addEventListener("storage",this.onStorage.bind(this)),!0}getGivenRecurrenceStorageParsed(t){try{const e=t.getItem("ABTastyWidgets");return JSON.parse(e)}catch(e){return t.removeItem("ABTastyWidgets"),!1}}getSessionRecurrenceStorageParsed(){return this.getGivenRecurrenceStorageParsed(window.sessionStorage)}getLocalRecurrenceStorageParsed(){return this.getGivenRecurrenceStorageParsed(window.localStorage)}removeGivenStorage(t,e){const{[this.recurrenceKey]:n,...i}=e;return Object.entries(i).length?(t.setItem("ABTastyWidgets",JSON.stringify(i)),i):(t.removeItem("ABTastyWidgets"),!1)}removeSessionRecurrenceStorage(){const t=this.getSessionRecurrenceStorageParsed();return!!t&&this.removeGivenStorage(window.sessionStorage,t)}removeLocalRecurrenceStorage(){const t=this.getLocalRecurrenceStorageParsed();return!!t&&this.removeGivenStorage(window.localStorage,t)}getSessionRecurrence(){const t=this.getSessionRecurrenceStorageParsed();return!!t&&t[this.recurrenceKey]}getLocalRecurrence(){const t=this.getLocalRecurrenceStorageParsed();return!!t&&t[this.recurrenceKey]}getCurrentRecurrence(){const t=this.getSessionRecurrence(),e=this.getLocalRecurrence();return t||e||{type:!1}}isOver(){const t=localStorage.getItem("ABTastyWidgetsTemporary"),e=!(!t||!t.includes(this.recurrenceKey))||this.getSessionRecurrence();t&&(sessionStorage.setItem("ABTastyWidgets",t),localStorage.removeItem("ABTastyWidgetsTemporary"));const n=this.getLocalRecurrence(),i=(n?parseFloat(n.stamp):0)<(new Date).getTime();return i&&this.removeLocalRecurrenceStorage(),!this.pendingRecurrence&&i&&!this.getLocalRecurrence()&&!e}setRecurrence(t,e){0!==t&&(window.removeEventListener("storage",this.onStorage.bind(this)),this.isListeningStorageEvent=!1);const n=this.getTypeOfStorage(t);if(o()||!n&&"object"!=typeof n)return!1;const{storageString:i,storageMethod:s}=n,r=this.getStamp(t),a={type:e,stamp:r},{type:c}=this.getCurrentRecurrence(),l=async()=>{const t=this.getSessionRecurrence(),e=this.getLocalRecurrence();let n;"session"===i?t?n=this.removeSessionRecurrenceStorage():(this.removeLocalRecurrenceStorage(),n=this.getSessionRecurrenceStorageParsed()):"local"===i&&(e?n=this.removeLocalRecurrenceStorage():(this.removeSessionRecurrenceStorage(),n=this.getLocalRecurrenceStorageParsed()));const o=n?{[this.recurrenceKey]:a,...n}:{[this.recurrenceKey]:a};if(!window.ABTasty.cnilReady){this.pendingRecurrence=!0;const t=new b({triggerEvent:"consent"});await t.isTriggered(),this.pendingRecurrence=!1}s.setItem("ABTastyWidgets",JSON.stringify(o)),this.onSetCallback&&"function"==typeof this.onSetCallback&&this.onSetCallback()};if(!s)return!1;if(c&&"validation"!==e)if("closing"===e&&"validation"!==c)l();else{if("display"!==e||"validation"===c||"closing"===c)return!1;l()}else l();return r}setDisplayRecurrence(){this.setRecurrence(this.displayRecurrence,"display")}setClosingRecurrence(){this.setRecurrence(this.closingRecurrence,"closing")}setValidationRecurrence(){this.setRecurrence(this.validationRecurrence,"validation")}getStamp(t){return(new Date).getTime()+864e5*t}getTypeOfStorage(t){return!(isNaN(t)||t<0||0!==t&&!t)&&(t>0?{storageString:"local",storageMethod:window.localStorage}:0===t&&{storageString:"session",storageMethod:window.sessionStorage})}}class T{constructor(t,e,n){this.recurrence=t,this.isWidgetApplied=e,this.callback=n,this.observer=new MutationObserver(this.observerHandler.bind(this)),this.eventListenerParams=["abtasty_resetActionTracking",this.eventHandler.bind(this),{passive:!0}],this.elementsWaiters=[]}recurrenceIsDone(){return!this.recurrence||this.recurrence.isOver()}decisionHandler(t){const e=r(),{type:n}=this.recurrence?this.recurrence.getCurrentRecurrence():{type:!1},i=()=>t&&"display"===n||this.recurrenceIsDone();return!this.isWidgetApplied()&&e&&i()?(this.clearWatcher(),this.callback("rebuild",t)):(!this.isWidgetApplied()||e&&i())&&(this.isWidgetApplied()||e)||(this.clearWatcher(),this.callback("remove",t),this.watch()),this}eventHandler(){let t=r();return[250,500].forEach(e=>setTimeout(()=>500===e&&r()===t?this:(t=r(),this.decisionHandler(!1)),e)),this}observerHandler(t){const e=t.some(({removedNodes:t})=>t&&t.length),n=t.some(({addedNodes:t})=>t&&t.length);return e||n?(this.decisionHandler(!0),this):this}watch(){if(i())return this;this.clearWatcher(),document.addEventListener(...this.eventListenerParams);const t=y("body",e=>{const n=[e,{childList:!0,subtree:!0}];this.observer.observe(...n),this.elementsWaiters=this.elementsWaiters.filter(e=>e!==t)});return this.elementsWaiters.push(t),this}clearWatcher(){return document.removeEventListener(...this.eventListenerParams),this.elementsWaiters.length&&(this.elementsWaiters.forEach(t=>t.clear()),this.elementsWaiters=[]),this.observer.disconnect(),this}}class x{constructor(){this.children=void 0,this.uniqueId=u(),this.widgetName=d(),this.prettyName=h(),this.recurrenceParams=(()=>{const{displayRecurrence:t,closingRecurrence:e,validationRecurrence:n}=DATA;if(i()||!t&&!e&&!n)return!1;const s={everytime:()=>-1,session:()=>0,once:()=>395,day:t=>DATA[t+"_day"],week:t=>7*DATA[t+"_week"],month:t=>30.5*DATA[t+"_month"]},o={};return t&&(o.displayRecurrence=s[t]("displayRecurrence")),e&&(o.closingRecurrence=s[e]("closingRecurrence")),n&&(o.validationRecurrence=s[n]("validationRecurrence")),o})(),this.triggerParams=(()=>{let{triggerEvent:t}=DATA;const{triggerEventClick:e,triggerEventReengageDelay:n,socialProofContentType:s,triggerEventElementVisible:o,triggerEventDelay:r}=DATA;if(i()||!t&&!s)return!1;const a={click:()=>e,elementVisible:()=>o},c=Object.prototype.hasOwnProperty.call(a,t)?a[t]():"body",l="reengage"===t?n:r;return s&&(t=1===s?"socialProofPurchases":"socialProofPageViews"),{triggerEvent:t,triggerSelector:c,triggerDelay:l}})(),this.recurrence=!!this.recurrenceParams&&new S(this.recurrenceParams,this.clearGivenClearables.bind(this)),this.trigger=!!this.triggerParams&&new b(this.triggerParams),this.pageWatcher=new T(this.recurrence,this.isWidgetApplied.bind(this),this.onPageChange.bind(this)),this.hasOncePerPageTrigger=(()=>{const{isOncePerPageTrigger:t,triggerEvent:e}=DATA;return!(!t||!["click","script"].includes(e))||["pageLoad","direct","reengage","socialProofPurchases","socialProofPageViews","elementVisible"].some(t=>t===e)})(),this.basicClassName="ab_widget_container_"+this.widgetName,this.widgetContainerId=`${this.basicClassName}_${this.uniqueId}`,this.contentClassName=this.basicClassName+"_content",this.overlayClassName=this.basicClassName+"_overlay",this.closeButtonClassName=this.basicClassName+"_close_button",this.hideClassName="ab_hide_"+this.uniqueId,this.domElement=this.getDom(),this.hasBeenShown=!1,this.closedByUser=!1,this.eventsListeners=[],this.timeouts=[],this.intervals=[],this.observers=[],this.promises=[],this.elementsWaiters=[]}clearGivenClearables(){this.eventsListeners.length&&(this.eventsListeners.forEach(t=>document.removeEventListener(...t)),this.eventsListeners=[]),this.timeouts.length&&(this.timeouts.forEach(t=>clearTimeout(t)),this.timeouts=[]),this.intervals.length&&(this.intervals.forEach(t=>clearInterval(t)),this.intervals=[]),this.observers.length&&(this.observers.forEach(t=>t.disconnect()),this.observers=[]),this.promises.length&&(this.promises.forEach(t=>t.resolve(!1)),this.promises=[]),this.elementsWaiters.length&&(this.elementsWaiters.forEach(t=>t.clear()),this.elementsWaiters=[])}isWidgetApplied(){return this.domElement&&!!this.domElement.closest("html")}removeOldDomElement(){const t=document.getElementById(this.widgetContainerId);return t&&t.remove(),this}async insert(){const t=(t,e,n)=>{this.elementsWaiters=this.elementsWaiters.filter(t=>t!==e),g(t),n(t)},e=new Promise((e,n)=>{const i=y("head",t=>{this.elementsWaiters=this.elementsWaiters.filter(t=>t!==i),e(t.appendChild(this.styleElement))},e=>t(e,i,n));this.elementsWaiters.push(i)}),n=new Promise((e,n)=>{const{layout:i,elementReferrer:s,referrerInsertType:o}=DATA,{selector:r,position:a}="string"==typeof i&&"free"===i&&"string"==typeof s&&"string"==typeof o?{selector:s,position:o}:{selector:"body",position:"beforeend"},c=y(r,t=>{this.elementsWaiters=this.elementsWaiters.filter(t=>t!==c),this.removeOldDomElement(),e(t.insertAdjacentElement(a,this.domElement))},e=>t(e,c,n));this.elementsWaiters.push(c)});return Promise.all([n,e]).then(()=>this)}remove(){return this.pageWatcher.clearWatcher(),this.domElement&&this.domElement.closest("html")&&this.domElement.remove(),this.styleElement&&this.styleElement.closest("html")&&this.styleElement.remove(),this.hasOncePerPageTrigger?this.pageWatcher.watch():i()||this.init().then(({response:t})=>t?this.show():this),this}show(){return this.hasBeenShown||i()||window.ABTastyEvent(this.prettyName+" displayed",null,TEST_ID),this.closedByUser=!1,this.domElement.classList.remove(this.hideClassName),this.recurrence&&this.recurrence.setDisplayRecurrence(),this.hasBeenShown=!0,this.pageWatcher.watch(),this}hide(){return this.hasBeenShown&&!i()&&window.ABTastyEvent(this.prettyName+" closed",null,TEST_ID),this.closedByUser=!0,this.domElement.classList.add(this.hideClassName),this}async init(t){if(!i()&&!r())return!1;if(this.trigger&&this.trigger.promises.length)return!1;const e=this.recurrence&&this.recurrence.isOver();if(this.recurrence&&!e)return this.pageWatcher.watch(),!1;this.pageWatcher.watch();const n=i()||!this.trigger||this.trigger&&await this.trigger.isTriggered();return!!n&&(await this.insert(),this.addCloseEvent(),i()||t||this.hasBeenShown||void 0===this.children||"function"!=typeof this.children.refreshContent||this.children.refreshContent(n),{container:this,response:n})}onPageChange(t,e){const n=()=>this.init().then(({response:t})=>t&&this.show());switch(e||(this.hasBeenShown=!1),t){case"remove":this.isWidgetApplied()?this.remove():(this.trigger&&this.trigger.clear(),this.pageWatcher.watch());break;case"rebuild":this.hasBeenShown?this.closedByUser?this.pageWatcher.watch():this.insert().then(t=>t.show()):n()}}addCloseEvent(...t){const{closeButton:e,overlayClickable:n,layout:s}=DATA,o=[];if(void 0!==n&&n&&void 0!==s&&"popin"===s&&o.push("."+this.overlayClassName),void 0!==e&&e&&o.push("."+this.closeButtonClassName),!o.length)return this;const r=this.domElement.querySelectorAll(o.join(", "));return r.length?(t.push(...r),t.forEach(t=>{i()&&(t.dataset.abtastyActionnable="true"),t.addEventListener("click",t=>{v(t),this.recurrence&&this.recurrence.setClosingRecurrence(),this.hide(),setTimeout(()=>this.remove(),1e3)},{once:!0,capture:!0})}),this):this}getDom(){const{closeButton:t,layout:e}=DATA,n=document.createElement("div");return n.className=`${this.basicClassName} ${this.hideClassName}`,n.id=this.widgetContainerId,n.innerHTML=`\n\t\t\t${void 0!==e&&"popin"===e?`<div class="${this.overlayClassName}"></div>`:""}\n\t\t\t<div class="${this.contentClassName}">\n\t\t\t${t?`<button class="${this.closeButtonClassName}"><svg viewBox="0 0 16 16">\n\t<defs><path id="prefix__a" d="M12 4.991L11.009 4 8 7.009 4.991 4 4 4.991 7.009 8 4 11.009 4.991 12 8 8.991 11.009 12 12 11.009 8.991 8z"></path></defs>\n\t<g><use xlink:href="#prefix__a"></use></g>\n</svg></button>`:""}\n\t\t\t</div>`,n}loadFont(t,e){if(!t||"inherit"===t)return;const n=document.createElement("style");n.appendChild(document.createTextNode(`\t\t\t@font-face { \t\t\tfont-family: '${t}'; \t\t\tsrc: url('${e}');\t\t\t}\t\t`)),document.head.appendChild(n)}getStyleTag(t=""){const{noStyles:e,layout:n}=DATA,{backgroundColor:s,isBackgroundImage:o,backgroundImage:r,backgroundSize:a,backgroundPosition:c,backgroundRepeat:l,borderColor:d,borderRadius:h,borderWidth:u,textColor:m,textAlign:g,fontName:p,fontStyle:y,fontSize:v,overlayColor:f,dropShadow:w,dropShadowColor:b,dropShadowBlur:S,containerMargin:T,containerPadding:x,closeButton:_,buttonsBorderWidth:E,buttonsBorderColor:C,buttonsBorderRadius:A,buttonsBackgroundColor:$,buttonsTextColor:N}=e?{}:DATA,k=document.createElement("style");k.type="text/css",i()&&k.setAttribute("abtasty-script-added","true"),this.loadFont(p,y);const L=`background: ${["string"==typeof s?s:"rgba(255, 255, 255, 1)",o&&"string"==typeof r&&r.length?`url(${r})`:"",o&&"string"==typeof c&&"100% 100%"!==a?c:"0 0",o&&"string"==typeof a?"/ "+a:"/ auto",o&&l&&!["cover","100% 100%"].includes(a)?"repeat":"no-repeat"].join(" ").trim()};`,B="number"==typeof u&&u>0,I=`border: ${[B?u+"px":"unset",B?"solid":"",B&&"string"==typeof d&&d.length?d:""].join(" ").trim()};`,P=void 0!==h?`border-radius: ${h}px;`:"",R=void 0!==m?`color: ${m}; fill: ${m}; -webkit-text-fill-color: ${m};`:"",O=void 0!==g?`text-align: ${g};`:"",W=p&&"inherit"!==p?`font-family:${p};`:y||"",D=v?`font-size: ${v}px;`:"",j=void 0!==w&&w?`box-shadow: 0 5px ${S}px 0 ${b};`:"",q=T instanceof Array&&1===T.length&&T[0],V=q?`margin: ${q.top}px ${q.right}px ${q.bottom}px ${q.left}px;`:"",M=q?`margin: calc(${q.top}px * 0.5) calc(${q.right}px * 0.5) calc(${q.bottom}px * 0.5) calc(${q.left}px * 0.5);`:"",F=x instanceof Array&&1===x.length&&x[0],H=F?`padding: ${F.top}px ${F.right}px ${F.bottom}px ${F.left}px;`:"",U=F?`padding: calc(${F.top}px * 0.5) calc(${F.right}px * 0.5) calc(${F.bottom}px * 0.5) calc(${F.left}px * 0.5);`:"",G=void 0!==E&&E?`border-width: ${E}px; border-style: solid;`:"",z=[C,E].every(t=>void 0!==t)&&E?`border-color: ${C};`:"",Y=void 0!==A?`border-radius: ${A}px;`:"",K=void 0!==$?`background-color: ${$};`:"",J=void 0!==N?`color: ${N}; -webkit-text-fill-color: ${N}; fill: ${N};`:"",X=void 0!==n&&"popin"===n?[`#${this.widgetContainerId} .${this.overlayClassName} {`,`background-color: ${void 0!==f?f:"rgba(0, 0, 0, 0.6)"};`,"}"].join(""):"",Q=e||void 0!==_&&_?[`#${this.widgetContainerId} .${this.contentClassName} .${this.closeButtonClassName} {`,"position: absolute;","top: 8px;","right: 8px;","width: auto;","height: auto;","background: none;","border: none;","cursor: pointer;","outline: none;","padding: 0;","margin: 0;","}",`#${this.widgetContainerId} .${this.contentClassName} .${this.closeButtonClassName} svg {`,"pointer-events: none;","width: 16px;","height: 16px;",R,W,D,"}"].join(""):"";return k.textContent=[`.${this.hideClassName} {`,"opacity: 0 !important;","pointer-events: none;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,L,P,I,R,O,j,V,W,D,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,"display: block;","line-height: 1;","text-indent: unset;",H,W,D,"}",`#${this.widgetContainerId} .${this.contentClassName} > * a, `,`#${this.widgetContainerId} .${this.contentClassName} > * button {`,G,z,Y,K,J,W,D,"}","@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,M,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,U,"}","}",X,Q,""+t].join(""),k}}class _ extends x{constructor(){super(),this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){return[`#${this.widgetContainerId} {`,"position: fixed;","top: 0;","left: 0;","width: 100%;","height: 100%;","z-index: 9999;","opacity: 1;","transition: opacity 0.25s ease;","}",`#${this.widgetContainerId} .${this.overlayClassName} {`,"position: absolute;","z-index: -1;","top: 0;","left: 0;","width: 100%;","height: 100%;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: absolute;","left: 50%;","top: 50%;","transform: translate(-50%, -50%);","width: auto;","height: auto;","}","@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,"max-width: 94vw;","}","}"].join("")}}class E extends x{constructor(){super(),this.position="string"==typeof DATA.layout&&"bannerTop"===DATA.layout?"top":"bottom",this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){return[`#${this.widgetContainerId} {`,"position: fixed;",this.position+": 0;","left: 0;","width: 100%;","height: auto;","z-index: 9999;","opacity: 1;","transition: opacity 0.25s ease;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: relative;","}"].join("")}}class C extends x{constructor(){super(),this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){return[`#${this.widgetContainerId} {`,"width: auto;","height: auto;","margin: 0;","padding: 0;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: relative;","}"].join("")}}const A=()=>{const{layout:t}=DATA;let e;switch(t){case"popin":e=new _;break;case"bannerTop":case"bannerBottom":e=new E;break;case"free":e=new C;break;default:e=new x}return e},$={category:c,type:"slider",min:1},N=[{...$,propName:"day",label:"widget_common_conditions_recurrence_ifOptionVariable_labelDays",value:5,max:395},{...$,propName:"week",label:"widget_common_conditions_recurrence_ifOptionVariable_labelWeeks",value:2,max:56},{...$,propName:"month",label:"widget_common_conditions_recurrence_ifOptionVariable_labelMonths",value:1,max:13}],k={category:c,type:"select",options:[{label:"widget_common_conditions_recurrence_option_everyTime",value:"everytime"},{label:"widget_common_conditions_recurrence_option_everySession",value:"session"},{label:"widget_common_conditions_recurrence_option_everyXDays",value:"day"},{label:"widget_common_conditions_recurrence_option_everyXWeeks",value:"week"},{label:"widget_common_conditions_recurrence_option_everyXMonths",value:"month"},{label:"widget_common_conditions_recurrence_option_once",value:"once"}],value:"everytime"},L={...k,label:"widget_common_conditions_recurrence_label_widgetDisplayed",propName:"displayRecurrence"},B=(N.map(t=>({...t,propName:`${L.propName}_${t.propName}`,conditions:[{field:L.propName,value:t.propName}]})),{...k,label:"widget_common_conditions_recurrence_label_widgetDisplayedAfterClosure",propName:"closingRecurrence"}),I=(N.map(t=>({...t,propName:`${B.propName}_${t.propName}`,conditions:[{field:B.propName,value:t.propName}]})),{...k,label:"widget_common_conditions_recurrence_label_widgetDisplayedAfterSubmission",propName:"validationRecurrence"});N.map(t=>({...t,propName:`${I.propName}_${t.propName}`,conditions:[{field:I.propName,value:t.propName}]}));B.condition=({closeButton:t,layout:e,overlayClickable:n})=>!("popin"===e&&!1===t&&!1===n||void 0!==e&&"popin"!==e&&!1===t);const P={pageLoad:{label:"widget_common_conditions_triggering_option_pageload",value:"pageLoad"},direct:{label:"widget_common_conditions_triggering_option_asap",value:"direct"},exitIntent:{label:"widget_common_conditions_triggering_option_exitIntent",value:"exitIntent"},reengage:{label:"widget_common_conditions_triggering_option_afterXSecondsOfInactivity",value:"reengage"},click:{label:"widget_common_conditions_triggering_option_click",value:"click"},elementVisible:{label:"widget_common_conditions_triggering_option_elementVisible",value:"elementVisible"},customScript:{label:"widget_common_conditions_triggering_option_customTrigger",value:"script"}};Object.keys(P).map(t=>P[t]);var R=function(t){if(Array.isArray(t))return t};var O=function(t,e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t)){var n=[],i=!0,s=!1,o=void 0;try{for(var r,a=t[Symbol.iterator]();!(i=(r=a.next()).done)&&(n.push(r.value),!e||n.length!==e);i=!0);}catch(t){s=!0,o=t}finally{try{i||null==a.return||a.return()}finally{if(s)throw o}}return n}};var W=function(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i};var D=function(t,e){if(t){if("string"==typeof t)return W(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?W(t,e):void 0}};var j=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")};var q=function(t,e){return R(t)||O(t,e)||D(t,e)||j()};var V=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")};function M(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}var F=function(t,e,n){return e&&M(t.prototype,e),n&&M(t,n),t},H=["fr","en","de","es"],U=["day","hour","minute","second"],G={day:{en:"Day",fr:"Jour",es:"Dia",de:"Tag"},days:{en:"Days",fr:"Jours",es:"Dias",de:"Tage"},hour:{en:"Hour",fr:"Heure",es:"Hora",de:"Zeit"},hours:{en:"Hours",fr:"Heures",es:"Horas",de:"Stunden"},minute:"Min",second:{en:"Sec",fr:"Sec",es:"Seg",de:"Sek"}},z=window.ABTASTY_S&&ABTASTY_S.USER&&ABTASTY_S.USER.lang?ABTASTY_S.USER.lang.split("_")[0]:navigator.language.substr(0,2)||"en",Y=function(t){return H.indexOf(t)>-1}(z)?z:"en",K={day:G.day[Y],days:G.days[Y],hour:G.hour[Y],hours:G.hours[Y],minute:G.minute,minutes:G.minute,second:G.second[Y],seconds:G.second[Y]};var J=function(){function e(t,n){V(this,e),this.testId=t,this.data=n,this.targetselector=n.selector,this.container=document.createElement("abtasty-countdown"),this.digitElements={},this.textElements={},this.timeElements={},this.timeLoop=null,this.maxWidth=0,this.previewTime=172799,this.unitsText=K,this.fonts=[],this.data.customTexts&&(this.unitsText={day:this.data.customDaysLabel,days:this.data.customDaysLabel,hour:this.data.customHoursLabel,hours:this.data.customHoursLabel,minute:this.data.customMinutesLabel,minutes:this.data.customMinutesLabel,second:this.data.customSecondsLabel,seconds:this.data.customSecondsLabel})}return F(e,[{key:"getFonts",value:function(){return[{name:this.data.messageFontName,style:this.data.messageFontStyle},{name:this.data.numbersfontName,style:this.data.numbersfontStyle},{name:this.data.legendfontName,style:this.data.legendfontStyle}]}},{key:"insert",value:function(t,e){return t.insertAdjacentElement(e,this.container),this}},{key:"setText",value:function(t){var e=this;U.forEach((function(n){var i=t[n];String(i).length<2&&(i="0".concat(i)),e.digitElements[n].textContent=i,e.textElements[n].textContent=1===i?e.unitsText[n]:e.unitsText["".concat(n,"s")],e.maxWidth<e.digitElements[n].offsetWidth&&(e.maxWidth=e.digitElements[n].offsetWidth,e.digitElements[n].style.minWidth="".concat(e.maxWidth,"px"),window.requestAnimationFrame((function(){e.setText(t)}))),e.digitElements[n].style.minWidth="".concat(e.maxWidth,"px")}))}},{key:"onTimeEnd",value:function(){if("hideWidget"===this.data.endSettings)return this.parentContainer.hide(),void(this.parentContainer.domElement.style.display="none");var t={};"showText"===this.data.endSettings&&(t.endText=!0,t.endCountdown=!0,t.endButton=!1),"showTextAndButton"===this.data.endSettings&&(t.endText=!0,t.endButton=!0,t.endCountdown=!0),"hideCountdownAndShowText"===this.data.endSettings&&(t.endText=!0,t.endCountdown=!1,t.endButton=!1),"hideCountdownAndShowTextAndButton"===this.data.endSettings&&(t.endText=!0,t.endCountdown=!1,t.endButton=!0);var e=[" abtasty-countdown-".concat(this.data.endSettings),"abtasty-countdown-finish"];for(var n in t)t[n]?e.push("abtasty-countdown-".concat(n,"-show")):e.push("abtasty-countdown-".concat(n,"-hide"));this.container.className+=" ".concat(e.join(" "))}},{key:"setCountdown",value:function(){var t,e=(new Date).getTime(),n=((t=this.data).dateTimeStart+(t.timezoneOffset||0)-e)/1e3;if(window.ABTastyEditor&&("ifEnded"===this.data.previewBlock&&(n=-1),this.previewTime-=1),n<=0)return this.setText({day:0,hour:0,minute:0,second:0}),void this.onTimeEnd();var i=Math.floor(n/86400);n-=86400*i;var s=Math.floor(n/3600);n-=3600*s;var o=Math.floor(n/60);n-=60*o;var r=Math.floor(n);this.setText({day:i,hour:s,minute:o,second:r})}},{key:"getStyle",value:function(){return this.loadFonts(),"\n abtasty-countdown .abtasty-countdown-finish-text,\n abtasty-countdown .abtasty-countdown-top-message {\n text-align: ".concat(this.data.messageAlign," !important;\n color: ").concat(this.data.textColor,";\n font-size: ").concat(this.data.messageFontSize,"px; \n ").concat(this.data.messageFontName&&"inherit"!==this.data.messageFontName?"font-family:".concat(this.data.messageFontName,"_").concat(this.data.messageFontStyle.match(/.+\/([^.]+)\.(otf|ttf)$/)[1],";"):this.data.messageFontStyle||"",";\n }\n \n abtasty-countdown .abtasty-countdown-elm-number {\n font-size: ").concat(this.data.numbersfontSize,"px; \n color: ").concat(this.data.numberstextColor,";\n -webkit-text-fill-color: ").concat(this.data.numberstextColor,";\n font-weight: initial;\n ").concat(this.data.numbersfontName&&"inherit"!==this.data.numbersfontName?"font-family:".concat(this.data.numbersfontName,"_").concat(this.data.numbersfontStyle.match(/.+\/([^.]+)\.(otf|ttf)$/)[1],";"):this.data.numbersfontStyle||"",";\n }\n\n abtasty-countdown .abtasty-countdown-elm-text {\n ").concat(this.data.legendfontName&&"inherit"!==this.data.legendfontName?"font-family:".concat(this.data.legendfontName,"_").concat(this.data.legendfontStyle.match(/.+\/([^.]+)\.(otf|ttf)$/)[1],";"):this.data.legendfontStyle||"",";\n font-size: ").concat(this.data.legendfontSize,"px; \n color: ").concat(this.data.legendtextColor,";\n -webkit-text-fill-color: ").concat(this.data.legendtextColor,";\n }\n \n abtasty-countdown .abtasty-countdown-elm-time {\n border-radius: ").concat(this.data.countdownBorderRadius,"px;\n border: ").concat(this.data.countdownBorderWidth,"px solid ").concat(this.data.countdownBorderColor,";\n background-color: ").concat(this.data.numbersBackgroundColor,"; \n } \n ")}},{key:"setButton",value:function(){if(this.data.button){var t=this.container.querySelector(".abtasty-countdown-bottom-button"),e=document.createElement("a");e.href=this.data.btnLink,e.innerHTML=this.data.btnLabel,this.data.btnTargetBlank&&(e.target="_blank"),t.appendChild(e)}var n=this.container.querySelector(".abtasty-countdown-finish-button"),i=document.createElement("a");i.href=this.data.endBtnLink,this.data.endBtnTargetBlank&&(i.target="_blank"),i.innerHTML=this.data.endBtnLabel,n.appendChild(i)}},{key:"setContent",value:function(){window.testt=this;var t=this.container.querySelector(".abtasty-countdown-top-message"),e=document.createElement("div");e.innerHTML=this.data.message,t.appendChild(e),t=this.container.querySelector(".abtasty-countdown-finish-text"),(e=document.createElement("div")).innerHTML=this.data.endMessage,t.appendChild(e)}},{key:"init",value:function(e){var i,s,o=this;try{if(this.parentContainer=e,this.container.className="abtasty-countdown-layout-block","bannerTop"===this.data.layout||"bannerBottom"===this.data.layout)this.container.className="abtasty-countdown-layout-line",e.domElement.querySelectorAll(".".concat(e.closeButtonClassName)).forEach((function(t){t.className+=" abtasty-countdown-close-inline"}));else if(this.data.imageOn&&"popin"===this.data.layout){var r=this.data.image,a=new Image;a.src=r,a.className="abtasty-countfown-image",a.onload=function(){var e=n(t.mark((function e(){var n,i;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=document.querySelector(".countdown_popin_img_container"),i="margin-bottom:20px; width:100%;","https://widgets-images.abtasty.com/widgets-default-image.png"===r&&(i+="width:300px !important; height:220px;"),a.style=i,n.appendChild(a);case 5:case"end":return t.stop()}}),e)})));return function(){return e.apply(this,arguments)}}()}this.container.innerHTML='\n <div class="abtasty-countdown-layout-'.concat(this.data.layout,'">\n ').concat(this.data.imageOn&&"popin"===this.data.layout?'<div class="countdown_popin_img_container" style="width:100%;"></div>':"",'\n <div class="abtasty-countdown-clock">\n <div class="abtasty-countdown-days abtasty-countdown-elm-time">\n <div class="abtasty-countdown-days__digit abtasty-countdown-elm-number"></div>\n <div class="abtasty-countdown-days__text abtasty-countdown-elm-text"></div>\n </div>\n <div class="abtasty-countdown-hours abtasty-countdown-elm-time">\n <div class="abtasty-countdown-hours__digit abtasty-countdown-elm-number"></div>\n <div class="abtasty-countdown-hours__text abtasty-countdown-elm-text"></div>\n </div>\n <div class="abtasty-countdown-minutes abtasty-countdown-elm-time">\n <div class="abtasty-countdown-minutes__digit abtasty-countdown-elm-number"></div>\n <div class="abtasty-countdown-minutes__text abtasty-countdown-elm-text"></div>\n </div>\n <div class="abtasty-countdown-seconds abtasty-countdown-elm-time">\n <div class="abtasty-countdown-seconds__digit abtasty-countdown-elm-number"></div>\n <div class="abtasty-countdown-seconds__text abtasty-countdown-elm-text"></div>\n </div>\n </div>\n <div class="abtasty-countdown-top-message"></div>\n <div class="abtasty-countdown-finish-text"></div>\n <div class="abtasty-countdown-finish-button"></div>\n <div class="abtasty-countdown-bottom-button"></div>\n </div>'),this.container.insertAdjacentElement("afterbegin",(i="".concat("abtasty-countdown{display:inline-block}abtasty-countdown>div{display:inline-block;text-align:center;margin:10px}abtasty-countdown .abtasty-countdown-finish-text,abtasty-countdown .abtasty-countdown-top-message{margin-bottom:15px}abtasty-countdown .abtasty-countdown-elm-time{display:inline-block;padding:6px;margin:6px 6px 15px}abtasty-countdown .abtasty-countdown-elm-text{text-align:center}abtasty-countdown .abtasty-countdown-elm-number,abtasty-countdown .abtasty-countdown-elm-text{font-weight:700;font-stretch:normal;font-style:normal;line-height:normal;letter-spacing:normal}abtasty-countdown .abtasty-countdown-bottom-button a,abtasty-countdown .abtasty-countdown-finish-button a{cursor:pointer;text-decoration:none;display:block;border:1px solid #57b8c7;text-align:center;display:inline-block;padding:6px 10px}.abtasty-countdown-layout-line.abtasty-countdown-finish .abtasty-countdown-finish-text{display:table-cell;padding:0 25px;vertical-align:middle}.abtasty-countdown-layout-line.abtasty-countdown-finish .abtasty-countdown-finish-button{display:table-cell;vertical-align:middle}.abtasty-countdown-layout-line>div{display:inline-block;margin:0}.abtasty-countdown-layout-line .abtasty-countdown-top-message{display:table-cell;vertical-align:middle;padding-left:30px}.abtasty-countdown-layout-line .abtasty-countdown-bottom-button{display:table-cell;vertical-align:middle}.abtasty-countdown-layout-line .abtasty-countdown-bottom-button a{margin-left:30px}.abtasty-countdown-layout-line .abtasty-countdown-elm-time{margin:0}.abtasty-countdown-layout-line .abtasty-countdown-clock{display:table-cell}.abtasty-countdown-close-inline{top:calc(50% - 13px)!important}.abtasty-countdown-layout-line{display:table;width:100%}.abtasty-countdown-finish-button,.abtasty-countdown-finish-text{display:none}.abtasty-countdown-endButton-show .abtasty-countdown-finish-button,.abtasty-countdown-endCountdown-show.abtasty-countdown-clock,.abtasty-countdown-endText-show .abtasty-countdown-finish-text{display:block}.abtasty-countdown-layout-line.abtasty-countdown-endButton-show .abtasty-countdown-finish-button,.abtasty-countdown-layout-line.abtasty-countdown-endCountdown-show .abtasty-countdown-clock,.abtasty-countdown-layout-line.abtasty-countdown-endText-show .abtasty-countdown-finish-text{display:table-cell}.abtasty-countdown-endButton-hide .abtasty-countdown-finish-button,.abtasty-countdown-endCountdown-hide .abtasty-countdown-clock,.abtasty-countdown-endText-hide .abtasty-countdown-finish-text,.abtasty-countdown-finish .abtasty-countdown-bottom-button,.abtasty-countdown-finish .abtasty-countdown-top-message{display:none!important}"," ").concat(this.getStyle()),(s=document.createElement("style")).type="text/css",s.styleSheet?s.styleSheet.cssText=i:s.appendChild(document.createTextNode(i)),s)),U.forEach((function(t){var e=o.container.querySelector(".abtasty-countdown-".concat(t,"s")),n=q(e.children,2),i=n[0],s=n[1];o.digitElements[t]=i,o.textElements[t]=s,o.timeElements[t]=e})),this.setContent(),this.setButton(),this.timeLoop=setInterval(this.setCountdown.bind(this),1e3),setTimeout((function(){o.setCountdown()}),100),this.setCountdown()}catch(t){console.warn("Countdown error occured during widget rendering:",t)}}},{key:"loadFonts",value:function(){this.getFonts().forEach((function(t){var e=t.name,n=t.style;if(e&&"inherit"!==e){var i=document.createElement("style");i.appendChild(document.createTextNode(" @font-face { font-family: '".concat(e,"_").concat(n.match(/.+\/([^.]+)\.(otf|ttf)$/)[1],"'; src: url('").concat(n,"'); } "))),document.head.appendChild(i)}}))}}]),e}();function X(){return(X=n(t.mark((function e(){var n,i,s;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=A(),t.next=3,n.init();case 3:if(t.sent){t.next=6;break}return t.abrupt("return",!1);case 6:return i=n.domElement.querySelector(".".concat(n.contentClassName)),(s=new J(TEST_ID,DATA)).init(n),s.insert(i,"beforeend"),n.show(),t.abrupt("return",s);case 12:case"end":return t.stop()}}),e)})))).apply(this,arguments)}!function(){X.apply(this,arguments)}()}(); |
{ | ||
"name": "@abtasty/countdown", | ||
"description": "Widget for AB Tasty", | ||
"version": "2.0.1-16", | ||
"version": "2.0.1-17", | ||
"form": "dist/form.js", | ||
@@ -6,0 +6,0 @@ "main": "dist/main.js", |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
671617
2592