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