@abtasty/drawer 0.0.31 → 0.0.32-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/main.js +1 -1
  2. package/package.json +3 -2
package/dist/main.js CHANGED
@@ -1 +1 @@
1
- !function(){"use strict";const e=()=>Object.prototype.hasOwnProperty.call(top,"ABTastyEditor"),t=()=>{const e=!!document.getElementById("ABTastyPreviewBar"),t=location.href.includes("ab_project=preview");return e||t},n=e=>new Function(`try {\n\t\t${e}\n\t} catch (error) {\n\t\treturn null;\n\t}`)(),i=()=>encodeURIComponent(DATA.spNoTrim?window.location.href.replace(window.location.origin,""):`${window.location.pathname}`),s=()=>!e()&&(t()||!!window.ABTasty.getTestsOnPage()[TEST_ID]),r=()=>window.ABTasty&&!0===window.ABTasty.consentReady,o=()=>{const{type:e}=DATA;return`${PACKAGE.replace("@abtasty/","")}${e?`_${e}`:""}`},a=()=>{const e=o();return`${e.charAt(0).toUpperCase()}${e.slice(1)}`.split("-").join(" ")},c=()=>`${PLUGIN_ID.split("-")[0]}_${TEST_ID}`,l=n=>{const i=(()=>{if(e()||t())return!1;const n=ABTasty.getTestsOnPage()[TEST_ID];return!!n&&Object.keys(n.targetings.qaParameters).length>0})(),s=window.document.cookie.includes("abTastyDebug=")||!0===window.abTastyDebug;if(i||s){const e=a();window.console.log(`%c${e} - ${i?"QA":"Debug"} Mode for campaign ${TEST_ID} %c ${n}`,"background-color: #D6FF01; color: #3100be; padding: 3px 0 3px 10px; border-radius: 5px 0 0 5px; font-weight: bold;","background-color: #3100be; color: white; padding: 3px 10px 3px 0; border-radius: 0 5px 5px 0;")}},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},d=(e,t)=>{const n=t?[]:null;if("string"!=typeof e||!e.trim().length)return n;const[i,s,r]=e.split("[]").map(e=>e.trim()),o=Boolean(r)?r:e,a=s?document.querySelector(i)?.[s]:document;return a?t?[...a.querySelectorAll(o)]:a.querySelector(o):n},u=e=>d(e,!1),g=e=>d(e,!0),m=(e,t)=>{const n={childList:!0,subtree:!0,attributes:!0},i=()=>s.disconnect(),s=new MutationObserver(()=>{const n=u(t);return n&&!i()&&e(n)});return{clear:i,observe:e=>{const t=document.querySelector("body")||document.documentElement,i=e??t;s.observe(i,n)}}},p=()=>{},v=(t,n)=>{const i=u(t),s={selector:t,clear:p,observe:p};if(i)return setTimeout(()=>n(i),0),s;if(e())return setTimeout(()=>v(t,n),1e3),s;if(t.includes("[]"))return((e,t)=>{const[n,i]=t.split("[]").map(e=>e.trim()),s=u(n),r=s?.[i],{clear:o,observe:a}=m(e,t),c=()=>{const n=u(t);return n&&!l()&&e(n)},l=()=>{o(),s?.removeEventListener("load",c)},h=()=>{a(r),"iframe"===s?.localName&&s.addEventListener("load",c)};return h(),{selector:t,clear:l,observe:h}})(n,t);const{clear:r,observe:o}=m(n,t);return o(),{selector:t,clear:r,observe:o}};function y(e,t){const n=e.parentElement||e.getRootNode().host;return t(e)||!n?e:y(n,t)}const f=t=>{e()||(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation())},b=(e,t)=>[...g(t)].some(n=>{const[i,,s]=t.split("[]"),r=s??i;return n===e||!!e.closest(r)});let w=!1;class T{constructor(){this.targets=[],this.existingTargets=[],this.inViewportTargets=[],this.visibilityObserver=null,this.mutationObserver=null,this.mouseOverEvent=null,this.scrollEvent=null,this.onTransitionEnd=null,this.onIframeLoad=null}transitionOverHandler(e){const t=[e,"transitionend",this.checkElements.bind(this),!0];return this.getEvents(...t)}intersectionHandler(e){e.forEach(e=>{e.isIntersecting?(this.existingTargets.forEach(t=>{t.element.isSameNode(e.target)&&(this.inViewportTargets.push(t),this.mouseOverEvent.start(),this.scrollEvent.start(),this.onTransitionEnd.start())}),this.checkElements()):this.inViewportTargets=this.inViewportTargets.filter(t=>!t.element.isSameNode(e.target)||(this.mouseOverEvent.clear(),this.scrollEvent.clear(),this.onTransitionEnd.clear(),!1))})}startVisibilityObserver(e){const t={root:e,rootMargin:"0px",threshold:.01};return this.visibilityObserver??=new IntersectionObserver(this.intersectionHandler.bind(this),t),this.visibilityObserver}startMutationObserver(e){return this.mutationObserver??=new MutationObserver(this.checkElements.bind(this)),this.mutationObserver.observe(e,{attributes:!0,childList:!0,subtree:!0}),this.mutationObserver}onMouseOver({target:e,path:t}){const n=this.inViewportTargets.find(({element:n,selector:i})=>{if(n.isSameNode(e))return!0;const[s,,r]=i.split("[]"),o=r??s,a=[...e.querySelectorAll(o)];if(a.length&&a.includes(n))return!0;if(t.includes(n))return!0;if(!e.parentElement?.children?.length)return;const c=[...e.parentElement.children],l=c.findIndex(t=>t.isSameNode(e)),h=c.filter((e,t)=>t>l);if(h.length){if(h.includes(n))return!0;if(h.some(e=>[...e.querySelectorAll(o)].includes(n)))return!0}return!1});if(n&&this.isElementVisible(n.element)){const{selector:e,element:t,uniqueId:i}=n,s=this.targets.find(t=>t.selector===e&&t.uniqueId===i);s&&s.resolve(t),this.clear(e,i)}}getEvents(e,...t){return{start:()=>e?.addEventListener(...t),clear:()=>e?.removeEventListener(...t)}}mouseOverHandler(e){const t=[e,"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0?"touchmove":"mouseover",e=>{const t=e.composedPath(),{target:n}=e;setTimeout(()=>this.onMouseOver({target:n,path:t}),50)},!0];return this.getEvents(...t)}scrollEventHandler(e){const t=[e,"scroll",(n=this.checkElements.bind(this),()=>{w||(w=!0,setTimeout(()=>{n(),w=!1},100))}),{passive:!0}];var n;return this.getEvents(...t)}isElementVisible(e){return this.isElementOpaque(e)&&this.isElementTopmost(e)}isElementOpaque(e){return"HTML"===y(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,s=0;for(;!i&&s<n.length;){const t=e.getRootNode()?.elementFromPoint(...n[s]);i=e===t||t?.contains(e)||e.contains(t),s+=1}return i}checkElements(){this.targets.forEach(({selector:e,uniqueId:t})=>{const n=u(e),[i,,s]=e.split("[]"),r=s??i;n&&!this.existingTargets.find(e=>e.element.matches(r)&&e.uniqueId===t)&&(this.existingTargets.push({element:n,selector:e,uniqueId:t}),this.visibilityObserver.observe(n))}),this.existingTargets=this.existingTargets.filter(({selector:e,element:t})=>!(!u(e)||!t.isConnected)||(t&&this.visibilityObserver.unobserve(t),!1)),this.inViewportTargets=this.inViewportTargets.filter(({selector:e,element:t,uniqueId:n})=>{const[i,,s]=e.split("[]"),r=s??i;if(t.matches(r)&&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})}onLoadIframe(e){const t=[e.defaultView.frameElement,"load",()=>this.watch(selector,resolve,uniqueId).bind(this),{passive:!0}];return this.getEvents(...t)}watch(e,t,n){this.targets.push({selector:e,resolve:t,uniqueId:n});const{clear:i}=v(e,e=>{i();const t=e.getRootNode({composed:!0}),n="body"in t?t.body:document;this.mouseOverEvent=this.mouseOverHandler(t),this.scrollEvent=this.scrollEventHandler(t),this.onTransitionEnd=this.transitionOverHandler(t),t.defaultView?.frameElement&&(this.onIframeLoad=this.onLoadIframe(t),this.onIframeLoad.start()),this.startVisibilityObserver(t),this.startMutationObserver(n),this.checkElements()})}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=u(e);n&&this.visibilityObserver?.unobserve(n),0===this.targets.length&&(this.mutationObserver?.disconnect(),this.onIframeLoad?.clear()),0===this.inViewportTargets.length&&(this.mouseOverEvent?.clear(),this.scrollEvent?.clear(),this.onTransitionEnd?.clear())}}const E="remove",C="rebuild",S="update",x="ABTastyData";class k{constructor({triggerEvent:e,triggerSelector:t,triggerDelay:n,triggerTarget:i}){this.event=e,this.selector=Boolean(t)?t:"body",this.target="string"==typeof i?u(t):i,this.delay=1e3*n,this.triggerElements=[],this.eventsListeners=[],this.timeouts=[],this.intervals=[],this.promises=[],this.visibilityObservers=[],this.socialProofStore={},this.elementWaiters=[]}async onElementVisible({promise:e,resolve:t}){const n=h(`${this.event}DomReady`);this.promises.push(n);const{clear:i}=v(this.selector,()=>{const e=new T;this.visibilityObservers.push(e),e.watch(this.selector,t,c())});return this.elementWaiters.push(i),e}onPageLoad({promise:e,resolve:t}){const n=()=>"complete"===document.readyState;if(!n()){const i=["readystatechange",()=>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=({isTrusted:e,target:n})=>{if(e)return(n.isEqualNode(this.target)||b(n,this.selector))&&t(!0)},{clear:i}=v(this.selector,e=>{i();const t=document.createElement("style");t.id=`Click_${c()}`;const[s,,r]=this.selector.split("[]"),o=r??s;t.innerHTML=`${o} {\n\t\t\t\tcursor: pointer !important;\n\t\t\t\tpointer-events: all !important;\n\t\t\t}`;const a=e.getRootNode();("head"in a?a.head:a).appendChild(t),this.triggerElements.push(t);const l=["click",n,{passive:!0,capture:!0}];this.eventsListeners.push([a,...l]),a.addEventListener(...l)});return this.elementWaiters.push(i),e}onHover({promise:e,resolve:t}){const n=({isTrusted:e,target:n})=>{if(e)return(this.target?n.isEqualNode(this.target):b(n,this.selector))&&t(!0)},{clear:i}=v(this.selector,e=>{const t=e.getRootNode(),i="body"in t?t.body:[...t.childNodes].find(t=>t.contains(e)),s=["mouseenter",n,{passive:!0,capture:!0}];this.eventsListeners.push([i,...s]),i.addEventListener(...s)});return this.elementWaiters.push(i),e}onExitIntent({promise:e,resolve:t}){const n=["mouseleave",({isTrusted:e,clientY:n})=>{e&&n<=0&&t(!0)},{passive:!0}],{clear:i}=v("html",e=>{i(),this.eventsListeners.push([e,...n]),e.addEventListener(...n)});return e}onReengage({promise:e,resolve:t}){const n=this.delay;let i=n;const s=[...document.querySelectorAll("*:empty")].map(e=>e.contentDocument||e.shadowRoot).filter(e=>e),r=[({isTrusted:e})=>{e&&(i=n)},{passive:!0}];["click","mousemove","scroll","keypress"].forEach(e=>{[document,...s].forEach(t=>{this.eventsListeners.push([t,e,...r]),t.addEventListener(e,...r)})});const o=setInterval(()=>{i<=0?t(!0):i-=100},100);return this.intervals.push(o),e}onCustomTrigger({promise:e,resolve:t}){const{triggerEventCustomScript:n,tagIsSafeEval:i}=DATA,s=i&&DATA_JS?.triggerEventCustomScript,r="function"==typeof s?()=>new Promise(e=>s(e)):new Function(`return new Promise(async resolve => {${n}})`);return r().then(e=>e&&t(!0)),e}onScrollUp({promise:e,resolve:t}){let n=0;const i=["scroll",({isTrusted:e})=>{e&&(window.scrollY<n?t(!0):n=window.scrollY)},{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 s=(()=>{let e;return window.ABTasty||window.ABTASTY_S?(window.ABTASTY_S?.USER?.accountIdentifier?.length?e=window.ABTASTY_S.USER.accountIdentifier:"function"==typeof window.ABTasty?.getAccountSettings?e=window.ABTasty.getAccountSettings().identifier:window.ABTasty?.accountSettings&&(e=window.ABTasty.accountSettings.identifier),e):e})(),{viewInterval:r,spNoTrim:o}=DATA;if(this.socialProofStore.hasOwnProperty(e))n(this.socialProofStore[e])?i(`${this.socialProofStore[e][r]}`):i(!1);else if(e&&s){const a=t=>(this.socialProofStore[e]=t,i(!!n(t)&&`${t[r]}`));fetch(`https://api-social-proof.abtasty.com/clients/${s}/metrics/${t}?key=${e}${o?"&noTrim=true":""}`).then(e=>e.ok&&e.json()).then(a).catch(()=>l("Failed to fetch datas from server."))}else i(!1)}getSocialProofDatas({promise:e,resolve:t},s,r=!1){const{productKey:o,keyType:a}=(()=>{const{socialProofContentType:e,productKeyProvider:t,pathToProductKey:s,customJSProductKey:r,productSKU:o,tagIsSafeEval:a}=DATA,{pathToProductKey:c,customJSProductKey:l}=a&&DATA_JS||{};if(2===e)return{productKey:i(),keyType:"url"};{let a=null,h="sku";switch(t){case"ABTastyProductKey":a=window.ABTastyProductKey;break;case"pathToProductKey":a="function"==typeof c?c():n(`return ${s};`);break;case"customJSProductKey":a="function"==typeof l?l():n(r);break;case"productSKU":a=o}return a||3!==e||(a=i(),h="url"),{productKey:a,keyType:h}}})(),{viewInterval:c,triggerSocialProofMinVisitors:h,triggerSocialProofMinPurchases:d,triggerSocialProofMinPageViews:u}=DATA,g={pv:u,i:d,"v-pv":h}[s];return[typeof c,typeof g].includes("undefined")&&t(!1),r&&!o&&(l("Not able to find ABTastyProductKey, impossible to call the API, read documentation for more informations:\n\t\t\t\thttps://support.abtasty.com/hc/en-us/articles/4710919241628-Widgets-List#h_84c04344-c655-4e5e-b9ab-d26a798ad9b0"),t(!1)),this.checkSocialProofConditions(o,"v-pv"===s&&"sku"===a?"v-i":s,e=>{const t=void 0!==e[c]&&e[c]>=g;return t||l(`Widget will not be shown, Social Proof API returned ${e[c]} while ${g} are required`),t},t),e}onConsent({promise:e,resolve:t}){if(!r()){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(x);const s=()=>JSON.parse(i)?.ActionTracking?.some(({name:e})=>e===n),r=["storage",({key:e,newValue:n})=>{e===x&&(i=n,s()&&t(!0))},{passive:!0,capture:!0}];return i&&s()?t(!0):(()=>{this.eventsListeners.push([window,...r]),window.addEventListener(...r)})(),e}onMinPagesViewed({promise:e,resolve:t}){const{triggerEventMinPagesViewed:n}=DATA;let i=localStorage.getItem(x);const s=()=>n<=(i?JSON.parse(i)?.VisitedPages?.length:0),r=["storage",({key:e,newValue:n})=>{e===x&&(i=n,s()&&t(!0))},{passive:!0,capture:!0}];return i&&s()?t(!0):(()=>{this.eventsListeners.push([window,...r]),window.addEventListener(...r)})(),e}onRageClick({promise:e,resolve:t}){const{triggerEventRageClickQuantity:n,triggerEventRageClickDelay:i}=DATA;let s=0,r=!1;const o=["click",({isTrusted:e})=>{if(e&&(s+=1,s>=n&&t(!0),!r)){r=!0;const e=setTimeout(()=>{s=0,r=!1},i);this.timeouts.push(e)}},{passive:!0,capture:!0}],a=e=>{this.eventsListeners.push([e,...o]),e.addEventListener(...o)},{clear:c}=v("iframe []contentDocument[] body > *",()=>{const e=document.getElementsByTagName("iframe");for(const t of e){"contentDocument"in t&&"body"in t.contentDocument&&a(t.contentDocument);const e=()=>a(t.contentDocument);t.addEventListener("load",e),this.eventsListeners.push([t,"onIframeLoad",e])}});return this.elementWaiters.push(c),a(document),e}clear(){this.triggerElements=this.triggerElements.filter(e=>(e.remove(),!1)),this.eventsListeners=this.eventsListeners.filter(e=>{const[t,...n]=e;return t&&n.length>1&&t.removeEventListener(...n),!1}),this.timeouts=this.timeouts.filter(e=>(clearTimeout(e),!1)),this.intervals=this.intervals.filter(e=>(clearInterval(e),!1));const e=c();return this.visibilityObservers=this.visibilityObservers.filter(t=>(t.clear(this.selector,e),!1)),this.promises=this.promises.filter(e=>(e.resolve(!1),!1)),this.elementWaiters=this.elementWaiters.filter(e=>(e(),!1)),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.getSocialProofDatas(e,"i",!0),socialProofPageViews:()=>this.getSocialProofDatas(e,"pv"),socialProofVisitors:()=>this.getSocialProofDatas(e,"v-pv")},n=!Object.prototype.hasOwnProperty.call(t,this.event)||await t[this.event]();return n&&this.clear(),"reengage"!==this.event&&this.delay?n&&await(async()=>{const e=h(`${this.event}Delay`);this.promises.push(e);const t=setTimeout(()=>{e.resolve(!0),this.clear()},this.delay);return this.timeouts.push(t),e.promise})():n}}const A="display",I="closing",P="validation",B="ABTastyWidgets",L=`${B}Temporary`;class N{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=o(),this.uniqueId=c(),this.recurrenceKey=`${this.widgetName}_${this.uniqueId}`,this.isListeningStorageEvent=this.listenStorageEvent(),this.pendingRecurrence=!1,this.pendingRecurrenceValue={}}onStorage({key:e}){const t=localStorage.getItem(L),n=sessionStorage.getItem(B);"ABTastyData"===e&&!t&&n&&localStorage.setItem(L,n)}listenStorageEvent(){return this.isListeningStorageEvent||window.addEventListener("storage",this.onStorage.bind(this)),!0}getGivenRecurrenceStorageParsed(e){try{const t=e.getItem(B);return JSON.parse(t)}catch(t){return e.removeItem(B),!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(B,JSON.stringify(i)),i):(e.removeItem(B),!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(L),t=!(!e||!e.includes(this.recurrenceKey))||this.getSessionRecurrence();e&&(sessionStorage.setItem(B,e),localStorage.removeItem(L));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 i=this.getTypeOfStorage(e);if(t()||!i&&"object"!=typeof i)return!1;const{storageString:s,storageMethod:o}=i,a=this.getStamp(e),c={type:n,stamp:a},{type:l}=this.getCurrentRecurrence(),h=async()=>{if(!r()){this.pendingRecurrence=!0,this.pendingRecurrenceValue=c;const e=new k({triggerEvent:"consent"});await e.isTriggered(),this.pendingRecurrence=!1,this.pendingRecurrenceValue={}}const e=this.getSessionRecurrence(),t=this.getLocalRecurrence();let n;"session"===s?e?n=this.removeSessionRecurrenceStorage():(this.removeLocalRecurrenceStorage(),n=this.getSessionRecurrenceStorageParsed()):"local"===s&&(t?n=this.removeLocalRecurrenceStorage():(this.removeSessionRecurrenceStorage(),n=this.getLocalRecurrenceStorageParsed()));const i=n?{[this.recurrenceKey]:c,...n}:{[this.recurrenceKey]:c};o.setItem(B,JSON.stringify(i)),this.onSetCallback&&"function"==typeof this.onSetCallback&&this.onSetCallback()};if(!o)return!1;if(l&&n!==P)if(n===I&&l!==P)h();else{if(n!==A||l===P||l===I)return!1;h()}else h();return a}setDisplayRecurrence(){const e=A;this.setRecurrence(this.displayRecurrence,e)}setClosingRecurrence(){const e=I;this.setRecurrence(this.closingRecurrence,e)}setValidationRecurrence(){const e=P;this.setRecurrence(this.validationRecurrence,e)}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 R{constructor(e,t,n){this.isWidgetApplied=e,this.callback=t,this.shouldUpdate=n,this.triggerIframeTarget=null,this.observer=new MutationObserver(this.observerHandler.bind(this)),this.tagRollbackEventParams=["abtasty_resetActionTracking",this.onTagRollback.bind(this)],this.onCampaignLaunchedEventParams=["abtasty_executedCampaign",this.onCampaignLaunched.bind(this)]}decisionHandler(e){const t=!e&&this.isWidgetApplied(),n=t?this.shouldUpdate&&S:C;return n?(this.clearWatcher(),this.callback(n,!e,t),this.watch(),this):this}onCampaignLaunched({detail:{campaignId:e}}){e===TEST_ID&&(this.callback(C,!1),this.watch())}onTagRollback({target:e}){return this.clearWatcher(e),this.callback(E,!1,!0),window.addEventListener(...this.onCampaignLaunchedEventParams),this}observerHandler(e){return s()?e.some(e=>["removedNodes","addedNodes"].some(t=>e[t]&&e[t].length))?this.decisionHandler():this:this.callback(E,!1)}watch(t,n){if(e())return this;if(this.clearWatcher(t),window.removeEventListener(...this.onCampaignLaunchedEventParams),document.addEventListener(...this.tagRollbackEventParams),n?.includes("[]contentDocument[]")){const e=n.split("[]")[0].trim(),{clear:t}=v(e,e=>{t(),this.triggerIframeTarget=e,e.addEventListener("load",this.decisionHandler.bind(this))})}const i=t?.defaultView?.frameElement;i&&this.triggerIframeTarget!==i&&i.addEventListener("load",this.decisionHandler.bind(this));const{clear:s}=v("body",e=>{s();const n=t?.body||t||e;this.observer.observe(n,{childList:!0,subtree:!0})});return this}clearTriggerElementWatcher(){this.triggerIframeTarget?.removeEventListener("load",this.decisionHandler.bind(this))}clearWatcher(e){return document.removeEventListener(...this.tagRollbackEventParams),this.observer.disconnect(),this.clearTriggerElementWatcher(),e?.defaultView?.frameElement?.removeEventListener("load",this.decisionHandler.bind(this)),this}}const D=/.+\/([^.]+)\.(otf|ttf)$/,_=["socialProofPurchases","socialProofPageViews","socialProofVisitors"];class O{constructor(t,n){this.children=void 0,this.uniqueId=`${c()}${n?`_${n}`:""}`,this.widgetName=o(),this.prettyName=a(),this.recurrenceParams=(()=>{const{displayRecurrence:t,closingRecurrence:n,validationRecurrence:i}=DATA,s=!t&&!n&&!i;if(e()||s)return!1;const r={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=r[t]("displayRecurrence")),n&&(o.closingRecurrence=r[n]("closingRecurrence")),i&&(o.validationRecurrence=r[i]("validationRecurrence")),o})(),this.triggerParams=(t=>{let{triggerEvent:n}=DATA;const{triggerEventClick:i,triggerEventHover:s,triggerEventReengageDelay:r,socialProofContentType:o,triggerEventElementVisible:a,triggerEventDelay:c}=DATA;if(e()||!n&&!o)return!1;const l={click:()=>i,hover:()=>s,elementVisible:()=>a},h=Object.prototype.hasOwnProperty.call(l,n)?l[n]():"body",d="reengage"===n?r:c;return o&&(n=[,"socialProofPurchases","socialProofPageViews","socialProofVisitors"][o]),{triggerEvent:n,triggerSelector:h,triggerDelay:d,triggerTarget:t}})(t),this.recurrence=!!this.recurrenceParams&&new N(this.recurrenceParams,this.clearGivenClearables.bind(this)),this.trigger=!!this.triggerParams&&new k(this.triggerParams),this.shouldUpdate=!!this.triggerParams&&_.includes(this.triggerParams.triggerEvent),this.pageWatcher=new R(this.isWidgetApplied.bind(this),this.onPageChange.bind(this)),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.rootElement=null,this.domElement=this.getDom(),this.hasBeenShown=!1,this.closedByUser=!1,this.elementsWaiters=[]}clearGivenClearables(){for(const e of this.elementsWaiters)e.clear();this.elementsWaiters=[]}isWidgetApplied(){return this.domElement?.isConnected&&this.domElement.ownerDocument?.defaultView}removeOldDomElement(){const e=this.rootElement?.getElementById(this.widgetContainerId);return e?.remove(),this}async insert(){if(this.isWidgetApplied())return!1;const e=["free"];"drawer"===DATA.layout&&DATA.customTarget&&e.push("drawer");const t=e.includes(DATA.layout);return new Promise(e=>{const{elementReferrer:n="body",referrerInsertType:i="beforeend"}=t?DATA:{},s=v(n,t=>{this.elementsWaiters=this.elementsWaiters.filter(e=>e.selector!==n),this.rootElement=t.getRootNode(),this.removeOldDomElement(),this.domElement.appendChild(this.styleElement),e(t.insertAdjacentElement(i,this.domElement))});this.elementsWaiters.push(s)}).then(()=>this)}remove(){this.trigger&&this.trigger.clear(),this.pageWatcher.clearWatcher(this.rootElement);for(const e of this.elementsWaiters)[DATA.elementReferrer,"body"].includes(e.selector)&&e.clear();return this.domElement?.isConnected&&this.domElement.remove(),this.hasOncePerPageTrigger?this.pageWatcher.watch(this.rootElement):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.rootElement),this}hide(t=!0){return!e()&&this.hasBeenShown&&t&&window.ABTastyEvent(`${this.prettyName} closed`,null,TEST_ID),t&&(this.pageWatcher.clearWatcher(this.rootElement),this.closedByUser=!0),this.domElement.classList.add(this.hideClassName),this}async init(t){const n=e(),i=s(),r=this.trigger?.promises?.length,o=!this.recurrence||this.recurrence.isOver();if(!n&&!i||r||!o)return{container:this,response:!1};this.pageWatcher.watch(this.rootElement||document,this.triggerParams.triggerSelector);const a=n||!this.trigger||this.trigger&&await this.trigger.isTriggered();this.pageWatcher.clearTriggerElementWatcher();const c={container:this,response:a};return a?(await this.insert(),this.addCloseEvent(),n||t||this.hasBeenShown||void 0===this.children||"function"!=typeof this.children.refreshContent||this.children.refreshContent(a),c):c}onPageChange(e,t,n){const i=()=>this.init().then(({response:e})=>{e?this.show():this.hide(!1)});t||(this.hasBeenShown=!1,n&&this.domElement.remove(),this.trigger&&this.trigger.clear());const s={[E]:()=>n?this.remove():this.pageWatcher.watch(this.rootElement),[C]:()=>{this.hasBeenShown?this.closedByUser?this.pageWatcher.watch(this.rootElement):n||this.insert().then(e=>e.show()).catch(this.pageWatcher.watch):i()},[S]:()=>{this.hasBeenShown?this.pageWatcher.watch():i()}};"function"==typeof s[e]&&s[e]()}addCloseEvent(...t){const{closeButton:n,overlay:i,overlayClickable:s,layout:r,animationDuration:o=1e3}=DATA,a=[];if(void 0!==i&&!0!==i||!0!==s||"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=>{f(e),this.recurrence&&this.recurrence.setClosingRecurrence(),this.hide(!0),setTimeout(()=>this.remove(),1.05*o)},{once:!0,capture:!0}];t.push(...c);for(const n of t)e()&&(n.dataset.abtastyActionnable="true"),n.removeEventListener(...l),n.addEventListener(...l);return this}getDom(){const{closeButton:e,layout:t,overlayClickable:n,overlay:i=!0}=DATA,s=document.createElement("div");return s.className=`${this.basicClassName} ${this.hideClassName}`,s.id=this.widgetContainerId,["popin","bannerTop","bannerBottom"].includes(t)&&(s.role="dialog"),s.innerHTML=`\n\t\t\t${"popin"===t&&!0===i?`<div ${n?'aria-label="Close dialog"':""} class="${this.overlayClassName}"></div>`:""}\n\t\t\t<div class="${this.contentClassName}">\n\t\t\t${e?`<button class="${this.closeButtonClassName}" aria-label="Close dialog"><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>`,s}loadFont(e,t){if(!e||"inherit"===e||!/otf|ttf/g.test(t))return;const n=document.createElement("style"),i=t.match(D)?t.match(D)[1]:"";n.innerHTML=`@font-face { font-family: '${e}_${i}'; src: url('${t}'); font-display: swap; }`;const s=this.rootElement?.head||document.head;s?.appendChild(n)}getStyleTag(t="",n=DATA){const{noStyles:i,layout:s}=n,{backgroundColor:r,isBackgroundImage:o,backgroundImage:a,backgroundSize:c,backgroundPosition:l,backgroundRepeat:h,borderColor:d,borderRadius:u,borderWidth:g,textColor:m,textAlign:p,fontName:v,fontStyle:y,fontSize:f,isTitle:b,titleTextAlign:w,titleTextColor:T,titleFontName:E,titleFontStyle:C,titleFontSize:S,overlay:x,overlayColor:k,dropShadow:A,dropShadowColor:I,dropShadowBlur:P,containerMargin:B,containerPadding:L,closeButton:N,closeButtonPosition:R,closeButtonSize:_,closeButtonBorderRadius:O,closeButtonBorderWidth:W,closeButtonBorderColor:V,closeButtonColor:j,closeButtonBackgroundColor:H,buttonsAlign:M,buttonsBorderWidth:q,buttonsBorderColor:F,buttonsBorderRadius:K,buttonsBackgroundColor:U,buttonsTextColor:z,buttonsFontName:Y,buttonsFontStyle:G,buttonsFontSize:J,secondLink:X,secondLinkBorderWidth:Q,secondLinkBorderColor:Z,secondLinkBorderRadius:ee,secondLinkBackgroundColor:te,secondLinkTextColor:ne,secondLinkFontName:ie,secondLinkFontStyle:se,secondLinkFontSize:re,animation:oe,animationDuration:ae,animationBehaviour:ce,animationSlideDirection:le}=i?{}:n,he=document.createElement("style");e()&&he.setAttribute("abtasty-script-added","true"),this.loadFont(v,y),this.loadFont(E,C),this.loadFont(Y,G),this.loadFont(ie,se);const de=`background: ${["string"==typeof r?r:"rgba(255, 255, 255, 1)",o&&"string"==typeof a&&a.length?`url(${a})`:"",o&&"string"==typeof l&&"100% 100%"!==c?l:"0 0",o&&"string"==typeof c?`/ ${c}`:"/ auto",o&&h&&!["cover","100% 100%"].includes(c)?"repeat":"no-repeat"].join(" ").trim()};`,ue="number"==typeof g&&g>0,ge=`border: ${[ue?`${g}px`:"unset",ue?"solid":"",ue&&"string"==typeof d&&d.length?d:""].join(" ").trim()};`,me=void 0!==u?`border-radius: ${u}px;`:"",pe=void 0!==m?`color: ${m}; fill: ${m}; -webkit-text-fill-color: ${m};`:"",ve=void 0!==p?`text-align: ${p};`:"",ye=v&&"inherit"!==v?`font-family:${v}_${y.match(D)?y.match(D)[1]:""};`:y||"",fe=f?`font-size: ${f}px;`:"",$e=void 0!==A&&A?`box-shadow: 0 5px ${P}px 0 ${I};`:"",be=B instanceof Array&&1===B.length&&B[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);`:"",Ee=L instanceof Array&&1===L.length&&L[0],Ce=Ee?`padding: ${Ee.top}px ${Ee.right}px ${Ee.bottom}px ${Ee.left}px;`:"",Se=Ee?`padding: calc(${Ee.top}px * 0.5) calc(${Ee.right}px * 0.5) calc(${Ee.bottom}px * 0.5) calc(${Ee.left}px * 0.5);`:"",xe=void 0!==q&&q?`border-width: ${q}px; border-style: solid;`:"",ke=[F,q].every(e=>void 0!==e)&&q?`border-color: ${F};`:"",Ae=void 0!==K?`border-radius: ${K}px;`:"",Ie=void 0!==U?`background-color: ${U};`:"",Pe=void 0!==z?`color: ${z}; fill: ${z}; -webkit-text-fill-color: ${z};`:"",Be=Y&&"inherit"!==Y?`font-family:${Y}_${G.match(D)?G.match(D)[1]:""};`:G||"",Le=J?`font-size: ${J}px;`:"",Ne="number"==typeof Q?`border-width: ${Q}px; border-style: solid;`:"",Re=[Z,Q].every(e=>void 0!==e)&&Q?`border-color: ${Z};`:"",De=void 0!==ee?`border-radius: ${ee}px;`:"",_e=void 0!==te?`background-color: ${te};`:"",Oe=void 0!==ne?`color: ${ne}; fill: ${ne}; -webkit-text-fill-color: ${ne};`:"",We=ie&&"inherit"!==ie?`font-family:${ie}_${se.match(D)?se.match(D)[1]:""};`:se||"",Ve=re?`font-size: ${re}px;`:"",je="popin"!==s||void 0!==x&&!0!==x?"":[`#${this.widgetContainerId} .${this.overlayClassName} {`,`background-color: ${void 0!==k?k:"rgba(0, 0, 0, 0.6)"};`,"}"].join(""),He="number"==typeof _?_:16,Me=He/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;","padding: 0;","margin: 0;","line-height: 0;","z-index: 9;","number"==typeof O?`border-radius: ${O}px;`:"","number"==typeof W&&W>0?`border: ${W}px solid ${void 0!==V?V:"rgba(57, 57, 57, 1)"};`:"","string"==typeof H?`background-color: ${H};`:"","}",`#${this.widgetContainerId} .${this.contentClassName} .${this.closeButtonClassName} svg {`,"pointer-events: none;",`width: ${He}px;`,`height: ${He}px;`,"string"==typeof j?`fill: ${j};`:"","}"].join(""):"",Fe=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};`:"",E&&"inherit"!==E?`font-family:${E}_${C.match(D)?C.match(D)[1]:""};`:C||"",S?`font-size: ${S}px;`:"","}"].join(""):"";let Ke="";if("string"==typeof oe){const t=(ae/1e3).toFixed(2),n=["top","bottom"].includes(le),i=Number(n),s=[(["top","left"].includes(le)?"-":"")+"100vmax",this.translateValues?this.translateValues[i]:"0"];n&&s.reverse(),Ke={none:[`.${this.hideClassName} {`,"opacity: 0 !important;","}"],fade:[`.${this.hideClassName} {`,"opacity: 0 !important;","}",`#${this.widgetContainerId} {`,`transition: opacity ${t}s ${ce};`,"}"],slide:[`.${this.hideClassName} .${this.overlayClassName} {`,"opacity: 0 !important;","}",`#${this.widgetContainerId} .${this.overlayClassName} {`,`transition: opacity ${t}s ${ce};`,"}",`.${this.hideClassName} .${this.contentClassName} {`,`transform: translate(${s.join(", ")}) !important;`,"}",`#${this.widgetContainerId} .${this.contentClassName} {`,`transition: transform ${t}s ${ce};`,"}"]}[e()&&!ABTASTY_S.WIDGETS.animationChanged?"none":oe].join("")}const Ue=[`#${this.widgetContainerId} .${this.contentClassName} .buttons_container .second_link {`,`margin-${"fill"===M?"top":"left"}: 8px;`,Ne,Re,De,_e,Oe,We,Ve,"}",`#${this.widgetContainerId} .${this.contentClassName} .buttons_container .second_link {`,Oe,We,Ve,"}"];return he.textContent=[`#${this.widgetContainerId} style { display: none; }`,`.${this.hideClassName} {`,"pointer-events: none;","}",`#${this.widgetContainerId} {`,"opacity: 1;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,de,me,ge,pe,ve,$e,we,ye,fe,"}",`#${this.widgetContainerId} .${this.contentClassName} p {`,pe,ve,ye,fe,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,"display: block;","line-height: 1;","text-indent: unset;",Ce,ye,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;",xe,ke,Ae,Ie,Pe,Be,Le,"}",`#${this.widgetContainerId} .${this.contentClassName} div.buttons_container a *, `,`#${this.widgetContainerId} .${this.contentClassName} button:not([class*="close_button"]) * {`,Pe,Be,Le,"}",...X?Ue:[],"@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,Te,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,Se,"}","}",je,qe,Fe,Ke,`${t}`].join(""),he}}const W={top:{top:0,left:50,translateX:-50,translateY:-100,translateOpenX:-50,translateOpenY:0},bottom:{top:100,left:50,translateX:-50,translateY:0,translateOpenX:-50,translateOpenY:-100},left:{top:50,left:0,translateX:-100,translateY:-50,translateOpenX:0,translateOpenY:-50},right:{top:50,right:0,translateX:100,translateY:-50,translateOpenX:0,translateOpenY:-50}},V={top:[!1,!1,!0,!0],bottom:[!0,!0,!1,!1],left:[!1,!0,!0,!1],right:[!0,!1,!1,!0]};class j extends O{constructor(){super(),this.button=this.setButton(),this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles),this.open=!1}toggleDrawer(){this.open=this.domElement.classList.toggle("drawer_open")}setButton(){const{mainButtonText:t,hasMainButtonIcon:n,mainButtonIcon:i,mainButtonIconAlt:s}=DATA,r=document.createElement("button");return r.className=`drawer_button_${this.uniqueId}`,e()&&(r.dataset.abtastyActionnable="true"),r.innerHTML=`<span>${t}</span>${n?`<img src="${i}" alt="${s}">`:""}`,e()&&top.document.documentElement.classList.contains("widget-react-form-opened")&&this.domElement.classList.add("drawer_open"),r.addEventListener("click",this.toggleDrawer.bind(this),!0),this.domElement.insertAdjacentElement("beforeend",r),r}getStyles(){const{buttonLayout:e,customTarget:t,elementReferrer:n,zindex:i,zindexCustom:s,styckyButtonBackgroundColor:r,styckyButtonIsBackgroundImage:o,styckyButtonBackgroundImage:a,styckyButtonBackgroundPosition:c,styckyButtonBackgroundRepeat:l,styckyButtonBackgroundSize:h,styckyButtonButtonsAlign:d,styckyButtonContainerMargin:u,styckyButtonContainerPadding:g,styckyButtonButtonsBorderWidth:m,styckyButtonButtonsBorderColor:p,styckyButtonButtonsBorderRadius:v,styckyButtonDropShadow:y,styckyButtonDropShadowBlur:f,styckyButtonDropShadowColor:b,styckyButtonTitleFontName:w,styckyButtonTitleFontStyle:T,styckyButtonTitleFontSize:E,styckyButtonTitleTextAlign:C,styckyButtonTitleTextColor:S,autoWidth:x,drawerLayout:k,hasMainButtonIcon:A,animationDuration:I,animationBehaviour:P}=DATA,{top:B,left:L,right:N,translateX:R,translateY:D,translateOpenX:_,translateOpenY:O}=W[e],j=["left","right"].includes(e),[{top:H,bottom:M,left:q,right:F}]=u,[{top:K,bottom:U,left:z,right:Y}]=g,G=V[e].map(e=>e?`${v}px`:"0").join(" "),J=`background: ${[r,o&&a.length?`url(${a})`:"",o&&"100% 100%"!==h?c:"0 0",o&&"string"==typeof h?`/ ${h}`:"/ auto",o&&l&&!["cover","100% 100%"].includes(h)?"repeat":"no-repeat"].join(" ").trim()};`,X=y?`box-shadow: 0 5px ${f}px 0 ${b};`:"",Q=`border: ${m>0?`${m}px solid ${p}`:"unset"};`,Z=/.+\/([^.]+)\.(otf|ttf)$/;this.loadFont(w,T);const ee=[`color: ${S}; fill: ${S}; -webkit-text-fill-color: ${S};`,`text-align: ${C};`,"inherit"!==w?`font-family:${w}_${T.match(Z)?T.match(Z)[1]:""};`:T||"",E?`font-size: ${E}px;`:""].join(""),te={left:"start",center:"center",right:"end"}[C],ne=t?n:"body",[ie,se,re]=ne.split("[]"),oe=re??ie,ae="shadowRoot"===se?":host":`${oe.trimEnd()}:not(:has(.fixed-drawer))`;return[`${oe} {`,"position: relative;","}",t?[`${ae} {`,`overflow-${j?"x":"y"}: hidden;`,"}"].join(""):"",`#${this.widgetContainerId} {`,"position: absolute;",`top: ${B}%;`,"number"==typeof L?`left: ${L}%;`:"","number"==typeof N?`right: ${N}%;`:"",`transform: translate(${R}%, ${D}%);`,`transition: transform ${(I/1e3).toFixed(2)}s ${P};`,"margin: 0;","padding: 0;","background: none;",`z-index: ${"custom"===i?s:i};`,(()=>{if(x)return t?`width: auto; height: auto; max-width: calc(100% - ${j?`${z+Y+1.5*E}px`:`${K+U+1.5*E}px`});`:`width: auto; height: auto; min-width: 30vw; max-width: ${["left","right"].includes(k)?"80vw":"40vw"};`;const{popinPercentWidth:e,popinPixelsWidth:n,widthUnit:i,autoHeight:s,popinPercentHeight:r,popinPixelsHeight:o,heightUnit:a}=DATA;return`width: ${"px"===i?n:e}${i};height: ${s?"auto":`${"px"===a?o:r}${a}`};`})(),"}",`#${this.widgetContainerId}.fixed-drawer {`,"position: fixed;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: relative;","width: 100%;","height: 100%;","}",`#${this.widgetContainerId}.drawer_open {`,`transform: translate(${_}%, ${O}%);`,"}",`.${this.button.className} {`,"position: absolute;",`${e}: 100%;`,["top","bottom"].includes(e)?[`${"right"===d?"right":"left"}: ${["left","right"].includes(d)?"0":"50%"};`,`transform: translate(${["left","right"].includes(d)?"0":"-50%"}, 0);`,`width: ${"fill"===d?"100%":"auto"};`].join(""):"",j?[`${"right"===d?"bottom":"top"}: ${["center","fill"].includes(d)?"50%":"0"};`,`transform: translate(0, ${["left","right"].includes(d)?"0":"-50%"});`,`height: ${"fill"===d?"100%":"auto"};`].join(""):"",`margin: ${H}px ${F}px ${M}px ${q}px;`,`padding: ${K}px ${Y}px ${U}px ${z}px;`,"text-wrap: nowrap;",J,Q,`border-radius: ${G};`,"display: flex;",`flex-direction: ${j?"column":"row"};`,"align-items: center;",`justify-content: ${te};`,X,"}",`.${this.button.className} span {`,j?["writing-mode: vertical-rl;","text-orientation: sideways;"].join(""):"","right"===e?"transform: rotate(180deg);":"","width: auto;",ee,"}",A?[`.${this.button.className} img {`,j?`transform: rotate(${e.includes("right")?"-":""}90deg);`:"",`min-width: ${2*E}px;`,`max-height: ${2*E}px;`,`margin-${j?"top":"left"}: ${E}px`,"}"].join(""):"","@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,x?"min-width: 40vw; max-width: 60vw;":"","}","}"].join("")}}class H{constructor(e){let{parentContainer:t}=e;this.parentContainer=t,this.className=`drawer_container_${t.uniqueId}`,this.domElement=this.getElement()}insertIn(e,t){this.setStyles(),e.insertAdjacentElement(t,this.domElement)}addRedirectionEvent(t){!e()&&t&&t.addEventListener("click",()=>{const{autoHide:t,timeHide:n}=DATA;t&&setTimeout(()=>{this.parentContainer.hide(),this.remove()},1e3*n),e()||this.parentContainer.recurrence.setValidationRecurrence()},{capture:!0,passive:!0})}addCloseEvent(t){t&&t.addEventListener("click",t=>{f(t),e()||this.parentContainer.recurrence.setClosingRecurrence(),this.parentContainer.hide(),setTimeout(()=>this.parentContainer.remove(),1e3)},{capture:!0,passive:!1})}buttonBuilder(e,t,n,i){let s=arguments.length>4&&void 0!==arguments[4]&&arguments[4];const r=document.createElement("a");return r.ariaLabel=e,r.innerHTML=`<span>${e}</span>`,r.href="button"===t?n:"#",s&&(r.className="second_link"),"button"===t?(r.target=i?"_blank":"_self",this.addRedirectionEvent(r)):(r.dataset.abtastyActionnable="true",this.addCloseEvent(r)),r}getButtons(){const{linkType:e,buttonText:t,redirectionUrl:n,openInNewTab:i,secondLink:s,secondLinkText:r,secondLinkType:o,secondLinkURL:a,secondLinkOpenInNewTab:c}=DATA,l=[this.buttonBuilder(t,e,n,i)];if(s){const e=this.buttonBuilder(r,o,a,c,s);l.push(e)}return l}getElement(){const{linkType:e,buttonText:t,redirectionUrl:n,isTitle:i,title:s,textContent:r,openInNewTab:o,drawerLayout:a,drawerImage:c}=DATA,l=document.createElement(e&&e.includes("widget")?"a":"div");l.className=this.className,"widget"===e?(l.href=n,l.target=o?"_blank":"_self",this.addRedirectionEvent(l)):"widgetClose"===e&&(l.href="#",l.dataset.abtastyActionnable="true",this.addCloseEvent(l)),l.innerHTML="textOnly"!==a?`<img src="${c}">`:"";const h=document.createElement("div");if(h.className="drawer_text_container","imageOnly"!==a&&(h.innerHTML=`\n\t\t\t${i?`<h2 class="drawer_title">${s}</h2>`:""}\n\t\t\t<p class="drawer_text">${r}</p>`),[e,t].every(e=>"string"==typeof e)&&e.includes("button")&&t.length){const e=this.getButtons(),t=document.createElement("div");t.className="buttons_container",e.forEach(e=>t.appendChild(e)),h.appendChild(t)}return l.appendChild(h),l}setStyles(){const{styleElement:e,widgetContainerId:t,contentClassName:n}=this.parentContainer,{linkType:i,buttonsAlign:s,drawerLayout:r}=DATA,o=`#${t} .${n}`,a=`${["left","right"].includes(r)?"row":"column"}${["right","bottom"].includes(r)?"-reverse":""}`,c=[`${o} .buttons_container {`,"display: inline-block;","width: 100%;",void 0!==s&&"fill"!==s?`text-align: ${s};`:"","}",`${o} .buttons_container a {`,"margin: 25px 0 0 0;","padding: 10px 22px;","line-height: 1;","max-width: 100%;",`width: ${"fill"===s?"100%":"auto"};`,"text-align: center;","}"].join(""),l=[`${o} .${this.className} {`,"display: flex;",`flex-direction: ${a};`,"justify-content: space-around;","align-items: center;","}",`.${this.className} > img {`,"max-width: 100%;","width: 100%;","height: auto;","}",["left","right"].includes(r)?[`${o} .${this.className} > * {`,"max-width: 46%;","}"].join(""):"",`${o} .drawer_title {`,"margin: 0 0 25px 0;","display: inline-block;","width: 100%;","}",`${o} .drawer_text_container {`,"line-height: 0;","white-space: pre-line;","display: inline-block;","vertical-align: middle;","width: 100%;","margin: 2vh 0;","}",`${o} .drawer_text_container * {`,"line-height: 1;","}",`${o} .drawer_text_container p {`,"margin: 0;","}"];i&&i.includes("button")&&l.push(c);const h=l.join("");return e.insertAdjacentText("beforeend",h),e}}!function(){l("Widget launch");const e=new j,t=e.domElement.querySelector(`.${e.contentClassName}`),n=new H({parentContainer:e});e.children=n,n.insertIn(t,"beforeend"),e.init(!0).then(t=>{let{response:n}=t;n&&(e.show(),(!0!==DATA.customTarget||u(DATA.elementReferrer).matches("body"))&&e.domElement.classList.add("fixed-drawer"))})}()}();
1
+ !function(){"use strict";const e=()=>Object.prototype.hasOwnProperty.call(top,"ABTastyEditor"),t=()=>{const e=!!document.getElementById("ABTastyPreviewBar"),t=location.href.includes("ab_project=preview");return e||t},n=e=>new Function(`try {\n\t\t${e}\n\t} catch (error) {\n\t\treturn null;\n\t}`)(),i=()=>encodeURIComponent(DATA.spNoTrim?window.location.href.replace(window.location.origin,""):`${window.location.pathname}`),s=()=>!e()&&(t()||!!window.ABTasty.getTestsOnPage()[TEST_ID]),r=()=>window.ABTasty&&!0===window.ABTasty.consentReady,o=()=>{const{type:e}=DATA;return`${PACKAGE.replace("@abtasty/","")}${e?`_${e}`:""}`},a=()=>{const e=o();return`${e.charAt(0).toUpperCase()}${e.slice(1)}`.split("-").join(" ")},c=()=>`${PLUGIN_ID.split("-")[0]}_${TEST_ID}`,l=n=>{const i=(()=>{if(e()||t())return!1;const n=ABTasty.getTestsOnPage()[TEST_ID];return!!n&&Object.keys(n.targetings.qaParameters).length>0})(),s=window.document.cookie.includes("abTastyDebug=")||!0===window.abTastyDebug;if(i||s){const e=a();window.console.log(`%c${e} - ${i?"QA":"Debug"} Mode for campaign ${TEST_ID} %c ${n}`,"background-color: #D6FF01; color: #3100be; padding: 3px 0 3px 10px; border-radius: 5px 0 0 5px; font-weight: bold;","background-color: #3100be; color: white; padding: 3px 10px 3px 0; border-radius: 0 5px 5px 0;")}},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},d=(e,t)=>{const n=t?[]:null;if("string"!=typeof e||!e.trim().length)return n;const[i,s,r]=e.split("[]").map(e=>e.trim()),o=Boolean(r)?r:e,a=s?document.querySelector(i)?.[s]:document;return a?t?[...a.querySelectorAll(o)]:a.querySelector(o):n},u=e=>d(e,!1),g=e=>d(e,!0),m=(e,t)=>{const n={childList:!0,subtree:!0,attributes:!0},i=()=>s.disconnect(),s=new MutationObserver(()=>{const n=u(t);return n&&!i()&&e(n)});return{clear:i,observe:e=>{const t=document.querySelector("body")||document.documentElement,i=e??t;s.observe(i,n)}}},p=()=>{},v=(t,n)=>{const i=u(t),s={selector:t,clear:p,observe:p};if(i)return setTimeout(()=>n(i),0),s;if(e())return setTimeout(()=>v(t,n),1e3),s;if(t.includes("[]"))return((e,t)=>{const[n,i]=t.split("[]").map(e=>e.trim()),s=u(n),r=s?.[i],{clear:o,observe:a}=m(e,t),c=()=>{const n=u(t);return n&&!l()&&e(n)},l=()=>{o(),s?.removeEventListener("load",c)},h=()=>{a(r),"iframe"===s?.localName&&s.addEventListener("load",c)};return h(),{selector:t,clear:l,observe:h}})(n,t);const{clear:r,observe:o}=m(n,t);return o(),{selector:t,clear:r,observe:o}};function y(e,t){const n=e.parentElement||e.getRootNode().host;return t(e)||!n?e:y(n,t)}const f=t=>{e()||(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation())},b=(e,t)=>[...g(t)].some(n=>{const[i,,s]=t.split("[]"),r=s??i;return n===e||!!e.closest(r)});let w=!1;class T{constructor(){this.targets=[],this.existingTargets=[],this.inViewportTargets=[],this.visibilityObserver=null,this.mutationObserver=null,this.mouseOverEvent=null,this.scrollEvent=null,this.onTransitionEnd=null,this.onIframeLoad=null}transitionOverHandler(e){const t=[e,"transitionend",this.checkElements.bind(this),!0];return this.getEvents(...t)}intersectionHandler(e){e.forEach(e=>{e.isIntersecting?(this.existingTargets.forEach(t=>{t.element.isSameNode(e.target)&&(this.inViewportTargets.push(t),this.mouseOverEvent.start(),this.scrollEvent.start(),this.onTransitionEnd.start())}),this.checkElements()):this.inViewportTargets=this.inViewportTargets.filter(t=>!t.element.isSameNode(e.target)||(this.mouseOverEvent.clear(),this.scrollEvent.clear(),this.onTransitionEnd.clear(),!1))})}startVisibilityObserver(e){const t={root:e,rootMargin:"0px",threshold:.01};return this.visibilityObserver??=new IntersectionObserver(this.intersectionHandler.bind(this),t),this.visibilityObserver}startMutationObserver(e){return this.mutationObserver??=new MutationObserver(this.checkElements.bind(this)),this.mutationObserver.observe(e,{attributes:!0,childList:!0,subtree:!0}),this.mutationObserver}onMouseOver({target:e,path:t}){const n=this.inViewportTargets.find(({element:n,selector:i})=>{if(n.isSameNode(e))return!0;const[s,,r]=i.split("[]"),o=r??s,a=[...e.querySelectorAll(o)];if(a.length&&a.includes(n))return!0;if(t.includes(n))return!0;if(!e.parentElement?.children?.length)return;const c=[...e.parentElement.children],l=c.findIndex(t=>t.isSameNode(e)),h=c.filter((e,t)=>t>l);if(h.length){if(h.includes(n))return!0;if(h.some(e=>[...e.querySelectorAll(o)].includes(n)))return!0}return!1});if(n&&this.isElementVisible(n.element)){const{selector:e,element:t,uniqueId:i}=n,s=this.targets.find(t=>t.selector===e&&t.uniqueId===i);s&&s.resolve(t),this.clear(e,i)}}getEvents(e,...t){return{start:()=>e?.addEventListener(...t),clear:()=>e?.removeEventListener(...t)}}mouseOverHandler(e){const t=[e,"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0?"touchmove":"mouseover",e=>{const t=e.composedPath(),{target:n}=e;setTimeout(()=>this.onMouseOver({target:n,path:t}),50)},!0];return this.getEvents(...t)}scrollEventHandler(e){const t=[e,"scroll",(n=this.checkElements.bind(this),()=>{w||(w=!0,setTimeout(()=>{n(),w=!1},100))}),{passive:!0}];var n;return this.getEvents(...t)}isElementVisible(e){return this.isElementOpaque(e)&&this.isElementTopmost(e)}isElementOpaque(e){return"HTML"===y(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,s=0;for(;!i&&s<n.length;){const t=e.getRootNode()?.elementFromPoint(...n[s]);i=e===t||t?.contains(e)||e.contains(t),s+=1}return i}checkElements(){this.targets.forEach(({selector:e,uniqueId:t})=>{const n=u(e),[i,,s]=e.split("[]"),r=s??i;n&&!this.existingTargets.find(e=>e.element.matches(r)&&e.uniqueId===t)&&(this.existingTargets.push({element:n,selector:e,uniqueId:t}),this.visibilityObserver.observe(n))}),this.existingTargets=this.existingTargets.filter(({selector:e,element:t})=>!(!u(e)||!t.isConnected)||(t&&this.visibilityObserver.unobserve(t),!1)),this.inViewportTargets=this.inViewportTargets.filter(({selector:e,element:t,uniqueId:n})=>{const[i,,s]=e.split("[]"),r=s??i;if(t.matches(r)&&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})}onLoadIframe(e){const t=[e.defaultView.frameElement,"load",()=>this.watch(selector,resolve,uniqueId).bind(this),{passive:!0}];return this.getEvents(...t)}watch(e,t,n){this.targets.push({selector:e,resolve:t,uniqueId:n});const{clear:i}=v(e,e=>{i();const t=e.getRootNode({composed:!0}),n="body"in t?t.body:document;this.mouseOverEvent=this.mouseOverHandler(t),this.scrollEvent=this.scrollEventHandler(t),this.onTransitionEnd=this.transitionOverHandler(t),t.defaultView?.frameElement&&(this.onIframeLoad=this.onLoadIframe(t),this.onIframeLoad.start()),this.startVisibilityObserver(t),this.startMutationObserver(n),this.checkElements()})}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=u(e);n&&this.visibilityObserver?.unobserve(n),0===this.targets.length&&(this.mutationObserver?.disconnect(),this.onIframeLoad?.clear()),0===this.inViewportTargets.length&&(this.mouseOverEvent?.clear(),this.scrollEvent?.clear(),this.onTransitionEnd?.clear())}}const E="remove",C="rebuild",S="update",x="ABTastyData";class k{constructor({triggerEvent:e,triggerSelector:t,triggerDelay:n,triggerTarget:i}){this.event=e,this.selector=Boolean(t)?t:"body",this.target="string"==typeof i?u(t):i,this.delay=1e3*n,this.triggerElements=[],this.eventsListeners=[],this.timeouts=[],this.intervals=[],this.promises=[],this.visibilityObservers=[],this.socialProofStore={},this.elementWaiters=[]}async onElementVisible({promise:e,resolve:t}){const n=h(`${this.event}DomReady`);this.promises.push(n);const{clear:i}=v(this.selector,()=>{const e=new T;this.visibilityObservers.push(e),e.watch(this.selector,t,c())});return this.elementWaiters.push(i),e}onPageLoad({promise:e,resolve:t}){const n=()=>"complete"===document.readyState;if(!n()){const i=["readystatechange",()=>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=({isTrusted:e,target:n})=>{if(e)return(n.isEqualNode(this.target)||b(n,this.selector))&&t(!0)},{clear:i}=v(this.selector,e=>{i();const t=document.createElement("style");t.id=`Click_${c()}`;const[s,,r]=this.selector.split("[]"),o=r??s;t.innerHTML=`${o} {\n\t\t\t\tcursor: pointer !important;\n\t\t\t\tpointer-events: all !important;\n\t\t\t}`;const a=e.getRootNode();("head"in a?a.head:a).appendChild(t),this.triggerElements.push(t);const l=["click",n,{passive:!0,capture:!0}];this.eventsListeners.push([a,...l]),a.addEventListener(...l)});return this.elementWaiters.push(i),e}onHover({promise:e,resolve:t}){const n=({isTrusted:e,target:n})=>{if(e)return(this.target?n.isEqualNode(this.target):b(n,this.selector))&&t(!0)},{clear:i}=v(this.selector,e=>{const t=e.getRootNode(),i="body"in t?t.body:[...t.childNodes].find(t=>t.contains(e)),s=["mouseenter",n,{passive:!0,capture:!0}];this.eventsListeners.push([i,...s]),i.addEventListener(...s)});return this.elementWaiters.push(i),e}onExitIntent({promise:e,resolve:t}){const n=["mouseleave",({isTrusted:e,clientY:n})=>{e&&n<=0&&t(!0)},{passive:!0}],{clear:i}=v("html",e=>{i(),this.eventsListeners.push([e,...n]),e.addEventListener(...n)});return e}onReengage({promise:e,resolve:t}){const n=this.delay;let i=n;const s=[...document.querySelectorAll("*:empty")].map(e=>e.contentDocument||e.shadowRoot).filter(e=>e),r=[({isTrusted:e})=>{e&&(i=n)},{passive:!0}];["click","mousemove","scroll","keypress"].forEach(e=>{[document,...s].forEach(t=>{this.eventsListeners.push([t,e,...r]),t.addEventListener(e,...r)})});const o=setInterval(()=>{i<=0?t(!0):i-=100},100);return this.intervals.push(o),e}onCustomTrigger({promise:e,resolve:t}){const{triggerEventCustomScript:n,tagIsSafeEval:i}=DATA,s=i&&DATA_JS?.triggerEventCustomScript,r="function"==typeof s?()=>new Promise(e=>s(e)):new Function(`return new Promise(async resolve => {${n}})`);return r().then(e=>e&&t(!0)),e}onScrollUp({promise:e,resolve:t}){let n=0;const i=["scroll",({isTrusted:e})=>{e&&(window.scrollY<n?t(!0):n=window.scrollY)},{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 s=(()=>{let e;return window.ABTasty||window.ABTASTY_S?(window.ABTASTY_S?.USER?.accountIdentifier?.length?e=window.ABTASTY_S.USER.accountIdentifier:"function"==typeof window.ABTasty?.getAccountSettings?e=window.ABTasty.getAccountSettings().identifier:window.ABTasty?.accountSettings&&(e=window.ABTasty.accountSettings.identifier),e):e})(),{viewInterval:r,spNoTrim:o}=DATA;if(this.socialProofStore.hasOwnProperty(e))n(this.socialProofStore[e])?i(`${this.socialProofStore[e][r]}`):i(!1);else if(e&&s){const a=t=>(this.socialProofStore[e]=t,i(!!n(t)&&`${t[r]}`));fetch(`https://api-social-proof.abtasty.com/clients/${s}/metrics/${t}?key=${e}${o?"&noTrim=true":""}`).then(e=>e.ok&&e.json()).then(a).catch(()=>l("Failed to fetch datas from server."))}else i(!1)}getSocialProofDatas({promise:e,resolve:t},s,r=!1){const{productKey:o,keyType:a}=(()=>{const{socialProofContentType:e,productKeyProvider:t,pathToProductKey:s,customJSProductKey:r,productSKU:o,tagIsSafeEval:a}=DATA,{pathToProductKey:c,customJSProductKey:l}=a&&DATA_JS||{};if(2===e)return{productKey:i(),keyType:"url"};{let a=null,h="sku";switch(t){case"ABTastyProductKey":a=window.ABTastyProductKey;break;case"pathToProductKey":a="function"==typeof c?c():n(`return ${s};`);break;case"customJSProductKey":a="function"==typeof l?l():n(r);break;case"productSKU":a=o}return a||3!==e||(a=i(),h="url"),{productKey:a,keyType:h}}})(),{viewInterval:c,triggerSocialProofMinVisitors:h,triggerSocialProofMinPurchases:d,triggerSocialProofMinPageViews:u}=DATA,g={pv:u,i:d,"v-pv":h}[s];return[typeof c,typeof g].includes("undefined")&&t(!1),r&&!o&&(l("Not able to find ABTastyProductKey, impossible to call the API, read documentation for more informations:\n\t\t\t\thttps://support.abtasty.com/hc/en-us/articles/4710919241628-Widgets-List#h_84c04344-c655-4e5e-b9ab-d26a798ad9b0"),t(!1)),this.checkSocialProofConditions(o,"v-pv"===s&&"sku"===a?"v-i":s,e=>{const t=void 0!==e[c]&&e[c]>=g;return t||l(`Widget will not be shown, Social Proof API returned ${e[c]} while ${g} are required`),t},t),e}onConsent({promise:e,resolve:t}){if(!r()){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(x);const s=()=>JSON.parse(i)?.ActionTracking?.some(({name:e})=>e===n),r=["storage",({key:e,newValue:n})=>{e===x&&(i=n,s()&&t(!0))},{passive:!0,capture:!0}];return i&&s()?t(!0):(()=>{this.eventsListeners.push([window,...r]),window.addEventListener(...r)})(),e}onMinPagesViewed({promise:e,resolve:t}){const{triggerEventMinPagesViewed:n}=DATA;let i=localStorage.getItem(x);const s=()=>n<=(i?JSON.parse(i)?.VisitedPages?.length:0),r=["storage",({key:e,newValue:n})=>{e===x&&(i=n,s()&&t(!0))},{passive:!0,capture:!0}];return i&&s()?t(!0):(()=>{this.eventsListeners.push([window,...r]),window.addEventListener(...r)})(),e}onRageClick({promise:e,resolve:t}){const{triggerEventRageClickQuantity:n,triggerEventRageClickDelay:i}=DATA;let s=0,r=!1;const o=["click",({isTrusted:e})=>{if(e&&(s+=1,s>=n&&t(!0),!r)){r=!0;const e=setTimeout(()=>{s=0,r=!1},i);this.timeouts.push(e)}},{passive:!0,capture:!0}],a=e=>{this.eventsListeners.push([e,...o]),e.addEventListener(...o)},{clear:c}=v("iframe []contentDocument[] body > *",()=>{const e=document.getElementsByTagName("iframe");for(const t of e){"contentDocument"in t&&"body"in t.contentDocument&&a(t.contentDocument);const e=()=>a(t.contentDocument);t.addEventListener("load",e),this.eventsListeners.push([t,"onIframeLoad",e])}});return this.elementWaiters.push(c),a(document),e}clear(){this.triggerElements=this.triggerElements.filter(e=>(e.remove(),!1)),this.eventsListeners=this.eventsListeners.filter(e=>{const[t,...n]=e;return t&&n.length>1&&t.removeEventListener(...n),!1}),this.timeouts=this.timeouts.filter(e=>(clearTimeout(e),!1)),this.intervals=this.intervals.filter(e=>(clearInterval(e),!1));const e=c();return this.visibilityObservers=this.visibilityObservers.filter(t=>(t.clear(this.selector,e),!1)),this.promises=this.promises.filter(e=>(e.resolve(!1),!1)),this.elementWaiters=this.elementWaiters.filter(e=>(e(),!1)),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.getSocialProofDatas(e,"i",!0),socialProofPageViews:()=>this.getSocialProofDatas(e,"pv"),socialProofVisitors:()=>this.getSocialProofDatas(e,"v-pv")},n=!Object.prototype.hasOwnProperty.call(t,this.event)||await t[this.event]();return n&&this.clear(),"reengage"!==this.event&&this.delay?n&&await(async()=>{const e=h(`${this.event}Delay`);this.promises.push(e);const t=setTimeout(()=>{e.resolve(!0),this.clear()},this.delay);return this.timeouts.push(t),e.promise})():n}}const A="display",I="closing",B="validation",P="ABTastyWidgets",L=`${P}Temporary`;class N{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=o(),this.uniqueId=c(),this.recurrenceKey=`${this.widgetName}_${this.uniqueId}`,this.isListeningStorageEvent=this.listenStorageEvent(),this.pendingRecurrence=!1,this.pendingRecurrenceValue={}}onStorage({key:e}){const t=localStorage.getItem(L),n=sessionStorage.getItem(P);"ABTastyData"===e&&!t&&n&&localStorage.setItem(L,n)}listenStorageEvent(){return this.isListeningStorageEvent||window.addEventListener("storage",this.onStorage.bind(this)),!0}getGivenRecurrenceStorageParsed(e){try{const t=e.getItem(P);return JSON.parse(t)}catch(t){return e.removeItem(P),!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(P,JSON.stringify(i)),i):(e.removeItem(P),!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(L),t=!(!e||!e.includes(this.recurrenceKey))||this.getSessionRecurrence();e&&(sessionStorage.setItem(P,e),localStorage.removeItem(L));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 i=this.getTypeOfStorage(e);if(t()||!i&&"object"!=typeof i)return!1;const{storageString:s,storageMethod:o}=i,a=this.getStamp(e),c={type:n,stamp:a},{type:l}=this.getCurrentRecurrence(),h=async()=>{if(!r()){this.pendingRecurrence=!0,this.pendingRecurrenceValue=c;const e=new k({triggerEvent:"consent"});await e.isTriggered(),this.pendingRecurrence=!1,this.pendingRecurrenceValue={}}const e=this.getSessionRecurrence(),t=this.getLocalRecurrence();let n;"session"===s?e?n=this.removeSessionRecurrenceStorage():(this.removeLocalRecurrenceStorage(),n=this.getSessionRecurrenceStorageParsed()):"local"===s&&(t?n=this.removeLocalRecurrenceStorage():(this.removeSessionRecurrenceStorage(),n=this.getLocalRecurrenceStorageParsed()));const i=n?{[this.recurrenceKey]:c,...n}:{[this.recurrenceKey]:c};o.setItem(P,JSON.stringify(i)),this.onSetCallback&&"function"==typeof this.onSetCallback&&this.onSetCallback()};if(!o)return!1;if(l&&n!==B)if(n===I&&l!==B)h();else{if(n!==A||l===B||l===I)return!1;h()}else h();return a}setDisplayRecurrence(){const e=A;this.setRecurrence(this.displayRecurrence,e)}setClosingRecurrence(){const e=I;this.setRecurrence(this.closingRecurrence,e)}setValidationRecurrence(){const e=B;this.setRecurrence(this.validationRecurrence,e)}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 R{constructor(e,t,n){this.isWidgetApplied=e,this.callback=t,this.shouldUpdate=n,this.triggerIframeTarget=null,this.observer=new MutationObserver(this.observerHandler.bind(this)),this.tagRollbackEventParams=["abtasty_resetActionTracking",this.onTagRollback.bind(this)],this.onCampaignLaunchedEventParams=["abtasty_executedCampaign",this.onCampaignLaunched.bind(this)]}decisionHandler(e){const t=!e&&this.isWidgetApplied(),n=t?this.shouldUpdate&&S:C;return n?(this.clearWatcher(),this.callback(n,!e,t),this.watch(),this):this}onCampaignLaunched({detail:{campaignId:e}}){e===TEST_ID&&(this.callback(C,!1),this.watch())}onTagRollback({target:e}){return this.clearWatcher(e),this.callback(E,!1,!0),window.addEventListener(...this.onCampaignLaunchedEventParams),this}observerHandler(e){return s()?e.some(e=>["removedNodes","addedNodes"].some(t=>e[t]&&e[t].length))?this.decisionHandler():this:this.callback(E,!1)}watch(t,n){if(e())return this;if(this.clearWatcher(t),window.removeEventListener(...this.onCampaignLaunchedEventParams),document.addEventListener(...this.tagRollbackEventParams),n?.includes("[]contentDocument[]")){const e=n.split("[]")[0].trim(),{clear:t}=v(e,e=>{t(),this.triggerIframeTarget=e,e.addEventListener("load",this.decisionHandler.bind(this))})}const i=t?.defaultView?.frameElement;i&&this.triggerIframeTarget!==i&&i.addEventListener("load",this.decisionHandler.bind(this));const{clear:s}=v("body",e=>{s();const n=t?.body||t||e;this.observer.observe(n,{childList:!0,subtree:!0})});return this}clearTriggerElementWatcher(){this.triggerIframeTarget?.removeEventListener("load",this.decisionHandler.bind(this))}clearWatcher(e){return document.removeEventListener(...this.tagRollbackEventParams),this.observer.disconnect(),this.clearTriggerElementWatcher(),e?.defaultView?.frameElement?.removeEventListener("load",this.decisionHandler.bind(this)),this}}const D=/.+\/([^.]+)\.(otf|ttf)$/,_=["socialProofPurchases","socialProofPageViews","socialProofVisitors"];class O{constructor(t,n){this.children=void 0,this.uniqueId=`${c()}${n?`_${n}`:""}`,this.widgetName=o(),this.prettyName=a(),this.recurrenceParams=(()=>{const{displayRecurrence:t,closingRecurrence:n,validationRecurrence:i}=DATA,s=!t&&!n&&!i;if(e()||s)return!1;const r={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=r[t]("displayRecurrence")),n&&(o.closingRecurrence=r[n]("closingRecurrence")),i&&(o.validationRecurrence=r[i]("validationRecurrence")),o})(),this.triggerParams=(t=>{let{triggerEvent:n}=DATA;const{triggerEventClick:i,triggerEventHover:s,triggerEventReengageDelay:r,socialProofContentType:o,triggerEventElementVisible:a,triggerEventDelay:c}=DATA;if(e()||!n&&!o)return!1;const l={click:()=>i,hover:()=>s,elementVisible:()=>a},h=Object.prototype.hasOwnProperty.call(l,n)?l[n]():"body",d="reengage"===n?r:c;return o&&(n=[,"socialProofPurchases","socialProofPageViews","socialProofVisitors"][o]),{triggerEvent:n,triggerSelector:h,triggerDelay:d,triggerTarget:t}})(t),this.recurrence=!!this.recurrenceParams&&new N(this.recurrenceParams,this.clearGivenClearables.bind(this)),this.trigger=!!this.triggerParams&&new k(this.triggerParams),this.shouldUpdate=!!this.triggerParams&&_.includes(this.triggerParams.triggerEvent),this.pageWatcher=new R(this.isWidgetApplied.bind(this),this.onPageChange.bind(this)),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.rootElement=null,this.domElement=this.getDom(),this.hasBeenShown=!1,this.closedByUser=!1,this.elementsWaiters=[]}clearGivenClearables(){for(const e of this.elementsWaiters)e.clear();this.elementsWaiters=[]}isWidgetApplied(){return this.domElement?.isConnected&&this.domElement.ownerDocument?.defaultView}removeOldDomElement(){const e=this.rootElement?.getElementById(this.widgetContainerId);return e?.remove(),this}async insert(){if(this.isWidgetApplied())return!1;const e=["free"];"drawer"===DATA.layout&&DATA.customTarget&&e.push("drawer");const t=e.includes(DATA.layout);return new Promise(e=>{const{elementReferrer:n="body",referrerInsertType:i="beforeend"}=t?DATA:{},s=v(n,t=>{this.elementsWaiters=this.elementsWaiters.filter(e=>e.selector!==n),this.rootElement=t.getRootNode(),this.removeOldDomElement(),this.domElement.appendChild(this.styleElement),e(t.insertAdjacentElement(i,this.domElement))});this.elementsWaiters.push(s)}).then(()=>this)}remove(){this.trigger&&this.trigger.clear(),this.pageWatcher.clearWatcher(this.rootElement);for(const e of this.elementsWaiters)[DATA.elementReferrer,"body"].includes(e.selector)&&e.clear();return this.domElement?.isConnected&&this.domElement.remove(),this.hasOncePerPageTrigger?this.pageWatcher.watch(this.rootElement):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.rootElement),this}hide(t=!0){return!e()&&this.hasBeenShown&&t&&window.ABTastyEvent(`${this.prettyName} closed`,null,TEST_ID),t&&(this.pageWatcher.clearWatcher(this.rootElement),this.closedByUser=!0),this.domElement.classList.add(this.hideClassName),this}async init(t){const n=e(),i=s(),r=this.trigger?.promises?.length,o=!this.recurrence||this.recurrence.isOver();if(!n&&!i||r||!o)return{container:this,response:!1};this.pageWatcher.watch(this.rootElement||document,this.triggerParams.triggerSelector);const a=n||!this.trigger||this.trigger&&await this.trigger.isTriggered();this.pageWatcher.clearTriggerElementWatcher();const c={container:this,response:a};return a?(await this.insert(),this.addCloseEvent(),n||t||this.hasBeenShown||void 0===this.children||"function"!=typeof this.children.refreshContent||this.children.refreshContent(a),c):c}onPageChange(e,t,n){const i=()=>this.init().then(({response:e})=>{e?this.show():this.hide(!1)});t||(this.hasBeenShown=!1,n&&this.domElement.remove(),this.trigger&&this.trigger.clear());const s={[E]:()=>n?this.remove():this.pageWatcher.watch(this.rootElement),[C]:()=>{this.hasBeenShown?this.closedByUser?this.pageWatcher.watch(this.rootElement):n||this.insert().then(e=>e.show()).catch(this.pageWatcher.watch):i()},[S]:()=>{this.hasBeenShown?this.pageWatcher.watch():i()}};"function"==typeof s[e]&&s[e]()}addCloseEvent(...t){const{closeButton:n,overlay:i,overlayClickable:s,layout:r,animationDuration:o=1e3}=DATA,a=[];if(void 0!==i&&!0!==i||!0!==s||"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=>{f(e),this.recurrence&&this.recurrence.setClosingRecurrence(),this.hide(!0),setTimeout(()=>this.remove(),1.05*o)},{once:!0,capture:!0}];t.push(...c);for(const n of t)e()&&(n.dataset.abtastyActionnable="true"),n.removeEventListener(...l),n.addEventListener(...l);return this}getDom(){const{closeButton:e,layout:t,overlayClickable:n,overlay:i=!0}=DATA,s=document.createElement("div");return s.className=`${this.basicClassName} ${this.hideClassName}`,s.id=this.widgetContainerId,["popin","bannerTop","bannerBottom"].includes(t)&&(s.role="dialog"),s.innerHTML=`\n\t\t\t${"popin"===t&&!0===i?`<div ${n?'aria-label="Close dialog"':""} class="${this.overlayClassName}"></div>`:""}\n\t\t\t<div class="${this.contentClassName}">\n\t\t\t${e?`<button class="${this.closeButtonClassName}" aria-label="Close dialog"><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>`,s}loadFont(e,t){if(!e||"inherit"===e||!/otf|ttf/g.test(t))return;const n=document.createElement("style"),i=t.match(D)?t.match(D)[1]:"";n.innerHTML=`@font-face { font-family: '${e}_${i}'; src: url('${t}'); font-display: swap; }`;const s=this.rootElement?.head||document.head;s?.appendChild(n)}getStyleTag(t="",n=DATA){const{noStyles:i,layout:s}=n,{backgroundColor:r,isBackgroundImage:o,backgroundImage:a,backgroundSize:c,backgroundPosition:l,backgroundRepeat:h,borderColor:d,borderRadius:u,borderWidth:g,textColor:m,textAlign:p,fontName:v,fontStyle:y,fontSize:f,isTitle:b,titleTextAlign:w,titleTextColor:T,titleFontName:E,titleFontStyle:C,titleFontSize:S,overlay:x,overlayColor:k,dropShadow:A,dropShadowColor:I,dropShadowBlur:B,containerMargin:P,containerPadding:L,closeButton:N,closeButtonPosition:R,closeButtonSize:_,closeButtonBorderRadius:O,closeButtonBorderWidth:W,closeButtonBorderColor:V,closeButtonColor:j,closeButtonBackgroundColor:H,buttonsAlign:M,buttonsBorderWidth:q,buttonsBorderColor:F,buttonsBorderRadius:K,buttonsBackgroundColor:U,buttonsTextColor:z,buttonsFontName:Y,buttonsFontStyle:G,buttonsFontSize:J,secondLink:X,secondLinkBorderWidth:Q,secondLinkBorderColor:Z,secondLinkBorderRadius:ee,secondLinkBackgroundColor:te,secondLinkTextColor:ne,secondLinkFontName:ie,secondLinkFontStyle:se,secondLinkFontSize:re,animation:oe,animationDuration:ae,animationBehaviour:ce,animationSlideDirection:le}=i?{}:n,he=document.createElement("style");e()&&he.setAttribute("abtasty-script-added","true"),this.loadFont(v,y),this.loadFont(E,C),this.loadFont(Y,G),this.loadFont(ie,se);const de=`background: ${["string"==typeof r?r:"rgba(255, 255, 255, 1)",o&&"string"==typeof a&&a.length?`url(${a})`:"",o&&"string"==typeof l&&"100% 100%"!==c?l:"0 0",o&&"string"==typeof c?`/ ${c}`:"/ auto",o&&h&&!["cover","100% 100%"].includes(c)?"repeat":"no-repeat"].join(" ").trim()};`,ue="number"==typeof g&&g>0,ge=`border: ${[ue?`${g}px`:"unset",ue?"solid":"",ue&&"string"==typeof d&&d.length?d:""].join(" ").trim()};`,me=void 0!==u?`border-radius: ${u}px;`:"",pe=void 0!==m?`color: ${m}; fill: ${m}; -webkit-text-fill-color: ${m};`:"",ve=void 0!==p?`text-align: ${p};`:"",ye=v&&"inherit"!==v?`font-family:${v}_${y.match(D)?y.match(D)[1]:""};`:y||"",fe=f?`font-size: ${f}px;`:"",$e=void 0!==A&&A?`box-shadow: 0 5px ${B}px 0 ${I};`:"",be=P instanceof Array&&1===P.length&&P[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);`:"",Ee=L instanceof Array&&1===L.length&&L[0],Ce=Ee?`padding: ${Ee.top}px ${Ee.right}px ${Ee.bottom}px ${Ee.left}px;`:"",Se=Ee?`padding: calc(${Ee.top}px * 0.5) calc(${Ee.right}px * 0.5) calc(${Ee.bottom}px * 0.5) calc(${Ee.left}px * 0.5);`:"",xe=void 0!==q&&q?`border-width: ${q}px; border-style: solid;`:"",ke=[F,q].every(e=>void 0!==e)&&q?`border-color: ${F};`:"",Ae=void 0!==K?`border-radius: ${K}px;`:"",Ie=void 0!==U?`background-color: ${U};`:"",Be=void 0!==z?`color: ${z}; fill: ${z}; -webkit-text-fill-color: ${z};`:"",Pe=Y&&"inherit"!==Y?`font-family:${Y}_${G.match(D)?G.match(D)[1]:""};`:G||"",Le=J?`font-size: ${J}px;`:"",Ne="number"==typeof Q?`border-width: ${Q}px; border-style: solid;`:"",Re=[Z,Q].every(e=>void 0!==e)&&Q?`border-color: ${Z};`:"",De=void 0!==ee?`border-radius: ${ee}px;`:"",_e=void 0!==te?`background-color: ${te};`:"",Oe=void 0!==ne?`color: ${ne}; fill: ${ne}; -webkit-text-fill-color: ${ne};`:"",We=ie&&"inherit"!==ie?`font-family:${ie}_${se.match(D)?se.match(D)[1]:""};`:se||"",Ve=re?`font-size: ${re}px;`:"",je="popin"!==s||void 0!==x&&!0!==x?"":[`#${this.widgetContainerId} .${this.overlayClassName} {`,`background-color: ${void 0!==k?k:"rgba(0, 0, 0, 0.6)"};`,"}"].join(""),He="number"==typeof _?_:16,Me=He/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;","padding: 0;","margin: 0;","line-height: 0;","z-index: 9;","number"==typeof O?`border-radius: ${O}px;`:"","number"==typeof W&&W>0?`border: ${W}px solid ${void 0!==V?V:"rgba(57, 57, 57, 1)"};`:"","string"==typeof H?`background-color: ${H};`:"","}",`#${this.widgetContainerId} .${this.contentClassName} .${this.closeButtonClassName} svg {`,"pointer-events: none;",`width: ${He}px;`,`height: ${He}px;`,"string"==typeof j?`fill: ${j};`:"","}"].join(""):"",Fe=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};`:"",E&&"inherit"!==E?`font-family:${E}_${C.match(D)?C.match(D)[1]:""};`:C||"",S?`font-size: ${S}px;`:"","}"].join(""):"";let Ke="";if("string"==typeof oe){const t=(ae/1e3).toFixed(2),n=["top","bottom"].includes(le),i=Number(n),s=[(["top","left"].includes(le)?"-":"")+"100vmax",this.translateValues?this.translateValues[i]:"0"];n&&s.reverse(),Ke={none:[`.${this.hideClassName} {`,"opacity: 0 !important;","}"],fade:[`.${this.hideClassName} {`,"opacity: 0 !important;","}",`#${this.widgetContainerId} {`,`transition: opacity ${t}s ${ce};`,"}"],slide:[`.${this.hideClassName} .${this.overlayClassName} {`,"opacity: 0 !important;","}",`#${this.widgetContainerId} .${this.overlayClassName} {`,`transition: opacity ${t}s ${ce};`,"}",`.${this.hideClassName} .${this.contentClassName} {`,`transform: translate(${s.join(", ")}) !important;`,"}",`#${this.widgetContainerId} .${this.contentClassName} {`,`transition: transform ${t}s ${ce};`,"}"]}[e()&&!ABTASTY_S.WIDGETS.animationChanged?"none":oe].join("")}const Ue=[`#${this.widgetContainerId} .${this.contentClassName} .buttons_container .second_link {`,`margin-${"fill"===M?"top":"left"}: 8px;`,Ne,Re,De,_e,Oe,We,Ve,"}",`#${this.widgetContainerId} .${this.contentClassName} .buttons_container .second_link {`,Oe,We,Ve,"}"];return he.textContent=[`#${this.widgetContainerId} style { display: none; }`,`.${this.hideClassName} {`,"pointer-events: none;","}",`#${this.widgetContainerId} {`,"opacity: 1;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,de,me,ge,pe,ve,$e,we,ye,fe,"}",`#${this.widgetContainerId} .${this.contentClassName} p {`,pe,ve,ye,fe,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,"display: block;","line-height: 1;","text-indent: unset;",Ce,ye,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;",xe,ke,Ae,Ie,Be,Pe,Le,"}",`#${this.widgetContainerId} .${this.contentClassName} div.buttons_container a *:not(.second_link span), `,`#${this.widgetContainerId} .${this.contentClassName} button:not([class*="close_button"], [class*="csatEmojiButton"]) * {`,Be,Pe,Le,"}",...X?Ue:[],"@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,Te,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,Se,"}","}",je,qe,Fe,Ke,`${t}`].join(""),he}}const W={top:{top:0,left:50,translateX:-50,translateY:-100,translateOpenX:-50,translateOpenY:0},bottom:{top:100,left:50,translateX:-50,translateY:0,translateOpenX:-50,translateOpenY:-100},left:{top:50,left:0,translateX:-100,translateY:-50,translateOpenX:0,translateOpenY:-50},right:{top:50,right:0,translateX:100,translateY:-50,translateOpenX:0,translateOpenY:-50}},V={top:[!1,!1,!0,!0],bottom:[!0,!0,!1,!1],left:[!1,!0,!0,!1],right:[!0,!1,!1,!0]};class j extends O{constructor(){super(),this.button=this.setButton(),this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles),this.open=!1}toggleDrawer(){this.open=this.domElement.classList.toggle("drawer_open")}setButton(){const{mainButtonText:t,hasMainButtonIcon:n,mainButtonIcon:i,mainButtonIconAlt:s}=DATA,r=document.createElement("button");return r.className=`drawer_button_${this.uniqueId}`,e()&&(r.dataset.abtastyActionnable="true"),r.innerHTML=`<span>${t}</span>${n?`<img src="${i}" alt="${s}">`:""}`,e()&&top.document.documentElement.classList.contains("widget-react-form-opened")&&this.domElement.classList.add("drawer_open"),r.addEventListener("click",this.toggleDrawer.bind(this),!0),this.domElement.insertAdjacentElement("beforeend",r),r}getStyles(){const{buttonLayout:e,customTarget:t,elementReferrer:n,zindex:i,zindexCustom:s,styckyButtonBackgroundColor:r,styckyButtonIsBackgroundImage:o,styckyButtonBackgroundImage:a,styckyButtonBackgroundPosition:c,styckyButtonBackgroundRepeat:l,styckyButtonBackgroundSize:h,styckyButtonButtonsAlign:d,styckyButtonContainerMargin:u,styckyButtonContainerPadding:g,styckyButtonButtonsBorderWidth:m,styckyButtonButtonsBorderColor:p,styckyButtonButtonsBorderRadius:v,styckyButtonDropShadow:y,styckyButtonDropShadowBlur:f,styckyButtonDropShadowColor:b,styckyButtonTitleFontName:w,styckyButtonTitleFontStyle:T,styckyButtonTitleFontSize:E,styckyButtonTitleTextAlign:C,styckyButtonTitleTextColor:S,autoWidth:x,drawerLayout:k,hasMainButtonIcon:A,animationDuration:I,animationBehaviour:B}=DATA,{top:P,left:L,right:N,translateX:R,translateY:D,translateOpenX:_,translateOpenY:O}=W[e],j=["left","right"].includes(e),[{top:H,bottom:M,left:q,right:F}]=u,[{top:K,bottom:U,left:z,right:Y}]=g,G=V[e].map(e=>e?`${v}px`:"0").join(" "),J=`background: ${[r,o&&a.length?`url(${a})`:"",o&&"100% 100%"!==h?c:"0 0",o&&"string"==typeof h?`/ ${h}`:"/ auto",o&&l&&!["cover","100% 100%"].includes(h)?"repeat":"no-repeat"].join(" ").trim()};`,X=y?`box-shadow: 0 5px ${f}px 0 ${b};`:"",Q=`border: ${m>0?`${m}px solid ${p}`:"unset"};`,Z=/.+\/([^.]+)\.(otf|ttf)$/;this.loadFont(w,T);const ee=[`color: ${S}; fill: ${S}; -webkit-text-fill-color: ${S};`,`text-align: ${C};`,"inherit"!==w?`font-family:${w}_${T.match(Z)?T.match(Z)[1]:""};`:T||"",E?`font-size: ${E}px;`:""].join(""),te={left:"start",center:"center",right:"end"}[C],ne=t?n:"body",[ie,se,re]=ne.split("[]"),oe=re??ie,ae="shadowRoot"===se?":host":`${oe.trimEnd()}:not(:has(.fixed-drawer))`;return[`${oe} {`,"position: relative;","}",t?[`${ae} {`,`overflow-${j?"x":"y"}: hidden;`,"}"].join(""):"",`#${this.widgetContainerId} {`,"position: absolute;",`top: ${P}%;`,"number"==typeof L?`left: ${L}%;`:"","number"==typeof N?`right: ${N}%;`:"",`transform: translate(${R}%, ${D}%);`,`transition: transform ${(I/1e3).toFixed(2)}s ${B};`,"margin: 0;","padding: 0;","background: none;",`z-index: ${"custom"===i?s:i};`,(()=>{if(x)return t?`width: auto; height: auto; max-width: calc(100% - ${j?`${z+Y+1.5*E}px`:`${K+U+1.5*E}px`});`:`width: auto; height: auto; min-width: 30vw; max-width: ${["left","right"].includes(k)?"80vw":"40vw"};`;const{popinPercentWidth:e,popinPixelsWidth:n,widthUnit:i,autoHeight:s,popinPercentHeight:r,popinPixelsHeight:o,heightUnit:a}=DATA;return`width: ${"px"===i?n:e}${i};height: ${s?"auto":`${"px"===a?o:r}${a}`};`})(),"}",`#${this.widgetContainerId}.fixed-drawer {`,"position: fixed;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: relative;","width: 100%;","height: 100%;","}",`#${this.widgetContainerId}.drawer_open {`,`transform: translate(${_}%, ${O}%);`,"}",`.${this.button.className} {`,"position: absolute;",`${e}: 100%;`,["top","bottom"].includes(e)?[`${"right"===d?"right":"left"}: ${["left","right"].includes(d)?"0":"50%"};`,`transform: translate(${["left","right"].includes(d)?"0":"-50%"}, 0);`,`width: ${"fill"===d?"100%":"auto"};`].join(""):"",j?[`${"right"===d?"bottom":"top"}: ${["center","fill"].includes(d)?"50%":"0"};`,`transform: translate(0, ${["left","right"].includes(d)?"0":"-50%"});`,`height: ${"fill"===d?"100%":"auto"};`].join(""):"",`margin: ${H}px ${F}px ${M}px ${q}px;`,`padding: ${K}px ${Y}px ${U}px ${z}px;`,"text-wrap: nowrap;",J,Q,`border-radius: ${G};`,"display: flex;",`flex-direction: ${j?"column":"row"};`,"align-items: center;",`justify-content: ${te};`,X,"}",`.${this.button.className} span {`,j?["writing-mode: vertical-rl;","text-orientation: sideways;"].join(""):"","right"===e?"transform: rotate(180deg);":"","width: auto;",ee,"}",A?[`.${this.button.className} img {`,j?`transform: rotate(${e.includes("right")?"-":""}90deg);`:"",`min-width: ${2*E}px;`,`max-height: ${2*E}px;`,`margin-${j?"top":"left"}: ${E}px`,"}"].join(""):"","@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,x?"min-width: 40vw; max-width: 60vw;":"","}","}"].join("")}}class H{constructor(e){let{parentContainer:t}=e;this.parentContainer=t,this.className=`drawer_container_${t.uniqueId}`,this.domElement=this.getElement()}insertIn(e,t){this.setStyles(),e.insertAdjacentElement(t,this.domElement)}addRedirectionEvent(t){!e()&&t&&t.addEventListener("click",()=>{const{autoHide:t,timeHide:n}=DATA;t&&setTimeout(()=>{this.parentContainer.hide(),this.remove()},1e3*n),e()||this.parentContainer.recurrence.setValidationRecurrence()},{capture:!0,passive:!0})}addCloseEvent(t){t&&t.addEventListener("click",t=>{f(t),e()||this.parentContainer.recurrence.setClosingRecurrence(),this.parentContainer.hide(),setTimeout(()=>this.parentContainer.remove(),1e3)},{capture:!0,passive:!1})}buttonBuilder(e,t,n,i){let s=arguments.length>4&&void 0!==arguments[4]&&arguments[4];const r=document.createElement("a");return r.ariaLabel=e,r.innerHTML=`<span>${e}</span>`,r.href="button"===t?n:"#",s&&(r.className="second_link"),"button"===t?(r.target=i?"_blank":"_self",this.addRedirectionEvent(r)):(r.dataset.abtastyActionnable="true",this.addCloseEvent(r)),r}getButtons(){const{linkType:e,buttonText:t,redirectionUrl:n,openInNewTab:i,secondLink:s,secondLinkText:r,secondLinkType:o,secondLinkURL:a,secondLinkOpenInNewTab:c}=DATA,l=[this.buttonBuilder(t,e,n,i)];if(s){const e=this.buttonBuilder(r,o,a,c,s);l.push(e)}return l}getElement(){const{linkType:e,buttonText:t,redirectionUrl:n,isTitle:i,title:s,textContent:r,openInNewTab:o,drawerLayout:a,drawerImage:c}=DATA,l=document.createElement(e&&e.includes("widget")?"a":"div");l.className=this.className,"widget"===e?(l.href=n,l.target=o?"_blank":"_self",this.addRedirectionEvent(l)):"widgetClose"===e&&(l.href="#",l.dataset.abtastyActionnable="true",this.addCloseEvent(l)),l.innerHTML="textOnly"!==a?`<img src="${c}">`:"";const h=document.createElement("div");if(h.className="drawer_text_container","imageOnly"!==a&&(h.innerHTML=`\n\t\t\t${i?`<h2 class="drawer_title">${s}</h2>`:""}\n\t\t\t<p class="drawer_text">${r}</p>`),[e,t].every(e=>"string"==typeof e)&&e.includes("button")&&t.length){const e=this.getButtons(),t=document.createElement("div");t.className="buttons_container",e.forEach(e=>t.appendChild(e)),h.appendChild(t)}return l.appendChild(h),l}setStyles(){const{styleElement:e,widgetContainerId:t,contentClassName:n}=this.parentContainer,{linkType:i,buttonsAlign:s,drawerLayout:r}=DATA,o=`#${t} .${n}`,a=`${["left","right"].includes(r)?"row":"column"}${["right","bottom"].includes(r)?"-reverse":""}`,c=[`${o} .buttons_container {`,"display: inline-block;","width: 100%;",void 0!==s&&"fill"!==s?`text-align: ${s};`:"","}",`${o} .buttons_container a {`,"margin: 25px 0 0 0;","padding: 10px 22px;","line-height: 1;","max-width: 100%;",`width: ${"fill"===s?"100%":"auto"};`,"text-align: center;","}"].join(""),l=[`${o} .${this.className} {`,"display: flex;",`flex-direction: ${a};`,"justify-content: space-around;","align-items: center;","}",`.${this.className} > img {`,"max-width: 100%;","width: 100%;","height: auto;","}",["left","right"].includes(r)?[`${o} .${this.className} > * {`,"max-width: 46%;","}"].join(""):"",`${o} .drawer_title {`,"margin: 0 0 25px 0;","display: inline-block;","width: 100%;","}",`${o} .drawer_text_container {`,"line-height: 0;","white-space: pre-line;","display: inline-block;","vertical-align: middle;","width: 100%;","margin: 2vh 0;","}",`${o} .drawer_text_container * {`,"line-height: 1;","}",`${o} .drawer_text_container p {`,"margin: 0;","}"];i&&i.includes("button")&&l.push(c);const h=l.join("");return e.insertAdjacentText("beforeend",h),e}}!function(){l("Widget launch");const e=new j,t=e.domElement.querySelector(`.${e.contentClassName}`),n=new H({parentContainer:e});e.children=n,n.insertIn(t,"beforeend"),e.init(!0).then(t=>{let{response:n}=t;n&&(e.show(),(!0!==DATA.customTarget||u(DATA.elementReferrer).matches("body"))&&e.domElement.classList.add("fixed-drawer"))})}()}();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@abtasty/drawer",
3
3
  "description": "Drawer widget",
4
- "version": "0.0.31",
4
+ "version": "0.0.32-0",
5
5
  "form": "dist/form.js",
6
6
  "main": "dist/main.js",
7
7
  "type": "module",
@@ -43,5 +43,6 @@
43
43
  "postcss-cssnext": "^3.1.1",
44
44
  "rollup": "^4.12.0",
45
45
  "rollup-plugin-postcss": "^4.0.2"
46
- }
46
+ },
47
+ "stableVersion": "0.0.31"
47
48
  }