@abtasty/popin-video 1.4.2 → 1.4.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. package/dist/main.js +1 -1
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -1 +1 @@
1
- !function(){"use strict";const e=()=>Object.prototype.hasOwnProperty.call(window,"ABTastyEditor"),t=()=>{let e;return window.ABTasty||window.ABTASTY_S?(window.ABTASTY_S&&window.ABTASTY_S.USER&&window.ABTASTY_S.USER.accountIdentifier&&window.ABTASTY_S.USER.accountIdentifier.length?e=window.ABTASTY_S.USER.accountIdentifier:window.ABTasty&&window.ABTasty.getAccountSettings&&"function"==typeof window.ABTasty.getAccountSettings?e=window.ABTasty.getAccountSettings().identifier:window.ABTasty&&window.ABTasty.accountSettings&&(e=window.ABTasty.accountSettings.identifier),e):e},i=()=>{const e=!!document.getElementById("ABTastyPreviewBar"),t=location.href.includes("ab_project=preview");return e||t},n=()=>!e()&&(i()||!!window.ABTasty.getTestsOnPage()[TEST_ID]),s=()=>window.ABTasty&&!0===window.ABTasty.consentReady,o="remove",r="rebuild",a="update",c="https://api-social-proof.abtasty.com/clients/",l=()=>{const{type:e}=DATA;return`${PACKAGE.replace("@abtasty/","")}${e?`_${e}`:""}`},d=()=>{const e=l();return`${e.charAt(0).toUpperCase()}${e.slice(1)}`.split("-").join(" ")},h=()=>`${PLUGIN_ID.split("-")[0]}_${TEST_ID}`,u=t=>{if((()=>{if(e()||i())return!1;const t=ABTasty.getTestsOnPage()[TEST_ID];return!!t&&Object.keys(t.targetings.qaParameters).length>0})()){const e=d();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=e=>{const t={promise:null,resolve:null,reject:null,name:e};return t.promise=new Promise((e,i)=>{t.resolve=e,t.reject=i}),t},m=(e,t)=>{const i=()=>{try{return document.querySelector(e)}catch(e){return null}};let n=i();const s=[document.body||document.documentElement,{childList:!0,subtree:!0,attributes:!0}],o=()=>a.disconnect(),r=()=>a.observe(...s),a=new MutationObserver(()=>(n=i(),n&&!o()&&t(n)));return n?setTimeout(()=>t(n),0):r(),{selector:e,clear:o,observe:r}};function g(e,t){return t(e)||!e.parentElement?e:g(e.parentElement,t)}const v=t=>{e()||(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation())},y=(e,t)=>[...document.querySelectorAll(t)].some(i=>i.isSameNode(e)||!!e.closest(t));class w{constructor(){this.targets=[],this.existingTargets=[],this.inViewportTargets=[],this.visibilityObserver=this.startVisibilityObserver(),this.mutationObserver=this.startMutationObserver(),this.mouseOverEvent=this.mouseOverHandler()}intersectionHandler(e){e.forEach(e=>{e.isIntersecting?(this.existingTargets.forEach(t=>{t.element.isSameNode(e.target)&&(this.inViewportTargets.push(t),this.mouseOverEvent.start())}),this.checkElements()):this.inViewportTargets=this.inViewportTargets.filter(t=>!t.element.isSameNode(e.target)||(this.mouseOverEvent.clear(),!1))})}startVisibilityObserver(){return new IntersectionObserver(this.intersectionHandler.bind(this),{root:null,rootMargin:"0px",threshold:0})}startMutationObserver(){const e=this.mutationObserver||new MutationObserver(this.checkElements.bind(this));return document.body&&e.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),e}onMouseOver({target:e,path:t}){const i=this.inViewportTargets.find(({element:i,selector:n})=>{if(i.isSameNode(e))return!0;const s=[...e.querySelectorAll(n)];if(s.length&&s.includes(i))return!0;if(t.includes(i))return!0;const o=[...e.parentElement.children],r=o.findIndex(t=>t.isSameNode(e)),a=o.filter((e,t)=>t>r);if(a.length){if(a.includes(i))return!0;if(a.some(e=>[...e.querySelectorAll(n)].includes(i)))return!0}return!1});if(i&&this.isElementVisible(i.element)){const{selector:e,element:t,uniqueId:n}=i,s=this.targets.find(t=>t.selector===e&&t.uniqueId===n);s&&s.resolve(t),this.clear(e,n)}}mouseOverHandler(){const e=["mouseover",e=>setTimeout(()=>this.onMouseOver(e),50),!0];return{start:()=>document.addEventListener(...e),clear:()=>document.removeEventListener(...e)}}isElementVisible(e){return this.isElementTopmost(e)&&this.isElementOpaque(e)}isElementOpaque(e){return"HTML"===g(e,e=>"0"===window.getComputedStyle(e).opacity).nodeName}isElementTopmost(e){const t=e.getBoundingClientRect(),i=[[t.left,t.top],[t.right,t.top],[t.left,t.bottom],[t.right,t.bottom],[t.left+t.width/2,t.top],[t.left+t.width/2,t.bottom],[t.left,t.height/2],[t.right,t.height/2],[t.left+t.left/2,t.height/2]];let n=!1,s=0;for(;!n&&s<i.length;){const t=document.elementFromPoint(...i[s]);n=e===t||e.contains(t),s+=1}return n}checkElements(){this.targets.forEach(({selector:e,uniqueId:t})=>{const i=document.querySelector(e);i&&!this.existingTargets.find(i=>i.element.matches(e)&&i.uniqueId===t)&&(this.existingTargets.push({element:i,selector:e,uniqueId:t}),this.visibilityObserver.observe(i))}),this.existingTargets=this.existingTargets.filter(({selector:e,element:t})=>!!document.querySelector(e)||(t&&this.visibilityObserver.unobserve(t),!1)),this.inViewportTargets=this.inViewportTargets.filter(({selector:e,element:t,uniqueId:i})=>{if(t.matches(e)&&this.isElementVisible(t)){const n=this.targets.find(t=>t.selector===e&&t.uniqueId===i);return n&&n.resolve(t),this.clear(e,i),!1}return!0})}watch(e,t,i){this.targets.push({selector:e,resolve:t,uniqueId:i});const n=()=>{this.startMutationObserver(),this.checkElements()};document.body?n():m("body",n)}clear(e,t){[this.targets,this.existingTargets,this.inViewportTargets]=[this.targets,this.existingTargets,this.inViewportTargets].map(i=>i.filter(({selector:i,uniqueId:n})=>i!==e&&n!==t));const i=document.querySelector(e);i&&this.visibilityObserver.unobserve(i),0===this.targets.length&&this.mutationObserver.disconnect(),0===this.inViewportTargets.length&&this.mouseOverEvent.clear()}}class b{constructor({triggerEvent:e,triggerSelector:t,triggerDelay:i}){this.event=e,this.selector=t&&t.length?t:"body",this.delay=1e3*i,this.elementsSelectors=[],this.eventsListeners=[],this.timeouts=[],this.intervals=[],this.observers=[],this.promises=[],this.visibilityObservers=[],this.elementsWaiters=[]}async onElementVisible({promise:e,resolve:t}){const i=p(`${this.event}DomReady`);this.promises.push(i);const n=await this.onPageLoad(i),s=await async function(){let e;return e=await("IntersectionObserver"in window&&"IntersectionObserverEntry"in window&&"intersectionRatio"in window.IntersectionObserverEntry.prototype||new Promise((e,t)=>{const i=window.document.getElementsByTagName("script")[0],n=window.document.createElement("script");n.src="https://polyfill.io/v3/polyfill.min.js?flags=gated&features=IntersectionObserver",i.parentNode.insertBefore(n,i),n.onload=e,n.onerror=t})),e}(),o=new w;if(this.visibilityObservers.push(o),s&&n){const e=h();o.watch(this.selector,t,e)}return e}onPageLoad({promise:e,resolve:t}){const i=()=>"complete"===document.readyState;if(!i()){const n=["readystatechange",({isTrusted:e})=>e&&i()&&t(!0),{passive:!0}];return this.eventsListeners.push([document,...n]),document.addEventListener(...n),e}return t(!0),e}onClick({promise:e,resolve:t}){const i=document.createElement("style");i.type="text/css",i.id=`Click_${h()}`,i.innerHTML=`${this.selector} {\n\t\t\tcursor: pointer !important;\n\t\t\tpointer-events: all !important;\n\t\t}`,document.head.appendChild(i),this.elementsSelectors.push(`#${i.id}`);const n=["click",({isTrusted:e,target:i})=>e&&y(i,this.selector)&&t(!0),{passive:!0,capture:!0}];return this.eventsListeners.push([document,...n]),document.addEventListener(...n),e}onHover({promise:e,resolve:t}){const i=["mouseenter",({isTrusted:e,target:i})=>e&&y(i,this.selector)&&t(!0),{passive:!0,capture:!0}];return this.eventsListeners.push([document.documentElement,...i]),document.documentElement.addEventListener(...i),e}onExitIntent({promise:e,resolve:t}){const i=["mouseleave",({isTrusted:e,clientY:i})=>{e&&i<=0&&t(!0)},{passive:!0}],n=m("body",e=>{this.eventsListeners.push([e,...i]),e.addEventListener(...i),this.elementsWaiters=this.elementsWaiters.filter(e=>e!==n)});return this.elementsWaiters.push(n),e}onReengage({promise:e,resolve:t}){const i=this.delay;let n=i;const s=[({isTrusted:e})=>{e&&(n=i)},{passive:!0}];["click","mousemove","scroll","keypress"].forEach(e=>{this.eventsListeners.push([document,e,...s]),document.addEventListener(e,...s)});const o=setInterval(()=>{n<=0?t(!0):n-=100},100);return this.intervals.push(o),e}onCustomTrigger({promise:e,resolve:t}){const{triggerEventCustomScript:i}=DATA;return new Function(`return new Promise(async resolve => {${i}})`)().then(e=>e&&t(!0)),e}onScrollUp({promise:e,resolve:t}){let i=0;const n=["scroll",({isTrusted:e})=>{e&&(window.pageYOffset<i?t(!0):i=window.pageYOffset)},{passive:!0,capture:!0}];return this.eventsListeners.push([document,...n]),document.addEventListener(...n),e}onScrollPercentReached({promise:e,resolve:t}){const{triggerEventScrollPercent:i}=DATA,n=["scroll",({isTrusted:e})=>{if(!e)return;const n=(()=>{const{documentElement:e,body:t}=document,i=e.scrollTop||t.scrollTop,n=e.scrollHeight||t.scrollHeight;return Math.trunc(i/(n-e.clientHeight)*100,10)})();i<n&&t(!0)},{passive:!0,capture:!0}];return this.eventsListeners.push([document,...n]),document.addEventListener(...n),e}getSocialProofPurchases({promise:e,resolve:i}){const n=window.ABTastyProductKey,s=t(),{viewInterval:o,triggerSocialProofMinPurchases:r,spNoTrim:a}=DATA;return n||(u("Not able to find ABTastyProductKey, impossible to call the API."),i(!1)),n&&s?fetch(`${c}${s}/metrics/i?key=${n}${a?"&noTrim=true":""}`).then(e=>e.ok&&e.json()).then(e=>(e=>{if(void 0===o||void 0===r)return!1;const t=void 0!==e[o]&&e[o]>=r;return t||u(`Widget will not be shown, product has been purchased ${e[o]} times while ${r} are required`),t})(e)&&i(`${e[o]}`)).catch(()=>u("Failed to fetch datas from server.")):i(!1),e}getSocialProofPageViews({promise:e,resolve:i}){const{viewInterval:n,triggerSocialProofMinPageViews:s,spNoTrim:o}=DATA,r=encodeURIComponent(o?window.location.href.replace(window.location.origin,""):`${window.location.pathname}`),a=t();return r&&a?fetch(`${c}${a}/metrics/pv?key=${r}${o?"&noTrim=true":""}`).then(e=>e.ok&&e.json()).then(e=>(e=>{if(void 0===n||void 0===s)return!1;const t=void 0!==e[n]&&e[n]>=s;return t||u(`Widget will not be shown, page has been seen ${e[n]} times while ${s} are required`),t})(e)&&i(`${e[n]}`)).catch(()=>u("Failed to fetch datas from server.")):i(!1),e}onConsent({promise:e,resolve:t}){if(!s()){const i=["abtasty_consentValid",()=>t(!0)];return this.eventsListeners.push(i),window.addEventListener(...i),e}return t(!0),e}onTrackingSent({promise:e,resolve:t}){const{triggerEventTrackingSent:i}=DATA;let n=localStorage.getItem("ABTastyData");const s=()=>JSON.parse(n).ActionTracking.find(({name:e})=>e===i),o=["storage",()=>{n=localStorage.getItem("ABTastyData"),s()&&t(!0)},{passive:!0,capture:!0}];return n&&s()?t(!0):(()=>{this.eventsListeners.push([window,...o]),window.addEventListener(...o)})(),e}onMinPagesViewed({promise:e,resolve:t}){const{triggerEventMinPagesViewed:i}=DATA;let n=localStorage.getItem("ABTastyData");const s=()=>i<=(n?JSON.parse(n).VisitedPages.length:0),o=["storage",()=>{n=localStorage.getItem("ABTastyData"),s()&&t(!0)},{passive:!0,capture:!0}];return n&&s()?t(!0):(()=>{this.eventsListeners.push([window,...o]),window.addEventListener(...o)})(),e}onRageClick({promise:e,resolve:t}){const{triggerEventRageClickQuantity:i,triggerEventRageClickDelay:n}=DATA;let s=0,o=!1;const r=["click",({isTrusted:e})=>{e&&(s+=1,s>=i&&t(!0),o||(o=!0,setTimeout(()=>{s=0,o=!1},n)))},{passive:!0,capture:!0}];return this.eventsListeners.push([document,...r]),document.addEventListener(...r),e}clear(){if(this.elementsSelectors.length&&(this.elementsSelectors.forEach(e=>{document.querySelector(e)&&document.querySelector(e).remove()}),this.elementsSelectors=[]),this.eventsListeners.length&&(this.eventsListeners.forEach(e=>{const[t,...i]=e;t&&i.length>1&&t.removeEventListener(...i)}),this.eventsListeners=[]),this.timeouts.length&&(this.timeouts.forEach(e=>clearTimeout(e)),this.timeouts=[]),this.intervals.length&&(this.intervals.forEach(e=>clearInterval(e)),this.intervals=[]),this.observers.length&&(this.observers.forEach(e=>e.disconnect()),this.observers=[]),this.visibilityObservers.length){const e=h();this.visibilityObservers.forEach(t=>t.clear(this.selector,e)),this.visibilityObservers=[]}return this.promises.length&&(this.promises.forEach(e=>e.resolve(!1)),this.promises=[]),this.elementsWaiters.length&&(this.elementsWaiters.forEach(e=>e.clear()),this.elementsWaiters=[]),this}async isTriggered(){this.clear();const e=p(this.event);this.promises.push(e);const t={consent:()=>this.onConsent(e),direct:()=>!0,pageLoad:()=>this.onPageLoad(e),click:()=>this.onClick(e),exitIntent:()=>this.onExitIntent(e),reengage:()=>this.onReengage(e),elementVisible:()=>this.onElementVisible(e),script:()=>this.onCustomTrigger(e),hover:()=>this.onHover(e),scrollUp:()=>this.onScrollUp(e),scrollPercent:()=>this.onScrollPercentReached(e),rageClick:()=>this.onRageClick(e),minPagesViewed:()=>this.onMinPagesViewed(e),trackingSent:()=>this.onTrackingSent(e),socialProofPurchases:()=>this.getSocialProofPurchases(e),socialProofPageViews:()=>this.getSocialProofPageViews(e)},i=!Object.prototype.hasOwnProperty.call(t,this.event)||await t[this.event]();return this.clear(),"reengage"!==this.event&&this.delay?i&&await(async()=>{const e=p(`${this.event}Delay`);return this.promises.push(e),setTimeout(()=>{e.resolve(!0),this.clear()},this.delay),e.promise})():i}}const f="closing",T="validation",$="ABTastyWidgets",C="ABTastyWidgetsTemporary";class S{constructor({displayRecurrence:e,closingRecurrence:t,validationRecurrence:i},n){this.displayRecurrence=parseFloat(e),this.closingRecurrence=parseFloat(t),this.validationRecurrence=parseFloat(i),this.onSetCallback=n,this.widgetName=l(),this.uniqueId=h(),this.recurrenceKey=`${this.widgetName}_${this.uniqueId}`,this.isListeningStorageEvent=this.listenStorageEvent(),this.pendingRecurrence=!1,this.pendingRecurrenceValue={}}onStorage({key:e}){const t=localStorage.getItem(C),i=sessionStorage.getItem($);"ABTastyData"===e&&!t&&i&&localStorage.setItem(C,i)}listenStorageEvent(){return this.isListeningStorageEvent||window.addEventListener("storage",this.onStorage.bind(this)),!0}getGivenRecurrenceStorageParsed(e){try{const t=e.getItem($);return JSON.parse(t)}catch(t){return e.removeItem($),!1}}getSessionRecurrenceStorageParsed(){return this.getGivenRecurrenceStorageParsed(window.sessionStorage)}getLocalRecurrenceStorageParsed(){return this.getGivenRecurrenceStorageParsed(window.localStorage)}removeGivenStorage(e,t){const{[this.recurrenceKey]:i,...n}=t;return Object.entries(n).length?(e.setItem($,JSON.stringify(n)),n):(e.removeItem($),!1)}removeSessionRecurrenceStorage(){const e=this.getSessionRecurrenceStorageParsed();return!!e&&this.removeGivenStorage(window.sessionStorage,e)}removeLocalRecurrenceStorage(){const e=this.getLocalRecurrenceStorageParsed();return!!e&&this.removeGivenStorage(window.localStorage,e)}getSessionRecurrence(){const e=this.getSessionRecurrenceStorageParsed();return!!e&&e[this.recurrenceKey]}getLocalRecurrence(){const e=this.getLocalRecurrenceStorageParsed();return!!e&&e[this.recurrenceKey]}getCurrentRecurrence(){if(this.pendingRecurrence)return this.pendingRecurrenceValue;const e=this.getSessionRecurrence(),t=this.getLocalRecurrence();return e||t||{type:!1}}isOver(){const e=localStorage.getItem(C),t=!(!e||!e.includes(this.recurrenceKey))||this.getSessionRecurrence();e&&(sessionStorage.setItem($,e),localStorage.removeItem(C));const i=this.getLocalRecurrence(),n=(i?parseFloat(i.stamp):0)<(new Date).getTime();return n&&this.removeLocalRecurrenceStorage(),!this.pendingRecurrence&&n&&!this.getLocalRecurrence()&&!t}setRecurrence(e,t){0!==e&&(window.removeEventListener("storage",this.onStorage.bind(this)),this.isListeningStorageEvent=!1);const n=this.getTypeOfStorage(e);if(i()||!n&&"object"!=typeof n)return!1;const{storageString:o,storageMethod:r}=n,a=this.getStamp(e),c={type:t,stamp:a},{type:l}=this.getCurrentRecurrence(),d=async()=>{if(!s()){this.pendingRecurrence=!0,this.pendingRecurrenceValue=c;const e=new b({triggerEvent:"consent"});await e.isTriggered(),this.pendingRecurrence=!1,this.pendingRecurrenceValue={}}const e=this.getSessionRecurrence(),t=this.getLocalRecurrence();let i;"session"===o?e?i=this.removeSessionRecurrenceStorage():(this.removeLocalRecurrenceStorage(),i=this.getSessionRecurrenceStorageParsed()):"local"===o&&(t?i=this.removeLocalRecurrenceStorage():(this.removeSessionRecurrenceStorage(),i=this.getLocalRecurrenceStorageParsed()));const n=i?{[this.recurrenceKey]:c,...i}:{[this.recurrenceKey]:c};r.setItem($,JSON.stringify(n)),this.onSetCallback&&"function"==typeof this.onSetCallback&&this.onSetCallback()};if(!r)return!1;if(l&&t!==T)if(t===f&&l!==T)d();else{if("display"!==t||l===T||l===f)return!1;d()}else d();return a}setDisplayRecurrence(){this.setRecurrence(this.displayRecurrence,"display")}setClosingRecurrence(){this.setRecurrence(this.closingRecurrence,"closing")}setValidationRecurrence(){this.setRecurrence(this.validationRecurrence,"validation")}getStamp(e){return(new Date).getTime()+864e5*e}getTypeOfStorage(e){return!(isNaN(e)||e<0||0!==e&&!e)&&(e>0?{storageString:"local",storageMethod:window.localStorage}:0===e&&{storageString:"session",storageMethod:window.sessionStorage})}}class A{constructor(e,t,i){this.recurrence=e,this.isWidgetApplied=t,this.callback=i,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(e){const t=n(),{type:i}=this.recurrence?this.recurrence.getCurrentRecurrence():{type:!1};let s;const c=this.isWidgetApplied(),l=(()=>{const t=this.recurrenceIsDone();return e&&"display"===i||t})();return!c&&t&&l?s=r:(!c||t&&l)&&(c||t)?c&&t&&l&&(s=a):s=o,"string"==typeof s&&(this.clearWatcher(),this.callback(s,e),this.watch()),this}eventHandler(){let e=n();return[250,500].forEach(t=>{setTimeout(()=>{const i=n();return 500===t&&i===e?this:(e=i,this.decisionHandler(!1))},t)}),this}observerHandler(e){return e.some(e=>["removedNodes","addedNodes"].some(t=>e[t]&&e[t].length))?this.decisionHandler(!0):this}watch(){if(e())return this;this.clearWatcher(),document.addEventListener(...this.eventListenerParams);const t=()=>{const e=[document.body,{childList:!0,subtree:!0}];this.observer.observe(...e)};return document.body?t():(()=>{const e=m("body",()=>{t(),this.elementsWaiters=this.elementsWaiters.filter(t=>t!==e)});this.elementsWaiters.push(e)})(),this}clearWatcher(){return document.removeEventListener(...this.eventListenerParams),this.elementsWaiters.length&&(this.elementsWaiters.forEach(e=>e.clear()),this.elementsWaiters=[]),this.observer.disconnect(),this}}const E=/.+\/([^.]+)\.(otf|ttf)$/,_=["triggerSocialProofMinPurchases","triggerSocialProofMinPageViews"],x=["top: 0;","top: 50%;","bottom: 0;"],P=["left: 0;","left: 50%;","right: 0;"],I=e=>1===e?"-50%":0,k=()=>{if(Array.isArray(DATA.popinPosition)){const{popinPosition:[{x:e,y:t}]}=DATA,i=`translate(${I(t)}, ${I(e)});`;return`${x[e]}${P[t]}transform: ${i}`}return"left: 50%;top: 50%;transform: translate(-50%, -50%);"},L=()=>"autoWidth"in DATA&&!0===DATA.autoWidth,N=()=>{if(L())return"width: auto;height: auto;";const{popinPercentWidth:e,popinPixelsWidth:t,widthUnit:i,autoHeight:n,popinPercentHeight:s,popinPixelsHeight:o,heightUnit:r}=DATA;return`width: ${"px"===i?t:e}${i};height: ${n?"auto":`${"px"===r?o:s}${r}`};`};class R extends class{constructor(){this.children=void 0,this.uniqueId=h(),this.widgetName=l(),this.prettyName=d(),this.recurrenceParams=(()=>{const{displayRecurrence:t,closingRecurrence:i,validationRecurrence:n}=DATA;if(e()||!t&&!i&&!n)return!1;const s={everytime:()=>-1,session:()=>0,once:()=>395,day:e=>DATA[`${e}_day`],week:e=>7*DATA[`${e}_week`],month:e=>30.5*DATA[`${e}_month`]},o={};return t&&(o.displayRecurrence=s[t]("displayRecurrence")),i&&(o.closingRecurrence=s[i]("closingRecurrence")),n&&(o.validationRecurrence=s[n]("validationRecurrence")),o})(),this.triggerParams=(()=>{let{triggerEvent:t}=DATA;const{triggerEventClick:i,triggerEventHover:n,triggerEventReengageDelay:s,socialProofContentType:o,triggerEventElementVisible:r,triggerEventDelay:a}=DATA;if(e()||!t&&!o)return!1;const c={click:()=>i,hover:()=>n,elementVisible:()=>r},l=Object.prototype.hasOwnProperty.call(c,t)?c[t]():"body",d="reengage"===t?s:a;return o&&(t=1===o?"socialProofPurchases":"socialProofPageViews"),{triggerEvent:t,triggerSelector:l,triggerDelay:d}})(),this.recurrence=!!this.recurrenceParams&&new S(this.recurrenceParams,this.clearGivenClearables.bind(this)),this.trigger=!!this.triggerParams&&new b(this.triggerParams),this.shouldUpdate=!!this.triggerParams&&_.includes(this.triggerParams.triggerEvent),this.pageWatcher=new A(this.recurrence,this.isWidgetApplied.bind(this),this.onPageChange.bind(this),this.shouldUpdate),this.hasOncePerPageTrigger=(()=>{const{isOncePerPageTrigger:e,triggerEvent:t}=DATA;return!t||!["click","hover","scrollUp","script"].includes(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(e=>document.removeEventListener(...e)),this.eventsListeners=[]),this.timeouts.length&&(this.timeouts.forEach(e=>clearTimeout(e)),this.timeouts=[]),this.intervals.length&&(this.intervals.forEach(e=>clearInterval(e)),this.intervals=[]),this.observers.length&&(this.observers.forEach(e=>e.disconnect()),this.observers=[]),this.promises.length&&(this.promises.forEach(e=>e.resolve(!1)),this.promises=[]),this.elementsWaiters.length&&(this.elementsWaiters.forEach(e=>e.clear()),this.elementsWaiters=[])}isWidgetApplied(){return this.domElement&&this.domElement.isConnected}removeOldDomElement(){const e=document.getElementById(this.widgetContainerId);return e&&e.remove(),this}async insert(){if(this.isWidgetApplied())return!1;const e=new Promise(e=>{const t=m("head",t=>{this.elementsWaiters=this.elementsWaiters.filter(({selector:e})=>"head"!==e),e(t.appendChild(this.styleElement))});this.elementsWaiters.push(t)}),t=new Promise(e=>{const{elementReferrer:t="body",referrerInsertType:i="beforeend"}="free"===DATA.layout?DATA:{},n=m(t,n=>{this.elementsWaiters=this.elementsWaiters.filter(e=>e.selector!==t),this.removeOldDomElement(),e(n.insertAdjacentElement(i,this.domElement))});this.elementsWaiters.push(n)});return Promise.all([t,e]).then(()=>this)}remove(){return this.pageWatcher.clearWatcher(),[this.domElement,this.styleElement].forEach(e=>e&&e.isConnected&&e.remove()),this.hasOncePerPageTrigger?this.pageWatcher.watch():e()||this.init().then(({response:e})=>e?this.show():this),this}show(){return e()||this.hasBeenShown&&this.hasOncePerPageTrigger||window.ABTastyEvent(`${this.prettyName} displayed`,null,TEST_ID),this.closedByUser=!1,setTimeout(()=>this.domElement.classList.remove(this.hideClassName),50),this.recurrence&&this.recurrence.setDisplayRecurrence(),this.hasBeenShown=!0,this.pageWatcher.watch(),this}hide(){return!e()&&this.hasBeenShown&&window.ABTastyEvent(`${this.prettyName} closed`,null,TEST_ID),this.closedByUser=!0,this.domElement.classList.add(this.hideClassName),this}async init(t){const i=e(),s=n(),o=this.trigger&&this.trigger.promises.length,r=!this.recurrence||this.recurrence.isOver();if(!i&&!s||o||!r)return!1;this.pageWatcher.watch();const a=i||!this.trigger||this.trigger&&await this.trigger.isTriggered();return!!a&&(await this.insert(),this.addCloseEvent(),i||t||this.hasBeenShown||void 0===this.children||"function"!=typeof this.children.refreshContent||this.children.refreshContent(a),{container:this,response:a})}onPageChange(e,t){const i=()=>this.init().then(({response:e})=>e&&this.show());t||(this.hasBeenShown=!1);const n=this.isWidgetApplied(),s={[o]:()=>{n?this.remove():(this.trigger&&this.trigger.clear(),this.pageWatcher.watch())},[r]:()=>{this.hasBeenShown?this.closedByUser?this.pageWatcher.watch():n||this.insert().then(e=>e.show()).catch(this.pageWatcher.watch):i()},[a]:i};"function"==typeof s[e]&&s[e]()}addCloseEvent(...t){const{closeButton:i,overlay:n,overlayClickable:s,layout:o,animationDuration:r=1e3}=DATA,a=[];if(void 0!==n&&!0!==n||!0!==s||"popin"!==o||a.push(`.${this.overlayClassName}`),void 0!==i&&i&&a.push(`.${this.closeButtonClassName}`),!a.length)return this;const c=this.domElement.querySelectorAll(a.join(", "));return c.length?(t.push(...c),t.forEach(t=>{e()&&(t.dataset.abtastyActionnable="true"),t.addEventListener("click",e=>{v(e),this.recurrence&&this.recurrence.setClosingRecurrence(),this.hide(),setTimeout(()=>this.remove(),1.05*r)},{once:!0,capture:!0})}),this):this}getDom(){const{closeButton:e,layout:t,overlay:i=!0}=DATA,n=document.createElement("div");return n.className=`${this.basicClassName} ${this.hideClassName}`,n.id=this.widgetContainerId,n.innerHTML=`\n\t\t\t${"popin"===t&&!0===i?`<div class="${this.overlayClassName}"></div>`:""}\n\t\t\t<div class="${this.contentClassName}">\n\t\t\t${e?`<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(e,t){if(!e||"inherit"===e)return;const i=document.createElement("style"),n=t.match(E)?t.match(E)[1]:"";i.innerHTML=`@font-face { font-family: '${e}_${n}'; src: url('${t}'); font-display: swap; }`,document.head.appendChild(i)}getStyleTag(t="",i=DATA){const{noStyles:n,layout:s}=i,{backgroundColor:o,isBackgroundImage:r,backgroundImage:a,backgroundSize:c,backgroundPosition:l,backgroundRepeat:d,borderColor:h,borderRadius:u,borderWidth:p,textColor:m,textAlign:g,fontName:v,fontStyle:y,fontSize:w,isTitle:b,titleTextAlign:f,titleTextColor:T,titleFontName:$,titleFontStyle:C,titleFontSize:S,overlay:A,overlayColor:_,dropShadow:x,dropShadowColor:P,dropShadowBlur:I,containerMargin:k,containerPadding:L,closeButton:N,closeButtonPosition:R,closeButtonSize:D,closeButtonBorderRadius:O,closeButtonBorderWidth:B,closeButtonBorderColor:V,closeButtonColor:W,closeButtonBackgroundColor:j,buttonsAlign:M,buttonsBorderWidth:q,buttonsBorderColor:H,buttonsBorderRadius:F,buttonsBackgroundColor:U,buttonsTextColor:z,buttonsFontName:Y,buttonsFontStyle:G,buttonsFontSize:K,secondLink:J,secondLinkBorderWidth:Q,secondLinkBorderColor:X,secondLinkBorderRadius:Z,secondLinkBackgroundColor:ee,secondLinkTextColor:te,secondLinkFontName:ie,secondLinkFontStyle:ne,secondLinkFontSize:se,animation:oe,animationDuration:re,animationBehaviour:ae,animationSlideDirection:ce}=n?{}:i,le=document.createElement("style");le.type="text/css",e()&&le.setAttribute("abtasty-script-added","true"),this.loadFont(v,y),this.loadFont($,C),this.loadFont(Y,G),this.loadFont(ie,ne);const de=`background: ${["string"==typeof o?o:"rgba(255, 255, 255, 1)",r&&"string"==typeof a&&a.length?`url(${a})`:"",r&&"string"==typeof l&&"100% 100%"!==c?l:"0 0",r&&"string"==typeof c?`/ ${c}`:"/ auto",r&&d&&!["cover","100% 100%"].includes(c)?"repeat":"no-repeat"].join(" ").trim()};`,he="number"==typeof p&&p>0,ue=`border: ${[he?`${p}px`:"unset",he?"solid":"",he&&"string"==typeof h&&h.length?h:""].join(" ").trim()};`,pe=void 0!==u?`border-radius: ${u}px;`:"",me=void 0!==m?`color: ${m}; fill: ${m}; -webkit-text-fill-color: ${m};`:"",ge=void 0!==g?`text-align: ${g};`:"",ve=v&&"inherit"!==v?`font-family:${v}_${y.match(E)?y.match(E)[1]:""};`:y||"",ye=w?`font-size: ${w}px;`:"",we=void 0!==x&&x?`box-shadow: 0 5px ${I}px 0 ${P};`:"",be=k instanceof Array&&1===k.length&&k[0],fe=be?`margin: ${be.top}px ${be.right}px ${be.bottom}px ${be.left}px;`:"",Te=be?`margin: calc(${be.top}px * 0.5) calc(${be.right}px * 0.5) calc(${be.bottom}px * 0.5) calc(${be.left}px * 0.5);`:"",$e=L instanceof Array&&1===L.length&&L[0],Ce=$e?`padding: ${$e.top}px ${$e.right}px ${$e.bottom}px ${$e.left}px;`:"",Se=$e?`padding: calc(${$e.top}px * 0.5) calc(${$e.right}px * 0.5) calc(${$e.bottom}px * 0.5) calc(${$e.left}px * 0.5);`:"",Ae=void 0!==q&&q?`border-width: ${q}px; border-style: solid;`:"",Ee=[H,q].every(e=>void 0!==e)&&q?`border-color: ${H};`:"",_e=void 0!==F?`border-radius: ${F}px;`:"",xe=void 0!==U?`background-color: ${U};`:"",Pe=void 0!==z?`color: ${z}; fill: ${z}; -webkit-text-fill-color: ${z};`:"",Ie=Y&&"inherit"!==Y?`font-family:${Y}_${G.match(E)?G.match(E)[1]:""};`:G||"",ke=K?`font-size: ${K}px;`:"",Le=void 0!==Q&&Q?`border-width: ${Q}px; border-style: solid;`:"",Ne=[X,Q].every(e=>void 0!==e)&&Q?`border-color: ${X};`:"",Re=void 0!==Z?`border-radius: ${Z}px;`:"",De=void 0!==ee?`background-color: ${ee};`:"",Oe=void 0!==te?`color: ${te}; fill: ${te}; -webkit-text-fill-color: ${te};`:"",Be=ie&&"inherit"!==ie?`font-family:${ie}_${ne.match(E)?ne.match(E)[1]:""};`:ne||"",Ve=se?`font-size: ${se}px;`:"",We="popin"!==s||void 0!==A&&!0!==A?"":[`#${this.widgetContainerId} .${this.overlayClassName} {`,`background-color: ${void 0!==_?_:"rgba(0, 0, 0, 0.6)"};`,"}"].join(""),je="number"==typeof D?D:16,Me=je/2,qe=n||void 0!==N&&N?[`#${this.widgetContainerId} .${this.contentClassName} .${this.closeButtonClassName} {`,"position: absolute;",("out"===R?`bottom: calc(100% + ${Me}px)`:`top: ${Me}px`)+";",`right: ${Me}px;`,"width: auto;","height: auto;","background: none;","border: none;","cursor: pointer;","outline: none;","padding: 0;","margin: 0;","line-height: 0;","z-index: 9;","number"==typeof O?`border-radius: ${O}px;`:"","number"==typeof B&&B>0?`border: ${B}px solid ${void 0!==V?V:"rgba(57, 57, 57, 1)"};`:"","string"==typeof j?`background-color: ${j};`:"","}",`#${this.widgetContainerId} .${this.contentClassName} .${this.closeButtonClassName} svg {`,"pointer-events: none;",`width: ${je}px;`,`height: ${je}px;`,"string"==typeof W?`fill: ${W};`:"","}"].join(""):"",He=b&&"string"==typeof T?[`#${this.widgetContainerId} .${this.contentClassName} > * h1, `,`#${this.widgetContainerId} .${this.contentClassName} > * h2, `,`#${this.widgetContainerId} .${this.contentClassName} > * h3, `,`#${this.widgetContainerId} .${this.contentClassName} > * h4, `,`#${this.widgetContainerId} .${this.contentClassName} > * h5, `,`#${this.widgetContainerId} .${this.contentClassName} > * h6 {`,`color: ${T}; fill: ${T}; -webkit-text-fill-color: ${T};`,void 0!==f?`text-align: ${f};`:"",$&&"inherit"!==$?`font-family:${$}_${C.match(E)?C.match(E)[1]:""};`:C||"",S?`font-size: ${S}px;`:"","}"].join(""):"";let Fe="";if("string"==typeof oe){const t=(re/1e3).toFixed(2),i=["top","bottom"].includes(ce),n=Number(i),s=[(["top","left"].includes(ce)?"-":"")+"100vmax",this.translateValues?this.translateValues[n]:"0"];i&&s.reverse(),Fe={none:[],fade:[`#${this.widgetContainerId} {`,`transition: opacity ${t}s ${ae};`,"}"],slide:[`.${this.hideClassName} .${this.overlayClassName} {`,"opacity: 0 !important;","}",`#${this.widgetContainerId} .${this.overlayClassName} {`,`transition: opacity ${t}s ${ae};`,"}",`.${this.hideClassName} .${this.contentClassName} {`,`transform: translate(${s.join(", ")}) !important;`,"}",`#${this.widgetContainerId} .${this.contentClassName} {`,`transition: transform ${t}s ${ae};`,"}"]}[e()&&!ABTASTY_S.WIDGETS.animationChanged?"none":oe].join("")}const Ue=[`#${this.widgetContainerId} .${this.contentClassName} > * a:nth-child(2), `,`#${this.widgetContainerId} .${this.contentClassName} > * button:nth-child(2) {`,`margin-${"fill"===M?"top":"left"}: 8px;`,Le,Ne,Re,De,Oe,Be,Ve,"}",`#${this.widgetContainerId} .${this.contentClassName} > * a:nth-child(2) *, `,`#${this.widgetContainerId} .${this.contentClassName} > * button:nth-child(2) * {`,Oe,Be,Ve,"}"];return le.textContent=[`.${this.hideClassName} {`,"opacity: 0 !important;","pointer-events: none;","}",`#${this.widgetContainerId} {`,"opacity: 1;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,de,pe,ue,me,ge,we,fe,ve,ye,"}",`#${this.widgetContainerId} .${this.contentClassName} p {`,me,ge,ve,ye,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,"display: block;","line-height: 1;","text-indent: unset;",Ce,ve,ye,"}",`#${this.widgetContainerId} .${this.contentClassName} > * a, `,`#${this.widgetContainerId} .${this.contentClassName} > * button {`,"box-sizing: border-box;","display: inline-block;",Ae,Ee,_e,xe,Pe,Ie,ke,"}",`#${this.widgetContainerId} .${this.contentClassName} > * a *, `,`#${this.widgetContainerId} .${this.contentClassName} > * button * {`,Pe,Ie,ke,"}",...J?Ue:[],"@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,Te,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,Se,"}","}",We,qe,He,Fe,`${t}`].join(""),le}}{constructor(){super(),this.translateValues=Object.values(DATA.popinPosition[0]).map(e=>I(e)),this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){const{zindex:e,zindexCustom:t,overlay:i}=DATA;return[`#${this.widgetContainerId} {`,"position: fixed;","top: 0;","left: 0;","width: 100%;","height: 100%;",`z-index: ${"custom"===e?t:e};`,"background: none;","pointer-events: "+(!1===i?"none":"all"),"}",`#${this.widgetContainerId} .${this.overlayClassName} {`,"position: absolute;","z-index: -1;","top: 0;","left: 0;","width: 100%;","height: 100%;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: absolute;",k(),N(),"pointer-events: all","}",`${L()?"":[`#${this.widgetContainerId} .${this.contentClassName} > div {`,"height: 100%;","overflow: auto;","box-sizing: border-box;","}"].join("")}`,`${L()?"":["@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,"max-width: 94vw;","}","}"].join("")}`].join("")}}e()&&Number(ABTASTY_S.USER.additionalInformation.account_iframe_less_mode);const D=["mp4","webm","ogg"],O=()=>D.some(e=>DATA.video.includes(e)),B=e=>e.replace("/","__").replace("?","__").replace("#","__").replace("&","__"),V=e=>(256|e).toString(16).slice(1);function W(e){const t=e.replace(/\s/g,"").match(/^rgba?\((\d+),(\d+),(\d+),?([^,\s)]+)?/i);return"".concat(V(t[1])).concat(V(t[2])).concat(V(t[3]))}const j="C71YkqN0pEA",M=["youtube.com","youtu.be"],q=()=>M.some(e=>DATA.video.includes(e)||""===DATA.video),H=(e,t)=>{if(window.YT&&"function"==typeof YT.Player){const i=(()=>{const{video:e}=DATA;if(""===e)return j;const t=["youtube.com/embed/","youtube.com/watch?v=","youtu.be/"].filter(t=>e.includes(t))[0],i=t?B(e.split(t)[1]):"";return!!i.length&&i.split("__")[0]})(),n=(()=>{const{youtubeCCLoadPolicy:e,youtubeColor:t,youtubeControls:i,youtubeDisableKeyboard:n,youtubeEndTime:s,youtubeFullScreen:o,youtubeStartTime:r}=DATA,a={origin:location.origin,rel:0,color:t,controls:i?1:0,disablekb:n?0:1,fs:o?1:0};return e&&(a.cc_load_policy=1),s&&(a.end=s),r&&(a.start=r),a})(),s=(()=>{const{youtubeAutoPlay:e,youtubeLoop:t,youtubeMuted:i,youtubeStartTime:n}=DATA,s={};return(e||i)&&(s.onReady=t=>{i&&t.target.mute(),e&&t.target.playVideo()}),t&&(s.onStateChange=e=>{0===e.data&&(n&&e.target.seekTo(n),e.target.playVideo())}),s})(),o=new YT.Player("popin_video_iframe_".concat(e),{videoId:i,playerVars:n,events:s});return t(o)}return setTimeout(()=>H(e,t),100)};function F(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),i.push.apply(i,n)}return i}function U(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}const z=()=>DATA.video.includes("vimeo.com"),Y=(e,t)=>{if(window.Vimeo&&"function"==typeof Vimeo.Player){const{vimeoStartTime:i}=DATA,n=(()=>{const{video:e,vimeoAutoPlay:t,vimeoColor:i,vimeoLoop:n,vimeoMuted:s,vimeoInfos:o}=DATA;return{url:e,autoplay:t,byline:o,color:W(i),loop:n,muted:s,portrait:o,title:o}})(),s=new Vimeo.Player("popin_video_iframe_".concat(e),function(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?F(Object(i),!0).forEach(function(t){U(e,t,i[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):F(Object(i)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})}return e}({},n));return i&&s.setCurrentTime(i),t(s)}return setTimeout(()=>Y(e,t),100)},G=["dailymotion.com","dai.ly"],K=()=>G.some(e=>DATA.video.includes(e)),J=()=>{const{video:e}=DATA,t=["/video/","dai.ly/"].filter(t=>e.includes(t))[0],i=t?B(e.split(t)[1]):"";return!!i.length&&i.split("__")[0]},Q=(e,t,i,n)=>{if(window.DM&&"function"==typeof DM.player){const s=(()=>{const{dailymotionAutoPlay:e,dailymotionMuted:t,dailymotionColor:i,dailymotionLogo:n}=DATA;return{autoplay:e,mute:t,logo:n,"ui-highlight":W(i)}})(),o=DM.player(t.querySelector("#popin_video_iframe_".concat(e)),{video:J(),params:s});return i(o),n(o)}return setTimeout(()=>Q(e,t,n,i),100)},X=()=>DATA.video.includes("tiktok.com"),Z=()=>{return e="".concat("https://www.tiktok.com/oembed?url=").concat(DATA.video),new Promise((t,i)=>{const n=new XMLHttpRequest;n.open("GET",e,!0),n.onload=function(){this.status>=200&&this.status<300?t(n.response):i({status:this.status,statusText:n.statusText})},n.onerror=function(){i({status:this.status,statusText:n.statusText})},n.send()});var e},ee=()=>{const{linkType:e,buttonText:t}=DATA;return!!([e,t].every(e=>"string"==typeof e)&&e.includes("button")&&t.length)};class te{constructor(e){let{parentContainer:t}=e;this.parentContainer=t,this.className="popinvideo_container_".concat(t.uniqueId),this.videoSource=DATA.video||"".concat("https://www.youtube.com/embed/").concat(j),this.contentElement=this.getContentElement(),this.styleElement=this.getStyleElement()}remove(){const{animationDuration:e=1e3}=DATA;setTimeout(()=>this.parentContainer.remove(),1.05*e)}addCloseEvent(t){t&&t.addEventListener("click",t=>{v(t),e()||this.parentContainer.recurrence.setClosingRecurrence(),this.parentContainer.hide(),this.remove()},{capture:!0,passive:!1})}addRedirectionEvent(t){!e()&&t&&t.addEventListener("click",()=>{const{autoHide:t,timeHide:i}=DATA;t&&setTimeout(()=>{this.parentContainer.hide(),this.remove()},1e3*i),e()||this.parentContainer.recurrence.setValidationRecurrence()},{capture:!0,passive:!0})}insertButtonsInContainer(e){const t=this.getButtons(),i=document.createElement("div");i.className="buttons_container",t.forEach(e=>i.appendChild(e)),e.appendChild(i)}getButtons(){const e=(e,t,i,n)=>{const s=document.createElement("a");return s.className="popin_link",s.innerHTML="<span>".concat(e,"</span>"),s.href="button"===t?i:"#","button"===t?(s.target=n?"_blank":"_self",this.addRedirectionEvent(s)):(s.dataset.abtastyActionnable="true",this.addCloseEvent(s)),s},{linkType:t,buttonText:i,redirectionUrl:n,openInNewTab:s,secondLink:o,secondLinkText:r,secondLinkType:a,secondLinkURL:c,secondLinkOpenInNewTab:l}=DATA,d=[e(i,t,n,s)];if(o){const t=e(r,a,c,l);d.push(t)}return d}getVideoContainer(){const e="popin_video_iframe",t="".concat(e,"_").concat(this.parentContainer.uniqueId),i=document.createElement("div");if(i.className="popin_video_container",O()){const{htmlPlayerAutoPlay:e,htmlPlayerMuted:t,htmlPlayerLoop:n,htmlPlayerControls:s}=DATA,o=D.filter(e=>this.videoSource.includes(".".concat(e)))[0],r=document.createElement("video");r.innerHTML='<source src="'.concat(this.videoSource,'" type="video/').concat(o,'">'),e&&(r.autoplay=!0),t&&(r.muted=!0),n&&(r.loop=!0),s&&(r.controls=!0),i.appendChild(r)}else{DATA.video.includes("facebook.com")&&(this.videoSource=(()=>{const{video:e}=DATA;return e.includes("plugins/video.php")?e:"https://www.facebook.com/plugins/video.php?href=".concat(e,"&show_text=0")})());const n='<div id="'.concat(t,'" class="').concat(e,'"></div>'),s='<iframe id="'.concat(t,'" class="').concat(e,'" src="').concat(this.videoSource,'"></iframe>');i.innerHTML=[q(),z(),K(),X()].some(e=>e)?n:s}return i}setVideoOnlyContent(e,t){const i=this.getVideoContainer();return e.appendChild(i),e.classList.add(t),ee()&&this.insertButtonsInContainer(e),e}setVideoAndTextContent(e,t){const{isTitle:i,title:n,textContent:s}=DATA,o=this.getVideoContainer(),r=document.createElement("div");return r.className="popin_text_container",r.innerHTML="".concat(i?'<h2 class="popin_video_title">'.concat(n,"</h2>"):"",'<p class="popin_video_text">').concat(s,"</p>"),e.classList.add(t),["leftVideo","topVideo"].some(e=>e===t)&&e.appendChild(o),e.appendChild(r),["rightVideo","bottomVideo"].some(e=>e===t)&&e.appendChild(o),ee()&&this.insertButtonsInContainer(r),e}insertIn(e,t){return document.head.insertAdjacentElement("beforeend",this.styleElement),e.insertAdjacentElement(t,this.contentElement),e}getContentElement(){const{contentLayout:e}=DATA,t=document.createElement("div");return t.className=this.className,{videoOnly:()=>this.setVideoOnlyContent(t,"onlyVideo"),left:()=>this.setVideoAndTextContent(t,"leftVideo"),right:()=>this.setVideoAndTextContent(t,"rightVideo"),top:()=>this.setVideoAndTextContent(t,"topVideo"),bottom:()=>this.setVideoAndTextContent(t,"bottomVideo")}[e](),t}getStyleElement(){const t=document.createElement("style");t.type="text/css",e()&&t.setAttribute("abtasty-script-added","true");const{textVideoRatio:i,borderRadius:n,borderWidth:s,containerPadding:o,contentLayout:r,linkType:a,buttonsAlign:c}=DATA,l="#".concat(this.parentContainer.widgetContainerId," .").concat(this.parentContainer.contentClassName),d=o[0],h=parseInt(n-s,10),u=h-d.top>0?h-d.top:0,p=h-d.bottom>0?h-d.bottom:0,m=void 0!==c&&"fill"!==c?"text-align: ".concat(c,";"):"",g=["".concat(l," .onlyVideo .popin_video_container {"),"border-radius: ".concat(u,"px ").concat(u,"px ").concat(p,"px ").concat(p,"px;"),"}"].join(""),v=["".concat(l," .leftVideo .popin_video_container {"),"width: calc(".concat(i,"% - 2.5%);"),"}","".concat(l," .leftVideo .popin_text_container {"),"width: calc(100% - ".concat(i,"% - 2.5%);"),"position: relative;","margin: 0 2.5%;","}","".concat(l," .leftVideo .popin_video_container {"),"border-radius: ".concat(u,"px 0 0 ").concat(p,"px;"),"}"].join(""),y=["".concat(l," .rightVideo .popin_video_container {"),"width: calc(".concat(i,"% - 2.5%);"),"}","".concat(l," .rightVideo .popin_text_container {"),"width: calc(100% - ".concat(i,"% - 2.5%);"),"position: relative;","margin: 0 2.5%;","}","".concat(l," .rightVideo .popin_video_container {"),"border-radius: 0 ".concat(u,"px ").concat(p,"px 0;"),"}"].join(""),w=["".concat(l," .topVideo .popin_video_container {"),"border-radius: ".concat(u,"px ").concat(u,"px 0 0;"),"margin-bottom: 15px","}"].join(""),b=["".concat(l," .bottomVideo .popin_video_container {"),"border-radius: 0 0 ".concat(p,"px ").concat(p,"px;"),"margin-top: 15px;","}"].join(""),f=["".concat(l," .buttons_container {"),"display: inline-block;","width: 100%;",m,"}","".concat(l," .popin_link {"),"display: inline-block;","margin: 25px 0 0 0;","padding: 10px 22px;","max-width: 100%;","width: ".concat("fill"===c?"100%":"auto",";"),"text-align: center;","}"].join(""),T=["".concat(l," .popin_video_container {"),"line-height: 0;","overflow: hidden;","width: 100%;","max-width: 100%;","}","".concat(l," .popin_video_title {"),"margin: 0 0 25px 0;","display: inline-block;","width: 100%;","}","".concat(l," .popin_video_container video,"),"".concat(l," .popin_video_container .popin_video_iframe {"),"display: inline-block;","width: 100%;","height: 100%;","}","".concat(l," .popin_video_container .popin_video_iframe iframe {"),"display: inline-block;","width: 100%;","}","".concat(l," .popin_text_container {"),"line-height: 1;","white-space: pre-line;","}","".concat(l," .popin_text_container p {"),"margin: 0;","}","".concat(l," .popin_video_container,"),"".concat(l," .popin_text_container {"),"display: inline-block;","vertical-align: middle;","}"];return(0,{videoOnly:()=>T.push(g),top:()=>T.push(w),bottom:()=>T.push(b),left:()=>T.push(v),right:()=>T.push(y)}[r])(),a&&T.push(f),t.textContent=T.join(""),t}}function ie(e){const t=e.querySelector(".popin_video_iframe"),i=parseInt(t.clientWidth/16*9,10)+1;t.style.height="".concat(i,"px")}!function(){const e=h(),t=q(),i=z(),n=K(),s=X();t&&(e=>{if(window.YT)return!1;const t=document.createElement("script");t.src="https://www.youtube.com/iframe_api",t.id="video_popin_ytapi_".concat(e),document.head.appendChild(t)})(e),i&&(e=>{if(window.Vimeo)return!1;const t=document.createElement("script");t.src="https://player.vimeo.com/api/player.js",t.id="video_popin_vimeoapi_".concat(e),document.head.appendChild(t)})(e),n&&(e=>{if(window.DM)return!1;const t=document.createElement("script");t.src="https://api.dmcdn.net/all.js",t.id="video_popin_dailymotionapi_".concat(e),document.head.appendChild(t)})(e),s&&(e=>{window.tiktokEmbed&&(window.tiktokEmbed=void 0);const t=document.createElement("script");t.src="https://www.tiktok.com/embed.js",t.id="video_popin_tiktokapi_".concat(e),t.async=!0,document.head.appendChild(t)})(e);const o=new R,r=new te({parentContainer:o}),a=r.contentElement.querySelector(".popin_video_container");if(s){const t=()=>{window.tiktokEmbed?Z().then(t=>{const i=JSON.parse(t),n=a.querySelector("#popin_video_iframe_".concat(e));n.innerHTML=i.html,r.player=n,a.appendChild(r.player)}):setTimeout(t,100)};t()}const c=o.domElement.querySelector(".".concat(o.contentClassName));o.children=r,r.insertIn(c,"beforeend"),o.init().then(c=>{let{response:l}=c;if(l){const c=e=>{r.player=e,i||s||O()||(ie(r.contentElement),window.addEventListener("resize",()=>ie(r.contentElement),{capture:!0,passive:!0}))};t&&H(e,c),i&&Y(e,c),n&&Q(e,r.contentElement,e=>{a.innerHTML="",a.appendChild(e)},c),r.player||c(a),o.show()}})}()}();
1
+ !function(){"use strict";const e=()=>Object.prototype.hasOwnProperty.call(window,"ABTastyEditor"),t=()=>{let e;return window.ABTasty||window.ABTASTY_S?(window.ABTASTY_S&&window.ABTASTY_S.USER&&window.ABTASTY_S.USER.accountIdentifier&&window.ABTASTY_S.USER.accountIdentifier.length?e=window.ABTASTY_S.USER.accountIdentifier:window.ABTasty&&window.ABTasty.getAccountSettings&&"function"==typeof window.ABTasty.getAccountSettings?e=window.ABTasty.getAccountSettings().identifier:window.ABTasty&&window.ABTasty.accountSettings&&(e=window.ABTasty.accountSettings.identifier),e):e},i=()=>{const e=!!document.getElementById("ABTastyPreviewBar"),t=location.href.includes("ab_project=preview");return e||t},n=()=>!e()&&(i()||!!window.ABTasty.getTestsOnPage()[TEST_ID]),s=()=>window.ABTasty&&!0===window.ABTasty.consentReady,o="remove",r="rebuild",a="update",c="https://api-social-proof.abtasty.com/clients/",l=()=>{const{type:e}=DATA;return`${PACKAGE.replace("@abtasty/","")}${e?`_${e}`:""}`},d=()=>{const e=l();return`${e.charAt(0).toUpperCase()}${e.slice(1)}`.split("-").join(" ")},h=()=>`${PLUGIN_ID.split("-")[0]}_${TEST_ID}`,u=t=>{if((()=>{if(e()||i())return!1;const t=ABTasty.getTestsOnPage()[TEST_ID];return!!t&&Object.keys(t.targetings.qaParameters).length>0})()){const e=d();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=e=>{const t={promise:null,resolve:null,reject:null,name:e};return t.promise=new Promise((e,i)=>{t.resolve=e,t.reject=i}),t},m=(e,t)=>{const i=()=>{try{return document.querySelector(e)}catch(e){return null}};let n=i();const s=[document.body||document.documentElement,{childList:!0,subtree:!0,attributes:!0}],o=()=>a.disconnect(),r=()=>a.observe(...s),a=new MutationObserver(()=>(n=i(),n&&!o()&&t(n)));return n?setTimeout(()=>t(n),0):r(),{selector:e,clear:o,observe:r}};function g(e,t){return t(e)||!e.parentElement?e:g(e.parentElement,t)}const v=t=>{e()||(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation())},y=(e,t)=>[...document.querySelectorAll(t)].some(i=>i.isSameNode(e)||!!e.closest(t));class w{constructor(){this.targets=[],this.existingTargets=[],this.inViewportTargets=[],this.visibilityObserver=this.startVisibilityObserver(),this.mutationObserver=this.startMutationObserver(),this.mouseOverEvent=this.mouseOverHandler()}intersectionHandler(e){e.forEach(e=>{e.isIntersecting?(this.existingTargets.forEach(t=>{t.element.isSameNode(e.target)&&(this.inViewportTargets.push(t),this.mouseOverEvent.start())}),this.checkElements()):this.inViewportTargets=this.inViewportTargets.filter(t=>!t.element.isSameNode(e.target)||(this.mouseOverEvent.clear(),!1))})}startVisibilityObserver(){return new IntersectionObserver(this.intersectionHandler.bind(this),{root:null,rootMargin:"0px",threshold:0})}startMutationObserver(){const e=this.mutationObserver||new MutationObserver(this.checkElements.bind(this));return document.body&&e.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),e}onMouseOver({target:e,path:t}){const i=this.inViewportTargets.find(({element:i,selector:n})=>{if(i.isSameNode(e))return!0;const s=[...e.querySelectorAll(n)];if(s.length&&s.includes(i))return!0;if(t.includes(i))return!0;const o=[...e.parentElement.children],r=o.findIndex(t=>t.isSameNode(e)),a=o.filter((e,t)=>t>r);if(a.length){if(a.includes(i))return!0;if(a.some(e=>[...e.querySelectorAll(n)].includes(i)))return!0}return!1});if(i&&this.isElementVisible(i.element)){const{selector:e,element:t,uniqueId:n}=i,s=this.targets.find(t=>t.selector===e&&t.uniqueId===n);s&&s.resolve(t),this.clear(e,n)}}mouseOverHandler(){const e=["mouseover",e=>setTimeout(()=>this.onMouseOver(e),50),!0];return{start:()=>document.addEventListener(...e),clear:()=>document.removeEventListener(...e)}}isElementVisible(e){return this.isElementTopmost(e)&&this.isElementOpaque(e)}isElementOpaque(e){return"HTML"===g(e,e=>"0"===window.getComputedStyle(e).opacity).nodeName}isElementTopmost(e){const t=e.getBoundingClientRect(),i=[[t.left,t.top],[t.right,t.top],[t.left,t.bottom],[t.right,t.bottom],[t.left+t.width/2,t.top],[t.left+t.width/2,t.bottom],[t.left,t.height/2],[t.right,t.height/2],[t.left+t.left/2,t.height/2]];let n=!1,s=0;for(;!n&&s<i.length;){const t=document.elementFromPoint(...i[s]);n=e===t||e.contains(t),s+=1}return n}checkElements(){this.targets.forEach(({selector:e,uniqueId:t})=>{const i=document.querySelector(e);i&&!this.existingTargets.find(i=>i.element.matches(e)&&i.uniqueId===t)&&(this.existingTargets.push({element:i,selector:e,uniqueId:t}),this.visibilityObserver.observe(i))}),this.existingTargets=this.existingTargets.filter(({selector:e,element:t})=>!!document.querySelector(e)||(t&&this.visibilityObserver.unobserve(t),!1)),this.inViewportTargets=this.inViewportTargets.filter(({selector:e,element:t,uniqueId:i})=>{if(t.matches(e)&&this.isElementVisible(t)){const n=this.targets.find(t=>t.selector===e&&t.uniqueId===i);return n&&n.resolve(t),this.clear(e,i),!1}return!0})}watch(e,t,i){this.targets.push({selector:e,resolve:t,uniqueId:i});const n=()=>{this.startMutationObserver(),this.checkElements()};document.body?n():m("body",n)}clear(e,t){[this.targets,this.existingTargets,this.inViewportTargets]=[this.targets,this.existingTargets,this.inViewportTargets].map(i=>i.filter(({selector:i,uniqueId:n})=>i!==e&&n!==t));const i=document.querySelector(e);i&&this.visibilityObserver.unobserve(i),0===this.targets.length&&this.mutationObserver.disconnect(),0===this.inViewportTargets.length&&this.mouseOverEvent.clear()}}class b{constructor({triggerEvent:e,triggerSelector:t,triggerDelay:i}){this.event=e,this.selector=t&&t.length?t:"body",this.delay=1e3*i,this.elementsSelectors=[],this.eventsListeners=[],this.timeouts=[],this.intervals=[],this.observers=[],this.promises=[],this.visibilityObservers=[],this.elementsWaiters=[]}async onElementVisible({promise:e,resolve:t}){const i=p(`${this.event}DomReady`);this.promises.push(i);const n=await this.onPageLoad(i),s=await async function(){let e;return e=await("IntersectionObserver"in window&&"IntersectionObserverEntry"in window&&"intersectionRatio"in window.IntersectionObserverEntry.prototype||new Promise((e,t)=>{const i=window.document.getElementsByTagName("script")[0],n=window.document.createElement("script");n.src="https://polyfill.io/v3/polyfill.min.js?flags=gated&features=IntersectionObserver",i.parentNode.insertBefore(n,i),n.onload=e,n.onerror=t})),e}(),o=new w;if(this.visibilityObservers.push(o),s&&n){const e=h();o.watch(this.selector,t,e)}return e}onPageLoad({promise:e,resolve:t}){const i=()=>"complete"===document.readyState;if(!i()){const n=["readystatechange",({isTrusted:e})=>e&&i()&&t(!0),{passive:!0}];return this.eventsListeners.push([document,...n]),document.addEventListener(...n),e}return t(!0),e}onClick({promise:e,resolve:t}){const i=document.createElement("style");i.type="text/css",i.id=`Click_${h()}`,i.innerHTML=`${this.selector} {\n\t\t\tcursor: pointer !important;\n\t\t\tpointer-events: all !important;\n\t\t}`,document.head.appendChild(i),this.elementsSelectors.push(`#${i.id}`);const n=["click",({isTrusted:e,target:i})=>e&&y(i,this.selector)&&t(!0),{passive:!0,capture:!0}];return this.eventsListeners.push([document,...n]),document.addEventListener(...n),e}onHover({promise:e,resolve:t}){const i=["mouseenter",({isTrusted:e,target:i})=>e&&y(i,this.selector)&&t(!0),{passive:!0,capture:!0}];return this.eventsListeners.push([document.documentElement,...i]),document.documentElement.addEventListener(...i),e}onExitIntent({promise:e,resolve:t}){const i=["mouseleave",({isTrusted:e,clientY:i})=>{e&&i<=0&&t(!0)},{passive:!0}],n=m("body",e=>{this.eventsListeners.push([e,...i]),e.addEventListener(...i),this.elementsWaiters=this.elementsWaiters.filter(e=>e!==n)});return this.elementsWaiters.push(n),e}onReengage({promise:e,resolve:t}){const i=this.delay;let n=i;const s=[({isTrusted:e})=>{e&&(n=i)},{passive:!0}];["click","mousemove","scroll","keypress"].forEach(e=>{this.eventsListeners.push([document,e,...s]),document.addEventListener(e,...s)});const o=setInterval(()=>{n<=0?t(!0):n-=100},100);return this.intervals.push(o),e}onCustomTrigger({promise:e,resolve:t}){const{triggerEventCustomScript:i}=DATA;return new Function(`return new Promise(async resolve => {${i}})`)().then(e=>e&&t(!0)),e}onScrollUp({promise:e,resolve:t}){let i=0;const n=["scroll",({isTrusted:e})=>{e&&(window.pageYOffset<i?t(!0):i=window.pageYOffset)},{passive:!0,capture:!0}];return this.eventsListeners.push([document,...n]),document.addEventListener(...n),e}onScrollPercentReached({promise:e,resolve:t}){const{triggerEventScrollPercent:i}=DATA,n=["scroll",({isTrusted:e})=>{if(!e)return;const n=(()=>{const{documentElement:e,body:t}=document,i=e.scrollTop||t.scrollTop,n=e.scrollHeight||t.scrollHeight;return Math.trunc(i/(n-e.clientHeight)*100,10)})();i<n&&t(!0)},{passive:!0,capture:!0}];return this.eventsListeners.push([document,...n]),document.addEventListener(...n),e}getSocialProofPurchases({promise:e,resolve:i}){const n=window.ABTastyProductKey,s=t(),{viewInterval:o,triggerSocialProofMinPurchases:r,spNoTrim:a}=DATA;return n||(u("Not able to find ABTastyProductKey, impossible to call the API."),i(!1)),n&&s?fetch(`${c}${s}/metrics/i?key=${n}${a?"&noTrim=true":""}`).then(e=>e.ok&&e.json()).then(e=>(e=>{if(void 0===o||void 0===r)return!1;const t=void 0!==e[o]&&e[o]>=r;return t||u(`Widget will not be shown, product has been purchased ${e[o]} times while ${r} are required`),t})(e)&&i(`${e[o]}`)).catch(()=>u("Failed to fetch datas from server.")):i(!1),e}getSocialProofPageViews({promise:e,resolve:i}){const{viewInterval:n,triggerSocialProofMinPageViews:s,spNoTrim:o}=DATA,r=encodeURIComponent(o?window.location.href.replace(window.location.origin,""):`${window.location.pathname}`),a=t();return r&&a?fetch(`${c}${a}/metrics/pv?key=${r}${o?"&noTrim=true":""}`).then(e=>e.ok&&e.json()).then(e=>(e=>{if(void 0===n||void 0===s)return!1;const t=void 0!==e[n]&&e[n]>=s;return t||u(`Widget will not be shown, page has been seen ${e[n]} times while ${s} are required`),t})(e)&&i(`${e[n]}`)).catch(()=>u("Failed to fetch datas from server.")):i(!1),e}onConsent({promise:e,resolve:t}){if(!s()){const i=["abtasty_consentValid",()=>t(!0)];return this.eventsListeners.push(i),window.addEventListener(...i),e}return t(!0),e}onTrackingSent({promise:e,resolve:t}){const{triggerEventTrackingSent:i}=DATA;let n=localStorage.getItem("ABTastyData");const s=()=>JSON.parse(n).ActionTracking.find(({name:e})=>e===i),o=["storage",()=>{n=localStorage.getItem("ABTastyData"),s()&&t(!0)},{passive:!0,capture:!0}];return n&&s()?t(!0):(()=>{this.eventsListeners.push([window,...o]),window.addEventListener(...o)})(),e}onMinPagesViewed({promise:e,resolve:t}){const{triggerEventMinPagesViewed:i}=DATA;let n=localStorage.getItem("ABTastyData");const s=()=>i<=(n?JSON.parse(n).VisitedPages.length:0),o=["storage",()=>{n=localStorage.getItem("ABTastyData"),s()&&t(!0)},{passive:!0,capture:!0}];return n&&s()?t(!0):(()=>{this.eventsListeners.push([window,...o]),window.addEventListener(...o)})(),e}onRageClick({promise:e,resolve:t}){const{triggerEventRageClickQuantity:i,triggerEventRageClickDelay:n}=DATA;let s=0,o=!1;const r=["click",({isTrusted:e})=>{e&&(s+=1,s>=i&&t(!0),o||(o=!0,setTimeout(()=>{s=0,o=!1},n)))},{passive:!0,capture:!0}];return this.eventsListeners.push([document,...r]),document.addEventListener(...r),e}clear(){if(this.elementsSelectors.length&&(this.elementsSelectors.forEach(e=>{document.querySelector(e)&&document.querySelector(e).remove()}),this.elementsSelectors=[]),this.eventsListeners.length&&(this.eventsListeners.forEach(e=>{const[t,...i]=e;t&&i.length>1&&t.removeEventListener(...i)}),this.eventsListeners=[]),this.timeouts.length&&(this.timeouts.forEach(e=>clearTimeout(e)),this.timeouts=[]),this.intervals.length&&(this.intervals.forEach(e=>clearInterval(e)),this.intervals=[]),this.observers.length&&(this.observers.forEach(e=>e.disconnect()),this.observers=[]),this.visibilityObservers.length){const e=h();this.visibilityObservers.forEach(t=>t.clear(this.selector,e)),this.visibilityObservers=[]}return this.promises.length&&(this.promises.forEach(e=>e.resolve(!1)),this.promises=[]),this.elementsWaiters.length&&(this.elementsWaiters.forEach(e=>e.clear()),this.elementsWaiters=[]),this}async isTriggered(){this.clear();const e=p(this.event);this.promises.push(e);const t={consent:()=>this.onConsent(e),direct:()=>!0,pageLoad:()=>this.onPageLoad(e),click:()=>this.onClick(e),exitIntent:()=>this.onExitIntent(e),reengage:()=>this.onReengage(e),elementVisible:()=>this.onElementVisible(e),script:()=>this.onCustomTrigger(e),hover:()=>this.onHover(e),scrollUp:()=>this.onScrollUp(e),scrollPercent:()=>this.onScrollPercentReached(e),rageClick:()=>this.onRageClick(e),minPagesViewed:()=>this.onMinPagesViewed(e),trackingSent:()=>this.onTrackingSent(e),socialProofPurchases:()=>this.getSocialProofPurchases(e),socialProofPageViews:()=>this.getSocialProofPageViews(e)},i=!Object.prototype.hasOwnProperty.call(t,this.event)||await t[this.event]();return this.clear(),"reengage"!==this.event&&this.delay?i&&await(async()=>{const e=p(`${this.event}Delay`);return this.promises.push(e),setTimeout(()=>{e.resolve(!0),this.clear()},this.delay),e.promise})():i}}const f="closing",T="validation",$="ABTastyWidgets",C="ABTastyWidgetsTemporary";class S{constructor({displayRecurrence:e,closingRecurrence:t,validationRecurrence:i},n){this.displayRecurrence=parseFloat(e),this.closingRecurrence=parseFloat(t),this.validationRecurrence=parseFloat(i),this.onSetCallback=n,this.widgetName=l(),this.uniqueId=h(),this.recurrenceKey=`${this.widgetName}_${this.uniqueId}`,this.isListeningStorageEvent=this.listenStorageEvent(),this.pendingRecurrence=!1,this.pendingRecurrenceValue={}}onStorage({key:e}){const t=localStorage.getItem(C),i=sessionStorage.getItem($);"ABTastyData"===e&&!t&&i&&localStorage.setItem(C,i)}listenStorageEvent(){return this.isListeningStorageEvent||window.addEventListener("storage",this.onStorage.bind(this)),!0}getGivenRecurrenceStorageParsed(e){try{const t=e.getItem($);return JSON.parse(t)}catch(t){return e.removeItem($),!1}}getSessionRecurrenceStorageParsed(){return this.getGivenRecurrenceStorageParsed(window.sessionStorage)}getLocalRecurrenceStorageParsed(){return this.getGivenRecurrenceStorageParsed(window.localStorage)}removeGivenStorage(e,t){const{[this.recurrenceKey]:i,...n}=t;return Object.entries(n).length?(e.setItem($,JSON.stringify(n)),n):(e.removeItem($),!1)}removeSessionRecurrenceStorage(){const e=this.getSessionRecurrenceStorageParsed();return!!e&&this.removeGivenStorage(window.sessionStorage,e)}removeLocalRecurrenceStorage(){const e=this.getLocalRecurrenceStorageParsed();return!!e&&this.removeGivenStorage(window.localStorage,e)}getSessionRecurrence(){const e=this.getSessionRecurrenceStorageParsed();return!!e&&e[this.recurrenceKey]}getLocalRecurrence(){const e=this.getLocalRecurrenceStorageParsed();return!!e&&e[this.recurrenceKey]}getCurrentRecurrence(){if(this.pendingRecurrence)return this.pendingRecurrenceValue;const e=this.getSessionRecurrence(),t=this.getLocalRecurrence();return e||t||{type:!1}}isOver(){const e=localStorage.getItem(C),t=!(!e||!e.includes(this.recurrenceKey))||this.getSessionRecurrence();e&&(sessionStorage.setItem($,e),localStorage.removeItem(C));const i=this.getLocalRecurrence(),n=(i?parseFloat(i.stamp):0)<(new Date).getTime();return n&&this.removeLocalRecurrenceStorage(),!this.pendingRecurrence&&n&&!this.getLocalRecurrence()&&!t}setRecurrence(e,t){0!==e&&(window.removeEventListener("storage",this.onStorage.bind(this)),this.isListeningStorageEvent=!1);const n=this.getTypeOfStorage(e);if(i()||!n&&"object"!=typeof n)return!1;const{storageString:o,storageMethod:r}=n,a=this.getStamp(e),c={type:t,stamp:a},{type:l}=this.getCurrentRecurrence(),d=async()=>{if(!s()){this.pendingRecurrence=!0,this.pendingRecurrenceValue=c;const e=new b({triggerEvent:"consent"});await e.isTriggered(),this.pendingRecurrence=!1,this.pendingRecurrenceValue={}}const e=this.getSessionRecurrence(),t=this.getLocalRecurrence();let i;"session"===o?e?i=this.removeSessionRecurrenceStorage():(this.removeLocalRecurrenceStorage(),i=this.getSessionRecurrenceStorageParsed()):"local"===o&&(t?i=this.removeLocalRecurrenceStorage():(this.removeSessionRecurrenceStorage(),i=this.getLocalRecurrenceStorageParsed()));const n=i?{[this.recurrenceKey]:c,...i}:{[this.recurrenceKey]:c};r.setItem($,JSON.stringify(n)),this.onSetCallback&&"function"==typeof this.onSetCallback&&this.onSetCallback()};if(!r)return!1;if(l&&t!==T)if(t===f&&l!==T)d();else{if("display"!==t||l===T||l===f)return!1;d()}else d();return a}setDisplayRecurrence(){this.setRecurrence(this.displayRecurrence,"display")}setClosingRecurrence(){this.setRecurrence(this.closingRecurrence,"closing")}setValidationRecurrence(){this.setRecurrence(this.validationRecurrence,"validation")}getStamp(e){return(new Date).getTime()+864e5*e}getTypeOfStorage(e){return!(isNaN(e)||e<0||0!==e&&!e)&&(e>0?{storageString:"local",storageMethod:window.localStorage}:0===e&&{storageString:"session",storageMethod:window.sessionStorage})}}class A{constructor(e,t,i){this.recurrence=e,this.isWidgetApplied=t,this.callback=i,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(e){const t=n(),{type:i}=this.recurrence?this.recurrence.getCurrentRecurrence():{type:!1};let s;const c=this.isWidgetApplied(),l=(()=>{const t=this.recurrenceIsDone();return e&&"display"===i||t})();return!c&&t&&l?s=r:(!c||t&&l)&&(c||t)?c&&t&&l&&(s=a):s=o,"string"==typeof s&&(this.clearWatcher(),this.callback(s,e),this.watch()),this}eventHandler(){let e=n();return[250,500].forEach(t=>{setTimeout(()=>{const i=n();return 500===t&&i===e?this:(e=i,this.decisionHandler(!1))},t)}),this}observerHandler(e){return e.some(e=>["removedNodes","addedNodes"].some(t=>e[t]&&e[t].length))?this.decisionHandler(!0):this}watch(){if(e())return this;this.clearWatcher(),document.addEventListener(...this.eventListenerParams);const t=()=>{const e=[document.body,{childList:!0,subtree:!0}];this.observer.observe(...e)};return document.body?t():(()=>{const e=m("body",()=>{t(),this.elementsWaiters=this.elementsWaiters.filter(t=>t!==e)});this.elementsWaiters.push(e)})(),this}clearWatcher(){return document.removeEventListener(...this.eventListenerParams),this.elementsWaiters.length&&(this.elementsWaiters.forEach(e=>e.clear()),this.elementsWaiters=[]),this.observer.disconnect(),this}}const E=/.+\/([^.]+)\.(otf|ttf)$/,_=["triggerSocialProofMinPurchases","triggerSocialProofMinPageViews"],x=["top: 0;","top: 50%;","bottom: 0;"],P=["left: 0;","left: 50%;","right: 0;"],I=e=>1===e?"-50%":0,k=()=>{if(Array.isArray(DATA.popinPosition)){const{popinPosition:[{x:e,y:t}]}=DATA,i=`translate(${I(t)}, ${I(e)});`;return`${x[e]}${P[t]}transform: ${i}`}return"left: 50%;top: 50%;transform: translate(-50%, -50%);"},L=()=>"autoWidth"in DATA&&!0===DATA.autoWidth,N=()=>{if(L())return"width: auto;height: auto;";const{popinPercentWidth:e,popinPixelsWidth:t,widthUnit:i,autoHeight:n,popinPercentHeight:s,popinPixelsHeight:o,heightUnit:r}=DATA;return`width: ${"px"===i?t:e}${i};height: ${n?"auto":`${"px"===r?o:s}${r}`};`};class R extends class{constructor(){this.children=void 0,this.uniqueId=h(),this.widgetName=l(),this.prettyName=d(),this.recurrenceParams=(()=>{const{displayRecurrence:t,closingRecurrence:i,validationRecurrence:n}=DATA;if(e()||!t&&!i&&!n)return!1;const s={everytime:()=>-1,session:()=>0,once:()=>395,day:e=>DATA[`${e}_day`],week:e=>7*DATA[`${e}_week`],month:e=>30.5*DATA[`${e}_month`]},o={};return t&&(o.displayRecurrence=s[t]("displayRecurrence")),i&&(o.closingRecurrence=s[i]("closingRecurrence")),n&&(o.validationRecurrence=s[n]("validationRecurrence")),o})(),this.triggerParams=(()=>{let{triggerEvent:t}=DATA;const{triggerEventClick:i,triggerEventHover:n,triggerEventReengageDelay:s,socialProofContentType:o,triggerEventElementVisible:r,triggerEventDelay:a}=DATA;if(e()||!t&&!o)return!1;const c={click:()=>i,hover:()=>n,elementVisible:()=>r},l=Object.prototype.hasOwnProperty.call(c,t)?c[t]():"body",d="reengage"===t?s:a;return o&&(t=1===o?"socialProofPurchases":"socialProofPageViews"),{triggerEvent:t,triggerSelector:l,triggerDelay:d}})(),this.recurrence=!!this.recurrenceParams&&new S(this.recurrenceParams,this.clearGivenClearables.bind(this)),this.trigger=!!this.triggerParams&&new b(this.triggerParams),this.shouldUpdate=!!this.triggerParams&&_.includes(this.triggerParams.triggerEvent),this.pageWatcher=new A(this.recurrence,this.isWidgetApplied.bind(this),this.onPageChange.bind(this),this.shouldUpdate),this.hasOncePerPageTrigger=(()=>{const{isOncePerPageTrigger:e,triggerEvent:t}=DATA;return!t||!["click","hover","scrollUp","script"].includes(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(e=>document.removeEventListener(...e)),this.eventsListeners=[]),this.timeouts.length&&(this.timeouts.forEach(e=>clearTimeout(e)),this.timeouts=[]),this.intervals.length&&(this.intervals.forEach(e=>clearInterval(e)),this.intervals=[]),this.observers.length&&(this.observers.forEach(e=>e.disconnect()),this.observers=[]),this.promises.length&&(this.promises.forEach(e=>e.resolve(!1)),this.promises=[]),this.elementsWaiters.length&&(this.elementsWaiters.forEach(e=>e.clear()),this.elementsWaiters=[])}isWidgetApplied(){return this.domElement&&this.domElement.isConnected}removeOldDomElement(){const e=document.getElementById(this.widgetContainerId);return e&&e.remove(),this}async insert(){if(this.isWidgetApplied())return!1;const e=new Promise(e=>{const t=m("head",t=>{this.elementsWaiters=this.elementsWaiters.filter(({selector:e})=>"head"!==e),e(t.appendChild(this.styleElement))});this.elementsWaiters.push(t)}),t=new Promise(e=>{const{elementReferrer:t="body",referrerInsertType:i="beforeend"}="free"===DATA.layout?DATA:{},n=m(t,n=>{this.elementsWaiters=this.elementsWaiters.filter(e=>e.selector!==t),this.removeOldDomElement(),e(n.insertAdjacentElement(i,this.domElement))});this.elementsWaiters.push(n)});return Promise.all([t,e]).then(()=>this)}remove(){return this.pageWatcher.clearWatcher(),[this.domElement,this.styleElement].forEach(e=>e&&e.isConnected&&e.remove()),this.hasOncePerPageTrigger?this.pageWatcher.watch():e()||this.init().then(({response:e})=>e?this.show():this),this}show(){return e()||this.hasBeenShown&&this.hasOncePerPageTrigger||window.ABTastyEvent(`${this.prettyName} displayed`,null,TEST_ID),this.closedByUser=!1,setTimeout(()=>this.domElement.classList.remove(this.hideClassName),50),this.recurrence&&this.recurrence.setDisplayRecurrence(),this.hasBeenShown=!0,this.pageWatcher.watch(),this}hide(){return!e()&&this.hasBeenShown&&window.ABTastyEvent(`${this.prettyName} closed`,null,TEST_ID),this.closedByUser=!0,this.domElement.classList.add(this.hideClassName),this}async init(t){const i=e(),s=n(),o=this.trigger&&this.trigger.promises.length,r=!this.recurrence||this.recurrence.isOver();if(!i&&!s||o||!r)return!1;this.pageWatcher.watch();const a=i||!this.trigger||this.trigger&&await this.trigger.isTriggered();return!!a&&(await this.insert(),this.addCloseEvent(),i||t||this.hasBeenShown||void 0===this.children||"function"!=typeof this.children.refreshContent||this.children.refreshContent(a),{container:this,response:a})}onPageChange(e,t){const i=()=>this.init().then(({response:e})=>e&&this.show());t||(this.hasBeenShown=!1);const n=this.isWidgetApplied(),s={[o]:()=>{n?this.remove():(this.trigger&&this.trigger.clear(),this.pageWatcher.watch())},[r]:()=>{this.hasBeenShown?this.closedByUser?this.pageWatcher.watch():n||this.insert().then(e=>e.show()).catch(this.pageWatcher.watch):i()},[a]:i};"function"==typeof s[e]&&s[e]()}addCloseEvent(...t){const{closeButton:i,overlay:n,overlayClickable:s,layout:o,animationDuration:r=1e3}=DATA,a=[];if(void 0!==n&&!0!==n||!0!==s||"popin"!==o||a.push(`.${this.overlayClassName}`),void 0!==i&&i&&a.push(`.${this.closeButtonClassName}`),!a.length)return this;const c=this.domElement.querySelectorAll(a.join(", "));return c.length?(t.push(...c),t.forEach(t=>{e()&&(t.dataset.abtastyActionnable="true"),t.addEventListener("click",e=>{v(e),this.recurrence&&this.recurrence.setClosingRecurrence(),this.hide(),setTimeout(()=>this.remove(),1.05*r)},{once:!0,capture:!0})}),this):this}getDom(){const{closeButton:e,layout:t,overlay:i=!0}=DATA,n=document.createElement("div");return n.className=`${this.basicClassName} ${this.hideClassName}`,n.id=this.widgetContainerId,n.innerHTML=`\n\t\t\t${"popin"===t&&!0===i?`<div class="${this.overlayClassName}"></div>`:""}\n\t\t\t<div class="${this.contentClassName}">\n\t\t\t${e?`<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(e,t){if(!e||"inherit"===e)return;const i=document.createElement("style"),n=t.match(E)?t.match(E)[1]:"";i.innerHTML=`@font-face { font-family: '${e}_${n}'; src: url('${t}'); font-display: swap; }`,document.head.appendChild(i)}getStyleTag(t="",i=DATA){const{noStyles:n,layout:s}=i,{backgroundColor:o,isBackgroundImage:r,backgroundImage:a,backgroundSize:c,backgroundPosition:l,backgroundRepeat:d,borderColor:h,borderRadius:u,borderWidth:p,textColor:m,textAlign:g,fontName:v,fontStyle:y,fontSize:w,isTitle:b,titleTextAlign:f,titleTextColor:T,titleFontName:$,titleFontStyle:C,titleFontSize:S,overlay:A,overlayColor:_,dropShadow:x,dropShadowColor:P,dropShadowBlur:I,containerMargin:k,containerPadding:L,closeButton:N,closeButtonPosition:R,closeButtonSize:D,closeButtonBorderRadius:O,closeButtonBorderWidth:B,closeButtonBorderColor:V,closeButtonColor:W,closeButtonBackgroundColor:j,buttonsAlign:M,buttonsBorderWidth:q,buttonsBorderColor:H,buttonsBorderRadius:F,buttonsBackgroundColor:U,buttonsTextColor:z,buttonsFontName:Y,buttonsFontStyle:G,buttonsFontSize:K,secondLink:J,secondLinkBorderWidth:Q,secondLinkBorderColor:X,secondLinkBorderRadius:Z,secondLinkBackgroundColor:ee,secondLinkTextColor:te,secondLinkFontName:ie,secondLinkFontStyle:ne,secondLinkFontSize:se,animation:oe,animationDuration:re,animationBehaviour:ae,animationSlideDirection:ce}=n?{}:i,le=document.createElement("style");le.type="text/css",e()&&le.setAttribute("abtasty-script-added","true"),this.loadFont(v,y),this.loadFont($,C),this.loadFont(Y,G),this.loadFont(ie,ne);const de=`background: ${["string"==typeof o?o:"rgba(255, 255, 255, 1)",r&&"string"==typeof a&&a.length?`url(${a})`:"",r&&"string"==typeof l&&"100% 100%"!==c?l:"0 0",r&&"string"==typeof c?`/ ${c}`:"/ auto",r&&d&&!["cover","100% 100%"].includes(c)?"repeat":"no-repeat"].join(" ").trim()};`,he="number"==typeof p&&p>0,ue=`border: ${[he?`${p}px`:"unset",he?"solid":"",he&&"string"==typeof h&&h.length?h:""].join(" ").trim()};`,pe=void 0!==u?`border-radius: ${u}px;`:"",me=void 0!==m?`color: ${m}; fill: ${m}; -webkit-text-fill-color: ${m};`:"",ge=void 0!==g?`text-align: ${g};`:"",ve=v&&"inherit"!==v?`font-family:${v}_${y.match(E)?y.match(E)[1]:""};`:y||"",ye=w?`font-size: ${w}px;`:"",we=void 0!==x&&x?`box-shadow: 0 5px ${I}px 0 ${P};`:"",be=k instanceof Array&&1===k.length&&k[0],fe=be?`margin: ${be.top}px ${be.right}px ${be.bottom}px ${be.left}px;`:"",Te=be?`margin: calc(${be.top}px * 0.5) calc(${be.right}px * 0.5) calc(${be.bottom}px * 0.5) calc(${be.left}px * 0.5);`:"",$e=L instanceof Array&&1===L.length&&L[0],Ce=$e?`padding: ${$e.top}px ${$e.right}px ${$e.bottom}px ${$e.left}px;`:"",Se=$e?`padding: calc(${$e.top}px * 0.5) calc(${$e.right}px * 0.5) calc(${$e.bottom}px * 0.5) calc(${$e.left}px * 0.5);`:"",Ae=void 0!==q&&q?`border-width: ${q}px; border-style: solid;`:"",Ee=[H,q].every(e=>void 0!==e)&&q?`border-color: ${H};`:"",_e=void 0!==F?`border-radius: ${F}px;`:"",xe=void 0!==U?`background-color: ${U};`:"",Pe=void 0!==z?`color: ${z}; fill: ${z}; -webkit-text-fill-color: ${z};`:"",Ie=Y&&"inherit"!==Y?`font-family:${Y}_${G.match(E)?G.match(E)[1]:""};`:G||"",ke=K?`font-size: ${K}px;`:"",Le=void 0!==Q&&Q?`border-width: ${Q}px; border-style: solid;`:"",Ne=[X,Q].every(e=>void 0!==e)&&Q?`border-color: ${X};`:"",Re=void 0!==Z?`border-radius: ${Z}px;`:"",De=void 0!==ee?`background-color: ${ee};`:"",Oe=void 0!==te?`color: ${te}; fill: ${te}; -webkit-text-fill-color: ${te};`:"",Be=ie&&"inherit"!==ie?`font-family:${ie}_${ne.match(E)?ne.match(E)[1]:""};`:ne||"",Ve=se?`font-size: ${se}px;`:"",We="popin"!==s||void 0!==A&&!0!==A?"":[`#${this.widgetContainerId} .${this.overlayClassName} {`,`background-color: ${void 0!==_?_:"rgba(0, 0, 0, 0.6)"};`,"}"].join(""),je="number"==typeof D?D:16,Me=je/2,qe=n||void 0!==N&&N?[`#${this.widgetContainerId} .${this.contentClassName} .${this.closeButtonClassName} {`,"position: absolute;",("out"===R?`bottom: calc(100% + ${Me}px)`:`top: ${Me}px`)+";",`right: ${Me}px;`,"width: auto;","height: auto;","background: none;","border: none;","cursor: pointer;","outline: none;","padding: 0;","margin: 0;","line-height: 0;","z-index: 9;","number"==typeof O?`border-radius: ${O}px;`:"","number"==typeof B&&B>0?`border: ${B}px solid ${void 0!==V?V:"rgba(57, 57, 57, 1)"};`:"","string"==typeof j?`background-color: ${j};`:"","}",`#${this.widgetContainerId} .${this.contentClassName} .${this.closeButtonClassName} svg {`,"pointer-events: none;",`width: ${je}px;`,`height: ${je}px;`,"string"==typeof W?`fill: ${W};`:"","}"].join(""):"",He=b&&"string"==typeof T?[`#${this.widgetContainerId} .${this.contentClassName} > * h1, `,`#${this.widgetContainerId} .${this.contentClassName} > * h2, `,`#${this.widgetContainerId} .${this.contentClassName} > * h3, `,`#${this.widgetContainerId} .${this.contentClassName} > * h4, `,`#${this.widgetContainerId} .${this.contentClassName} > * h5, `,`#${this.widgetContainerId} .${this.contentClassName} > * h6 {`,`color: ${T}; fill: ${T}; -webkit-text-fill-color: ${T};`,void 0!==f?`text-align: ${f};`:"",$&&"inherit"!==$?`font-family:${$}_${C.match(E)?C.match(E)[1]:""};`:C||"",S?`font-size: ${S}px;`:"","}"].join(""):"";let Fe="";if("string"==typeof oe){const t=(re/1e3).toFixed(2),i=["top","bottom"].includes(ce),n=Number(i),s=[(["top","left"].includes(ce)?"-":"")+"100vmax",this.translateValues?this.translateValues[n]:"0"];i&&s.reverse(),Fe={none:[],fade:[`#${this.widgetContainerId} {`,`transition: opacity ${t}s ${ae};`,"}"],slide:[`.${this.hideClassName} .${this.overlayClassName} {`,"opacity: 0 !important;","}",`#${this.widgetContainerId} .${this.overlayClassName} {`,`transition: opacity ${t}s ${ae};`,"}",`.${this.hideClassName} .${this.contentClassName} {`,`transform: translate(${s.join(", ")}) !important;`,"}",`#${this.widgetContainerId} .${this.contentClassName} {`,`transition: transform ${t}s ${ae};`,"}"]}[e()&&!ABTASTY_S.WIDGETS.animationChanged?"none":oe].join("")}const Ue=[`#${this.widgetContainerId} .${this.contentClassName} > * a:nth-child(2), `,`#${this.widgetContainerId} .${this.contentClassName} > * button:nth-child(2) {`,`margin-${"fill"===M?"top":"left"}: 8px;`,Le,Ne,Re,De,Oe,Be,Ve,"}",`#${this.widgetContainerId} .${this.contentClassName} > * a:nth-child(2) *, `,`#${this.widgetContainerId} .${this.contentClassName} > * button:nth-child(2) * {`,Oe,Be,Ve,"}"];return le.textContent=[`.${this.hideClassName} {`,"opacity: 0 !important;","pointer-events: none;","}",`#${this.widgetContainerId} {`,"opacity: 1;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,de,pe,ue,me,ge,we,fe,ve,ye,"}",`#${this.widgetContainerId} .${this.contentClassName} p {`,me,ge,ve,ye,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,"display: block;","line-height: 1;","text-indent: unset;",Ce,ve,ye,"}",`#${this.widgetContainerId} .${this.contentClassName} > * a, `,`#${this.widgetContainerId} .${this.contentClassName} > * button {`,"box-sizing: border-box;","display: inline-block;",Ae,Ee,_e,xe,Pe,Ie,ke,"}",`#${this.widgetContainerId} .${this.contentClassName} > * a *, `,`#${this.widgetContainerId} .${this.contentClassName} > * button * {`,Pe,Ie,ke,"}",...J?Ue:[],"@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,Te,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,Se,"}","}",We,qe,He,Fe,`${t}`].join(""),le}}{constructor(){super(),this.translateValues=Object.values(DATA.popinPosition[0]).map(e=>I(e)),this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){const{zindex:e,zindexCustom:t,overlay:i}=DATA;return[`#${this.widgetContainerId} {`,"position: fixed;","top: 0;","left: 0;","width: 100%;","height: 100%;",`z-index: ${"custom"===e?t:e};`,"background: none;","pointer-events: "+(!1===i?"none":"all"),"}",`#${this.widgetContainerId} .${this.overlayClassName} {`,"position: absolute;","z-index: -1;","top: 0;","left: 0;","width: 100%;","height: 100%;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: absolute;",k(),N(),"pointer-events: all","}",`${L()?"":[`#${this.widgetContainerId} .${this.contentClassName} > div {`,"height: 100%;","overflow: auto;","box-sizing: border-box;","}"].join("")}`,`${L()?"":["@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,"max-width: 94vw;","}","}"].join("")}`].join("")}}e()&&Number(ABTASTY_S.USER.additionalInformation.account_iframe_less_mode);const D=["mp4","webm","ogg"],O=()=>D.some(e=>DATA.video.includes(e)),B=e=>e.replace("/","__").replace("?","__").replace("#","__").replace("&","__"),V=e=>(256|e).toString(16).slice(1);function W(e){const t=e.replace(/\s/g,"").match(/^rgba?\((\d+),(\d+),(\d+),?([^,\s)]+)?/i);return"".concat(V(t[1])).concat(V(t[2])).concat(V(t[3]))}const j="C71YkqN0pEA",M=["youtube.com","youtu.be"],q=()=>M.some(e=>DATA.video.includes(e)||""===DATA.video),H=(e,t)=>{if(window.YT&&"function"==typeof YT.Player){const i=(()=>{const{video:e}=DATA;if(""===e)return j;const t=["youtube.com/embed/","youtube.com/watch?v=","youtu.be/"].filter(t=>e.includes(t))[0],i=t?B(e.split(t)[1]):"";return!!i.length&&i.split("__")[0]})(),n=(()=>{const{youtubeCCLoadPolicy:e,youtubeColor:t,youtubeControls:i,youtubeDisableKeyboard:n,youtubeEndTime:s,youtubeFullScreen:o,youtubeStartTime:r}=DATA,a={origin:location.origin,rel:0,color:t,controls:i?1:0,disablekb:n?0:1,fs:o?1:0};return e&&(a.cc_load_policy=1),s&&(a.end=s),r&&(a.start=r),a})(),s=(()=>{const{youtubeAutoPlay:e,youtubeLoop:t,youtubeMuted:i,youtubeStartTime:n}=DATA,s={};return(e||i)&&(s.onReady=t=>{i&&t.target.mute(),e&&t.target.playVideo()}),t&&(s.onStateChange=e=>{0===e.data&&(n&&e.target.seekTo(n),e.target.playVideo())}),s})(),o=new YT.Player("popin_video_iframe_".concat(e),{videoId:i,playerVars:n,events:s});return t(o)}return setTimeout(()=>H(e,t),100)};function F(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),i.push.apply(i,n)}return i}function U(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}const z=()=>DATA.video.includes("vimeo.com"),Y=(e,t)=>{if(window.Vimeo&&"function"==typeof Vimeo.Player){const{vimeoStartTime:i}=DATA,n=(()=>{const{video:e,vimeoAutoPlay:t,vimeoColor:i,vimeoLoop:n,vimeoMuted:s,vimeoInfos:o}=DATA;return{url:e,autoplay:t,byline:o,color:W(i),loop:n,muted:s,portrait:o,title:o}})(),s=new Vimeo.Player("popin_video_iframe_".concat(e),function(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?F(Object(i),!0).forEach(function(t){U(e,t,i[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):F(Object(i)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})}return e}({},n));return i&&s.setCurrentTime(i),t(s)}return setTimeout(()=>Y(e,t),100)},G=["dailymotion.com","dai.ly"],K=()=>G.some(e=>DATA.video.includes(e)),J=()=>{const{video:e}=DATA,t=["/video/","dai.ly/"].filter(t=>e.includes(t))[0],i=t?B(e.split(t)[1]):"";return!!i.length&&i.split("__")[0]},Q=(e,t,i,n)=>{if(window.DM&&"function"==typeof DM.player){const s=(()=>{const{dailymotionAutoPlay:e,dailymotionMuted:t,dailymotionColor:i,dailymotionLogo:n}=DATA;return{autoplay:e,mute:t,logo:n,"ui-highlight":W(i)}})(),o=DM.player(t.querySelector("#popin_video_iframe_".concat(e)),{video:J(),params:s});return i(o),n(o)}return setTimeout(()=>Q(e,t,n,i),100)},X=()=>DATA.video.includes("tiktok.com"),Z=()=>{return e="".concat("https://www.tiktok.com/oembed?url=").concat(DATA.video),new Promise((t,i)=>{const n=new XMLHttpRequest;n.open("GET",e,!0),n.onload=function(){this.status>=200&&this.status<300?t(n.response):i({status:this.status,statusText:n.statusText})},n.onerror=function(){i({status:this.status,statusText:n.statusText})},n.send()});var e},ee=()=>{const{linkType:e,buttonText:t}=DATA;return!!([e,t].every(e=>"string"==typeof e)&&e.includes("button")&&t.length)};class te{constructor(e){let{parentContainer:t}=e;this.parentContainer=t,this.className="popinvideo_container_".concat(t.uniqueId),this.videoSource=DATA.video||"".concat("https://www.youtube.com/embed/").concat(j),this.contentElement=this.getContentElement(),this.styleElement=this.getStyleElement()}remove(){const{animationDuration:e=1e3}=DATA;setTimeout(()=>this.parentContainer.remove(),1.05*e)}addCloseEvent(t){t&&t.addEventListener("click",t=>{v(t),e()||this.parentContainer.recurrence.setClosingRecurrence(),this.parentContainer.hide(),this.remove()},{capture:!0,passive:!1})}addRedirectionEvent(t){!e()&&t&&t.addEventListener("click",()=>{const{autoHide:t,timeHide:i}=DATA;t&&setTimeout(()=>{this.parentContainer.hide(),this.remove()},1e3*i),e()||this.parentContainer.recurrence.setValidationRecurrence()},{capture:!0,passive:!0})}insertButtonsInContainer(e){const t=this.getButtons(),i=document.createElement("div");i.className="buttons_container",t.forEach(e=>i.appendChild(e)),e.appendChild(i)}getButtons(){const e=(e,t,i,n)=>{const s=document.createElement("a");return s.className="popin_link",s.innerHTML="<span>".concat(e,"</span>"),s.href="button"===t?i:"#","button"===t?(s.target=n?"_blank":"_self",this.addRedirectionEvent(s)):(s.dataset.abtastyActionnable="true",this.addCloseEvent(s)),s},{linkType:t,buttonText:i,redirectionUrl:n,openInNewTab:s,secondLink:o,secondLinkText:r,secondLinkType:a,secondLinkURL:c,secondLinkOpenInNewTab:l}=DATA,d=[e(i,t,n,s)];if(o){const t=e(r,a,c,l);d.push(t)}return d}getVideoContainer(){const e="popin_video_iframe",t="".concat(e,"_").concat(this.parentContainer.uniqueId),i=document.createElement("div");if(i.className="popin_video_container",O()){const{htmlPlayerAutoPlay:e,htmlPlayerMuted:t,htmlPlayerLoop:n,htmlPlayerControls:s}=DATA,o=D.filter(e=>this.videoSource.includes(".".concat(e)))[0],r=document.createElement("video");r.innerHTML='<source src="'.concat(this.videoSource,'" type="video/').concat(o,'">'),e&&(r.autoplay=!0),t&&(r.muted=!0),n&&(r.loop=!0),s&&(r.controls=!0),i.appendChild(r)}else{DATA.video.includes("facebook.com")&&(this.videoSource=(()=>{const{video:e}=DATA;return e.includes("plugins/video.php")?e:"https://www.facebook.com/plugins/video.php?href=".concat(e,"&show_text=0")})());const n='<div id="'.concat(t,'" class="').concat(e,'"></div>'),s='<iframe id="'.concat(t,'" class="').concat(e,'" src="').concat(this.videoSource,'"></iframe>');i.innerHTML=[q(),z(),K(),X()].some(e=>e)?n:s}return i}setVideoOnlyContent(e,t){const i=this.getVideoContainer();return e.appendChild(i),e.classList.add(t),ee()&&this.insertButtonsInContainer(e),e}setVideoAndTextContent(e,t){const{isTitle:i,title:n,textContent:s}=DATA,o=this.getVideoContainer(),r=document.createElement("div");return r.className="popin_text_container",r.innerHTML="".concat(i?'<h2 class="popin_video_title">'.concat(n,"</h2>"):"",'<p class="popin_video_text">').concat(s,"</p>"),e.classList.add(t),["leftVideo","topVideo"].some(e=>e===t)&&e.appendChild(o),e.appendChild(r),["rightVideo","bottomVideo"].some(e=>e===t)&&e.appendChild(o),ee()&&this.insertButtonsInContainer(r),e}insertIn(e,t){return document.head.insertAdjacentElement("beforeend",this.styleElement),e.insertAdjacentElement(t,this.contentElement),e}getContentElement(){const{contentLayout:e}=DATA,t=document.createElement("div");return t.className=this.className,{videoOnly:()=>this.setVideoOnlyContent(t,"onlyVideo"),left:()=>this.setVideoAndTextContent(t,"leftVideo"),right:()=>this.setVideoAndTextContent(t,"rightVideo"),top:()=>this.setVideoAndTextContent(t,"topVideo"),bottom:()=>this.setVideoAndTextContent(t,"bottomVideo")}[e](),t}getStyleElement(){const t=document.createElement("style");t.type="text/css",e()&&t.setAttribute("abtasty-script-added","true");const{textVideoRatio:i,borderRadius:n,borderWidth:s,containerPadding:o,contentLayout:r,linkType:a,buttonsAlign:c}=DATA,l="#".concat(this.parentContainer.widgetContainerId," .").concat(this.parentContainer.contentClassName),d=o[0],h=parseInt(n-s,10),u=h-d.top>0?h-d.top:0,p=h-d.bottom>0?h-d.bottom:0,m=void 0!==c&&"fill"!==c?"text-align: ".concat(c,";"):"",g=["".concat(l," .onlyVideo .popin_video_container {"),"border-radius: ".concat(u,"px ").concat(u,"px ").concat(p,"px ").concat(p,"px;"),"}"].join(""),v=["".concat(l," .leftVideo .popin_video_container {"),"width: calc(".concat(i,"% - 2.5%);"),"}","".concat(l," .leftVideo .popin_text_container {"),"width: calc(100% - ".concat(i,"% - 2.5%);"),"position: relative;","margin: 0 2.5%;","}","".concat(l," .leftVideo .popin_video_container {"),"border-radius: ".concat(u,"px 0 0 ").concat(p,"px;"),"}"].join(""),y=["".concat(l," .rightVideo .popin_video_container {"),"width: calc(".concat(i,"% - 2.5%);"),"}","".concat(l," .rightVideo .popin_text_container {"),"width: calc(100% - ".concat(i,"% - 2.5%);"),"position: relative;","margin: 0 2.5%;","}","".concat(l," .rightVideo .popin_video_container {"),"border-radius: 0 ".concat(u,"px ").concat(p,"px 0;"),"}"].join(""),w=["".concat(l," .topVideo .popin_video_container {"),"border-radius: ".concat(u,"px ").concat(u,"px 0 0;"),"margin-bottom: 15px","}"].join(""),b=["".concat(l," .bottomVideo .popin_video_container {"),"border-radius: 0 0 ".concat(p,"px ").concat(p,"px;"),"margin-top: 15px;","}"].join(""),f=["".concat(l," .buttons_container {"),"display: inline-block;","width: 100%;",m,"}","".concat(l," .popin_link {"),"display: inline-block;","margin: 25px 0 0 0;","padding: 10px 22px;","max-width: 100%;","width: ".concat("fill"===c?"100%":"auto",";"),"text-align: center;","}"].join(""),T=["".concat(l," .popin_video_container {"),"line-height: 0;","overflow: hidden;","width: 100%;","max-width: 100%;","}","".concat(l," .popin_video_title {"),"margin: 0 0 25px 0;","display: inline-block;","width: 100%;","}","".concat(l," .popin_video_container video,"),"".concat(l," .popin_video_container .popin_video_iframe {"),"display: inline-block;","width: 100%;","height: 100%;","}","".concat(l," .popin_video_container .popin_video_iframe iframe {"),"display: inline-block;","width: 100%;","}","".concat(l," .popin_text_container {"),"line-height: 1;","white-space: pre-line;","}","".concat(l," .popin_text_container p {"),"margin: 0;","}","".concat(l," .popin_video_container,"),"".concat(l," .popin_text_container {"),"display: inline-block;","vertical-align: middle;","}"];return(0,{videoOnly:()=>T.push(g),top:()=>T.push(w),bottom:()=>T.push(b),left:()=>T.push(v),right:()=>T.push(y)}[r])(),a&&T.push(f),t.textContent=T.join(""),t}}function ie(e){const t=e.querySelector(".popin_video_iframe"),i=parseInt(t.clientWidth/16*9,10)+1;t.style.height="".concat(i,"px")}!function(){const e=h(),t=q(),i=z(),n=K(),s=X();t&&(e=>{if(window.YT)return!1;const t=document.createElement("script");t.src="https://www.youtube.com/iframe_api",t.id="video_popin_ytapi_".concat(e),document.head.appendChild(t)})(e),i&&(e=>{if(window.Vimeo)return!1;const t=document.createElement("script");t.src="https://player.vimeo.com/api/player.js",t.id="video_popin_vimeoapi_".concat(e),document.head.appendChild(t)})(e),n&&(e=>{if(window.DM)return!1;const t=document.createElement("script");t.src="https://api.dmcdn.net/all.js",t.id="video_popin_dailymotionapi_".concat(e),document.head.appendChild(t)})(e);const o=new R,r=new te({parentContainer:o}),a=r.contentElement.querySelector(".popin_video_container");s&&Z().then(t=>{const i=JSON.parse(t),n=a.querySelector("#popin_video_iframe_".concat(e));n.innerHTML=i.html,r.player=n,a.appendChild(r.player),(e=>{window.tiktokEmbed&&(window.tiktokEmbed=void 0);const t=document.createElement("script");t.src="https://www.tiktok.com/embed.js",t.id="video_popin_tiktokapi_".concat(e),t.async=!0,document.head.appendChild(t)})(e)});const c=o.domElement.querySelector(".".concat(o.contentClassName));o.children=r,r.insertIn(c,"beforeend"),o.init().then(c=>{let{response:l}=c;if(l){const c=e=>{r.player=e,i||s||O()||(ie(r.contentElement),window.addEventListener("resize",()=>ie(r.contentElement),{capture:!0,passive:!0}))};t&&H(e,c),i&&Y(e,c),n&&Q(e,r.contentElement,e=>{a.innerHTML="",a.appendChild(e)},c),r.player||c(a),o.show()}})}()}();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@abtasty/popin-video",
3
3
  "description": "A simple way to create a modal with an video in it",
4
- "version": "1.4.2",
4
+ "version": "1.4.3",
5
5
  "main": "dist/main.js",
6
6
  "form": "dist/form.js",
7
7
  "files": [