@abtasty/csat 0.0.29 → 0.0.31

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/main.js CHANGED
@@ -1 +1 @@
1
- !function(){"use strict";const t=()=>Object.prototype.hasOwnProperty.call(top,"ABTastyEditor"),e=()=>{const t=!!document.getElementById("ABTastyPreviewBar"),e=location.href.includes("ab_project=preview");return t||e},n=t=>new Function(`try {\n\t\t${t}\n\t} catch (error) {\n\t\treturn null;\n\t}`)(),r=()=>encodeURIComponent(DATA.spNoTrim?window.location.href.replace(window.location.origin,""):`${window.location.pathname}`),i=()=>!t()&&(e()||!!window.ABTasty.getTestsOnPage()[TEST_ID]),o=()=>window.ABTasty&&!0===window.ABTasty.consentReady,s=()=>{const{type:t}=DATA;return`${PACKAGE.replace("@abtasty/","")}${t?`_${t}`:""}`},a=()=>{const t=s();return`${t.charAt(0).toUpperCase()}${t.slice(1)}`.split("-").join(" ")},c=()=>`${PLUGIN_ID.split("-")[0]}_${TEST_ID}`,l=n=>{const r=(()=>{if(t()||e())return!1;const n=ABTasty.getTestsOnPage()[TEST_ID];return!!n&&Object.keys(n.targetings.qaParameters).length>0})(),i=window.document.cookie.includes("abTastyDebug=")||!0===window.abTastyDebug;if(r||i){const t=a();window.console.log(`%c${t} - ${r?"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=t=>{const e={promise:null,resolve:null,reject:null,name:t};return e.promise=new Promise((t,n)=>{e.resolve=t,e.reject=n}),e},u=(t,e)=>{const n=e?[]:null;if("string"!=typeof t||!t.trim().length)return n;const[r,i,o]=t.split("[]").map(t=>t.trim()),s=Boolean(o)?o:t,a=i?document.querySelector(r)?.[i]:document;return a?e?[...a.querySelectorAll(s)]:a.querySelector(s):n},d=t=>u(t,!1),m=t=>u(t,!0),p=(t,e)=>{const n=document.querySelector("body")||document.documentElement,r={childList:!0,subtree:!0,attributes:!0},i=()=>o.disconnect(),o=new MutationObserver(()=>{const n=d(e);return n&&!i()&&t(n)});return{clear:i,observe:(t=n)=>o.observe(t,r)}},g=()=>{},f=(e,n)=>{const r=d(e),i={selector:e,clear:g,observe:g};if(r)return setTimeout(()=>n(r),0),i;if(t())return setTimeout(()=>f(e,n),1e3),i;if(e.includes("[]"))return((t,e)=>{const[n,r]=e.split("[]").map(t=>t.trim()),i=d(n),o=i?.[r],{clear:s,observe:a}=p(t,e),c=()=>{const n=d(e);return n&&!l()&&t(n)},l=()=>{s(),i?.removeEventListener("load",c)},h=()=>{a(o),"iframe"===i?.localName&&i.addEventListener("load",c)};return h(),{selector:e,clear:l,observe:h}})(n,e);const{clear:o,observe:s}=p(n,e);return s(),{selector:e,clear:o,observe:s}};function v(t,e){const n=t.parentElement||t.getRootNode().host;return e(t)||!n?t:v(n,e)}const y=(t,e)=>[...m(e)].some(n=>{const[r,,i]=e.split("[]"),o=i??r;return n===t||!!t.closest(o)});let b=!1;class w{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(t){const e=[t,"transitionend",this.checkElements.bind(this),!0];return this.getEvents(...e)}intersectionHandler(t){t.forEach(t=>{t.isIntersecting?(this.existingTargets.forEach(e=>{e.element.isSameNode(t.target)&&(this.inViewportTargets.push(e),this.mouseOverEvent.start(),this.scrollEvent.start(),this.onTransitionEnd.start())}),this.checkElements()):this.inViewportTargets=this.inViewportTargets.filter(e=>!e.element.isSameNode(t.target)||(this.mouseOverEvent.clear(),this.scrollEvent.clear(),this.onTransitionEnd.clear(),!1))})}startVisibilityObserver(t){const e={root:t,rootMargin:"0px",threshold:0};return this.visibilityObserver??=new IntersectionObserver(this.intersectionHandler.bind(this),e),this.visibilityObserver}startMutationObserver(t){return this.mutationObserver??=new MutationObserver(this.checkElements.bind(this)),this.mutationObserver.observe(t,{attributes:!0,childList:!0,subtree:!0}),this.mutationObserver}onMouseOver({target:t,path:e}){const n=this.inViewportTargets.find(({element:n,selector:r})=>{if(n.isSameNode(t))return!0;const[i,,o]=r.split("[]"),s=o??i,a=[...t.querySelectorAll(s)];if(a.length&&a.includes(n))return!0;if(e.includes(n))return!0;if(!t.parentElement?.children?.length)return;const c=[...t.parentElement.children],l=c.findIndex(e=>e.isSameNode(t)),h=c.filter((t,e)=>e>l);if(h.length){if(h.includes(n))return!0;if(h.some(t=>[...t.querySelectorAll(s)].includes(n)))return!0}return!1});if(n&&this.isElementVisible(n.element)){const{selector:t,element:e,uniqueId:r}=n,i=this.targets.find(e=>e.selector===t&&e.uniqueId===r);i&&i.resolve(e),this.clear(t,r)}}getEvents(t,...e){return{start:()=>t?.addEventListener(...e),clear:()=>t?.removeEventListener(...e)}}mouseOverHandler(t){const e=[t,"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0?"touchmove":"mouseover",t=>{const e=t.composedPath(),{target:n}=t;setTimeout(()=>this.onMouseOver({target:n,path:e}),50)},!0];return this.getEvents(...e)}scrollEventHandler(t){const e=[t,"scroll",(n=this.checkElements.bind(this),()=>{b||(b=!0,setTimeout(()=>{n(),b=!1},100))}),{passive:!0}];var n;return this.getEvents(...e)}isElementVisible(t){return this.isElementOpaque(t)&&this.isElementTopmost(t)}isElementOpaque(t){return"HTML"===v(t,t=>"0"===window.getComputedStyle(t).opacity).nodeName}isElementTopmost(t){const e=t.getBoundingClientRect(),n=[[e.left,e.top],[e.right,e.top],[e.left,e.bottom],[e.right,e.bottom],[e.left+e.width/2,e.top],[e.left+e.width/2,e.bottom],[e.left,e.height/2],[e.right,e.height/2],[e.left+e.left/2,e.height/2]];let r=!1,i=0;for(;!r&&i<n.length;){const e=t.getRootNode()?.elementFromPoint(...n[i]);r=t===e||e?.contains(t)||t.contains(e),i+=1}return r}checkElements(){this.targets.forEach(({selector:t,uniqueId:e})=>{const n=d(t),[r,,i]=t.split("[]"),o=i??r;n&&!this.existingTargets.find(t=>t.element.matches(o)&&t.uniqueId===e)&&(this.existingTargets.push({element:n,selector:t,uniqueId:e}),this.visibilityObserver.observe(n))}),this.existingTargets=this.existingTargets.filter(({selector:t,element:e})=>!!d(t)||(e&&this.visibilityObserver.unobserve(e),!1)),this.inViewportTargets=this.inViewportTargets.filter(({selector:t,element:e,uniqueId:n})=>{const[r,,i]=t.split("[]"),o=i??r;if(e.matches(o)&&this.isElementVisible(e)){const r=this.targets.find(e=>e.selector===t&&e.uniqueId===n);return r&&r.resolve(e),this.clear(t,n),!1}return!0})}onLoadIframe(t){const e=[t.defaultView.frameElement,"load",()=>this.watch(selector,resolve,uniqueId).bind(this),{passive:!0}];return this.getEvents(...e)}watch(t,e,n){this.targets.push({selector:t,resolve:e,uniqueId:n});const{clear:r}=f(t,t=>{r();const e=t.getRootNode(),n="body"in e?e.body:document;this.mouseOverEvent=this.mouseOverHandler(e),this.scrollEvent=this.scrollEventHandler(e),this.onTransitionEnd=this.transitionOverHandler(e),e.defaultView?.frameElement&&(this.onIframeLoad=this.onLoadIframe(e),this.onIframeLoad.start()),this.startVisibilityObserver(n),this.startMutationObserver(n),this.checkElements()})}clear(t,e){[this.targets,this.existingTargets,this.inViewportTargets]=[this.targets,this.existingTargets,this.inViewportTargets].map(n=>n.filter(({selector:n,uniqueId:r})=>n!==t&&r!==e));const n=d(t);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",T="rebuild",C="update",S="ABTastyData";class ${constructor({triggerEvent:t,triggerSelector:e,triggerDelay:n,triggerTarget:r}){this.event=t,this.selector=Boolean(e)?e:"body",this.target="string"==typeof r?d(e):r,this.delay=1e3*n,this.triggerElements=[],this.eventsListeners=[],this.timeouts=[],this.intervals=[],this.promises=[],this.visibilityObservers=[],this.socialProofStore={},this.elementWaiters=[]}async onElementVisible({promise:t,resolve:e}){const n=h(`${this.event}DomReady`);this.promises.push(n);const{clear:r}=f(this.selector,()=>{const t=new w;this.visibilityObservers.push(t),t.watch(this.selector,e,c())});return this.elementWaiters.push(r),t}onPageLoad({promise:t,resolve:e}){const n=()=>"complete"===document.readyState;if(!n()){const r=["readystatechange",()=>n()&&e(!0),{passive:!0}];return this.eventsListeners.push([document,...r]),document.addEventListener(...r),t}return e(!0),t}onClick({promise:t,resolve:e}){const n=({isTrusted:t,target:n})=>{if(t)return(n.isEqualNode(this.target)||y(n,this.selector))&&e(!0)},{clear:r}=f(this.selector,t=>{r();const e=document.createElement("style");e.id=`Click_${c()}`;const[i,,o]=this.selector.split("[]"),s=o??i;e.innerHTML=`${s} {\n\t\t\t\tcursor: pointer !important;\n\t\t\t\tpointer-events: all !important;\n\t\t\t}`;const a=t.getRootNode();("head"in a?a.head:a).appendChild(e),this.triggerElements.push(e);const l=["click",n,{passive:!0,capture:!0}];this.eventsListeners.push([a,...l]),a.addEventListener(...l)});return this.elementWaiters.push(r),t}onHover({promise:t,resolve:e}){const n=({isTrusted:t,target:n})=>{if(t)return(this.target?n.isEqualNode(this.target):y(n,this.selector))&&e(!0)},{clear:r}=f(this.selector,t=>{const e=t.getRootNode(),r="body"in e?e.body:[...e.childNodes].find(e=>e.contains(t)),i=["mouseenter",n,{passive:!0,capture:!0}];this.eventsListeners.push([r,...i]),r.addEventListener(...i)});return this.elementWaiters.push(r),t}onExitIntent({promise:t,resolve:e}){const n=["mouseleave",({isTrusted:t,clientY:n})=>{t&&n<=0&&e(!0)},{passive:!0}],{clear:r}=f("html",t=>{r(),this.eventsListeners.push([t,...n]),t.addEventListener(...n)});return t}onReengage({promise:t,resolve:e}){const n=this.delay;let r=n;const i=[...document.querySelectorAll("*:empty")].map(t=>t.contentDocument||t.shadowRoot).filter(t=>t),o=[({isTrusted:t})=>{t&&(r=n)},{passive:!0}];["click","mousemove","scroll","keypress"].forEach(t=>{[document,...i].forEach(e=>{this.eventsListeners.push([e,t,...o]),e.addEventListener(t,...o)})});const s=setInterval(()=>{r<=0?e(!0):r-=100},100);return this.intervals.push(s),t}onCustomTrigger({promise:t,resolve:e}){const{triggerEventCustomScript:n,tagIsSafeEval:r}=DATA,i=r&&DATA_JS?.triggerEventCustomScript,o="function"==typeof i?()=>new Promise(t=>i(t)):new Function(`return new Promise(async resolve => {${n}})`);return o().then(t=>t&&e(!0)),t}onScrollUp({promise:t,resolve:e}){let n=0;const r=["scroll",({isTrusted:t})=>{t&&(window.scrollY<n?e(!0):n=window.scrollY)},{passive:!0,capture:!0}];return this.eventsListeners.push([document,...r]),document.addEventListener(...r),t}onScrollPercentReached({promise:t,resolve:e}){const{triggerEventScrollPercent:n}=DATA,r=["scroll",({isTrusted:t})=>{if(!t)return;const r=(()=>{const{documentElement:t,body:e}=document,n=t.scrollTop||e.scrollTop,r=t.scrollHeight||e.scrollHeight;return Math.trunc(n/(r-t.clientHeight)*100,10)})();n<r&&e(!0)},{passive:!0,capture:!0}];return this.eventsListeners.push([document,...r]),document.addEventListener(...r),t}checkSocialProofConditions(t,e,n,r){const i=(()=>{let t;return window.ABTasty||window.ABTASTY_S?(window.ABTASTY_S?.USER?.accountIdentifier?.length?t=window.ABTASTY_S.USER.accountIdentifier:"function"==typeof window.ABTasty?.getAccountSettings?t=window.ABTasty.getAccountSettings().identifier:window.ABTasty?.accountSettings&&(t=window.ABTasty.accountSettings.identifier),t):t})(),{viewInterval:o,spNoTrim:s}=DATA;if(this.socialProofStore.hasOwnProperty(t))n(this.socialProofStore[t])?r(`${this.socialProofStore[t][o]}`):r(!1);else if(t&&i){const a=e=>(this.socialProofStore[t]=e,r(!!n(e)&&`${e[o]}`));fetch(`https://api-social-proof.abtasty.com/clients/${i}/metrics/${e}?key=${t}${s?"&noTrim=true":""}`).then(t=>t.ok&&t.json()).then(a).catch(()=>l("Failed to fetch datas from server."))}else r(!1)}getSocialProofDatas({promise:t,resolve:e},i,o=!1){const{productKey:s,keyType:a}=(()=>{const{socialProofContentType:t,productKeyProvider:e,pathToProductKey:i,customJSProductKey:o,productSKU:s,tagIsSafeEval:a}=DATA,{pathToProductKey:c,customJSProductKey:l}=a?DATA_JS:{};if(2===t)return{productKey:r(),keyType:"url"};{let a=null,h="sku";switch(e){case"ABTastyProductKey":a=window.ABTastyProductKey;break;case"pathToProductKey":a="function"==typeof c?c():n(`return ${i};`);break;case"customJSProductKey":a="function"==typeof l?l():n(o);break;case"productSKU":a=s}return a||3!==t||(a=r(),h="url"),{productKey:a,keyType:h}}})(),{viewInterval:c,triggerSocialProofMinVisitors:h,triggerSocialProofMinPurchases:u,triggerSocialProofMinPageViews:d}=DATA,m={pv:d,i:u,"v-pv":h}[i];return[typeof c,typeof m].includes("undefined")&&e(!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"),e(!1)),this.checkSocialProofConditions(s,"v-pv"===i&&"sku"===a?"v-i":i,t=>{const e=void 0!==t[c]&&t[c]>=m;return e||l(`Widget will not be shown, Social Proof API returned ${t[c]} while ${m} are required`),e},e),t}onConsent({promise:t,resolve:e}){if(!o()){const n=["abtasty_consentValid",()=>e(!0)];return this.eventsListeners.push(n),window.addEventListener(...n),t}return e(!0),t}onTrackingSent({promise:t,resolve:e}){const{triggerEventTrackingSent:n}=DATA;let r=localStorage.getItem(S);const i=()=>JSON.parse(r)?.ActionTracking?.some(({name:t})=>t===n),o=["storage",({key:t,newValue:n})=>{t===S&&(r=n,i()&&e(!0))},{passive:!0,capture:!0}];return r&&i()?e(!0):(()=>{this.eventsListeners.push([window,...o]),window.addEventListener(...o)})(),t}onMinPagesViewed({promise:t,resolve:e}){const{triggerEventMinPagesViewed:n}=DATA;let r=localStorage.getItem(S);const i=()=>n<=(r?JSON.parse(r)?.VisitedPages?.length:0),o=["storage",({key:t,newValue:n})=>{t===S&&(r=n,i()&&e(!0))},{passive:!0,capture:!0}];return r&&i()?e(!0):(()=>{this.eventsListeners.push([window,...o]),window.addEventListener(...o)})(),t}onRageClick({promise:t,resolve:e}){const{triggerEventRageClickQuantity:n,triggerEventRageClickDelay:r}=DATA;let i=0,o=!1;const s=["click",({isTrusted:t})=>{if(t&&(i+=1,i>=n&&e(!0),!o)){o=!0;const t=setTimeout(()=>{i=0,o=!1},r);this.timeouts.push(t)}},{passive:!0,capture:!0}],a=t=>{this.eventsListeners.push([t,...s]),t.addEventListener(...s)},{clear:c}=f("iframe []contentDocument[] body > *",()=>{const t=document.getElementsByTagName("iframe");for(const e of t){"contentDocument"in e&&"body"in e.contentDocument&&a(e.contentDocument);const t=()=>a(e.contentDocument);e.addEventListener("load",t),this.eventsListeners.push([e,"onIframeLoad",t])}});return this.elementWaiters.push(c),a(document),t}clear(){this.triggerElements=this.triggerElements.filter(t=>(t.remove(),!1)),this.eventsListeners=this.eventsListeners.filter(t=>{const[e,...n]=t;return e&&n.length>1&&e.removeEventListener(...n),!1}),this.timeouts=this.timeouts.filter(t=>(clearTimeout(t),!1)),this.intervals=this.intervals.filter(t=>(clearInterval(t),!1));const t=c();return this.visibilityObservers=this.visibilityObservers.filter(e=>(e.clear(this.selector,t),!1)),this.promises=this.promises.filter(t=>(t.resolve(!1),!1)),this.elementWaiters=this.elementWaiters.filter(t=>(t(),!1)),this}async isTriggered(){this.clear();const t=h(this.event);this.promises.push(t);const e={consent:()=>this.onConsent(t),direct:()=>!0,pageLoad:()=>this.onPageLoad(t),click:()=>this.onClick(t),exitIntent:()=>this.onExitIntent(t),reengage:()=>this.onReengage(t),elementVisible:()=>this.onElementVisible(t),script:()=>this.onCustomTrigger(t),hover:()=>this.onHover(t),scrollUp:()=>this.onScrollUp(t),scrollPercent:()=>this.onScrollPercentReached(t),rageClick:()=>this.onRageClick(t),minPagesViewed:()=>this.onMinPagesViewed(t),trackingSent:()=>this.onTrackingSent(t),socialProofPurchases:()=>this.getSocialProofDatas(t,"i",!0),socialProofPageViews:()=>this.getSocialProofDatas(t,"pv"),socialProofVisitors:()=>this.getSocialProofDatas(t,"v-pv")},n=!Object.prototype.hasOwnProperty.call(e,this.event)||await e[this.event]();return n&&this.clear(),"reengage"!==this.event&&this.delay?n&&await(async()=>{const t=h(`${this.event}Delay`);this.promises.push(t);const e=setTimeout(()=>{t.resolve(!0),this.clear()},this.delay);return this.timeouts.push(e),t.promise})():n}}const x="display",A="closing",L="validation",k="ABTastyWidgets",N=`${k}Temporary`;class P{constructor({displayRecurrence:t,closingRecurrence:e,validationRecurrence:n},r){this.displayRecurrence=parseFloat(t),this.closingRecurrence=parseFloat(e),this.validationRecurrence=parseFloat(n),this.onSetCallback=r,this.widgetName=s(),this.uniqueId=c(),this.recurrenceKey=`${this.widgetName}_${this.uniqueId}`,this.isListeningStorageEvent=this.listenStorageEvent(),this.pendingRecurrence=!1,this.pendingRecurrenceValue={}}onStorage({key:t}){const e=localStorage.getItem(N),n=sessionStorage.getItem(k);"ABTastyData"===t&&!e&&n&&localStorage.setItem(N,n)}listenStorageEvent(){return this.isListeningStorageEvent||window.addEventListener("storage",this.onStorage.bind(this)),!0}getGivenRecurrenceStorageParsed(t){try{const e=t.getItem(k);return JSON.parse(e)}catch(e){return t.removeItem(k),!1}}getSessionRecurrenceStorageParsed(){return this.getGivenRecurrenceStorageParsed(window.sessionStorage)}getLocalRecurrenceStorageParsed(){return this.getGivenRecurrenceStorageParsed(window.localStorage)}removeGivenStorage(t,e){const{[this.recurrenceKey]:n,...r}=e;return Object.entries(r).length?(t.setItem(k,JSON.stringify(r)),r):(t.removeItem(k),!1)}removeSessionRecurrenceStorage(){const t=this.getSessionRecurrenceStorageParsed();return!!t&&this.removeGivenStorage(window.sessionStorage,t)}removeLocalRecurrenceStorage(){const t=this.getLocalRecurrenceStorageParsed();return!!t&&this.removeGivenStorage(window.localStorage,t)}getSessionRecurrence(){const t=this.getSessionRecurrenceStorageParsed();return!!t&&t[this.recurrenceKey]}getLocalRecurrence(){const t=this.getLocalRecurrenceStorageParsed();return!!t&&t[this.recurrenceKey]}getCurrentRecurrence(){if(this.pendingRecurrence)return this.pendingRecurrenceValue;const t=this.getSessionRecurrence(),e=this.getLocalRecurrence();return t||e||{type:!1}}isOver(){const t=localStorage.getItem(N),e=!(!t||!t.includes(this.recurrenceKey))||this.getSessionRecurrence();t&&(sessionStorage.setItem(k,t),localStorage.removeItem(N));const n=this.getLocalRecurrence(),r=(n?parseFloat(n.stamp):0)<(new Date).getTime();return r&&this.removeLocalRecurrenceStorage(),!this.pendingRecurrence&&r&&!this.getLocalRecurrence()&&!e}setRecurrence(t,n){0!==t&&(window.removeEventListener("storage",this.onStorage.bind(this)),this.isListeningStorageEvent=!1);const r=this.getTypeOfStorage(t);if(e()||!r&&"object"!=typeof r)return!1;const{storageString:i,storageMethod:s}=r,a=this.getStamp(t),c={type:n,stamp:a},{type:l}=this.getCurrentRecurrence(),h=async()=>{if(!o()){this.pendingRecurrence=!0,this.pendingRecurrenceValue=c;const t=new $({triggerEvent:"consent"});await t.isTriggered(),this.pendingRecurrence=!1,this.pendingRecurrenceValue={}}const t=this.getSessionRecurrence(),e=this.getLocalRecurrence();let n;"session"===i?t?n=this.removeSessionRecurrenceStorage():(this.removeLocalRecurrenceStorage(),n=this.getSessionRecurrenceStorageParsed()):"local"===i&&(e?n=this.removeLocalRecurrenceStorage():(this.removeSessionRecurrenceStorage(),n=this.getLocalRecurrenceStorageParsed()));const r=n?{[this.recurrenceKey]:c,...n}:{[this.recurrenceKey]:c};s.setItem(k,JSON.stringify(r)),this.onSetCallback&&"function"==typeof this.onSetCallback&&this.onSetCallback()};if(!s)return!1;if(l&&n!==L)if(n===A&&l!==L)h();else{if(n!==x||l===L||l===A)return!1;h()}else h();return a}setDisplayRecurrence(){const t=x;this.setRecurrence(this.displayRecurrence,t)}setClosingRecurrence(){const t=A;this.setRecurrence(this.closingRecurrence,t)}setValidationRecurrence(){const t=L;this.setRecurrence(this.validationRecurrence,t)}getStamp(t){return(new Date).getTime()+864e5*t}getTypeOfStorage(t){return!(isNaN(t)||t<0||0!==t&&!t)&&(t>0?{storageString:"local",storageMethod:window.localStorage}:0===t&&{storageString:"session",storageMethod:window.sessionStorage})}}class I{constructor(t,e,n){this.isWidgetApplied=t,this.callback=e,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(t){const e=!t&&this.isWidgetApplied(),n=e?this.shouldUpdate&&C:T;return n?(this.clearWatcher(),this.callback(n,!t,e),this.watch(),this):this}onCampaignLaunched({detail:{campaignId:t}}){t===TEST_ID&&(this.callback(T,!1),this.watch())}onTagRollback({target:t}){return this.clearWatcher(t),this.callback(E,!1,!0),window.addEventListener(...this.onCampaignLaunchedEventParams),this}observerHandler(t){return i()?t.some(t=>["removedNodes","addedNodes"].some(e=>t[e]&&t[e].length))?this.decisionHandler():this:this.callback(E,!1)}watch(e,n){if(t())return this;if(this.clearWatcher(e),window.removeEventListener(...this.onCampaignLaunchedEventParams),document.addEventListener(...this.tagRollbackEventParams),n?.includes("[]contentDocument[]")){const t=n.split("[]")[0].trim(),{clear:e}=f(t,t=>{e(),this.triggerIframeTarget=t,t.addEventListener("load",this.decisionHandler.bind(this))})}const r=e?.defaultView?.frameElement;r&&this.triggerIframeTarget!==r&&r.addEventListener("load",this.decisionHandler.bind(this));const{clear:i}=f("body",t=>{i();const n=e?.body||e||t;this.observer.observe(n,{childList:!0,subtree:!0})});return this}clearTriggerElementWatcher(){this.triggerIframeTarget?.removeEventListener("load",this.decisionHandler.bind(this))}clearWatcher(t){return document.removeEventListener(...this.tagRollbackEventParams),this.observer.disconnect(),this.clearTriggerElementWatcher(),t?.defaultView?.frameElement?.removeEventListener("load",this.decisionHandler.bind(this)),this}}const _=/.+\/([^.]+)\.(otf|ttf)$/,j=["socialProofPurchases","socialProofPageViews","socialProofVisitors"];class D{constructor(e,n){this.children=void 0,this.uniqueId=`${c()}${n?`_${n}`:""}`,this.widgetName=s(),this.prettyName=a(),this.recurrenceParams=(()=>{const{displayRecurrence:e,closingRecurrence:n,validationRecurrence:r}=DATA,i=!e&&!n&&!r;if(t()||i)return!1;const o={everytime:()=>-1,session:()=>0,once:()=>395,day:t=>DATA[`${t}_day`],week:t=>7*DATA[`${t}_week`],month:t=>30.5*DATA[`${t}_month`]},s={};return e&&(s.displayRecurrence=o[e]("displayRecurrence")),n&&(s.closingRecurrence=o[n]("closingRecurrence")),r&&(s.validationRecurrence=o[r]("validationRecurrence")),s})(),this.triggerParams=(e=>{let{triggerEvent:n}=DATA;const{triggerEventClick:r,triggerEventHover:i,triggerEventReengageDelay:o,socialProofContentType:s,triggerEventElementVisible:a,triggerEventDelay:c}=DATA;if(t()||!n&&!s)return!1;const l={click:()=>r,hover:()=>i,elementVisible:()=>a},h=Object.prototype.hasOwnProperty.call(l,n)?l[n]():"body",u="reengage"===n?o:c;return s&&(n=[,"socialProofPurchases","socialProofPageViews","socialProofVisitors"][s]),{triggerEvent:n,triggerSelector:h,triggerDelay:u,triggerTarget:e}})(e),this.recurrence=!!this.recurrenceParams&&new P(this.recurrenceParams,this.clearGivenClearables.bind(this)),this.trigger=!!this.triggerParams&&new $(this.triggerParams),this.shouldUpdate=!!this.triggerParams&&j.includes(this.triggerParams.triggerEvent),this.pageWatcher=new I(this.isWidgetApplied.bind(this),this.onPageChange.bind(this)),this.hasOncePerPageTrigger=(()=>{const{isOncePerPageTrigger:t,triggerEvent:e}=DATA;return!e||!["click","hover","scrollUp","script"].includes(e)||t})(),this.basicClassName=`ab_widget_container_${this.widgetName}`,this.widgetContainerId=`${this.basicClassName}_${this.uniqueId}`,this.contentClassName=`${this.basicClassName}_content`,this.overlayClassName=`${this.basicClassName}_overlay`,this.closeButtonClassName=`${this.basicClassName}_close_button`,this.hideClassName=`ab_hide_${this.uniqueId}`,this.rootElement=null,this.domElement=this.getDom(),this.hasBeenShown=!1,this.closedByUser=!1,this.elementsWaiters=[]}clearGivenClearables(){this.elementsWaiters.forEach(t=>t.clear()),this.elementsWaiters=[]}isWidgetApplied(){return this.domElement?.isConnected&&this.domElement.ownerDocument?.defaultView}removeOldDomElement(){const t=this.rootElement?.getElementById(this.widgetContainerId);return t?.remove(),this}async insert(){if(this.isWidgetApplied())return!1;const t=["free"];"drawer"===DATA.layout&&DATA.customTarget&&t.push("drawer");const e=t.includes(DATA.layout);return new Promise(t=>{const{elementReferrer:n="body",referrerInsertType:r="beforeend"}=e?DATA:{},i=f(n,e=>{this.elementsWaiters=this.elementsWaiters.filter(t=>t.selector!==n),this.rootElement=e.getRootNode(),this.removeOldDomElement(),this.domElement.appendChild(this.styleElement),t(e.insertAdjacentElement(r,this.domElement))});this.elementsWaiters.push(i)}).then(()=>this)}remove(){return this.trigger&&this.trigger.clear(),this.pageWatcher.clearWatcher(this.rootElement),this.domElement?.isConnected&&this.domElement.remove(),this.hasOncePerPageTrigger?this.pageWatcher.watch(this.rootElement):t()||this.init().then(({response:t})=>t?this.show():this),this}show(){return t()||this.hasBeenShown&&this.hasOncePerPageTrigger||window.ABTastyEvent(`${this.prettyName} displayed`,null,TEST_ID),this.closedByUser=!1,setTimeout(()=>this.domElement.classList.remove(this.hideClassName),50),this.recurrence&&this.recurrence.setDisplayRecurrence(),this.hasBeenShown=!0,this.pageWatcher.watch(this.rootElement),this}hide(e=!0){return!t()&&this.hasBeenShown&&e&&window.ABTastyEvent(`${this.prettyName} closed`,null,TEST_ID),e&&(this.pageWatcher.clearWatcher(this.rootElement),this.closedByUser=!0),this.domElement.classList.add(this.hideClassName),this}async init(e){const n=t(),r=i(),o=this.trigger?.promises?.length,s=!this.recurrence||this.recurrence.isOver();if(!n&&!r||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||e||this.hasBeenShown||void 0===this.children||"function"!=typeof this.children.refreshContent||this.children.refreshContent(a),c):c}onPageChange(t,e,n){const r=()=>this.init().then(({response:t})=>{t?this.show():this.hide(!1)});e||(this.hasBeenShown=!1,n&&this.domElement.remove(),this.trigger&&this.trigger.clear());const i={[E]:()=>n?this.remove():this.pageWatcher.watch(this.rootElement),[T]:()=>{this.hasBeenShown?this.closedByUser?this.pageWatcher.watch(this.rootElement):n||this.insert().then(t=>t.show()).catch(this.pageWatcher.watch):r()},[C]:()=>{this.hasBeenShown?this.pageWatcher.watch():r()}};"function"==typeof i[t]&&i[t]()}addCloseEvent(...e){const{closeButton:n,overlay:r,overlayClickable:i,layout:o,animationDuration:s=1e3}=DATA,a=[];if(void 0!==r&&!0!==r||!0!==i||"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=["click",e=>{(e=>{t()||(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation())})(e),this.recurrence&&this.recurrence.setClosingRecurrence(),this.hide(!0),setTimeout(()=>this.remove(),1.05*s)},{once:!0,capture:!0}];return e.push(...c),e.forEach(e=>{t()&&(e.dataset.abtastyActionnable="true"),e.removeEventListener(...l),e.addEventListener(...l)}),this}getDom(){const{closeButton:t,layout:e,overlayClickable:n,overlay:r=!0}=DATA,i=document.createElement("div");return i.className=`${this.basicClassName} ${this.hideClassName}`,i.id=this.widgetContainerId,["popin","bannerTop","bannerBottom"].includes(e)&&(i.role="dialog"),i.innerHTML=`\n\t\t\t${"popin"===e&&!0===r?`<div ${n?'aria-label="Close dialog"':""} class="${this.overlayClassName}"></div>`:""}\n\t\t\t<div class="${this.contentClassName}">\n\t\t\t${t?`<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>`,i}loadFont(t,e){if(!t||"inherit"===t||!/otf|ttf/g.test(e))return;const n=document.createElement("style"),r=e.match(_)?e.match(_)[1]:"";n.innerHTML=`@font-face { font-family: '${t}_${r}'; src: url('${e}'); font-display: swap; }`;const i=this.rootElement?.head||document.head;i?.appendChild(n)}getStyleTag(e="",n=DATA){const{noStyles:r,layout:i}=n,{backgroundColor:o,isBackgroundImage:s,backgroundImage:a,backgroundSize:c,backgroundPosition:l,backgroundRepeat:h,borderColor:u,borderRadius:d,borderWidth:m,textColor:p,textAlign:g,fontName:f,fontStyle:v,fontSize:y,isTitle:b,titleTextAlign:w,titleTextColor:E,titleFontName:T,titleFontStyle:C,titleFontSize:S,overlay:$,overlayColor:x,dropShadow:A,dropShadowColor:L,dropShadowBlur:k,containerMargin:N,containerPadding:P,closeButton:I,closeButtonPosition:j,closeButtonSize:D,closeButtonBorderRadius:O,closeButtonBorderWidth:R,closeButtonBorderColor:B,closeButtonColor:W,closeButtonBackgroundColor:V,buttonsAlign:q,buttonsBorderWidth:F,buttonsBorderColor:H,buttonsBorderRadius:M,buttonsBackgroundColor:G,buttonsTextColor:U,buttonsFontName:Q,buttonsFontStyle:K,buttonsFontSize:z,secondLink:Y,secondLinkBorderWidth:J,secondLinkBorderColor:X,secondLinkBorderRadius:Z,secondLinkBackgroundColor:tt,secondLinkTextColor:et,secondLinkFontName:nt,secondLinkFontStyle:rt,secondLinkFontSize:it,animation:ot,animationDuration:st,animationBehaviour:at,animationSlideDirection:ct}=r?{}:n,lt=document.createElement("style");t()&&lt.setAttribute("abtasty-script-added","true"),this.loadFont(f,v),this.loadFont(T,C),this.loadFont(Q,K),this.loadFont(nt,rt);const ht=`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()};`,ut="number"==typeof m&&m>0,dt=`border: ${[ut?`${m}px`:"unset",ut?"solid":"",ut&&"string"==typeof u&&u.length?u:""].join(" ").trim()};`,mt=void 0!==d?`border-radius: ${d}px;`:"",pt=void 0!==p?`color: ${p}; fill: ${p}; -webkit-text-fill-color: ${p};`:"",gt=void 0!==g?`text-align: ${g};`:"",ft=f&&"inherit"!==f?`font-family:${f}_${v.match(_)?v.match(_)[1]:""};`:v||"",vt=y?`font-size: ${y}px;`:"",yt=void 0!==A&&A?`box-shadow: 0 5px ${k}px 0 ${L};`:"",bt=N instanceof Array&&1===N.length&&N[0],wt=bt?`margin: ${bt.top}px ${bt.right}px ${bt.bottom}px ${bt.left}px;`:"",Et=bt?`margin: calc(${bt.top}px * 0.5) calc(${bt.right}px * 0.5) calc(${bt.bottom}px * 0.5) calc(${bt.left}px * 0.5);`:"",Tt=P instanceof Array&&1===P.length&&P[0],Ct=Tt?`padding: ${Tt.top}px ${Tt.right}px ${Tt.bottom}px ${Tt.left}px;`:"",St=Tt?`padding: calc(${Tt.top}px * 0.5) calc(${Tt.right}px * 0.5) calc(${Tt.bottom}px * 0.5) calc(${Tt.left}px * 0.5);`:"",$t=void 0!==F&&F?`border-width: ${F}px; border-style: solid;`:"",xt=[H,F].every(t=>void 0!==t)&&F?`border-color: ${H};`:"",At=void 0!==M?`border-radius: ${M}px;`:"",Lt=void 0!==G?`background-color: ${G};`:"",kt=void 0!==U?`color: ${U}; fill: ${U}; -webkit-text-fill-color: ${U};`:"",Nt=Q&&"inherit"!==Q?`font-family:${Q}_${K.match(_)?K.match(_)[1]:""};`:K||"",Pt=z?`font-size: ${z}px;`:"",It="number"==typeof J?`border-width: ${J}px; border-style: solid;`:"",_t=[X,J].every(t=>void 0!==t)&&J?`border-color: ${X};`:"",jt=void 0!==Z?`border-radius: ${Z}px;`:"",Dt=void 0!==tt?`background-color: ${tt};`:"",Ot=void 0!==et?`color: ${et}; fill: ${et}; -webkit-text-fill-color: ${et};`:"",Rt=nt&&"inherit"!==nt?`font-family:${nt}_${rt.match(_)?rt.match(_)[1]:""};`:rt||"",Bt=it?`font-size: ${it}px;`:"",Wt="popin"!==i||void 0!==$&&!0!==$?"":[`#${this.widgetContainerId} .${this.overlayClassName} {`,`background-color: ${void 0!==x?x:"rgba(0, 0, 0, 0.6)"};`,"}"].join(""),Vt="number"==typeof D?D:16,qt=Vt/2,Ft=r||void 0!==I&&I?[`#${this.widgetContainerId} .${this.contentClassName} .${this.closeButtonClassName} {`,"position: absolute;",("out"===j?`bottom: calc(100% + ${qt}px)`:`top: ${qt}px`)+";",`right: ${qt}px;`,"width: auto;","height: auto;","background: none;","border: none;","cursor: pointer;","padding: 0;","margin: 0;","line-height: 0;","z-index: 9;","number"==typeof O?`border-radius: ${O}px;`:"","number"==typeof R&&R>0?`border: ${R}px solid ${void 0!==B?B:"rgba(57, 57, 57, 1)"};`:"","string"==typeof V?`background-color: ${V};`:"","}",`#${this.widgetContainerId} .${this.contentClassName} .${this.closeButtonClassName} svg {`,"pointer-events: none;",`width: ${Vt}px;`,`height: ${Vt}px;`,"string"==typeof W?`fill: ${W};`:"","}"].join(""):"",Ht=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}_${C.match(_)?C.match(_)[1]:""};`:C||"",S?`font-size: ${S}px;`:"","}"].join(""):"";let Mt="";if("string"==typeof ot){const e=(st/1e3).toFixed(2),n=["top","bottom"].includes(ct),r=Number(n),i=[(["top","left"].includes(ct)?"-":"")+"100vmax",this.translateValues?this.translateValues[r]:"0"];n&&i.reverse(),Mt={none:[`.${this.hideClassName} {`,"opacity: 0 !important;","}"],fade:[`.${this.hideClassName} {`,"opacity: 0 !important;","}",`#${this.widgetContainerId} {`,`transition: opacity ${e}s ${at};`,"}"],slide:[`.${this.hideClassName} .${this.overlayClassName} {`,"opacity: 0 !important;","}",`#${this.widgetContainerId} .${this.overlayClassName} {`,`transition: opacity ${e}s ${at};`,"}",`.${this.hideClassName} .${this.contentClassName} {`,`transform: translate(${i.join(", ")}) !important;`,"}",`#${this.widgetContainerId} .${this.contentClassName} {`,`transition: transform ${e}s ${at};`,"}"]}[t()&&!ABTASTY_S.WIDGETS.animationChanged?"none":ot].join("")}const Gt=[`#${this.widgetContainerId} .${this.contentClassName} .buttons_container .second_link {`,`margin-${"fill"===q?"top":"left"}: 8px;`,It,_t,jt,Dt,Ot,Rt,Bt,"}",`#${this.widgetContainerId} .${this.contentClassName} .buttons_container .second_link {`,Ot,Rt,Bt,"}"];return lt.textContent=[`#${this.widgetContainerId} style { display: none; }`,`.${this.hideClassName} {`,"pointer-events: none;","}",`#${this.widgetContainerId} {`,"opacity: 1;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,ht,mt,dt,pt,gt,yt,wt,ft,vt,"}",`#${this.widgetContainerId} .${this.contentClassName} p {`,pt,gt,ft,vt,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,"display: block;","line-height: 1;","text-indent: unset;",Ct,ft,vt,"}",`#${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;",$t,xt,At,Lt,kt,Nt,Pt,"}",`#${this.widgetContainerId} .${this.contentClassName} div.buttons_container a *, `,`#${this.widgetContainerId} .${this.contentClassName} button:not(class*="close_button") * {`,kt,Nt,Pt,"}",...Y?Gt:[],"@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,Et,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,St,"}","}",Wt,Ft,Ht,Mt,`${e}`].join(""),lt}}const O=["top: 0;","top: 50%;","bottom: 0;"],R=["left: 0;","left: 50%;","right: 0;"],B=t=>1===t?"-50%":0,W=()=>{if(Array.isArray(DATA.popinPosition)){const{popinPosition:[{x:t,y:e}]}=DATA,n=`translate(${B(e)}, ${B(t)});`;return`${O[t]}${R[e]}transform: ${n}`}return"left: 50%;top: 50%;transform: translate(-50%, -50%);"},V=()=>"autoWidth"in DATA&&!0===DATA.autoWidth,q=()=>{if(V())return"width: auto; height: auto; min-width: fit-content;";const{popinPercentWidth:t,popinPixelsWidth:e,widthUnit:n,autoHeight:r,popinPercentHeight:i,popinPixelsHeight:o,heightUnit:s}=DATA;return`width: ${"px"===n?e:t}${n};height: ${r?"auto":`${"px"===s?o:i}${s}`};`};class F extends D{constructor(){super(),this.translateValues=Object.values(DATA.popinPosition[0]).map(t=>B(t)),this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){const{zindex:t,zindexCustom:e,widthUnit:n}=DATA,r="string"!=typeof DATA.overlay&&DATA.overlay;return[`#${this.widgetContainerId} {`,"position: fixed;","top: 0;","left: 0;","width: 100%;","height: 100%;",`z-index: ${"custom"===t?e:t};`,"background: none;","pointer-events: "+(r?"all":"none"),"}",`#${this.widgetContainerId} .${this.overlayClassName} {`,"position: absolute;","z-index: -1;","top: 0;","left: 0;","width: 100%;","height: 100%;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: absolute;",W(),q(),"pointer-events: all","}",`${V()?"":[`#${this.widgetContainerId} .${this.contentClassName} > div {`,"height: 100%;","overflow: auto;","box-sizing: border-box;","}"].join("")}`,`${!V()&&["px","em"].includes(n)?["@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,"max-width: 94vw;","}","}"].join(""):""}`].join("")}}class H extends D{constructor(){super(),this.position="string"==typeof DATA.layout&&"bannerTop"===DATA.layout?"top":"bottom",this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){const{zindex:t,zindexCustom:e}=DATA;return[`#${this.widgetContainerId} {`,"position: fixed;",`${this.position}: 0;`,"left: 0;","width: 100%;","height: auto;",`z-index: ${"custom"===t?e:t};`,"background: none;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: relative;","}"].join("")}}class M extends D{constructor(t,e){super(t,e),this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){return[`#${this.widgetContainerId} {`,"width: auto;","height: auto;","margin: 0;","padding: 0;","background: none;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: relative;","}"].join("")}}const G=()=>{const{layout:t}=DATA;let e;switch(t){case"popin":e=new F;break;case"bannerTop":case"bannerBottom":e=new H;break;case"free":e=new M;break;default:e=new D}return e};function U(t){return U="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},U(t)}function Q(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */Q=function(){return e};var t,e={},n=Object.prototype,r=n.hasOwnProperty,i=Object.defineProperty||function(t,e,n){t[e]=n.value},o="function"==typeof Symbol?Symbol:{},s=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function l(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,n){return t[e]=n}}function h(t,e,n,r){var o=e&&e.prototype instanceof f?e:f,s=Object.create(o.prototype),a=new k(r||[]);return i(s,"_invoke",{value:$(t,n,a)}),s}function u(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}e.wrap=h;var d="suspendedStart",m="executing",p="completed",g={};function f(){}function v(){}function y(){}var b={};l(b,s,function(){return this});var w=Object.getPrototypeOf,E=w&&w(w(N([])));E&&E!==n&&r.call(E,s)&&(b=E);var T=y.prototype=f.prototype=Object.create(b);function C(t){["next","throw","return"].forEach(function(e){l(t,e,function(t){return this._invoke(e,t)})})}function S(t,e){function n(i,o,s,a){var c=u(t[i],t,o);if("throw"!==c.type){var l=c.arg,h=l.value;return h&&"object"==U(h)&&r.call(h,"__await")?e.resolve(h.__await).then(function(t){n("next",t,s,a)},function(t){n("throw",t,s,a)}):e.resolve(h).then(function(t){l.value=t,s(l)},function(t){return n("throw",t,s,a)})}a(c.arg)}var o;i(this,"_invoke",{value:function(t,r){function i(){return new e(function(e,i){n(t,r,e,i)})}return o=o?o.then(i,i):i()}})}function $(e,n,r){var i=d;return function(o,s){if(i===m)throw Error("Generator is already running");if(i===p){if("throw"===o)throw s;return{value:t,done:!0}}for(r.method=o,r.arg=s;;){var a=r.delegate;if(a){var c=x(a,r);if(c){if(c===g)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===d)throw i=p,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=m;var l=u(e,n,r);if("normal"===l.type){if(i=r.done?p:"suspendedYield",l.arg===g)continue;return{value:l.arg,done:r.done}}"throw"===l.type&&(i=p,r.method="throw",r.arg=l.arg)}}}function x(e,n){var r=n.method,i=e.iterator[r];if(i===t)return n.delegate=null,"throw"===r&&e.iterator.return&&(n.method="return",n.arg=t,x(e,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),g;var o=u(i,e.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,g;var s=o.arg;return s?s.done?(n[e.resultName]=s.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,g):s:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,g)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function L(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function N(e){if(e||""===e){var n=e[s];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=function n(){for(;++i<e.length;)if(r.call(e,i))return n.value=e[i],n.done=!1,n;return n.value=t,n.done=!0,n};return o.next=o}}throw new TypeError(U(e)+" is not iterable")}return v.prototype=y,i(T,"constructor",{value:y,configurable:!0}),i(y,"constructor",{value:v,configurable:!0}),v.displayName=l(y,c,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,l(t,c,"GeneratorFunction")),t.prototype=Object.create(T),t},e.awrap=function(t){return{__await:t}},C(S.prototype),l(S.prototype,a,function(){return this}),e.AsyncIterator=S,e.async=function(t,n,r,i,o){void 0===o&&(o=Promise);var s=new S(h(t,n,r,i),o);return e.isGeneratorFunction(n)?s:s.next().then(function(t){return t.done?t.value:s.next()})},C(T),l(T,c,"Generator"),l(T,s,function(){return this}),l(T,"toString",function(){return"[object Generator]"}),e.keys=function(t){var e=Object(t),n=[];for(var r in e)n.push(r);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},e.values=N,k.prototype={constructor:k,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(L),!e)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var n=this;function i(r,i){return a.type="throw",a.arg=e,n.next=r,i&&(n.method="next",n.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var s=this.tryEntries[o],a=s.completion;if("root"===s.tryLoc)return i("end");if(s.tryLoc<=this.prev){var c=r.call(s,"catchLoc"),l=r.call(s,"finallyLoc");if(c&&l){if(this.prev<s.catchLoc)return i(s.catchLoc,!0);if(this.prev<s.finallyLoc)return i(s.finallyLoc)}else if(c){if(this.prev<s.catchLoc)return i(s.catchLoc,!0)}else{if(!l)throw Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return i(s.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var s=o?o.completion:{};return s.type=t,s.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(s)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),g},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),L(n),g}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var i=r.arg;L(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:N(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),g}},e}function K(t,e,n,r,i,o,s){try{var a=t[o](s),c=a.value}catch(t){return void n(t)}a.done?e(c):Promise.resolve(c).then(r,i)}function z(t){return function(){var e=this,n=arguments;return new Promise(function(r,i){var o=t.apply(e,n);function s(t){K(o,r,i,s,a,"next",t)}function a(t){K(o,r,i,s,a,"throw",t)}s(void 0)})}}function Y(t){var e=function(t){if("object"!=U(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=U(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==U(e)?e:e+""}var J={angry:"rgba(234, 78, 45, 1)",sad:"rgba(227, 119, 31, 1)",neutral:"rgba(224, 185, 10, 1)",happy:"rgba(28, 191, 151, 1)",excited:"rgba(85, 174, 218, 1)"},X=Object.keys(J),Z=function(){return e=function e(n){var r=n.parentContainer;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),this.parentContainer=r,this.baseClassName="csat_container",this.className="".concat(this.baseClassName,"_").concat(r.uniqueId),this.voteClassName="".concat(this.baseClassName,"_vote"),this.questionClassName="".concat(this.baseClassName,"_question"),this.thanksClassName="".concat(this.baseClassName,"_thanks"),this.hideClassName="csat_".concat(r.uniqueId,"_display_none"),this.steps=["vote",!!DATA.askOpenQuestion&&"question",!!DATA.isThankYouMessage&&"thanks","complete"].filter(function(t){return"string"==typeof t}),this.currentStep=t()?DATA.stepPreview:"vote",this.emojiChoice=NaN,this.currentNote=NaN,this.currentFeedback="",this.currentOpenQuestion=DATA.openQuestionPositive,this.emojisList=this.getEmojisList(),this.CSATContainer=document.createElement("div"),this.voteElement=null,this.questionElement=this.getQuestionElement(),this.thanksElement=this.getThanksElement(),this.CSATElement=null},n=[{key:"getABtastyEmojis",value:(o=z(Q().mark(function t(){var e=this;return Q().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Promise.all(this.emojisList.map(function(t){var n=t.iconUrl;return e.fetchTastyEmojis(n)}));case 2:window.abtastyEmojis=t.sent,this.emojisList.forEach(function(t,e){t.iconUrl=window.abtastyEmojis[e]});case 4:case"end":return t.stop()}},t,this)})),function(){return o.apply(this,arguments)})},{key:"insertIn",value:(i=z(Q().mark(function t(e,n){var r;return Q().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if("abtasty"!==DATA.emojisType||null!==(r=window.abtastyEmojis)&&void 0!==r&&r.length){t.next=4;break}return t.next=4,this.getABtastyEmojis();case 4:return this.setStyles(),this.CSATElement=this.getCSATElement(),e.insertAdjacentElement(n,this.CSATElement),t.abrupt("return",this.showCurrentStep());case 8:case"end":return t.stop()}},t,this)})),function(t,e){return i.apply(this,arguments)})},{key:"setQuestion",value:function(){var t=DATA,e=t.layout,n=t.openQuestionPositive,r=t.openQuestionNeutral,i=t.openQuestionNegative,o=[i,i,r,n,n][this.emojiChoice]||n,s=this.questionElement.querySelector("textarea");return this.currentOpenQuestion=o,s.ariaLabel=o,["popin","bannerTop","bannerBottom"].includes(e)&&(this.parentContainer.domElement.ariaLabel=o),s.focus(),this.questionElement.querySelector("p").innerHTML=o,this}},{key:"getQuestionElement",value:function(){var e=this,n=DATA,r=n.openQuestionPositive,i=n.sendButtonText,o=document.createElement("div");o.className=this.questionClassName,o.innerHTML="<p>".concat(r,"</p>\n\t\t<textarea></textarea>\n\t\t<button>").concat(i,"</button>");var s=o.querySelector("button");return t()&&(s.dataset.abtastyActionnable="true"),s.addEventListener("click",function(){e.currentFeedback=o.querySelector("textarea").value,e.currentStep=e.steps[e.steps.indexOf(e.currentStep)+1],e.showCurrentStep()},{passive:!0,capture:!0,once:!0}),o}},{key:"getThanksElement",value:function(){var t=DATA,e=t.thanksMessage,n=t.layout,r=document.createElement("p");return r.className=this.thanksClassName,r.innerHTML=e,["popin","bannerTop","bannerBottom"].includes(n)&&(this.parentContainer.domElement.ariaLabel=e),r}},{key:"sendDatas",value:function(){return window.abtasty.send("event",{ec:"csat",ea:"Customer Satisfaction",ev:this.currentNote,el:DATA.mainQuestion,caid:TEST_ID,vaid:VARIATION_ID,cv:{0:"openEndedQuestion, ".concat(this.currentOpenQuestion),1:"openEndedAnswer, ".concat(this.currentFeedback),2:"maxScore, ".concat(DATA.emojisQty)}}),l("Sending datas, note: ".concat(this.currentNote,"/").concat(DATA.emojisQty,', feedback: "').concat(this.currentFeedback,'"')),this}},{key:"complete",value:function(){var t=this;this.parentContainer.recurrence.setValidationRecurrence();var e=DATA,n=e.autoHide,r=e.timeHide;return n?(this.CSATContainer.style.pointerEvents="none",setTimeout(function(){t.parentContainer.hide(!1),t.parentContainer.pageWatcher.clearWatcher(),t.parentContainer.closedByUser=!0,setTimeout(function(){return t.parentContainer.remove()},1e3)},1e3*r),this):this}},{key:"showCurrentStep",value:function(){var e=this,n=!t();return"complete"!==this.currentStep&&([this.voteElement,this.questionElement,this.thanksElement].forEach(function(t){return t.classList.add(e.hideClassName)}),this["".concat(this.currentStep,"Element")].classList.remove(this.hideClassName)),"question"===this.currentStep?this.setQuestion():["thanks","complete"].includes(this.currentStep)&&n?this.sendDatas().complete():this}},{key:"fetchTastyEmojis",value:(r=z(Q().mark(function t(e){return Q().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch(e,{method:"GET",mode:"cors",cache:"no-cache",referrerPolicy:"no-referrer"}).then(function(t){return t.blob()}).then(function(t){return t.text()}).then(function(t){return t}).catch(function(t){return console.error("ERROR on loading picture, message: ".concat(t))});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},t)})),function(t){return r.apply(this,arguments)})},{key:"getEmojisList",value:function(){var t=DATA.emojisType;return X.map(function(e,n){var r;return{index:n,iconUrl:"abtasty"===t?null!==(r=window.abtastyEmojis)&&void 0!==r&&r.length?window.abtastyEmojis[n]:"".concat("https://widgets-images.abtasty.com/","csat/").concat(e,".svg"):"<img src='".concat(DATA["".concat(e,"EmojiCustom")],"'>"),iconText:DATA["".concat(e,"EmojiText")],className:"csatEmojiButton ".concat(e,"EmojiButton")}})}},{key:"onEmojiClick",value:function(t){var e=t.currentTarget;return isNaN(this.currentNote)&&(this.emojiChoice=Number(e.dataset.index),this.currentNote=Number(e.dataset.note)),this.currentStep=this.steps[this.steps.indexOf(this.currentStep)+1],this.showCurrentStep()}},{key:"getEmojiButton",value:function(e,n){var r=DATA,i=r.emojisType,o=r.mainQuestion,s=r.emojisQty,a=document.createElement("button");return a.className=e.className,a.dataset.index=e.index,a.dataset.note=n,a.ariaLabel="".concat(o," - ").concat(n,"/").concat(s),a.innerHTML="text"===i?e.iconText:e.iconUrl,t()&&(a.dataset.abtastyActionnable="true"),a.addEventListener("click",this.onEmojiClick.bind(this),{passive:!0,capture:!0}),a}},{key:"getEmojisContainer",value:function(){var e=this,n=DATA,r=n.emojisQty,i=n.stepPreview,o=n.mainQuestion,s=n.layout,a=document.createElement("p");a.innerHTML=o,["popin","bannerTop","bannerBottom"].includes(s)&&(this.parentContainer.domElement.ariaLabel=o);var c=document.createElement("div");c.className=this.voteClassName,c.appendChild(a);var l=[,,[0,4],[0,2,4],[0,1,3,4],[0,1,2,3,4]];return this.emojisList.forEach(function(t,n){if(l[r].includes(n)){var i=l[r].indexOf(n)+1,o=e.getEmojiButton(t,i);c.appendChild(o)}}),(t()&&"vote"!==i||"vote"!==this.currentStep)&&c.classList.add(this.hideClassName),c}},{key:"getCSATElement",value:function(){var t=DATA,e=t.askOpenQuestion,n=t.isThankYouMessage;return this.CSATContainer.classList.add("".concat(this.baseClassName),"".concat(this.className)),this.voteElement=this.getEmojisContainer(),this.CSATContainer.appendChild(this.voteElement),(e||"question"===this.currentStep)&&this.CSATContainer.appendChild(this.questionElement),(n||"thanks"===this.currentStep)&&this.CSATContainer.appendChild(this.thanksElement),this.CSATContainer}},{key:"setStyles",value:function(){var t=this.parentContainer,e=t.styleElement,n=t.widgetContainerId,r=t.contentClassName,i=DATA,o=i.emojisType,s=i.customColors,a=i.emojisMargin,c=i.borderColor,l=i.textColor,h=i.backgroundColor,u=X.reduce(function(t,e){var n=s?DATA["".concat(e,"Color")]:J[e],r=".csat_emoji_".concat(e," .csat_emoji_shadow,\n\t\t\t.csat_emoji_").concat(e," .csat_emoji_head {\n\t\t\t\tfill: ").concat(n,";\n\t\t\t}");return"".concat(t).concat(r)},""),d=[["abtasty"===o?u:"",".csatEmojiButton {","all: unset !important;","margin: 0 ".concat(a,"px !important;"),"font-size: 30px !important;","cursor: pointer !important;","}",".csatEmojiButton svg {","overflow: visible;","pointer-events: none;","}",".csatEmojiButton .csat_emoji > * {","transform-origin: center;","transition: transform .5s ease;","}",".csatEmojiButton:hover .csat_emoji_shadow {","transform: scale(1.4);","}",".csatEmojiButton:hover .csat_emoji_shadow ~ * {","transform: scale(1.2);","}",".csat_emoji_shadow {","opacity: 0.1;","}",".csat_emoji_mouth,",".csat_emoji_eyebrow,",".csat_emoji_eye {","mix-blend-mode: multiply;","fill: rgb(57, 57, 57);","}",".csat_emoji_mouth,",".csat_emoji_eyebrow {","opacity: 0.5;","}"].join(""),".".concat(this.questionClassName," textarea {"),"width: 100%;","min-height: 60px;","margin-top: 12px;","margin-bottom: 20px;","border: 2px solid ".concat(c,";"),"color: ".concat(l,";"),"}",".".concat(this.className," textarea::selection,\n\t\t\t.").concat(this.className," p::selection {"),"-webkit-text-fill-color: ".concat(h,";"),"text-fill-color: ".concat(h,";"),"color: ".concat(h,";"),"background-color: ".concat(c,";"),"}",".".concat(this.questionClassName," button {"),"cursor: pointer;","}",".".concat(this.voteClassName," p {"),"margin-bottom: 12px;","}","#".concat(n," .").concat(r," .").concat(this.className," {"),"overflow: hidden;","}",".".concat(this.className," > * {"),"opacity: 1;","height: auto;","}",".".concat(this.className," > .").concat(this.hideClassName," {"),"opacity: 0;","pointer-events: none;","transition: opacity 0.5s ease;","height: 0;","}"].join("");return e.insertAdjacentText("beforeend",d),e}}],n&&function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Y(r.key),r)}}(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n,r,i,o}();function tt(t){return tt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},tt(t)}function et(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */et=function(){return e};var t,e={},n=Object.prototype,r=n.hasOwnProperty,i=Object.defineProperty||function(t,e,n){t[e]=n.value},o="function"==typeof Symbol?Symbol:{},s=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function l(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,n){return t[e]=n}}function h(t,e,n,r){var o=e&&e.prototype instanceof f?e:f,s=Object.create(o.prototype),a=new k(r||[]);return i(s,"_invoke",{value:$(t,n,a)}),s}function u(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}e.wrap=h;var d="suspendedStart",m="executing",p="completed",g={};function f(){}function v(){}function y(){}var b={};l(b,s,function(){return this});var w=Object.getPrototypeOf,E=w&&w(w(N([])));E&&E!==n&&r.call(E,s)&&(b=E);var T=y.prototype=f.prototype=Object.create(b);function C(t){["next","throw","return"].forEach(function(e){l(t,e,function(t){return this._invoke(e,t)})})}function S(t,e){function n(i,o,s,a){var c=u(t[i],t,o);if("throw"!==c.type){var l=c.arg,h=l.value;return h&&"object"==tt(h)&&r.call(h,"__await")?e.resolve(h.__await).then(function(t){n("next",t,s,a)},function(t){n("throw",t,s,a)}):e.resolve(h).then(function(t){l.value=t,s(l)},function(t){return n("throw",t,s,a)})}a(c.arg)}var o;i(this,"_invoke",{value:function(t,r){function i(){return new e(function(e,i){n(t,r,e,i)})}return o=o?o.then(i,i):i()}})}function $(e,n,r){var i=d;return function(o,s){if(i===m)throw Error("Generator is already running");if(i===p){if("throw"===o)throw s;return{value:t,done:!0}}for(r.method=o,r.arg=s;;){var a=r.delegate;if(a){var c=x(a,r);if(c){if(c===g)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===d)throw i=p,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=m;var l=u(e,n,r);if("normal"===l.type){if(i=r.done?p:"suspendedYield",l.arg===g)continue;return{value:l.arg,done:r.done}}"throw"===l.type&&(i=p,r.method="throw",r.arg=l.arg)}}}function x(e,n){var r=n.method,i=e.iterator[r];if(i===t)return n.delegate=null,"throw"===r&&e.iterator.return&&(n.method="return",n.arg=t,x(e,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),g;var o=u(i,e.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,g;var s=o.arg;return s?s.done?(n[e.resultName]=s.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,g):s:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,g)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function L(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function N(e){if(e||""===e){var n=e[s];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=function n(){for(;++i<e.length;)if(r.call(e,i))return n.value=e[i],n.done=!1,n;return n.value=t,n.done=!0,n};return o.next=o}}throw new TypeError(tt(e)+" is not iterable")}return v.prototype=y,i(T,"constructor",{value:y,configurable:!0}),i(y,"constructor",{value:v,configurable:!0}),v.displayName=l(y,c,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,l(t,c,"GeneratorFunction")),t.prototype=Object.create(T),t},e.awrap=function(t){return{__await:t}},C(S.prototype),l(S.prototype,a,function(){return this}),e.AsyncIterator=S,e.async=function(t,n,r,i,o){void 0===o&&(o=Promise);var s=new S(h(t,n,r,i),o);return e.isGeneratorFunction(n)?s:s.next().then(function(t){return t.done?t.value:s.next()})},C(T),l(T,c,"Generator"),l(T,s,function(){return this}),l(T,"toString",function(){return"[object Generator]"}),e.keys=function(t){var e=Object(t),n=[];for(var r in e)n.push(r);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},e.values=N,k.prototype={constructor:k,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(L),!e)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var n=this;function i(r,i){return a.type="throw",a.arg=e,n.next=r,i&&(n.method="next",n.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var s=this.tryEntries[o],a=s.completion;if("root"===s.tryLoc)return i("end");if(s.tryLoc<=this.prev){var c=r.call(s,"catchLoc"),l=r.call(s,"finallyLoc");if(c&&l){if(this.prev<s.catchLoc)return i(s.catchLoc,!0);if(this.prev<s.finallyLoc)return i(s.finallyLoc)}else if(c){if(this.prev<s.catchLoc)return i(s.catchLoc,!0)}else{if(!l)throw Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return i(s.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var s=o?o.completion:{};return s.type=t,s.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(s)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),g},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),L(n),g}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var i=r.arg;L(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:N(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),g}},e}function nt(t,e,n,r,i,o,s){try{var a=t[o](s),c=a.value}catch(t){return void n(t)}a.done?e(c):Promise.resolve(c).then(r,i)}var rt=function(){var t,e=(t=et().mark(function t(){var e,n,r;return et().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return l("Widget launch"),e=G(),n=e.domElement.querySelector(".".concat(e.contentClassName)),r=new Z({parentContainer:e}),e.children=r,t.next=8,r.insertIn(n,"beforeend");case 8:return e.init(!0).then(function(t){return t.response&&e.show()}),t.abrupt("return",{parentContainer:e,CSAT:r});case 10:case"end":return t.stop()}},t)}),function(){var e=this,n=arguments;return new Promise(function(r,i){var o=t.apply(e,n);function s(t){nt(o,r,i,s,a,"next",t)}function a(t){nt(o,r,i,s,a,"throw",t)}s(void 0)})});return function(){return e.apply(this,arguments)}}();rt()}();
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},s=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}`),n=()=>!e()&&(t()||!!window.ABTasty.getTestsOnPage()[TEST_ID]),r=()=>window.ABTasty&&!0===window.ABTasty.consentReady,o=()=>{const{type:e}=DATA;return`${PACKAGE.replace("@abtasty/","")}${e?`_${e}`:""}`},a=()=>{const e=o();return`${e.charAt(0).toUpperCase()}${e.slice(1)}`.split("-").join(" ")},c=()=>`${PLUGIN_ID.split("-")[0]}_${TEST_ID}`,l=s=>{const i=(()=>{if(e()||t())return!1;const s=ABTasty.getTestsOnPage()[TEST_ID];return!!s&&Object.keys(s.targetings.qaParameters).length>0})(),n=window.document.cookie.includes("abTastyDebug=")||!0===window.abTastyDebug;if(i||n){const e=a();window.console.log(`%c${e} - ${i?"QA":"Debug"} Mode for campaign ${TEST_ID} %c ${s}`,"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,s)=>{t.resolve=e,t.reject=s}),t},d=(e,t)=>{const s=t?[]:null;if("string"!=typeof e||!e.trim().length)return s;const[i,n,r]=e.split("[]").map(e=>e.trim()),o=Boolean(r)?r:e,a=n?document.querySelector(i)?.[n]:document;return a?t?[...a.querySelectorAll(o)]:a.querySelector(o):s},u=e=>d(e,!1),m=e=>d(e,!0),g=(e,t)=>{const s={childList:!0,subtree:!0,attributes:!0},i=()=>n.disconnect(),n=new MutationObserver(()=>{const s=u(t);return s&&!i()&&e(s)});return{clear:i,observe:e=>{const t=document.querySelector("body")||document.documentElement,i=e??t;n.observe(i,s)}}},p=()=>{},v=(t,s)=>{const i=u(t),n={selector:t,clear:p,observe:p};if(i)return setTimeout(()=>s(i),0),n;if(e())return setTimeout(()=>v(t,s),1e3),n;if(t.includes("[]"))return((e,t)=>{const[s,i]=t.split("[]").map(e=>e.trim()),n=u(s),r=n?.[i],{clear:o,observe:a}=g(e,t),c=()=>{const s=u(t);return s&&!l()&&e(s)},l=()=>{o(),n?.removeEventListener("load",c)},h=()=>{a(r),"iframe"===n?.localName&&n.addEventListener("load",c)};return h(),{selector:t,clear:l,observe:h}})(s,t);const{clear:r,observe:o}=g(s,t);return o(),{selector:t,clear:r,observe:o}};function y(e,t){const s=e.parentElement||e.getRootNode().host;return t(e)||!s?e:y(s,t)}const b=(e,t)=>[...m(t)].some(s=>{const[i,,n]=t.split("[]"),r=n??i;return s===e||!!e.closest(r)});let f=!1;class w{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:0};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 s=this.inViewportTargets.find(({element:s,selector:i})=>{if(s.isSameNode(e))return!0;const[n,,r]=i.split("[]"),o=r??n,a=[...e.querySelectorAll(o)];if(a.length&&a.includes(s))return!0;if(t.includes(s))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(s))return!0;if(h.some(e=>[...e.querySelectorAll(o)].includes(s)))return!0}return!1});if(s&&this.isElementVisible(s.element)){const{selector:e,element:t,uniqueId:i}=s,n=this.targets.find(t=>t.selector===e&&t.uniqueId===i);n&&n.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:s}=e;setTimeout(()=>this.onMouseOver({target:s,path:t}),50)},!0];return this.getEvents(...t)}scrollEventHandler(e){const t=[e,"scroll",(s=this.checkElements.bind(this),()=>{f||(f=!0,setTimeout(()=>{s(),f=!1},100))}),{passive:!0}];var s;return this.getEvents(...t)}isElementVisible(e){return this.isElementOpaque(e)&&this.isElementTopmost(e)}isElementOpaque(e){return"HTML"===y(e,e=>"0"===window.getComputedStyle(e).opacity).nodeName}isElementTopmost(e){const t=e.getBoundingClientRect(),s=[[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,n=0;for(;!i&&n<s.length;){const t=e.getRootNode()?.elementFromPoint(...s[n]);i=e===t||t?.contains(e)||e.contains(t),n+=1}return i}checkElements(){this.targets.forEach(({selector:e,uniqueId:t})=>{const s=u(e),[i,,n]=e.split("[]"),r=n??i;s&&!this.existingTargets.find(e=>e.element.matches(r)&&e.uniqueId===t)&&(this.existingTargets.push({element:s,selector:e,uniqueId:t}),this.visibilityObserver.observe(s))}),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:s})=>{const[i,,n]=e.split("[]"),r=n??i;if(t.matches(r)&&this.isElementVisible(t)){const i=this.targets.find(t=>t.selector===e&&t.uniqueId===s);return i&&i.resolve(t),this.clear(e,s),!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,s){this.targets.push({selector:e,resolve:t,uniqueId:s});const{clear:i}=v(e,e=>{i();const t=e.getRootNode({composed:!0}),s="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(s),this.checkElements()})}clear(e,t){[this.targets,this.existingTargets,this.inViewportTargets]=[this.targets,this.existingTargets,this.inViewportTargets].map(s=>s.filter(({selector:s,uniqueId:i})=>s!==e&&i!==t));const s=u(e);s&&this.visibilityObserver?.unobserve(s),0===this.targets.length&&(this.mutationObserver?.disconnect(),this.onIframeLoad?.clear()),0===this.inViewportTargets.length&&(this.mouseOverEvent?.clear(),this.scrollEvent?.clear(),this.onTransitionEnd?.clear())}}const $="remove",T="rebuild",E="update",C="ABTastyData";class S{constructor({triggerEvent:e,triggerSelector:t,triggerDelay:s,triggerTarget:i}){this.event=e,this.selector=Boolean(t)?t:"body",this.target="string"==typeof i?u(t):i,this.delay=1e3*s,this.triggerElements=[],this.eventsListeners=[],this.timeouts=[],this.intervals=[],this.promises=[],this.visibilityObservers=[],this.socialProofStore={},this.elementWaiters=[]}async onElementVisible({promise:e,resolve:t}){const s=h(`${this.event}DomReady`);this.promises.push(s);const{clear:i}=v(this.selector,()=>{const e=new w;this.visibilityObservers.push(e),e.watch(this.selector,t,c())});return this.elementWaiters.push(i),e}onPageLoad({promise:e,resolve:t}){const s=()=>"complete"===document.readyState;if(!s()){const i=["readystatechange",()=>s()&&t(!0),{passive:!0}];return this.eventsListeners.push([document,...i]),document.addEventListener(...i),e}return t(!0),e}onClick({promise:e,resolve:t}){const s=({isTrusted:e,target:s})=>{if(e)return(s.isEqualNode(this.target)||b(s,this.selector))&&t(!0)},{clear:i}=v(this.selector,e=>{i();const t=document.createElement("style");t.id=`Click_${c()}`;const[n,,r]=this.selector.split("[]"),o=r??n;t.innerHTML=`${o} {\n\t\t\t\tcursor: pointer !important;\n\t\t\t\tpointer-events: all !important;\n\t\t\t}`;const a=e.getRootNode();("head"in a?a.head:a).appendChild(t),this.triggerElements.push(t);const l=["click",s,{passive:!0,capture:!0}];this.eventsListeners.push([a,...l]),a.addEventListener(...l)});return this.elementWaiters.push(i),e}onHover({promise:e,resolve:t}){const s=({isTrusted:e,target:s})=>{if(e)return(this.target?s.isEqualNode(this.target):b(s,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)),n=["mouseenter",s,{passive:!0,capture:!0}];this.eventsListeners.push([i,...n]),i.addEventListener(...n)});return this.elementWaiters.push(i),e}onExitIntent({promise:e,resolve:t}){const s=["mouseleave",({isTrusted:e,clientY:s})=>{e&&s<=0&&t(!0)},{passive:!0}],{clear:i}=v("html",e=>{i(),this.eventsListeners.push([e,...s]),e.addEventListener(...s)});return e}onReengage({promise:e,resolve:t}){const s=this.delay;let i=s;const n=[...document.querySelectorAll("*:empty")].map(e=>e.contentDocument||e.shadowRoot).filter(e=>e),r=[({isTrusted:e})=>{e&&(i=s)},{passive:!0}];["click","mousemove","scroll","keypress"].forEach(e=>{[document,...n].forEach(t=>{this.eventsListeners.push([t,e,...r]),t.addEventListener(e,...r)})});const o=setInterval(()=>{i<=0?t(!0):i-=100},100);return this.intervals.push(o),e}onCustomTrigger({promise:e,resolve:t}){const{triggerEventCustomScript:s,tagIsSafeEval:i}=DATA,n=i&&DATA_JS?.triggerEventCustomScript,r="function"==typeof n?()=>new Promise(e=>n(e)):new Function(`return new Promise(async resolve => {${s}})`);return r().then(e=>e&&t(!0)),e}onScrollUp({promise:e,resolve:t}){let s=0;const i=["scroll",({isTrusted:e})=>{e&&(window.scrollY<s?t(!0):s=window.scrollY)},{passive:!0,capture:!0}];return this.eventsListeners.push([document,...i]),document.addEventListener(...i),e}onScrollPercentReached({promise:e,resolve:t}){const{triggerEventScrollPercent:s}=DATA,i=["scroll",({isTrusted:e})=>{if(!e)return;const i=(()=>{const{documentElement:e,body:t}=document,s=e.scrollTop||t.scrollTop,i=e.scrollHeight||t.scrollHeight;return Math.trunc(s/(i-e.clientHeight)*100,10)})();s<i&&t(!0)},{passive:!0,capture:!0}];return this.eventsListeners.push([document,...i]),document.addEventListener(...i),e}checkSocialProofConditions(e,t,s,i){const n=(()=>{let e;return window.ABTasty||window.ABTASTY_S?(window.ABTASTY_S?.USER?.accountIdentifier?.length?e=window.ABTASTY_S.USER.accountIdentifier:"function"==typeof window.ABTasty?.getAccountSettings?e=window.ABTasty.getAccountSettings().identifier:window.ABTasty?.accountSettings&&(e=window.ABTasty.accountSettings.identifier),e):e})(),{viewInterval:r,spNoTrim:o}=DATA;if(this.socialProofStore.hasOwnProperty(e))s(this.socialProofStore[e])?i(`${this.socialProofStore[e][r]}`):i(!1);else if(e&&n){const a=t=>(this.socialProofStore[e]=t,i(!!s(t)&&`${t[r]}`));fetch(`https://api-social-proof.abtasty.com/clients/${n}/metrics/${t}?key=${e}${o?"&noTrim=true":""}`).then(e=>e.ok&&e.json()).then(a).catch(()=>l("Failed to fetch datas from server."))}else i(!1)}getSocialProofDatas({promise:e,resolve:t},n,r=!1){const{productKey:o,keyType:a}=(()=>{const{socialProofContentType:e,productKeyProvider:t,pathToProductKey:n,customJSProductKey:r,productSKU:o,tagIsSafeEval:a}=DATA,{pathToProductKey:c,customJSProductKey:l}=a&&DATA_JS||{};if(2===e)return{productKey:i(),keyType:"url"};{let a=null,h="sku";switch(t){case"ABTastyProductKey":a=window.ABTastyProductKey;break;case"pathToProductKey":a="function"==typeof c?c():s(`return ${n};`);break;case"customJSProductKey":a="function"==typeof l?l():s(r);break;case"productSKU":a=o}return a||3!==e||(a=i(),h="url"),{productKey:a,keyType:h}}})(),{viewInterval:c,triggerSocialProofMinVisitors:h,triggerSocialProofMinPurchases:d,triggerSocialProofMinPageViews:u}=DATA,m={pv:u,i:d,"v-pv":h}[n];return[typeof c,typeof m].includes("undefined")&&t(!1),r&&!o&&(l("Not able to find ABTastyProductKey, impossible to call the API, read documentation for more informations:\n\t\t\t\thttps://support.abtasty.com/hc/en-us/articles/4710919241628-Widgets-List#h_84c04344-c655-4e5e-b9ab-d26a798ad9b0"),t(!1)),this.checkSocialProofConditions(o,"v-pv"===n&&"sku"===a?"v-i":n,e=>{const t=void 0!==e[c]&&e[c]>=m;return t||l(`Widget will not be shown, Social Proof API returned ${e[c]} while ${m} are required`),t},t),e}onConsent({promise:e,resolve:t}){if(!r()){const s=["abtasty_consentValid",()=>t(!0)];return this.eventsListeners.push(s),window.addEventListener(...s),e}return t(!0),e}onTrackingSent({promise:e,resolve:t}){const{triggerEventTrackingSent:s}=DATA;let i=localStorage.getItem(C);const n=()=>JSON.parse(i)?.ActionTracking?.some(({name:e})=>e===s),r=["storage",({key:e,newValue:s})=>{e===C&&(i=s,n()&&t(!0))},{passive:!0,capture:!0}];return i&&n()?t(!0):(()=>{this.eventsListeners.push([window,...r]),window.addEventListener(...r)})(),e}onMinPagesViewed({promise:e,resolve:t}){const{triggerEventMinPagesViewed:s}=DATA;let i=localStorage.getItem(C);const n=()=>s<=(i?JSON.parse(i)?.VisitedPages?.length:0),r=["storage",({key:e,newValue:s})=>{e===C&&(i=s,n()&&t(!0))},{passive:!0,capture:!0}];return i&&n()?t(!0):(()=>{this.eventsListeners.push([window,...r]),window.addEventListener(...r)})(),e}onRageClick({promise:e,resolve:t}){const{triggerEventRageClickQuantity:s,triggerEventRageClickDelay:i}=DATA;let n=0,r=!1;const o=["click",({isTrusted:e})=>{if(e&&(n+=1,n>=s&&t(!0),!r)){r=!0;const e=setTimeout(()=>{n=0,r=!1},i);this.timeouts.push(e)}},{passive:!0,capture:!0}],a=e=>{this.eventsListeners.push([e,...o]),e.addEventListener(...o)},{clear:c}=v("iframe []contentDocument[] body > *",()=>{const e=document.getElementsByTagName("iframe");for(const t of e){"contentDocument"in t&&"body"in t.contentDocument&&a(t.contentDocument);const e=()=>a(t.contentDocument);t.addEventListener("load",e),this.eventsListeners.push([t,"onIframeLoad",e])}});return this.elementWaiters.push(c),a(document),e}clear(){this.triggerElements=this.triggerElements.filter(e=>(e.remove(),!1)),this.eventsListeners=this.eventsListeners.filter(e=>{const[t,...s]=e;return t&&s.length>1&&t.removeEventListener(...s),!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")},s=!Object.prototype.hasOwnProperty.call(t,this.event)||await t[this.event]();return s&&this.clear(),"reengage"!==this.event&&this.delay?s&&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})():s}}const A="display",N="closing",x="validation",k="ABTastyWidgets",P=`${k}Temporary`;class I{constructor({displayRecurrence:e,closingRecurrence:t,validationRecurrence:s},i){this.displayRecurrence=parseFloat(e),this.closingRecurrence=parseFloat(t),this.validationRecurrence=parseFloat(s),this.onSetCallback=i,this.widgetName=o(),this.uniqueId=c(),this.recurrenceKey=`${this.widgetName}_${this.uniqueId}`,this.isListeningStorageEvent=this.listenStorageEvent(),this.pendingRecurrence=!1,this.pendingRecurrenceValue={}}onStorage({key:e}){const t=localStorage.getItem(P),s=sessionStorage.getItem(k);"ABTastyData"===e&&!t&&s&&localStorage.setItem(P,s)}listenStorageEvent(){return this.isListeningStorageEvent||window.addEventListener("storage",this.onStorage.bind(this)),!0}getGivenRecurrenceStorageParsed(e){try{const t=e.getItem(k);return JSON.parse(t)}catch(t){return e.removeItem(k),!1}}getSessionRecurrenceStorageParsed(){return this.getGivenRecurrenceStorageParsed(window.sessionStorage)}getLocalRecurrenceStorageParsed(){return this.getGivenRecurrenceStorageParsed(window.localStorage)}removeGivenStorage(e,t){const{[this.recurrenceKey]:s,...i}=t;return Object.entries(i).length?(e.setItem(k,JSON.stringify(i)),i):(e.removeItem(k),!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(P),t=!(!e||!e.includes(this.recurrenceKey))||this.getSessionRecurrence();e&&(sessionStorage.setItem(k,e),localStorage.removeItem(P));const s=this.getLocalRecurrence(),i=(s?parseFloat(s.stamp):0)<(new Date).getTime();return i&&this.removeLocalRecurrenceStorage(),!this.pendingRecurrence&&i&&!this.getLocalRecurrence()&&!t}setRecurrence(e,s){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:n,storageMethod:o}=i,a=this.getStamp(e),c={type:s,stamp:a},{type:l}=this.getCurrentRecurrence(),h=async()=>{if(!r()){this.pendingRecurrence=!0,this.pendingRecurrenceValue=c;const e=new S({triggerEvent:"consent"});await e.isTriggered(),this.pendingRecurrence=!1,this.pendingRecurrenceValue={}}const e=this.getSessionRecurrence(),t=this.getLocalRecurrence();let s;"session"===n?e?s=this.removeSessionRecurrenceStorage():(this.removeLocalRecurrenceStorage(),s=this.getSessionRecurrenceStorageParsed()):"local"===n&&(t?s=this.removeLocalRecurrenceStorage():(this.removeSessionRecurrenceStorage(),s=this.getLocalRecurrenceStorageParsed()));const i=s?{[this.recurrenceKey]:c,...s}:{[this.recurrenceKey]:c};o.setItem(k,JSON.stringify(i)),this.onSetCallback&&"function"==typeof this.onSetCallback&&this.onSetCallback()};if(!o)return!1;if(l&&s!==x)if(s===N&&l!==x)h();else{if(s!==A||l===x||l===N)return!1;h()}else h();return a}setDisplayRecurrence(){const e=A;this.setRecurrence(this.displayRecurrence,e)}setClosingRecurrence(){const e=N;this.setRecurrence(this.closingRecurrence,e)}setValidationRecurrence(){const e=x;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 L{constructor(e,t,s){this.isWidgetApplied=e,this.callback=t,this.shouldUpdate=s,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(),s=t?this.shouldUpdate&&E:T;return s?(this.clearWatcher(),this.callback(s,!e,t),this.watch(),this):this}onCampaignLaunched({detail:{campaignId:e}}){e===TEST_ID&&(this.callback(T,!1),this.watch())}onTagRollback({target:e}){return this.clearWatcher(e),this.callback($,!1,!0),window.addEventListener(...this.onCampaignLaunchedEventParams),this}observerHandler(e){return n()?e.some(e=>["removedNodes","addedNodes"].some(t=>e[t]&&e[t].length))?this.decisionHandler():this:this.callback($,!1)}watch(t,s){if(e())return this;if(this.clearWatcher(t),window.removeEventListener(...this.onCampaignLaunchedEventParams),document.addEventListener(...this.tagRollbackEventParams),s?.includes("[]contentDocument[]")){const e=s.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:n}=v("body",e=>{n();const s=t?.body||t||e;this.observer.observe(s,{childList:!0,subtree:!0})});return this}clearTriggerElementWatcher(){this.triggerIframeTarget?.removeEventListener("load",this.decisionHandler.bind(this))}clearWatcher(e){return document.removeEventListener(...this.tagRollbackEventParams),this.observer.disconnect(),this.clearTriggerElementWatcher(),e?.defaultView?.frameElement?.removeEventListener("load",this.decisionHandler.bind(this)),this}}const D=/.+\/([^.]+)\.(otf|ttf)$/,R=["socialProofPurchases","socialProofPageViews","socialProofVisitors"];class B{constructor(t,s){this.children=void 0,this.uniqueId=`${c()}${s?`_${s}`:""}`,this.widgetName=o(),this.prettyName=a(),this.recurrenceParams=(()=>{const{displayRecurrence:t,closingRecurrence:s,validationRecurrence:i}=DATA,n=!t&&!s&&!i;if(e()||n)return!1;const r={everytime:()=>-1,session:()=>0,once:()=>395,day:e=>DATA[`${e}_day`],week:e=>7*DATA[`${e}_week`],month:e=>30.5*DATA[`${e}_month`]},o={};return t&&(o.displayRecurrence=r[t]("displayRecurrence")),s&&(o.closingRecurrence=r[s]("closingRecurrence")),i&&(o.validationRecurrence=r[i]("validationRecurrence")),o})(),this.triggerParams=(t=>{let{triggerEvent:s}=DATA;const{triggerEventClick:i,triggerEventHover:n,triggerEventReengageDelay:r,socialProofContentType:o,triggerEventElementVisible:a,triggerEventDelay:c}=DATA;if(e()||!s&&!o)return!1;const l={click:()=>i,hover:()=>n,elementVisible:()=>a},h=Object.prototype.hasOwnProperty.call(l,s)?l[s]():"body",d="reengage"===s?r:c;return o&&(s=[,"socialProofPurchases","socialProofPageViews","socialProofVisitors"][o]),{triggerEvent:s,triggerSelector:h,triggerDelay:d,triggerTarget:t}})(t),this.recurrence=!!this.recurrenceParams&&new I(this.recurrenceParams,this.clearGivenClearables.bind(this)),this.trigger=!!this.triggerParams&&new S(this.triggerParams),this.shouldUpdate=!!this.triggerParams&&R.includes(this.triggerParams.triggerEvent),this.pageWatcher=new L(this.isWidgetApplied.bind(this),this.onPageChange.bind(this)),this.hasOncePerPageTrigger=(()=>{const{isOncePerPageTrigger:e,triggerEvent:t}=DATA;return!t||!["click","hover","scrollUp","script"].includes(t)||e})(),this.basicClassName=`ab_widget_container_${this.widgetName}`,this.widgetContainerId=`${this.basicClassName}_${this.uniqueId}`,this.contentClassName=`${this.basicClassName}_content`,this.overlayClassName=`${this.basicClassName}_overlay`,this.closeButtonClassName=`${this.basicClassName}_close_button`,this.hideClassName=`ab_hide_${this.uniqueId}`,this.rootElement=null,this.domElement=this.getDom(),this.hasBeenShown=!1,this.closedByUser=!1,this.elementsWaiters=[]}clearGivenClearables(){this.elementsWaiters.forEach(e=>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:s="body",referrerInsertType:i="beforeend"}=t?DATA:{},n=v(s,t=>{this.elementsWaiters=this.elementsWaiters.filter(e=>e.selector!==s),this.rootElement=t.getRootNode(),this.removeOldDomElement(),this.domElement.appendChild(this.styleElement),e(t.insertAdjacentElement(i,this.domElement))});this.elementsWaiters.push(n)}).then(()=>this)}remove(){this.trigger&&this.trigger.clear(),this.pageWatcher.clearWatcher(this.rootElement);for(const e of this.elementsWaiters)[DATA.elementReferrer,"body"].includes(e.selector)&&e.clear();return this.domElement?.isConnected&&this.domElement.remove(),this.hasOncePerPageTrigger?this.pageWatcher.watch(this.rootElement):e()||this.init().then(({response:e})=>e?this.show():this),this}show(){return e()||this.hasBeenShown&&this.hasOncePerPageTrigger||window.ABTastyEvent(`${this.prettyName} displayed`,null,TEST_ID),this.closedByUser=!1,setTimeout(()=>this.domElement.classList.remove(this.hideClassName),50),this.recurrence&&this.recurrence.setDisplayRecurrence(),this.hasBeenShown=!0,this.pageWatcher.watch(this.rootElement),this}hide(t=!0){return!e()&&this.hasBeenShown&&t&&window.ABTastyEvent(`${this.prettyName} closed`,null,TEST_ID),t&&(this.pageWatcher.clearWatcher(this.rootElement),this.closedByUser=!0),this.domElement.classList.add(this.hideClassName),this}async init(t){const s=e(),i=n(),r=this.trigger?.promises?.length,o=!this.recurrence||this.recurrence.isOver();if(!s&&!i||r||!o)return{container:this,response:!1};this.pageWatcher.watch(this.rootElement||document,this.triggerParams.triggerSelector);const a=s||!this.trigger||this.trigger&&await this.trigger.isTriggered();this.pageWatcher.clearTriggerElementWatcher();const c={container:this,response:a};return a?(await this.insert(),this.addCloseEvent(),s||t||this.hasBeenShown||void 0===this.children||"function"!=typeof this.children.refreshContent||this.children.refreshContent(a),c):c}onPageChange(e,t,s){const i=()=>this.init().then(({response:e})=>{e?this.show():this.hide(!1)});t||(this.hasBeenShown=!1,s&&this.domElement.remove(),this.trigger&&this.trigger.clear());const n={[$]:()=>s?this.remove():this.pageWatcher.watch(this.rootElement),[T]:()=>{this.hasBeenShown?this.closedByUser?this.pageWatcher.watch(this.rootElement):s||this.insert().then(e=>e.show()).catch(this.pageWatcher.watch):i()},[E]:()=>{this.hasBeenShown?this.pageWatcher.watch():i()}};"function"==typeof n[e]&&n[e]()}addCloseEvent(...t){const{closeButton:s,overlay:i,overlayClickable:n,layout:r,animationDuration:o=1e3}=DATA,a=[];if(void 0!==i&&!0!==i||!0!==n||"popin"!==r||a.push(`.${this.overlayClassName}`),void 0!==s&&s&&a.push(`.${this.closeButtonClassName}`),!a.length)return this;const c=this.domElement.querySelectorAll(a.join(", "));if(!c.length)return this;const l=["click",t=>{(t=>{e()||(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation())})(t),this.recurrence&&this.recurrence.setClosingRecurrence(),this.hide(!0),setTimeout(()=>this.remove(),1.05*o)},{once:!0,capture:!0}];return t.push(...c),t.forEach(t=>{e()&&(t.dataset.abtastyActionnable="true"),t.removeEventListener(...l),t.addEventListener(...l)}),this}getDom(){const{closeButton:e,layout:t,overlayClickable:s,overlay:i=!0}=DATA,n=document.createElement("div");return n.className=`${this.basicClassName} ${this.hideClassName}`,n.id=this.widgetContainerId,["popin","bannerTop","bannerBottom"].includes(t)&&(n.role="dialog"),n.innerHTML=`\n\t\t\t${"popin"===t&&!0===i?`<div ${s?'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>`,n}loadFont(e,t){if(!e||"inherit"===e||!/otf|ttf/g.test(t))return;const s=document.createElement("style"),i=t.match(D)?t.match(D)[1]:"";s.innerHTML=`@font-face { font-family: '${e}_${i}'; src: url('${t}'); font-display: swap; }`;const n=this.rootElement?.head||document.head;n?.appendChild(s)}getStyleTag(t="",s=DATA){const{noStyles:i,layout:n}=s,{backgroundColor:r,isBackgroundImage:o,backgroundImage:a,backgroundSize:c,backgroundPosition:l,backgroundRepeat:h,borderColor:d,borderRadius:u,borderWidth:m,textColor:g,textAlign:p,fontName:v,fontStyle:y,fontSize:b,isTitle:f,titleTextAlign:w,titleTextColor:$,titleFontName:T,titleFontStyle:E,titleFontSize:C,overlay:S,overlayColor:A,dropShadow:N,dropShadowColor:x,dropShadowBlur:k,containerMargin:P,containerPadding:I,closeButton:L,closeButtonPosition:R,closeButtonSize:B,closeButtonBorderRadius:_,closeButtonBorderWidth:j,closeButtonBorderColor:O,closeButtonColor:W,closeButtonBackgroundColor:V,buttonsAlign:q,buttonsBorderWidth:H,buttonsBorderColor:M,buttonsBorderRadius:F,buttonsBackgroundColor:U,buttonsTextColor:Q,buttonsFontName:K,buttonsFontStyle:z,buttonsFontSize:G,secondLink:J,secondLinkBorderWidth:Y,secondLinkBorderColor:X,secondLinkBorderRadius:Z,secondLinkBackgroundColor:ee,secondLinkTextColor:te,secondLinkFontName:se,secondLinkFontStyle:ie,secondLinkFontSize:ne,animation:re,animationDuration:oe,animationBehaviour:ae,animationSlideDirection:ce}=i?{}:s,le=document.createElement("style");e()&&le.setAttribute("abtasty-script-added","true"),this.loadFont(v,y),this.loadFont(T,E),this.loadFont(K,z),this.loadFont(se,ie);const he=`background: ${["string"==typeof r?r:"rgba(255, 255, 255, 1)",o&&"string"==typeof a&&a.length?`url(${a})`:"",o&&"string"==typeof l&&"100% 100%"!==c?l:"0 0",o&&"string"==typeof c?`/ ${c}`:"/ auto",o&&h&&!["cover","100% 100%"].includes(c)?"repeat":"no-repeat"].join(" ").trim()};`,de="number"==typeof m&&m>0,ue=`border: ${[de?`${m}px`:"unset",de?"solid":"",de&&"string"==typeof d&&d.length?d:""].join(" ").trim()};`,me=void 0!==u?`border-radius: ${u}px;`:"",ge=void 0!==g?`color: ${g}; fill: ${g}; -webkit-text-fill-color: ${g};`:"",pe=void 0!==p?`text-align: ${p};`:"",ve=v&&"inherit"!==v?`font-family:${v}_${y.match(D)?y.match(D)[1]:""};`:y||"",ye=b?`font-size: ${b}px;`:"",be=void 0!==N&&N?`box-shadow: 0 5px ${k}px 0 ${x};`:"",fe=P instanceof Array&&1===P.length&&P[0],we=fe?`margin: ${fe.top}px ${fe.right}px ${fe.bottom}px ${fe.left}px;`:"",$e=fe?`margin: calc(${fe.top}px * 0.5) calc(${fe.right}px * 0.5) calc(${fe.bottom}px * 0.5) calc(${fe.left}px * 0.5);`:"",Te=I instanceof Array&&1===I.length&&I[0],Ee=Te?`padding: ${Te.top}px ${Te.right}px ${Te.bottom}px ${Te.left}px;`:"",Ce=Te?`padding: calc(${Te.top}px * 0.5) calc(${Te.right}px * 0.5) calc(${Te.bottom}px * 0.5) calc(${Te.left}px * 0.5);`:"",Se=void 0!==H&&H?`border-width: ${H}px; border-style: solid;`:"",Ae=[M,H].every(e=>void 0!==e)&&H?`border-color: ${M};`:"",Ne=void 0!==F?`border-radius: ${F}px;`:"",xe=void 0!==U?`background-color: ${U};`:"",ke=void 0!==Q?`color: ${Q}; fill: ${Q}; -webkit-text-fill-color: ${Q};`:"",Pe=K&&"inherit"!==K?`font-family:${K}_${z.match(D)?z.match(D)[1]:""};`:z||"",Ie=G?`font-size: ${G}px;`:"",Le="number"==typeof Y?`border-width: ${Y}px; border-style: solid;`:"",De=[X,Y].every(e=>void 0!==e)&&Y?`border-color: ${X};`:"",Re=void 0!==Z?`border-radius: ${Z}px;`:"",Be=void 0!==ee?`background-color: ${ee};`:"",_e=void 0!==te?`color: ${te}; fill: ${te}; -webkit-text-fill-color: ${te};`:"",je=se&&"inherit"!==se?`font-family:${se}_${ie.match(D)?ie.match(D)[1]:""};`:ie||"",Oe=ne?`font-size: ${ne}px;`:"",We="popin"!==n||void 0!==S&&!0!==S?"":[`#${this.widgetContainerId} .${this.overlayClassName} {`,`background-color: ${void 0!==A?A:"rgba(0, 0, 0, 0.6)"};`,"}"].join(""),Ve="number"==typeof B?B:16,qe=Ve/2,He=i||void 0!==L&&L?[`#${this.widgetContainerId} .${this.contentClassName} .${this.closeButtonClassName} {`,"position: absolute;",("out"===R?`bottom: calc(100% + ${qe}px)`:`top: ${qe}px`)+";",`right: ${qe}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!==O?O:"rgba(57, 57, 57, 1)"};`:"","string"==typeof V?`background-color: ${V};`:"","}",`#${this.widgetContainerId} .${this.contentClassName} .${this.closeButtonClassName} svg {`,"pointer-events: none;",`width: ${Ve}px;`,`height: ${Ve}px;`,"string"==typeof W?`fill: ${W};`:"","}"].join(""):"",Me=f&&"string"==typeof $?[`#${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: ${$}; fill: ${$}; -webkit-text-fill-color: ${$};`,void 0!==w?`text-align: ${w};`:"",T&&"inherit"!==T?`font-family:${T}_${E.match(D)?E.match(D)[1]:""};`:E||"",C?`font-size: ${C}px;`:"","}"].join(""):"";let Fe="";if("string"==typeof re){const t=(oe/1e3).toFixed(2),s=["top","bottom"].includes(ce),i=Number(s),n=[(["top","left"].includes(ce)?"-":"")+"100vmax",this.translateValues?this.translateValues[i]:"0"];s&&n.reverse(),Fe={none:[`.${this.hideClassName} {`,"opacity: 0 !important;","}"],fade:[`.${this.hideClassName} {`,"opacity: 0 !important;","}",`#${this.widgetContainerId} {`,`transition: opacity ${t}s ${ae};`,"}"],slide:[`.${this.hideClassName} .${this.overlayClassName} {`,"opacity: 0 !important;","}",`#${this.widgetContainerId} .${this.overlayClassName} {`,`transition: opacity ${t}s ${ae};`,"}",`.${this.hideClassName} .${this.contentClassName} {`,`transform: translate(${n.join(", ")}) !important;`,"}",`#${this.widgetContainerId} .${this.contentClassName} {`,`transition: transform ${t}s ${ae};`,"}"]}[e()&&!ABTASTY_S.WIDGETS.animationChanged?"none":re].join("")}const Ue=[`#${this.widgetContainerId} .${this.contentClassName} .buttons_container .second_link {`,`margin-${"fill"===q?"top":"left"}: 8px;`,Le,De,Re,Be,_e,je,Oe,"}",`#${this.widgetContainerId} .${this.contentClassName} .buttons_container .second_link {`,_e,je,Oe,"}"];return le.textContent=[`#${this.widgetContainerId} style { display: none; }`,`.${this.hideClassName} {`,"pointer-events: none;","}",`#${this.widgetContainerId} {`,"opacity: 1;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,he,me,ue,ge,pe,be,we,ve,ye,"}",`#${this.widgetContainerId} .${this.contentClassName} p {`,ge,pe,ve,ye,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,"display: block;","line-height: 1;","text-indent: unset;",Ee,ve,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;",Se,Ae,Ne,xe,ke,Pe,Ie,"}",`#${this.widgetContainerId} .${this.contentClassName} div.buttons_container a *, `,`#${this.widgetContainerId} .${this.contentClassName} button:not(class*="close_button") * {`,ke,Pe,Ie,"}",...J?Ue:[],"@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,$e,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,Ce,"}","}",We,He,Me,Fe,`${t}`].join(""),le}}const _=["top: 0;","top: 50%;","bottom: 0;"],j=["left: 0;","left: 50%;","right: 0;"],O=e=>1===e?"-50%":0,W=()=>{if(Array.isArray(DATA.popinPosition)){const{popinPosition:[{x:e,y:t}]}=DATA,s=`translate(${O(t)}, ${O(e)});`;return`${_[e]}${j[t]}transform: ${s}`}return"left: 50%;top: 50%;transform: translate(-50%, -50%);"},V=()=>"autoWidth"in DATA&&!0===DATA.autoWidth,q=()=>{if(V())return"width: auto; height: auto; min-width: fit-content;";const{popinPercentWidth:e,popinPixelsWidth:t,widthUnit:s,autoHeight:i,popinPercentHeight:n,popinPixelsHeight:r,heightUnit:o}=DATA;return`width: ${"px"===s?t:e}${s};height: ${i?"auto":`${"px"===o?r:n}${o}`};`};class H extends B{constructor(){super(),this.translateValues=Object.values(DATA.popinPosition[0]).map(e=>O(e)),this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){const{zindex:e,zindexCustom:t,widthUnit:s}=DATA,i="string"!=typeof DATA.overlay&&DATA.overlay;return[`#${this.widgetContainerId} {`,"position: fixed;","top: 0;","left: 0;","width: 100%;","height: 100%;",`z-index: ${"custom"===e?t:e};`,"background: none;","pointer-events: "+(i?"all":"none"),"}",`#${this.widgetContainerId} .${this.overlayClassName} {`,"position: absolute;","z-index: -1;","top: 0;","left: 0;","width: 100%;","height: 100%;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: absolute;",W(),q(),"pointer-events: all","}",`${V()?"":[`#${this.widgetContainerId} .${this.contentClassName} > div {`,"height: 100%;","overflow: auto;","box-sizing: border-box;","}"].join("")}`,`${!V()&&["px","em"].includes(s)?["@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,"max-width: 94vw;","}","}"].join(""):""}`].join("")}}class M extends B{constructor(){super(),this.position="string"==typeof DATA.layout&&"bannerTop"===DATA.layout?"top":"bottom",this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){const{zindex:e,zindexCustom:t}=DATA;return[`#${this.widgetContainerId} {`,"position: fixed;",`${this.position}: 0;`,"left: 0;","width: 100%;","height: auto;",`z-index: ${"custom"===e?t:e};`,"background: none;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: relative;","}"].join("")}}class F extends B{constructor(e,t){super(e,t),this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){return[`#${this.widgetContainerId} {`,"width: auto;","height: auto;","margin: 0;","padding: 0;","background: none;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: relative;","}"].join("")}}const U={angry:"rgba(234, 78, 45, 1)",sad:"rgba(227, 119, 31, 1)",neutral:"rgba(224, 185, 10, 1)",happy:"rgba(28, 191, 151, 1)",excited:"rgba(85, 174, 218, 1)"},Q=Object.keys(U);class K{constructor(t){let{parentContainer:s}=t;this.parentContainer=s,this.baseClassName="csat_container",this.className=`${this.baseClassName}_${s.uniqueId}`,this.voteClassName=`${this.baseClassName}_vote`,this.questionClassName=`${this.baseClassName}_question`,this.thanksClassName=`${this.baseClassName}_thanks`,this.hideClassName=`csat_${s.uniqueId}_display_none`,this.steps=["vote",!!DATA.askOpenQuestion&&"question",!!DATA.isThankYouMessage&&"thanks","complete"].filter(e=>"string"==typeof e),this.currentStep=e()?DATA.stepPreview:"vote",this.emojiChoice=NaN,this.currentNote=NaN,this.currentFeedback="",this.currentOpenQuestion=DATA.openQuestionPositive,this.emojisList=this.getEmojisList(),this.CSATContainer=document.createElement("div"),this.voteElement=null,this.questionElement=this.getQuestionElement(),this.thanksElement=this.getThanksElement(),this.CSATElement=null}async getABtastyEmojis(){window.abtastyEmojis=await Promise.all(this.emojisList.map(e=>{let{iconUrl:t}=e;return this.fetchTastyEmojis(t)})),this.emojisList.forEach((e,t)=>{e.iconUrl=window.abtastyEmojis[t]})}async insertIn(e,t){const{emojisType:s}=DATA;return"abtasty"!==s||window.abtastyEmojis?.length||await this.getABtastyEmojis(),this.setStyles(),this.CSATElement=this.getCSATElement(),e.insertAdjacentElement(t,this.CSATElement),this.showCurrentStep()}setQuestion(){const{layout:e,openQuestionPositive:t,openQuestionNeutral:s,openQuestionNegative:i}=DATA,n=[i,i,s,t,t][this.emojiChoice]||t,r=this.questionElement.querySelector("textarea");return this.currentOpenQuestion=n,r.ariaLabel=n,["popin","bannerTop","bannerBottom"].includes(e)&&(this.parentContainer.domElement.ariaLabel=n),r.focus(),this.questionElement.querySelector("p").innerHTML=n,this}getQuestionElement(){const{openQuestionPositive:t,sendButtonText:s}=DATA,i=document.createElement("div");i.className=this.questionClassName,i.innerHTML=`<p>${t}</p>\n\t\t<textarea></textarea>\n\t\t<button>${s}</button>`;const n=i.querySelector("button");return e()&&(n.dataset.abtastyActionnable="true"),n.addEventListener("click",()=>{this.currentFeedback=i.querySelector("textarea").value,this.currentStep=this.steps[this.steps.indexOf(this.currentStep)+1],this.showCurrentStep()},{passive:!0,capture:!0,once:!0}),i}getThanksElement(){const{thanksMessage:e,layout:t}=DATA,s=document.createElement("p");return s.className=this.thanksClassName,s.innerHTML=e,["popin","bannerTop","bannerBottom"].includes(t)&&(this.parentContainer.domElement.ariaLabel=e),s}sendDatas(){return window.abtasty.send("event",{ec:"csat",ea:"Customer Satisfaction",ev:this.currentNote,el:DATA.mainQuestion,caid:TEST_ID,vaid:VARIATION_ID,cv:{0:`openEndedQuestion, ${this.currentOpenQuestion}`,1:`openEndedAnswer, ${this.currentFeedback}`,2:`maxScore, ${DATA.emojisQty}`}}),l(`Sending datas, note: ${this.currentNote}/${DATA.emojisQty}, feedback: "${this.currentFeedback}"`),this}complete(){this.parentContainer.recurrence.setValidationRecurrence();const{autoHide:e,timeHide:t}=DATA;return e?(this.CSATContainer.style.pointerEvents="none",setTimeout(()=>{this.parentContainer.hide(!1),this.parentContainer.pageWatcher.clearWatcher(),this.parentContainer.closedByUser=!0,setTimeout(()=>this.parentContainer.remove(),1e3)},1e3*t),this):this}showCurrentStep(){const t=!e();return"complete"!==this.currentStep&&([this.voteElement,this.questionElement,this.thanksElement].forEach(e=>e.classList.add(this.hideClassName)),this[`${this.currentStep}Element`].classList.remove(this.hideClassName)),"question"===this.currentStep?this.setQuestion():["thanks","complete"].includes(this.currentStep)&&t?this.sendDatas().complete():this}async fetchTastyEmojis(e){return await fetch(e,{method:"GET",mode:"cors",cache:"no-cache",referrerPolicy:"no-referrer"}).then(e=>e.blob()).then(e=>e.text()).then(e=>e).catch(e=>console.error(`ERROR on loading picture, message: ${e}`))}getEmojisList(){const{emojisType:e}=DATA;return Q.map((t,s)=>({index:s,iconUrl:"abtasty"===e?window.abtastyEmojis?.length?window.abtastyEmojis[s]:`https://widgets-images.abtasty.com/csat/${t}.svg`:`<img src='${DATA[`${t}EmojiCustom`]}'>`,iconText:DATA[`${t}EmojiText`],className:`csatEmojiButton ${t}EmojiButton`}))}onEmojiClick(e){let{currentTarget:t}=e;return isNaN(this.currentNote)&&(this.emojiChoice=Number(t.dataset.index),this.currentNote=Number(t.dataset.note)),this.currentStep=this.steps[this.steps.indexOf(this.currentStep)+1],this.showCurrentStep()}getEmojiButton(t,s){const{emojisType:i,mainQuestion:n,emojisQty:r}=DATA,o=document.createElement("button");return o.className=t.className,o.dataset.index=t.index,o.dataset.note=s,o.ariaLabel=`${n} - ${s}/${r}`,o.innerHTML="text"===i?t.iconText:t.iconUrl,e()&&(o.dataset.abtastyActionnable="true"),o.addEventListener("click",this.onEmojiClick.bind(this),{passive:!0,capture:!0}),o}getEmojisContainer(){const{emojisQty:t,stepPreview:s,mainQuestion:i,layout:n}=DATA,r=document.createElement("p");r.innerHTML=i,["popin","bannerTop","bannerBottom"].includes(n)&&(this.parentContainer.domElement.ariaLabel=i);const o=document.createElement("div");o.className=this.voteClassName,o.appendChild(r);const a=[,,[0,4],[0,2,4],[0,1,3,4],[0,1,2,3,4]];return this.emojisList.forEach((e,s)=>{if(a[t].includes(s)){const i=a[t].indexOf(s)+1,n=this.getEmojiButton(e,i);o.appendChild(n)}}),(e()&&"vote"!==s||"vote"!==this.currentStep)&&o.classList.add(this.hideClassName),o}getCSATElement(){const{askOpenQuestion:e,isThankYouMessage:t}=DATA;return this.CSATContainer.classList.add(`${this.baseClassName}`,`${this.className}`),this.voteElement=this.getEmojisContainer(),this.CSATContainer.appendChild(this.voteElement),(e||"question"===this.currentStep)&&this.CSATContainer.appendChild(this.questionElement),(t||"thanks"===this.currentStep)&&this.CSATContainer.appendChild(this.thanksElement),this.CSATContainer}setStyles(){const{styleElement:e,widgetContainerId:t,contentClassName:s}=this.parentContainer,{emojisType:i,customColors:n,emojisMargin:r,borderColor:o,textColor:a,backgroundColor:c}=DATA,l=Q.reduce((e,t)=>`${e}.csat_emoji_${t} .csat_emoji_shadow,\n\t\t\t.csat_emoji_${t} .csat_emoji_head {\n\t\t\t\tfill: ${n?DATA[`${t}Color`]:U[t]};\n\t\t\t}`,""),h=[["abtasty"===i?l:"",".csatEmojiButton {","all: unset !important;",`margin: 0 ${r}px !important;`,"font-size: 30px !important;","cursor: pointer !important;","}",".csatEmojiButton svg {","overflow: visible;","pointer-events: none;","}",".csatEmojiButton .csat_emoji > * {","transform-origin: center;","transition: transform .5s ease;","}",".csatEmojiButton:hover .csat_emoji_shadow {","transform: scale(1.4);","}",".csatEmojiButton:hover .csat_emoji_shadow ~ * {","transform: scale(1.2);","}",".csat_emoji_shadow {","opacity: 0.1;","}",".csat_emoji_mouth,",".csat_emoji_eyebrow,",".csat_emoji_eye {","mix-blend-mode: multiply;","fill: rgb(57, 57, 57);","}",".csat_emoji_mouth,",".csat_emoji_eyebrow {","opacity: 0.5;","}"].join(""),`.${this.questionClassName} textarea {`,"width: 100%;","min-height: 60px;","margin-top: 12px;","margin-bottom: 20px;",`border: 2px solid ${o};`,`color: ${a};`,"}",`.${this.className} textarea::selection,\n\t\t\t.${this.className} p::selection {`,`-webkit-text-fill-color: ${c};`,`text-fill-color: ${c};`,`color: ${c};`,`background-color: ${o};`,"}",`.${this.questionClassName} button {`,"cursor: pointer;","}",`.${this.voteClassName} p {`,"margin-bottom: 12px;","}",`#${t} .${s} .${this.className} {`,"overflow: hidden;","}",`.${this.className} > * {`,"opacity: 1;","height: auto;","}",`.${this.className} > .${this.hideClassName} {`,"opacity: 0;","pointer-events: none;","transition: opacity 0.5s ease;","height: 0;","}"].join("");return e.insertAdjacentText("beforeend",h),e}}(async()=>{l("Widget launch");const e=(()=>{const{layout:e}=DATA;let t;switch(e){case"popin":t=new H;break;case"bannerTop":case"bannerBottom":t=new M;break;case"free":t=new F;break;default:t=new B}return t})(),t=e.domElement.querySelector(`.${e.contentClassName}`),s=new K({parentContainer:e});e.children=s,await s.insertIn(t,"beforeend"),e.init(!0).then(t=>{let{response:s}=t;return s&&e.show()})})()}();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@abtasty/csat",
3
3
  "description": "Customer Satisfaction widget",
4
- "version": "0.0.29",
4
+ "version": "0.0.31",
5
5
  "form": "dist/form.js",
6
6
  "main": "dist/main.js",
7
7
  "type": "module",