@abtasty/csat 0.0.22 → 0.0.24
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/form.js +1 -1
- package/dist/main.js +1 -1
- package/package.json +47 -43
package/dist/main.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
!function(){"use strict";const e=()=>Object.prototype.hasOwnProperty.call(window,"ABTastyEditor"),t=()=>{const e=!!document.getElementById("ABTastyPreviewBar"),t=location.href.includes("ab_project=preview");return e||t},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=(e,t)=>{const s=()=>{try{return document.querySelector(e)}catch(e){return null}};let i=s();const n=[document.querySelector("body")||document.documentElement,{childList:!0,subtree:!0,attributes:!0}],r=()=>a.disconnect(),o=()=>a.observe(...n),a=new MutationObserver(()=>(i=s(),i&&!r()&&t(i)));return i?setTimeout(()=>t(i),0):o(),{selector:e,clear:r,observe:o}};function a(e,t){return t(e)||!e.parentElement?e:a(e.parentElement,t)}const c=(e,t)=>[...document.querySelectorAll(t)].some(s=>s===e||!!e.closest(t)),l=(e,t)=>{let s=Date.now();return()=>{s+t-Date.now()<=0&&(e(),s=Date.now())}},h=()=>{const{type:e}=DATA;return`${PACKAGE.replace("@abtasty/","")}${e?`_${e}`:""}`},d=()=>{const e=h();return`${e.charAt(0).toUpperCase()}${e.slice(1)}`.split("-").join(" ")},u=()=>`${PLUGIN_ID.split("-")[0]}_${TEST_ID}`,m=s=>{const i=(()=>{if(e()||t())return!1;const s=ABTasty.getTestsOnPage()[TEST_ID];return!!s&&Object.keys(s.targetings.qaParameters).length>0})(),n=document.cookie.includes("abTastyDebug=")||!0===window.abTastyDebug;if(i||n){const e=d();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;")}},g=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};class p{constructor(){this.targets=[],this.existingTargets=[],this.inViewportTargets=[],this.visibilityObserver=this.startVisibilityObserver(),this.mutationObserver=null,this.mouseOverEvent=this.mouseOverHandler(),this.scrollEvent=this.scrollEventHandler()}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.checkElements()):this.inViewportTargets=this.inViewportTargets.filter(t=>!t.element.isSameNode(e.target)||(this.mouseOverEvent.clear(),this.scrollEvent.clear(),!1))})}startVisibilityObserver(){return new IntersectionObserver(this.intersectionHandler.bind(this),{root:null,rootMargin:"0px",threshold:0})}startMutationObserver(){this.mutationObserver??=new MutationObserver(this.checkElements.bind(this));const{clear:e}=o("body",t=>{e(),this.mutationObserver.observe(t,{attributes:!0,childList:!0,subtree:!0})});return this.mutationObserver}onMouseOver({target:e,path:t}){const s=this.inViewportTargets.find(({element:s,selector:i})=>{if(s.isSameNode(e))return!0;const n=[...e.querySelectorAll(i)];if(n.length&&n.includes(s))return!0;if(t.includes(s))return!0;const r=[...e.parentElement.children],o=r.findIndex(t=>t.isSameNode(e)),a=r.filter((e,t)=>t>o);if(a.length){if(a.includes(s))return!0;if(a.some(e=>[...e.querySelectorAll(i)].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){return{start:()=>document.addEventListener(...e),clear:()=>document.removeEventListener(...e)}}mouseOverHandler(){const 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(e)}scrollEventHandler(){const e=["scroll",l(this.checkElements.bind(this),50),{passive:!0}];return this.getEvents(e)}isElementVisible(e){return this.isElementTopmost(e)&&this.isElementOpaque(e)}isElementOpaque(e){return"HTML"===a(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=document.elementFromPoint(...s[n]);i=e===t||e.contains(t),n+=1}return i}checkElements(){this.targets.forEach(({selector:e,uniqueId:t})=>{const s=document.querySelector(e);s&&!this.existingTargets.find(s=>s.element.matches(e)&&s.uniqueId===t)&&(this.existingTargets.push({element:s,selector:e,uniqueId:t}),this.visibilityObserver.observe(s))}),this.existingTargets=this.existingTargets.filter(({selector:e,element:t})=>!!document.querySelector(e)||(t&&this.visibilityObserver.unobserve(t),!1)),this.inViewportTargets=this.inViewportTargets.filter(({selector:e,element:t,uniqueId:s})=>{if(t.matches(e)&&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})}watch(e,t,s){this.targets.push({selector:e,resolve:t,uniqueId:s}),this.startMutationObserver(),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=document.querySelector(e);s&&this.visibilityObserver.unobserve(s),0===this.targets.length&&this.mutationObserver.disconnect(),0===this.inViewportTargets.length&&(this.mouseOverEvent.clear(),this.scrollEvent.clear())}}const v="remove",y="rebuild",b="update";class w{constructor({triggerEvent:e,triggerSelector:t,triggerDelay:s,triggerTarget:i}){this.event=e,this.selector=t&&t.length?t:"body",this.target=i,this.delay=1e3*s,this.elementsSelectors=[],this.eventsListeners=[],this.timeouts=[],this.intervals=[],this.promises=[],this.visibilityObservers=[],this.socialProofStore={}}async onElementVisible({promise:e,resolve:t}){const s=g(`${this.event}DomReady`);this.promises.push(s);const i=await this.onPageLoad(s),n=await async function(){let e;return e=await("IntersectionObserver"in window&&"IntersectionObserverEntry"in window&&"intersectionRatio"in window.IntersectionObserverEntry.prototype||new Promise((e,t)=>{const s=window.document.getElementsByTagName("script")[0],i=window.document.createElement("script");i.src="https://polyfill.io/v3/polyfill.min.js?flags=gated&features=IntersectionObserver",s.parentNode.insertBefore(i,s),i.onload=e,i.onerror=t})),e}(),r=new p;if(this.visibilityObservers.push(r),n&&i){const e=u();r.watch(this.selector,t,e)}return 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=document.createElement("style");s.type="text/css",s.id=`Click_${u()}`,s.innerHTML=`${this.selector} {\n\t\t\tcursor: pointer !important;\n\t\t\tpointer-events: all !important;\n\t\t}`,document.head.appendChild(s),this.elementsSelectors.push(`#${s.id}`);const i=["click",({isTrusted:e,target:s})=>{const i=s.isEqualNode(this.target)||c(s,this.selector);return e&&i&&t(!0)},{passive:!0,capture:!0}];return this.eventsListeners.push([document,...i]),document.addEventListener(...i),e}onHover({promise:e,resolve:t}){const s=["mouseenter",({isTrusted:e,target:s})=>{const i=this.target?s.isEqualNode(this.target):c(s,this.selector);return e&&i&&t(!0)},{passive:!0,capture:!0}];return this.eventsListeners.push([document.documentElement,...s]),document.documentElement.addEventListener(...s),e}onExitIntent({promise:e,resolve:t}){const s=["mouseleave",({isTrusted:e,clientY:s})=>{e&&s<=0&&t(!0)},{passive:!0}],{clear:i}=o("body",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=[({isTrusted:e})=>{e&&(i=s)},{passive:!0}];["click","mousemove","scroll","keypress"].forEach(e=>{this.eventsListeners.push([document,e,...n]),document.addEventListener(e,...n)});const r=setInterval(()=>{i<=0?t(!0):i-=100},100);return this.intervals.push(r),e}onCustomTrigger({promise:e,resolve:t}){const{triggerEventCustomScript:s}=DATA;return new Function(`return new Promise(async resolve => {${s}})`)().then(e=>e&&t(!0)),e}onScrollUp({promise:e,resolve:t}){let s=0;const i=["scroll",({isTrusted:e})=>{e&&(window.pageYOffset<s?t(!0):s=window.pageYOffset)},{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&&window.ABTASTY_S.USER&&window.ABTASTY_S.USER.accountIdentifier&&window.ABTASTY_S.USER.accountIdentifier.length?e=window.ABTASTY_S.USER.accountIdentifier:window.ABTasty&&window.ABTasty.getAccountSettings&&"function"==typeof window.ABTasty.getAccountSettings?e=window.ABTasty.getAccountSettings().identifier:window.ABTasty&&window.ABTasty.accountSettings&&(e=window.ABTasty.accountSettings.identifier),e):e})(),{viewInterval:r,spNoTrim: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(()=>m("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}=DATA;if(2===e)return{productKey:i(),keyType:"url"};{let a=null,c="sku";switch(t){case"ABTastyProductKey":a=window.ABTastyProductKey;break;case"pathToProductKey":a=s(`return ${n};`);break;case"customJSProductKey":a=s(r);break;case"productSKU":a=o}return a||3!==e||(a=i(),c="url"),{productKey:a,keyType:c}}})(),{viewInterval:c,triggerSocialProofMinVisitors:l,triggerSocialProofMinPurchases:h,triggerSocialProofMinPageViews:d}=DATA,u={pv:d,i:h,"v-pv":l}[n];return[typeof c,typeof u].includes("undefined")&&t(!1),r&&!o&&(m("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]>=u;return t||m(`Widget will not be shown, Social Proof API returned ${e[c]} while ${u} 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("ABTastyData");const n=()=>JSON.parse(i).ActionTracking.find(({name:e})=>e===s),r=["storage",()=>{i=localStorage.getItem("ABTastyData"),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("ABTastyData");const n=()=>s<=(i?JSON.parse(i).VisitedPages.length:0),r=["storage",()=>{i=localStorage.getItem("ABTastyData"),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}];return this.eventsListeners.push([document,...o]),document.addEventListener(...o),e}clear(){if(this.elementsSelectors.length&&(this.elementsSelectors.forEach(e=>{document.querySelector(e)&&document.querySelector(e).remove()}),this.elementsSelectors=[]),this.eventsListeners.length&&(this.eventsListeners.forEach(e=>{const[t,...s]=e;t&&s.length>1&&t.removeEventListener(...s)}),this.eventsListeners=[]),this.timeouts.length&&(this.timeouts.forEach(e=>clearTimeout(e)),this.timeouts=[]),this.intervals.length&&(this.intervals.forEach(e=>clearInterval(e)),this.intervals=[]),this.visibilityObservers.length){const e=u();this.visibilityObservers.forEach(t=>t.clear(this.selector,e)),this.visibilityObservers=[]}return this.promises.length&&(this.promises.forEach(e=>e.resolve(!1)),this.promises=[]),this}async isTriggered(){this.clear();const e=g(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=g(`${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 $="display",f="closing",T="validation",C="ABTastyWidgets",S=`${C}Temporary`;class E{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=h(),this.uniqueId=u(),this.recurrenceKey=`${this.widgetName}_${this.uniqueId}`,this.isListeningStorageEvent=this.listenStorageEvent(),this.pendingRecurrence=!1,this.pendingRecurrenceValue={}}onStorage({key:e}){const t=localStorage.getItem(S),s=sessionStorage.getItem(C);"ABTastyData"===e&&!t&&s&&localStorage.setItem(S,s)}listenStorageEvent(){return this.isListeningStorageEvent||window.addEventListener("storage",this.onStorage.bind(this)),!0}getGivenRecurrenceStorageParsed(e){try{const t=e.getItem(C);return JSON.parse(t)}catch(t){return e.removeItem(C),!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(C,JSON.stringify(i)),i):(e.removeItem(C),!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(S),t=!(!e||!e.includes(this.recurrenceKey))||this.getSessionRecurrence();e&&(sessionStorage.setItem(C,e),localStorage.removeItem(S));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 w({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(C,JSON.stringify(i)),this.onSetCallback&&"function"==typeof this.onSetCallback&&this.onSetCallback()};if(!o)return!1;if(l&&s!==T)if(s===f&&l!==T)h();else{if(s!==$||l===T||l===f)return!1;h()}else h();return a}setDisplayRecurrence(){const e=$;this.setRecurrence(this.displayRecurrence,e)}setClosingRecurrence(){const e=f;this.setRecurrence(this.closingRecurrence,e)}setValidationRecurrence(){const e=T;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 A{constructor(e,t,s){this.isWidgetApplied=e,this.callback=t,this.shouldUpdate=s,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(){const e=this.isWidgetApplied()?this.shouldUpdate&&b:y;return e?(this.clearWatcher(),this.callback(e,!0),this.watch(),this):this}onCampaignLaunched({detail:{campaignId:e}}){e===TEST_ID&&(this.callback(y,!1),this.watch())}onTagRollback(){return this.clearWatcher(),this.callback(v,!1),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(v,!1)}watch(){if(e())return this;this.clearWatcher(),window.removeEventListener(...this.onCampaignLaunchedEventParams),document.addEventListener(...this.tagRollbackEventParams);const{clear:t}=o("body",e=>{t(),this.observer.observe(e,{childList:!0,subtree:!0})});return this}clearWatcher(){return document.removeEventListener(...this.tagRollbackEventParams),this.observer.disconnect(),this}}const x=/.+\/([^.]+)\.(otf|ttf)$/,N=["socialProofPurchases","socialProofPageViews","socialProofVisitors"];class k{constructor(t,s){this.children=void 0,this.uniqueId=`${u()}${s?`_${s}`:""}`,this.widgetName=h(),this.prettyName=d(),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 E(this.recurrenceParams,this.clearGivenClearables.bind(this)),this.trigger=!!this.triggerParams&&new w(this.triggerParams),this.shouldUpdate=!!this.triggerParams&&N.includes(this.triggerParams.triggerEvent),this.pageWatcher=new A(this.isWidgetApplied.bind(this),this.onPageChange.bind(this),this.shouldUpdate),this.hasOncePerPageTrigger=(()=>{const{isOncePerPageTrigger:e,triggerEvent:t}=DATA;return!t||!["click","hover","scrollUp","script"].includes(t)||e})(),this.basicClassName=`ab_widget_container_${this.widgetName}`,this.widgetContainerId=`${this.basicClassName}_${this.uniqueId}`,this.contentClassName=`${this.basicClassName}_content`,this.overlayClassName=`${this.basicClassName}_overlay`,this.closeButtonClassName=`${this.basicClassName}_close_button`,this.hideClassName=`ab_hide_${this.uniqueId}`,this.domElement=this.getDom(),this.hasBeenShown=!1,this.closedByUser=!1,this.eventsListeners=[],this.timeouts=[],this.intervals=[],this.observers=[],this.promises=[],this.elementsWaiters=[]}clearGivenClearables(){this.eventsListeners.forEach(e=>document.removeEventListener(...e)),this.eventsListeners=[],this.timeouts.forEach(e=>clearTimeout(e)),this.timeouts=[],this.intervals.forEach(e=>clearInterval(e)),this.intervals=[],this.observers.forEach(e=>e.disconnect()),this.observers=[],this.promises.forEach(e=>e.resolve(!1)),this.promises=[],this.elementsWaiters.forEach(e=>e.clear()),this.elementsWaiters=[]}isWidgetApplied(){return this.domElement&&this.domElement.isConnected}removeOldDomElement(){const e=document.getElementById(this.widgetContainerId);return e&&e.remove(),this}async insert(){if(this.isWidgetApplied())return!1;document.head.appendChild(this.styleElement);const e=["free"];return"drawer"===DATA.layout&&DATA.customTarget&&e.push("drawer"),new Promise(t=>{const{elementReferrer:s="body",referrerInsertType:i="beforeend"}=e.includes(DATA.layout)?DATA:{},n=o(s,e=>{this.elementsWaiters=this.elementsWaiters.filter(e=>e.selector!==s),this.removeOldDomElement(),t(e.insertAdjacentElement(i,this.domElement))});this.elementsWaiters.push(n)}).then(()=>this)}remove(){return this.trigger&&this.trigger.clear(),this.pageWatcher.clearWatcher(),[this.domElement,this.styleElement].forEach(e=>e&&e.isConnected&&e.remove()),this.hasOncePerPageTrigger?this.pageWatcher.watch():e()||this.init().then(({response:e})=>e?this.show():this),this}show(){return e()||this.hasBeenShown&&this.hasOncePerPageTrigger||window.ABTastyEvent(`${this.prettyName} displayed`,null,TEST_ID),this.closedByUser=!1,setTimeout(()=>this.domElement.classList.remove(this.hideClassName),50),this.recurrence&&this.recurrence.setDisplayRecurrence(),this.hasBeenShown=!0,this.pageWatcher.watch(),this}hide(t=!0){return!e()&&this.hasBeenShown&&t&&window.ABTastyEvent(`${this.prettyName} closed`,null,TEST_ID),t&&(this.pageWatcher.clearWatcher(),this.closedByUser=!0),this.domElement.classList.add(this.hideClassName),this}async init(t){const s=e(),i=n(),r=this.trigger&&this.trigger.promises.length,o=!this.recurrence||this.recurrence.isOver();if(!s&&!i||r||!o)return{container:this,response:!1};this.pageWatcher.watch();const a=s||!this.trigger||this.trigger&&await this.trigger.isTriggered(),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){const s=()=>this.init().then(({response:e})=>{e?this.show():this.hide(!1)});t||(this.hasBeenShown=!1,this.trigger&&this.trigger.clear());const i=this.isWidgetApplied(),n={[v]:()=>i?this.remove():this.pageWatcher.watch(),[y]:()=>{this.hasBeenShown?this.closedByUser?this.pageWatcher.watch():i||this.insert().then(e=>e.show()).catch(this.pageWatcher.watch):s()},[b]:s};"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,overlay:s=!0}=DATA,i=document.createElement("div");return i.className=`${this.basicClassName} ${this.hideClassName}`,i.id=this.widgetContainerId,i.role="dialog",i.innerHTML=`\n\t\t\t${"popin"===t&&!0===s?`<div class="${this.overlayClassName}"></div>`:""}\n\t\t\t<div class="${this.contentClassName}" aria-label="Dialog content">\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>`,i}loadFont(e,t){if(!e||"inherit"===e||!/otf|ttf/g.test(t))return;const s=document.createElement("style"),i=t.match(x)?t.match(x)[1]:"";s.innerHTML=`@font-face { font-family: '${e}_${i}'; src: url('${t}'); font-display: swap; }`,document.head.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:w,titleTextAlign:$,titleTextColor:f,titleFontName:T,titleFontStyle:C,titleFontSize:S,overlay:E,overlayColor:A,dropShadow:N,dropShadowColor:k,dropShadowBlur:P,containerMargin:I,containerPadding:D,closeButton:L,closeButtonPosition:R,closeButtonSize:B,closeButtonBorderRadius:_,closeButtonBorderWidth:j,closeButtonBorderColor:O,closeButtonColor:q,closeButtonBackgroundColor:V,buttonsAlign:W,buttonsBorderWidth:M,buttonsBorderColor:H,buttonsBorderRadius:F,buttonsBackgroundColor:U,buttonsTextColor:Q,buttonsFontName:z,buttonsFontStyle:K,buttonsFontSize:G,secondLink:Y,secondLinkBorderWidth:J,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");le.type="text/css",e()&&le.setAttribute("abtasty-script-added","true"),this.loadFont(v,y),this.loadFont(T,C),this.loadFont(z,K),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(x)?y.match(x)[1]:""};`:y||"",ye=b?`font-size: ${b}px;`:"",be=void 0!==N&&N?`box-shadow: 0 5px ${P}px 0 ${k};`:"",we=I instanceof Array&&1===I.length&&I[0],$e=we?`margin: ${we.top}px ${we.right}px ${we.bottom}px ${we.left}px;`:"",fe=we?`margin: calc(${we.top}px * 0.5) calc(${we.right}px * 0.5) calc(${we.bottom}px * 0.5) calc(${we.left}px * 0.5);`:"",Te=D instanceof Array&&1===D.length&&D[0],Ce=Te?`padding: ${Te.top}px ${Te.right}px ${Te.bottom}px ${Te.left}px;`:"",Se=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);`:"",Ee=void 0!==M&&M?`border-width: ${M}px; border-style: solid;`:"",Ae=[H,M].every(e=>void 0!==e)&&M?`border-color: ${H};`:"",xe=void 0!==F?`border-radius: ${F}px;`:"",Ne=void 0!==U?`background-color: ${U};`:"",ke=void 0!==Q?`color: ${Q}; fill: ${Q}; -webkit-text-fill-color: ${Q};`:"",Pe=z&&"inherit"!==z?`font-family:${z}_${K.match(x)?K.match(x)[1]:""};`:K||"",Ie=G?`font-size: ${G}px;`:"",De="number"==typeof J?`border-width: ${J}px; border-style: solid;`:"",Le=[X,J].every(e=>void 0!==e)&&J?`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(x)?ie.match(x)[1]:""};`:ie||"",Oe=ne?`font-size: ${ne}px;`:"",qe="popin"!==n||void 0!==E&&!0!==E?"":[`#${this.widgetContainerId} .${this.overlayClassName} {`,`background-color: ${void 0!==A?A:"rgba(0, 0, 0, 0.6)"};`,"}"].join(""),Ve="number"==typeof B?B:16,We=Ve/2,Me=i||void 0!==L&&L?[`#${this.widgetContainerId} .${this.contentClassName} .${this.closeButtonClassName} {`,"position: absolute;",("out"===R?`bottom: calc(100% + ${We}px)`:`top: ${We}px`)+";",`right: ${We}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 q?`fill: ${q};`:"","}"].join(""):"",He=w&&"string"==typeof f?[`#${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: ${f}; fill: ${f}; -webkit-text-fill-color: ${f};`,void 0!==$?`text-align: ${$};`:"",T&&"inherit"!==T?`font-family:${T}_${C.match(x)?C.match(x)[1]:""};`:C||"",S?`font-size: ${S}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"===W?"top":"left"}: 8px;`,De,Le,Re,Be,_e,je,Oe,"}",`#${this.widgetContainerId} .${this.contentClassName} .buttons_container .second_link {`,_e,je,Oe,"}"];return le.textContent=[`.${this.hideClassName} {`,"pointer-events: none;","}",`#${this.widgetContainerId} {`,"opacity: 1;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,he,me,ue,ge,pe,be,$e,ve,ye,"}",`#${this.widgetContainerId} .${this.contentClassName} p {`,ge,pe,ve,ye,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,"display: block;","line-height: 1;","text-indent: unset;",Ce,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;",Ee,Ae,xe,Ne,ke,Pe,Ie,"}",`#${this.widgetContainerId} .${this.contentClassName} div.buttons_container a *, `,`#${this.widgetContainerId} .${this.contentClassName} button:not(class*="close_button") * {`,ke,Pe,Ie,"}",...Y?Ue:[],"@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,fe,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,Se,"}","}",qe,Me,He,Fe,`${t}`].join(""),le}}const P=["top: 0;","top: 50%;","bottom: 0;"],I=["left: 0;","left: 50%;","right: 0;"],D=e=>1===e?"-50%":0,L=()=>{if(Array.isArray(DATA.popinPosition)){const{popinPosition:[{x:e,y:t}]}=DATA,s=`translate(${D(t)}, ${D(e)});`;return`${P[e]}${I[t]}transform: ${s}`}return"left: 50%;top: 50%;transform: translate(-50%, -50%);"},R=()=>"autoWidth"in DATA&&!0===DATA.autoWidth,B=()=>{if(R())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 _ extends k{constructor(){super(),this.translateValues=Object.values(DATA.popinPosition[0]).map(e=>D(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;",L(),B(),"pointer-events: all","}",`${R()?"":[`#${this.widgetContainerId} .${this.contentClassName} > div {`,"height: 100%;","overflow: auto;","box-sizing: border-box;","}"].join("")}`,`${!R()&&["px","em"].includes(s)?["@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,"max-width: 94vw;","}","}"].join(""):""}`].join("")}}class j extends k{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 O extends k{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 q={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)"},V=Object.keys(q);class W{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,this.styleElement=this.getStyleElement()}async getABtastyEmojis(){window.abtastyEmojis=await this.emojisList.reduce(async(e,t)=>{let{iconUrl:s}=t;return[...await e,await this.fetchTastyEmojis(s)]},[]),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(),document.head.insertAdjacentElement("beforeend",this.styleElement),this.CSATElement=this.getCSATElement(),e.insertAdjacentElement(t,this.CSATElement),this.showCurrentStep()}setQuestion(){const{openQuestionPositive:e,openQuestionNeutral:t,openQuestionNegative:s}=DATA,i=[s,s,t,e,e][this.emojiChoice],n=this.questionElement.querySelector("textarea");return this.currentOpenQuestion=i,n.ariaLabel=i,n.focus(),this.questionElement.querySelector("p").innerHTML=i||e,this}getQuestionElement(){const{openQuestionPositive:t}=DATA,s=document.createElement("div");s.className=this.questionClassName,s.innerHTML=`<p>${t}</p>\n\t\t<textarea aria-label="${t}"></textarea>\n\t\t<button>${DATA.sendButtonText}</button>`;const i=s.querySelector("button");return e()&&(i.dataset.abtastyActionnable="true"),i.addEventListener("click",()=>{this.currentFeedback=s.querySelector("textarea").value,this.currentStep=this.steps[this.steps.indexOf(this.currentStep)+1],this.showCurrentStep()},{passive:!0,capture:!0,once:!0}),s}getThanksElement(){const e=document.createElement("p");return e.className=this.thanksClassName,e.innerHTML=DATA.thanksMessage,e}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}`}}),m(`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 V.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}=DATA,n=document.createElement("button");return n.className=t.className,n.dataset.index=t.index,n.dataset.note=s,n.ariaLabel=`${DATA.mainQuestion} - ${s}/${DATA.emojisQty}`,n.innerHTML="text"===i?t.iconText:t.iconUrl,e()&&(n.dataset.abtastyActionnable="true"),n.addEventListener("click",this.onEmojiClick.bind(this),{passive:!0,capture:!0}),n}getEmojisContainer(){const{emojisQty:t,stepPreview:s,mainQuestion:i}=DATA,n=document.createElement("p");n.innerHTML=i;const r=document.createElement("div");r.className=this.voteClassName,r.appendChild(n);const o=[,,[0,4],[0,2,4],[0,1,3,4],[0,1,2,3,4]];return this.emojisList.forEach((e,s)=>{if(o[t].includes(s)){const i=o[t].indexOf(s)+1,n=this.getEmojiButton(e,i);r.appendChild(n)}}),(e()&&"vote"!==s||"vote"!==this.currentStep)&&r.classList.add(this.hideClassName),r}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}getStyleElement(){const t=document.createElement("style");t.type="text/css",e()&&t.setAttribute("abtasty-script-added","true");const{emojisType:s,customColors:i,emojisMargin:n,borderColor:r,textColor:o,backgroundColor:a}=DATA,c=V.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: ${i?DATA[`${t}Color`]:q[t]};\n\t\t\t}`,""),l=["abtasty"===s?c:"",".csatEmojiButton {","all: unset !important;",`margin: 0 ${n}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("");return t.textContent=[l,`.${this.questionClassName} textarea {`,"width: 100%;","min-height: 60px;","margin-top: 12px;","margin-bottom: 20px;",`border: 2px solid ${r};`,`color: ${o};`,"}",`.${this.className} textarea::selection,\n\t\t\t.${this.className} p::selection {`,`-webkit-text-fill-color: ${a};`,`text-fill-color: ${a};`,`color: ${a};`,`background-color: ${r};`,"}",`.${this.questionClassName} button {`,"cursor: pointer;","}",`.${this.voteClassName} p {`,"margin-bottom: 12px;","}",`#${this.parentContainer.widgetContainerId} .${this.parentContainer.contentClassName} .${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(""),t}}(async()=>{m("Widget launch");const e=(()=>{const{layout:e}=DATA;let t;switch(e){case"popin":t=new _;break;case"bannerTop":case"bannerBottom":t=new j;break;case"free":t=new O;break;default:t=new k}return t})(),t=e.domElement.querySelector(`.${e.contentClassName}`),s=new W({parentContainer:e});e.children=s,await s.insertIn(t,"beforeend"),e.init(!0).then(t=>{let{response:s}=t;return s&&e.show()})})()}();
|
1
|
+
!function(){"use strict";const t=()=>Object.prototype.hasOwnProperty.call(window,"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="remove",a="rebuild",c="update",l=()=>{const{type:t}=DATA;return`${PACKAGE.replace("@abtasty/","")}${t?`_${t}`:""}`},h=()=>{const t=l();return`${t.charAt(0).toUpperCase()}${t.slice(1)}`.split("-").join(" ")},u=()=>`${PLUGIN_ID.split("-")[0]}_${TEST_ID}`,d=n=>{const r=(()=>{if(t()||e())return!1;const n=ABTasty.getTestsOnPage()[TEST_ID];return!!n&&Object.keys(n.targetings.qaParameters).length>0})(),i=document.cookie.includes("abTastyDebug=")||!0===window.abTastyDebug;if(r||i){const t=h();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;")}},m=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},p=(t,e)=>{const n=()=>{try{return document.querySelector(t)}catch(t){return null}};let r=n();const i=[document.querySelector("body")||document.documentElement,{childList:!0,subtree:!0,attributes:!0}],o=()=>a.disconnect(),s=()=>a.observe(...i),a=new MutationObserver(()=>(r=n(),r&&!o()&&e(r)));return r?setTimeout(()=>e(r),0):s(),{selector:t,clear:o,observe:s}};function g(t,e){return e(t)||!t.parentElement?t:g(t.parentElement,e)}const f=(t,e)=>[...document.querySelectorAll(e)].some(n=>n===t||!!t.closest(e)),v=(t,e)=>{let n=Date.now();return()=>{n+e-Date.now()<=0&&(t(),n=Date.now())}};class y{constructor(){this.targets=[],this.existingTargets=[],this.inViewportTargets=[],this.visibilityObserver=this.startVisibilityObserver(),this.mutationObserver=null,this.mouseOverEvent=this.mouseOverHandler(),this.scrollEvent=this.scrollEventHandler(),this.onTransitionEnd=this.transitionOverHandler()}transitionOverHandler(){const t=["transitionend",this.checkElements.bind(this),!0];return this.getEvents(t)}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(){return new IntersectionObserver(this.intersectionHandler.bind(this),{root:null,rootMargin:"0px",threshold:0})}startMutationObserver(){this.mutationObserver??=new MutationObserver(this.checkElements.bind(this));const{clear:t}=p("body",e=>{t(),this.mutationObserver.observe(e,{attributes:!0,childList:!0,subtree:!0})});return this.mutationObserver}onMouseOver({target:t,path:e}){const n=this.inViewportTargets.find(({element:n,selector:r})=>{if(n.isSameNode(t))return!0;const i=[...t.querySelectorAll(r)];if(i.length&&i.includes(n))return!0;if(e.includes(n))return!0;const o=[...t.parentElement.children],s=o.findIndex(e=>e.isSameNode(t)),a=o.filter((t,e)=>e>s);if(a.length){if(a.includes(n))return!0;if(a.some(t=>[...t.querySelectorAll(r)].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){return{start:()=>document.addEventListener(...t),clear:()=>document.removeEventListener(...t)}}mouseOverHandler(){const 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(t)}scrollEventHandler(){const t=["scroll",v(this.checkElements.bind(this),50),{passive:!0}];return this.getEvents(t)}isElementVisible(t){return this.isElementTopmost(t)&&this.isElementOpaque(t)}isElementOpaque(t){return"HTML"===g(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=document.elementFromPoint(...n[i]);r=t===e||t.contains(e),i+=1}return r}checkElements(){this.targets.forEach(({selector:t,uniqueId:e})=>{const n=document.querySelector(t);n&&!this.existingTargets.find(n=>n.element.matches(t)&&n.uniqueId===e)&&(this.existingTargets.push({element:n,selector:t,uniqueId:e}),this.visibilityObserver.observe(n))}),this.existingTargets=this.existingTargets.filter(({selector:t,element:e})=>!!document.querySelector(t)||(e&&this.visibilityObserver.unobserve(e),!1)),this.inViewportTargets=this.inViewportTargets.filter(({selector:t,element:e,uniqueId:n})=>{if(e.matches(t)&&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})}watch(t,e,n){this.targets.push({selector:t,resolve:e,uniqueId:n}),this.startMutationObserver(),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=document.querySelector(t);n&&this.visibilityObserver.unobserve(n),0===this.targets.length&&this.mutationObserver?.disconnect(),0===this.inViewportTargets.length&&(this.mouseOverEvent.clear(),this.scrollEvent.clear(),this.onTransitionEnd.clear())}}class w{constructor({triggerEvent:t,triggerSelector:e,triggerDelay:n,triggerTarget:r}){this.event=t,this.selector=e&&e.length?e:"body",this.target=r,this.delay=1e3*n,this.elementsSelectors=[],this.eventsListeners=[],this.timeouts=[],this.intervals=[],this.promises=[],this.visibilityObservers=[],this.socialProofStore={}}async onElementVisible({promise:t,resolve:e}){const n=m(`${this.event}DomReady`);this.promises.push(n);const r=await this.onPageLoad(n),i=new y;if(this.visibilityObservers.push(i),r){const t=u();i.watch(this.selector,e,t)}return 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=document.createElement("style");n.type="text/css",n.id=`Click_${u()}`,n.innerHTML=`${this.selector} {\n\t\t\tcursor: pointer !important;\n\t\t\tpointer-events: all !important;\n\t\t}`,document.head.appendChild(n),this.elementsSelectors.push(`#${n.id}`);const r=["click",({isTrusted:t,target:n})=>{const r=n.isEqualNode(this.target)||f(n,this.selector);return t&&r&&e(!0)},{passive:!0,capture:!0}];return this.eventsListeners.push([document,...r]),document.addEventListener(...r),t}onHover({promise:t,resolve:e}){const n=["mouseenter",({isTrusted:t,target:n})=>{const r=this.target?n.isEqualNode(this.target):f(n,this.selector);return t&&r&&e(!0)},{passive:!0,capture:!0}];return this.eventsListeners.push([document.documentElement,...n]),document.documentElement.addEventListener(...n),t}onExitIntent({promise:t,resolve:e}){const n=["mouseleave",({isTrusted:t,clientY:n})=>{t&&n<=0&&e(!0)},{passive:!0}],{clear:r}=p("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=[({isTrusted:t})=>{t&&(r=n)},{passive:!0}];["click","mousemove","scroll","keypress"].forEach(t=>{this.eventsListeners.push([document,t,...i]),document.addEventListener(t,...i)});const o=setInterval(()=>{r<=0?e(!0):r-=100},100);return this.intervals.push(o),t}onCustomTrigger({promise:t,resolve:e}){const{triggerEventCustomScript:n}=DATA;return new Function(`return new Promise(async resolve => {${n}})`)().then(t=>t&&e(!0)),t}onScrollUp({promise:t,resolve:e}){let n=0;const r=["scroll",({isTrusted:t})=>{t&&(window.pageYOffset<n?e(!0):n=window.pageYOffset)},{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&&window.ABTASTY_S.USER&&window.ABTASTY_S.USER.accountIdentifier&&window.ABTASTY_S.USER.accountIdentifier.length?t=window.ABTASTY_S.USER.accountIdentifier:window.ABTasty&&window.ABTasty.getAccountSettings&&"function"==typeof window.ABTasty.getAccountSettings?t=window.ABTasty.getAccountSettings().identifier:window.ABTasty&&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(()=>d("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}=DATA;if(2===t)return{productKey:r(),keyType:"url"};{let a=null,c="sku";switch(e){case"ABTastyProductKey":a=window.ABTastyProductKey;break;case"pathToProductKey":a=n(`return ${i};`);break;case"customJSProductKey":a=n(o);break;case"productSKU":a=s}return a||3!==t||(a=r(),c="url"),{productKey:a,keyType:c}}})(),{viewInterval:c,triggerSocialProofMinVisitors:l,triggerSocialProofMinPurchases:h,triggerSocialProofMinPageViews:u}=DATA,m={pv:u,i:h,"v-pv":l}[i];return[typeof c,typeof m].includes("undefined")&&e(!1),o&&!s&&(d("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||d(`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("ABTastyData");const i=()=>JSON.parse(r).ActionTracking.find(({name:t})=>t===n),o=["storage",()=>{r=localStorage.getItem("ABTastyData"),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("ABTastyData");const i=()=>n<=(r?JSON.parse(r).VisitedPages.length:0),o=["storage",()=>{r=localStorage.getItem("ABTastyData"),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}];return this.eventsListeners.push([document,...s]),document.addEventListener(...s),t}clear(){if(this.elementsSelectors.length&&(this.elementsSelectors.forEach(t=>{document.querySelector(t)&&document.querySelector(t).remove()}),this.elementsSelectors=[]),this.eventsListeners.length&&(this.eventsListeners.forEach(t=>{const[e,...n]=t;e&&n.length>1&&e.removeEventListener(...n)}),this.eventsListeners=[]),this.timeouts.length&&(this.timeouts.forEach(t=>clearTimeout(t)),this.timeouts=[]),this.intervals.length&&(this.intervals.forEach(t=>clearInterval(t)),this.intervals=[]),this.visibilityObservers.length){const t=u();this.visibilityObservers.forEach(e=>e.clear(this.selector,t)),this.visibilityObservers=[]}return this.promises.length&&(this.promises.forEach(t=>t.resolve(!1)),this.promises=[]),this}async isTriggered(){this.clear();const t=m(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=m(`${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 b="display",E="closing",T="validation",S="ABTastyWidgets",C=`${S}Temporary`;class ${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=l(),this.uniqueId=u(),this.recurrenceKey=`${this.widgetName}_${this.uniqueId}`,this.isListeningStorageEvent=this.listenStorageEvent(),this.pendingRecurrence=!1,this.pendingRecurrenceValue={}}onStorage({key:t}){const e=localStorage.getItem(C),n=sessionStorage.getItem(S);"ABTastyData"===t&&!e&&n&&localStorage.setItem(C,n)}listenStorageEvent(){return this.isListeningStorageEvent||window.addEventListener("storage",this.onStorage.bind(this)),!0}getGivenRecurrenceStorageParsed(t){try{const e=t.getItem(S);return JSON.parse(e)}catch(e){return t.removeItem(S),!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(S,JSON.stringify(r)),r):(t.removeItem(S),!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(C),e=!(!t||!t.includes(this.recurrenceKey))||this.getSessionRecurrence();t&&(sessionStorage.setItem(S,t),localStorage.removeItem(C));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 w({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(S,JSON.stringify(r)),this.onSetCallback&&"function"==typeof this.onSetCallback&&this.onSetCallback()};if(!s)return!1;if(l&&n!==T)if(n===E&&l!==T)h();else{if(n!==b||l===T||l===E)return!1;h()}else h();return a}setDisplayRecurrence(){const t=b;this.setRecurrence(this.displayRecurrence,t)}setClosingRecurrence(){const t=E;this.setRecurrence(this.closingRecurrence,t)}setValidationRecurrence(){const t=T;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 A{constructor(t,e,n){this.isWidgetApplied=t,this.callback=e,this.shouldUpdate=n,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(){const t=this.isWidgetApplied()?this.shouldUpdate&&c:a;return t?(this.clearWatcher(),this.callback(t,!0),this.watch(),this):this}onCampaignLaunched({detail:{campaignId:t}}){t===TEST_ID&&(this.callback(a,!1),this.watch())}onTagRollback(){return this.clearWatcher(),this.callback(s,!1),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(s,!1)}watch(){if(t())return this;this.clearWatcher(),window.removeEventListener(...this.onCampaignLaunchedEventParams),document.addEventListener(...this.tagRollbackEventParams);const{clear:e}=p("body",t=>{e(),this.observer.observe(t,{childList:!0,subtree:!0})});return this}clearWatcher(){return document.removeEventListener(...this.tagRollbackEventParams),this.observer.disconnect(),this}}const x=/.+\/([^.]+)\.(otf|ttf)$/,k=["socialProofPurchases","socialProofPageViews","socialProofVisitors"];class L{constructor(e,n){this.children=void 0,this.uniqueId=`${u()}${n?`_${n}`:""}`,this.widgetName=l(),this.prettyName=h(),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 $(this.recurrenceParams,this.clearGivenClearables.bind(this)),this.trigger=!!this.triggerParams&&new w(this.triggerParams),this.shouldUpdate=!!this.triggerParams&&k.includes(this.triggerParams.triggerEvent),this.pageWatcher=new A(this.isWidgetApplied.bind(this),this.onPageChange.bind(this),this.shouldUpdate),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.domElement=this.getDom(),this.hasBeenShown=!1,this.closedByUser=!1,this.eventsListeners=[],this.timeouts=[],this.intervals=[],this.observers=[],this.promises=[],this.elementsWaiters=[]}clearGivenClearables(){this.eventsListeners.forEach(t=>document.removeEventListener(...t)),this.eventsListeners=[],this.timeouts.forEach(t=>clearTimeout(t)),this.timeouts=[],this.intervals.forEach(t=>clearInterval(t)),this.intervals=[],this.elementsWaiters.forEach(t=>t.clear()),this.elementsWaiters=[]}isWidgetApplied(){return this.domElement&&this.domElement.isConnected}removeOldDomElement(){const t=document.getElementById(this.widgetContainerId);return t&&t.remove(),this}async insert(){if(this.isWidgetApplied())return!1;document.head.appendChild(this.styleElement);const t=["free"];return"drawer"===DATA.layout&&DATA.customTarget&&t.push("drawer"),new Promise(e=>{const{elementReferrer:n="body",referrerInsertType:r="beforeend"}=t.includes(DATA.layout)?DATA:{},i=p(n,t=>{this.elementsWaiters=this.elementsWaiters.filter(t=>t.selector!==n),this.removeOldDomElement(),e(t.insertAdjacentElement(r,this.domElement))});this.elementsWaiters.push(i)}).then(()=>this)}remove(){return this.trigger&&this.trigger.clear(),this.pageWatcher.clearWatcher(),[this.domElement,this.styleElement].forEach(t=>t&&t.isConnected&&t.remove()),this.hasOncePerPageTrigger?this.pageWatcher.watch():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}hide(e=!0){return!t()&&this.hasBeenShown&&e&&window.ABTastyEvent(`${this.prettyName} closed`,null,TEST_ID),e&&(this.pageWatcher.clearWatcher(),this.closedByUser=!0),this.domElement.classList.add(this.hideClassName),this}async init(e){const n=t(),r=i(),o=this.trigger&&this.trigger.promises.length,s=!this.recurrence||this.recurrence.isOver();if(!n&&!r||o||!s)return{container:this,response:!1};this.pageWatcher.watch();const a=n||!this.trigger||this.trigger&&await this.trigger.isTriggered(),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){const n=()=>this.init().then(({response:t})=>{t?this.show():this.hide(!1)});e||(this.hasBeenShown=!1,this.trigger&&this.trigger.clear());const r=this.isWidgetApplied(),i={[s]:()=>r?this.remove():this.pageWatcher.watch(),[a]:()=>{this.hasBeenShown?this.closedByUser?this.pageWatcher.watch():r||this.insert().then(t=>t.show()).catch(this.pageWatcher.watch):n()},[c]:n};"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,overlay:n=!0}=DATA,r=document.createElement("div");return r.className=`${this.basicClassName} ${this.hideClassName}`,r.id=this.widgetContainerId,["popin","banner"].includes(e)&&(r.role="dialog"),r.innerHTML=`\n\t\t\t${"popin"===e&&!0===n?`<div 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>`,r}loadFont(t,e){if(!t||"inherit"===t||!/otf|ttf/g.test(e))return;const n=document.createElement("style"),r=e.match(x)?e.match(x)[1]:"";n.innerHTML=`@font-face { font-family: '${t}_${r}'; src: url('${e}'); font-display: swap; }`,document.head.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:w,titleTextAlign:b,titleTextColor:E,titleFontName:T,titleFontStyle:S,titleFontSize:C,overlay:$,overlayColor:A,dropShadow:k,dropShadowColor:L,dropShadowBlur:N,containerMargin:P,containerPadding:j,closeButton:_,closeButtonPosition:I,closeButtonSize:D,closeButtonBorderRadius:O,closeButtonBorderWidth:R,closeButtonBorderColor:B,closeButtonColor:q,closeButtonBackgroundColor:V,buttonsAlign:W,buttonsBorderWidth:F,buttonsBorderColor:M,buttonsBorderRadius:H,buttonsBackgroundColor:U,buttonsTextColor:G,buttonsFontName:Q,buttonsFontStyle:z,buttonsFontSize:K,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");lt.type="text/css",t()&<.setAttribute("abtasty-script-added","true"),this.loadFont(f,v),this.loadFont(T,S),this.loadFont(Q,z),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(x)?v.match(x)[1]:""};`:v||"",vt=y?`font-size: ${y}px;`:"",yt=void 0!==k&&k?`box-shadow: 0 5px ${N}px 0 ${L};`:"",wt=P instanceof Array&&1===P.length&&P[0],bt=wt?`margin: ${wt.top}px ${wt.right}px ${wt.bottom}px ${wt.left}px;`:"",Et=wt?`margin: calc(${wt.top}px * 0.5) calc(${wt.right}px * 0.5) calc(${wt.bottom}px * 0.5) calc(${wt.left}px * 0.5);`:"",Tt=j instanceof Array&&1===j.length&&j[0],St=Tt?`padding: ${Tt.top}px ${Tt.right}px ${Tt.bottom}px ${Tt.left}px;`:"",Ct=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;`:"",At=[M,F].every(t=>void 0!==t)&&F?`border-color: ${M};`:"",xt=void 0!==H?`border-radius: ${H}px;`:"",kt=void 0!==U?`background-color: ${U};`:"",Lt=void 0!==G?`color: ${G}; fill: ${G}; -webkit-text-fill-color: ${G};`:"",Nt=Q&&"inherit"!==Q?`font-family:${Q}_${z.match(x)?z.match(x)[1]:""};`:z||"",Pt=K?`font-size: ${K}px;`:"",jt="number"==typeof J?`border-width: ${J}px; border-style: solid;`:"",_t=[X,J].every(t=>void 0!==t)&&J?`border-color: ${X};`:"",It=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(x)?rt.match(x)[1]:""};`:rt||"",Bt=it?`font-size: ${it}px;`:"",qt="popin"!==i||void 0!==$&&!0!==$?"":[`#${this.widgetContainerId} .${this.overlayClassName} {`,`background-color: ${void 0!==A?A:"rgba(0, 0, 0, 0.6)"};`,"}"].join(""),Vt="number"==typeof D?D:16,Wt=Vt/2,Ft=r||void 0!==_&&_?[`#${this.widgetContainerId} .${this.contentClassName} .${this.closeButtonClassName} {`,"position: absolute;",("out"===I?`bottom: calc(100% + ${Wt}px)`:`top: ${Wt}px`)+";",`right: ${Wt}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 q?`fill: ${q};`:"","}"].join(""):"",Mt=w&&"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!==b?`text-align: ${b};`:"",T&&"inherit"!==T?`font-family:${T}_${S.match(x)?S.match(x)[1]:""};`:S||"",C?`font-size: ${C}px;`:"","}"].join(""):"";let Ht="";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(),Ht={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 Ut=[`#${this.widgetContainerId} .${this.contentClassName} .buttons_container .second_link {`,`margin-${"fill"===W?"top":"left"}: 8px;`,jt,_t,It,Dt,Ot,Rt,Bt,"}",`#${this.widgetContainerId} .${this.contentClassName} .buttons_container .second_link {`,Ot,Rt,Bt,"}"];return lt.textContent=[`.${this.hideClassName} {`,"pointer-events: none;","}",`#${this.widgetContainerId} {`,"opacity: 1;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,ht,mt,dt,pt,gt,yt,bt,ft,vt,"}",`#${this.widgetContainerId} .${this.contentClassName} p {`,pt,gt,ft,vt,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,"display: block;","line-height: 1;","text-indent: unset;",St,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,At,xt,kt,Lt,Nt,Pt,"}",`#${this.widgetContainerId} .${this.contentClassName} div.buttons_container a *, `,`#${this.widgetContainerId} .${this.contentClassName} button:not(class*="close_button") * {`,Lt,Nt,Pt,"}",...Y?Ut:[],"@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,Et,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,Ct,"}","}",qt,Ft,Mt,Ht,`${e}`].join(""),lt}}const N=["top: 0;","top: 50%;","bottom: 0;"],P=["left: 0;","left: 50%;","right: 0;"],j=t=>1===t?"-50%":0,_=()=>{if(Array.isArray(DATA.popinPosition)){const{popinPosition:[{x:t,y:e}]}=DATA,n=`translate(${j(e)}, ${j(t)});`;return`${N[t]}${P[e]}transform: ${n}`}return"left: 50%;top: 50%;transform: translate(-50%, -50%);"},I=()=>"autoWidth"in DATA&&!0===DATA.autoWidth,D=()=>{if(I())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 O extends L{constructor(){super(),this.translateValues=Object.values(DATA.popinPosition[0]).map(t=>j(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;",_(),D(),"pointer-events: all","}",`${I()?"":[`#${this.widgetContainerId} .${this.contentClassName} > div {`,"height: 100%;","overflow: auto;","box-sizing: border-box;","}"].join("")}`,`${!I()&&["px","em"].includes(n)?["@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,"max-width: 94vw;","}","}"].join(""):""}`].join("")}}class R extends L{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 B extends L{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 q=()=>{const{layout:t}=DATA;let e;switch(t){case"popin":e=new O;break;case"bannerTop":case"bannerBottom":e=new R;break;case"free":e=new B;break;default:e=new L}return e};function V(t){return V="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},V(t)}function W(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */W=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 L(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 w={};l(w,s,function(){return this});var b=Object.getPrototypeOf,E=b&&b(b(N([])));E&&E!==n&&r.call(E,s)&&(w=E);var T=y.prototype=f.prototype=Object.create(w);function S(t){["next","throw","return"].forEach(function(e){l(t,e,function(t){return this._invoke(e,t)})})}function C(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"==V(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=A(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 A(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,A(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 x(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 k(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function L(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,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(V(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}},S(C.prototype),l(C.prototype,a,function(){return this}),e.AsyncIterator=C,e.async=function(t,n,r,i,o){void 0===o&&(o=Promise);var s=new C(h(t,n,r,i),o);return e.isGeneratorFunction(n)?s:s.next().then(function(t){return t.done?t.value:s.next()})},S(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,L.prototype={constructor:L,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(k),!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),k(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;k(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 F(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function M(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 H(t){return function(){var e=this,n=arguments;return new Promise(function(r,i){var o=t.apply(e,n);function s(t){M(o,r,i,s,a,"next",t)}function a(t){M(o,r,i,s,a,"throw",t)}s(void 0)})}}function U(t){var e=function(t){if("object"!=V(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=V(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==V(e)?e:e+""}var G={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(G),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,this.styleElement=this.getStyleElement()},n=[{key:"getABtastyEmojis",value:(o=H(W().mark(function t(){var e,n=this;return W().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return e=function(){var t=H(W().mark(function t(e,r){var i,o,s;return W().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return i=r.iconUrl,t.next=3,e;case 3:return o=t.sent,t.next=6,n.fetchTastyEmojis(i);case 6:return s=t.sent,t.abrupt("return",[].concat(function(t){if(Array.isArray(t))return F(t)}(a=o)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(a)||function(t,e){if(t){if("string"==typeof t)return F(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?F(t,e):void 0}}(a)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),[s]));case 8:case"end":return t.stop()}var a},t)}));return function(e,n){return t.apply(this,arguments)}}(),t.next=3,this.emojisList.reduce(e,[]);case 3:window.abtastyEmojis=t.sent,this.emojisList.forEach(function(t,e){t.iconUrl=window.abtastyEmojis[e]});case 5:case"end":return t.stop()}},t,this)})),function(){return o.apply(this,arguments)})},{key:"insertIn",value:(i=H(W().mark(function t(e,n){var r;return W().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 document.head.insertAdjacentElement("beforeend",this.styleElement),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.openQuestionPositive,n=t.openQuestionNeutral,r=t.openQuestionNegative,i=[r,r,n,e,e][this.emojiChoice],o=this.questionElement.querySelector("textarea");return this.currentOpenQuestion=i,o.ariaLabel=i,o.focus(),this.questionElement.querySelector("p").innerHTML=i||e,this}},{key:"getQuestionElement",value:function(){var e=this,n=DATA.openQuestionPositive,r=document.createElement("div");r.className=this.questionClassName,r.innerHTML="<p>".concat(n,'</p>\n\t\t<textarea aria-label="').concat(n,'"></textarea>\n\t\t<button>').concat(DATA.sendButtonText,"</button>");var i=r.querySelector("button");return t()&&(i.dataset.abtastyActionnable="true"),i.addEventListener("click",function(){e.currentFeedback=r.querySelector("textarea").value,e.currentStep=e.steps[e.steps.indexOf(e.currentStep)+1],e.showCurrentStep()},{passive:!0,capture:!0,once:!0}),r}},{key:"getThanksElement",value:function(){var t=document.createElement("p");return t.className=this.thanksClassName,t.innerHTML=DATA.thanksMessage,t}},{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)}}),d("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=H(W().mark(function t(e){return W().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 Q.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.emojisType,i=document.createElement("button");return i.className=e.className,i.dataset.index=e.index,i.dataset.note=n,i.ariaLabel="".concat(DATA.mainQuestion," - ").concat(n,"/").concat(DATA.emojisQty),i.innerHTML="text"===r?e.iconText:e.iconUrl,t()&&(i.dataset.abtastyActionnable="true"),i.addEventListener("click",this.onEmojiClick.bind(this),{passive:!0,capture:!0}),i}},{key:"getEmojisContainer",value:function(){var e=this,n=DATA,r=n.emojisQty,i=n.stepPreview,o=n.mainQuestion,s=document.createElement("p");s.innerHTML=o;var a=document.createElement("div");a.className=this.voteClassName,a.appendChild(s);var c=[,,[0,4],[0,2,4],[0,1,3,4],[0,1,2,3,4]];return this.emojisList.forEach(function(t,n){if(c[r].includes(n)){var i=c[r].indexOf(n)+1,o=e.getEmojiButton(t,i);a.appendChild(o)}}),(t()&&"vote"!==i||"vote"!==this.currentStep)&&a.classList.add(this.hideClassName),a}},{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:"getStyleElement",value:function(){var e=document.createElement("style");e.type="text/css",t()&&e.setAttribute("abtasty-script-added","true");var n=DATA,r=n.emojisType,i=n.customColors,o=n.emojisMargin,s=n.borderColor,a=n.textColor,c=n.backgroundColor,l=Q.reduce(function(t,e){var n=i?DATA["".concat(e,"Color")]:G[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)},""),h=["abtasty"===r?l:"",".csatEmojiButton {","all: unset !important;","margin: 0 ".concat(o,"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("");return e.textContent=[h,".".concat(this.questionClassName," textarea {"),"width: 100%;","min-height: 60px;","margin-top: 12px;","margin-bottom: 20px;","border: 2px solid ".concat(s,";"),"color: ".concat(a,";"),"}",".".concat(this.className," textarea::selection,\n\t\t\t.").concat(this.className," p::selection {"),"-webkit-text-fill-color: ".concat(c,";"),"text-fill-color: ".concat(c,";"),"color: ".concat(c,";"),"background-color: ".concat(s,";"),"}",".".concat(this.questionClassName," button {"),"cursor: pointer;","}",".".concat(this.voteClassName," p {"),"margin-bottom: 12px;","}","#".concat(this.parentContainer.widgetContainerId," .").concat(this.parentContainer.contentClassName," .").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(""),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,U(r.key),r)}}(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n,r,i,o}();function K(t){return K="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},K(t)}function Y(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */Y=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 L(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 w={};l(w,s,function(){return this});var b=Object.getPrototypeOf,E=b&&b(b(N([])));E&&E!==n&&r.call(E,s)&&(w=E);var T=y.prototype=f.prototype=Object.create(w);function S(t){["next","throw","return"].forEach(function(e){l(t,e,function(t){return this._invoke(e,t)})})}function C(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"==K(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=A(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 A(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,A(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 x(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 k(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function L(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,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(K(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}},S(C.prototype),l(C.prototype,a,function(){return this}),e.AsyncIterator=C,e.async=function(t,n,r,i,o){void 0===o&&(o=Promise);var s=new C(h(t,n,r,i),o);return e.isGeneratorFunction(n)?s:s.next().then(function(t){return t.done?t.value:s.next()})},S(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,L.prototype={constructor:L,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(k),!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),k(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;k(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 J(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 X=function(){var t,e=(t=Y().mark(function t(){var e,n,r;return Y().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return d("Widget launch"),e=q(),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){J(o,r,i,s,a,"next",t)}function a(t){J(o,r,i,s,a,"throw",t)}s(void 0)})});return function(){return e.apply(this,arguments)}}();X()}();
|
package/package.json
CHANGED
@@ -1,43 +1,47 @@
|
|
1
|
-
{
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
1
|
+
{
|
2
|
+
"name": "@abtasty/csat",
|
3
|
+
"description": "Customer Satisfaction widget",
|
4
|
+
"version": "0.0.24",
|
5
|
+
"form": "dist/form.js",
|
6
|
+
"main": "dist/main.js",
|
7
|
+
"type": "module",
|
8
|
+
"files": [
|
9
|
+
"dist"
|
10
|
+
],
|
11
|
+
"author": "ABTasty",
|
12
|
+
"license": "MIT",
|
13
|
+
"scripts": {
|
14
|
+
"cloneConfig": "scp ../rollup.default.config.js ./rollup.config.js && scp ../babel.default.config.json ./babel.config.json",
|
15
|
+
"publish:package": "yarn build && yarn npm publish --access public",
|
16
|
+
"publish:staging": "yarn && yarn version prerelease && yarn run publish:package",
|
17
|
+
"publish:prod": "yarn && yarn version patch && yarn run publish:package",
|
18
|
+
"publish:staging:breaking:minor": "yarn && yarn version preminor && yarn run publish:package",
|
19
|
+
"publish:breaking:minor": "yarn && yarn version minor && yarn run publish:package",
|
20
|
+
"publish:staging:breaking:major": "yarn && yarn version premajor && yarn run publish:package",
|
21
|
+
"publish:breaking:major": "yarn && yarn version major && yarn run publish:package",
|
22
|
+
"watch": "yarn && yarn run cloneConfig && rollup -c --watch",
|
23
|
+
"build": "yarn && yarn run cloneConfig && rollup -c"
|
24
|
+
},
|
25
|
+
"devDependencies": {
|
26
|
+
"@babel/core": "^7.24.0",
|
27
|
+
"@babel/eslint-parser": "^7.23.10",
|
28
|
+
"@babel/plugin-proposal-object-rest-spread": "^7.18.6",
|
29
|
+
"@babel/preset-env": "^7.24.0",
|
30
|
+
"@rollup/plugin-alias": "5.1.0",
|
31
|
+
"@rollup/plugin-babel": "^6.0.3",
|
32
|
+
"@rollup/plugin-eslint": "^9.0.1",
|
33
|
+
"@rollup/plugin-node-resolve": "^15.0.1",
|
34
|
+
"@rollup/plugin-terser": "^0.4.4",
|
35
|
+
"babel-plugin-minify-dead-code-elimination": "^0.5.2",
|
36
|
+
"caniuse-lite": "^1.0.30001434",
|
37
|
+
"cssnano": "^5.1.12",
|
38
|
+
"eslint": "^8.57.0",
|
39
|
+
"eslint-config-prettier": "^9.1.0",
|
40
|
+
"eslint-import-resolver-node": "^0.3.2",
|
41
|
+
"eslint-plugin-import": "^2.29.1",
|
42
|
+
"postcss": "^8.4.19",
|
43
|
+
"postcss-cssnext": "^3.1.1",
|
44
|
+
"rollup": "^4.12.0",
|
45
|
+
"rollup-plugin-postcss": "^4.0.2"
|
46
|
+
}
|
47
|
+
}
|