@abtasty/widget-utils
Advanced tools
Comparing version 1.16.7-0 to 1.16.7-1
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=()=>Object.prototype.hasOwnProperty.call(window,"ABTastyEditor");function t(e,t){return ABTasty.widgetUtils||(ABTasty.widgetUtils={}),ABTasty.widgetUtils[e]||Object.assign(ABTasty.widgetUtils,{[e]:new t}),ABTasty.widgetUtils[e]}const o=()=>{let e;return window.ABTasty||window.ABTASTY_S?(window.ABTASTY_S&&window.ABTASTY_S.USER&&window.ABTASTY_S.USER.accountIdentifier&&window.ABTASTY_S.USER.accountIdentifier.length?e=window.ABTASTY_S.USER.accountIdentifier:window.ABTasty&&window.ABTasty.getAccountSettings&&"function"==typeof window.ABTasty.getAccountSettings?e=window.ABTasty.getAccountSettings().identifier:window.ABTasty&&window.ABTasty.accountSettings&&(e=window.ABTasty.accountSettings.identifier),e):e},r=()=>{const e=!!document.getElementById("ABTastyPreviewBar"),t=location.href.includes("ab_project=preview");return e||t},i=()=>window.ABTastyProductKey,s=()=>!!window.ABTasty.getTestsOnPage()[TEST_ID]||r(),n=()=>{if(e())return!1;const t=ABTasty.getTestsOnPage()[TEST_ID];return!!t&&Object.keys(t.targetings.qaParameters).length>0},a="style",l="conditions",c="switch",g="slider",d="group",p="https://widgets-images.abtasty.com/",u="rgba(255, 255, 255, 1)",m="rgba(247, 247, 247, 1)",h="https://social-proof-api.abtasty.com/clients/",_=()=>{const{type:e}=DATA;return`${PACKAGE.replace("@abtasty/","")}${e?`_${e}`:""}`},b=()=>{const e=_();return`${e.charAt(0).toUpperCase()}${e.slice(1)}`.split("-").join(" ")},y=()=>`${PLUGIN_ID.split("-")[0]}_${TEST_ID}`,v=()=>{const{displayRecurrence:t,closingRecurrence:o,validationRecurrence:r}=DATA;if(e()||!t&&!o&&!r)return!1;const i={everytime:()=>-1,session:()=>0,once:()=>395,day:e=>DATA[`${e}_day`],week:e=>7*DATA[`${e}_week`],month:e=>30.5*DATA[`${e}_month`]},s={};return t&&(s.displayRecurrence=i[t]("displayRecurrence")),o&&(s.closingRecurrence=i[o]("closingRecurrence")),r&&(s.validationRecurrence=i[r]("validationRecurrence")),s},w=()=>{let{triggerEvent:t}=DATA;const{triggerEventClick:o,triggerEventReengageDelay:r,socialProofContentType:i,triggerEventElementVisible:s,triggerEventDelay:n}=DATA;if(e()||!t&&!i)return!1;const a={click:()=>o,elementVisible:()=>s},l=Object.prototype.hasOwnProperty.call(a,t)?a[t]():"body",c="reengage"===t?r:n;return i&&(t=1===i?"socialProofPurchases":"socialProofPageViews"),{triggerEvent:t,triggerSelector:l,triggerDelay:c}},f=()=>{const{isOncePerPageTrigger:e,triggerEvent:t}=DATA;return!(!e||!["click","script"].includes(t))||["pageLoad","direct","reengage","socialProofPurchases","socialProofPageViews","elementVisible"].some(e=>e===t)},x=(...e)=>{e.unshift(`[AB Tasty Widget] ${PACKAGE}:`),console.log(...e)},T=e=>{if(n()){const t=b();window.console.log(`%c${t} - QA Mode for campaign ${TEST_ID}\n${e}`,`background-color: rgba(0, 127, 145, 1); color: ${m}`)}},S=()=>{let e=document.location.hostname.split("").reverse().join("");if(e=e.match(/(?:[a-z]{2,4}\.[a-z]{2,3}|[a-z]{2,5})\.[a-z0-9-]+(?:\.|$)/i),null===e)e=document.location.hostname;else{"."!==e[0].substr(e[0].length-1)&&(e[0]+="."),e=e[0].split("").reverse().join("")}return e},E=e=>{const t={promise:null,resolve:null,reject:null,name:e};return t.promise=new Promise((e,o)=>{t.resolve=e,t.reject=o}),t},A=(e,t,o)=>{let r=0,i=0;try{document.querySelector(e)}catch(t){const r=`Selector «${e}» not valid.`;return x(r),"function"==typeof o&&o(r)}function s(){clearInterval(i),clearTimeout(r)}return r=setTimeout(()=>{s();const t=`Can't find element «${e}».`;return x(t),"function"==typeof o&&o(t)},1e4),i=setInterval(()=>{const o=document.querySelector(e);return null!==o?(s(),"function"==typeof t&&t(o)):o},200),{clear:s}};function C(e,t){return t(e)||!e.parentElement?e:C(e.parentElement,t)}let I;function N(e){return new Promise((t,o)=>{const r=window.document.getElementsByTagName("script")[0],i=window.document.createElement("script");i.src=e,r.parentNode.insertBefore(i,r),i.onload=t,i.onerror=o})}async function $(e){let t;switch(e){case"IntersectionObserver":t=await("IntersectionObserver"in window&&"IntersectionObserverEntry"in window&&"intersectionRatio"in window.IntersectionObserverEntry.prototype||N("https://polyfill.io/v3/polyfill.min.js?flags=gated&features=IntersectionObserver"));break;default:t=!0}return t}class R{constructor({displayRecurrence:e,closingRecurrence:t,validationRecurrence:o},r){this.displayRecurrence=parseFloat(e),this.closingRecurrence=parseFloat(t),this.validationRecurrence=parseFloat(o),this.onSetCallback=r,this.widgetName=_(),this.uniqueId=y(),this.recurrenceKey=`${this.widgetName}_${this.uniqueId}`}getGivenRecurrenceStorageParsed(e){try{const t=e.getItem("ABTastyWidgets");return JSON.parse(t)}catch(t){return e.removeItem("ABTastyWidgets"),!1}}getSessionRecurrenceStorageParsed(){return this.getGivenRecurrenceStorageParsed(window.sessionStorage)}getLocalRecurrenceStorageParsed(){return this.getGivenRecurrenceStorageParsed(window.localStorage)}removeGivenStorage(e,t){const{[this.recurrenceKey]:o,...r}=t;return Object.entries(r).length?(e.setItem("ABTastyWidgets",JSON.stringify(r)),r):(e.removeItem("ABTastyWidgets"),!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(){const e=this.getSessionRecurrence(),t=this.getLocalRecurrence();return e||t||{type:!1}}isOver(){const e=this.getLocalRecurrence(),t=(e?parseFloat(e.stamp):0)<(new Date).getTime();return t&&this.removeLocalRecurrenceStorage(),t&&!this.getLocalRecurrence()&&!this.getSessionRecurrence()}setRecurrence(e,t){const o=this.getTypeOfStorage(e);if(r()||!o&&"object"!=typeof o)return!1;const{storageString:i,storageMethod:s}=o,n=this.getStamp(e),a={type:t,stamp:n},{type:l}=this.getCurrentRecurrence(),c=()=>{const e=this.getSessionRecurrence(),t=this.getLocalRecurrence();let o;"session"===i?e?o=this.removeSessionRecurrenceStorage():(this.removeLocalRecurrenceStorage(),o=this.getSessionRecurrenceStorageParsed()):"local"===i&&(t?o=this.removeLocalRecurrenceStorage():(this.removeSessionRecurrenceStorage(),o=this.getLocalRecurrenceStorageParsed()));const r=o?{[this.recurrenceKey]:a,...o}:{[this.recurrenceKey]:a};s.setItem("ABTastyWidgets",JSON.stringify(r)),this.onSetCallback&&"function"==typeof this.onSetCallback&&this.onSetCallback()};if(!s)return!1;if(l&&"validation"!==t)if("closing"===t&&"validation"!==l)c();else{if("display"!==t||"validation"===l||"closing"===l)return!1;c()}else c();return n}setDisplayRecurrence(){this.setRecurrence(this.displayRecurrence,"display")}setClosingRecurrence(){this.setRecurrence(this.closingRecurrence,"closing")}setValidationRecurrence(){this.setRecurrence(this.validationRecurrence,"validation")}getStamp(e){return(new Date).getTime()+864e5*e}getTypeOfStorage(e){return!(isNaN(e)||e<0||0!==e&&!e)&&(e>0?{storageString:"local",storageMethod:window.localStorage}:0===e&&{storageString:"session",storageMethod:window.sessionStorage})}}class k{constructor(){this.targets=[],this.existingTargets=[],this.inViewportTargets=[],this.visibilityObserver=this.startVisibilityObserver(),this.mutationObserver=this.startMutationObserver(),this.mouseOverEvent=this.mouseOverHandler()}intersectionHandler(e){e.forEach(e=>{e.isIntersecting?(this.existingTargets.forEach(t=>{t.element.isSameNode(e.target)&&(this.inViewportTargets.push(t),this.mouseOverEvent.start())}),this.checkElements()):this.inViewportTargets=this.inViewportTargets.filter(t=>!t.element.isSameNode(e.target)||(this.mouseOverEvent.clear(),!1))})}startVisibilityObserver(){return new IntersectionObserver(this.intersectionHandler.bind(this),{root:null,rootMargin:"0px",threshold:0})}startMutationObserver(){const e=this.mutationObserver||new MutationObserver(this.checkElements.bind(this));return document.body&&e.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),e}onMouseOver({target:e,path:t}){const o=this.inViewportTargets.find(({element:o,selector:r})=>{if(o.isSameNode(e))return!0;const i=[...e.querySelectorAll(r)];if(i.length){if(i.includes(o))return!0}if(t.includes(o))return!0;const s=[...e.parentElement.children],n=s.findIndex(t=>t.isSameNode(e)),a=s.filter((e,t)=>t>n);if(a.length){if(a.includes(o))return!0;if(a.some(e=>[...e.querySelectorAll(r)].includes(o)))return!0}return!1});if(o&&this.isElementVisible(o.element)){const{selector:e,element:t,uniqueId:r}=o,i=this.targets.find(t=>t.selector===e&&t.uniqueId===r);i&&i.resolve(t),this.clear(e,r)}}mouseOverHandler(){const e=["mouseover",e=>setTimeout(()=>this.onMouseOver(e),50),!0];return{start:()=>document.addEventListener(...e),clear:()=>document.removeEventListener(...e)}}isElementVisible(e){return this.isElementTopmost(e)&&this.isElementOpaque(e)}isElementOpaque(e){return"HTML"===C(e,e=>"0"===window.getComputedStyle(e).opacity).nodeName}isElementTopmost(e){const t=e.getBoundingClientRect(),o=[[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 r=!1,i=0;for(;!r&&i<o.length;){const t=document.elementFromPoint(...o[i]);r=e===t||e.contains(t),i+=1}return r}checkElements(){this.targets.forEach(({selector:e,uniqueId:t})=>{const o=document.querySelector(e);o&&!this.existingTargets.find(o=>o.element.matches(e)&&o.uniqueId===t)&&(this.existingTargets.push({element:o,selector:e,uniqueId:t}),this.visibilityObserver.observe(o))}),this.existingTargets=this.existingTargets.filter(({selector:e,element:t})=>!!document.querySelector(e)||(this.visibilityObserver.unobserve(t),!1)),this.inViewportTargets=this.inViewportTargets.filter(({selector:e,element:t,uniqueId:o})=>{if(t.matches(e)&&this.isElementVisible(t)){const r=this.targets.find(t=>t.selector===e&&t.uniqueId===o);return r&&r.resolve(t),this.clear(e,o),!1}return!0})}watch(e,t,o){this.targets.push({selector:e,resolve:t,uniqueId:o});const r=()=>{this.startMutationObserver(),this.checkElements()};document.body?r():A("body",r)}clear(e,t){[this.targets,this.existingTargets,this.inViewportTargets]=[this.targets,this.existingTargets,this.inViewportTargets].map(o=>o.filter(({selector:o,uniqueId:r})=>o!==e&&r!==t)),this.visibilityObserver.unobserve(document.querySelector(e)),0===this.targets.length&&this.mutationObserver.disconnect(),0===this.inViewportTargets.length&&this.mouseOverEvent.clear()}}class P{constructor({triggerEvent:e,triggerSelector:t,triggerDelay:o}){this.event=e,this.selector=t&&t.length?t:"body",this.delay=1e3*o,this.elementsSelectors=[],this.eventsListeners=[],this.timeouts=[],this.intervals=[],this.observers=[],this.promises=[],this.visibilityObservers=[],this.elementsWaiters=[]}async onElementVisible({promise:e,resolve:o}){const r=E(`${this.event}DomReady`);this.promises.push(r);const i=await this.onPageLoad(r),s=await $("IntersectionObserver"),n=t("VisibilityObserver",k);if(this.visibilityObservers.push(n),s&&i){const e=y();n.watch(this.selector,o,e)}return e}onPageLoad({promise:e,resolve:t}){const o=()=>"complete"===document.readyState;if(!o()){const e=["readystatechange",()=>o()&&t(!0),{passive:!0}];this.eventsListeners.push(e),document.addEventListener(...e)}return t(!0),e}onClick({promise:e,resolve:t}){const o=document.createElement("style");o.type="text/css",o.id=`Click_${y()}`,o.innerHTML=`${this.selector} {\n\t\t\tcursor: pointer !important;\n\t\t\tpointer-events: all !important;\n\t\t}`,document.head.appendChild(o),this.elementsSelectors.push(`#${o.id}`);const r=e=>[...document.querySelectorAll(this.selector)].some(t=>t.isSameNode(e)||!!e.closest(this.selector)),i=["click",({target:e})=>r(e)&&t(!0),{passive:!0,capture:!0}];return this.eventsListeners.push(i),document.addEventListener(...i),e}onExitIntent({promise:e,resolve:t}){const o=["mouseleave",async({clientY:e})=>{e<=0&&t(!0)},{passive:!0}],r=A("body",e=>{e.addEventListener(...o),this.eventsListeners.push([e,...o]),this.elementsWaiters=this.elementsWaiters.filter(e=>e!==r)});return this.elementsWaiters.push(r),e}onReengage({promise:e,resolve:t}){const o=this.delay;let r=o;const i=[()=>(r=o,r),{passive:!0}];["click","mousemove","scroll","keypress"].forEach(e=>{document.addEventListener(e,...i),this.eventsListeners.push([e,...i])});const s=setInterval(()=>{r<=0?t(!0):r-=100},100);return this.intervals.push(s),e}onCustomTrigger({promise:e,resolve:t}){const{triggerEventCustomScript:o}=DATA;return new Function(`return new Promise(async resolve => {${o}})`)().then(e=>e&&t(!0)),e}getSocialProofPurchases({promise:e,resolve:t}){const r=i(),s=o(),{viewInterval:n,triggerSocialProofMinPurchases:a,spNoTrim:l}=DATA;if(r||(T("Not able to find ABTastyProductKey, impossible to call the API."),t(!1)),r&&s){fetch(`${h}${s}/metrics/i?key=${r}${l?"&noTrim=true":""}`).then(e=>e.ok&&e.json()).then(e=>(e=>{if(void 0===n||void 0===a)return!1;const t=e[n]&&e[n]>=a;return t||T(`Widget will not be shown, product has been purchased ${e[n]} times while ${a} are required`),t})(e)&&t(e[n])).catch(()=>T("Failed to fetch datas from server."))}else t(!1);return e}getSocialProofPageViews({promise:e,resolve:t}){const r=encodeURIComponent(`${window.location.pathname}`),i=o(),{viewInterval:s,triggerSocialProofMinPageViews:n}=DATA;if(r&&i){fetch(`${h}${i}/metrics/pv?key=${r}`).then(e=>e.ok&&e.json()).then(e=>(e=>{if(void 0===s||void 0===n)return!1;const t=e[s]&&e[s]>=n;return t||T(`Widget will not be shown, page has been seen ${e[s]} times while ${n} are required`),t})(e)&&t(e[s])).catch(()=>T("Failed to fetch datas from server."))}else t(!1);return 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,...o]="string"==typeof e[0]?[document,...e]:e;t&&o.length>1&&t.removeEventListener(...o)}),this.eventsListeners=[]),this.timeouts.length&&(this.timeouts.forEach(e=>clearTimeout(e)),this.timeouts=[]),this.intervals.length&&(this.intervals.forEach(e=>clearInterval(e)),this.intervals=[]),this.observers.length&&(this.observers.forEach(e=>e.disconnect()),this.observers=[]),this.visibilityObservers.length){const e=y();this.visibilityObservers.forEach(t=>t.clear(this.selector,e)),this.visibilityObservers=[]}return this.promises.length&&(this.promises.forEach(e=>e.resolve(!1)),this.promises=[]),this.elementsWaiters.length&&(this.elementsWaiters.forEach(e=>e.clear()),this.elementsWaiters=[]),this}async isTriggered(){this.clear();const e=E(this.event);this.promises.push(e);const t={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),socialProofPurchases:()=>this.getSocialProofPurchases(e),socialProofPageViews:()=>this.getSocialProofPageViews(e)},o=!Object.prototype.hasOwnProperty.call(t,this.event)||await t[this.event]();this.clear();return"reengage"!==this.event&&this.delay?o&&await(async()=>{const e=E(`${this.event}Delay`);return this.promises.push(e),setTimeout(()=>{e.resolve(!0),this.clear()},this.delay),e.promise})():o}}class O{constructor(e,t,o){this.recurrence=e,this.isWidgetApplied=t,this.callback=o,this.observer=new MutationObserver(this.observerHandler.bind(this)),this.eventListenerParams=["abtasty_resetActionTracking",this.eventHandler.bind(this),{passive:!0}],this.elementsWaiters=[]}recurrenceIsDone(){return!this.recurrence||this.recurrence.isOver()}decisionHandler(e){const t=s(),{type:o}=this.recurrence?this.recurrence.getCurrentRecurrence():{type:!1},r=()=>e&&"display"===o||this.recurrenceIsDone();return!this.isWidgetApplied()&&t&&r()?(this.clearWatcher(),this.callback("rebuild",e)):(!this.isWidgetApplied()||t&&r())&&(this.isWidgetApplied()||t)||(this.clearWatcher(),this.callback("remove",e),this.watch()),this}eventHandler(){let e=s();return[250,500].forEach(t=>setTimeout(()=>500===t&&s()===e?this:(e=s(),this.decisionHandler(!1)),t)),this}observerHandler(e){const t=e.some(({removedNodes:e})=>e&&e.length),o=e.some(({addedNodes:e})=>e&&e.length);return t||o?(this.decisionHandler(!0),this):this}watch(){if(e())return this;this.clearWatcher(),document.addEventListener(...this.eventListenerParams);const t=A("body",e=>{const o=[e,{childList:!0,subtree:!0}];this.observer.observe(...o),this.elementsWaiters=this.elementsWaiters.filter(e=>e!==t)});return this.elementsWaiters.push(t),this}clearWatcher(){return document.removeEventListener(...this.eventListenerParams),this.elementsWaiters.length&&(this.elementsWaiters.forEach(e=>e.clear()),this.elementsWaiters=[]),this.observer.disconnect(),this}}class B{constructor(){this.children=void 0,this.uniqueId=y(),this.widgetName=_(),this.prettyName=b(),this.recurrenceParams=v(),this.triggerParams=w(),this.recurrence=!!this.recurrenceParams&&new R(this.recurrenceParams,this.clearGivenClearables.bind(this)),this.trigger=!!this.triggerParams&&new P(this.triggerParams),this.pageWatcher=new O(this.recurrence,this.isWidgetApplied.bind(this),this.onPageChange.bind(this)),this.hasOncePerPageTrigger=f(),this.basicClassName=`ab_widget_container_${this.widgetName}`,this.widgetContainerId=`${this.basicClassName}_${this.uniqueId}`,this.contentClassName=`${this.basicClassName}_content`,this.overlayClassName=`${this.basicClassName}_overlay`,this.closeButtonClassName=`${this.basicClassName}_close_button`,this.hideClassName=`ab_hide_${this.uniqueId}`,this.domElement=this.getDom(),this.hasBeenShown=!1,this.closedByUser=!1,this.eventsListeners=[],this.timeouts=[],this.intervals=[],this.observers=[],this.promises=[],this.elementsWaiters=[]}clearGivenClearables(){this.eventsListeners.length&&(this.eventsListeners.forEach(e=>document.removeEventListener(...e)),this.eventsListeners=[]),this.timeouts.length&&(this.timeouts.forEach(e=>clearTimeout(e)),this.timeouts=[]),this.intervals.length&&(this.intervals.forEach(e=>clearInterval(e)),this.intervals=[]),this.observers.length&&(this.observers.forEach(e=>e.disconnect()),this.observers=[]),this.promises.length&&(this.promises.forEach(e=>e.resolve(!1)),this.promises=[]),this.elementsWaiters.length&&(this.elementsWaiters.forEach(e=>e.clear()),this.elementsWaiters=[])}isWidgetApplied(){return this.domElement&&!!this.domElement.closest("html")}removeOldDomElement(){const e=document.getElementById(this.widgetContainerId);return e&&e.remove(),this}async insert(){const e=(e,t,o)=>{this.elementsWaiters=this.elementsWaiters.filter(e=>e!==t),T(e),o(e)},t=new Promise((t,o)=>{const r=A("head",e=>{this.elementsWaiters=this.elementsWaiters.filter(e=>e!==r),t(e.appendChild(this.styleElement))},t=>e(t,r,o));this.elementsWaiters.push(r)}),o=new Promise((t,o)=>{const{layout:r,elementReferrer:i,referrerInsertType:s}=DATA,{selector:n,position:a}="string"==typeof r&&"free"===r&&"string"==typeof i&&"string"==typeof s?{selector:i,position:s}:{selector:"body",position:"beforeend"},l=A(n,e=>{this.elementsWaiters=this.elementsWaiters.filter(e=>e!==l),this.removeOldDomElement(),t(e.insertAdjacentElement(a,this.domElement))},t=>e(t,l,o));this.elementsWaiters.push(l)});return Promise.all([o,t]).then(()=>this)}remove(){return this.pageWatcher.clearWatcher(),this.domElement&&this.domElement.closest("html")&&this.domElement.remove(),this.styleElement&&this.styleElement.closest("html")&&this.styleElement.remove(),this.hasOncePerPageTrigger?this.pageWatcher.watch():e()||this.init().then(({response:e})=>e?this.show():this),this}show(){return this.hasBeenShown||e()||window.ABTastyEvent(`${this.prettyName} displayed`,null,TEST_ID),this.closedByUser=!1,this.domElement.classList.remove(this.hideClassName),this.recurrence&&this.recurrence.setDisplayRecurrence(),this.hasBeenShown=!0,this.pageWatcher.watch(),this}hide(){return this.hasBeenShown&&!e()&&window.ABTastyEvent(`${this.prettyName} closed`,null,TEST_ID),this.closedByUser=!0,this.domElement.classList.add(this.hideClassName),this}async init(t){if(!e()&&!s())return!1;if(this.trigger&&this.trigger.promises.length)return!1;const o=this.recurrence&&this.recurrence.isOver();if(this.recurrence&&!o)return this.pageWatcher.watch(),!1;this.pageWatcher.watch();const r=e()||!this.trigger||this.trigger&&await this.trigger.isTriggered();return!!r&&(await this.insert(),this.addCloseEvent(),e()||t||this.hasBeenShown||void 0===this.children||"function"!=typeof this.children.refreshContent||this.children.refreshContent(r),{container:this,response:r})}onPageChange(e,t){const o=()=>this.init().then(({response:e})=>e&&this.show());switch(t||(this.hasBeenShown=!1),e){case"remove":this.isWidgetApplied()?this.remove():(this.trigger&&this.trigger.clear(),this.pageWatcher.watch());break;case"rebuild":this.hasBeenShown?this.closedByUser?this.pageWatcher.watch():this.insert().then(e=>e.show()):o()}}addCloseEvent(...t){const{closeButton:o,overlayClickable:r,layout:i}=DATA,s=[];if(void 0!==r&&r&&void 0!==i&&"popin"===i&&s.push(`.${this.overlayClassName}`),void 0!==o&&o&&s.push(`.${this.closeButtonClassName}`),!s.length)return this;const n=this.domElement.querySelectorAll(s.join(", "));return n.length?(t.push(...n),t.forEach(t=>{e()&&(t.dataset.abtastyActionnable="true"),t.addEventListener("click",()=>{this.recurrence&&this.recurrence.setClosingRecurrence(),this.hide(),setTimeout(()=>this.remove(),1e3)},{passive:!0,once:!0})}),this):this}getDom(){const{closeButton:e,layout:t}=DATA,o=document.createElement("div");return o.className=`${this.basicClassName} ${this.hideClassName}`,o.id=this.widgetContainerId,o.innerHTML=`\n\t\t\t${void 0!==t&&"popin"===t?`<div class="${this.overlayClassName}"></div>`:""}\n\t\t\t<div class="${this.contentClassName}">\n\t\t\t\t${e?`<button class="${this.closeButtonClassName}"><svg viewBox="0 0 16 16">\n\t<defs><path id="prefix__a" d="M12 4.991L11.009 4 8 7.009 4.991 4 4 4.991 7.009 8 4 11.009 4.991 12 8 8.991 11.009 12 12 11.009 8.991 8z"></path></defs>\n\t<g><use xlink:href="#prefix__a"></use></g>\n</svg></button>`:""}\n\t\t\t</div>`,o}getStyleTag(t=""){const{noStyles:o,layout:r}=DATA,{backgroundColor:i,isBackgroundImage:s,backgroundImage:n,backgroundSize:a,backgroundPosition:l,backgroundRepeat:c,borderColor:g,borderRadius:d,borderWidth:p,textColor:m,textAlign:h,overlayColor:_,dropShadow:b,dropShadowColor:y,dropShadowBlur:v,containerMargin:w,containerPadding:f,closeButton:x,buttonsBorderWidth:T,buttonsBorderColor:S,buttonsBorderRadius:E,buttonsBackgroundColor:A,buttonsTextColor:C}=o?{}:DATA,I=document.createElement("style");I.type="text/css",e()&&I.setAttribute("abtasty-script-added","true");const N=["string"==typeof i?i:u,"string"==typeof n&&n.length?`url(${n})`:"","string"==typeof l&&"100% 100%"!==a?l:"0 0","string"==typeof a?`/ ${a}`:"/ auto",c&&!["cover","100% 100%"].includes(a)?"repeat":"no-repeat"],$=`background: ${s?N.join(" ").trim():u};`,R="number"==typeof p&&p>0,k=`border: ${[R?`${p}px`:"unset",R?"solid":"",R&&"string"==typeof g&&g.length?g:""].join(" ").trim()};`,P=void 0!==d?`border-radius: ${d}px;`:"",O=void 0!==m?`color: ${m}; fill: ${m};`:"",B=void 0!==h?`text-align: ${h};`:"",L=void 0!==b&&b?`box-shadow: 0 5px ${v}px 0 ${y};`:"",W=w instanceof Array&&1===w.length&&w[0],D=W?`margin: ${W.top}px ${W.right}px ${W.bottom}px ${W.left}px;`:"",U=W?`margin: calc(${W.top}px * 0.5) calc(${W.right}px * 0.5) calc(${W.bottom}px * 0.5) calc(${W.left}px * 0.5);`:"",F=f instanceof Array&&1===f.length&&f[0],V=F?`padding: ${F.top}px ${F.right}px ${F.bottom}px ${F.left}px;`:"",G=F?`padding: calc(${F.top}px * 0.5) calc(${F.right}px * 0.5) calc(${F.bottom}px * 0.5) calc(${F.left}px * 0.5);`:"",q=void 0!==T&&T?`border-width: ${T}px; border-style: solid;`:"",M=[S,T].every(e=>void 0!==e)&&T?`border-color: ${S};`:"",H=void 0!==E?`border-radius: ${E}px;`:"",j=void 0!==A?`background-color: ${A};`:"",Y=void 0!==C?`color: ${C};`:"",K=void 0!==r&&"popin"===r?[`#${this.widgetContainerId} .${this.overlayClassName} {`,`background-color: ${void 0!==_?_:"rgba(0, 0, 0, 0.6)"};`,"}"].join(""):"",z=o||void 0!==x&&x?[`#${this.widgetContainerId} .${this.contentClassName} .${this.closeButtonClassName} {`,"position: absolute;","top: 8px;","right: 8px;","width: auto;","height: auto;","background: none;","border: none;","cursor: pointer;","outline: none;","padding: 0;","margin: 0;","}",`#${this.widgetContainerId} .${this.contentClassName} .${this.closeButtonClassName} svg {`,"pointer-events: none;","width: 16px;","height: 16px;",O,"}"].join(""):"";return I.textContent=[`.${this.hideClassName} {`,"opacity: 0 !important;","pointer-events: none;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,$,P,k,O,B,L,D,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,"display: block;","line-height: 1;","text-indent: unset;",V,"}",`#${this.widgetContainerId} .${this.contentClassName} > * a, `,`#${this.widgetContainerId} .${this.contentClassName} > * button {`,q,M,H,j,Y,"}","@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,U,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,G,"}","}",K,z,`${t}`].join(""),I}}class L extends B{constructor(){super(),this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){return[`#${this.widgetContainerId} {`,"position: fixed;","top: 0;","left: 0;","width: 100%;","height: 100%;","z-index: 9999;","opacity: 1;","transition: opacity 0.25s ease;","}",`#${this.widgetContainerId} .${this.overlayClassName} {`,"position: absolute;","z-index: -1;","top: 0;","left: 0;","width: 100%;","height: 100%;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: absolute;","left: 50%;","top: 50%;","transform: translate(-50%, -50%);","width: auto;","height: auto;","}","@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,"max-width: 94vw;","}","}"].join("")}}class W extends B{constructor(){super(),this.position="string"==typeof DATA.layout&&"bannerTop"===DATA.layout?"top":"bottom",this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){return[`#${this.widgetContainerId} {`,"position: fixed;",`${this.position}: 0;`,"left: 0;","width: 100%;","height: auto;","z-index: 9999;","opacity: 1;","transition: opacity 0.25s ease;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: relative;","}"].join("")}}class D extends B{constructor(){super(),this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){return[`#${this.widgetContainerId} {`,"width: auto;","height: auto;","margin: 0;","padding: 0;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: relative;","}"].join("")}}const U=[{label:"widget_common_conditions_recurrence_option_everyTime",value:"everytime"},{label:"widget_common_conditions_recurrence_option_everySession",value:"session"},{label:"widget_common_conditions_recurrence_option_everyXDays",value:"day"},{label:"widget_common_conditions_recurrence_option_everyXWeeks",value:"week"},{label:"widget_common_conditions_recurrence_option_everyXMonths",value:"month"},{label:"widget_common_conditions_recurrence_option_once",value:"once"}],F={category:l,type:g,min:1},V=[{...F,propName:"day",label:"widget_common_conditions_recurrence_ifOptionVariable_labelDays",value:5,max:395},{...F,propName:"week",label:"widget_common_conditions_recurrence_ifOptionVariable_labelWeeks",value:2,max:56},{...F,propName:"month",label:"widget_common_conditions_recurrence_ifOptionVariable_labelMonths",value:1,max:13}],G={category:l,type:"select",options:U,value:"everytime"},q={...G,label:"widget_common_conditions_recurrence_label_widgetDisplayed",propName:"displayRecurrence"},M=V.map(e=>({...e,propName:`${q.propName}_${e.propName}`,conditions:[{field:q.propName,value:e.propName}]})),H={...G,label:"widget_common_conditions_recurrence_label_widgetDisplayedAfterClosure",propName:"closingRecurrence"},j=V.map(e=>({...e,propName:`${H.propName}_${e.propName}`,conditions:[{field:H.propName,value:e.propName}]})),Y={...G,label:"widget_common_conditions_recurrence_label_widgetDisplayedAfterSubmission",propName:"validationRecurrence"},K=V.map(e=>({...e,propName:`${Y.propName}_${e.propName}`,conditions:[{field:Y.propName,value:e.propName}]})),z={category:l,type:d,label:"widget_common_conditions_recurrence_blockTitle",collapsible:!0,children:[q,...M,H,...j,Y,...K]},X={category:l,type:g,propName:"triggerEventDelay",label:"widget_common_conditions_triggering_delay_label",min:0,max:60,value:0},J={...X,propName:"triggerEventReengageDelay",value:10,max:180},Q={category:l,type:"selectelement",propName:"triggerEventClick",value:"body"},Z={...Q,propName:"triggerEventElementVisible"},ee={category:l,type:"textarea",label:"widget_common_conditions_triggering_option_customTrigger",propName:"triggerEventCustomScript",value:"/* In this example snippet, the widget will be triggered as soon as any scroll is detected.\nCreate your own by resolving resolve() with true (which does trigger) or false (which doesn't trigger) */\n\nfunction launchIfScroll() {\n\treturn new Promise(resolve => {\n\t\tdocument.addEventListener('scroll', () => resolve(true), {once: true});\n\t});\n}\n\nconst result = await launchIfScroll();\nreturn resolve(result);",rows:15},te={pageLoad:{label:"widget_common_conditions_triggering_option_pageload",value:"pageLoad"},direct:{label:"widget_common_conditions_triggering_option_asap",value:"direct"},exitIntent:{label:"widget_common_conditions_triggering_option_exitIntent",value:"exitIntent"},reengage:{label:"widget_common_conditions_triggering_option_afterXSecondsOfInactivity",value:"reengage"},click:{label:"widget_common_conditions_triggering_option_click",value:"click"},elementVisible:{label:"widget_common_conditions_triggering_option_elementVisible",value:"elementVisible"},customScript:{label:"widget_common_conditions_triggering_option_customTrigger",value:"script"}},oe={category:l,type:c,propName:"isOncePerPageTrigger",value:!0,label:"widget_common_conditions_triggering_label_triggerOnlyOnce"},re={category:l,type:c,propName:"autoHide",value:!0,label:"widget_common_conditions_triggering_autohide_toggler_label_autoHideAfterRedirection"},ie={category:l,type:g,propName:"timeHide",value:2,max:120,label:"widget_common_conditions_triggering_autohide_toggler_label_autoHideAfterXSeconds",conditions:[{field:"autoHide",value:!0}]},se={category:l,type:"select",label:"widget_common_conditions_triggering_label",options:Object.keys(te).map(e=>te[e]),propName:"triggerEvent",value:"pageLoad"};Q.conditions=[{field:"triggerEvent",value:"click"}],J.conditions=[{field:"triggerEvent",value:"reengage"}],Z.conditions=[{field:"triggerEvent",value:"elementVisible"}],ee.conditions=[{field:"triggerEvent",value:"script"}],X.conditions=[{field:"triggerEvent",value:e=>"reengage"!==e}],oe.conditions=[{field:"triggerEvent",value:e=>"click"===e||"script"===e}];const ne=[Q,Z,ee,oe,J,X],ae={category:l,type:d,label:"widget_common_conditions_triggering_blockTitle",collapsible:!0,children:[se,...ne]};const le={category:"content",propName:"button",type:c,value:!1,label:"widget_common_content_toggler_label_displayButton"},ce={category:"content",propName:"buttonText",type:"text",label:"widget_common_content_label_buttonText",value:"widget_common_content_buttonText_default"},ge={category:"content",propName:"buttonLink",type:"text",label:"widget_common_content_label_buttonUrl",value:location.origin,conditions:[{field:"button"}]},de={category:"content",propName:"buttonTargetType",type:c,label:"widget_common_content_button_label_openLinkNewTab",value:!1,conditions:[{field:"button"}]},pe=[{field:"button"}];ce.conditions=pe,ge.conditions=pe,de.conditions=pe;const ue={category:"content",type:d,label:"widget_common_tabName_content",collapsible:!1,children:[le,ce,ge,de]},me={category:"layout",type:"radioImage",propName:"layout",label:"widget_common_layout_label_selectALayout",value:"popin",style:"big",options:[{label:"widget_common_layout_option_modal",value:"popin",src:`${p}layout/icon-layout-modal.png`},{label:"widget_common_layout_option_topBanner",value:"bannerTop",src:`${p}layout/icon-layout-topBanner.png`},{label:"widget_common_layout_option_bottomBanner",value:"bannerBottom",src:`${p}layout/icon-layout-bottomBanner.png`},{label:"widget_common_layout_option_freePlacement",value:"free",src:`${p}layout/icon-layout-freePlacement.png`}]},he={category:"layout",type:"selectelement",propName:"elementReferrer",label:"widget_common_layout_label_selectElementContainWidget",value:"body"},_e={category:"layout",type:"radio",propName:"referrerInsertType",value:"afterbegin",label:"widget_common_layout_positioning_label_selectPosition",options:[{label:"widget_common_layout_positioning_option_before",value:"beforebegin"},{label:"widget_common_layout_positioning_option_atTheBeginning",value:"afterbegin"},{label:"widget_common_layout_positioning_option_atTheEnd",value:"beforeend"},{label:"widget_common_layout_positioning_option_after",value:"afterend"}]},be=[{field:"layout",value:"free"}];he.conditions=be,_e.conditions=be;const ye={category:"layout",type:d,label:"widget_common_tabName_layout",collapsible:!0,children:[me,he,_e]},ve={category:a,type:"colorpicker",label:"widget_common_style_container_label_backgroundColor",propName:"backgroundColor",value:m},we={category:a,type:c,label:"widget_common_style_toggler_label_backgroundImage",propName:"isBackgroundImage",value:!1},fe={category:a,type:"mediaupload",label:"widget_common_style_toggler_label_backgroundImage",propName:"backgroundImage",value:""},xe={category:a,type:"radio",label:"widget_common_style_backgroundImageUploader_imageOptions_label",propName:"backgroundSize",value:"cover",options:[{label:"widget_common_style_backgroundImageUploader_imageOptions_option_cover",value:"cover"},{label:"widget_common_style_backgroundImageUploader_imageOptions_option_contain",value:"contain"},{label:"widget_common_style_backgroundImageUploader_imageOptions_option_fill",value:"100% 100%"},{label:"widget_common_style_backgroundImageUploader_imageOptions_option_none",value:"auto"}]},Te={category:a,type:"select",label:"widget_common_style_backgroundImageUploader_imagePosition_select_label",propName:"backgroundPosition",value:"center",options:[{label:"widget_common_style_backgroundImageUploader_imagePosition_option_top",value:"top"},{label:"widget_common_style_backgroundImageUploader_imagePosition_option_bottom",value:"bottom"},{label:"widget_common_style_backgroundImageUploader_imagePosition_option_center",value:"center"},{label:"widget_common_style_backgroundImageUploader_imagePosition_option_left",value:"left"},{label:"widget_common_style_backgroundImageUploader_imagePosition_option_right",value:"right"},{label:"widget_common_style_backgroundImageUploader_imagePosition_option_topLeft",value:"top left"},{label:"widget_common_style_backgroundImageUploader_imagePosition_option_topRight",value:"top right"},{label:"widget_common_style_backgroundImageUploader_imagePosition_option_bottomLeft",value:"bottom left"},{label:"widget_common_style_backgroundImageUploader_imagePosition_option_bottomRight",value:"bottom right"}]},Se={category:a,type:c,label:"widget_common_style_backgroundImageUploader_toggler_repeatBackgroundImage",propName:"backgroundRepeat",value:!1},Ee={category:a,type:"colorpicker",label:"widget_common_style_border_label_borderColor",propName:"borderColor",value:"rgba(0, 127, 145, 1)"},Ae={category:a,type:g,label:"widget_common_style_border_label_borderRadius",propName:"borderRadius",value:4,unit:"px"},Ce={category:a,type:g,label:"widget_common_style_border_label_borderThickness",propName:"borderWidth",value:2,min:0,max:50,unit:"px"},Ie={category:a,type:"colorpicker",label:"widget_common_style_text_label_textColor",propName:"textColor",value:"rgba(57, 57, 57, 1)"},Ne={category:a,type:"radioImage",label:"widget_common_style_text_label_textAlignment",propName:"textAlign",value:"center",style:"little",options:[{label:"widget_common_style_text_textAlignment_option_left",value:"left",src:`${p}style/icon-text-alignLeft.png`},{label:"widget_common_style_text_textAlignment_option_center",value:"center",src:`${p}style/icon-text-alignCenter.png`},{label:"widget_common_style_text_textAlignment_option_right",value:"right",src:`${p}style/icon-text-alignRight.png`}]},$e={category:a,type:"areainput"},Re={...$e,label:"widget_common_style_container_label_margin",propName:"containerMargin",value:[{top:0,left:0,bottom:0,right:0}]},ke={...$e,label:"widget_common_style_container_label_padding",propName:"containerPadding",value:[{top:35,left:60,bottom:35,right:60}]},Pe={category:a,type:c,label:"widget_common_style_container_dropShadow_blockTitle",propName:"dropShadow",value:!1},Oe={category:a,type:"colorpicker",label:"widget_common_style_container_dropShadow_label_color",propName:"dropShadowColor",value:"rgba(57, 57, 57, 0.25);"},Be={category:a,type:g,label:"widget_common_style_container_dropShadow_label_blurRadius",propName:"dropShadowBlur",value:10,unit:"px"},Le={category:a,type:c,label:"widget_common_style_container_label_displayCloseButton",propName:"closeButton",value:!0},We={category:a,type:"colorpicker",label:"widget_common_style_overlay_label_overlayColor",propName:"overlayColor",value:"rgba(0, 0, 0, 0.6)"},De={category:a,type:c,label:"widget_common_style_overlay_label_overlayClickable",propName:"overlayClickable",value:!0},Ue={category:a,type:g,label:"widget_common_style_buttons_label_buttonBorderThickness",propName:"buttonsBorderWidth",value:1,min:0,max:30,unit:"px"},Fe={category:a,type:"colorpicker",label:"widget_common_style_buttons_label_buttonBorderColor",propName:"buttonsBorderColor",value:"rgba(87, 184, 199, 1)"},Ve={category:a,type:g,label:"widget_common_style_buttons_label_buttonBorderRadius",propName:"buttonsBorderRadius",value:4,min:0,max:30,unit:"px"},Ge={category:a,type:"colorpicker",label:"widget_common_style_buttons_label_buttonBackgroundColor",propName:"buttonsBackgroundColor",value:"rgba(0, 127, 145, 1)"},qe={category:a,type:"colorpicker",label:"widget_common_style_buttons_label_buttonTextColor",propName:"buttonsTextColor",value:m},Me={field:we.propName,value:!0},He={field:xe.propName,value:e=>"cover"!==e},je={field:xe.propName,value:e=>"100% 100%"!==e};fe.conditions=[Me],xe.conditions=[Me],Te.conditions=[Me,je],Se.conditions=[Me,je,He];const Ye=[ve,we,fe,xe,Te,Se],Ke={category:a,type:d,label:"widget_stickyElement_content_positionOn_option_background",collapsible:!0,children:Ye},ze=[{field:Ce.propName,value:e=>e>0}];Ee.conditions=ze;const Xe={category:a,type:d,label:"widget_common_style_blockTitle_border",collapsible:!0,children:[Ce,Ee,Ae]},Je={category:a,type:d,label:"widget_common_style_blockTitle_text",collapsible:!0,children:[Ne,Ie]},Qe=[{field:"dropShadow",value:!0}];Oe.conditions=Qe,Be.conditions=Qe;const Ze={category:a,type:d,label:"widget_common_style_blockTitle_container",collapsible:!0,children:[Re,ke,...Ye,Pe,Oe,Be,Le]},et={category:a,type:d,label:"widget_common_style_blockTitle_overlay",collapsible:!0,children:[We,De],conditions:[{field:"layout",value:"popin"}]},tt=[{field:Ue.propName,value:e=>e>0}];Fe.conditions=tt;const ot={category:a,type:d,label:"widget_common_style_blockTitle_buttons",collapsible:!0,children:[Ue,Fe,Ve,Ge,qe]};exports.ABTASTY_IMAGES_ROUTE=p,exports.AREAINPUT="areainput",exports.BLACK="rgba(0, 0, 0, 1)",exports.Banner=W,exports.CHECKBOX="checkbox",exports.COLOR_PICKER="colorpicker",exports.CONDITIONS=l,exports.CONTENT="content",exports.DARK_GRAY="rgba(57, 57, 57, 1)",exports.DARK_TURQUOISE="rgba(0, 127, 145, 1)",exports.DATE_PICKER="datepicker",exports.DATE_RANGE_PICKER="dateRangePicker",exports.Free=D,exports.GROUP=d,exports.HIDDEN="hidden",exports.INLINE_NOTIFICATION="inlinenotification",exports.LAYOUT="layout",exports.LIGHT_GREY=m,exports.LIGHT_TURQUOISE="rgba(87, 184, 199, 1)",exports.MEDIA_UPLOAD="mediaupload",exports.NUMBER="number",exports.PARAGRAPH="paragraph",exports.PageWatcher=O,exports.Popin=L,exports.RADIO_BUTTON="radio",exports.RADIO_IMAGE="radioImage",exports.REBUILD_WIDGET="rebuild",exports.REMOVE_WIDGET="remove",exports.Recurrence=R,exports.SELECT="select",exports.SELECT_ELEMENT="selectelement",exports.SEPARATOR="separator",exports.SHORT_SEPARATOR="short-separator",exports.SLIDER=g,exports.SOCIAL_PROOF_API_BASE=h,exports.STYLE=a,exports.SWITCH=c,exports.TAG_RESET_EVENT="abtasty_resetActionTracking",exports.TASTY_GREEN="rgba(28, 191, 151, 1)",exports.TASTY_RED="rgba(213, 64, 64, 1)",exports.TASTY_YELLOW="rgba(224, 185, 10, 1)",exports.TEXT_AREA="textarea",exports.TEXT_FIELD="text",exports.TIME_PICKER="timepicker",exports.Trigger=P,exports.URL_FIELD="url",exports.VARIABLES_INPUT="variablesinput",exports.WHITE=u,exports.WYSIWYG="wysiwyg",exports.WidgetContainer=B,exports.addGlobalUtil=t,exports.addPolyfill=$,exports.allowGlobalScroll=function(){A("body",()=>{const{body:e}=document;I&&(e.style.overflowY=I)},e=>x(e))},exports.asyncRequest=function(e,t){return new Promise((o,r)=>{const i=new XMLHttpRequest;i.open(e,t,!0),i.onload=function(){this.status>=200&&this.status<300?o(i.response):r({status:this.status,statusText:i.statusText})},i.onerror=function(){r({status:this.status,statusText:i.statusText})},i.send()})},exports.autoHideForm=re,exports.backgroundColorForm=ve,exports.backgroundImageForm=fe,exports.backgroundsGroup=Ke,exports.backgroundsGroupChildren=Ye,exports.borderColorForm=Ee,exports.borderRadiusForm=Ae,exports.borderWidthForm=Ce,exports.bordersGroup=Xe,exports.buttonLinkForm=ge,exports.buttonLinkGroup=ue,exports.buttonTargetTypeForm=de,exports.buttonTextForm=ce,exports.buttonsBackgroundColorForm=Ge,exports.buttonsBorderColorForm=Fe,exports.buttonsBorderRadiusForm=Ve,exports.buttonsBorderWidthForm=Ue,exports.buttonsGroup=ot,exports.buttonsTextColorForm=qe,exports.closingRecurrenceForm=H,exports.containerGroup=Ze,exports.displayCloseButtonSwitchForm=Le,exports.displayRecurrenceForm=q,exports.dropShadowBlurForm=Be,exports.dropShadowColorForm=Oe,exports.dropShadowSwitchForm=Pe,exports.elementReferrerForm=he,exports.findParent=C,exports.getAccountIdentifier=o,exports.getCookie=e=>{const t=`${e}=`,o=document.cookie.split(";");for(let e=0;e<o.length;e+=1){let r=o[e];for(;" "===r.charAt(0);)r=r.substring(1);if(0===r.indexOf(t))return r.substring(t.length,r.length)}return""},exports.getCustomTriggersGroup=function(e){const t=e.reduce((e,t)=>[...e,te[t]],[]),o=ne.reduce((t,o)=>{const{conditions:r}=o;return r&&r.some(({value:t})=>e.includes(t))?[...t,o]:t},[]),r={...se,options:t,value:e[0]};return{category:l,type:d,label:"widget_common_conditions_triggering_blockTitle",collapsible:!0,children:[r,...o]}},exports.getGroupSettedValues=(e,t)=>{if("object"!=typeof t)return e;const{type:o,children:r}=e,i=Object.keys(t);if(!i.length)return e;if("object"!=typeof e||!o||"group"!==o||!r||!Array.isArray(r)||Array.isArray(r)&&!r.length)return{};const s=r.map(e=>{const{propName:o,value:r}=e;return i.includes(o)&&typeof r==typeof t[o]?{...e,value:t[o]}:e});return{...e,children:s}},exports.getHostname=S,exports.getPrettyWidgetName=b,exports.getProductKey=i,exports.getRecurrenceParams=v,exports.getTriggerParams=w,exports.getUniqueId=y,exports.getVisitorId=()=>window.ABTasty&&window.ABTasty.visitor?window.ABTasty.visitor.id:void 0,exports.getWidgetContainer=()=>{const{layout:e}=DATA;let t;switch(e){case"popin":t=new L;break;case"bannerTop":case"bannerBottom":t=new W;break;case"free":t=new D;break;default:t=new B}return t},exports.getWidgetName=_,exports.isAffected=s,exports.isBackgroundImageForm=we,exports.isInQaMode=n,exports.isOnEditor=e,exports.isOnPreview=r,exports.isTouch=()=>void 0!==window.ontouchstart,exports.isTriggerOncePerPage=f,exports.layoutGroup=ye,exports.layoutsForm=me,exports.loadImage=e=>new Promise((t,o)=>{const r=new Image;r.onload=()=>{t(r)},r.src=e,r.onerror=()=>{const t=new Error(`Image ${e} is not loaded.`);return o(t)}}),exports.loadJS=N,exports.log=x,exports.marginForm=Re,exports.olverlayCloseOnClickForm=De,exports.overlayColorForm=We,exports.overlayGroup=et,exports.paddingForm=ke,exports.preventGlobalScroll=function(){A("body",()=>{const{body:e}=document;I=window.getComputedStyle(e).overflowY,e.style.overflowY="hidden"},e=>x(e))},exports.promiseDeferrer=E,exports.recurrencesGroup=z,exports.referrerInsertTypeForm=_e,exports.setCookie=(e,t,o)=>{let r="";if(o){const e=new Date;e.setTime(e.getTime()+24*o*60*60*1e3),r=`expires=${e.toUTCString()}`}const i=`domain=${S()}`;document.cookie=`${e}=${t}; ${r};${i};path=/`},exports.switchButtonForm=le,exports.syncRequest=function(e,t){const o=new XMLHttpRequest;return o.open(e,t,!1),o.send(null),o},exports.textAlignmentForm=Ne,exports.textColorForm=Ie,exports.textGroup=Je,exports.timeHideForm=ie,exports.triggerDelay=X,exports.triggerEventCustomScript=ee,exports.triggerEventElementVisible=Z,exports.triggerEventReengageDelay=J,exports.triggerOncePerPage=oe,exports.triggersForm=se,exports.triggersGroup=ae,exports.triggersOptions=te,exports.validationRecurrenceForm=Y,exports.waitForElement=A,exports.widgetLog=T; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=()=>Object.prototype.hasOwnProperty.call(window,"ABTastyEditor");function t(e,t){return ABTasty.widgetUtils||(ABTasty.widgetUtils={}),ABTasty.widgetUtils[e]||Object.assign(ABTasty.widgetUtils,{[e]:new t}),ABTasty.widgetUtils[e]}const o=()=>{let e;return window.ABTasty||window.ABTASTY_S?(window.ABTASTY_S&&window.ABTASTY_S.USER&&window.ABTASTY_S.USER.accountIdentifier&&window.ABTASTY_S.USER.accountIdentifier.length?e=window.ABTASTY_S.USER.accountIdentifier:window.ABTasty&&window.ABTasty.getAccountSettings&&"function"==typeof window.ABTasty.getAccountSettings?e=window.ABTasty.getAccountSettings().identifier:window.ABTasty&&window.ABTasty.accountSettings&&(e=window.ABTasty.accountSettings.identifier),e):e},r=()=>{const e=!!document.getElementById("ABTastyPreviewBar"),t=location.href.includes("ab_project=preview");return e||t},i=()=>window.ABTastyProductKey,s=()=>!!window.ABTasty.getTestsOnPage()[TEST_ID]||r(),n=()=>{if(e())return!1;const t=ABTasty.getTestsOnPage()[TEST_ID];return!!t&&Object.keys(t.targetings.qaParameters).length>0},a="style",l="conditions",c="switch",g="slider",d="group",p="https://widgets-images.abtasty.com/",u="rgba(255, 255, 255, 1)",m="rgba(247, 247, 247, 1)",h="https://social-proof-api.abtasty.com/clients/",_=()=>{const{type:e}=DATA;return`${PACKAGE.replace("@abtasty/","")}${e?`_${e}`:""}`},b=()=>{const e=_();return`${e.charAt(0).toUpperCase()}${e.slice(1)}`.split("-").join(" ")},y=()=>`${PLUGIN_ID.split("-")[0]}_${TEST_ID}`,v=()=>{const{displayRecurrence:t,closingRecurrence:o,validationRecurrence:r}=DATA;if(e()||!t&&!o&&!r)return!1;const i={everytime:()=>-1,session:()=>0,once:()=>395,day:e=>DATA[`${e}_day`],week:e=>7*DATA[`${e}_week`],month:e=>30.5*DATA[`${e}_month`]},s={};return t&&(s.displayRecurrence=i[t]("displayRecurrence")),o&&(s.closingRecurrence=i[o]("closingRecurrence")),r&&(s.validationRecurrence=i[r]("validationRecurrence")),s},w=()=>{let{triggerEvent:t}=DATA;const{triggerEventClick:o,triggerEventReengageDelay:r,socialProofContentType:i,triggerEventElementVisible:s,triggerEventDelay:n}=DATA;if(e()||!t&&!i)return!1;const a={click:()=>o,elementVisible:()=>s},l=Object.prototype.hasOwnProperty.call(a,t)?a[t]():"body",c="reengage"===t?r:n;return i&&(t=1===i?"socialProofPurchases":"socialProofPageViews"),{triggerEvent:t,triggerSelector:l,triggerDelay:c}},f=()=>{const{isOncePerPageTrigger:e,triggerEvent:t}=DATA;return!(!e||!["click","script"].includes(t))||["pageLoad","direct","reengage","socialProofPurchases","socialProofPageViews","elementVisible"].some(e=>e===t)},x=(...e)=>{e.unshift(`[AB Tasty Widget] ${PACKAGE}:`),console.log(...e)},T=e=>{if(n()){const t=b();window.console.log(`%c${t} - QA Mode for campaign ${TEST_ID}\n${e}`,`background-color: rgba(0, 127, 145, 1); color: ${m}`)}},S=()=>{let e=document.location.hostname.split("").reverse().join("");if(e=e.match(/(?:[a-z]{2,4}\.[a-z]{2,3}|[a-z]{2,5})\.[a-z0-9-]+(?:\.|$)/i),null===e)e=document.location.hostname;else{"."!==e[0].substr(e[0].length-1)&&(e[0]+="."),e=e[0].split("").reverse().join("")}return e},E=e=>{const t={promise:null,resolve:null,reject:null,name:e};return t.promise=new Promise((e,o)=>{t.resolve=e,t.reject=o}),t},A=(e,t,o)=>{let r=0,i=0;try{document.querySelector(e)}catch(t){const r=`Selector «${e}» not valid.`;return x(r),"function"==typeof o&&o(r)}function s(){clearInterval(i),clearTimeout(r)}return r=setTimeout(()=>{s();const t=`Can't find element «${e}».`;return x(t),"function"==typeof o&&o(t)},1e4),i=setInterval(()=>{const o=document.querySelector(e);return null!==o?(s(),"function"==typeof t&&t(o)):o},200),{clear:s}};function C(e,t){return t(e)||!e.parentElement?e:C(e.parentElement,t)}let I;function N(e){return new Promise((t,o)=>{const r=window.document.getElementsByTagName("script")[0],i=window.document.createElement("script");i.src=e,r.parentNode.insertBefore(i,r),i.onload=t,i.onerror=o})}async function $(e){let t;switch(e){case"IntersectionObserver":t=await("IntersectionObserver"in window&&"IntersectionObserverEntry"in window&&"intersectionRatio"in window.IntersectionObserverEntry.prototype||N("https://polyfill.io/v3/polyfill.min.js?flags=gated&features=IntersectionObserver"));break;default:t=!0}return t}class R{constructor({displayRecurrence:e,closingRecurrence:t,validationRecurrence:o},r){this.displayRecurrence=parseFloat(e),this.closingRecurrence=parseFloat(t),this.validationRecurrence=parseFloat(o),this.onSetCallback=r,this.widgetName=_(),this.uniqueId=y(),this.recurrenceKey=`${this.widgetName}_${this.uniqueId}`}getGivenRecurrenceStorageParsed(e){try{const t=e.getItem("ABTastyWidgets");return JSON.parse(t)}catch(t){return e.removeItem("ABTastyWidgets"),!1}}getSessionRecurrenceStorageParsed(){return this.getGivenRecurrenceStorageParsed(window.sessionStorage)}getLocalRecurrenceStorageParsed(){return this.getGivenRecurrenceStorageParsed(window.localStorage)}removeGivenStorage(e,t){const{[this.recurrenceKey]:o,...r}=t;return Object.entries(r).length?(e.setItem("ABTastyWidgets",JSON.stringify(r)),r):(e.removeItem("ABTastyWidgets"),!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(){const e=this.getSessionRecurrence(),t=this.getLocalRecurrence();return e||t||{type:!1}}isOver(){const e=this.getLocalRecurrence(),t=(e?parseFloat(e.stamp):0)<(new Date).getTime();return t&&this.removeLocalRecurrenceStorage(),t&&!this.getLocalRecurrence()&&!this.getSessionRecurrence()}setRecurrence(e,t){const o=this.getTypeOfStorage(e);if(r()||!o&&"object"!=typeof o)return!1;const{storageString:i,storageMethod:s}=o,n=this.getStamp(e),a={type:t,stamp:n},{type:l}=this.getCurrentRecurrence(),c=()=>{const e=this.getSessionRecurrence(),t=this.getLocalRecurrence();let o;"session"===i?e?o=this.removeSessionRecurrenceStorage():(this.removeLocalRecurrenceStorage(),o=this.getSessionRecurrenceStorageParsed()):"local"===i&&(t?o=this.removeLocalRecurrenceStorage():(this.removeSessionRecurrenceStorage(),o=this.getLocalRecurrenceStorageParsed()));const r=o?{[this.recurrenceKey]:a,...o}:{[this.recurrenceKey]:a};s.setItem("ABTastyWidgets",JSON.stringify(r)),this.onSetCallback&&"function"==typeof this.onSetCallback&&this.onSetCallback()};if(!s)return!1;if(l&&"validation"!==t)if("closing"===t&&"validation"!==l)c();else{if("display"!==t||"validation"===l||"closing"===l)return!1;c()}else c();return n}setDisplayRecurrence(){this.setRecurrence(this.displayRecurrence,"display")}setClosingRecurrence(){this.setRecurrence(this.closingRecurrence,"closing")}setValidationRecurrence(){this.setRecurrence(this.validationRecurrence,"validation")}getStamp(e){return(new Date).getTime()+864e5*e}getTypeOfStorage(e){return!(isNaN(e)||e<0||0!==e&&!e)&&(e>0?{storageString:"local",storageMethod:window.localStorage}:0===e&&{storageString:"session",storageMethod:window.sessionStorage})}}class k{constructor(){this.targets=[],this.existingTargets=[],this.inViewportTargets=[],this.visibilityObserver=this.startVisibilityObserver(),this.mutationObserver=this.startMutationObserver(),this.mouseOverEvent=this.mouseOverHandler()}intersectionHandler(e){e.forEach(e=>{e.isIntersecting?(this.existingTargets.forEach(t=>{t.element.isSameNode(e.target)&&(this.inViewportTargets.push(t),this.mouseOverEvent.start())}),this.checkElements()):this.inViewportTargets=this.inViewportTargets.filter(t=>!t.element.isSameNode(e.target)||(this.mouseOverEvent.clear(),!1))})}startVisibilityObserver(){return new IntersectionObserver(this.intersectionHandler.bind(this),{root:null,rootMargin:"0px",threshold:0})}startMutationObserver(){const e=this.mutationObserver||new MutationObserver(this.checkElements.bind(this));return document.body&&e.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),e}onMouseOver({target:e,path:t}){const o=this.inViewportTargets.find(({element:o,selector:r})=>{if(o.isSameNode(e))return!0;const i=[...e.querySelectorAll(r)];if(i.length){if(i.includes(o))return!0}if(t.includes(o))return!0;const s=[...e.parentElement.children],n=s.findIndex(t=>t.isSameNode(e)),a=s.filter((e,t)=>t>n);if(a.length){if(a.includes(o))return!0;if(a.some(e=>[...e.querySelectorAll(r)].includes(o)))return!0}return!1});if(o&&this.isElementVisible(o.element)){const{selector:e,element:t,uniqueId:r}=o,i=this.targets.find(t=>t.selector===e&&t.uniqueId===r);i&&i.resolve(t),this.clear(e,r)}}mouseOverHandler(){const e=["mouseover",e=>setTimeout(()=>this.onMouseOver(e),50),!0];return{start:()=>document.addEventListener(...e),clear:()=>document.removeEventListener(...e)}}isElementVisible(e){return this.isElementTopmost(e)&&this.isElementOpaque(e)}isElementOpaque(e){return"HTML"===C(e,e=>"0"===window.getComputedStyle(e).opacity).nodeName}isElementTopmost(e){const t=e.getBoundingClientRect(),o=[[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 r=!1,i=0;for(;!r&&i<o.length;){const t=document.elementFromPoint(...o[i]);r=e===t||e.contains(t),i+=1}return r}checkElements(){this.targets.forEach(({selector:e,uniqueId:t})=>{const o=document.querySelector(e);o&&!this.existingTargets.find(o=>o.element.matches(e)&&o.uniqueId===t)&&(this.existingTargets.push({element:o,selector:e,uniqueId:t}),this.visibilityObserver.observe(o))}),this.existingTargets=this.existingTargets.filter(({selector:e,element:t})=>!!document.querySelector(e)||(this.visibilityObserver.unobserve(t),!1)),this.inViewportTargets=this.inViewportTargets.filter(({selector:e,element:t,uniqueId:o})=>{if(t.matches(e)&&this.isElementVisible(t)){const r=this.targets.find(t=>t.selector===e&&t.uniqueId===o);return r&&r.resolve(t),this.clear(e,o),!1}return!0})}watch(e,t,o){this.targets.push({selector:e,resolve:t,uniqueId:o});const r=()=>{this.startMutationObserver(),this.checkElements()};document.body?r():A("body",r)}clear(e,t){[this.targets,this.existingTargets,this.inViewportTargets]=[this.targets,this.existingTargets,this.inViewportTargets].map(o=>o.filter(({selector:o,uniqueId:r})=>o!==e&&r!==t)),this.visibilityObserver.unobserve(document.querySelector(e)),0===this.targets.length&&this.mutationObserver.disconnect(),0===this.inViewportTargets.length&&this.mouseOverEvent.clear()}}class P{constructor({triggerEvent:e,triggerSelector:t,triggerDelay:o}){this.event=e,this.selector=t&&t.length?t:"body",this.delay=1e3*o,this.elementsSelectors=[],this.eventsListeners=[],this.timeouts=[],this.intervals=[],this.observers=[],this.promises=[],this.visibilityObservers=[],this.elementsWaiters=[]}async onElementVisible({promise:e,resolve:o}){const r=E(`${this.event}DomReady`);this.promises.push(r);const i=await this.onPageLoad(r),s=await $("IntersectionObserver"),n=t("VisibilityObserver",k);if(this.visibilityObservers.push(n),s&&i){const e=y();n.watch(this.selector,o,e)}return e}onPageLoad({promise:e,resolve:t}){const o=()=>"complete"===document.readyState;if(!o()){const r=["readystatechange",()=>o()&&t(!0),{passive:!0}];return this.eventsListeners.push(r),document.addEventListener(...r),e}return t(!0),e}onClick({promise:e,resolve:t}){const o=document.createElement("style");o.type="text/css",o.id=`Click_${y()}`,o.innerHTML=`${this.selector} {\n\t\t\tcursor: pointer !important;\n\t\t\tpointer-events: all !important;\n\t\t}`,document.head.appendChild(o),this.elementsSelectors.push(`#${o.id}`);const r=e=>[...document.querySelectorAll(this.selector)].some(t=>t.isSameNode(e)||!!e.closest(this.selector)),i=["click",({target:e})=>r(e)&&t(!0),{passive:!0,capture:!0}];return this.eventsListeners.push(i),document.addEventListener(...i),e}onExitIntent({promise:e,resolve:t}){const o=["mouseleave",async({clientY:e})=>{e<=0&&t(!0)},{passive:!0}],r=A("body",e=>{e.addEventListener(...o),this.eventsListeners.push([e,...o]),this.elementsWaiters=this.elementsWaiters.filter(e=>e!==r)});return this.elementsWaiters.push(r),e}onReengage({promise:e,resolve:t}){const o=this.delay;let r=o;const i=[()=>(r=o,r),{passive:!0}];["click","mousemove","scroll","keypress"].forEach(e=>{document.addEventListener(e,...i),this.eventsListeners.push([e,...i])});const s=setInterval(()=>{r<=0?t(!0):r-=100},100);return this.intervals.push(s),e}onCustomTrigger({promise:e,resolve:t}){const{triggerEventCustomScript:o}=DATA;return new Function(`return new Promise(async resolve => {${o}})`)().then(e=>e&&t(!0)),e}getSocialProofPurchases({promise:e,resolve:t}){const r=i(),s=o(),{viewInterval:n,triggerSocialProofMinPurchases:a,spNoTrim:l}=DATA;if(r||(T("Not able to find ABTastyProductKey, impossible to call the API."),t(!1)),r&&s){fetch(`${h}${s}/metrics/i?key=${r}${l?"&noTrim=true":""}`).then(e=>e.ok&&e.json()).then(e=>(e=>{if(void 0===n||void 0===a)return!1;const t=e[n]&&e[n]>=a;return t||T(`Widget will not be shown, product has been purchased ${e[n]} times while ${a} are required`),t})(e)&&t(e[n])).catch(()=>T("Failed to fetch datas from server."))}else t(!1);return e}getSocialProofPageViews({promise:e,resolve:t}){const r=encodeURIComponent(`${window.location.pathname}`),i=o(),{viewInterval:s,triggerSocialProofMinPageViews:n}=DATA;if(r&&i){fetch(`${h}${i}/metrics/pv?key=${r}`).then(e=>e.ok&&e.json()).then(e=>(e=>{if(void 0===s||void 0===n)return!1;const t=e[s]&&e[s]>=n;return t||T(`Widget will not be shown, page has been seen ${e[s]} times while ${n} are required`),t})(e)&&t(e[s])).catch(()=>T("Failed to fetch datas from server."))}else t(!1);return 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,...o]="string"==typeof e[0]?[document,...e]:e;t&&o.length>1&&t.removeEventListener(...o)}),this.eventsListeners=[]),this.timeouts.length&&(this.timeouts.forEach(e=>clearTimeout(e)),this.timeouts=[]),this.intervals.length&&(this.intervals.forEach(e=>clearInterval(e)),this.intervals=[]),this.observers.length&&(this.observers.forEach(e=>e.disconnect()),this.observers=[]),this.visibilityObservers.length){const e=y();this.visibilityObservers.forEach(t=>t.clear(this.selector,e)),this.visibilityObservers=[]}return this.promises.length&&(this.promises.forEach(e=>e.resolve(!1)),this.promises=[]),this.elementsWaiters.length&&(this.elementsWaiters.forEach(e=>e.clear()),this.elementsWaiters=[]),this}async isTriggered(){this.clear();const e=E(this.event);this.promises.push(e);const t={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),socialProofPurchases:()=>this.getSocialProofPurchases(e),socialProofPageViews:()=>this.getSocialProofPageViews(e)},o=!Object.prototype.hasOwnProperty.call(t,this.event)||await t[this.event]();this.clear();return"reengage"!==this.event&&this.delay?o&&await(async()=>{const e=E(`${this.event}Delay`);return this.promises.push(e),setTimeout(()=>{e.resolve(!0),this.clear()},this.delay),e.promise})():o}}class O{constructor(e,t,o){this.recurrence=e,this.isWidgetApplied=t,this.callback=o,this.observer=new MutationObserver(this.observerHandler.bind(this)),this.eventListenerParams=["abtasty_resetActionTracking",this.eventHandler.bind(this),{passive:!0}],this.elementsWaiters=[]}recurrenceIsDone(){return!this.recurrence||this.recurrence.isOver()}decisionHandler(e){const t=s(),{type:o}=this.recurrence?this.recurrence.getCurrentRecurrence():{type:!1},r=()=>e&&"display"===o||this.recurrenceIsDone();return!this.isWidgetApplied()&&t&&r()?(this.clearWatcher(),this.callback("rebuild",e)):(!this.isWidgetApplied()||t&&r())&&(this.isWidgetApplied()||t)||(this.clearWatcher(),this.callback("remove",e),this.watch()),this}eventHandler(){let e=s();return[250,500].forEach(t=>setTimeout(()=>500===t&&s()===e?this:(e=s(),this.decisionHandler(!1)),t)),this}observerHandler(e){const t=e.some(({removedNodes:e})=>e&&e.length),o=e.some(({addedNodes:e})=>e&&e.length);return t||o?(this.decisionHandler(!0),this):this}watch(){if(e())return this;this.clearWatcher(),document.addEventListener(...this.eventListenerParams);const t=A("body",e=>{const o=[e,{childList:!0,subtree:!0}];this.observer.observe(...o),this.elementsWaiters=this.elementsWaiters.filter(e=>e!==t)});return this.elementsWaiters.push(t),this}clearWatcher(){return document.removeEventListener(...this.eventListenerParams),this.elementsWaiters.length&&(this.elementsWaiters.forEach(e=>e.clear()),this.elementsWaiters=[]),this.observer.disconnect(),this}}class B{constructor(){this.children=void 0,this.uniqueId=y(),this.widgetName=_(),this.prettyName=b(),this.recurrenceParams=v(),this.triggerParams=w(),this.recurrence=!!this.recurrenceParams&&new R(this.recurrenceParams,this.clearGivenClearables.bind(this)),this.trigger=!!this.triggerParams&&new P(this.triggerParams),this.pageWatcher=new O(this.recurrence,this.isWidgetApplied.bind(this),this.onPageChange.bind(this)),this.hasOncePerPageTrigger=f(),this.basicClassName=`ab_widget_container_${this.widgetName}`,this.widgetContainerId=`${this.basicClassName}_${this.uniqueId}`,this.contentClassName=`${this.basicClassName}_content`,this.overlayClassName=`${this.basicClassName}_overlay`,this.closeButtonClassName=`${this.basicClassName}_close_button`,this.hideClassName=`ab_hide_${this.uniqueId}`,this.domElement=this.getDom(),this.hasBeenShown=!1,this.closedByUser=!1,this.eventsListeners=[],this.timeouts=[],this.intervals=[],this.observers=[],this.promises=[],this.elementsWaiters=[]}clearGivenClearables(){this.eventsListeners.length&&(this.eventsListeners.forEach(e=>document.removeEventListener(...e)),this.eventsListeners=[]),this.timeouts.length&&(this.timeouts.forEach(e=>clearTimeout(e)),this.timeouts=[]),this.intervals.length&&(this.intervals.forEach(e=>clearInterval(e)),this.intervals=[]),this.observers.length&&(this.observers.forEach(e=>e.disconnect()),this.observers=[]),this.promises.length&&(this.promises.forEach(e=>e.resolve(!1)),this.promises=[]),this.elementsWaiters.length&&(this.elementsWaiters.forEach(e=>e.clear()),this.elementsWaiters=[])}isWidgetApplied(){return this.domElement&&!!this.domElement.closest("html")}removeOldDomElement(){const e=document.getElementById(this.widgetContainerId);return e&&e.remove(),this}async insert(){const e=(e,t,o)=>{this.elementsWaiters=this.elementsWaiters.filter(e=>e!==t),T(e),o(e)},t=new Promise((t,o)=>{const r=A("head",e=>{this.elementsWaiters=this.elementsWaiters.filter(e=>e!==r),t(e.appendChild(this.styleElement))},t=>e(t,r,o));this.elementsWaiters.push(r)}),o=new Promise((t,o)=>{const{layout:r,elementReferrer:i,referrerInsertType:s}=DATA,{selector:n,position:a}="string"==typeof r&&"free"===r&&"string"==typeof i&&"string"==typeof s?{selector:i,position:s}:{selector:"body",position:"beforeend"},l=A(n,e=>{this.elementsWaiters=this.elementsWaiters.filter(e=>e!==l),this.removeOldDomElement(),t(e.insertAdjacentElement(a,this.domElement))},t=>e(t,l,o));this.elementsWaiters.push(l)});return Promise.all([o,t]).then(()=>this)}remove(){return this.pageWatcher.clearWatcher(),this.domElement&&this.domElement.closest("html")&&this.domElement.remove(),this.styleElement&&this.styleElement.closest("html")&&this.styleElement.remove(),this.hasOncePerPageTrigger?this.pageWatcher.watch():e()||this.init().then(({response:e})=>e?this.show():this),this}show(){return this.hasBeenShown||e()||window.ABTastyEvent(`${this.prettyName} displayed`,null,TEST_ID),this.closedByUser=!1,this.domElement.classList.remove(this.hideClassName),this.recurrence&&this.recurrence.setDisplayRecurrence(),this.hasBeenShown=!0,this.pageWatcher.watch(),this}hide(){return this.hasBeenShown&&!e()&&window.ABTastyEvent(`${this.prettyName} closed`,null,TEST_ID),this.closedByUser=!0,this.domElement.classList.add(this.hideClassName),this}async init(t){if(!e()&&!s())return!1;if(this.trigger&&this.trigger.promises.length)return!1;const o=this.recurrence&&this.recurrence.isOver();if(this.recurrence&&!o)return this.pageWatcher.watch(),!1;this.pageWatcher.watch();const r=e()||!this.trigger||this.trigger&&await this.trigger.isTriggered();return!!r&&(await this.insert(),this.addCloseEvent(),e()||t||this.hasBeenShown||void 0===this.children||"function"!=typeof this.children.refreshContent||this.children.refreshContent(r),{container:this,response:r})}onPageChange(e,t){const o=()=>this.init().then(({response:e})=>e&&this.show());switch(t||(this.hasBeenShown=!1),e){case"remove":this.isWidgetApplied()?this.remove():(this.trigger&&this.trigger.clear(),this.pageWatcher.watch());break;case"rebuild":this.hasBeenShown?this.closedByUser?this.pageWatcher.watch():this.insert().then(e=>e.show()):o()}}addCloseEvent(...t){const{closeButton:o,overlayClickable:r,layout:i}=DATA,s=[];if(void 0!==r&&r&&void 0!==i&&"popin"===i&&s.push(`.${this.overlayClassName}`),void 0!==o&&o&&s.push(`.${this.closeButtonClassName}`),!s.length)return this;const n=this.domElement.querySelectorAll(s.join(", "));return n.length?(t.push(...n),t.forEach(t=>{e()&&(t.dataset.abtastyActionnable="true"),t.addEventListener("click",()=>{this.recurrence&&this.recurrence.setClosingRecurrence(),this.hide(),setTimeout(()=>this.remove(),1e3)},{passive:!0,once:!0})}),this):this}getDom(){const{closeButton:e,layout:t}=DATA,o=document.createElement("div");return o.className=`${this.basicClassName} ${this.hideClassName}`,o.id=this.widgetContainerId,o.innerHTML=`\n\t\t\t${void 0!==t&&"popin"===t?`<div class="${this.overlayClassName}"></div>`:""}\n\t\t\t<div class="${this.contentClassName}">\n\t\t\t\t${e?`<button class="${this.closeButtonClassName}"><svg viewBox="0 0 16 16">\n\t<defs><path id="prefix__a" d="M12 4.991L11.009 4 8 7.009 4.991 4 4 4.991 7.009 8 4 11.009 4.991 12 8 8.991 11.009 12 12 11.009 8.991 8z"></path></defs>\n\t<g><use xlink:href="#prefix__a"></use></g>\n</svg></button>`:""}\n\t\t\t</div>`,o}getStyleTag(t=""){const{noStyles:o,layout:r}=DATA,{backgroundColor:i,isBackgroundImage:s,backgroundImage:n,backgroundSize:a,backgroundPosition:l,backgroundRepeat:c,borderColor:g,borderRadius:d,borderWidth:p,textColor:m,textAlign:h,overlayColor:_,dropShadow:b,dropShadowColor:y,dropShadowBlur:v,containerMargin:w,containerPadding:f,closeButton:x,buttonsBorderWidth:T,buttonsBorderColor:S,buttonsBorderRadius:E,buttonsBackgroundColor:A,buttonsTextColor:C}=o?{}:DATA,I=document.createElement("style");I.type="text/css",e()&&I.setAttribute("abtasty-script-added","true");const N=`background: ${["string"==typeof i?i:u,s&&"string"==typeof n&&n.length?`url(${n})`:"",s&&"string"==typeof l&&"100% 100%"!==a?l:"0 0",s&&"string"==typeof a?`/ ${a}`:"/ auto",s&&c&&!["cover","100% 100%"].includes(a)?"repeat":"no-repeat"].join(" ").trim()};`,$="number"==typeof p&&p>0,R=`border: ${[$?`${p}px`:"unset",$?"solid":"",$&&"string"==typeof g&&g.length?g:""].join(" ").trim()};`,k=void 0!==d?`border-radius: ${d}px;`:"",P=void 0!==m?`color: ${m}; fill: ${m};`:"",O=void 0!==h?`text-align: ${h};`:"",B=void 0!==b&&b?`box-shadow: 0 5px ${v}px 0 ${y};`:"",L=w instanceof Array&&1===w.length&&w[0],W=L?`margin: ${L.top}px ${L.right}px ${L.bottom}px ${L.left}px;`:"",D=L?`margin: calc(${L.top}px * 0.5) calc(${L.right}px * 0.5) calc(${L.bottom}px * 0.5) calc(${L.left}px * 0.5);`:"",U=f instanceof Array&&1===f.length&&f[0],F=U?`padding: ${U.top}px ${U.right}px ${U.bottom}px ${U.left}px;`:"",V=U?`padding: calc(${U.top}px * 0.5) calc(${U.right}px * 0.5) calc(${U.bottom}px * 0.5) calc(${U.left}px * 0.5);`:"",G=void 0!==T&&T?`border-width: ${T}px; border-style: solid;`:"",q=[S,T].every(e=>void 0!==e)&&T?`border-color: ${S};`:"",M=void 0!==E?`border-radius: ${E}px;`:"",H=void 0!==A?`background-color: ${A};`:"",j=void 0!==C?`color: ${C};`:"",Y=void 0!==r&&"popin"===r?[`#${this.widgetContainerId} .${this.overlayClassName} {`,`background-color: ${void 0!==_?_:"rgba(0, 0, 0, 0.6)"};`,"}"].join(""):"",K=o||void 0!==x&&x?[`#${this.widgetContainerId} .${this.contentClassName} .${this.closeButtonClassName} {`,"position: absolute;","top: 8px;","right: 8px;","width: auto;","height: auto;","background: none;","border: none;","cursor: pointer;","outline: none;","padding: 0;","margin: 0;","}",`#${this.widgetContainerId} .${this.contentClassName} .${this.closeButtonClassName} svg {`,"pointer-events: none;","width: 16px;","height: 16px;",P,"}"].join(""):"";return I.textContent=[`.${this.hideClassName} {`,"opacity: 0 !important;","pointer-events: none;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,N,k,R,P,O,B,W,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,"display: block;","line-height: 1;","text-indent: unset;",F,"}",`#${this.widgetContainerId} .${this.contentClassName} > * a, `,`#${this.widgetContainerId} .${this.contentClassName} > * button {`,G,q,M,H,j,"}","@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,D,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,V,"}","}",Y,K,`${t}`].join(""),I}}class L extends B{constructor(){super(),this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){return[`#${this.widgetContainerId} {`,"position: fixed;","top: 0;","left: 0;","width: 100%;","height: 100%;","z-index: 9999;","opacity: 1;","transition: opacity 0.25s ease;","}",`#${this.widgetContainerId} .${this.overlayClassName} {`,"position: absolute;","z-index: -1;","top: 0;","left: 0;","width: 100%;","height: 100%;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: absolute;","left: 50%;","top: 50%;","transform: translate(-50%, -50%);","width: auto;","height: auto;","}","@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,"max-width: 94vw;","}","}"].join("")}}class W extends B{constructor(){super(),this.position="string"==typeof DATA.layout&&"bannerTop"===DATA.layout?"top":"bottom",this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){return[`#${this.widgetContainerId} {`,"position: fixed;",`${this.position}: 0;`,"left: 0;","width: 100%;","height: auto;","z-index: 9999;","opacity: 1;","transition: opacity 0.25s ease;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: relative;","}"].join("")}}class D extends B{constructor(){super(),this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){return[`#${this.widgetContainerId} {`,"width: auto;","height: auto;","margin: 0;","padding: 0;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: relative;","}"].join("")}}const U=[{label:"widget_common_conditions_recurrence_option_everyTime",value:"everytime"},{label:"widget_common_conditions_recurrence_option_everySession",value:"session"},{label:"widget_common_conditions_recurrence_option_everyXDays",value:"day"},{label:"widget_common_conditions_recurrence_option_everyXWeeks",value:"week"},{label:"widget_common_conditions_recurrence_option_everyXMonths",value:"month"},{label:"widget_common_conditions_recurrence_option_once",value:"once"}],F={category:l,type:g,min:1},V=[{...F,propName:"day",label:"widget_common_conditions_recurrence_ifOptionVariable_labelDays",value:5,max:395},{...F,propName:"week",label:"widget_common_conditions_recurrence_ifOptionVariable_labelWeeks",value:2,max:56},{...F,propName:"month",label:"widget_common_conditions_recurrence_ifOptionVariable_labelMonths",value:1,max:13}],G={category:l,type:"select",options:U,value:"everytime"},q={...G,label:"widget_common_conditions_recurrence_label_widgetDisplayed",propName:"displayRecurrence"},M=V.map(e=>({...e,propName:`${q.propName}_${e.propName}`,conditions:[{field:q.propName,value:e.propName}]})),H={...G,label:"widget_common_conditions_recurrence_label_widgetDisplayedAfterClosure",propName:"closingRecurrence"},j=V.map(e=>({...e,propName:`${H.propName}_${e.propName}`,conditions:[{field:H.propName,value:e.propName}]})),Y={...G,label:"widget_common_conditions_recurrence_label_widgetDisplayedAfterSubmission",propName:"validationRecurrence"},K=V.map(e=>({...e,propName:`${Y.propName}_${e.propName}`,conditions:[{field:Y.propName,value:e.propName}]})),z={category:l,type:d,label:"widget_common_conditions_recurrence_blockTitle",collapsible:!0,children:[q,...M,H,...j,Y,...K]},X={category:l,type:g,propName:"triggerEventDelay",label:"widget_common_conditions_triggering_delay_label",min:0,max:60,value:0},J={...X,propName:"triggerEventReengageDelay",value:10,max:180},Q={category:l,type:"selectelement",propName:"triggerEventClick",value:"body"},Z={...Q,propName:"triggerEventElementVisible"},ee={category:l,type:"textarea",label:"widget_common_conditions_triggering_option_customTrigger",propName:"triggerEventCustomScript",value:"/* In this example snippet, the widget will be triggered as soon as any scroll is detected.\nCreate your own by resolving resolve() with true (which does trigger) or false (which doesn't trigger) */\n\nfunction launchIfScroll() {\n\treturn new Promise(resolve => {\n\t\tdocument.addEventListener('scroll', () => resolve(true), {once: true});\n\t});\n}\n\nconst result = await launchIfScroll();\nreturn resolve(result);",rows:15},te={pageLoad:{label:"widget_common_conditions_triggering_option_pageload",value:"pageLoad"},direct:{label:"widget_common_conditions_triggering_option_asap",value:"direct"},exitIntent:{label:"widget_common_conditions_triggering_option_exitIntent",value:"exitIntent"},reengage:{label:"widget_common_conditions_triggering_option_afterXSecondsOfInactivity",value:"reengage"},click:{label:"widget_common_conditions_triggering_option_click",value:"click"},elementVisible:{label:"widget_common_conditions_triggering_option_elementVisible",value:"elementVisible"},customScript:{label:"widget_common_conditions_triggering_option_customTrigger",value:"script"}},oe={category:l,type:c,propName:"isOncePerPageTrigger",value:!0,label:"widget_common_conditions_triggering_label_triggerOnlyOnce"},re={category:l,type:c,propName:"autoHide",value:!0,label:"widget_common_conditions_triggering_autohide_toggler_label_autoHideAfterRedirection"},ie={category:l,type:g,propName:"timeHide",value:2,max:120,label:"widget_common_conditions_triggering_autohide_toggler_label_autoHideAfterXSeconds",conditions:[{field:"autoHide",value:!0}]},se={category:l,type:"select",label:"widget_common_conditions_triggering_label",options:Object.keys(te).map(e=>te[e]),propName:"triggerEvent",value:"pageLoad"};Q.conditions=[{field:"triggerEvent",value:"click"}],J.conditions=[{field:"triggerEvent",value:"reengage"}],Z.conditions=[{field:"triggerEvent",value:"elementVisible"}],ee.conditions=[{field:"triggerEvent",value:"script"}],X.conditions=[{field:"triggerEvent",value:e=>"reengage"!==e}],oe.conditions=[{field:"triggerEvent",value:e=>"click"===e||"script"===e}];const ne=[Q,Z,ee,oe,J,X],ae={category:l,type:d,label:"widget_common_conditions_triggering_blockTitle",collapsible:!0,children:[se,...ne]};const le={category:"content",propName:"button",type:c,value:!1,label:"widget_common_content_toggler_label_displayButton"},ce={category:"content",propName:"buttonText",type:"text",label:"widget_common_content_label_buttonText",value:"widget_common_content_buttonText_default"},ge={category:"content",propName:"buttonLink",type:"text",label:"widget_common_content_label_buttonUrl",value:location.origin,conditions:[{field:"button"}]},de={category:"content",propName:"buttonTargetType",type:c,label:"widget_common_content_button_label_openLinkNewTab",value:!1,conditions:[{field:"button"}]},pe=[{field:"button"}];ce.conditions=pe,ge.conditions=pe,de.conditions=pe;const ue={category:"content",type:d,label:"widget_common_tabName_content",collapsible:!1,children:[le,ce,ge,de]},me={category:"layout",type:"radioImage",propName:"layout",label:"widget_common_layout_label_selectALayout",value:"popin",style:"big",options:[{label:"widget_common_layout_option_modal",value:"popin",src:`${p}layout/icon-layout-modal.png`},{label:"widget_common_layout_option_topBanner",value:"bannerTop",src:`${p}layout/icon-layout-topBanner.png`},{label:"widget_common_layout_option_bottomBanner",value:"bannerBottom",src:`${p}layout/icon-layout-bottomBanner.png`},{label:"widget_common_layout_option_freePlacement",value:"free",src:`${p}layout/icon-layout-freePlacement.png`}]},he={category:"layout",type:"selectelement",propName:"elementReferrer",label:"widget_common_layout_label_selectElementContainWidget",value:"body"},_e={category:"layout",type:"radio",propName:"referrerInsertType",value:"afterbegin",label:"widget_common_layout_positioning_label_selectPosition",options:[{label:"widget_common_layout_positioning_option_before",value:"beforebegin"},{label:"widget_common_layout_positioning_option_atTheBeginning",value:"afterbegin"},{label:"widget_common_layout_positioning_option_atTheEnd",value:"beforeend"},{label:"widget_common_layout_positioning_option_after",value:"afterend"}]},be=[{field:"layout",value:"free"}];he.conditions=be,_e.conditions=be;const ye={category:"layout",type:d,label:"widget_common_tabName_layout",collapsible:!0,children:[me,he,_e]},ve={category:a,type:"colorpicker",label:"widget_common_style_container_label_backgroundColor",propName:"backgroundColor",value:m},we={category:a,type:c,label:"widget_common_style_toggler_label_backgroundImage",propName:"isBackgroundImage",value:!1},fe={category:a,type:"mediaupload",label:"widget_common_style_toggler_label_backgroundImage",propName:"backgroundImage",value:""},xe={category:a,type:"radio",label:"widget_common_style_backgroundImageUploader_imageOptions_label",propName:"backgroundSize",value:"cover",options:[{label:"widget_common_style_backgroundImageUploader_imageOptions_option_cover",value:"cover"},{label:"widget_common_style_backgroundImageUploader_imageOptions_option_contain",value:"contain"},{label:"widget_common_style_backgroundImageUploader_imageOptions_option_fill",value:"100% 100%"},{label:"widget_common_style_backgroundImageUploader_imageOptions_option_none",value:"auto"}]},Te={category:a,type:"select",label:"widget_common_style_backgroundImageUploader_imagePosition_select_label",propName:"backgroundPosition",value:"center",options:[{label:"widget_common_style_backgroundImageUploader_imagePosition_option_top",value:"top"},{label:"widget_common_style_backgroundImageUploader_imagePosition_option_bottom",value:"bottom"},{label:"widget_common_style_backgroundImageUploader_imagePosition_option_center",value:"center"},{label:"widget_common_style_backgroundImageUploader_imagePosition_option_left",value:"left"},{label:"widget_common_style_backgroundImageUploader_imagePosition_option_right",value:"right"},{label:"widget_common_style_backgroundImageUploader_imagePosition_option_topLeft",value:"top left"},{label:"widget_common_style_backgroundImageUploader_imagePosition_option_topRight",value:"top right"},{label:"widget_common_style_backgroundImageUploader_imagePosition_option_bottomLeft",value:"bottom left"},{label:"widget_common_style_backgroundImageUploader_imagePosition_option_bottomRight",value:"bottom right"}]},Se={category:a,type:c,label:"widget_common_style_backgroundImageUploader_toggler_repeatBackgroundImage",propName:"backgroundRepeat",value:!1},Ee={category:a,type:"colorpicker",label:"widget_common_style_border_label_borderColor",propName:"borderColor",value:"rgba(0, 127, 145, 1)"},Ae={category:a,type:g,label:"widget_common_style_border_label_borderRadius",propName:"borderRadius",value:4,unit:"px"},Ce={category:a,type:g,label:"widget_common_style_border_label_borderThickness",propName:"borderWidth",value:2,min:0,max:50,unit:"px"},Ie={category:a,type:"colorpicker",label:"widget_common_style_text_label_textColor",propName:"textColor",value:"rgba(57, 57, 57, 1)"},Ne={category:a,type:"radioImage",label:"widget_common_style_text_label_textAlignment",propName:"textAlign",value:"center",style:"little",options:[{label:"widget_common_style_text_textAlignment_option_left",value:"left",src:`${p}style/icon-text-alignLeft.png`},{label:"widget_common_style_text_textAlignment_option_center",value:"center",src:`${p}style/icon-text-alignCenter.png`},{label:"widget_common_style_text_textAlignment_option_right",value:"right",src:`${p}style/icon-text-alignRight.png`}]},$e={category:a,type:"areainput"},Re={...$e,label:"widget_common_style_container_label_margin",propName:"containerMargin",value:[{top:0,left:0,bottom:0,right:0}]},ke={...$e,label:"widget_common_style_container_label_padding",propName:"containerPadding",value:[{top:35,left:60,bottom:35,right:60}]},Pe={category:a,type:c,label:"widget_common_style_container_dropShadow_blockTitle",propName:"dropShadow",value:!1},Oe={category:a,type:"colorpicker",label:"widget_common_style_container_dropShadow_label_color",propName:"dropShadowColor",value:"rgba(57, 57, 57, 0.25);"},Be={category:a,type:g,label:"widget_common_style_container_dropShadow_label_blurRadius",propName:"dropShadowBlur",value:10,unit:"px"},Le={category:a,type:c,label:"widget_common_style_container_label_displayCloseButton",propName:"closeButton",value:!0},We={category:a,type:"colorpicker",label:"widget_common_style_overlay_label_overlayColor",propName:"overlayColor",value:"rgba(0, 0, 0, 0.6)"},De={category:a,type:c,label:"widget_common_style_overlay_label_overlayClickable",propName:"overlayClickable",value:!0},Ue={category:a,type:g,label:"widget_common_style_buttons_label_buttonBorderThickness",propName:"buttonsBorderWidth",value:1,min:0,max:30,unit:"px"},Fe={category:a,type:"colorpicker",label:"widget_common_style_buttons_label_buttonBorderColor",propName:"buttonsBorderColor",value:"rgba(87, 184, 199, 1)"},Ve={category:a,type:g,label:"widget_common_style_buttons_label_buttonBorderRadius",propName:"buttonsBorderRadius",value:4,min:0,max:30,unit:"px"},Ge={category:a,type:"colorpicker",label:"widget_common_style_buttons_label_buttonBackgroundColor",propName:"buttonsBackgroundColor",value:"rgba(0, 127, 145, 1)"},qe={category:a,type:"colorpicker",label:"widget_common_style_buttons_label_buttonTextColor",propName:"buttonsTextColor",value:m},Me={field:we.propName,value:!0},He={field:xe.propName,value:e=>"cover"!==e},je={field:xe.propName,value:e=>"100% 100%"!==e};fe.conditions=[Me],xe.conditions=[Me],Te.conditions=[Me,je],Se.conditions=[Me,je,He];const Ye=[ve,we,fe,xe,Te,Se],Ke={category:a,type:d,label:"widget_stickyElement_content_positionOn_option_background",collapsible:!0,children:Ye},ze=[{field:Ce.propName,value:e=>e>0}];Ee.conditions=ze;const Xe={category:a,type:d,label:"widget_common_style_blockTitle_border",collapsible:!0,children:[Ce,Ee,Ae]},Je={category:a,type:d,label:"widget_common_style_blockTitle_text",collapsible:!0,children:[Ne,Ie]},Qe=[{field:"dropShadow",value:!0}];Oe.conditions=Qe,Be.conditions=Qe;const Ze={category:a,type:d,label:"widget_common_style_blockTitle_container",collapsible:!0,children:[Re,ke,...Ye,Pe,Oe,Be,Le]},et={category:a,type:d,label:"widget_common_style_blockTitle_overlay",collapsible:!0,children:[We,De],conditions:[{field:"layout",value:"popin"}]},tt=[{field:Ue.propName,value:e=>e>0}];Fe.conditions=tt;const ot={category:a,type:d,label:"widget_common_style_blockTitle_buttons",collapsible:!0,children:[Ue,Fe,Ve,Ge,qe]};exports.ABTASTY_IMAGES_ROUTE=p,exports.AREAINPUT="areainput",exports.BLACK="rgba(0, 0, 0, 1)",exports.Banner=W,exports.CHECKBOX="checkbox",exports.COLOR_PICKER="colorpicker",exports.CONDITIONS=l,exports.CONTENT="content",exports.DARK_GRAY="rgba(57, 57, 57, 1)",exports.DARK_TURQUOISE="rgba(0, 127, 145, 1)",exports.DATE_PICKER="datepicker",exports.DATE_RANGE_PICKER="dateRangePicker",exports.Free=D,exports.GROUP=d,exports.HIDDEN="hidden",exports.INLINE_NOTIFICATION="inlinenotification",exports.LAYOUT="layout",exports.LIGHT_GREY=m,exports.LIGHT_TURQUOISE="rgba(87, 184, 199, 1)",exports.MEDIA_UPLOAD="mediaupload",exports.NUMBER="number",exports.PARAGRAPH="paragraph",exports.PageWatcher=O,exports.Popin=L,exports.RADIO_BUTTON="radio",exports.RADIO_IMAGE="radioImage",exports.REBUILD_WIDGET="rebuild",exports.REMOVE_WIDGET="remove",exports.Recurrence=R,exports.SELECT="select",exports.SELECT_ELEMENT="selectelement",exports.SEPARATOR="separator",exports.SHORT_SEPARATOR="short-separator",exports.SLIDER=g,exports.SOCIAL_PROOF_API_BASE=h,exports.STYLE=a,exports.SWITCH=c,exports.TAG_RESET_EVENT="abtasty_resetActionTracking",exports.TASTY_GREEN="rgba(28, 191, 151, 1)",exports.TASTY_RED="rgba(213, 64, 64, 1)",exports.TASTY_YELLOW="rgba(224, 185, 10, 1)",exports.TEXT_AREA="textarea",exports.TEXT_FIELD="text",exports.TIME_PICKER="timepicker",exports.Trigger=P,exports.URL_FIELD="url",exports.VARIABLES_INPUT="variablesinput",exports.WHITE=u,exports.WYSIWYG="wysiwyg",exports.WidgetContainer=B,exports.addGlobalUtil=t,exports.addPolyfill=$,exports.allowGlobalScroll=function(){A("body",()=>{const{body:e}=document;I&&(e.style.overflowY=I)},e=>x(e))},exports.asyncRequest=function(e,t){return new Promise((o,r)=>{const i=new XMLHttpRequest;i.open(e,t,!0),i.onload=function(){this.status>=200&&this.status<300?o(i.response):r({status:this.status,statusText:i.statusText})},i.onerror=function(){r({status:this.status,statusText:i.statusText})},i.send()})},exports.autoHideForm=re,exports.backgroundColorForm=ve,exports.backgroundImageForm=fe,exports.backgroundsGroup=Ke,exports.backgroundsGroupChildren=Ye,exports.borderColorForm=Ee,exports.borderRadiusForm=Ae,exports.borderWidthForm=Ce,exports.bordersGroup=Xe,exports.buttonLinkForm=ge,exports.buttonLinkGroup=ue,exports.buttonTargetTypeForm=de,exports.buttonTextForm=ce,exports.buttonsBackgroundColorForm=Ge,exports.buttonsBorderColorForm=Fe,exports.buttonsBorderRadiusForm=Ve,exports.buttonsBorderWidthForm=Ue,exports.buttonsGroup=ot,exports.buttonsTextColorForm=qe,exports.closingRecurrenceForm=H,exports.containerGroup=Ze,exports.displayCloseButtonSwitchForm=Le,exports.displayRecurrenceForm=q,exports.dropShadowBlurForm=Be,exports.dropShadowColorForm=Oe,exports.dropShadowSwitchForm=Pe,exports.elementReferrerForm=he,exports.findParent=C,exports.getAccountIdentifier=o,exports.getCookie=e=>{const t=`${e}=`,o=document.cookie.split(";");for(let e=0;e<o.length;e+=1){let r=o[e];for(;" "===r.charAt(0);)r=r.substring(1);if(0===r.indexOf(t))return r.substring(t.length,r.length)}return""},exports.getCustomTriggersGroup=function(e){const t=e.reduce((e,t)=>[...e,te[t]],[]),o=ne.reduce((t,o)=>{const{conditions:r}=o;return r&&r.some(({value:t})=>e.includes(t))?[...t,o]:t},[]),r={...se,options:t,value:e[0]};return{category:l,type:d,label:"widget_common_conditions_triggering_blockTitle",collapsible:!0,children:[r,...o]}},exports.getGroupSettedValues=(e,t)=>{if("object"!=typeof t)return e;const{type:o,children:r}=e,i=Object.keys(t);if(!i.length)return e;if("object"!=typeof e||!o||"group"!==o||!r||!Array.isArray(r)||Array.isArray(r)&&!r.length)return{};const s=r.map(e=>{const{propName:o,value:r}=e;return i.includes(o)&&typeof r==typeof t[o]?{...e,value:t[o]}:e});return{...e,children:s}},exports.getHostname=S,exports.getPrettyWidgetName=b,exports.getProductKey=i,exports.getRecurrenceParams=v,exports.getTriggerParams=w,exports.getUniqueId=y,exports.getVisitorId=()=>window.ABTasty&&window.ABTasty.visitor?window.ABTasty.visitor.id:void 0,exports.getWidgetContainer=()=>{const{layout:e}=DATA;let t;switch(e){case"popin":t=new L;break;case"bannerTop":case"bannerBottom":t=new W;break;case"free":t=new D;break;default:t=new B}return t},exports.getWidgetName=_,exports.isAffected=s,exports.isBackgroundImageForm=we,exports.isInQaMode=n,exports.isOnEditor=e,exports.isOnPreview=r,exports.isTouch=()=>void 0!==window.ontouchstart,exports.isTriggerOncePerPage=f,exports.layoutGroup=ye,exports.layoutsForm=me,exports.loadImage=e=>new Promise((t,o)=>{const r=new Image;r.onload=()=>{t(r)},r.src=e,r.onerror=()=>{const t=new Error(`Image ${e} is not loaded.`);return o(t)}}),exports.loadJS=N,exports.log=x,exports.marginForm=Re,exports.olverlayCloseOnClickForm=De,exports.overlayColorForm=We,exports.overlayGroup=et,exports.paddingForm=ke,exports.preventGlobalScroll=function(){A("body",()=>{const{body:e}=document;I=window.getComputedStyle(e).overflowY,e.style.overflowY="hidden"},e=>x(e))},exports.promiseDeferrer=E,exports.recurrencesGroup=z,exports.referrerInsertTypeForm=_e,exports.setCookie=(e,t,o)=>{let r="";if(o){const e=new Date;e.setTime(e.getTime()+24*o*60*60*1e3),r=`expires=${e.toUTCString()}`}const i=`domain=${S()}`;document.cookie=`${e}=${t}; ${r};${i};path=/`},exports.switchButtonForm=le,exports.syncRequest=function(e,t){const o=new XMLHttpRequest;return o.open(e,t,!1),o.send(null),o},exports.textAlignmentForm=Ne,exports.textColorForm=Ie,exports.textGroup=Je,exports.timeHideForm=ie,exports.triggerDelay=X,exports.triggerEventCustomScript=ee,exports.triggerEventElementVisible=Z,exports.triggerEventReengageDelay=J,exports.triggerOncePerPage=oe,exports.triggersForm=se,exports.triggersGroup=ae,exports.triggersOptions=te,exports.validationRecurrenceForm=Y,exports.waitForElement=A,exports.widgetLog=T; |
@@ -1,1 +0,1 @@ | ||
const e=()=>Object.prototype.hasOwnProperty.call(window,"ABTastyEditor");function t(e,t){return ABTasty.widgetUtils||(ABTasty.widgetUtils={}),ABTasty.widgetUtils[e]||Object.assign(ABTasty.widgetUtils,{[e]:new t}),ABTasty.widgetUtils[e]}const o=()=>{let e;return window.ABTasty||window.ABTASTY_S?(window.ABTASTY_S&&window.ABTASTY_S.USER&&window.ABTASTY_S.USER.accountIdentifier&&window.ABTASTY_S.USER.accountIdentifier.length?e=window.ABTASTY_S.USER.accountIdentifier:window.ABTasty&&window.ABTasty.getAccountSettings&&"function"==typeof window.ABTasty.getAccountSettings?e=window.ABTasty.getAccountSettings().identifier:window.ABTasty&&window.ABTasty.accountSettings&&(e=window.ABTasty.accountSettings.identifier),e):e},i=()=>{const e=!!document.getElementById("ABTastyPreviewBar"),t=location.href.includes("ab_project=preview");return e||t},r=()=>window.ABTasty&&window.ABTasty.visitor?window.ABTasty.visitor.id:void 0,n=()=>window.ABTastyProductKey,s=()=>!!window.ABTasty.getTestsOnPage()[TEST_ID]||i(),a=()=>{if(e())return!1;const t=ABTasty.getTestsOnPage()[TEST_ID];return!!t&&Object.keys(t.targetings.qaParameters).length>0},l="style",c="layout",d="content",g="conditions",h="hidden",u="separator",m="short-separator",p="paragraph",_="text",b="url",y="select",v="checkbox",w="wysiwyg",f="colorpicker",T="datepicker",S="timepicker",$="number",N="textarea",E="variablesinput",C="selectelement",A="radio",k="radioImage",x="switch",I="slider",P="mediaupload",R="dateRangePicker",B="group",O="areainput",L="inlinenotification",W="https://widgets-images.abtasty.com/",D="abtasty_resetActionTracking",V="remove",U="rebuild",q="rgba(255, 255, 255, 1)",j="rgba(0, 0, 0, 1)",M="rgba(247, 247, 247, 1)",H="rgba(57, 57, 57, 1)",G="rgba(0, 127, 145, 1)",z="rgba(87, 184, 199, 1)",K="rgba(213, 64, 64, 1)",Y="rgba(28, 191, 151, 1)",F="rgba(224, 185, 10, 1)",X="https://social-proof-api.abtasty.com/clients/",J=()=>{const{type:e}=DATA;return`${PACKAGE.replace("@abtasty/","")}${e?`_${e}`:""}`},Q=()=>{const e=J();return`${e.charAt(0).toUpperCase()}${e.slice(1)}`.split("-").join(" ")},Z=()=>`${PLUGIN_ID.split("-")[0]}_${TEST_ID}`,ee=()=>{const{displayRecurrence:t,closingRecurrence:o,validationRecurrence:i}=DATA;if(e()||!t&&!o&&!i)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`]},n={};return t&&(n.displayRecurrence=r[t]("displayRecurrence")),o&&(n.closingRecurrence=r[o]("closingRecurrence")),i&&(n.validationRecurrence=r[i]("validationRecurrence")),n},te=()=>{let{triggerEvent:t}=DATA;const{triggerEventClick:o,triggerEventReengageDelay:i,socialProofContentType:r,triggerEventElementVisible:n,triggerEventDelay:s}=DATA;if(e()||!t&&!r)return!1;const a={click:()=>o,elementVisible:()=>n},l=Object.prototype.hasOwnProperty.call(a,t)?a[t]():"body",c="reengage"===t?i:s;return r&&(t=1===r?"socialProofPurchases":"socialProofPageViews"),{triggerEvent:t,triggerSelector:l,triggerDelay:c}},oe=()=>{const{isOncePerPageTrigger:e,triggerEvent:t}=DATA;return!(!e||!["click","script"].includes(t))||["pageLoad","direct","reengage","socialProofPurchases","socialProofPageViews","elementVisible"].some(e=>e===t)},ie=(...e)=>{e.unshift(`[AB Tasty Widget] ${PACKAGE}:`),console.log(...e)},re=e=>{if(a()){const t=Q();window.console.log(`%c${t} - QA Mode for campaign ${TEST_ID}\n${e}`,`background-color: rgba(0, 127, 145, 1); color: ${M}`)}},ne=()=>{let e=document.location.hostname.split("").reverse().join("");if(e=e.match(/(?:[a-z]{2,4}\.[a-z]{2,3}|[a-z]{2,5})\.[a-z0-9-]+(?:\.|$)/i),null===e)e=document.location.hostname;else{"."!==e[0].substr(e[0].length-1)&&(e[0]+="."),e=e[0].split("").reverse().join("")}return e},se=(e,t)=>{if("object"!=typeof t)return e;const{type:o,children:i}=e,r=Object.keys(t);if(!r.length)return e;if("object"!=typeof e||!o||"group"!==o||!i||!Array.isArray(i)||Array.isArray(i)&&!i.length)return{};const n=i.map(e=>{const{propName:o,value:i}=e;return r.includes(o)&&typeof i==typeof t[o]?{...e,value:t[o]}:e});return{...e,children:n}},ae=e=>{const t={promise:null,resolve:null,reject:null,name:e};return t.promise=new Promise((e,o)=>{t.resolve=e,t.reject=o}),t},le=(e,t,o)=>{let i=0,r=0;try{document.querySelector(e)}catch(t){const i=`Selector «${e}» not valid.`;return ie(i),"function"==typeof o&&o(i)}function n(){clearInterval(r),clearTimeout(i)}return i=setTimeout(()=>{n();const t=`Can't find element «${e}».`;return ie(t),"function"==typeof o&&o(t)},1e4),r=setInterval(()=>{const o=document.querySelector(e);return null!==o?(n(),"function"==typeof t&&t(o)):o},200),{clear:n}};function ce(e,t){return t(e)||!e.parentElement?e:ce(e.parentElement,t)}let de;function ge(){le("body",()=>{const{body:e}=document;de=window.getComputedStyle(e).overflowY,e.style.overflowY="hidden"},e=>ie(e))}function he(){le("body",()=>{const{body:e}=document;de&&(e.style.overflowY=de)},e=>ie(e))}const ue=e=>new Promise((t,o)=>{const i=new Image;i.onload=()=>{t(i)},i.src=e,i.onerror=()=>{const t=new Error(`Image ${e} is not loaded.`);return o(t)}}),me=()=>void 0!==window.ontouchstart;function pe(e,t){const o=new XMLHttpRequest;return o.open(e,t,!1),o.send(null),o}function _e(e,t){return new Promise((o,i)=>{const r=new XMLHttpRequest;r.open(e,t,!0),r.onload=function(){this.status>=200&&this.status<300?o(r.response):i({status:this.status,statusText:r.statusText})},r.onerror=function(){i({status:this.status,statusText:r.statusText})},r.send()})}function be(e){return new Promise((t,o)=>{const i=window.document.getElementsByTagName("script")[0],r=window.document.createElement("script");r.src=e,i.parentNode.insertBefore(r,i),r.onload=t,r.onerror=o})}async function ye(e){let t;switch(e){case"IntersectionObserver":t=await("IntersectionObserver"in window&&"IntersectionObserverEntry"in window&&"intersectionRatio"in window.IntersectionObserverEntry.prototype||be("https://polyfill.io/v3/polyfill.min.js?flags=gated&features=IntersectionObserver"));break;default:t=!0}return t}const ve=(e,t,o)=>{let i="";if(o){const e=new Date;e.setTime(e.getTime()+24*o*60*60*1e3),i=`expires=${e.toUTCString()}`}const r=`domain=${ne()}`;document.cookie=`${e}=${t}; ${i};${r};path=/`},we=e=>{const t=`${e}=`,o=document.cookie.split(";");for(let e=0;e<o.length;e+=1){let i=o[e];for(;" "===i.charAt(0);)i=i.substring(1);if(0===i.indexOf(t))return i.substring(t.length,i.length)}return""};class fe{constructor({displayRecurrence:e,closingRecurrence:t,validationRecurrence:o},i){this.displayRecurrence=parseFloat(e),this.closingRecurrence=parseFloat(t),this.validationRecurrence=parseFloat(o),this.onSetCallback=i,this.widgetName=J(),this.uniqueId=Z(),this.recurrenceKey=`${this.widgetName}_${this.uniqueId}`}getGivenRecurrenceStorageParsed(e){try{const t=e.getItem("ABTastyWidgets");return JSON.parse(t)}catch(t){return e.removeItem("ABTastyWidgets"),!1}}getSessionRecurrenceStorageParsed(){return this.getGivenRecurrenceStorageParsed(window.sessionStorage)}getLocalRecurrenceStorageParsed(){return this.getGivenRecurrenceStorageParsed(window.localStorage)}removeGivenStorage(e,t){const{[this.recurrenceKey]:o,...i}=t;return Object.entries(i).length?(e.setItem("ABTastyWidgets",JSON.stringify(i)),i):(e.removeItem("ABTastyWidgets"),!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(){const e=this.getSessionRecurrence(),t=this.getLocalRecurrence();return e||t||{type:!1}}isOver(){const e=this.getLocalRecurrence(),t=(e?parseFloat(e.stamp):0)<(new Date).getTime();return t&&this.removeLocalRecurrenceStorage(),t&&!this.getLocalRecurrence()&&!this.getSessionRecurrence()}setRecurrence(e,t){const o=this.getTypeOfStorage(e);if(i()||!o&&"object"!=typeof o)return!1;const{storageString:r,storageMethod:n}=o,s=this.getStamp(e),a={type:t,stamp:s},{type:l}=this.getCurrentRecurrence(),c=()=>{const e=this.getSessionRecurrence(),t=this.getLocalRecurrence();let o;"session"===r?e?o=this.removeSessionRecurrenceStorage():(this.removeLocalRecurrenceStorage(),o=this.getSessionRecurrenceStorageParsed()):"local"===r&&(t?o=this.removeLocalRecurrenceStorage():(this.removeSessionRecurrenceStorage(),o=this.getLocalRecurrenceStorageParsed()));const i=o?{[this.recurrenceKey]:a,...o}:{[this.recurrenceKey]:a};n.setItem("ABTastyWidgets",JSON.stringify(i)),this.onSetCallback&&"function"==typeof this.onSetCallback&&this.onSetCallback()};if(!n)return!1;if(l&&"validation"!==t)if("closing"===t&&"validation"!==l)c();else{if("display"!==t||"validation"===l||"closing"===l)return!1;c()}else c();return s}setDisplayRecurrence(){this.setRecurrence(this.displayRecurrence,"display")}setClosingRecurrence(){this.setRecurrence(this.closingRecurrence,"closing")}setValidationRecurrence(){this.setRecurrence(this.validationRecurrence,"validation")}getStamp(e){return(new Date).getTime()+864e5*e}getTypeOfStorage(e){return!(isNaN(e)||e<0||0!==e&&!e)&&(e>0?{storageString:"local",storageMethod:window.localStorage}:0===e&&{storageString:"session",storageMethod:window.sessionStorage})}}class Te{constructor(){this.targets=[],this.existingTargets=[],this.inViewportTargets=[],this.visibilityObserver=this.startVisibilityObserver(),this.mutationObserver=this.startMutationObserver(),this.mouseOverEvent=this.mouseOverHandler()}intersectionHandler(e){e.forEach(e=>{e.isIntersecting?(this.existingTargets.forEach(t=>{t.element.isSameNode(e.target)&&(this.inViewportTargets.push(t),this.mouseOverEvent.start())}),this.checkElements()):this.inViewportTargets=this.inViewportTargets.filter(t=>!t.element.isSameNode(e.target)||(this.mouseOverEvent.clear(),!1))})}startVisibilityObserver(){return new IntersectionObserver(this.intersectionHandler.bind(this),{root:null,rootMargin:"0px",threshold:0})}startMutationObserver(){const e=this.mutationObserver||new MutationObserver(this.checkElements.bind(this));return document.body&&e.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),e}onMouseOver({target:e,path:t}){const o=this.inViewportTargets.find(({element:o,selector:i})=>{if(o.isSameNode(e))return!0;const r=[...e.querySelectorAll(i)];if(r.length){if(r.includes(o))return!0}if(t.includes(o))return!0;const n=[...e.parentElement.children],s=n.findIndex(t=>t.isSameNode(e)),a=n.filter((e,t)=>t>s);if(a.length){if(a.includes(o))return!0;if(a.some(e=>[...e.querySelectorAll(i)].includes(o)))return!0}return!1});if(o&&this.isElementVisible(o.element)){const{selector:e,element:t,uniqueId:i}=o,r=this.targets.find(t=>t.selector===e&&t.uniqueId===i);r&&r.resolve(t),this.clear(e,i)}}mouseOverHandler(){const e=["mouseover",e=>setTimeout(()=>this.onMouseOver(e),50),!0];return{start:()=>document.addEventListener(...e),clear:()=>document.removeEventListener(...e)}}isElementVisible(e){return this.isElementTopmost(e)&&this.isElementOpaque(e)}isElementOpaque(e){return"HTML"===ce(e,e=>"0"===window.getComputedStyle(e).opacity).nodeName}isElementTopmost(e){const t=e.getBoundingClientRect(),o=[[t.left,t.top],[t.right,t.top],[t.left,t.bottom],[t.right,t.bottom],[t.left+t.width/2,t.top],[t.left+t.width/2,t.bottom],[t.left,t.height/2],[t.right,t.height/2],[t.left+t.left/2,t.height/2]];let i=!1,r=0;for(;!i&&r<o.length;){const t=document.elementFromPoint(...o[r]);i=e===t||e.contains(t),r+=1}return i}checkElements(){this.targets.forEach(({selector:e,uniqueId:t})=>{const o=document.querySelector(e);o&&!this.existingTargets.find(o=>o.element.matches(e)&&o.uniqueId===t)&&(this.existingTargets.push({element:o,selector:e,uniqueId:t}),this.visibilityObserver.observe(o))}),this.existingTargets=this.existingTargets.filter(({selector:e,element:t})=>!!document.querySelector(e)||(this.visibilityObserver.unobserve(t),!1)),this.inViewportTargets=this.inViewportTargets.filter(({selector:e,element:t,uniqueId:o})=>{if(t.matches(e)&&this.isElementVisible(t)){const i=this.targets.find(t=>t.selector===e&&t.uniqueId===o);return i&&i.resolve(t),this.clear(e,o),!1}return!0})}watch(e,t,o){this.targets.push({selector:e,resolve:t,uniqueId:o});const i=()=>{this.startMutationObserver(),this.checkElements()};document.body?i():le("body",i)}clear(e,t){[this.targets,this.existingTargets,this.inViewportTargets]=[this.targets,this.existingTargets,this.inViewportTargets].map(o=>o.filter(({selector:o,uniqueId:i})=>o!==e&&i!==t)),this.visibilityObserver.unobserve(document.querySelector(e)),0===this.targets.length&&this.mutationObserver.disconnect(),0===this.inViewportTargets.length&&this.mouseOverEvent.clear()}}class Se{constructor({triggerEvent:e,triggerSelector:t,triggerDelay:o}){this.event=e,this.selector=t&&t.length?t:"body",this.delay=1e3*o,this.elementsSelectors=[],this.eventsListeners=[],this.timeouts=[],this.intervals=[],this.observers=[],this.promises=[],this.visibilityObservers=[],this.elementsWaiters=[]}async onElementVisible({promise:e,resolve:o}){const i=ae(`${this.event}DomReady`);this.promises.push(i);const r=await this.onPageLoad(i),n=await ye("IntersectionObserver"),s=t("VisibilityObserver",Te);if(this.visibilityObservers.push(s),n&&r){const e=Z();s.watch(this.selector,o,e)}return e}onPageLoad({promise:e,resolve:t}){const o=()=>"complete"===document.readyState;if(!o()){const e=["readystatechange",()=>o()&&t(!0),{passive:!0}];this.eventsListeners.push(e),document.addEventListener(...e)}return t(!0),e}onClick({promise:e,resolve:t}){const o=document.createElement("style");o.type="text/css",o.id=`Click_${Z()}`,o.innerHTML=`${this.selector} {\n\t\t\tcursor: pointer !important;\n\t\t\tpointer-events: all !important;\n\t\t}`,document.head.appendChild(o),this.elementsSelectors.push(`#${o.id}`);const i=e=>[...document.querySelectorAll(this.selector)].some(t=>t.isSameNode(e)||!!e.closest(this.selector)),r=["click",({target:e})=>i(e)&&t(!0),{passive:!0,capture:!0}];return this.eventsListeners.push(r),document.addEventListener(...r),e}onExitIntent({promise:e,resolve:t}){const o=["mouseleave",async({clientY:e})=>{e<=0&&t(!0)},{passive:!0}],i=le("body",e=>{e.addEventListener(...o),this.eventsListeners.push([e,...o]),this.elementsWaiters=this.elementsWaiters.filter(e=>e!==i)});return this.elementsWaiters.push(i),e}onReengage({promise:e,resolve:t}){const o=this.delay;let i=o;const r=[()=>(i=o,i),{passive:!0}];["click","mousemove","scroll","keypress"].forEach(e=>{document.addEventListener(e,...r),this.eventsListeners.push([e,...r])});const n=setInterval(()=>{i<=0?t(!0):i-=100},100);return this.intervals.push(n),e}onCustomTrigger({promise:e,resolve:t}){const{triggerEventCustomScript:o}=DATA;return new Function(`return new Promise(async resolve => {${o}})`)().then(e=>e&&t(!0)),e}getSocialProofPurchases({promise:e,resolve:t}){const i=n(),r=o(),{viewInterval:s,triggerSocialProofMinPurchases:a,spNoTrim:l}=DATA;if(i||(re("Not able to find ABTastyProductKey, impossible to call the API."),t(!1)),i&&r){fetch(`${X}${r}/metrics/i?key=${i}${l?"&noTrim=true":""}`).then(e=>e.ok&&e.json()).then(e=>(e=>{if(void 0===s||void 0===a)return!1;const t=e[s]&&e[s]>=a;return t||re(`Widget will not be shown, product has been purchased ${e[s]} times while ${a} are required`),t})(e)&&t(e[s])).catch(()=>re("Failed to fetch datas from server."))}else t(!1);return e}getSocialProofPageViews({promise:e,resolve:t}){const i=encodeURIComponent(`${window.location.pathname}`),r=o(),{viewInterval:n,triggerSocialProofMinPageViews:s}=DATA;if(i&&r){fetch(`${X}${r}/metrics/pv?key=${i}`).then(e=>e.ok&&e.json()).then(e=>(e=>{if(void 0===n||void 0===s)return!1;const t=e[n]&&e[n]>=s;return t||re(`Widget will not be shown, page has been seen ${e[n]} times while ${s} are required`),t})(e)&&t(e[n])).catch(()=>re("Failed to fetch datas from server."))}else t(!1);return 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,...o]="string"==typeof e[0]?[document,...e]:e;t&&o.length>1&&t.removeEventListener(...o)}),this.eventsListeners=[]),this.timeouts.length&&(this.timeouts.forEach(e=>clearTimeout(e)),this.timeouts=[]),this.intervals.length&&(this.intervals.forEach(e=>clearInterval(e)),this.intervals=[]),this.observers.length&&(this.observers.forEach(e=>e.disconnect()),this.observers=[]),this.visibilityObservers.length){const e=Z();this.visibilityObservers.forEach(t=>t.clear(this.selector,e)),this.visibilityObservers=[]}return this.promises.length&&(this.promises.forEach(e=>e.resolve(!1)),this.promises=[]),this.elementsWaiters.length&&(this.elementsWaiters.forEach(e=>e.clear()),this.elementsWaiters=[]),this}async isTriggered(){this.clear();const e=ae(this.event);this.promises.push(e);const t={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),socialProofPurchases:()=>this.getSocialProofPurchases(e),socialProofPageViews:()=>this.getSocialProofPageViews(e)},o=!Object.prototype.hasOwnProperty.call(t,this.event)||await t[this.event]();this.clear();return"reengage"!==this.event&&this.delay?o&&await(async()=>{const e=ae(`${this.event}Delay`);return this.promises.push(e),setTimeout(()=>{e.resolve(!0),this.clear()},this.delay),e.promise})():o}}class $e{constructor(e,t,o){this.recurrence=e,this.isWidgetApplied=t,this.callback=o,this.observer=new MutationObserver(this.observerHandler.bind(this)),this.eventListenerParams=["abtasty_resetActionTracking",this.eventHandler.bind(this),{passive:!0}],this.elementsWaiters=[]}recurrenceIsDone(){return!this.recurrence||this.recurrence.isOver()}decisionHandler(e){const t=s(),{type:o}=this.recurrence?this.recurrence.getCurrentRecurrence():{type:!1},i=()=>e&&"display"===o||this.recurrenceIsDone();return!this.isWidgetApplied()&&t&&i()?(this.clearWatcher(),this.callback("rebuild",e)):(!this.isWidgetApplied()||t&&i())&&(this.isWidgetApplied()||t)||(this.clearWatcher(),this.callback("remove",e),this.watch()),this}eventHandler(){let e=s();return[250,500].forEach(t=>setTimeout(()=>500===t&&s()===e?this:(e=s(),this.decisionHandler(!1)),t)),this}observerHandler(e){const t=e.some(({removedNodes:e})=>e&&e.length),o=e.some(({addedNodes:e})=>e&&e.length);return t||o?(this.decisionHandler(!0),this):this}watch(){if(e())return this;this.clearWatcher(),document.addEventListener(...this.eventListenerParams);const t=le("body",e=>{const o=[e,{childList:!0,subtree:!0}];this.observer.observe(...o),this.elementsWaiters=this.elementsWaiters.filter(e=>e!==t)});return this.elementsWaiters.push(t),this}clearWatcher(){return document.removeEventListener(...this.eventListenerParams),this.elementsWaiters.length&&(this.elementsWaiters.forEach(e=>e.clear()),this.elementsWaiters=[]),this.observer.disconnect(),this}}class Ne{constructor(){this.children=void 0,this.uniqueId=Z(),this.widgetName=J(),this.prettyName=Q(),this.recurrenceParams=ee(),this.triggerParams=te(),this.recurrence=!!this.recurrenceParams&&new fe(this.recurrenceParams,this.clearGivenClearables.bind(this)),this.trigger=!!this.triggerParams&&new Se(this.triggerParams),this.pageWatcher=new $e(this.recurrence,this.isWidgetApplied.bind(this),this.onPageChange.bind(this)),this.hasOncePerPageTrigger=oe(),this.basicClassName=`ab_widget_container_${this.widgetName}`,this.widgetContainerId=`${this.basicClassName}_${this.uniqueId}`,this.contentClassName=`${this.basicClassName}_content`,this.overlayClassName=`${this.basicClassName}_overlay`,this.closeButtonClassName=`${this.basicClassName}_close_button`,this.hideClassName=`ab_hide_${this.uniqueId}`,this.domElement=this.getDom(),this.hasBeenShown=!1,this.closedByUser=!1,this.eventsListeners=[],this.timeouts=[],this.intervals=[],this.observers=[],this.promises=[],this.elementsWaiters=[]}clearGivenClearables(){this.eventsListeners.length&&(this.eventsListeners.forEach(e=>document.removeEventListener(...e)),this.eventsListeners=[]),this.timeouts.length&&(this.timeouts.forEach(e=>clearTimeout(e)),this.timeouts=[]),this.intervals.length&&(this.intervals.forEach(e=>clearInterval(e)),this.intervals=[]),this.observers.length&&(this.observers.forEach(e=>e.disconnect()),this.observers=[]),this.promises.length&&(this.promises.forEach(e=>e.resolve(!1)),this.promises=[]),this.elementsWaiters.length&&(this.elementsWaiters.forEach(e=>e.clear()),this.elementsWaiters=[])}isWidgetApplied(){return this.domElement&&!!this.domElement.closest("html")}removeOldDomElement(){const e=document.getElementById(this.widgetContainerId);return e&&e.remove(),this}async insert(){const e=(e,t,o)=>{this.elementsWaiters=this.elementsWaiters.filter(e=>e!==t),re(e),o(e)},t=new Promise((t,o)=>{const i=le("head",e=>{this.elementsWaiters=this.elementsWaiters.filter(e=>e!==i),t(e.appendChild(this.styleElement))},t=>e(t,i,o));this.elementsWaiters.push(i)}),o=new Promise((t,o)=>{const{layout:i,elementReferrer:r,referrerInsertType:n}=DATA,{selector:s,position:a}="string"==typeof i&&"free"===i&&"string"==typeof r&&"string"==typeof n?{selector:r,position:n}:{selector:"body",position:"beforeend"},l=le(s,e=>{this.elementsWaiters=this.elementsWaiters.filter(e=>e!==l),this.removeOldDomElement(),t(e.insertAdjacentElement(a,this.domElement))},t=>e(t,l,o));this.elementsWaiters.push(l)});return Promise.all([o,t]).then(()=>this)}remove(){return this.pageWatcher.clearWatcher(),this.domElement&&this.domElement.closest("html")&&this.domElement.remove(),this.styleElement&&this.styleElement.closest("html")&&this.styleElement.remove(),this.hasOncePerPageTrigger?this.pageWatcher.watch():e()||this.init().then(({response:e})=>e?this.show():this),this}show(){return this.hasBeenShown||e()||window.ABTastyEvent(`${this.prettyName} displayed`,null,TEST_ID),this.closedByUser=!1,this.domElement.classList.remove(this.hideClassName),this.recurrence&&this.recurrence.setDisplayRecurrence(),this.hasBeenShown=!0,this.pageWatcher.watch(),this}hide(){return this.hasBeenShown&&!e()&&window.ABTastyEvent(`${this.prettyName} closed`,null,TEST_ID),this.closedByUser=!0,this.domElement.classList.add(this.hideClassName),this}async init(t){if(!e()&&!s())return!1;if(this.trigger&&this.trigger.promises.length)return!1;const o=this.recurrence&&this.recurrence.isOver();if(this.recurrence&&!o)return this.pageWatcher.watch(),!1;this.pageWatcher.watch();const i=e()||!this.trigger||this.trigger&&await this.trigger.isTriggered();return!!i&&(await this.insert(),this.addCloseEvent(),e()||t||this.hasBeenShown||void 0===this.children||"function"!=typeof this.children.refreshContent||this.children.refreshContent(i),{container:this,response:i})}onPageChange(e,t){const o=()=>this.init().then(({response:e})=>e&&this.show());switch(t||(this.hasBeenShown=!1),e){case"remove":this.isWidgetApplied()?this.remove():(this.trigger&&this.trigger.clear(),this.pageWatcher.watch());break;case"rebuild":this.hasBeenShown?this.closedByUser?this.pageWatcher.watch():this.insert().then(e=>e.show()):o()}}addCloseEvent(...t){const{closeButton:o,overlayClickable:i,layout:r}=DATA,n=[];if(void 0!==i&&i&&void 0!==r&&"popin"===r&&n.push(`.${this.overlayClassName}`),void 0!==o&&o&&n.push(`.${this.closeButtonClassName}`),!n.length)return this;const s=this.domElement.querySelectorAll(n.join(", "));return s.length?(t.push(...s),t.forEach(t=>{e()&&(t.dataset.abtastyActionnable="true"),t.addEventListener("click",()=>{this.recurrence&&this.recurrence.setClosingRecurrence(),this.hide(),setTimeout(()=>this.remove(),1e3)},{passive:!0,once:!0})}),this):this}getDom(){const{closeButton:e,layout:t}=DATA,o=document.createElement("div");return o.className=`${this.basicClassName} ${this.hideClassName}`,o.id=this.widgetContainerId,o.innerHTML=`\n\t\t\t${void 0!==t&&"popin"===t?`<div class="${this.overlayClassName}"></div>`:""}\n\t\t\t<div class="${this.contentClassName}">\n\t\t\t\t${e?`<button class="${this.closeButtonClassName}"><svg viewBox="0 0 16 16">\n\t<defs><path id="prefix__a" d="M12 4.991L11.009 4 8 7.009 4.991 4 4 4.991 7.009 8 4 11.009 4.991 12 8 8.991 11.009 12 12 11.009 8.991 8z"></path></defs>\n\t<g><use xlink:href="#prefix__a"></use></g>\n</svg></button>`:""}\n\t\t\t</div>`,o}getStyleTag(t=""){const{noStyles:o,layout:i}=DATA,{backgroundColor:r,isBackgroundImage:n,backgroundImage:s,backgroundSize:a,backgroundPosition:l,backgroundRepeat:c,borderColor:d,borderRadius:g,borderWidth:h,textColor:u,textAlign:m,overlayColor:p,dropShadow:_,dropShadowColor:b,dropShadowBlur:y,containerMargin:v,containerPadding:w,closeButton:f,buttonsBorderWidth:T,buttonsBorderColor:S,buttonsBorderRadius:$,buttonsBackgroundColor:N,buttonsTextColor:E}=o?{}:DATA,C=document.createElement("style");C.type="text/css",e()&&C.setAttribute("abtasty-script-added","true");const A=["string"==typeof r?r:q,"string"==typeof s&&s.length?`url(${s})`:"","string"==typeof l&&"100% 100%"!==a?l:"0 0","string"==typeof a?`/ ${a}`:"/ auto",c&&!["cover","100% 100%"].includes(a)?"repeat":"no-repeat"],k=`background: ${n?A.join(" ").trim():q};`,x="number"==typeof h&&h>0,I=`border: ${[x?`${h}px`:"unset",x?"solid":"",x&&"string"==typeof d&&d.length?d:""].join(" ").trim()};`,P=void 0!==g?`border-radius: ${g}px;`:"",R=void 0!==u?`color: ${u}; fill: ${u};`:"",B=void 0!==m?`text-align: ${m};`:"",O=void 0!==_&&_?`box-shadow: 0 5px ${y}px 0 ${b};`:"",L=v instanceof Array&&1===v.length&&v[0],W=L?`margin: ${L.top}px ${L.right}px ${L.bottom}px ${L.left}px;`:"",D=L?`margin: calc(${L.top}px * 0.5) calc(${L.right}px * 0.5) calc(${L.bottom}px * 0.5) calc(${L.left}px * 0.5);`:"",V=w instanceof Array&&1===w.length&&w[0],U=V?`padding: ${V.top}px ${V.right}px ${V.bottom}px ${V.left}px;`:"",j=V?`padding: calc(${V.top}px * 0.5) calc(${V.right}px * 0.5) calc(${V.bottom}px * 0.5) calc(${V.left}px * 0.5);`:"",M=void 0!==T&&T?`border-width: ${T}px; border-style: solid;`:"",H=[S,T].every(e=>void 0!==e)&&T?`border-color: ${S};`:"",G=void 0!==$?`border-radius: ${$}px;`:"",z=void 0!==N?`background-color: ${N};`:"",K=void 0!==E?`color: ${E};`:"",Y=void 0!==i&&"popin"===i?[`#${this.widgetContainerId} .${this.overlayClassName} {`,`background-color: ${void 0!==p?p:"rgba(0, 0, 0, 0.6)"};`,"}"].join(""):"",F=o||void 0!==f&&f?[`#${this.widgetContainerId} .${this.contentClassName} .${this.closeButtonClassName} {`,"position: absolute;","top: 8px;","right: 8px;","width: auto;","height: auto;","background: none;","border: none;","cursor: pointer;","outline: none;","padding: 0;","margin: 0;","}",`#${this.widgetContainerId} .${this.contentClassName} .${this.closeButtonClassName} svg {`,"pointer-events: none;","width: 16px;","height: 16px;",R,"}"].join(""):"";return C.textContent=[`.${this.hideClassName} {`,"opacity: 0 !important;","pointer-events: none;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,k,P,I,R,B,O,W,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,"display: block;","line-height: 1;","text-indent: unset;",U,"}",`#${this.widgetContainerId} .${this.contentClassName} > * a, `,`#${this.widgetContainerId} .${this.contentClassName} > * button {`,M,H,G,z,K,"}","@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,D,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,j,"}","}",Y,F,`${t}`].join(""),C}}class Ee extends Ne{constructor(){super(),this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){return[`#${this.widgetContainerId} {`,"position: fixed;","top: 0;","left: 0;","width: 100%;","height: 100%;","z-index: 9999;","opacity: 1;","transition: opacity 0.25s ease;","}",`#${this.widgetContainerId} .${this.overlayClassName} {`,"position: absolute;","z-index: -1;","top: 0;","left: 0;","width: 100%;","height: 100%;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: absolute;","left: 50%;","top: 50%;","transform: translate(-50%, -50%);","width: auto;","height: auto;","}","@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,"max-width: 94vw;","}","}"].join("")}}class Ce extends Ne{constructor(){super(),this.position="string"==typeof DATA.layout&&"bannerTop"===DATA.layout?"top":"bottom",this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){return[`#${this.widgetContainerId} {`,"position: fixed;",`${this.position}: 0;`,"left: 0;","width: 100%;","height: auto;","z-index: 9999;","opacity: 1;","transition: opacity 0.25s ease;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: relative;","}"].join("")}}class Ae extends Ne{constructor(){super(),this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){return[`#${this.widgetContainerId} {`,"width: auto;","height: auto;","margin: 0;","padding: 0;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: relative;","}"].join("")}}const ke=()=>{const{layout:e}=DATA;let t;switch(e){case"popin":t=new Ee;break;case"bannerTop":case"bannerBottom":t=new Ce;break;case"free":t=new Ae;break;default:t=new Ne}return t},xe=[{label:"widget_common_conditions_recurrence_option_everyTime",value:"everytime"},{label:"widget_common_conditions_recurrence_option_everySession",value:"session"},{label:"widget_common_conditions_recurrence_option_everyXDays",value:"day"},{label:"widget_common_conditions_recurrence_option_everyXWeeks",value:"week"},{label:"widget_common_conditions_recurrence_option_everyXMonths",value:"month"},{label:"widget_common_conditions_recurrence_option_once",value:"once"}],Ie={category:g,type:I,min:1},Pe=[{...Ie,propName:"day",label:"widget_common_conditions_recurrence_ifOptionVariable_labelDays",value:5,max:395},{...Ie,propName:"week",label:"widget_common_conditions_recurrence_ifOptionVariable_labelWeeks",value:2,max:56},{...Ie,propName:"month",label:"widget_common_conditions_recurrence_ifOptionVariable_labelMonths",value:1,max:13}],Re={category:g,type:"select",options:xe,value:"everytime"},Be={...Re,label:"widget_common_conditions_recurrence_label_widgetDisplayed",propName:"displayRecurrence"},Oe=Pe.map(e=>({...e,propName:`${Be.propName}_${e.propName}`,conditions:[{field:Be.propName,value:e.propName}]})),Le={...Re,label:"widget_common_conditions_recurrence_label_widgetDisplayedAfterClosure",propName:"closingRecurrence"},We=Pe.map(e=>({...e,propName:`${Le.propName}_${e.propName}`,conditions:[{field:Le.propName,value:e.propName}]})),De={...Re,label:"widget_common_conditions_recurrence_label_widgetDisplayedAfterSubmission",propName:"validationRecurrence"},Ve=Pe.map(e=>({...e,propName:`${De.propName}_${e.propName}`,conditions:[{field:De.propName,value:e.propName}]})),Ue={category:g,type:B,label:"widget_common_conditions_recurrence_blockTitle",collapsible:!0,children:[Be,...Oe,Le,...We,De,...Ve]},qe={category:g,type:I,propName:"triggerEventDelay",label:"widget_common_conditions_triggering_delay_label",min:0,max:60,value:0},je={...qe,propName:"triggerEventReengageDelay",value:10,max:180},Me={category:g,type:"selectelement",propName:"triggerEventClick",value:"body"},He={...Me,propName:"triggerEventElementVisible"},Ge={category:g,type:"textarea",label:"widget_common_conditions_triggering_option_customTrigger",propName:"triggerEventCustomScript",value:"/* In this example snippet, the widget will be triggered as soon as any scroll is detected.\nCreate your own by resolving resolve() with true (which does trigger) or false (which doesn't trigger) */\n\nfunction launchIfScroll() {\n\treturn new Promise(resolve => {\n\t\tdocument.addEventListener('scroll', () => resolve(true), {once: true});\n\t});\n}\n\nconst result = await launchIfScroll();\nreturn resolve(result);",rows:15},ze={pageLoad:{label:"widget_common_conditions_triggering_option_pageload",value:"pageLoad"},direct:{label:"widget_common_conditions_triggering_option_asap",value:"direct"},exitIntent:{label:"widget_common_conditions_triggering_option_exitIntent",value:"exitIntent"},reengage:{label:"widget_common_conditions_triggering_option_afterXSecondsOfInactivity",value:"reengage"},click:{label:"widget_common_conditions_triggering_option_click",value:"click"},elementVisible:{label:"widget_common_conditions_triggering_option_elementVisible",value:"elementVisible"},customScript:{label:"widget_common_conditions_triggering_option_customTrigger",value:"script"}},Ke={category:g,type:x,propName:"isOncePerPageTrigger",value:!0,label:"widget_common_conditions_triggering_label_triggerOnlyOnce"},Ye={category:g,type:x,propName:"autoHide",value:!0,label:"widget_common_conditions_triggering_autohide_toggler_label_autoHideAfterRedirection"},Fe={category:g,type:I,propName:"timeHide",value:2,max:120,label:"widget_common_conditions_triggering_autohide_toggler_label_autoHideAfterXSeconds",conditions:[{field:"autoHide",value:!0}]},Xe={category:g,type:"select",label:"widget_common_conditions_triggering_label",options:Object.keys(ze).map(e=>ze[e]),propName:"triggerEvent",value:"pageLoad"};Me.conditions=[{field:"triggerEvent",value:"click"}],je.conditions=[{field:"triggerEvent",value:"reengage"}],He.conditions=[{field:"triggerEvent",value:"elementVisible"}],Ge.conditions=[{field:"triggerEvent",value:"script"}],qe.conditions=[{field:"triggerEvent",value:e=>"reengage"!==e}],Ke.conditions=[{field:"triggerEvent",value:e=>"click"===e||"script"===e}];const Je=[Me,He,Ge,Ke,je,qe],Qe={category:g,type:B,label:"widget_common_conditions_triggering_blockTitle",collapsible:!0,children:[Xe,...Je]};function Ze(e){const t=e.reduce((e,t)=>[...e,ze[t]],[]),o=Je.reduce((t,o)=>{const{conditions:i}=o;return i&&i.some(({value:t})=>e.includes(t))?[...t,o]:t},[]),i={...Xe,options:t,value:e[0]};return{category:g,type:B,label:"widget_common_conditions_triggering_blockTitle",collapsible:!0,children:[i,...o]}}const et={category:"content",propName:"button",type:x,value:!1,label:"widget_common_content_toggler_label_displayButton"},tt={category:"content",propName:"buttonText",type:"text",label:"widget_common_content_label_buttonText",value:"widget_common_content_buttonText_default"},ot={category:"content",propName:"buttonLink",type:"text",label:"widget_common_content_label_buttonUrl",value:location.origin,conditions:[{field:"button"}]},it={category:"content",propName:"buttonTargetType",type:x,label:"widget_common_content_button_label_openLinkNewTab",value:!1,conditions:[{field:"button"}]},rt=[{field:"button"}];tt.conditions=rt,ot.conditions=rt,it.conditions=rt;const nt={category:"content",type:B,label:"widget_common_tabName_content",collapsible:!1,children:[et,tt,ot,it]},st={category:"layout",type:"radioImage",propName:"layout",label:"widget_common_layout_label_selectALayout",value:"popin",style:"big",options:[{label:"widget_common_layout_option_modal",value:"popin",src:`${W}layout/icon-layout-modal.png`},{label:"widget_common_layout_option_topBanner",value:"bannerTop",src:`${W}layout/icon-layout-topBanner.png`},{label:"widget_common_layout_option_bottomBanner",value:"bannerBottom",src:`${W}layout/icon-layout-bottomBanner.png`},{label:"widget_common_layout_option_freePlacement",value:"free",src:`${W}layout/icon-layout-freePlacement.png`}]},at={category:"layout",type:"selectelement",propName:"elementReferrer",label:"widget_common_layout_label_selectElementContainWidget",value:"body"},lt={category:"layout",type:"radio",propName:"referrerInsertType",value:"afterbegin",label:"widget_common_layout_positioning_label_selectPosition",options:[{label:"widget_common_layout_positioning_option_before",value:"beforebegin"},{label:"widget_common_layout_positioning_option_atTheBeginning",value:"afterbegin"},{label:"widget_common_layout_positioning_option_atTheEnd",value:"beforeend"},{label:"widget_common_layout_positioning_option_after",value:"afterend"}]},ct=[{field:"layout",value:"free"}];at.conditions=ct,lt.conditions=ct;const dt={category:"layout",type:B,label:"widget_common_tabName_layout",collapsible:!0,children:[st,at,lt]},gt={category:l,type:"colorpicker",label:"widget_common_style_container_label_backgroundColor",propName:"backgroundColor",value:M},ht={category:l,type:x,label:"widget_common_style_toggler_label_backgroundImage",propName:"isBackgroundImage",value:!1},ut={category:l,type:"mediaupload",label:"widget_common_style_toggler_label_backgroundImage",propName:"backgroundImage",value:""},mt={category:l,type:"radio",label:"widget_common_style_backgroundImageUploader_imageOptions_label",propName:"backgroundSize",value:"cover",options:[{label:"widget_common_style_backgroundImageUploader_imageOptions_option_cover",value:"cover"},{label:"widget_common_style_backgroundImageUploader_imageOptions_option_contain",value:"contain"},{label:"widget_common_style_backgroundImageUploader_imageOptions_option_fill",value:"100% 100%"},{label:"widget_common_style_backgroundImageUploader_imageOptions_option_none",value:"auto"}]},pt={category:l,type:"select",label:"widget_common_style_backgroundImageUploader_imagePosition_select_label",propName:"backgroundPosition",value:"center",options:[{label:"widget_common_style_backgroundImageUploader_imagePosition_option_top",value:"top"},{label:"widget_common_style_backgroundImageUploader_imagePosition_option_bottom",value:"bottom"},{label:"widget_common_style_backgroundImageUploader_imagePosition_option_center",value:"center"},{label:"widget_common_style_backgroundImageUploader_imagePosition_option_left",value:"left"},{label:"widget_common_style_backgroundImageUploader_imagePosition_option_right",value:"right"},{label:"widget_common_style_backgroundImageUploader_imagePosition_option_topLeft",value:"top left"},{label:"widget_common_style_backgroundImageUploader_imagePosition_option_topRight",value:"top right"},{label:"widget_common_style_backgroundImageUploader_imagePosition_option_bottomLeft",value:"bottom left"},{label:"widget_common_style_backgroundImageUploader_imagePosition_option_bottomRight",value:"bottom right"}]},_t={category:l,type:x,label:"widget_common_style_backgroundImageUploader_toggler_repeatBackgroundImage",propName:"backgroundRepeat",value:!1},bt={category:l,type:"colorpicker",label:"widget_common_style_border_label_borderColor",propName:"borderColor",value:"rgba(0, 127, 145, 1)"},yt={category:l,type:I,label:"widget_common_style_border_label_borderRadius",propName:"borderRadius",value:4,unit:"px"},vt={category:l,type:I,label:"widget_common_style_border_label_borderThickness",propName:"borderWidth",value:2,min:0,max:50,unit:"px"},wt={category:l,type:"colorpicker",label:"widget_common_style_text_label_textColor",propName:"textColor",value:"rgba(57, 57, 57, 1)"},ft={category:l,type:"radioImage",label:"widget_common_style_text_label_textAlignment",propName:"textAlign",value:"center",style:"little",options:[{label:"widget_common_style_text_textAlignment_option_left",value:"left",src:`${W}style/icon-text-alignLeft.png`},{label:"widget_common_style_text_textAlignment_option_center",value:"center",src:`${W}style/icon-text-alignCenter.png`},{label:"widget_common_style_text_textAlignment_option_right",value:"right",src:`${W}style/icon-text-alignRight.png`}]},Tt={category:l,type:"areainput"},St={...Tt,label:"widget_common_style_container_label_margin",propName:"containerMargin",value:[{top:0,left:0,bottom:0,right:0}]},$t={...Tt,label:"widget_common_style_container_label_padding",propName:"containerPadding",value:[{top:35,left:60,bottom:35,right:60}]},Nt={category:l,type:x,label:"widget_common_style_container_dropShadow_blockTitle",propName:"dropShadow",value:!1},Et={category:l,type:"colorpicker",label:"widget_common_style_container_dropShadow_label_color",propName:"dropShadowColor",value:"rgba(57, 57, 57, 0.25);"},Ct={category:l,type:I,label:"widget_common_style_container_dropShadow_label_blurRadius",propName:"dropShadowBlur",value:10,unit:"px"},At={category:l,type:x,label:"widget_common_style_container_label_displayCloseButton",propName:"closeButton",value:!0},kt={category:l,type:"colorpicker",label:"widget_common_style_overlay_label_overlayColor",propName:"overlayColor",value:"rgba(0, 0, 0, 0.6)"},xt={category:l,type:x,label:"widget_common_style_overlay_label_overlayClickable",propName:"overlayClickable",value:!0},It={category:l,type:I,label:"widget_common_style_buttons_label_buttonBorderThickness",propName:"buttonsBorderWidth",value:1,min:0,max:30,unit:"px"},Pt={category:l,type:"colorpicker",label:"widget_common_style_buttons_label_buttonBorderColor",propName:"buttonsBorderColor",value:"rgba(87, 184, 199, 1)"},Rt={category:l,type:I,label:"widget_common_style_buttons_label_buttonBorderRadius",propName:"buttonsBorderRadius",value:4,min:0,max:30,unit:"px"},Bt={category:l,type:"colorpicker",label:"widget_common_style_buttons_label_buttonBackgroundColor",propName:"buttonsBackgroundColor",value:"rgba(0, 127, 145, 1)"},Ot={category:l,type:"colorpicker",label:"widget_common_style_buttons_label_buttonTextColor",propName:"buttonsTextColor",value:M},Lt={field:ht.propName,value:!0},Wt={field:mt.propName,value:e=>"cover"!==e},Dt={field:mt.propName,value:e=>"100% 100%"!==e};ut.conditions=[Lt],mt.conditions=[Lt],pt.conditions=[Lt,Dt],_t.conditions=[Lt,Dt,Wt];const Vt=[gt,ht,ut,mt,pt,_t],Ut={category:l,type:B,label:"widget_stickyElement_content_positionOn_option_background",collapsible:!0,children:Vt},qt=[{field:vt.propName,value:e=>e>0}];bt.conditions=qt;const jt={category:l,type:B,label:"widget_common_style_blockTitle_border",collapsible:!0,children:[vt,bt,yt]},Mt={category:l,type:B,label:"widget_common_style_blockTitle_text",collapsible:!0,children:[ft,wt]},Ht=[{field:"dropShadow",value:!0}];Et.conditions=Ht,Ct.conditions=Ht;const Gt={category:l,type:B,label:"widget_common_style_blockTitle_container",collapsible:!0,children:[St,$t,...Vt,Nt,Et,Ct,At]},zt={category:l,type:B,label:"widget_common_style_blockTitle_overlay",collapsible:!0,children:[kt,xt],conditions:[{field:"layout",value:"popin"}]},Kt=[{field:It.propName,value:e=>e>0}];Pt.conditions=Kt;const Yt={category:l,type:B,label:"widget_common_style_blockTitle_buttons",collapsible:!0,children:[It,Pt,Rt,Bt,Ot]};export{W as ABTASTY_IMAGES_ROUTE,O as AREAINPUT,j as BLACK,Ce as Banner,v as CHECKBOX,f as COLOR_PICKER,g as CONDITIONS,d as CONTENT,H as DARK_GRAY,G as DARK_TURQUOISE,T as DATE_PICKER,R as DATE_RANGE_PICKER,Ae as Free,B as GROUP,h as HIDDEN,L as INLINE_NOTIFICATION,c as LAYOUT,M as LIGHT_GREY,z as LIGHT_TURQUOISE,P as MEDIA_UPLOAD,$ as NUMBER,p as PARAGRAPH,$e as PageWatcher,Ee as Popin,A as RADIO_BUTTON,k as RADIO_IMAGE,U as REBUILD_WIDGET,V as REMOVE_WIDGET,fe as Recurrence,y as SELECT,C as SELECT_ELEMENT,u as SEPARATOR,m as SHORT_SEPARATOR,I as SLIDER,X as SOCIAL_PROOF_API_BASE,l as STYLE,x as SWITCH,D as TAG_RESET_EVENT,Y as TASTY_GREEN,K as TASTY_RED,F as TASTY_YELLOW,N as TEXT_AREA,_ as TEXT_FIELD,S as TIME_PICKER,Se as Trigger,b as URL_FIELD,E as VARIABLES_INPUT,q as WHITE,w as WYSIWYG,Ne as WidgetContainer,t as addGlobalUtil,ye as addPolyfill,he as allowGlobalScroll,_e as asyncRequest,Ye as autoHideForm,gt as backgroundColorForm,ut as backgroundImageForm,Ut as backgroundsGroup,Vt as backgroundsGroupChildren,bt as borderColorForm,yt as borderRadiusForm,vt as borderWidthForm,jt as bordersGroup,ot as buttonLinkForm,nt as buttonLinkGroup,it as buttonTargetTypeForm,tt as buttonTextForm,Bt as buttonsBackgroundColorForm,Pt as buttonsBorderColorForm,Rt as buttonsBorderRadiusForm,It as buttonsBorderWidthForm,Yt as buttonsGroup,Ot as buttonsTextColorForm,Le as closingRecurrenceForm,Gt as containerGroup,At as displayCloseButtonSwitchForm,Be as displayRecurrenceForm,Ct as dropShadowBlurForm,Et as dropShadowColorForm,Nt as dropShadowSwitchForm,at as elementReferrerForm,ce as findParent,o as getAccountIdentifier,we as getCookie,Ze as getCustomTriggersGroup,se as getGroupSettedValues,ne as getHostname,Q as getPrettyWidgetName,n as getProductKey,ee as getRecurrenceParams,te as getTriggerParams,Z as getUniqueId,r as getVisitorId,ke as getWidgetContainer,J as getWidgetName,s as isAffected,ht as isBackgroundImageForm,a as isInQaMode,e as isOnEditor,i as isOnPreview,me as isTouch,oe as isTriggerOncePerPage,dt as layoutGroup,st as layoutsForm,ue as loadImage,be as loadJS,ie as log,St as marginForm,xt as olverlayCloseOnClickForm,kt as overlayColorForm,zt as overlayGroup,$t as paddingForm,ge as preventGlobalScroll,ae as promiseDeferrer,Ue as recurrencesGroup,lt as referrerInsertTypeForm,ve as setCookie,et as switchButtonForm,pe as syncRequest,ft as textAlignmentForm,wt as textColorForm,Mt as textGroup,Fe as timeHideForm,qe as triggerDelay,Ge as triggerEventCustomScript,He as triggerEventElementVisible,je as triggerEventReengageDelay,Ke as triggerOncePerPage,Xe as triggersForm,Qe as triggersGroup,ze as triggersOptions,De as validationRecurrenceForm,le as waitForElement,re as widgetLog}; | ||
const e=()=>Object.prototype.hasOwnProperty.call(window,"ABTastyEditor");function t(e,t){return ABTasty.widgetUtils||(ABTasty.widgetUtils={}),ABTasty.widgetUtils[e]||Object.assign(ABTasty.widgetUtils,{[e]:new t}),ABTasty.widgetUtils[e]}const o=()=>{let e;return window.ABTasty||window.ABTASTY_S?(window.ABTASTY_S&&window.ABTASTY_S.USER&&window.ABTASTY_S.USER.accountIdentifier&&window.ABTASTY_S.USER.accountIdentifier.length?e=window.ABTASTY_S.USER.accountIdentifier:window.ABTasty&&window.ABTasty.getAccountSettings&&"function"==typeof window.ABTasty.getAccountSettings?e=window.ABTasty.getAccountSettings().identifier:window.ABTasty&&window.ABTasty.accountSettings&&(e=window.ABTasty.accountSettings.identifier),e):e},i=()=>{const e=!!document.getElementById("ABTastyPreviewBar"),t=location.href.includes("ab_project=preview");return e||t},r=()=>window.ABTasty&&window.ABTasty.visitor?window.ABTasty.visitor.id:void 0,n=()=>window.ABTastyProductKey,s=()=>!!window.ABTasty.getTestsOnPage()[TEST_ID]||i(),a=()=>{if(e())return!1;const t=ABTasty.getTestsOnPage()[TEST_ID];return!!t&&Object.keys(t.targetings.qaParameters).length>0},l="style",c="layout",d="content",g="conditions",h="hidden",u="separator",m="short-separator",p="paragraph",_="text",b="url",y="select",v="checkbox",w="wysiwyg",f="colorpicker",T="datepicker",S="timepicker",$="number",N="textarea",E="variablesinput",C="selectelement",A="radio",k="radioImage",x="switch",I="slider",P="mediaupload",R="dateRangePicker",B="group",O="areainput",L="inlinenotification",W="https://widgets-images.abtasty.com/",D="abtasty_resetActionTracking",V="remove",U="rebuild",q="rgba(255, 255, 255, 1)",j="rgba(0, 0, 0, 1)",M="rgba(247, 247, 247, 1)",H="rgba(57, 57, 57, 1)",G="rgba(0, 127, 145, 1)",z="rgba(87, 184, 199, 1)",K="rgba(213, 64, 64, 1)",Y="rgba(28, 191, 151, 1)",F="rgba(224, 185, 10, 1)",X="https://social-proof-api.abtasty.com/clients/",J=()=>{const{type:e}=DATA;return`${PACKAGE.replace("@abtasty/","")}${e?`_${e}`:""}`},Q=()=>{const e=J();return`${e.charAt(0).toUpperCase()}${e.slice(1)}`.split("-").join(" ")},Z=()=>`${PLUGIN_ID.split("-")[0]}_${TEST_ID}`,ee=()=>{const{displayRecurrence:t,closingRecurrence:o,validationRecurrence:i}=DATA;if(e()||!t&&!o&&!i)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`]},n={};return t&&(n.displayRecurrence=r[t]("displayRecurrence")),o&&(n.closingRecurrence=r[o]("closingRecurrence")),i&&(n.validationRecurrence=r[i]("validationRecurrence")),n},te=()=>{let{triggerEvent:t}=DATA;const{triggerEventClick:o,triggerEventReengageDelay:i,socialProofContentType:r,triggerEventElementVisible:n,triggerEventDelay:s}=DATA;if(e()||!t&&!r)return!1;const a={click:()=>o,elementVisible:()=>n},l=Object.prototype.hasOwnProperty.call(a,t)?a[t]():"body",c="reengage"===t?i:s;return r&&(t=1===r?"socialProofPurchases":"socialProofPageViews"),{triggerEvent:t,triggerSelector:l,triggerDelay:c}},oe=()=>{const{isOncePerPageTrigger:e,triggerEvent:t}=DATA;return!(!e||!["click","script"].includes(t))||["pageLoad","direct","reengage","socialProofPurchases","socialProofPageViews","elementVisible"].some(e=>e===t)},ie=(...e)=>{e.unshift(`[AB Tasty Widget] ${PACKAGE}:`),console.log(...e)},re=e=>{if(a()){const t=Q();window.console.log(`%c${t} - QA Mode for campaign ${TEST_ID}\n${e}`,`background-color: rgba(0, 127, 145, 1); color: ${M}`)}},ne=()=>{let e=document.location.hostname.split("").reverse().join("");if(e=e.match(/(?:[a-z]{2,4}\.[a-z]{2,3}|[a-z]{2,5})\.[a-z0-9-]+(?:\.|$)/i),null===e)e=document.location.hostname;else{"."!==e[0].substr(e[0].length-1)&&(e[0]+="."),e=e[0].split("").reverse().join("")}return e},se=(e,t)=>{if("object"!=typeof t)return e;const{type:o,children:i}=e,r=Object.keys(t);if(!r.length)return e;if("object"!=typeof e||!o||"group"!==o||!i||!Array.isArray(i)||Array.isArray(i)&&!i.length)return{};const n=i.map(e=>{const{propName:o,value:i}=e;return r.includes(o)&&typeof i==typeof t[o]?{...e,value:t[o]}:e});return{...e,children:n}},ae=e=>{const t={promise:null,resolve:null,reject:null,name:e};return t.promise=new Promise((e,o)=>{t.resolve=e,t.reject=o}),t},le=(e,t,o)=>{let i=0,r=0;try{document.querySelector(e)}catch(t){const i=`Selector «${e}» not valid.`;return ie(i),"function"==typeof o&&o(i)}function n(){clearInterval(r),clearTimeout(i)}return i=setTimeout(()=>{n();const t=`Can't find element «${e}».`;return ie(t),"function"==typeof o&&o(t)},1e4),r=setInterval(()=>{const o=document.querySelector(e);return null!==o?(n(),"function"==typeof t&&t(o)):o},200),{clear:n}};function ce(e,t){return t(e)||!e.parentElement?e:ce(e.parentElement,t)}let de;function ge(){le("body",()=>{const{body:e}=document;de=window.getComputedStyle(e).overflowY,e.style.overflowY="hidden"},e=>ie(e))}function he(){le("body",()=>{const{body:e}=document;de&&(e.style.overflowY=de)},e=>ie(e))}const ue=e=>new Promise((t,o)=>{const i=new Image;i.onload=()=>{t(i)},i.src=e,i.onerror=()=>{const t=new Error(`Image ${e} is not loaded.`);return o(t)}}),me=()=>void 0!==window.ontouchstart;function pe(e,t){const o=new XMLHttpRequest;return o.open(e,t,!1),o.send(null),o}function _e(e,t){return new Promise((o,i)=>{const r=new XMLHttpRequest;r.open(e,t,!0),r.onload=function(){this.status>=200&&this.status<300?o(r.response):i({status:this.status,statusText:r.statusText})},r.onerror=function(){i({status:this.status,statusText:r.statusText})},r.send()})}function be(e){return new Promise((t,o)=>{const i=window.document.getElementsByTagName("script")[0],r=window.document.createElement("script");r.src=e,i.parentNode.insertBefore(r,i),r.onload=t,r.onerror=o})}async function ye(e){let t;switch(e){case"IntersectionObserver":t=await("IntersectionObserver"in window&&"IntersectionObserverEntry"in window&&"intersectionRatio"in window.IntersectionObserverEntry.prototype||be("https://polyfill.io/v3/polyfill.min.js?flags=gated&features=IntersectionObserver"));break;default:t=!0}return t}const ve=(e,t,o)=>{let i="";if(o){const e=new Date;e.setTime(e.getTime()+24*o*60*60*1e3),i=`expires=${e.toUTCString()}`}const r=`domain=${ne()}`;document.cookie=`${e}=${t}; ${i};${r};path=/`},we=e=>{const t=`${e}=`,o=document.cookie.split(";");for(let e=0;e<o.length;e+=1){let i=o[e];for(;" "===i.charAt(0);)i=i.substring(1);if(0===i.indexOf(t))return i.substring(t.length,i.length)}return""};class fe{constructor({displayRecurrence:e,closingRecurrence:t,validationRecurrence:o},i){this.displayRecurrence=parseFloat(e),this.closingRecurrence=parseFloat(t),this.validationRecurrence=parseFloat(o),this.onSetCallback=i,this.widgetName=J(),this.uniqueId=Z(),this.recurrenceKey=`${this.widgetName}_${this.uniqueId}`}getGivenRecurrenceStorageParsed(e){try{const t=e.getItem("ABTastyWidgets");return JSON.parse(t)}catch(t){return e.removeItem("ABTastyWidgets"),!1}}getSessionRecurrenceStorageParsed(){return this.getGivenRecurrenceStorageParsed(window.sessionStorage)}getLocalRecurrenceStorageParsed(){return this.getGivenRecurrenceStorageParsed(window.localStorage)}removeGivenStorage(e,t){const{[this.recurrenceKey]:o,...i}=t;return Object.entries(i).length?(e.setItem("ABTastyWidgets",JSON.stringify(i)),i):(e.removeItem("ABTastyWidgets"),!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(){const e=this.getSessionRecurrence(),t=this.getLocalRecurrence();return e||t||{type:!1}}isOver(){const e=this.getLocalRecurrence(),t=(e?parseFloat(e.stamp):0)<(new Date).getTime();return t&&this.removeLocalRecurrenceStorage(),t&&!this.getLocalRecurrence()&&!this.getSessionRecurrence()}setRecurrence(e,t){const o=this.getTypeOfStorage(e);if(i()||!o&&"object"!=typeof o)return!1;const{storageString:r,storageMethod:n}=o,s=this.getStamp(e),a={type:t,stamp:s},{type:l}=this.getCurrentRecurrence(),c=()=>{const e=this.getSessionRecurrence(),t=this.getLocalRecurrence();let o;"session"===r?e?o=this.removeSessionRecurrenceStorage():(this.removeLocalRecurrenceStorage(),o=this.getSessionRecurrenceStorageParsed()):"local"===r&&(t?o=this.removeLocalRecurrenceStorage():(this.removeSessionRecurrenceStorage(),o=this.getLocalRecurrenceStorageParsed()));const i=o?{[this.recurrenceKey]:a,...o}:{[this.recurrenceKey]:a};n.setItem("ABTastyWidgets",JSON.stringify(i)),this.onSetCallback&&"function"==typeof this.onSetCallback&&this.onSetCallback()};if(!n)return!1;if(l&&"validation"!==t)if("closing"===t&&"validation"!==l)c();else{if("display"!==t||"validation"===l||"closing"===l)return!1;c()}else c();return s}setDisplayRecurrence(){this.setRecurrence(this.displayRecurrence,"display")}setClosingRecurrence(){this.setRecurrence(this.closingRecurrence,"closing")}setValidationRecurrence(){this.setRecurrence(this.validationRecurrence,"validation")}getStamp(e){return(new Date).getTime()+864e5*e}getTypeOfStorage(e){return!(isNaN(e)||e<0||0!==e&&!e)&&(e>0?{storageString:"local",storageMethod:window.localStorage}:0===e&&{storageString:"session",storageMethod:window.sessionStorage})}}class Te{constructor(){this.targets=[],this.existingTargets=[],this.inViewportTargets=[],this.visibilityObserver=this.startVisibilityObserver(),this.mutationObserver=this.startMutationObserver(),this.mouseOverEvent=this.mouseOverHandler()}intersectionHandler(e){e.forEach(e=>{e.isIntersecting?(this.existingTargets.forEach(t=>{t.element.isSameNode(e.target)&&(this.inViewportTargets.push(t),this.mouseOverEvent.start())}),this.checkElements()):this.inViewportTargets=this.inViewportTargets.filter(t=>!t.element.isSameNode(e.target)||(this.mouseOverEvent.clear(),!1))})}startVisibilityObserver(){return new IntersectionObserver(this.intersectionHandler.bind(this),{root:null,rootMargin:"0px",threshold:0})}startMutationObserver(){const e=this.mutationObserver||new MutationObserver(this.checkElements.bind(this));return document.body&&e.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),e}onMouseOver({target:e,path:t}){const o=this.inViewportTargets.find(({element:o,selector:i})=>{if(o.isSameNode(e))return!0;const r=[...e.querySelectorAll(i)];if(r.length){if(r.includes(o))return!0}if(t.includes(o))return!0;const n=[...e.parentElement.children],s=n.findIndex(t=>t.isSameNode(e)),a=n.filter((e,t)=>t>s);if(a.length){if(a.includes(o))return!0;if(a.some(e=>[...e.querySelectorAll(i)].includes(o)))return!0}return!1});if(o&&this.isElementVisible(o.element)){const{selector:e,element:t,uniqueId:i}=o,r=this.targets.find(t=>t.selector===e&&t.uniqueId===i);r&&r.resolve(t),this.clear(e,i)}}mouseOverHandler(){const e=["mouseover",e=>setTimeout(()=>this.onMouseOver(e),50),!0];return{start:()=>document.addEventListener(...e),clear:()=>document.removeEventListener(...e)}}isElementVisible(e){return this.isElementTopmost(e)&&this.isElementOpaque(e)}isElementOpaque(e){return"HTML"===ce(e,e=>"0"===window.getComputedStyle(e).opacity).nodeName}isElementTopmost(e){const t=e.getBoundingClientRect(),o=[[t.left,t.top],[t.right,t.top],[t.left,t.bottom],[t.right,t.bottom],[t.left+t.width/2,t.top],[t.left+t.width/2,t.bottom],[t.left,t.height/2],[t.right,t.height/2],[t.left+t.left/2,t.height/2]];let i=!1,r=0;for(;!i&&r<o.length;){const t=document.elementFromPoint(...o[r]);i=e===t||e.contains(t),r+=1}return i}checkElements(){this.targets.forEach(({selector:e,uniqueId:t})=>{const o=document.querySelector(e);o&&!this.existingTargets.find(o=>o.element.matches(e)&&o.uniqueId===t)&&(this.existingTargets.push({element:o,selector:e,uniqueId:t}),this.visibilityObserver.observe(o))}),this.existingTargets=this.existingTargets.filter(({selector:e,element:t})=>!!document.querySelector(e)||(this.visibilityObserver.unobserve(t),!1)),this.inViewportTargets=this.inViewportTargets.filter(({selector:e,element:t,uniqueId:o})=>{if(t.matches(e)&&this.isElementVisible(t)){const i=this.targets.find(t=>t.selector===e&&t.uniqueId===o);return i&&i.resolve(t),this.clear(e,o),!1}return!0})}watch(e,t,o){this.targets.push({selector:e,resolve:t,uniqueId:o});const i=()=>{this.startMutationObserver(),this.checkElements()};document.body?i():le("body",i)}clear(e,t){[this.targets,this.existingTargets,this.inViewportTargets]=[this.targets,this.existingTargets,this.inViewportTargets].map(o=>o.filter(({selector:o,uniqueId:i})=>o!==e&&i!==t)),this.visibilityObserver.unobserve(document.querySelector(e)),0===this.targets.length&&this.mutationObserver.disconnect(),0===this.inViewportTargets.length&&this.mouseOverEvent.clear()}}class Se{constructor({triggerEvent:e,triggerSelector:t,triggerDelay:o}){this.event=e,this.selector=t&&t.length?t:"body",this.delay=1e3*o,this.elementsSelectors=[],this.eventsListeners=[],this.timeouts=[],this.intervals=[],this.observers=[],this.promises=[],this.visibilityObservers=[],this.elementsWaiters=[]}async onElementVisible({promise:e,resolve:o}){const i=ae(`${this.event}DomReady`);this.promises.push(i);const r=await this.onPageLoad(i),n=await ye("IntersectionObserver"),s=t("VisibilityObserver",Te);if(this.visibilityObservers.push(s),n&&r){const e=Z();s.watch(this.selector,o,e)}return e}onPageLoad({promise:e,resolve:t}){const o=()=>"complete"===document.readyState;if(!o()){const i=["readystatechange",()=>o()&&t(!0),{passive:!0}];return this.eventsListeners.push(i),document.addEventListener(...i),e}return t(!0),e}onClick({promise:e,resolve:t}){const o=document.createElement("style");o.type="text/css",o.id=`Click_${Z()}`,o.innerHTML=`${this.selector} {\n\t\t\tcursor: pointer !important;\n\t\t\tpointer-events: all !important;\n\t\t}`,document.head.appendChild(o),this.elementsSelectors.push(`#${o.id}`);const i=e=>[...document.querySelectorAll(this.selector)].some(t=>t.isSameNode(e)||!!e.closest(this.selector)),r=["click",({target:e})=>i(e)&&t(!0),{passive:!0,capture:!0}];return this.eventsListeners.push(r),document.addEventListener(...r),e}onExitIntent({promise:e,resolve:t}){const o=["mouseleave",async({clientY:e})=>{e<=0&&t(!0)},{passive:!0}],i=le("body",e=>{e.addEventListener(...o),this.eventsListeners.push([e,...o]),this.elementsWaiters=this.elementsWaiters.filter(e=>e!==i)});return this.elementsWaiters.push(i),e}onReengage({promise:e,resolve:t}){const o=this.delay;let i=o;const r=[()=>(i=o,i),{passive:!0}];["click","mousemove","scroll","keypress"].forEach(e=>{document.addEventListener(e,...r),this.eventsListeners.push([e,...r])});const n=setInterval(()=>{i<=0?t(!0):i-=100},100);return this.intervals.push(n),e}onCustomTrigger({promise:e,resolve:t}){const{triggerEventCustomScript:o}=DATA;return new Function(`return new Promise(async resolve => {${o}})`)().then(e=>e&&t(!0)),e}getSocialProofPurchases({promise:e,resolve:t}){const i=n(),r=o(),{viewInterval:s,triggerSocialProofMinPurchases:a,spNoTrim:l}=DATA;if(i||(re("Not able to find ABTastyProductKey, impossible to call the API."),t(!1)),i&&r){fetch(`${X}${r}/metrics/i?key=${i}${l?"&noTrim=true":""}`).then(e=>e.ok&&e.json()).then(e=>(e=>{if(void 0===s||void 0===a)return!1;const t=e[s]&&e[s]>=a;return t||re(`Widget will not be shown, product has been purchased ${e[s]} times while ${a} are required`),t})(e)&&t(e[s])).catch(()=>re("Failed to fetch datas from server."))}else t(!1);return e}getSocialProofPageViews({promise:e,resolve:t}){const i=encodeURIComponent(`${window.location.pathname}`),r=o(),{viewInterval:n,triggerSocialProofMinPageViews:s}=DATA;if(i&&r){fetch(`${X}${r}/metrics/pv?key=${i}`).then(e=>e.ok&&e.json()).then(e=>(e=>{if(void 0===n||void 0===s)return!1;const t=e[n]&&e[n]>=s;return t||re(`Widget will not be shown, page has been seen ${e[n]} times while ${s} are required`),t})(e)&&t(e[n])).catch(()=>re("Failed to fetch datas from server."))}else t(!1);return 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,...o]="string"==typeof e[0]?[document,...e]:e;t&&o.length>1&&t.removeEventListener(...o)}),this.eventsListeners=[]),this.timeouts.length&&(this.timeouts.forEach(e=>clearTimeout(e)),this.timeouts=[]),this.intervals.length&&(this.intervals.forEach(e=>clearInterval(e)),this.intervals=[]),this.observers.length&&(this.observers.forEach(e=>e.disconnect()),this.observers=[]),this.visibilityObservers.length){const e=Z();this.visibilityObservers.forEach(t=>t.clear(this.selector,e)),this.visibilityObservers=[]}return this.promises.length&&(this.promises.forEach(e=>e.resolve(!1)),this.promises=[]),this.elementsWaiters.length&&(this.elementsWaiters.forEach(e=>e.clear()),this.elementsWaiters=[]),this}async isTriggered(){this.clear();const e=ae(this.event);this.promises.push(e);const t={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),socialProofPurchases:()=>this.getSocialProofPurchases(e),socialProofPageViews:()=>this.getSocialProofPageViews(e)},o=!Object.prototype.hasOwnProperty.call(t,this.event)||await t[this.event]();this.clear();return"reengage"!==this.event&&this.delay?o&&await(async()=>{const e=ae(`${this.event}Delay`);return this.promises.push(e),setTimeout(()=>{e.resolve(!0),this.clear()},this.delay),e.promise})():o}}class $e{constructor(e,t,o){this.recurrence=e,this.isWidgetApplied=t,this.callback=o,this.observer=new MutationObserver(this.observerHandler.bind(this)),this.eventListenerParams=["abtasty_resetActionTracking",this.eventHandler.bind(this),{passive:!0}],this.elementsWaiters=[]}recurrenceIsDone(){return!this.recurrence||this.recurrence.isOver()}decisionHandler(e){const t=s(),{type:o}=this.recurrence?this.recurrence.getCurrentRecurrence():{type:!1},i=()=>e&&"display"===o||this.recurrenceIsDone();return!this.isWidgetApplied()&&t&&i()?(this.clearWatcher(),this.callback("rebuild",e)):(!this.isWidgetApplied()||t&&i())&&(this.isWidgetApplied()||t)||(this.clearWatcher(),this.callback("remove",e),this.watch()),this}eventHandler(){let e=s();return[250,500].forEach(t=>setTimeout(()=>500===t&&s()===e?this:(e=s(),this.decisionHandler(!1)),t)),this}observerHandler(e){const t=e.some(({removedNodes:e})=>e&&e.length),o=e.some(({addedNodes:e})=>e&&e.length);return t||o?(this.decisionHandler(!0),this):this}watch(){if(e())return this;this.clearWatcher(),document.addEventListener(...this.eventListenerParams);const t=le("body",e=>{const o=[e,{childList:!0,subtree:!0}];this.observer.observe(...o),this.elementsWaiters=this.elementsWaiters.filter(e=>e!==t)});return this.elementsWaiters.push(t),this}clearWatcher(){return document.removeEventListener(...this.eventListenerParams),this.elementsWaiters.length&&(this.elementsWaiters.forEach(e=>e.clear()),this.elementsWaiters=[]),this.observer.disconnect(),this}}class Ne{constructor(){this.children=void 0,this.uniqueId=Z(),this.widgetName=J(),this.prettyName=Q(),this.recurrenceParams=ee(),this.triggerParams=te(),this.recurrence=!!this.recurrenceParams&&new fe(this.recurrenceParams,this.clearGivenClearables.bind(this)),this.trigger=!!this.triggerParams&&new Se(this.triggerParams),this.pageWatcher=new $e(this.recurrence,this.isWidgetApplied.bind(this),this.onPageChange.bind(this)),this.hasOncePerPageTrigger=oe(),this.basicClassName=`ab_widget_container_${this.widgetName}`,this.widgetContainerId=`${this.basicClassName}_${this.uniqueId}`,this.contentClassName=`${this.basicClassName}_content`,this.overlayClassName=`${this.basicClassName}_overlay`,this.closeButtonClassName=`${this.basicClassName}_close_button`,this.hideClassName=`ab_hide_${this.uniqueId}`,this.domElement=this.getDom(),this.hasBeenShown=!1,this.closedByUser=!1,this.eventsListeners=[],this.timeouts=[],this.intervals=[],this.observers=[],this.promises=[],this.elementsWaiters=[]}clearGivenClearables(){this.eventsListeners.length&&(this.eventsListeners.forEach(e=>document.removeEventListener(...e)),this.eventsListeners=[]),this.timeouts.length&&(this.timeouts.forEach(e=>clearTimeout(e)),this.timeouts=[]),this.intervals.length&&(this.intervals.forEach(e=>clearInterval(e)),this.intervals=[]),this.observers.length&&(this.observers.forEach(e=>e.disconnect()),this.observers=[]),this.promises.length&&(this.promises.forEach(e=>e.resolve(!1)),this.promises=[]),this.elementsWaiters.length&&(this.elementsWaiters.forEach(e=>e.clear()),this.elementsWaiters=[])}isWidgetApplied(){return this.domElement&&!!this.domElement.closest("html")}removeOldDomElement(){const e=document.getElementById(this.widgetContainerId);return e&&e.remove(),this}async insert(){const e=(e,t,o)=>{this.elementsWaiters=this.elementsWaiters.filter(e=>e!==t),re(e),o(e)},t=new Promise((t,o)=>{const i=le("head",e=>{this.elementsWaiters=this.elementsWaiters.filter(e=>e!==i),t(e.appendChild(this.styleElement))},t=>e(t,i,o));this.elementsWaiters.push(i)}),o=new Promise((t,o)=>{const{layout:i,elementReferrer:r,referrerInsertType:n}=DATA,{selector:s,position:a}="string"==typeof i&&"free"===i&&"string"==typeof r&&"string"==typeof n?{selector:r,position:n}:{selector:"body",position:"beforeend"},l=le(s,e=>{this.elementsWaiters=this.elementsWaiters.filter(e=>e!==l),this.removeOldDomElement(),t(e.insertAdjacentElement(a,this.domElement))},t=>e(t,l,o));this.elementsWaiters.push(l)});return Promise.all([o,t]).then(()=>this)}remove(){return this.pageWatcher.clearWatcher(),this.domElement&&this.domElement.closest("html")&&this.domElement.remove(),this.styleElement&&this.styleElement.closest("html")&&this.styleElement.remove(),this.hasOncePerPageTrigger?this.pageWatcher.watch():e()||this.init().then(({response:e})=>e?this.show():this),this}show(){return this.hasBeenShown||e()||window.ABTastyEvent(`${this.prettyName} displayed`,null,TEST_ID),this.closedByUser=!1,this.domElement.classList.remove(this.hideClassName),this.recurrence&&this.recurrence.setDisplayRecurrence(),this.hasBeenShown=!0,this.pageWatcher.watch(),this}hide(){return this.hasBeenShown&&!e()&&window.ABTastyEvent(`${this.prettyName} closed`,null,TEST_ID),this.closedByUser=!0,this.domElement.classList.add(this.hideClassName),this}async init(t){if(!e()&&!s())return!1;if(this.trigger&&this.trigger.promises.length)return!1;const o=this.recurrence&&this.recurrence.isOver();if(this.recurrence&&!o)return this.pageWatcher.watch(),!1;this.pageWatcher.watch();const i=e()||!this.trigger||this.trigger&&await this.trigger.isTriggered();return!!i&&(await this.insert(),this.addCloseEvent(),e()||t||this.hasBeenShown||void 0===this.children||"function"!=typeof this.children.refreshContent||this.children.refreshContent(i),{container:this,response:i})}onPageChange(e,t){const o=()=>this.init().then(({response:e})=>e&&this.show());switch(t||(this.hasBeenShown=!1),e){case"remove":this.isWidgetApplied()?this.remove():(this.trigger&&this.trigger.clear(),this.pageWatcher.watch());break;case"rebuild":this.hasBeenShown?this.closedByUser?this.pageWatcher.watch():this.insert().then(e=>e.show()):o()}}addCloseEvent(...t){const{closeButton:o,overlayClickable:i,layout:r}=DATA,n=[];if(void 0!==i&&i&&void 0!==r&&"popin"===r&&n.push(`.${this.overlayClassName}`),void 0!==o&&o&&n.push(`.${this.closeButtonClassName}`),!n.length)return this;const s=this.domElement.querySelectorAll(n.join(", "));return s.length?(t.push(...s),t.forEach(t=>{e()&&(t.dataset.abtastyActionnable="true"),t.addEventListener("click",()=>{this.recurrence&&this.recurrence.setClosingRecurrence(),this.hide(),setTimeout(()=>this.remove(),1e3)},{passive:!0,once:!0})}),this):this}getDom(){const{closeButton:e,layout:t}=DATA,o=document.createElement("div");return o.className=`${this.basicClassName} ${this.hideClassName}`,o.id=this.widgetContainerId,o.innerHTML=`\n\t\t\t${void 0!==t&&"popin"===t?`<div class="${this.overlayClassName}"></div>`:""}\n\t\t\t<div class="${this.contentClassName}">\n\t\t\t\t${e?`<button class="${this.closeButtonClassName}"><svg viewBox="0 0 16 16">\n\t<defs><path id="prefix__a" d="M12 4.991L11.009 4 8 7.009 4.991 4 4 4.991 7.009 8 4 11.009 4.991 12 8 8.991 11.009 12 12 11.009 8.991 8z"></path></defs>\n\t<g><use xlink:href="#prefix__a"></use></g>\n</svg></button>`:""}\n\t\t\t</div>`,o}getStyleTag(t=""){const{noStyles:o,layout:i}=DATA,{backgroundColor:r,isBackgroundImage:n,backgroundImage:s,backgroundSize:a,backgroundPosition:l,backgroundRepeat:c,borderColor:d,borderRadius:g,borderWidth:h,textColor:u,textAlign:m,overlayColor:p,dropShadow:_,dropShadowColor:b,dropShadowBlur:y,containerMargin:v,containerPadding:w,closeButton:f,buttonsBorderWidth:T,buttonsBorderColor:S,buttonsBorderRadius:$,buttonsBackgroundColor:N,buttonsTextColor:E}=o?{}:DATA,C=document.createElement("style");C.type="text/css",e()&&C.setAttribute("abtasty-script-added","true");const A=`background: ${["string"==typeof r?r:q,n&&"string"==typeof s&&s.length?`url(${s})`:"",n&&"string"==typeof l&&"100% 100%"!==a?l:"0 0",n&&"string"==typeof a?`/ ${a}`:"/ auto",n&&c&&!["cover","100% 100%"].includes(a)?"repeat":"no-repeat"].join(" ").trim()};`,k="number"==typeof h&&h>0,x=`border: ${[k?`${h}px`:"unset",k?"solid":"",k&&"string"==typeof d&&d.length?d:""].join(" ").trim()};`,I=void 0!==g?`border-radius: ${g}px;`:"",P=void 0!==u?`color: ${u}; fill: ${u};`:"",R=void 0!==m?`text-align: ${m};`:"",B=void 0!==_&&_?`box-shadow: 0 5px ${y}px 0 ${b};`:"",O=v instanceof Array&&1===v.length&&v[0],L=O?`margin: ${O.top}px ${O.right}px ${O.bottom}px ${O.left}px;`:"",W=O?`margin: calc(${O.top}px * 0.5) calc(${O.right}px * 0.5) calc(${O.bottom}px * 0.5) calc(${O.left}px * 0.5);`:"",D=w instanceof Array&&1===w.length&&w[0],V=D?`padding: ${D.top}px ${D.right}px ${D.bottom}px ${D.left}px;`:"",U=D?`padding: calc(${D.top}px * 0.5) calc(${D.right}px * 0.5) calc(${D.bottom}px * 0.5) calc(${D.left}px * 0.5);`:"",j=void 0!==T&&T?`border-width: ${T}px; border-style: solid;`:"",M=[S,T].every(e=>void 0!==e)&&T?`border-color: ${S};`:"",H=void 0!==$?`border-radius: ${$}px;`:"",G=void 0!==N?`background-color: ${N};`:"",z=void 0!==E?`color: ${E};`:"",K=void 0!==i&&"popin"===i?[`#${this.widgetContainerId} .${this.overlayClassName} {`,`background-color: ${void 0!==p?p:"rgba(0, 0, 0, 0.6)"};`,"}"].join(""):"",Y=o||void 0!==f&&f?[`#${this.widgetContainerId} .${this.contentClassName} .${this.closeButtonClassName} {`,"position: absolute;","top: 8px;","right: 8px;","width: auto;","height: auto;","background: none;","border: none;","cursor: pointer;","outline: none;","padding: 0;","margin: 0;","}",`#${this.widgetContainerId} .${this.contentClassName} .${this.closeButtonClassName} svg {`,"pointer-events: none;","width: 16px;","height: 16px;",P,"}"].join(""):"";return C.textContent=[`.${this.hideClassName} {`,"opacity: 0 !important;","pointer-events: none;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,A,I,x,P,R,B,L,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,"display: block;","line-height: 1;","text-indent: unset;",V,"}",`#${this.widgetContainerId} .${this.contentClassName} > * a, `,`#${this.widgetContainerId} .${this.contentClassName} > * button {`,j,M,H,G,z,"}","@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,W,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,U,"}","}",K,Y,`${t}`].join(""),C}}class Ee extends Ne{constructor(){super(),this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){return[`#${this.widgetContainerId} {`,"position: fixed;","top: 0;","left: 0;","width: 100%;","height: 100%;","z-index: 9999;","opacity: 1;","transition: opacity 0.25s ease;","}",`#${this.widgetContainerId} .${this.overlayClassName} {`,"position: absolute;","z-index: -1;","top: 0;","left: 0;","width: 100%;","height: 100%;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: absolute;","left: 50%;","top: 50%;","transform: translate(-50%, -50%);","width: auto;","height: auto;","}","@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,"max-width: 94vw;","}","}"].join("")}}class Ce extends Ne{constructor(){super(),this.position="string"==typeof DATA.layout&&"bannerTop"===DATA.layout?"top":"bottom",this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){return[`#${this.widgetContainerId} {`,"position: fixed;",`${this.position}: 0;`,"left: 0;","width: 100%;","height: auto;","z-index: 9999;","opacity: 1;","transition: opacity 0.25s ease;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: relative;","}"].join("")}}class Ae extends Ne{constructor(){super(),this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){return[`#${this.widgetContainerId} {`,"width: auto;","height: auto;","margin: 0;","padding: 0;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: relative;","}"].join("")}}const ke=()=>{const{layout:e}=DATA;let t;switch(e){case"popin":t=new Ee;break;case"bannerTop":case"bannerBottom":t=new Ce;break;case"free":t=new Ae;break;default:t=new Ne}return t},xe=[{label:"widget_common_conditions_recurrence_option_everyTime",value:"everytime"},{label:"widget_common_conditions_recurrence_option_everySession",value:"session"},{label:"widget_common_conditions_recurrence_option_everyXDays",value:"day"},{label:"widget_common_conditions_recurrence_option_everyXWeeks",value:"week"},{label:"widget_common_conditions_recurrence_option_everyXMonths",value:"month"},{label:"widget_common_conditions_recurrence_option_once",value:"once"}],Ie={category:g,type:I,min:1},Pe=[{...Ie,propName:"day",label:"widget_common_conditions_recurrence_ifOptionVariable_labelDays",value:5,max:395},{...Ie,propName:"week",label:"widget_common_conditions_recurrence_ifOptionVariable_labelWeeks",value:2,max:56},{...Ie,propName:"month",label:"widget_common_conditions_recurrence_ifOptionVariable_labelMonths",value:1,max:13}],Re={category:g,type:"select",options:xe,value:"everytime"},Be={...Re,label:"widget_common_conditions_recurrence_label_widgetDisplayed",propName:"displayRecurrence"},Oe=Pe.map(e=>({...e,propName:`${Be.propName}_${e.propName}`,conditions:[{field:Be.propName,value:e.propName}]})),Le={...Re,label:"widget_common_conditions_recurrence_label_widgetDisplayedAfterClosure",propName:"closingRecurrence"},We=Pe.map(e=>({...e,propName:`${Le.propName}_${e.propName}`,conditions:[{field:Le.propName,value:e.propName}]})),De={...Re,label:"widget_common_conditions_recurrence_label_widgetDisplayedAfterSubmission",propName:"validationRecurrence"},Ve=Pe.map(e=>({...e,propName:`${De.propName}_${e.propName}`,conditions:[{field:De.propName,value:e.propName}]})),Ue={category:g,type:B,label:"widget_common_conditions_recurrence_blockTitle",collapsible:!0,children:[Be,...Oe,Le,...We,De,...Ve]},qe={category:g,type:I,propName:"triggerEventDelay",label:"widget_common_conditions_triggering_delay_label",min:0,max:60,value:0},je={...qe,propName:"triggerEventReengageDelay",value:10,max:180},Me={category:g,type:"selectelement",propName:"triggerEventClick",value:"body"},He={...Me,propName:"triggerEventElementVisible"},Ge={category:g,type:"textarea",label:"widget_common_conditions_triggering_option_customTrigger",propName:"triggerEventCustomScript",value:"/* In this example snippet, the widget will be triggered as soon as any scroll is detected.\nCreate your own by resolving resolve() with true (which does trigger) or false (which doesn't trigger) */\n\nfunction launchIfScroll() {\n\treturn new Promise(resolve => {\n\t\tdocument.addEventListener('scroll', () => resolve(true), {once: true});\n\t});\n}\n\nconst result = await launchIfScroll();\nreturn resolve(result);",rows:15},ze={pageLoad:{label:"widget_common_conditions_triggering_option_pageload",value:"pageLoad"},direct:{label:"widget_common_conditions_triggering_option_asap",value:"direct"},exitIntent:{label:"widget_common_conditions_triggering_option_exitIntent",value:"exitIntent"},reengage:{label:"widget_common_conditions_triggering_option_afterXSecondsOfInactivity",value:"reengage"},click:{label:"widget_common_conditions_triggering_option_click",value:"click"},elementVisible:{label:"widget_common_conditions_triggering_option_elementVisible",value:"elementVisible"},customScript:{label:"widget_common_conditions_triggering_option_customTrigger",value:"script"}},Ke={category:g,type:x,propName:"isOncePerPageTrigger",value:!0,label:"widget_common_conditions_triggering_label_triggerOnlyOnce"},Ye={category:g,type:x,propName:"autoHide",value:!0,label:"widget_common_conditions_triggering_autohide_toggler_label_autoHideAfterRedirection"},Fe={category:g,type:I,propName:"timeHide",value:2,max:120,label:"widget_common_conditions_triggering_autohide_toggler_label_autoHideAfterXSeconds",conditions:[{field:"autoHide",value:!0}]},Xe={category:g,type:"select",label:"widget_common_conditions_triggering_label",options:Object.keys(ze).map(e=>ze[e]),propName:"triggerEvent",value:"pageLoad"};Me.conditions=[{field:"triggerEvent",value:"click"}],je.conditions=[{field:"triggerEvent",value:"reengage"}],He.conditions=[{field:"triggerEvent",value:"elementVisible"}],Ge.conditions=[{field:"triggerEvent",value:"script"}],qe.conditions=[{field:"triggerEvent",value:e=>"reengage"!==e}],Ke.conditions=[{field:"triggerEvent",value:e=>"click"===e||"script"===e}];const Je=[Me,He,Ge,Ke,je,qe],Qe={category:g,type:B,label:"widget_common_conditions_triggering_blockTitle",collapsible:!0,children:[Xe,...Je]};function Ze(e){const t=e.reduce((e,t)=>[...e,ze[t]],[]),o=Je.reduce((t,o)=>{const{conditions:i}=o;return i&&i.some(({value:t})=>e.includes(t))?[...t,o]:t},[]),i={...Xe,options:t,value:e[0]};return{category:g,type:B,label:"widget_common_conditions_triggering_blockTitle",collapsible:!0,children:[i,...o]}}const et={category:"content",propName:"button",type:x,value:!1,label:"widget_common_content_toggler_label_displayButton"},tt={category:"content",propName:"buttonText",type:"text",label:"widget_common_content_label_buttonText",value:"widget_common_content_buttonText_default"},ot={category:"content",propName:"buttonLink",type:"text",label:"widget_common_content_label_buttonUrl",value:location.origin,conditions:[{field:"button"}]},it={category:"content",propName:"buttonTargetType",type:x,label:"widget_common_content_button_label_openLinkNewTab",value:!1,conditions:[{field:"button"}]},rt=[{field:"button"}];tt.conditions=rt,ot.conditions=rt,it.conditions=rt;const nt={category:"content",type:B,label:"widget_common_tabName_content",collapsible:!1,children:[et,tt,ot,it]},st={category:"layout",type:"radioImage",propName:"layout",label:"widget_common_layout_label_selectALayout",value:"popin",style:"big",options:[{label:"widget_common_layout_option_modal",value:"popin",src:`${W}layout/icon-layout-modal.png`},{label:"widget_common_layout_option_topBanner",value:"bannerTop",src:`${W}layout/icon-layout-topBanner.png`},{label:"widget_common_layout_option_bottomBanner",value:"bannerBottom",src:`${W}layout/icon-layout-bottomBanner.png`},{label:"widget_common_layout_option_freePlacement",value:"free",src:`${W}layout/icon-layout-freePlacement.png`}]},at={category:"layout",type:"selectelement",propName:"elementReferrer",label:"widget_common_layout_label_selectElementContainWidget",value:"body"},lt={category:"layout",type:"radio",propName:"referrerInsertType",value:"afterbegin",label:"widget_common_layout_positioning_label_selectPosition",options:[{label:"widget_common_layout_positioning_option_before",value:"beforebegin"},{label:"widget_common_layout_positioning_option_atTheBeginning",value:"afterbegin"},{label:"widget_common_layout_positioning_option_atTheEnd",value:"beforeend"},{label:"widget_common_layout_positioning_option_after",value:"afterend"}]},ct=[{field:"layout",value:"free"}];at.conditions=ct,lt.conditions=ct;const dt={category:"layout",type:B,label:"widget_common_tabName_layout",collapsible:!0,children:[st,at,lt]},gt={category:l,type:"colorpicker",label:"widget_common_style_container_label_backgroundColor",propName:"backgroundColor",value:M},ht={category:l,type:x,label:"widget_common_style_toggler_label_backgroundImage",propName:"isBackgroundImage",value:!1},ut={category:l,type:"mediaupload",label:"widget_common_style_toggler_label_backgroundImage",propName:"backgroundImage",value:""},mt={category:l,type:"radio",label:"widget_common_style_backgroundImageUploader_imageOptions_label",propName:"backgroundSize",value:"cover",options:[{label:"widget_common_style_backgroundImageUploader_imageOptions_option_cover",value:"cover"},{label:"widget_common_style_backgroundImageUploader_imageOptions_option_contain",value:"contain"},{label:"widget_common_style_backgroundImageUploader_imageOptions_option_fill",value:"100% 100%"},{label:"widget_common_style_backgroundImageUploader_imageOptions_option_none",value:"auto"}]},pt={category:l,type:"select",label:"widget_common_style_backgroundImageUploader_imagePosition_select_label",propName:"backgroundPosition",value:"center",options:[{label:"widget_common_style_backgroundImageUploader_imagePosition_option_top",value:"top"},{label:"widget_common_style_backgroundImageUploader_imagePosition_option_bottom",value:"bottom"},{label:"widget_common_style_backgroundImageUploader_imagePosition_option_center",value:"center"},{label:"widget_common_style_backgroundImageUploader_imagePosition_option_left",value:"left"},{label:"widget_common_style_backgroundImageUploader_imagePosition_option_right",value:"right"},{label:"widget_common_style_backgroundImageUploader_imagePosition_option_topLeft",value:"top left"},{label:"widget_common_style_backgroundImageUploader_imagePosition_option_topRight",value:"top right"},{label:"widget_common_style_backgroundImageUploader_imagePosition_option_bottomLeft",value:"bottom left"},{label:"widget_common_style_backgroundImageUploader_imagePosition_option_bottomRight",value:"bottom right"}]},_t={category:l,type:x,label:"widget_common_style_backgroundImageUploader_toggler_repeatBackgroundImage",propName:"backgroundRepeat",value:!1},bt={category:l,type:"colorpicker",label:"widget_common_style_border_label_borderColor",propName:"borderColor",value:"rgba(0, 127, 145, 1)"},yt={category:l,type:I,label:"widget_common_style_border_label_borderRadius",propName:"borderRadius",value:4,unit:"px"},vt={category:l,type:I,label:"widget_common_style_border_label_borderThickness",propName:"borderWidth",value:2,min:0,max:50,unit:"px"},wt={category:l,type:"colorpicker",label:"widget_common_style_text_label_textColor",propName:"textColor",value:"rgba(57, 57, 57, 1)"},ft={category:l,type:"radioImage",label:"widget_common_style_text_label_textAlignment",propName:"textAlign",value:"center",style:"little",options:[{label:"widget_common_style_text_textAlignment_option_left",value:"left",src:`${W}style/icon-text-alignLeft.png`},{label:"widget_common_style_text_textAlignment_option_center",value:"center",src:`${W}style/icon-text-alignCenter.png`},{label:"widget_common_style_text_textAlignment_option_right",value:"right",src:`${W}style/icon-text-alignRight.png`}]},Tt={category:l,type:"areainput"},St={...Tt,label:"widget_common_style_container_label_margin",propName:"containerMargin",value:[{top:0,left:0,bottom:0,right:0}]},$t={...Tt,label:"widget_common_style_container_label_padding",propName:"containerPadding",value:[{top:35,left:60,bottom:35,right:60}]},Nt={category:l,type:x,label:"widget_common_style_container_dropShadow_blockTitle",propName:"dropShadow",value:!1},Et={category:l,type:"colorpicker",label:"widget_common_style_container_dropShadow_label_color",propName:"dropShadowColor",value:"rgba(57, 57, 57, 0.25);"},Ct={category:l,type:I,label:"widget_common_style_container_dropShadow_label_blurRadius",propName:"dropShadowBlur",value:10,unit:"px"},At={category:l,type:x,label:"widget_common_style_container_label_displayCloseButton",propName:"closeButton",value:!0},kt={category:l,type:"colorpicker",label:"widget_common_style_overlay_label_overlayColor",propName:"overlayColor",value:"rgba(0, 0, 0, 0.6)"},xt={category:l,type:x,label:"widget_common_style_overlay_label_overlayClickable",propName:"overlayClickable",value:!0},It={category:l,type:I,label:"widget_common_style_buttons_label_buttonBorderThickness",propName:"buttonsBorderWidth",value:1,min:0,max:30,unit:"px"},Pt={category:l,type:"colorpicker",label:"widget_common_style_buttons_label_buttonBorderColor",propName:"buttonsBorderColor",value:"rgba(87, 184, 199, 1)"},Rt={category:l,type:I,label:"widget_common_style_buttons_label_buttonBorderRadius",propName:"buttonsBorderRadius",value:4,min:0,max:30,unit:"px"},Bt={category:l,type:"colorpicker",label:"widget_common_style_buttons_label_buttonBackgroundColor",propName:"buttonsBackgroundColor",value:"rgba(0, 127, 145, 1)"},Ot={category:l,type:"colorpicker",label:"widget_common_style_buttons_label_buttonTextColor",propName:"buttonsTextColor",value:M},Lt={field:ht.propName,value:!0},Wt={field:mt.propName,value:e=>"cover"!==e},Dt={field:mt.propName,value:e=>"100% 100%"!==e};ut.conditions=[Lt],mt.conditions=[Lt],pt.conditions=[Lt,Dt],_t.conditions=[Lt,Dt,Wt];const Vt=[gt,ht,ut,mt,pt,_t],Ut={category:l,type:B,label:"widget_stickyElement_content_positionOn_option_background",collapsible:!0,children:Vt},qt=[{field:vt.propName,value:e=>e>0}];bt.conditions=qt;const jt={category:l,type:B,label:"widget_common_style_blockTitle_border",collapsible:!0,children:[vt,bt,yt]},Mt={category:l,type:B,label:"widget_common_style_blockTitle_text",collapsible:!0,children:[ft,wt]},Ht=[{field:"dropShadow",value:!0}];Et.conditions=Ht,Ct.conditions=Ht;const Gt={category:l,type:B,label:"widget_common_style_blockTitle_container",collapsible:!0,children:[St,$t,...Vt,Nt,Et,Ct,At]},zt={category:l,type:B,label:"widget_common_style_blockTitle_overlay",collapsible:!0,children:[kt,xt],conditions:[{field:"layout",value:"popin"}]},Kt=[{field:It.propName,value:e=>e>0}];Pt.conditions=Kt;const Yt={category:l,type:B,label:"widget_common_style_blockTitle_buttons",collapsible:!0,children:[It,Pt,Rt,Bt,Ot]};export{W as ABTASTY_IMAGES_ROUTE,O as AREAINPUT,j as BLACK,Ce as Banner,v as CHECKBOX,f as COLOR_PICKER,g as CONDITIONS,d as CONTENT,H as DARK_GRAY,G as DARK_TURQUOISE,T as DATE_PICKER,R as DATE_RANGE_PICKER,Ae as Free,B as GROUP,h as HIDDEN,L as INLINE_NOTIFICATION,c as LAYOUT,M as LIGHT_GREY,z as LIGHT_TURQUOISE,P as MEDIA_UPLOAD,$ as NUMBER,p as PARAGRAPH,$e as PageWatcher,Ee as Popin,A as RADIO_BUTTON,k as RADIO_IMAGE,U as REBUILD_WIDGET,V as REMOVE_WIDGET,fe as Recurrence,y as SELECT,C as SELECT_ELEMENT,u as SEPARATOR,m as SHORT_SEPARATOR,I as SLIDER,X as SOCIAL_PROOF_API_BASE,l as STYLE,x as SWITCH,D as TAG_RESET_EVENT,Y as TASTY_GREEN,K as TASTY_RED,F as TASTY_YELLOW,N as TEXT_AREA,_ as TEXT_FIELD,S as TIME_PICKER,Se as Trigger,b as URL_FIELD,E as VARIABLES_INPUT,q as WHITE,w as WYSIWYG,Ne as WidgetContainer,t as addGlobalUtil,ye as addPolyfill,he as allowGlobalScroll,_e as asyncRequest,Ye as autoHideForm,gt as backgroundColorForm,ut as backgroundImageForm,Ut as backgroundsGroup,Vt as backgroundsGroupChildren,bt as borderColorForm,yt as borderRadiusForm,vt as borderWidthForm,jt as bordersGroup,ot as buttonLinkForm,nt as buttonLinkGroup,it as buttonTargetTypeForm,tt as buttonTextForm,Bt as buttonsBackgroundColorForm,Pt as buttonsBorderColorForm,Rt as buttonsBorderRadiusForm,It as buttonsBorderWidthForm,Yt as buttonsGroup,Ot as buttonsTextColorForm,Le as closingRecurrenceForm,Gt as containerGroup,At as displayCloseButtonSwitchForm,Be as displayRecurrenceForm,Ct as dropShadowBlurForm,Et as dropShadowColorForm,Nt as dropShadowSwitchForm,at as elementReferrerForm,ce as findParent,o as getAccountIdentifier,we as getCookie,Ze as getCustomTriggersGroup,se as getGroupSettedValues,ne as getHostname,Q as getPrettyWidgetName,n as getProductKey,ee as getRecurrenceParams,te as getTriggerParams,Z as getUniqueId,r as getVisitorId,ke as getWidgetContainer,J as getWidgetName,s as isAffected,ht as isBackgroundImageForm,a as isInQaMode,e as isOnEditor,i as isOnPreview,me as isTouch,oe as isTriggerOncePerPage,dt as layoutGroup,st as layoutsForm,ue as loadImage,be as loadJS,ie as log,St as marginForm,xt as olverlayCloseOnClickForm,kt as overlayColorForm,zt as overlayGroup,$t as paddingForm,ge as preventGlobalScroll,ae as promiseDeferrer,Ue as recurrencesGroup,lt as referrerInsertTypeForm,ve as setCookie,et as switchButtonForm,pe as syncRequest,ft as textAlignmentForm,wt as textColorForm,Mt as textGroup,Fe as timeHideForm,qe as triggerDelay,Ge as triggerEventCustomScript,He as triggerEventElementVisible,je as triggerEventReengageDelay,Ke as triggerOncePerPage,Xe as triggersForm,Qe as triggersGroup,ze as triggersOptions,De as validationRecurrenceForm,le as waitForElement,re as widgetLog}; |
{ | ||
"name": "@abtasty/widget-utils", | ||
"version": "1.16.7-0", | ||
"version": "1.16.7-1", | ||
"main": "dist/widget-utils.cjs.js", | ||
@@ -5,0 +5,0 @@ "module": "dist/widget-utils.esm.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
99366