@abtasty/drawer 0.0.36 → 0.0.37
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.
- package/dist/form.js +1 -1
- package/dist/main.js +1 -1
- package/package.json +1 -1
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}`),r=()=>!e()&&(t()||!!window.ABTasty.getTestsOnPage()[TEST_ID]),o=()=>window.ABTasty&&!0===window.ABTasty.consentReady,s=()=>{const{type:e}=DATA;return`${PACKAGE.replace("@abtasty/","")}${e?`_${e}`:""}`},a=()=>{const e=s();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})(),r=window.document.cookie.includes("abTastyDebug=")||!0===window.abTastyDebug;if(i||r){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,r,o]=e.split("[]").map(e=>e.trim()),s=Boolean(o)?o:e,a=r?document.querySelector(i)?.[r]:document;return a?t?[...a.querySelectorAll(s)]:a.querySelector(s):n},u=e=>d(e,!1),g=e=>d(e,!0),m=(e,t)=>{const n={childList:!0,subtree:!0,attributes:!0},i=()=>r.disconnect(),r=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;r.observe(i,n)}}},p=()=>{},v=(t,n)=>{const i=u(t),r={selector:t,clear:p,observe:p};if(i)return setTimeout(()=>n(i),0),r;if(e())return setTimeout(()=>v(t,n),1e3),r;if(t.includes("[]"))return((e,t)=>{const[n,i]=t.split("[]").map(e=>e.trim()),r=u(n),o=r?.[i],{clear:s,observe:a}=m(e,t),c=()=>{const n=u(t);return n&&!l()&&e(n)},l=()=>{s(),r?.removeEventListener("load",c)},h=()=>{a(o),"iframe"===r?.localName&&r.addEventListener("load",c)};return h(),{selector:t,clear:l,observe:h}})(n,t);const{clear:o,observe:s}=m(n,t);return s(),{selector:t,clear:o,observe:s}};function f(e,t){const n=e.parentElement||e.getRootNode().host;return t(e)||!n?e:f(n,t)}const y=t=>{e()||(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation())},b=(e,t)=>[...g(t)].some(n=>{const[i,,r]=t.split("[]"),o=r??i;return n===e||!!e.closest(o)});let w=!1;class E{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[r,,o]=i.split("[]"),s=o??r,a=[...e.querySelectorAll(s)];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(s)].includes(n)))return!0}return!1});if(n&&this.isElementVisible(n.element)){const{selector:e,element:t,uniqueId:i}=n,r=this.targets.find(t=>t.selector===e&&t.uniqueId===i);r&&r.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"===f(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,r=0;for(;!i&&r<n.length;){const t=e.getRootNode()?.elementFromPoint(...n[r]);i=e===t||t?.contains(e)||e.contains(t),r+=1}return i}checkElements(){this.targets.forEach(({selector:e,uniqueId:t})=>{const n=u(e),[i,,r]=e.split("[]"),o=r??i;n&&!this.existingTargets.find(e=>e.element.matches(o)&&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,,r]=e.split("[]"),o=r??i;if(t.matches(o)&&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 T="remove",S="rebuild",C="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 E;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[r,,o]=this.selector.split("[]"),s=o??r;t.innerHTML=`${s} {\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)),r=["mouseenter",n,{passive:!0,capture:!0}];this.eventsListeners.push([i,...r]),i.addEventListener(...r)});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 r=[...document.querySelectorAll("*:empty")].map(e=>e.contentDocument||e.shadowRoot).filter(e=>e),o=[({isTrusted:e})=>{e&&(i=n)},{passive:!0}];["click","mousemove","scroll","keypress"].forEach(e=>{[document,...r].forEach(t=>{this.eventsListeners.push([t,e,...o]),t.addEventListener(e,...o)})});const s=setInterval(()=>{i<=0?t(!0):i-=100},100);return this.intervals.push(s),e}onCustomTrigger({promise:e,resolve:t}){const{triggerEventCustomScript:n,tagIsSafeEval:i}=DATA,r=i&&DATA_JS?.triggerEventCustomScript,o="function"==typeof r?()=>new Promise(e=>r(e)):new Function(`return new Promise(async resolve => {${n}})`);return o().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 r=(()=>{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:o,spNoTrim:s}=DATA;if(this.socialProofStore.hasOwnProperty(e))n(this.socialProofStore[e])?i(`${this.socialProofStore[e][o]}`):i(!1);else if(e&&r){const a=t=>(this.socialProofStore[e]=t,i(!!n(t)&&`${t[o]}`));fetch(`https://api-social-proof.abtasty.com/clients/${r}/metrics/${t}?key=${e}${s?"&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},r,o=!1){const{productKey:s,keyType:a}=(()=>{const{socialProofContentType:e,productKeyProvider:t,pathToProductKey:r,customJSProductKey:o,productSKU:s,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 ${r};`);break;case"customJSProductKey":a="function"==typeof l?l():n(o);break;case"productSKU":a=s}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}[r];return[typeof c,typeof g].includes("undefined")&&t(!1),o&&!s&&(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(s,"v-pv"===r&&"sku"===a?"v-i":r,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(!o()){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 r=()=>JSON.parse(i)?.ActionTracking?.some(({name:e})=>e===n),o=["storage",({key:e,newValue:n})=>{e===x&&(i=n,r()&&t(!0))},{passive:!0,capture:!0}];return i&&r()?t(!0):(()=>{this.eventsListeners.push([window,...o]),window.addEventListener(...o)})(),e}onMinPagesViewed({promise:e,resolve:t}){const{triggerEventMinPagesViewed:n}=DATA;let i=localStorage.getItem(x);const r=()=>n<=(i?JSON.parse(i)?.VisitedPages?.length:0),o=["storage",({key:e,newValue:n})=>{e===x&&(i=n,r()&&t(!0))},{passive:!0,capture:!0}];return i&&r()?t(!0):(()=>{this.eventsListeners.push([window,...o]),window.addEventListener(...o)})(),e}onRageClick({promise:e,resolve:t}){const{triggerEventRageClickQuantity:n,triggerEventRageClickDelay:i}=DATA;let r=0,o=!1;const s=["click",({isTrusted:e})=>{if(e&&(r+=1,r>=n&&t(!0),!o)){o=!0;const e=setTimeout(()=>{r=0,o=!1},i);this.timeouts.push(e)}},{passive:!0,capture:!0}],a=e=>{this.eventsListeners.push([e,...s]),e.addEventListener(...s)},{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",P="closing",I="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=s(),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:r,storageMethod:s}=i,a=this.getStamp(e),c={type:n,stamp:a},{type:l}=this.getCurrentRecurrence(),h=async()=>{if(!o()){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"===r?e?n=this.removeSessionRecurrenceStorage():(this.removeLocalRecurrenceStorage(),n=this.getSessionRecurrenceStorageParsed()):"local"===r&&(t?n=this.removeLocalRecurrenceStorage():(this.removeSessionRecurrenceStorage(),n=this.getLocalRecurrenceStorageParsed()));const i=n?{[this.recurrenceKey]:c,...n}:{[this.recurrenceKey]:c};s.setItem(B,JSON.stringify(i)),this.onSetCallback&&"function"==typeof this.onSetCallback&&this.onSetCallback()};if(!s)return!1;if(l&&n!==I)if(n===P&&l!==I)h();else{if(n!==A||l===I||l===P)return!1;h()}else h();return a}setDisplayRecurrence(){const e=A;this.setRecurrence(this.displayRecurrence,e)}setClosingRecurrence(){const e=P;this.setRecurrence(this.closingRecurrence,e)}setValidationRecurrence(){const e=I;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&&C:S;return n?(this.clearWatcher(),this.callback(n,!e,t),this.watch(),this):this}onCampaignLaunched({detail:{campaignId:e}}){e===TEST_ID&&(this.callback(S,!1),this.watch())}onTagRollback({target:e}){return this.clearWatcher(e),this.callback(T,!1,!0),window.addEventListener(...this.onCampaignLaunchedEventParams),this}observerHandler(e){return r()?e.some(e=>["removedNodes","addedNodes"].some(t=>e[t]&&e[t].length))?this.decisionHandler():this:this.callback(T,!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:r}=v("body",e=>{r();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 O=/.+\/([^.]+)\.(otf|ttf)$/,D=["socialProofPurchases","socialProofPageViews","socialProofVisitors"];class _{constructor(t,n){this.children=void 0,this.uniqueId=`${c()}${n?`_${n}`:""}`,this.widgetName=s(),this.prettyName=a(),this.recurrenceParams=(()=>{const{displayRecurrence:t,closingRecurrence:n,validationRecurrence:i}=DATA,r=!t&&!n&&!i;if(e()||r)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`]},s={};return t&&(s.displayRecurrence=o[t]("displayRecurrence")),n&&(s.closingRecurrence=o[n]("closingRecurrence")),i&&(s.validationRecurrence=o[i]("validationRecurrence")),s})(),this.triggerParams=(t=>{let{triggerEvent:n}=DATA;const{triggerEventClick:i,triggerEventHover:r,triggerEventReengageDelay:o,socialProofContentType:s,triggerEventElementVisible:a,triggerEventDelay:c}=DATA;if(e()||!n&&!s)return!1;const l={click:()=>i,hover:()=>r,elementVisible:()=>a},h=Object.prototype.hasOwnProperty.call(l,n)?l[n]():"body",d="reengage"===n?o:c;return s&&(n=[,"socialProofPurchases","socialProofPageViews","socialProofVisitors"][s]),{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&&D.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.websiteFocusedElement=null,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:{},r=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(r)}).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(){const{layout:t,overlay:n=!0}=DATA;return e()||this.hasBeenShown&&this.hasOncePerPageTrigger||window.ABTastyEvent(`${this.prettyName} displayed`,null,TEST_ID),this.closedByUser=!1,this.websiteFocusedElement=document.activeElement,setTimeout(()=>{this.domElement.classList.remove(this.hideClassName),e()||"popin"!==t||!0!==n||this.domElement.querySelector('input[type="text"], textarea, a, button')?.focus()},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),!e()&&this.websiteFocusedElement?.isConnected&&this.websiteFocusedElement.focus(),this}async init(t){const n=e(),i=r(),o=this.trigger?.promises?.length,s=!this.recurrence||this.recurrence.isOver();if(!n&&!i||o||!s)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 r={[T]:()=>n?this.remove():this.pageWatcher.watch(this.rootElement),[S]:()=>{this.hasBeenShown?this.closedByUser?this.pageWatcher.watch(this.rootElement):n||this.insert().then(e=>e.show()).catch(this.pageWatcher.watch):i()},[C]:()=>{this.hasBeenShown?this.pageWatcher.watch():i()}};"function"==typeof r[e]&&r[e]()}addCloseEvent(...t){const{closeButton:n,overlay:i,overlayClickable:r,layout:o,animationDuration:s=1e3}=DATA,a=[];if(void 0!==i&&!0!==i||!0!==r||"popin"!==o||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=e=>{const t="click"===e.type,n="keyup"===e.type&&"Escape"===e.code&&e.isTrusted;(t||n)&&(y(e),this.recurrence&&this.recurrence.setClosingRecurrence(),this.hide(!0),setTimeout(()=>this.remove(),1.05*s))},h=["click",l,{once:!0,capture:!0}];t.push(...c);for(const n of t)e()&&(n.dataset.abtastyActionnable="true"),n.removeEventListener(...h),n.addEventListener(...h);return window.removeEventListener("keyup",l,{once:!0}),window.addEventListener("keyup",l,{once:!0}),this}getDom(){const{closeButton:e,layout:t,overlayClickable:n,overlay:i=!0}=DATA,r=document.createElement("div");return r.className=`${this.basicClassName} ${this.hideClassName}`,r.id=this.widgetContainerId,["popin","bannerTop","bannerBottom"].includes(t)&&(r.role="dialog","popin"===t&&!0===i&&(r.ariaModal="true")),r.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>`,r}loadFont(e,t){if(!e||"inherit"===e||!/otf|ttf/g.test(t))return;const n=document.createElement("style"),i=t.match(O)?t.match(O)[1]:"";n.innerHTML=`@font-face { font-family: '${e}_${i}'; src: url('${t}'); font-display: swap; }`;const r=this.rootElement?.head||document.head;r?.appendChild(n)}getStyleTag(t="",n=DATA){const{noStyles:i,layout:r}=n,{backgroundColor:o,isBackgroundImage:s,backgroundImage:a,backgroundSize:c,backgroundPosition:l,backgroundRepeat:h,borderColor:d,borderRadius:u,borderWidth:g,textColor:m,textAlign:p,fontName:v,fontStyle:f,fontSize:y,isTitle:b,titleTextAlign:w,titleTextColor:E,titleFontName:T,titleFontStyle:S,titleFontSize:C,overlay:x,overlayColor:k,dropShadow:A,dropShadowColor:P,dropShadowBlur:I,containerMargin:B,containerPadding:L,closeButton:N,closeButtonPosition:R,closeButtonSize:D,closeButtonBorderRadius:_,closeButtonBorderWidth:j,closeButtonBorderColor:W,closeButtonColor:V,closeButtonBackgroundColor:H,buttonsAlign:M,buttonsBorderWidth:F,buttonsBorderColor:q,buttonsBorderRadius:U,buttonsBackgroundColor:K,buttonsTextColor:z,buttonsFontName:Y,buttonsFontStyle:G,buttonsFontSize:J,secondLink:X,secondLinkBorderWidth:Q,secondLinkBorderColor:Z,secondLinkBorderRadius:ee,secondLinkBackgroundColor:te,secondLinkTextColor:ne,secondLinkFontName:ie,secondLinkFontStyle:re,secondLinkFontSize:oe,animation:se,animationDuration:ae,animationBehaviour:ce,animationSlideDirection:le}=i?{}:n,he=document.createElement("style");e()&&he.setAttribute("abtasty-script-added","true"),this.loadFont(v,f),this.loadFont(T,S),this.loadFont(Y,G),this.loadFont(ie,re);const de=`background: ${["string"==typeof o?o:"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&&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};`:"",fe=v&&"inherit"!==v?`font-family:${v}_${f.match(O)?f.match(O)[1]:""};`:f||"",ye=y?`font-size: ${y}px;`:"",be=void 0!==A&&A?`box-shadow: 0 5px ${I}px 0 ${P};`:"",we=B instanceof Array&&1===B.length&&B[0],Ee=we?`margin: ${we.top}px ${we.right}px ${we.bottom}px ${we.left}px;`:"",Te=we?`margin: calc(${we.top}px * 0.5) calc(${we.right}px * 0.5) calc(${we.bottom}px * 0.5) calc(${we.left}px * 0.5);`:"",$e=L instanceof Array&&1===L.length&&L[0],Se=$e?`padding: ${$e.top}px ${$e.right}px ${$e.bottom}px ${$e.left}px;`:"",Ce=$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);`:"",xe=void 0!==F&&F?`border-width: ${F}px; border-style: solid;`:"",ke=[q,F].every(e=>void 0!==e)&&F?`border-color: ${q};`:"",Ae=void 0!==U?`border-radius: ${U}px;`:"",Pe=void 0!==K?`background-color: ${K};`:"",Ie=void 0!==z?`color: ${z}; fill: ${z}; -webkit-text-fill-color: ${z};`:"",Be=Y&&"inherit"!==Y?`font-family:${Y}_${G.match(O)?G.match(O)[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};`:"",Oe=void 0!==ee?`border-radius: ${ee}px;`:"",De=void 0!==te?`background-color: ${te};`:"",_e=void 0!==ne?`color: ${ne}; fill: ${ne}; -webkit-text-fill-color: ${ne};`:"",je=ie&&"inherit"!==ie?`font-family:${ie}_${re.match(O)?re.match(O)[1]:""};`:re||"",We=oe?`font-size: ${oe}px;`:"",Ve="popin"!==r||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 D?D:16,Me=He/2,Fe=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 _?`border-radius: ${_}px;`:"","number"==typeof j&&j>0?`border: ${j}px solid ${void 0!==W?W:"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 V?`fill: ${V};`:"","}"].join(""):"",qe=b&&"string"==typeof E?[`#${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: ${E}; fill: ${E}; -webkit-text-fill-color: ${E};`,void 0!==w?`text-align: ${w};`:"",T&&"inherit"!==T?`font-family:${T}_${S.match(O)?S.match(O)[1]:""};`:S||"",C?`font-size: ${C}px;`:"","}"].join(""):"";let Ue="";if("string"==typeof se){const t=(ae/1e3).toFixed(2),n=["top","bottom"].includes(le),i=Number(n),r=[(["top","left"].includes(le)?"-":"")+"100vmax",this.translateValues?this.translateValues[i]:"0"];n&&r.reverse(),Ue={none:[`.${this.hideClassName} {`,"opacity: 0 !important;","}"],fade:[`.${this.hideClassName} {`,"opacity: 0 !important;","}",`#${this.widgetContainerId} {`,`transition: opacity ${t}s ${ce};`,"}","@media (prefers-reduced-motion: reduce) {",`#${this.widgetContainerId} {`,"transition: unset;","}","}"],slide:[`.${this.hideClassName} .${this.overlayClassName} {`,"opacity: 0 !important;","}",`#${this.widgetContainerId} .${this.overlayClassName} {`,`transition: opacity ${t}s ${ce};`,"}",`.${this.hideClassName} .${this.contentClassName} {`,`transform: translate(${r.join(", ")}) !important;`,"}",`#${this.widgetContainerId} .${this.contentClassName} {`,`transition: transform ${t}s ${ce};`,"}","@media (prefers-reduced-motion: reduce) {",`#${this.widgetContainerId} .${this.overlayClassName},`,`.${this.hideClassName} .${this.contentClassName},`,`#${this.widgetContainerId} .${this.contentClassName} {`,"transition: unset;","}","}"]}[e()&&!ABTASTY_S.WIDGETS.animationChanged?"none":se].join("")}const Ke=[`#${this.widgetContainerId} .${this.contentClassName} .buttons_container .second_link {`,`margin-${"fill"===M?"top":"left"}: 8px;`,Ne,Re,Oe,De,_e,je,We,"}",`#${this.widgetContainerId} .${this.contentClassName} .buttons_container .second_link {`,_e,je,We,"}"];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,be,Ee,fe,ye,"}",`#${this.widgetContainerId} .${this.contentClassName} p {`,pe,ve,fe,ye,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,"display: block;","line-height: 1;","text-indent: unset;",Se,fe,ye,"}",`#${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,Pe,Ie,Be,Le,"}",`#${this.widgetContainerId} .${this.contentClassName} div.buttons_container a *:not(.second_link span), `,`#${this.widgetContainerId} .${this.contentClassName} button:not([class*="close_button"], [class*="csatEmojiButton"]) * {`,Ie,Be,Le,"}",...X?Ke:[],"@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,Te,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,Ce,"}","}",Ve,Fe,qe,Ue,`${t}`].join(""),he}}function j(e){return j="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},j(e)}function W(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var i,r,o,s,a=[],c=!0,l=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;c=!1}else for(;!(c=(i=o.call(n)).done)&&(a.push(i.value),a.length!==t);c=!0);}catch(e){l=!0,r=e}finally{try{if(!c&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(l)throw r}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return V(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?V(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function V(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function H(e){var t=function(e){if("object"!=j(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=j(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==j(t)?t:t+""}function M(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(M=function(){return!!e})()}function F(e){return F=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},F(e)}function q(e,t){return q=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},q(e,t)}var U={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}},K={top:[!1,!1,!0,!0],bottom:[!0,!0,!1,!1],left:[!1,!0,!0,!1],right:[!0,!1,!1,!0]},z=function(t){function n(){var e,t,i;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),(t=this,i=n,i=F(i),e=function(e,t){if(t&&("object"==j(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(t,M()?Reflect.construct(i,[],F(t).constructor):i.apply(t,undefined))).button=e.setButton(),e.stringStyles=e.getStyles(),e.styleElement=e.getStyleTag(e.stringStyles),e.open=!1,e}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&q(e,t)}(n,t),i=n,r=[{key:"toggleDrawer",value:function(){this.open=this.domElement.classList.toggle("drawer_open")}},{key:"setButton",value:function(){var t=DATA,n=t.mainButtonText,i=t.hasMainButtonIcon,r=t.mainButtonIcon,o=t.mainButtonIconAlt,s=document.createElement("button");return s.className="drawer_button_".concat(this.uniqueId),e()&&(s.dataset.abtastyActionnable="true"),s.innerHTML="<span>".concat(n,"</span>").concat(i?'<img src="'.concat(r,'" alt="').concat(o,'">'):""),e()&&top.document.documentElement.classList.contains("widget-react-form-opened")&&this.domElement.classList.add("drawer_open"),s.addEventListener("click",this.toggleDrawer.bind(this),!0),this.domElement.insertAdjacentElement("beforeend",s),s}},{key:"getStyles",value:function(){var e=DATA,t=e.buttonLayout,n=e.customTarget,i=e.elementReferrer,r=e.zindex,o=e.zindexCustom,s=e.styckyButtonBackgroundColor,a=e.styckyButtonIsBackgroundImage,c=e.styckyButtonBackgroundImage,l=e.styckyButtonBackgroundPosition,h=e.styckyButtonBackgroundRepeat,d=e.styckyButtonBackgroundSize,u=e.styckyButtonButtonsAlign,g=e.styckyButtonContainerMargin,m=e.styckyButtonContainerPadding,p=e.styckyButtonButtonsBorderWidth,v=e.styckyButtonButtonsBorderColor,f=e.styckyButtonButtonsBorderRadius,y=e.styckyButtonDropShadow,b=e.styckyButtonDropShadowBlur,w=e.styckyButtonDropShadowColor,E=e.styckyButtonTitleFontName,T=e.styckyButtonTitleFontStyle,S=e.styckyButtonTitleFontSize,C=e.styckyButtonTitleTextAlign,x=e.styckyButtonTitleTextColor,k=e.autoWidth,A=e.drawerLayout,P=e.hasMainButtonIcon,I=e.animationDuration,B=e.animationBehaviour,L=U[t],N=L.top,R=L.left,O=L.right,D=L.translateX,_=L.translateY,j=L.translateOpenX,V=L.translateOpenY,H=["left","right"].includes(t),M=W(g,1)[0],F=M.top,q=M.bottom,z=M.left,Y=M.right,G=W(m,1)[0],J=G.top,X=G.bottom,Q=G.left,Z=G.right,ee=K[t].map(function(e){return e?"".concat(f,"px"):"0"}).join(" "),te=[s,a&&c.length?"url(".concat(c,")"):"",a&&"100% 100%"!==d?l:"0 0",a&&"string"==typeof d?"/ ".concat(d):"/ auto",a&&h&&!["cover","100% 100%"].includes(d)?"repeat":"no-repeat"],ne="background: ".concat(te.join(" ").trim()," !important;"),ie=y?"box-shadow: 0 5px ".concat(b,"px 0 ").concat(w,";"):"",re="border: ".concat(p>0?"".concat(p,"px solid ").concat(v):"unset",";"),oe=/.+\/([^.]+)\.(otf|ttf)$/;this.loadFont(E,T);var se=["color: ".concat(x,"; fill: ").concat(x,"; -webkit-text-fill-color: ").concat(x,";"),"text-align: ".concat(C,";"),"inherit"!==E?"font-family:".concat(E,"_").concat(T.match(oe)?T.match(oe)[1]:"",";"):T||"",S?"font-size: ".concat(S,"px;"):""].join(""),ae={left:"start",center:"center",right:"end"}[C],ce=W((n?i:"body").split("[]"),3),le=ce[0],he=ce[1],de=ce[2],ue=null!=de?de:le,ge="shadowRoot"===he?":host":"".concat(ue.trimEnd(),":not(:has(.fixed-drawer))"),me=n?["".concat(ge," {"),"overflow-".concat(H?"x":"y",": hidden;"),"}"].join(""):"";return["".concat(ue," {"),"position: relative;","}",me,"#".concat(this.widgetContainerId," {"),"position: absolute;","top: ".concat(N,"%;"),"number"==typeof R?"left: ".concat(R,"%;"):"","number"==typeof O?"right: ".concat(O,"%;"):"","transform: translate(".concat(D,"%, ").concat(_,"%);"),"transition: transform ".concat((I/1e3).toFixed(2),"s ").concat(B,";"),"margin: 0;","padding: 0;","background: none;","z-index: ".concat("custom"===r?o:r,";"),function(){if(k)return n?"width: auto; height: auto; max-width: calc(100% - ".concat("".concat(H?Q+Z+1.5*S:J+X+1.5*S,"px"),");"):"width: auto; height: auto; min-width: 30vw; max-width: ".concat(["left","right"].includes(A)?"80vw":"40vw",";");var e=DATA,t=e.popinPercentWidth,i=e.popinPixelsWidth,r=e.widthUnit,o=e.autoHeight,s=e.popinPercentHeight,a=e.popinPixelsHeight,c=e.heightUnit,l="px"===c?a:s;return"width: ".concat("px"===r?i:t).concat(r,";height: ").concat(o?"auto":"".concat(l).concat(c),";")}(),"}","@media (prefers-reduced-motion: reduce) {","#".concat(this.widgetContainerId," {"),"transition: unset;","}","}","#".concat(this.widgetContainerId,".fixed-drawer {"),"position: fixed;","}","#".concat(this.widgetContainerId," .").concat(this.contentClassName," {"),"position: relative;","width: 100%;","height: 100%;","box-sizing: border-box;","}","#".concat(this.widgetContainerId,".drawer_open {"),"transform: translate(".concat(j,"%, ").concat(V,"%);"),"}",".".concat(this.button.className," {"),"position: absolute;","".concat(t,": 100%;"),["top","bottom"].includes(t)?["".concat("right"===u?"right":"left",": ").concat(["left","right"].includes(u)?"0":"50%",";"),"transform: translate(".concat(["left","right"].includes(u)?"0":"-50%",", 0);"),"width: ".concat("fill"===u?"100%":"auto",";")].join(""):"",H?["".concat("right"===u?"bottom":"top",": ").concat(["center","fill"].includes(u)?"50%":"0",";"),"transform: translate(0, ".concat(["left","right"].includes(u)?"0":"-50%",");"),"height: ".concat("fill"===u?"100%":"auto",";")].join(""):"","margin: ".concat(F,"px ").concat(Y,"px ").concat(q,"px ").concat(z,"px;"),"padding: ".concat(J,"px ").concat(Z,"px ").concat(X,"px ").concat(Q,"px;"),"text-wrap: nowrap;",ne,re,"border-radius: ".concat(ee,";"),"display: flex;","flex-direction: ".concat(H?"column":"row",";"),"align-items: center;","justify-content: ".concat(ae,";"),ie,"}",".".concat(this.button.className," span {"),H?["writing-mode: vertical-rl;","text-orientation: sideways;"].join(""):"","right"===t?"transform: rotate(180deg);":"","width: auto;",se,"}",P?[".".concat(this.button.className," img {"),H?"transform: rotate(".concat(t.includes("right")?"-":"","90deg);"):"","min-width: ".concat(2*S,"px;"),"max-height: ".concat(2*S,"px;"),"margin-".concat(H?"top":"left",": ").concat(S,"px"),"}"].join(""):"","@media screen and (max-width: 579px) {","#".concat(this.widgetContainerId," .").concat(this.contentClassName," {"),k?"min-width: 40vw; max-width: 60vw;":"","}","}"].join("")}}],r&&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,H(i.key),i)}}(i.prototype,r),Object.defineProperty(i,"prototype",{writable:!1}),i;var i,r}(_);function Y(e){return Y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Y(e)}function G(e){var t=function(e){if("object"!=Y(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=Y(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Y(t)?t:t+""}var J=function(){return t=function e(t){var n=t.parentContainer;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.parentContainer=n,this.className="drawer_container_".concat(n.uniqueId),this.domElement=this.getElement()},n=[{key:"insertIn",value:function(e,t){this.setStyles(),e.insertAdjacentElement(t,this.domElement)}},{key:"addRedirectionEvent",value:function(t){var n=this;!e()&&t&&t.addEventListener("click",function(){var t=DATA,i=t.autoHide,r=t.timeHide;i&&setTimeout(function(){n.parentContainer.hide(),n.remove()},1e3*r),e()||n.parentContainer.recurrence.setValidationRecurrence()},{capture:!0,passive:!0})}},{key:"addCloseEvent",value:function(t){var n=this;t&&t.addEventListener("click",function(t){y(t),e()||n.parentContainer.recurrence.setClosingRecurrence(),n.parentContainer.hide(),setTimeout(function(){return n.parentContainer.remove()},1e3)},{capture:!0,passive:!1})}},{key:"buttonBuilder",value:function(e,t,n,i){var r=arguments.length>4&&void 0!==arguments[4]&&arguments[4],o=document.createElement("a");return o.ariaLabel=e,o.innerHTML="<span>".concat(e,"</span>"),o.href="button"===t?n:"#",r&&(o.className="second_link"),"button"===t?(o.target=i?"_blank":"_self",this.addRedirectionEvent(o)):(o.dataset.abtastyActionnable="true",this.addCloseEvent(o)),o}},{key:"getButtons",value:function(){var e=DATA,t=e.linkType,n=e.buttonText,i=e.redirectionUrl,r=e.openInNewTab,o=e.secondLink,s=e.secondLinkText,a=e.secondLinkType,c=e.secondLinkURL,l=e.secondLinkOpenInNewTab,h=[this.buttonBuilder(n,t,i,r)];if(o){var d=this.buttonBuilder(s,a,c,l,o);h.push(d)}return h}},{key:"getElement",value:function(){var e=DATA,t=e.linkType,n=e.buttonText,i=e.redirectionUrl,r=e.isTitle,o=e.title,s=e.textContent,a=e.openInNewTab,c=e.drawerLayout,l=e.drawerImage,h=e.altDesc,d=document.createElement(t&&t.includes("widget")?"a":"div");d.className=this.className,"widget"===t?(d.href=i,d.target=a?"_blank":"_self",this.addRedirectionEvent(d)):"widgetClose"===t&&(d.href="#",d.dataset.abtastyActionnable="true",this.addCloseEvent(d)),d.innerHTML="".concat("textOnly"!==c?'<img src="'.concat(l,'" ').concat("string"==typeof h?'alt="'.concat(h,'"'):"",">"):"");var u=document.createElement("div");if(u.className="drawer_text_container","imageOnly"!==c&&(u.innerHTML="\n\t\t\t".concat(r?'<h2 class="drawer_title">'.concat(o,"</h2>"):"",'\n\t\t\t<p class="drawer_text">').concat(s,"</p>")),[t,n].every(function(e){return"string"==typeof e})&&t.includes("button")&&n.length){var g=this.getButtons(),m=document.createElement("div");m.className="buttons_container",g.forEach(function(e){return m.appendChild(e)}),u.appendChild(m)}return d.appendChild(u),d}},{key:"setStyles",value:function(){var e=this.parentContainer,t=e.styleElement,n=e.widgetContainerId,i=e.contentClassName,r=DATA,o=r.linkType,s=r.buttonsAlign,a=r.drawerLayout,c="#".concat(n," .").concat(i),l="".concat(["left","right"].includes(a)?"row":"column").concat(["right","bottom"].includes(a)?"-reverse":""),h=void 0!==s&&"fill"!==s?"text-align: ".concat(s,";"):"",d=["".concat(c," .buttons_container {"),"display: inline-block;","width: 100%;",h,"}","".concat(c," .buttons_container a {"),"margin: 25px 0 0 0;","padding: 10px 22px;","line-height: 1;","max-width: 100%;","width: ".concat("fill"===s?"100%":"auto",";"),"text-align: center;","}"].join(""),u=["".concat(c," .").concat(this.className," {"),"display: flex;","flex-direction: ".concat(l,";"),"justify-content: space-around;","align-items: center;","}",".".concat(this.className," > img {"),"max-width: 100%;","width: 100%;","height: auto;","}",["left","right"].includes(a)?["".concat(c," .").concat(this.className," > * {"),"max-width: 46%;","}"].join(""):"","".concat(c," .drawer_title {"),"margin: 0 0 25px 0;","display: inline-block;","width: 100%;","}","".concat(c," .drawer_text_container {"),"line-height: 0;","white-space: pre-line;","display: inline-block;","vertical-align: middle;","width: 100%;","margin: 2vh 0;","}","".concat(c," .drawer_text_container * {"),"line-height: 1;","}","".concat(c," .drawer_text_container p {"),"margin: 0;","}"];o&&o.includes("button")&&u.push(d);var g=u.join("");return t.insertAdjacentText("beforeend",g),t}}],n&&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,G(i.key),i)}}(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,n}();!function(){l("Widget launch");var e=new z,t=e.domElement.querySelector(".".concat(e.contentClassName)),n=new J({parentContainer:e});e.children=n,n.insertIn(t,"beforeend"),e.init(!0).then(function(t){t.response&&(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}`),r=()=>!e()&&(t()||!!window.ABTasty.getTestsOnPage()[TEST_ID]),o=()=>window.ABTasty&&!0===window.ABTasty.consentReady,s=()=>{const{type:e}=DATA;return`${PACKAGE.replace("@abtasty/","")}${e?`_${e}`:""}`},a=()=>{const e=s();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})(),r=window.document.cookie.includes("abTastyDebug=")||!0===window.abTastyDebug;if(i||r){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,r,o]=e.split("[]").map(e=>e.trim()),s=Boolean(o)?o:e,a=r?document.querySelector(i)?.[r]:document;return a?t?[...a.querySelectorAll(s)]:a.querySelector(s):n},u=e=>d(e,!1),g=e=>d(e,!0),m=(e,t)=>{const n={childList:!0,subtree:!0,attributes:!0},i=()=>r.disconnect(),r=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;r.observe(i,n)}}},p=()=>{},v=(t,n)=>{const i=u(t),r={selector:t,clear:p,observe:p};if(i)return setTimeout(()=>n(i),0),r;if(e())return setTimeout(()=>v(t,n),1e3),r;if(t.includes("[]"))return((e,t)=>{const[n,i]=t.split("[]").map(e=>e.trim()),r=u(n),o=r?.[i],{clear:s,observe:a}=m(e,t),c=()=>{const n=u(t);return n&&!l()&&e(n)},l=()=>{s(),r?.removeEventListener("load",c)},h=()=>{a(o),"iframe"===r?.localName&&r.addEventListener("load",c)};return h(),{selector:t,clear:l,observe:h}})(n,t);const{clear:o,observe:s}=m(n,t);return s(),{selector:t,clear:o,observe:s}};function f(e,t){const n=e.parentElement||e.getRootNode().host;return t(e)||!n?e:f(n,t)}const y=t=>{e()||(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation())},b=(e,t)=>[...g(t)].some(n=>{const[i,,r]=t.split("[]"),o=r??i;return n===e||!!e.closest(o)});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[r,,o]=i.split("[]"),s=o??r,a=[...e.querySelectorAll(s)];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(s)].includes(n)))return!0}return!1});if(n&&this.isElementVisible(n.element)){const{selector:e,element:t,uniqueId:i}=n,r=this.targets.find(t=>t.selector===e&&t.uniqueId===i);r&&r.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"===f(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,r=0;for(;!i&&r<n.length;){const t=e.getRootNode()?.elementFromPoint(...n[r]);i=e===t||t?.contains(e)||e.contains(t),r+=1}return i}checkElements(){this.targets.forEach(({selector:e,uniqueId:t})=>{const n=u(e),[i,,r]=e.split("[]"),o=r??i;n&&!this.existingTargets.find(e=>e.element.matches(o)&&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,,r]=e.split("[]"),o=r??i;if(t.matches(o)&&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",S="rebuild",C="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[r,,o]=this.selector.split("[]"),s=o??r;t.innerHTML=`${s} {\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)),r=["mouseenter",n,{passive:!0,capture:!0}];this.eventsListeners.push([i,...r]),i.addEventListener(...r)});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 r=[...document.querySelectorAll("*:empty")].map(e=>e.contentDocument||e.shadowRoot).filter(e=>e),o=[({isTrusted:e})=>{e&&(i=n)},{passive:!0}];["click","mousemove","scroll","keypress"].forEach(e=>{[document,...r].forEach(t=>{this.eventsListeners.push([t,e,...o]),t.addEventListener(e,...o)})});const s=setInterval(()=>{i<=0?t(!0):i-=100},100);return this.intervals.push(s),e}onCustomTrigger({promise:e,resolve:t}){const{triggerEventCustomScript:n}=DATA,i="undefined"!=typeof DATA_JS&&DATA_JS?.triggerEventCustomScript,r="function"==typeof i?()=>new Promise(e=>i(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 r=(()=>{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:o,spNoTrim:s}=DATA;if(this.socialProofStore.hasOwnProperty(e))n(this.socialProofStore[e])?i(`${this.socialProofStore[e][o]}`):i(!1);else if(e&&r){const a=t=>(this.socialProofStore[e]=t,i(!!n(t)&&`${t[o]}`));fetch(`https://api-social-proof.abtasty.com/clients/${r}/metrics/${t}?key=${e}${s?"&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},r,o=!1){const{productKey:s,keyType:a}=(()=>{const{socialProofContentType:e,productKeyProvider:t,pathToProductKey:r,customJSProductKey:o,productSKU:s}=DATA,{pathToProductKey:a,customJSProductKey:c}="undefined"!=typeof DATA_JS?DATA_JS:{};if(2===e)return{productKey:i(),keyType:"url"};{let l=null,h="sku";switch(t){case"ABTastyProductKey":l=window.ABTastyProductKey;break;case"pathToProductKey":l="function"==typeof a?a():n(`return ${r};`);break;case"customJSProductKey":l="function"==typeof c?c():n(o);break;case"productSKU":l=s}return l||3!==e||(l=i(),h="url"),{productKey:l,keyType:h}}})(),{viewInterval:c,triggerSocialProofMinVisitors:h,triggerSocialProofMinPurchases:d,triggerSocialProofMinPageViews:u}=DATA,g={pv:u,i:d,"v-pv":h}[r];return[typeof c,typeof g].includes("undefined")&&t(!1),o&&!s&&(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(s,"v-pv"===r&&"sku"===a?"v-i":r,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(!o()){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 r=()=>JSON.parse(i)?.ActionTracking?.some(({name:e})=>e===n),o=["storage",({key:e,newValue:n})=>{e===x&&(i=n,r()&&t(!0))},{passive:!0,capture:!0}];return i&&r()?t(!0):(()=>{this.eventsListeners.push([window,...o]),window.addEventListener(...o)})(),e}onMinPagesViewed({promise:e,resolve:t}){const{triggerEventMinPagesViewed:n}=DATA;let i=localStorage.getItem(x);const r=()=>n<=(i?JSON.parse(i)?.VisitedPages?.length:0),o=["storage",({key:e,newValue:n})=>{e===x&&(i=n,r()&&t(!0))},{passive:!0,capture:!0}];return i&&r()?t(!0):(()=>{this.eventsListeners.push([window,...o]),window.addEventListener(...o)})(),e}onRageClick({promise:e,resolve:t}){const{triggerEventRageClickQuantity:n,triggerEventRageClickDelay:i}=DATA;let r=0,o=!1;const s=["click",({isTrusted:e})=>{if(e&&(r+=1,r>=n&&t(!0),!o)){o=!0;const e=setTimeout(()=>{r=0,o=!1},i);this.timeouts.push(e)}},{passive:!0,capture:!0}],a=e=>{this.eventsListeners.push([e,...s]),e.addEventListener(...s)},{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",P="closing",I="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=s(),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:r,storageMethod:s}=i,a=this.getStamp(e),c={type:n,stamp:a},{type:l}=this.getCurrentRecurrence(),h=async()=>{if(!o()){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"===r?e?n=this.removeSessionRecurrenceStorage():(this.removeLocalRecurrenceStorage(),n=this.getSessionRecurrenceStorageParsed()):"local"===r&&(t?n=this.removeLocalRecurrenceStorage():(this.removeSessionRecurrenceStorage(),n=this.getLocalRecurrenceStorageParsed()));const i=n?{[this.recurrenceKey]:c,...n}:{[this.recurrenceKey]:c};s.setItem(B,JSON.stringify(i)),this.onSetCallback&&"function"==typeof this.onSetCallback&&this.onSetCallback()};if(!s)return!1;if(l&&n!==I)if(n===P&&l!==I)h();else{if(n!==A||l===I||l===P)return!1;h()}else h();return a}setDisplayRecurrence(){const e=A;this.setRecurrence(this.displayRecurrence,e)}setClosingRecurrence(){const e=P;this.setRecurrence(this.closingRecurrence,e)}setValidationRecurrence(){const e=I;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&&C:S;return n?(this.clearWatcher(),this.callback(n,!e,t),this.watch(),this):this}onCampaignLaunched({detail:{campaignId:e}}){e===TEST_ID&&(this.callback(S,!1),this.watch())}onTagRollback({target:e}){return this.clearWatcher(e),this.callback(E,!1,!0),window.addEventListener(...this.onCampaignLaunchedEventParams),this}observerHandler(e){return r()?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:r}=v("body",e=>{r();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 O=/.+\/([^.]+)\.(otf|ttf)$/,D=["socialProofPurchases","socialProofPageViews","socialProofVisitors"];class _{constructor(t,n){this.children=void 0,this.uniqueId=`${c()}${n?`_${n}`:""}`,this.widgetName=s(),this.prettyName=a(),this.recurrenceParams=(()=>{const{displayRecurrence:t,closingRecurrence:n,validationRecurrence:i}=DATA,r=!t&&!n&&!i;if(e()||r)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`]},s={};return t&&(s.displayRecurrence=o[t]("displayRecurrence")),n&&(s.closingRecurrence=o[n]("closingRecurrence")),i&&(s.validationRecurrence=o[i]("validationRecurrence")),s})(),this.triggerParams=(t=>{let{triggerEvent:n}=DATA;const{triggerEventClick:i,triggerEventHover:r,triggerEventReengageDelay:o,socialProofContentType:s,triggerEventElementVisible:a,triggerEventDelay:c}=DATA;if(e()||!n&&!s)return!1;const l={click:()=>i,hover:()=>r,elementVisible:()=>a},h=Object.prototype.hasOwnProperty.call(l,n)?l[n]():"body",d="reengage"===n?o:c;return s&&(n=[,"socialProofPurchases","socialProofPageViews","socialProofVisitors"][s]),{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&&D.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.websiteFocusedElement=null,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:{},r=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(r)}).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(){const{layout:t,overlay:n=!0}=DATA;return e()||this.hasBeenShown&&this.hasOncePerPageTrigger||window.ABTastyEvent(`${this.prettyName} displayed`,null,TEST_ID),this.closedByUser=!1,this.websiteFocusedElement=document.activeElement,setTimeout(()=>{this.domElement.classList.remove(this.hideClassName),e()||"popin"!==t||!0!==n||this.domElement.querySelector('input[type="text"], textarea, a, button')?.focus()},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),!e()&&this.websiteFocusedElement?.isConnected&&this.websiteFocusedElement.focus(),this}async init(t){const n=e(),i=r(),o=this.trigger?.promises?.length,s=!this.recurrence||this.recurrence.isOver();if(!n&&!i||o||!s)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 r={[E]:()=>n?this.remove():this.pageWatcher.watch(this.rootElement),[S]:()=>{this.hasBeenShown?this.closedByUser?this.pageWatcher.watch(this.rootElement):n||this.insert().then(e=>e.show()).catch(this.pageWatcher.watch):i()},[C]:()=>{this.hasBeenShown?this.pageWatcher.watch():i()}};"function"==typeof r[e]&&r[e]()}addCloseEvent(...t){const{closeButton:n,overlay:i,overlayClickable:r,layout:o,animationDuration:s=1e3}=DATA,a=[];if(void 0!==i&&!0!==i||!0!==r||"popin"!==o||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=e=>{const t="click"===e.type,n="keyup"===e.type&&"Escape"===e.code&&e.isTrusted;(t||n)&&(y(e),this.recurrence&&this.recurrence.setClosingRecurrence(),this.hide(!0),setTimeout(()=>this.remove(),1.05*s))},h=["click",l,{once:!0,capture:!0}];t.push(...c);for(const n of t)e()&&(n.dataset.abtastyActionnable="true"),n.removeEventListener(...h),n.addEventListener(...h);return window.removeEventListener("keyup",l,{once:!0}),window.addEventListener("keyup",l,{once:!0}),this}getDom(){const{closeButton:e,layout:t,overlayClickable:n,overlay:i=!0}=DATA,r=document.createElement("div");return r.className=`${this.basicClassName} ${this.hideClassName}`,r.id=this.widgetContainerId,["popin","bannerTop","bannerBottom"].includes(t)&&(r.role="dialog","popin"===t&&!0===i&&(r.ariaModal="true")),r.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>`,r}loadFont(e,t){if(!e||"inherit"===e||!/otf|ttf/g.test(t))return;const n=document.createElement("style"),i=t.match(O)?t.match(O)[1]:"";n.innerHTML=`@font-face { font-family: '${e}_${i}'; src: url('${t}'); font-display: swap; }`;const r=this.rootElement?.head||document.head;r?.appendChild(n)}getStyleTag(t="",n=DATA){const{noStyles:i,layout:r}=n,{backgroundColor:o,isBackgroundImage:s,backgroundImage:a,backgroundSize:c,backgroundPosition:l,backgroundRepeat:h,borderColor:d,borderRadius:u,borderWidth:g,textColor:m,textAlign:p,fontName:v,fontStyle:f,fontSize:y,isTitle:b,titleTextAlign:w,titleTextColor:T,titleFontName:E,titleFontStyle:S,titleFontSize:C,overlay:x,overlayColor:k,dropShadow:A,dropShadowColor:P,dropShadowBlur:I,containerMargin:B,containerPadding:L,closeButton:N,closeButtonPosition:R,closeButtonSize:D,closeButtonBorderRadius:_,closeButtonBorderWidth:j,closeButtonBorderColor:W,closeButtonColor:V,closeButtonBackgroundColor:H,buttonsAlign:M,buttonsBorderWidth:F,buttonsBorderColor:q,buttonsBorderRadius:U,buttonsBackgroundColor:K,buttonsTextColor:z,buttonsFontName:Y,buttonsFontStyle:J,buttonsFontSize:G,secondLink:X,secondLinkBorderWidth:Q,secondLinkBorderColor:Z,secondLinkBorderRadius:ee,secondLinkBackgroundColor:te,secondLinkTextColor:ne,secondLinkFontName:ie,secondLinkFontStyle:re,secondLinkFontSize:oe,animation:se,animationDuration:ae,animationBehaviour:ce,animationSlideDirection:le}=i?{}:n,he=document.createElement("style");e()&&he.setAttribute("abtasty-script-added","true"),this.loadFont(v,f),this.loadFont(E,S),this.loadFont(Y,J),this.loadFont(ie,re);const de=`background: ${["string"==typeof o?o:"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&&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};`:"",fe=v&&"inherit"!==v?`font-family:${v}_${f.match(O)?f.match(O)[1]:""};`:f||"",ye=y?`font-size: ${y}px;`:"",be=void 0!==A&&A?`box-shadow: 0 5px ${I}px 0 ${P};`:"",we=B instanceof Array&&1===B.length&&B[0],Te=we?`margin: ${we.top}px ${we.right}px ${we.bottom}px ${we.left}px;`:"",Ee=we?`margin: calc(${we.top}px * 0.5) calc(${we.right}px * 0.5) calc(${we.bottom}px * 0.5) calc(${we.left}px * 0.5);`:"",$e=L instanceof Array&&1===L.length&&L[0],Se=$e?`padding: ${$e.top}px ${$e.right}px ${$e.bottom}px ${$e.left}px;`:"",Ce=$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);`:"",xe=void 0!==F&&F?`border-width: ${F}px; border-style: solid;`:"",ke=[q,F].every(e=>void 0!==e)&&F?`border-color: ${q};`:"",Ae=void 0!==U?`border-radius: ${U}px;`:"",Pe=void 0!==K?`background-color: ${K};`:"",Ie=void 0!==z?`color: ${z}; fill: ${z}; -webkit-text-fill-color: ${z};`:"",Be=Y&&"inherit"!==Y?`font-family:${Y}_${J.match(O)?J.match(O)[1]:""};`:J||"",Le=G?`font-size: ${G}px;`:"",Ne="number"==typeof Q?`border-width: ${Q}px; border-style: solid;`:"",Re=[Z,Q].every(e=>void 0!==e)&&Q?`border-color: ${Z};`:"",Oe=void 0!==ee?`border-radius: ${ee}px;`:"",De=void 0!==te?`background-color: ${te};`:"",_e=void 0!==ne?`color: ${ne}; fill: ${ne}; -webkit-text-fill-color: ${ne};`:"",je=ie&&"inherit"!==ie?`font-family:${ie}_${re.match(O)?re.match(O)[1]:""};`:re||"",We=oe?`font-size: ${oe}px;`:"",Ve="popin"!==r||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 D?D:16,Me=He/2,Fe=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 _?`border-radius: ${_}px;`:"","number"==typeof j&&j>0?`border: ${j}px solid ${void 0!==W?W:"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 V?`fill: ${V};`:"","}"].join(""):"",qe=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}_${S.match(O)?S.match(O)[1]:""};`:S||"",C?`font-size: ${C}px;`:"","}"].join(""):"";let Ue="";if("string"==typeof se){const t=(ae/1e3).toFixed(2),n=["top","bottom"].includes(le),i=Number(n),r=[(["top","left"].includes(le)?"-":"")+"100vmax",this.translateValues?this.translateValues[i]:"0"];n&&r.reverse(),Ue={none:[`.${this.hideClassName} {`,"opacity: 0 !important;","}"],fade:[`.${this.hideClassName} {`,"opacity: 0 !important;","}",`#${this.widgetContainerId} {`,`transition: opacity ${t}s ${ce};`,"}","@media (prefers-reduced-motion: reduce) {",`#${this.widgetContainerId} {`,"transition: unset;","}","}"],slide:[`.${this.hideClassName} .${this.overlayClassName} {`,"opacity: 0 !important;","}",`#${this.widgetContainerId} .${this.overlayClassName} {`,`transition: opacity ${t}s ${ce};`,"}",`.${this.hideClassName} .${this.contentClassName} {`,`transform: translate(${r.join(", ")}) !important;`,"}",`#${this.widgetContainerId} .${this.contentClassName} {`,`transition: transform ${t}s ${ce};`,"}","@media (prefers-reduced-motion: reduce) {",`#${this.widgetContainerId} .${this.overlayClassName},`,`.${this.hideClassName} .${this.contentClassName},`,`#${this.widgetContainerId} .${this.contentClassName} {`,"transition: unset;","}","}"]}[e()&&!ABTASTY_S.WIDGETS.animationChanged?"none":se].join("")}const Ke=[`#${this.widgetContainerId} .${this.contentClassName} .buttons_container .second_link {`,`margin-${"fill"===M?"top":"left"}: 8px;`,Ne,Re,Oe,De,_e,je,We,"}",`#${this.widgetContainerId} .${this.contentClassName} .buttons_container .second_link {`,_e,je,We,"}"];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,be,Te,fe,ye,"}",`#${this.widgetContainerId} .${this.contentClassName} p {`,pe,ve,fe,ye,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,"display: block;","line-height: 1;","text-indent: unset;",Se,fe,ye,"}",`#${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,Pe,Ie,Be,Le,"}",`#${this.widgetContainerId} .${this.contentClassName} div.buttons_container a *:not(.second_link span), `,`#${this.widgetContainerId} .${this.contentClassName} button:not([class*="close_button"], [class*="csatEmojiButton"]) * {`,Ie,Be,Le,"}",...X?Ke:[],"@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,Ee,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,Ce,"}","}",Ve,Fe,qe,Ue,`${t}`].join(""),he}}function j(e){return j="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},j(e)}function W(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var i,r,o,s,a=[],c=!0,l=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;c=!1}else for(;!(c=(i=o.call(n)).done)&&(a.push(i.value),a.length!==t);c=!0);}catch(e){l=!0,r=e}finally{try{if(!c&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(l)throw r}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return V(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?V(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function V(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function H(e){var t=function(e){if("object"!=j(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=j(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==j(t)?t:t+""}function M(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(M=function(){return!!e})()}function F(e){return F=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},F(e)}function q(e,t){return q=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},q(e,t)}var U={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}},K={top:[!1,!1,!0,!0],bottom:[!0,!0,!1,!1],left:[!1,!0,!0,!1],right:[!0,!1,!1,!0]},z=function(t){function n(){var e,t,i;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),(t=this,i=n,i=F(i),e=function(e,t){if(t&&("object"==j(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(t,M()?Reflect.construct(i,[],F(t).constructor):i.apply(t,undefined))).button=e.setButton(),e.stringStyles=e.getStyles(),e.styleElement=e.getStyleTag(e.stringStyles),e.open=!1,e}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&q(e,t)}(n,t),i=n,r=[{key:"toggleDrawer",value:function(){this.open=this.domElement.classList.toggle("drawer_open")}},{key:"setButton",value:function(){var t=DATA,n=t.mainButtonText,i=t.hasMainButtonIcon,r=t.mainButtonIcon,o=t.mainButtonIconAlt,s=document.createElement("button");return s.className="drawer_button_".concat(this.uniqueId),e()&&(s.dataset.abtastyActionnable="true"),s.innerHTML="<span>".concat(n,"</span>").concat(i?'<img src="'.concat(r,'" alt="').concat(o,'">'):""),e()&&top.document.documentElement.classList.contains("widget-react-form-opened")&&this.domElement.classList.add("drawer_open"),s.addEventListener("click",this.toggleDrawer.bind(this),!0),this.domElement.insertAdjacentElement("beforeend",s),s}},{key:"getStyles",value:function(){var e=DATA,t=e.buttonLayout,n=e.customTarget,i=e.elementReferrer,r=e.zindex,o=e.zindexCustom,s=e.styckyButtonBackgroundColor,a=e.styckyButtonIsBackgroundImage,c=e.styckyButtonBackgroundImage,l=e.styckyButtonBackgroundPosition,h=e.styckyButtonBackgroundRepeat,d=e.styckyButtonBackgroundSize,u=e.styckyButtonButtonsAlign,g=e.styckyButtonContainerMargin,m=e.styckyButtonContainerPadding,p=e.styckyButtonButtonsBorderWidth,v=e.styckyButtonButtonsBorderColor,f=e.styckyButtonButtonsBorderRadius,y=e.styckyButtonDropShadow,b=e.styckyButtonDropShadowBlur,w=e.styckyButtonDropShadowColor,T=e.styckyButtonTitleFontName,E=e.styckyButtonTitleFontStyle,S=e.styckyButtonTitleFontSize,C=e.styckyButtonTitleTextAlign,x=e.styckyButtonTitleTextColor,k=e.autoWidth,A=e.drawerLayout,P=e.hasMainButtonIcon,I=e.animationDuration,B=e.animationBehaviour,L=U[t],N=L.top,R=L.left,O=L.right,D=L.translateX,_=L.translateY,j=L.translateOpenX,V=L.translateOpenY,H=["left","right"].includes(t),M=W(g,1)[0],F=M.top,q=M.bottom,z=M.left,Y=M.right,J=W(m,1)[0],G=J.top,X=J.bottom,Q=J.left,Z=J.right,ee=K[t].map(function(e){return e?"".concat(f,"px"):"0"}).join(" "),te=[s,a&&c.length?"url(".concat(c,")"):"",a&&"100% 100%"!==d?l:"0 0",a&&"string"==typeof d?"/ ".concat(d):"/ auto",a&&h&&!["cover","100% 100%"].includes(d)?"repeat":"no-repeat"],ne="background: ".concat(te.join(" ").trim()," !important;"),ie=y?"box-shadow: 0 5px ".concat(b,"px 0 ").concat(w,";"):"",re="border: ".concat(p>0?"".concat(p,"px solid ").concat(v):"unset",";"),oe=/.+\/([^.]+)\.(otf|ttf)$/;this.loadFont(T,E);var se=["color: ".concat(x,"; fill: ").concat(x,"; -webkit-text-fill-color: ").concat(x,";"),"text-align: ".concat(C,";"),"inherit"!==T?"font-family:".concat(T,"_").concat(E.match(oe)?E.match(oe)[1]:"",";"):E||"",S?"font-size: ".concat(S,"px;"):""].join(""),ae={left:"start",center:"center",right:"end"}[C],ce=W((n?i:"body").split("[]"),3),le=ce[0],he=ce[1],de=ce[2],ue=null!=de?de:le,ge="shadowRoot"===he?":host":"".concat(ue.trimEnd(),":not(:has(.fixed-drawer))"),me=n?["".concat(ge," {"),"overflow-".concat(H?"x":"y",": hidden;"),"}"].join(""):"";return["".concat(ue," {"),"position: relative;","}",me,"#".concat(this.widgetContainerId," {"),"position: absolute;","top: ".concat(N,"%;"),"number"==typeof R?"left: ".concat(R,"%;"):"","number"==typeof O?"right: ".concat(O,"%;"):"","transform: translate(".concat(D,"%, ").concat(_,"%);"),"transition: transform ".concat((I/1e3).toFixed(2),"s ").concat(B,";"),"margin: 0;","padding: 0;","background: none;","z-index: ".concat("custom"===r?o:r,";"),function(){if(k)return n?"width: auto; height: auto; max-width: calc(100% - ".concat("".concat(H?Q+Z+1.5*S:G+X+1.5*S,"px"),");"):"width: auto; height: auto; min-width: 30vw; max-width: ".concat(["left","right"].includes(A)?"80vw":"40vw",";");var e=DATA,t=e.popinPercentWidth,i=e.popinPixelsWidth,r=e.widthUnit,o=e.autoHeight,s=e.popinPercentHeight,a=e.popinPixelsHeight,c=e.heightUnit,l="px"===c?a:s;return"width: ".concat("px"===r?i:t).concat(r,";height: ").concat(o?"auto":"".concat(l).concat(c),";")}(),"}","@media (prefers-reduced-motion: reduce) {","#".concat(this.widgetContainerId," {"),"transition: unset;","}","}","#".concat(this.widgetContainerId,".fixed-drawer {"),"position: fixed;","}","#".concat(this.widgetContainerId," .").concat(this.contentClassName," {"),"position: relative;","width: 100%;","height: 100%;","box-sizing: border-box;","}","#".concat(this.widgetContainerId,".drawer_open {"),"transform: translate(".concat(j,"%, ").concat(V,"%);"),"}",".".concat(this.button.className," {"),"position: absolute;","".concat(t,": 100%;"),["top","bottom"].includes(t)?["".concat("right"===u?"right":"left",": ").concat(["left","right"].includes(u)?"0":"50%",";"),"transform: translate(".concat(["left","right"].includes(u)?"0":"-50%",", 0);"),"width: ".concat("fill"===u?"100%":"auto",";")].join(""):"",H?["".concat("right"===u?"bottom":"top",": ").concat(["center","fill"].includes(u)?"50%":"0",";"),"transform: translate(0, ".concat(["left","right"].includes(u)?"0":"-50%",");"),"height: ".concat("fill"===u?"100%":"auto",";")].join(""):"","margin: ".concat(F,"px ").concat(Y,"px ").concat(q,"px ").concat(z,"px;"),"padding: ".concat(G,"px ").concat(Z,"px ").concat(X,"px ").concat(Q,"px;"),"text-wrap: nowrap;",ne,re,"border-radius: ".concat(ee,";"),"display: flex;","flex-direction: ".concat(H?"column":"row",";"),"align-items: center;","justify-content: ".concat(ae,";"),ie,"}",".".concat(this.button.className," span {"),H?["writing-mode: vertical-rl;","text-orientation: sideways;"].join(""):"","right"===t?"transform: rotate(180deg);":"","width: auto;",se,"}",P?[".".concat(this.button.className," img {"),H?"transform: rotate(".concat(t.includes("right")?"-":"","90deg);"):"","min-width: ".concat(2*S,"px;"),"max-height: ".concat(2*S,"px;"),"margin-".concat(H?"top":"left",": ").concat(S,"px"),"}"].join(""):"","@media screen and (max-width: 579px) {","#".concat(this.widgetContainerId," .").concat(this.contentClassName," {"),k?"min-width: 40vw; max-width: 60vw;":"","}","}"].join("")}}],r&&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,H(i.key),i)}}(i.prototype,r),Object.defineProperty(i,"prototype",{writable:!1}),i;var i,r}(_);function Y(e){return Y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Y(e)}function J(e){var t=function(e){if("object"!=Y(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=Y(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Y(t)?t:t+""}var G=function(){return t=function e(t){var n=t.parentContainer;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.parentContainer=n,this.className="drawer_container_".concat(n.uniqueId),this.domElement=this.getElement()},n=[{key:"insertIn",value:function(e,t){this.setStyles(),e.insertAdjacentElement(t,this.domElement)}},{key:"addRedirectionEvent",value:function(t){var n=this;!e()&&t&&t.addEventListener("click",function(){var t=DATA,i=t.autoHide,r=t.timeHide;i&&setTimeout(function(){n.parentContainer.hide(),n.remove()},1e3*r),e()||n.parentContainer.recurrence.setValidationRecurrence()},{capture:!0,passive:!0})}},{key:"addCloseEvent",value:function(t){var n=this;t&&t.addEventListener("click",function(t){y(t),e()||n.parentContainer.recurrence.setClosingRecurrence(),n.parentContainer.hide(),setTimeout(function(){return n.parentContainer.remove()},1e3)},{capture:!0,passive:!1})}},{key:"buttonBuilder",value:function(e,t,n,i){var r=arguments.length>4&&void 0!==arguments[4]&&arguments[4],o=document.createElement("a");return o.ariaLabel=e,o.innerHTML="<span>".concat(e,"</span>"),o.href="button"===t?n:"#",r&&(o.className="second_link"),"button"===t?(o.target=i?"_blank":"_self",this.addRedirectionEvent(o)):(o.dataset.abtastyActionnable="true",this.addCloseEvent(o)),o}},{key:"getButtons",value:function(){var e=DATA,t=e.linkType,n=e.buttonText,i=e.redirectionUrl,r=e.openInNewTab,o=e.secondLink,s=e.secondLinkText,a=e.secondLinkType,c=e.secondLinkURL,l=e.secondLinkOpenInNewTab,h=[this.buttonBuilder(n,t,i,r)];if(o){var d=this.buttonBuilder(s,a,c,l,o);h.push(d)}return h}},{key:"getElement",value:function(){var e=DATA,t=e.linkType,n=e.buttonText,i=e.redirectionUrl,r=e.isTitle,o=e.title,s=e.textContent,a=e.openInNewTab,c=e.drawerLayout,l=e.drawerImage,h=e.altDesc,d=document.createElement(t&&t.includes("widget")?"a":"div");d.className=this.className,"widget"===t?(d.href=i,d.target=a?"_blank":"_self",this.addRedirectionEvent(d)):"widgetClose"===t&&(d.href="#",d.dataset.abtastyActionnable="true",this.addCloseEvent(d)),d.innerHTML="".concat("textOnly"!==c?'<img src="'.concat(l,'" ').concat("string"==typeof h?'alt="'.concat(h,'"'):"",">"):"");var u=document.createElement("div");if(u.className="drawer_text_container","imageOnly"!==c&&(u.innerHTML="\n\t\t\t".concat(r?'<h2 class="drawer_title">'.concat(o,"</h2>"):"",'\n\t\t\t<p class="drawer_text">').concat(s,"</p>")),[t,n].every(function(e){return"string"==typeof e})&&t.includes("button")&&n.length){var g=this.getButtons(),m=document.createElement("div");m.className="buttons_container",g.forEach(function(e){return m.appendChild(e)}),u.appendChild(m)}return d.appendChild(u),d}},{key:"setStyles",value:function(){var e=this.parentContainer,t=e.styleElement,n=e.widgetContainerId,i=e.contentClassName,r=DATA,o=r.linkType,s=r.buttonsAlign,a=r.drawerLayout,c="#".concat(n," .").concat(i),l="".concat(["left","right"].includes(a)?"row":"column").concat(["right","bottom"].includes(a)?"-reverse":""),h=void 0!==s&&"fill"!==s?"text-align: ".concat(s,";"):"",d=["".concat(c," .buttons_container {"),"display: inline-block;","width: 100%;",h,"}","".concat(c," .buttons_container a {"),"margin: 25px 0 0 0;","padding: 10px 22px;","line-height: 1;","max-width: 100%;","width: ".concat("fill"===s?"100%":"auto",";"),"text-align: center;","}"].join(""),u=["".concat(c," .").concat(this.className," {"),"display: flex;","flex-direction: ".concat(l,";"),"justify-content: space-around;","align-items: center;","}",".".concat(this.className," > img {"),"max-width: 100%;","width: 100%;","height: auto;","}",["left","right"].includes(a)?["".concat(c," .").concat(this.className," > * {"),"max-width: 46%;","}"].join(""):"","".concat(c," .drawer_title {"),"margin: 0 0 25px 0;","display: inline-block;","width: 100%;","}","".concat(c," .drawer_text_container {"),"line-height: 0;","white-space: pre-line;","display: inline-block;","vertical-align: middle;","width: 100%;","margin: 2vh 0;","}","".concat(c," .drawer_text_container * {"),"line-height: 1;","}","".concat(c," .drawer_text_container p {"),"margin: 0;","}"];o&&o.includes("button")&&u.push(d);var g=u.join("");return t.insertAdjacentText("beforeend",g),t}}],n&&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,J(i.key),i)}}(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,n}();!function(){l("Widget launch");var e=new z,t=e.domElement.querySelector(".".concat(e.contentClassName)),n=new G({parentContainer:e});e.children=n,n.insertIn(t,"beforeend"),e.init(!0).then(function(t){t.response&&(e.show(),(!0!==DATA.customTarget||u(DATA.elementReferrer).matches("body"))&&e.domElement.classList.add("fixed-drawer"))})}()}();
|