@abtasty/nps
Advanced tools
Comparing version 0.5.2-0 to 0.5.2-1
@@ -1,1 +0,1 @@ | ||
!function(){"use strict";var t=function(t,e){return t(e={exports:{}},e.exports),e.exports}((function(t){var e=function(t){var e=Object.prototype,n=e.hasOwnProperty,s="function"==typeof Symbol?Symbol:{},r=s.iterator||"@@iterator",i=s.asyncIterator||"@@asyncIterator",o=s.toStringTag||"@@toStringTag";function a(t,e,n,s){var r=e&&e.prototype instanceof l?e:l,i=Object.create(r.prototype),o=new E(s||[]);return i._invoke=function(t,e,n){var s="suspendedStart";return function(r,i){if("executing"===s)throw new Error("Generator is already running");if("completed"===s){if("throw"===r)throw i;return k()}for(n.method=r,n.arg=i;;){var o=n.delegate;if(o){var a=b(o,n);if(a){if(a===h)continue;return a}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===s)throw s="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);s="executing";var l=c(t,e,n);if("normal"===l.type){if(s=n.done?"completed":"suspendedYield",l.arg===h)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(s="completed",n.method="throw",n.arg=l.arg)}}}(t,n,o),i}function c(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}t.wrap=a;var h={};function l(){}function u(){}function d(){}var m={};m[r]=function(){return this};var g=Object.getPrototypeOf,p=g&&g(g(N([])));p&&p!==e&&n.call(p,r)&&(m=p);var f=d.prototype=l.prototype=Object.create(m);function v(t){["next","throw","return"].forEach((function(e){t[e]=function(t){return this._invoke(e,t)}}))}function y(t){var e;this._invoke=function(s,r){function i(){return new Promise((function(e,i){!function e(s,r,i,o){var a=c(t[s],t,r);if("throw"!==a.type){var h=a.arg,l=h.value;return l&&"object"==typeof l&&n.call(l,"__await")?Promise.resolve(l.__await).then((function(t){e("next",t,i,o)}),(function(t){e("throw",t,i,o)})):Promise.resolve(l).then((function(t){h.value=t,i(h)}),(function(t){return e("throw",t,i,o)}))}o(a.arg)}(s,r,e,i)}))}return e=e?e.then(i,i):i()}}function b(t,e){var n=t.iterator[e.method];if(void 0===n){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,b(t,e),"throw"===e.method))return h;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return h}var s=c(n,t.iterator,e.arg);if("throw"===s.type)return e.method="throw",e.arg=s.arg,e.delegate=null,h;var r=s.arg;return r?r.done?(e[t.resultName]=r.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,h):r:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,h)}function w(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function C(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function E(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(w,this),this.reset(!0)}function N(t){if(t){var e=t[r];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var s=-1,i=function e(){for(;++s<t.length;)if(n.call(t,s))return e.value=t[s],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:k}}function k(){return{value:void 0,done:!0}}return u.prototype=f.constructor=d,d.constructor=u,d[o]=u.displayName="GeneratorFunction",t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===u||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,o in t||(t[o]="GeneratorFunction")),t.prototype=Object.create(f),t},t.awrap=function(t){return{__await:t}},v(y.prototype),y.prototype[i]=function(){return this},t.AsyncIterator=y,t.async=function(e,n,s,r){var i=new y(a(e,n,s,r));return t.isGeneratorFunction(n)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},v(f),f[o]="Generator",f[r]=function(){return this},f.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var n in t)e.push(n);return e.reverse(),function n(){for(;e.length;){var s=e.pop();if(s in t)return n.value=s,n.done=!1,n}return n.done=!0,n}},t.values=N,E.prototype={constructor:E,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(C),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function s(n,s){return o.type="throw",o.arg=t,e.next=n,s&&(e.method="next",e.arg=void 0),!!s}for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r],o=i.completion;if("root"===i.tryLoc)return s("end");if(i.tryLoc<=this.prev){var a=n.call(i,"catchLoc"),c=n.call(i,"finallyLoc");if(a&&c){if(this.prev<i.catchLoc)return s(i.catchLoc,!0);if(this.prev<i.finallyLoc)return s(i.finallyLoc)}else if(a){if(this.prev<i.catchLoc)return s(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return s(i.finallyLoc)}}}},abrupt:function(t,e){for(var s=this.tryEntries.length-1;s>=0;--s){var r=this.tryEntries[s];if(r.tryLoc<=this.prev&&n.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var i=r;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=t,o.arg=e,i?(this.method="next",this.next=i.finallyLoc,h):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),h},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),C(n),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var s=n.completion;if("throw"===s.type){var r=s.arg;C(n)}return r}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:N(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),h}},t}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}}));function e(t,e,n,s,r,i,o){try{var a=t[i](o),c=a.value}catch(t){return void n(t)}a.done?e(c):Promise.resolve(c).then(s,r)}var n=function(t){return function(){var n=this,s=arguments;return new Promise((function(r,i){var o=t.apply(n,s);function a(t){e(o,r,i,a,c,"next",t)}function c(t){e(o,r,i,a,c,"throw",t)}a(void 0)}))}};var s=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t};var r=function(t){if(Array.isArray(t))return t};var i=function(t,e){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t)){var n=[],s=!0,r=!1,i=void 0;try{for(var o,a=t[Symbol.iterator]();!(s=(o=a.next()).done)&&(n.push(o.value),!e||n.length!==e);s=!0);}catch(t){r=!0,i=t}finally{try{s||null==a.return||a.return()}finally{if(r)throw i}}return n}};var o=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")};var a=function(t,e){return r(t)||i(t,e)||o()};const c=()=>Object.prototype.hasOwnProperty.call(window,"ABTastyEditor");const h=()=>!!window.ABTasty.getTestsOnPage()[TEST_ID],l=()=>{const{type:t}=DATA;return`${PACKAGE.replace("@abtasty/","")}${t?`_${t}`:""}`},u=()=>`${PLUGIN_ID.split("-")[0]}_${TEST_ID}`,d=(...t)=>{t.unshift(`[AB Tasty Widget] ${PACKAGE}:`),console.log(...t)},m=(t,e,n)=>{let s=0,r=0;try{document.querySelector(t)}catch(e){const s=`Selector «${t}» not valid.`;return d(s),"function"==typeof n&&n(s)}function i(){clearInterval(r),clearTimeout(s)}return s=setTimeout(()=>{i();const e=`Can't find element «${t}».`;return d(e),"function"==typeof n&&n(e)},1e4),r=setInterval(()=>{const n=document.querySelector(t);return null!==n?(i(),"function"==typeof e&&e(n)):n},200),{clear:i}};async function g(t){let e;switch(t){case"IntersectionObserver":e=await("IntersectionObserver"in window&&"IntersectionObserverEntry"in window&&"intersectionRatio"in window.IntersectionObserverEntry.prototype||function(t){return new Promise((e,n)=>{const s=window.document.getElementsByTagName("script")[0],r=window.document.createElement("script");r.src=t,s.parentNode.insertBefore(r,s),r.onload=e,r.onerror=n})}("https://polyfill.io/v3/polyfill.min.js?flags=gated&features=IntersectionObserver"));break;default:e=!0}return e}class p{constructor({displayRecurrence:t,closingRecurrence:e,validationRecurrence:n},s){this.displayRecurrence=parseFloat(t),this.closingRecurrence=parseFloat(e),this.validationRecurrence=parseFloat(n),this.onSetCallback=s,this.widgetName=l(),this.uniqueId=u(),this.recurrenceKey=`${this.widgetName}_${this.uniqueId}`}getGivenRecurrenceStorageParsed(t){try{const e=t.getItem("ABTastyWidgets");return JSON.parse(e)}catch(e){return t.removeItem("ABTastyWidgets"),!1}}getSessionRecurrenceStorageParsed(){return this.getGivenRecurrenceStorageParsed(window.sessionStorage)}getLocalRecurrenceStorageParsed(){return this.getGivenRecurrenceStorageParsed(window.localStorage)}removeGivenStorage(t,e){const{[this.recurrenceKey]:n,...s}=e;return Object.entries(s).length?(t.setItem("ABTastyWidgets",JSON.stringify(s)),s):(t.removeItem("ABTastyWidgets"),!1)}removeSessionRecurrenceStorage(){const t=this.getSessionRecurrenceStorageParsed();return!!t&&this.removeGivenStorage(window.sessionStorage,t)}removeLocalRecurrenceStorage(){const t=this.getLocalRecurrenceStorageParsed();return!!t&&this.removeGivenStorage(window.localStorage,t)}getSessionRecurrence(){const t=this.getSessionRecurrenceStorageParsed();return!!t&&t[this.recurrenceKey]}getLocalRecurrence(){const t=this.getLocalRecurrenceStorageParsed();return!!t&&t[this.recurrenceKey]}getCurrentRecurrence(){const t=this.getSessionRecurrence(),e=this.getLocalRecurrence();return t||e||{type:!1}}isOver(){const t=this.getLocalRecurrence(),e=(t?parseFloat(t.stamp):0)<(new Date).getTime();return e&&this.removeLocalRecurrenceStorage(),e&&!this.getLocalRecurrence()&&!this.getSessionRecurrence()}setRecurrence(t,e){const n=this.getTypeOfStorage(t);if(!n&&"object"!=typeof n)return!1;const{storageString:s,storageMethod:r}=this.getTypeOfStorage(t),i=this.getStamp(t),o={type:e,stamp:i},{type:a}=this.getCurrentRecurrence(),c=()=>{const t=this.getSessionRecurrence(),e=this.getLocalRecurrence();let n;"session"===s?t?n=this.removeSessionRecurrenceStorage():(this.removeLocalRecurrenceStorage(),n=this.getSessionRecurrenceStorageParsed()):"local"===s&&(e?n=this.removeLocalRecurrenceStorage():(this.removeSessionRecurrenceStorage(),n=this.getLocalRecurrenceStorageParsed()));const i=n?{[this.recurrenceKey]:o,...n}:{[this.recurrenceKey]:o};r.setItem("ABTastyWidgets",JSON.stringify(i)),this.onSetCallback&&"function"==typeof this.onSetCallback&&this.onSetCallback()};if(!r)return!1;if(a&&"validation"!==e)if("closing"===e&&"validation"!==a)c();else{if("display"!==e||"validation"===a||"closing"===a)return!1;c()}else c();return i}setDisplayRecurrence(){this.setRecurrence(this.displayRecurrence,"display")}setClosingRecurrence(){this.setRecurrence(this.closingRecurrence,"closing")}setValidationRecurrence(){this.setRecurrence(this.validationRecurrence,"validation")}getStamp(t){return(new Date).getTime()+864e5*t}getTypeOfStorage(t){return!(isNaN(t)||t<0||0!==t&&!t)&&(t>0?{storageString:"local",storageMethod:window.localStorage}:0===t&&{storageString:"session",storageMethod:window.sessionStorage})}}class f{constructor(){this.targets=[],this.existingTargets=[],this.inViewPortTargets=[],this.visibilityobserver=this.startVisibilityObserver(),this.mutationobserver=this.startMutationObserver()}intersectionHandler(t){t.forEach(t=>{t.isIntersecting?(this.existingTargets=this.existingTargets.filter(e=>e.element!==t.target||(this.inViewPortTargets.push(e),!1)),this.checkElements()):this.inViewPortTargets=this.inViewPortTargets.filter(e=>e.element!==t.target||(this.existingTargets.push(e),!1))})}startVisibilityObserver(){return new IntersectionObserver(this.intersectionHandler.bind(this),{root:null,rootMargin:"0px",threshold:0})}startMutationObserver(){const t=new MutationObserver(this.checkElements.bind(this));return t.observe(document,{attributes:!0,childList:!0,subtree:!0}),t}isElementVisible(t){return this.isElementTopmost(t)&&this.isElementOpaque(t)}isElementOpaque(t){return"HTML"===function t(e,n){return n(e)||!e.parentElement?e:t(e.parentElement,n)}(t,t=>"0"===window.getComputedStyle(t).opacity).nodeName}isElementTopmost(t){const e=t.getBoundingClientRect(),n=[[e.left,e.top],[e.right,e.top],[e.left,e.bottom],[e.right,e.bottom],[e.left+e.width/2,e.top],[e.left+e.width/2,e.bottom],[e.left,e.height/2],[e.right,e.height/2],[e.left+e.left/2,e.height/2]];let s=!1,r=0;for(;!s&&r<n.length;){const e=document.elementFromPoint(...n[r]);s=t===e||t.contains(e),r+=1}return s}checkElements(){this.targets=this.targets.filter(t=>{const e=document.querySelector(t.selector);return!e||(this.existingTargets.push(Object.assign(t,{element:e})),this.visibilityobserver.observe(e),!1)}),this.existingTargets=this.existingTargets.filter(t=>!!document.querySelector(t.selector)||(this.visibilityobserver.unobserve(t.element),this.targets.push(t),!1)),this.inViewPortTargets=this.inViewPortTargets.filter(({element:t,resolve:e})=>!this.isElementVisible(t)||(this.visibilityobserver.unobserve(t),e(t),!1))}watch(t,e){this.targets.push({selector:t,resolve:e})}clear(t){const e=this.targets.filter(e=>e.selector!==t);0===e.length&&(this.existingTargets=[],this.inViewPortTargets=[],this.mutationobserver.disconnect(),this.visibilityobserver.unobserve(t)),this.targets.length>e&&(this.targets=e,this.visibilityobserver.unobserve(t))}}class v{constructor({triggerEvent:t,triggerSelector:e,triggerDelay:n}){this.event=t,this.selector=e&&e.length?e:"body",this.delay=n,this.elementsSelectors=[],this.eventsListeners=[],this.timeouts=[],this.intervals=[],this.observers=[],this.promises=[],this.visibilityObservers=[],this.elementsWaiters=[]}static promiseDeferrer(t){const e={promise:null,resolve:null,reject:null,name:t};return e.promise=new Promise((t,n)=>{e.resolve=t,e.reject=n}),e}async onElementVisible(){const t=v.promiseDeferrer("onElementVisible");this.promises.push(t);const e=await this.onPageLoad(),n=await g("IntersectionObserver"),s=function(t,e){return ABTasty.widgetUtils||(ABTasty.widgetUtils={}),ABTasty.widgetUtils[t]||Object.assign(ABTasty.widgetUtils,{[t]:new e}),ABTasty.widgetUtils[t]}("VisibilityObserver",f);return this.visibilityObservers.push(s),n&&e&&s.watch(this.selector,t.resolve),t.promise}onPageLoad(){const t=v.promiseDeferrer("onPageLoad");this.promises.push(t);const e=()=>"complete"===document.readyState;if(e())t.resolve(!0);else{const n=()=>e()&&!clearTimeout(s)&&!t.resolve(!0),s=setTimeout(()=>t.resolve(!1),2e4),r=["readystatechange",n,{passive:!0}];this.timeouts.push(s),this.eventsListeners.push(r),document.addEventListener(...r)}return t.promise}onClick(){const t=document.createElement("style");t.type="text/css",t.id=`Click_${u()}`,t.innerHTML=`${this.selector} {\n\t\t\tcursor: pointer !important;\n\t\t\tpointer-events: all !important;\n\t\t}`,document.head.appendChild(t),this.elementsSelectors.push(`#${t.id}`);const e=v.promiseDeferrer("onClick");this.promises.push(e);const n=()=>[...document.querySelectorAll(this.selector)],s=t=>n().some(e=>e.isSameNode(t)||!!t.closest(this.selector)),r=["click",({target:t})=>!!s(t)&&(e.resolve(!0),this.clear()),{passive:!0,capture:!0}];return this.eventsListeners.push(r),document.addEventListener(...r),e.promise}onExitIntent(){const t=v.promiseDeferrer("onExitIntent");this.promises.push(t);const e=["mouseleave",async({clientY:e})=>{if(!(e>0))if(this.delay){const e=1e3*this.delay,n=setTimeout(()=>{t.resolve(!0)},e);this.timeouts.push(n)}else t.resolve(!0)},{passive:!0}],n=m("body",t=>{t.addEventListener(...e),this.eventsListeners.push([t,...e]),this.elementsWaiters=this.elementsWaiters.filter(t=>t!==n)});return this.elementsWaiters.push(n),t.promise}onDelay(){const t=v.promiseDeferrer("onDelay");this.promises.push(t);const e=1e3*this.delay,n=setTimeout(()=>{t.resolve(!0)},e);return this.timeouts.push(n),t.promise}onReengage(){const t=v.promiseDeferrer("onReengage");this.promises.push(t);const e=1e3*this.delay;let n=e;const s=[()=>(n=e,n),{passive:!0}];["click","mousemove","scroll","keypress"].forEach(t=>{document.addEventListener(t,...s),this.eventsListeners.push([t,...s])});const r=setInterval(()=>{n<=0?t.resolve(!0):n-=100},100);return this.intervals.push(r),t.promise}clear(){return this.elementsSelectors.length&&(this.elementsSelectors.forEach(t=>{document.querySelector(t)&&document.querySelector(t).remove()}),this.elementsSelectors=[]),this.eventsListeners.length&&(this.eventsListeners.forEach(t=>{const[e,...n]="string"==typeof t[0]?[document,...t]:t;e&&n.length>1&&e.removeEventListener(...n)}),this.eventsListeners=[]),this.timeouts.length&&(this.timeouts.forEach(t=>clearTimeout(t)),this.timeouts=[]),this.intervals.length&&(this.intervals.forEach(t=>clearInterval(t)),this.intervals=[]),this.observers.length&&(this.observers.forEach(t=>t.disconnect()),this.observers=[]),this.visibilityObservers.length&&(this.visibilityObservers.forEach(t=>t.clear(this.selector)),this.visibilityObservers=[]),this.promises.length&&(this.promises.forEach(t=>t.resolve(!1)),this.promises=[]),this.elementsWaiters.length&&(this.elementsWaiters.forEach(t=>t.clear()),this.elementsWaiters=[]),this}async isTriggered(){let t;switch(this.clear(),this.event){case"pageLoad":t=await this.onPageLoad(),this.clear();break;case"click":t=await this.onClick(),this.clear();break;case"exitIntent":t=await this.onExitIntent(),this.clear();break;case"delay":t=await this.onDelay(),this.clear();break;case"reengage":t=await this.onReengage(),this.clear();break;case"elementVisible":t=await this.onElementVisible(),this.clear();break;default:t=!1}return t}}class y{constructor(t,e,n){this.recurrence=t,this.isWidgetApplied=e,this.callback=n,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(t){const e=h(),{type:n}=this.recurrence?this.recurrence.getCurrentRecurrence():{type:!1},s=()=>t&&"display"===n||this.recurrenceIsDone();return!this.isWidgetApplied()&&e&&s()?(this.clearWatcher(),this.callback("rebuild",t)):(!this.isWidgetApplied()||e&&s())&&(this.isWidgetApplied()||e)||(this.clearWatcher(),this.callback("remove",t),this.watch()),this}eventHandler(){let t=h();return[250,500].forEach(e=>setTimeout(()=>500===e&&h()===t?this:(t=h(),this.decisionHandler(!1)),e)),this}observerHandler(t){const e=t.some(({removedNodes:t})=>t&&t.length),n=t.some(({addedNodes:t})=>t&&t.length);return e||n?(this.decisionHandler(!0),this):this}watch(){if(c())return this;this.clearWatcher(),document.addEventListener(...this.eventListenerParams);const t=m("body",e=>{const n=[e,{childList:!0,subtree:!0}];this.observer.observe(...n),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(t=>t.clear()),this.elementsWaiters=[]),this.observer.disconnect(),this}}const b=["pageLoad","delay","reengage"];class w{constructor(){this.uniqueId=u(),this.widgetName=l(),this.recurrenceParams=(()=>{const{displayRecurrence:t,closingRecurrence:e,validationRecurrence:n}=DATA;return!(c()||!(t||e||n))&&{displayRecurrence:t,closingRecurrence:e,validationRecurrence:n}})(),this.triggerParams=(()=>{const{triggerEvent:t,triggerEventClick:e,triggerEventExitDelay:n,triggerEventDelay:s,triggerEventReengageDelay:r}=DATA;if(c()||!t)return!1;const i=e;let o;switch(t){case"exitIntent":o=n;break;case"delay":o=s;break;case"reengage":o=r;break;default:o=0}return{triggerEvent:t,triggerSelector:i,triggerDelay:o}})(),this.recurrence=!!this.recurrenceParams&&new p(this.recurrenceParams,this.clearGivenClearables.bind(this)),this.trigger=!!this.triggerParams&&new v(this.triggerParams),this.pageWatcher=new y(this.recurrence,this.isWidgetApplied.bind(this),this.onPageChange.bind(this)),this.hasOncePerPageTrigger=!!this.trigger&&b.some(t=>t===this.trigger.event),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(t=>document.removeEventListener(...t)),this.eventsListeners=[]),this.timeouts.length&&(this.timeouts.forEach(t=>clearTimeout(t)),this.timeouts=[]),this.intervals.length&&(this.intervals.forEach(t=>clearInterval(t)),this.intervals=[]),this.observers.length&&(this.observers.forEach(t=>t.disconnect()),this.observers=[]),this.promises.length&&(this.promises.forEach(t=>t.resolve(!1)),this.promises=[]),this.elementsWaiters.length&&(this.elementsWaiters.forEach(t=>t.clear()),this.elementsWaiters=[])}isWidgetApplied(){return this.domElement&&!!this.domElement.closest("html")}removeOldDomElement(){const t=document.getElementById(this.widgetContainerId);return t&&t.remove(),this}insert(){const t=m("head",e=>(this.elementsWaiters=this.elementsWaiters.filter(e=>e!==t),e.appendChild(this.styleElement)),e=>(this.elementsWaiters=this.elementsWaiters.filter(e=>e!==t),d(e))),e=m("body",t=>(this.elementsWaiters=this.elementsWaiters.filter(t=>t!==e),this.removeOldDomElement(),t.appendChild(this.domElement)),t=>(this.elementsWaiters=this.elementsWaiters.filter(t=>t!==e),d(t)));return this.elementsWaiters.push(t,e),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():c()||this.init().then(t=>t?this.show():this),this}show(){return this.hasBeenShown||c()||window.ABTastyEvent(`${this.widgetName} 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&&!c()&&window.ABTastyEvent(`${this.widgetName} closed`,null,TEST_ID),this.closedByUser=!0,this.domElement.classList.add(this.hideClassName),this}async init(){if(!c()&&!h())return!1;if(this.trigger&&this.trigger.promises.length)return!1;const t=this.recurrence&&this.recurrence.isOver();return this.recurrence&&!t?(this.pageWatcher.watch(),!1):(this.pageWatcher.watch(),!!(c()||!this.trigger||this.trigger&&await this.trigger.isTriggered())&&(this.insert(),this.addCloseEvent(),this))}onPageChange(t,e){const n=()=>this.init().then(t=>t&&this.show());switch(e||(this.hasBeenShown=!1),t){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().show():n()}}addCloseEvent(...t){const e=this.domElement.querySelectorAll(`\n\t\t\t.${this.overlayClassName},\n\t\t\t.${this.closeButtonClassName}\n\t\t`);return t.push(...e),t.forEach(t=>{t.addEventListener("click",()=>{this.recurrence&&this.recurrence.setClosingRecurrence(),this.hide(),setTimeout(()=>this.remove(),1e3)},{passive:!0,once:!0})}),this}getDom(){const t=document.createElement("div");return t.className=`${this.basicClassName} ${this.hideClassName}`,t.id=this.widgetContainerId,t.innerHTML=`\n\t\t\t<div class="${this.overlayClassName}"></div>\n\t\t\t<div class="${this.contentClassName}">\n\t\t\t\t<button class="${this.closeButtonClassName}" ${c()?"data-abtasty-actionnable":""}>+</button>\n\t\t\t</div>`,t}getStyleTag(t=""){const e=document.createElement("style");return e.type="text/css",c()&&e.setAttribute("abtasty-script-added","true"),e.textContent=`\n\t\t\t.${this.hideClassName} {opacity: 0 !important; pointer-events: none;}\n\t\t\t${t}`,e}}class C extends w{constructor(){super(),this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){return`\n\t\t#${this.widgetContainerId} {\n\t\t\tposition: fixed;\n\t\t\ttop: 0;\n\t\t\tleft: 0;\n\t\t\twidth: 100%;\n\t\t\theight: 100%;\n\t\t\tz-index: 9999;\n\t\t\topacity: 1;\n\t\t\ttransition: opacity 0.25s ease;\n\t\t}\n\t\t#${this.widgetContainerId} .${this.overlayClassName} {\n\t\t\tposition: absolute;\n\t\t\tz-index: -1;\n\t\t\ttop: 0;\n\t\t\tleft: 0;\n\t\t\twidth: 100%;\n\t\t\theight: 100%;\n\t\t\tbackground-color: black;\n\t\t\topacity: 0.6;\n\t\t}\n\t\t#${this.widgetContainerId} .${this.contentClassName} {\n\t\t\tposition: absolute;\n\t\t\tleft: 50%;\n\t\t\ttop: 50%;\n\t\t\ttransform: translate(-50%, -50%);\n\t\t\twidth: auto;\n\t\t\theight: auto;\n\t\t}\n\t\t#${this.widgetContainerId} .${this.closeButtonClassName} {\n\t\t\tposition: absolute;\n\t\t\ttop: 0;\n\t\t\tright: 0;\n\t\t\twidth: auto;\n\t\t\theight: auto;\n\t\t\tcolor: black;\n\t\t\tbackground: none;\n\t\t\tborder: none;\n\t\t\ttransform: rotate(45deg);\n\t\t\tcursor: pointer;\n\t\t\toutline: none;\n\t\t\tfont-size: 1.8em;\n\t\t}\n\t\t\n\t\t@media screen and (max-width: 550px) and (orientation: portrait) {\n\t\t\t#${this.widgetContainerId} .${this.closeButtonClassName} {\n\t\t\t\tfont-size: 6vmin;\n\t\t\t}\n\t\t}`}}class E extends w{constructor(t){super(),this.position=t,this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){return`\n\t\t#${this.widgetContainerId} {\n\t\t\tposition: fixed;\n\t\t\t${this.position}: 0;\n\t\t\tleft: 0;\n\t\t\twidth: 100%;\n\t\t\theight: auto;\n\t\t\tz-index: 9999;\n\t\t\topacity: 1;\n\t\t\ttransition: opacity 0.25s ease;\n\t\t}\n\t\t#${this.widgetContainerId} .${this.overlayClassName} {\n\t\t\tdisplay: none;\n\t\t}\n\t\t#${this.widgetContainerId} .${this.closeButtonClassName} {\n\t\t\tposition: absolute;\n\t\t\ttop: 0;\n\t\t\tright: 0;\n\t\t\twidth: auto;\n\t\t\theight: auto;\n\t\t\tcolor: black;\n\t\t\tbackground: none;\n\t\t\tborder: none;\n\t\t\ttransform: rotate(45deg);\n\t\t\tcursor: pointer;\n\t\t\toutline: none;\n\t\t\tfont-size: 1.8em;\n\t\t}`}}class N extends w{constructor(t,e){super(),this.position=t,this.referrerElement=e,this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}insert(){const t=m("head",e=>(this.elementsWaiters=this.elementsWaiters.filter(e=>e!==t),e.appendChild(this.styleElement)),e=>(this.elementsWaiters=this.elementsWaiters.filter(e=>e!==t),d(e))),e=m(this.referrerElement,t=>(this.elementsWaiters=this.elementsWaiters.filter(t=>t!==e),this.removeOldDomElement(this.domElement.id),t.insertAdjacentElement(this.position,this.domElement)),t=>(this.elementsWaiters=this.elementsWaiters.filter(t=>t!==e),d(t)));return this.elementsWaiters.push(t,e),this}getStyles(){return`\n\t\t#${this.widgetContainerId} {\n\t\t\twidth: auto;\n\t\t\theight: auto;\n\t\t\tposition: relative;\n\t\t\tmargin: 0;\n\t\t\tpadding: 0;\n\t\t}\n\t\t#${this.widgetContainerId} .${this.overlayClassName} {\n\t\t\tdisplay: none;\n\t\t}\n\t\t#${this.widgetContainerId} .${this.closeButtonClassName} {\n\t\t\tposition: absolute;\n\t\t\ttop: 0;\n\t\t\tright: 0;\n\t\t\twidth: auto;\n\t\t\theight: auto;\n\t\t\tcolor: black;\n\t\t\tbackground: none;\n\t\t\tborder: none;\n\t\t\ttransform: rotate(45deg);\n\t\t\tcursor: pointer;\n\t\t\toutline: none;\n\t\t\tfont-size: 1.8em;\n\t\t}`}}var k=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")};function S(t,e){for(var n=0;n<e.length;n++){var s=e[n];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}var x=function(t,e,n){return e&&S(t.prototype,e),n&&S(t,n),t};function T(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e&&(s=s.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,s)}return n}var L=DATA,O=L.themeType,P=L.layout,I=L.isFeedBackQuestion,B=L.isThankYouMessage,R=L.isLegend,W=L.timeHide,j=L.stepToShow,A=L.question,D=L.feedbackQuestion,$=L.buttonText,_=L.thankYouMessage,M=L.zeroLegend,q=L.tenLegend,F=function(){function t(e){var n=e.userStyles,s=e.parentContainer;k(this,t),this.question=A,this.feedbackQuestion=D,this.userStyles=n,this.parentContainer=s,this.buttonText=$,this.thankYouMessage=_,this.legend={zeroLegend:M,tenLegend:q},this.baseClassName="nps_container",this.npsClassName="".concat(this.baseClassName,"_").concat(s.uniqueId),this.questionClassName="".concat(this.baseClassName,"_question"),this.notesClassName="".concat(this.baseClassName,"_notes"),this.feedbackQuestionClassName="".concat(this.questionClassName,"_feedback"),this.feedbackFormClassName="".concat(this.questionClassName,"_feedback_form"),this.notesButtonsClassName="".concat(this.notesClassName,"_button"),this.thankYouClassName="".concat(this.baseClassName,"_thanks"),this.hideClassName="nps_".concat(s.uniqueId,"_display_none"),this.currentNote=NaN,this.userFeedback="",this.npsContainer=this.getContainer(),this.questionElement=this.getQuestionElement(),this.notesContainer=this.getNotesElement(),this.feedbackElements=this.getFeedBackElements(),this.thankYouElement=this.getThankYouElement(),this.npsElement=this.getNPSElement(),this.styleElement=this.getStyleElement()}return x(t,[{key:"sendNote",value:function(){if(!c()&&!isNaN(this.currentNote)){try{window.abtasty.send("nps",{ns:this.currentNote,nf:this.userFeedback})}catch(t){}this.parentContainer.recurrence.setValidationRecurrence()}return this}},{key:"insertIn",value:function(t,e){return document.head.insertAdjacentElement("beforeend",this.styleElement),t.insertAdjacentElement(e,this.npsElement),this}},{key:"remove",value:function(){return this.npsElement&&this.npsElement.remove(),this.styleElement&&this.styleElement.remove(),this}},{key:"complete",value:function(){var t=this;this.sendNote(),setTimeout((function(){t.parentContainer.hide(),setTimeout((function(){t.remove(),t.parentContainer.hide().remove()}),1e3)}),1e3*W)}},{key:"onClickNote",value:function(t){this.currentNote=Number(t.target.dataset.note),I&&this.feedbackQuestion&&this.feedbackQuestion.length?this.showFeedBack():B&&this.thankYouMessage&&this.thankYouMessage.length?this.showThankYouMessage():this.complete()}},{key:"onFeedbackSend",value:function(){B&&this.thankYouMessage&&this.thankYouMessage.length?this.showThankYouMessage():this.complete()}},{key:"showFeedBack",value:function(){var t=this;return this.npsContainer.childNodes.forEach((function(e){return e.classList.add(t.hideClassName)})),Object.values(this.feedbackElements).forEach((function(e){return e.classList.remove(t.hideClassName)})),this}},{key:"showThankYouMessage",value:function(){var t=this;return this.npsContainer.childNodes.forEach((function(e){return e.classList.add(t.hideClassName)})),this.thankYouElement.classList.remove(this.hideClassName),this.complete(),this}},{key:"getThankYouElement",value:function(){var t=document.createElement("p");return t.className="".concat(this.thankYouClassName," ").concat(this.hideClassName),t.innerHTML=this.thankYouMessage,c()&&"displayThanksStep"===j&&t.classList.remove(this.hideClassName),t}},{key:"getFeedBackElements",value:function(){var t=this,e=document.createElement("p");e.className="".concat(this.feedbackQuestionClassName," ").concat(this.hideClassName),e.innerHTML=this.feedbackQuestion;var n=document.createElement("form");n.className="".concat(this.feedbackFormClassName," ").concat(this.hideClassName),n.addEventListener("submit",(function(t){return t.preventDefault()}),{passive:!1});var s=document.createElement("input");s.className="".concat(this.feedbackQuestionClassName,"_input"),s.type="text";var r=document.createElement("button");return r.className="".concat(this.feedbackQuestionClassName,"_button"),r.innerHTML=this.buttonText,r.addEventListener("click",(function(){return t.userFeedback=s.value,t.onFeedbackSend()}),{passive:!0}),c()&&"displayFeedbackStep"===j&&[e,n].forEach((function(e){return e.classList.remove(t.hideClassName)})),n.appendChild(s),n.appendChild(r),{feedbackQuestionElement:e,feedbackFormElement:n}}},{key:"getNotesElement",value:function(){var t=this,e=document.createElement("div");e.className=this.notesClassName,c()&&"displayNoteStep"!==j&&e.classList.add(this.hideClassName);for(var n=10;n>=0;){var s=document.createElement("button");s.className=this.notesButtonsClassName,s.dataset.note=n,c()&&s.setAttribute("data-abtasty-actionnable",""),s.innerHTML+="<span>".concat(n,"</span>"),s.addEventListener("click",(function(e){return t.onClickNote(e)}),{passive:!0}),e.insertAdjacentElement("afterbegin",s),5===n&&s.insertAdjacentHTML("afterend","<br>"),n-=1}return R&&(e.insertAdjacentHTML("afterbegin","<legend>".concat(this.legend.zeroLegend,"</legend>")),e.insertAdjacentHTML("beforeend","<legend>".concat(this.legend.tenLegend,"</legend>"))),e}},{key:"getQuestionElement",value:function(){var t=document.createElement("p");return t.className=this.questionClassName,t.innerHTML=this.question,c()&&"displayNoteStep"!==j&&t.classList.add(this.hideClassName),t}},{key:"getContainer",value:function(){var t=document.createElement("div");return t.className="".concat(this.baseClassName," ").concat(this.npsClassName),t}},{key:"getNPSElement",value:function(){var t=this;return this.npsContainer.appendChild(this.questionElement),this.npsContainer.appendChild(this.notesContainer),I&&Object.values(this.feedbackElements).forEach((function(e){t.npsContainer.appendChild(e)})),B&&this.npsContainer.appendChild(this.thankYouElement),this.npsContainer}},{key:"getDefaultStyles",value:function(){var t="\n\t\t\t#".concat(this.parentContainer.widgetContainerId," .").concat(this.baseClassName,",\n\t\t\t#").concat(this.parentContainer.widgetContainerId," .").concat(this.baseClassName," *");return"\n\t\t".concat(t," {\n\t\t\twidth: auto;\n\t\t\theight: auto;\n\t\t\tmin-width: inherit;\n\t\t\tmin-height: inherit;\n\t\t\tmax-width: inherit;\n\t\t\tmax-height: inherit;\n\t\t\tline-height: 1;\n\t\t\tmargin: 0;\n\t\t\tpadding: 0;\n\t\t\tborder: none;\n\t\t\tbox-sizing: border-box;\n\t\t}\n\t\t#").concat(this.parentContainer.widgetContainerId," .").concat(this.hideClassName," {\n\t\t\tdisplay: none !important;\n\t\t}\n\t\t#").concat(this.parentContainer.widgetContainerId," .").concat(this.baseClassName," .").concat(this.notesButtonsClassName," span {\n\t\t\tpointer-events: none;\n\t\t}\n\t\tbody #").concat(this.parentContainer.widgetContainerId," .").concat(this.parentContainer.closeButtonClassName," {\n\t\t\tpadding: 0;\n\t\t\tline-height: 1;\n\t\t}\n\t\t@media (orientation: landscape) {\n\t\t\t").concat(t," {\n\t\t\t\tfont-size: .55vmax;\n\t\t\t}\n\t\t}\n\t\t@media (orientation: landscape) and (max-width: 1280px) {\n\t\t\t").concat(t," {\n\t\t\t\tfont-size: .7vmax;\n\t\t\t}\n\t\t}\n\t\t@media (orientation: landscape) and (max-width: 800px) {\n\t\t\t").concat(t," {\n\t\t\t\tfont-size: 1vmax;\n\t\t\t}\n\t\t}\n\t\t@media (orientation: portrait) {\n\t\t\t").concat(t," {\n\t\t\t\tfont-size: 1vmin;\n\t\t\t}\n\t\t}\n\t\t@media (orientation: portrait) and (max-width: 550px) {\n\t\t\t").concat(t," {\n\t\t\t\tfont-size: 2.2vmin;\n\t\t\t\tline-height: 1.3;\n\t\t\t\tmax-width: ").concat("popin"===P?"85vw":"auto",";\n\t\t\t}\n\t\t}")}},{key:"getThemeDefaultStyles",value:function(){var t="popin"===P?"75em":"auto",e="#".concat(this.parentContainer.widgetContainerId," .").concat(this.npsClassName);return"\n\t\t".concat(e,",\n\t\t").concat(e," * {\n\t\t\tdisplay: flex;\n\t\t\tflex-wrap: nowrap;\n\t\t\tjustify-content: center;\n\t\t}\n\t\t").concat(e," {\n\t\t\twidth: ").concat(t,";\n\t\t\talign-items: center;\n\t\t}\n\t\t").concat(e," .").concat(this.questionClassName,",\n\t\t").concat(e," .").concat(this.feedbackQuestionClassName,",\n\t\t").concat(e," .").concat(this.thankYouClassName," {\n\t\t\tfont-size: 2em;\n\t\t\tmargin-right: 1em;\n\t\t}\n\t\t").concat(e," .").concat(this.notesClassName," {\n\t\t\tflex-direction: row;\n\t\t}\n\t\t").concat(e," .").concat(this.notesClassName," legend {\n\t\t\talign-self: center;\n\t\t\tfont-size: 1.5em;\n\t\t}\n\t\t").concat(e," .").concat(this.notesClassName," legend:first-of-type {\n\t\t\tmargin-right: 1em;\n\t\t}\n\t\t").concat(e," .").concat(this.notesClassName," legend:last-of-type {\n\t\t\tmargin-left: 1em;\n\t\t}\n\t\t").concat(e," .").concat(this.notesButtonsClassName," {\n\t\t\twidth: 3.5em;\n\t\t\theight: 3.5em;\n\t\t}\n\t\t").concat(e," .").concat(this.notesButtonsClassName," span {\n\t\t\tfont-size: 2em;\n\t\t}\n\t\t").concat(e," .").concat(this.feedbackFormClassName," {\n\t\t\tflex-direction: row;\n\t\t}\n\t\t").concat(e," .").concat(this.feedbackFormClassName," input {\n\t\t\twidth: 45em;\n\t\t\theight: 4em;\n\t\t\tpadding: 0 0.5em;\n\t\t}\n\t\t").concat(e," .").concat(this.feedbackFormClassName," button {\n\t\t\twidth: 10em;\n\t\t\tfont-size: 1.4em;\n\t\t}\n\t\t@media screen and (max-width: 550px) and (orientation: portrait) {\n\t\t\t").concat(e," .").concat(this.questionClassName,",\n\t\t\t").concat(e," .").concat(this.feedbackQuestionClassName," ,\n\t\t\t").concat(e," .").concat(this.thankYouClassName," {\n\t\t\t\tmax-width: 90%;\n\t\t\t\t align-self: flex-start;\n\t\t\t}\n\t\t\t").concat(e," .").concat(this.notesClassName," {\n\t\t\t\tdisplay: inline-block;\n\t\t\t\twidth: 100%;\n\t\t\t\ttext-align: center;\n\t\t\t\tline-height: 5.5;\n\t\t\t\tposition: relative;\n\t\t\t\t").concat(R?"padding-bottom: 4em;":"","\n\t\t\t}\n\t\t\t").concat(e," .").concat(this.notesButtonsClassName," {\n\t\t\t\tdisplay: inline-block;\n\t\t\t\twidth: 4em;\n\t\t\t\theight: 4em;\n\t\t\t}\n\t\t\t").concat(e," .").concat(this.notesClassName," legend {\n\t\t\t\tposition: absolute;\n\t\t\t\tbottom: 0;\n\t\t\t\tleft: 0;\n\t\t\t\tmargin: 0 !important;\n\t\t\t\tfont-size: 1.25em;\n\t\t\t}\n\t\t\t").concat(e," .").concat(this.notesClassName," legend:first-of-type {\n\t\t\t\tbottom: 1.2em;\n\t\t\t}\n\t\t\t").concat(e," .").concat(this.notesClassName," legend:first-of-type::before {\n\t\t\t\tcontent: '0:';\n\t\t\t\tmargin-right: 0.4em;\n\t\t\t}\n\t\t\t").concat(e," .").concat(this.notesClassName," legend:last-of-type::before {\n\t\t\t\tcontent: '10:';\n\t\t\t\tmargin-right: 0.4em;\n\t\t\t}\n\t\t\t").concat(e," .").concat(this.feedbackFormClassName," {\n\t\t\t\tflex-direction: column;\n\t\t\t\twidth: 100%;\n\t\t\t}\n\t\t\t").concat(e," .").concat(this.feedbackFormClassName," input {\n\t\t\t\tmargin: 0;\n\t\t\t\twidth: 100%;\n\t\t\t\theight: 3em;\n\t\t\t\tfont-size: 1.8em;\n\t\t\t}\n\t\t\t").concat(e," .").concat(this.feedbackFormClassName," button {\n\t\t\t\twidth: 50%;\n\t\t\t\theight: 2.7em;\n\t\t\t\tmargin-top: 1em;\n\t\t\t\talign-self: center;\n\t\t\t\tfont-size: 1.5em;\n\t\t\t\tfont-weight: bold;\n\t\t\t}\n\t\t}")}},{key:"getUserStyles",value:function(){var t,e=this.userStyles,n=e.backgroundColor,r=e.borderColor,i=e.borderRadius,o=e.borderWidth,c=e.dropShadow,h=e.textColor,l=e.horizontalPaddingContainer,u=e.verticalPaddingContainer,d=e.horizontalMarginContainer,m=e.verticalMarginContainer,g=e.overlayColor,p=e.shadowOpacity,f=e.buttonsContrast,v=e.buttonsBorderRadius,y=e.buttonsShape,b=e.contentDirection,w=e.questionMargin,C=e.buttonsHorizontalMargin,E=e.inputBackgroundColor,N=e.inputBorderColor,k=e.inputBorderWidth,S=e.inputBorderRadius,x=e.inputTextColor,L=e.inputMarginWithButton,O=e.feedbackButtonBackgroundColor,P=e.feedbackButtonBorderColor,I=e.feedbackButtonBorderWidth,B=e.feedbackButtonBorderRadius,R=e.feedbackButtonTextColor,W=Object.entries(this.userStyles).filter((function(t){return a(t,1)[0].includes(f)})).reduce((function(t,e){var n=a(e,2),r=n[0],i=n[1],o=r.split("_".concat(f))[0],c=function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?T(Object(n),!0).forEach((function(e){s(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):T(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}({},t);return c[o]=i,c}),{}),j=W.buttonsBackgroundColor,A=W.buttonsTextColor,D=W.buttonsBorderColor,$=W.buttonsBorderWidth;switch(y){case"roundsquare":t="border-radius: ".concat(v,"px;");break;case"round":t="border-radius: 50%;";break;default:t=""}var _=c?"box-shadow: 0px 5px 10px 2px rgba(0, 0, 0, ".concat(p/100,");"):"",M="#".concat(this.parentContainer.widgetContainerId," .").concat(this.npsClassName),q="\n\t\t\t".concat(M," .").concat(this.notesButtonsClassName," {\n\t\t\t\tmargin-left: ").concat(C,"px;\n\t\t\t\tmargin-right: ").concat(C,"px;\n\t\t\t\tbackground-color: ").concat(j,";\n\t\t\t\tborder: ").concat($,"px solid ").concat(D,";\n\t\t\t\t").concat(t,"\n\t\t\t}\n\t\t\t").concat(M," .").concat(this.notesButtonsClassName," span {\n\t\t\t\tcolor: ").concat(A,";\n\t\t\t}");return"\n\t\t\tbody ".concat(M," {\n\t\t\t\tflex-direction: ").concat(b,";\n\t\t\t\tbackground-color: ").concat(n,";\n\t\t\t\tborder: ").concat(o,"px solid ").concat(r,";\n\t\t\t\tborder-radius: ").concat(i,"px;\n\t\t\t\tpadding: ").concat(u,"px ").concat(l,"px;\n\t\t\t\t").concat(_,"\n\t\t\t}\n\t\t\t").concat(M," .").concat(this.questionClassName,",\n\t\t\t").concat(M," .").concat(this.feedbackQuestionClassName," ,\n\t\t\t").concat(M," .").concat(this.thankYouClassName," {\n\t\t\t\tcolor: ").concat(h,";\n\t\t\t\tmargin-").concat("row"===b?"right":"bottom"," : ").concat(w,"px;\n\t\t\t}\n\t\t\t").concat(M," .").concat(this.thankYouClassName," {\n\t\t\t\tmargin-bottom: 0;\n\t\t\t}\n\t\t\t").concat(M," .").concat(this.notesClassName," legend {\n\t\t\t\tcolor: ").concat(h,";\n\t\t\t}\n\t\t\t").concat(q,"\n\t\t\t").concat(M," .").concat(this.feedbackFormClassName," input {\n\t\t\t\tbackground-color: ").concat(E,";\n\t\t\t\tborder: ").concat(k,"px solid ").concat(N,";\n\t\t\t\tborder-radius: ").concat(S,"px;\n\t\t\t\tcolor: ").concat(x,";\n\t\t\t\tmargin-right: ").concat(L,"px;\n\t\t\t}\n\t\t\t").concat(M," .").concat(this.feedbackFormClassName," button {\n\t\t\t\tbackground-color: ").concat(O,";\n\t\t\t\tborder: ").concat(I,"px solid ").concat(P,";\n\t\t\t\tborder-radius: ").concat(B,"px;\n\t\t\t\tcolor: ").concat(R,";\n\t\t\t}\n\t\t\tbody #").concat(this.parentContainer.widgetContainerId," {\n\t\t\t\tmargin: ").concat(m,"px ").concat(d,"px;\n\t\t\t}\n\t\t\tbody #").concat(this.parentContainer.widgetContainerId," .").concat(this.parentContainer.overlayClassName," {\n\t\t\t\tbackground-color: ").concat(g,";\n\t\t\t\topacity: 1;\n\t\t\t}\n\t\t\tbody #").concat(this.parentContainer.widgetContainerId," .").concat(this.parentContainer.closeButtonClassName," {\n\t\t\t\ttop: ").concat(u,"px;\n\t\t\t\tright: ").concat(l,"px;\n\t\t\t}")}},{key:"getStyleElement",value:function(){var t="theme"===O,e=this.getDefaultStyles(),n=t?this.getThemeDefaultStyles():"",s=t?this.getUserStyles():"",r=document.createElement("style");return r.type="text/css",c()&&r.setAttribute("abtasty-script-added","true"),r.textContent="".concat(e," ").concat(n," ").concat(s),r}}]),t}();function z(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e&&(s=s.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,s)}return n}function Y(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?z(Object(n),!0).forEach((function(e){s(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):z(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}var H=DATA,G=H.layout,V=H.bannerPosition,Q=H.npsElementReferrer,U=H.npsReferrerInsertType,K=H.contentDirection,J=H.themeType,X=H.theme;function Z(){if("customCss"===J)return!1;var t=Object.entries(DATA).filter((function(t){return a(t,1)[0].includes(X)})).reduce((function(t,e){var n=a(e,2),s=n[0],r=n[1],i=s.split("".concat(X,"_"))[1],o=Y({},t);return o[i]=r,o}),{});return Y({},t,{contentDirection:K})}function tt(){return(tt=n(t.mark((function e(){var n,s,r,i;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:t.t0=G,t.next="popin"===t.t0?3:"banner"===t.t0?5:7;break;case 3:return n=new C,t.abrupt("break",9);case 5:return n=new E(V),t.abrupt("break",9);case 7:return n=new N(U,Q),t.abrupt("break",9);case 9:return s=Z(),r=n.domElement.querySelector(".".concat(n.contentClassName)),i=new F({userStyles:s,parentContainer:n}),n.children=i,i.insertIn(r,"beforeend"),n.init().then((function(t){return t&&n.show()})),t.abrupt("return",{parentContainer:n,NPS:i});case 17:case"end":return t.stop()}}),e)})))).apply(this,arguments)}!function(){tt.apply(this,arguments)}()}(); | ||
!function(){"use strict";var t=function(t,e){return t(e={exports:{}},e.exports),e.exports}((function(t){var e=function(t){var e=Object.prototype,n=e.hasOwnProperty,s="function"==typeof Symbol?Symbol:{},r=s.iterator||"@@iterator",i=s.asyncIterator||"@@asyncIterator",o=s.toStringTag||"@@toStringTag";function a(t,e,n,s){var r=e&&e.prototype instanceof l?e:l,i=Object.create(r.prototype),o=new E(s||[]);return i._invoke=function(t,e,n){var s="suspendedStart";return function(r,i){if("executing"===s)throw new Error("Generator is already running");if("completed"===s){if("throw"===r)throw i;return k()}for(n.method=r,n.arg=i;;){var o=n.delegate;if(o){var a=b(o,n);if(a){if(a===h)continue;return a}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===s)throw s="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);s="executing";var l=c(t,e,n);if("normal"===l.type){if(s=n.done?"completed":"suspendedYield",l.arg===h)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(s="completed",n.method="throw",n.arg=l.arg)}}}(t,n,o),i}function c(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}t.wrap=a;var h={};function l(){}function u(){}function d(){}var m={};m[r]=function(){return this};var g=Object.getPrototypeOf,p=g&&g(g(N([])));p&&p!==e&&n.call(p,r)&&(m=p);var f=d.prototype=l.prototype=Object.create(m);function v(t){["next","throw","return"].forEach((function(e){t[e]=function(t){return this._invoke(e,t)}}))}function y(t){var e;this._invoke=function(s,r){function i(){return new Promise((function(e,i){!function e(s,r,i,o){var a=c(t[s],t,r);if("throw"!==a.type){var h=a.arg,l=h.value;return l&&"object"==typeof l&&n.call(l,"__await")?Promise.resolve(l.__await).then((function(t){e("next",t,i,o)}),(function(t){e("throw",t,i,o)})):Promise.resolve(l).then((function(t){h.value=t,i(h)}),(function(t){return e("throw",t,i,o)}))}o(a.arg)}(s,r,e,i)}))}return e=e?e.then(i,i):i()}}function b(t,e){var n=t.iterator[e.method];if(void 0===n){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,b(t,e),"throw"===e.method))return h;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return h}var s=c(n,t.iterator,e.arg);if("throw"===s.type)return e.method="throw",e.arg=s.arg,e.delegate=null,h;var r=s.arg;return r?r.done?(e[t.resultName]=r.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,h):r:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,h)}function w(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function C(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function E(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(w,this),this.reset(!0)}function N(t){if(t){var e=t[r];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var s=-1,i=function e(){for(;++s<t.length;)if(n.call(t,s))return e.value=t[s],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:k}}function k(){return{value:void 0,done:!0}}return u.prototype=f.constructor=d,d.constructor=u,d[o]=u.displayName="GeneratorFunction",t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===u||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,o in t||(t[o]="GeneratorFunction")),t.prototype=Object.create(f),t},t.awrap=function(t){return{__await:t}},v(y.prototype),y.prototype[i]=function(){return this},t.AsyncIterator=y,t.async=function(e,n,s,r){var i=new y(a(e,n,s,r));return t.isGeneratorFunction(n)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},v(f),f[o]="Generator",f[r]=function(){return this},f.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var n in t)e.push(n);return e.reverse(),function n(){for(;e.length;){var s=e.pop();if(s in t)return n.value=s,n.done=!1,n}return n.done=!0,n}},t.values=N,E.prototype={constructor:E,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(C),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function s(n,s){return o.type="throw",o.arg=t,e.next=n,s&&(e.method="next",e.arg=void 0),!!s}for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r],o=i.completion;if("root"===i.tryLoc)return s("end");if(i.tryLoc<=this.prev){var a=n.call(i,"catchLoc"),c=n.call(i,"finallyLoc");if(a&&c){if(this.prev<i.catchLoc)return s(i.catchLoc,!0);if(this.prev<i.finallyLoc)return s(i.finallyLoc)}else if(a){if(this.prev<i.catchLoc)return s(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return s(i.finallyLoc)}}}},abrupt:function(t,e){for(var s=this.tryEntries.length-1;s>=0;--s){var r=this.tryEntries[s];if(r.tryLoc<=this.prev&&n.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var i=r;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=t,o.arg=e,i?(this.method="next",this.next=i.finallyLoc,h):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),h},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),C(n),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var s=n.completion;if("throw"===s.type){var r=s.arg;C(n)}return r}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:N(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),h}},t}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}}));function e(t,e,n,s,r,i,o){try{var a=t[i](o),c=a.value}catch(t){return void n(t)}a.done?e(c):Promise.resolve(c).then(s,r)}var n=function(t){return function(){var n=this,s=arguments;return new Promise((function(r,i){var o=t.apply(n,s);function a(t){e(o,r,i,a,c,"next",t)}function c(t){e(o,r,i,a,c,"throw",t)}a(void 0)}))}};var s=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t};var r=function(t){if(Array.isArray(t))return t};var i=function(t,e){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t)){var n=[],s=!0,r=!1,i=void 0;try{for(var o,a=t[Symbol.iterator]();!(s=(o=a.next()).done)&&(n.push(o.value),!e||n.length!==e);s=!0);}catch(t){r=!0,i=t}finally{try{s||null==a.return||a.return()}finally{if(r)throw i}}return n}};var o=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")};var a=function(t,e){return r(t)||i(t,e)||o()};const c=()=>Object.prototype.hasOwnProperty.call(window,"ABTastyEditor");const h=()=>!!window.ABTasty.getTestsOnPage()[TEST_ID],l=()=>{const{type:t}=DATA;return`${PACKAGE.replace("@abtasty/","")}${t?`_${t}`:""}`},u=()=>`${PLUGIN_ID.split("-")[0]}_${TEST_ID}`,d=(...t)=>{t.unshift(`[AB Tasty Widget] ${PACKAGE}:`),console.log(...t)},m=(t,e,n)=>{let s=0,r=0;try{document.querySelector(t)}catch(e){const s=`Selector «${t}» not valid.`;return d(s),"function"==typeof n&&n(s)}function i(){clearInterval(r),clearTimeout(s)}return s=setTimeout(()=>{i();const e=`Can't find element «${t}».`;return d(e),"function"==typeof n&&n(e)},1e4),r=setInterval(()=>{const n=document.querySelector(t);return null!==n?(i(),"function"==typeof e&&e(n)):n},200),{clear:i}};async function g(t){let e;switch(t){case"IntersectionObserver":e=await("IntersectionObserver"in window&&"IntersectionObserverEntry"in window&&"intersectionRatio"in window.IntersectionObserverEntry.prototype||function(t){return new Promise((e,n)=>{const s=window.document.getElementsByTagName("script")[0],r=window.document.createElement("script");r.src=t,s.parentNode.insertBefore(r,s),r.onload=e,r.onerror=n})}("https://polyfill.io/v3/polyfill.min.js?flags=gated&features=IntersectionObserver"));break;default:e=!0}return e}class p{constructor({displayRecurrence:t,closingRecurrence:e,validationRecurrence:n},s){this.displayRecurrence=parseFloat(t),this.closingRecurrence=parseFloat(e),this.validationRecurrence=parseFloat(n),this.onSetCallback=s,this.widgetName=l(),this.uniqueId=u(),this.recurrenceKey=`${this.widgetName}_${this.uniqueId}`}getGivenRecurrenceStorageParsed(t){try{const e=t.getItem("ABTastyWidgets");return JSON.parse(e)}catch(e){return t.removeItem("ABTastyWidgets"),!1}}getSessionRecurrenceStorageParsed(){return this.getGivenRecurrenceStorageParsed(window.sessionStorage)}getLocalRecurrenceStorageParsed(){return this.getGivenRecurrenceStorageParsed(window.localStorage)}removeGivenStorage(t,e){const{[this.recurrenceKey]:n,...s}=e;return Object.entries(s).length?(t.setItem("ABTastyWidgets",JSON.stringify(s)),s):(t.removeItem("ABTastyWidgets"),!1)}removeSessionRecurrenceStorage(){const t=this.getSessionRecurrenceStorageParsed();return!!t&&this.removeGivenStorage(window.sessionStorage,t)}removeLocalRecurrenceStorage(){const t=this.getLocalRecurrenceStorageParsed();return!!t&&this.removeGivenStorage(window.localStorage,t)}getSessionRecurrence(){const t=this.getSessionRecurrenceStorageParsed();return!!t&&t[this.recurrenceKey]}getLocalRecurrence(){const t=this.getLocalRecurrenceStorageParsed();return!!t&&t[this.recurrenceKey]}getCurrentRecurrence(){const t=this.getSessionRecurrence(),e=this.getLocalRecurrence();return t||e||{type:!1}}isOver(){const t=this.getLocalRecurrence(),e=(t?parseFloat(t.stamp):0)<(new Date).getTime();return e&&this.removeLocalRecurrenceStorage(),e&&!this.getLocalRecurrence()&&!this.getSessionRecurrence()}setRecurrence(t,e){const n=this.getTypeOfStorage(t);if(!n&&"object"!=typeof n)return!1;const{storageString:s,storageMethod:r}=this.getTypeOfStorage(t),i=this.getStamp(t),o={type:e,stamp:i},{type:a}=this.getCurrentRecurrence(),c=()=>{const t=this.getSessionRecurrence(),e=this.getLocalRecurrence();let n;"session"===s?t?n=this.removeSessionRecurrenceStorage():(this.removeLocalRecurrenceStorage(),n=this.getSessionRecurrenceStorageParsed()):"local"===s&&(e?n=this.removeLocalRecurrenceStorage():(this.removeSessionRecurrenceStorage(),n=this.getLocalRecurrenceStorageParsed()));const i=n?{[this.recurrenceKey]:o,...n}:{[this.recurrenceKey]:o};r.setItem("ABTastyWidgets",JSON.stringify(i)),this.onSetCallback&&"function"==typeof this.onSetCallback&&this.onSetCallback()};if(!r)return!1;if(a&&"validation"!==e)if("closing"===e&&"validation"!==a)c();else{if("display"!==e||"validation"===a||"closing"===a)return!1;c()}else c();return i}setDisplayRecurrence(){this.setRecurrence(this.displayRecurrence,"display")}setClosingRecurrence(){this.setRecurrence(this.closingRecurrence,"closing")}setValidationRecurrence(){this.setRecurrence(this.validationRecurrence,"validation")}getStamp(t){return(new Date).getTime()+864e5*t}getTypeOfStorage(t){return!(isNaN(t)||t<0||0!==t&&!t)&&(t>0?{storageString:"local",storageMethod:window.localStorage}:0===t&&{storageString:"session",storageMethod:window.sessionStorage})}}class f{constructor(){this.targets=[],this.existingTargets=[],this.inViewPortTargets=[],this.visibilityobserver=this.startVisibilityObserver(),this.mutationobserver=this.startMutationObserver()}intersectionHandler(t){t.forEach(t=>{t.isIntersecting?(this.existingTargets=this.existingTargets.filter(e=>e.element!==t.target||(this.inViewPortTargets.push(e),!1)),this.checkElements()):this.inViewPortTargets=this.inViewPortTargets.filter(e=>e.element!==t.target||(this.existingTargets.push(e),!1))})}startVisibilityObserver(){return new IntersectionObserver(this.intersectionHandler.bind(this),{root:null,rootMargin:"0px",threshold:0})}startMutationObserver(){const t=new MutationObserver(this.checkElements.bind(this));return t.observe(document,{attributes:!0,childList:!0,subtree:!0}),t}isElementVisible(t){return this.isElementTopmost(t)&&this.isElementOpaque(t)}isElementOpaque(t){return"HTML"===function t(e,n){return n(e)||!e.parentElement?e:t(e.parentElement,n)}(t,t=>"0"===window.getComputedStyle(t).opacity).nodeName}isElementTopmost(t){const e=t.getBoundingClientRect(),n=[[e.left,e.top],[e.right,e.top],[e.left,e.bottom],[e.right,e.bottom],[e.left+e.width/2,e.top],[e.left+e.width/2,e.bottom],[e.left,e.height/2],[e.right,e.height/2],[e.left+e.left/2,e.height/2]];let s=!1,r=0;for(;!s&&r<n.length;){const e=document.elementFromPoint(...n[r]);s=t===e||t.contains(e),r+=1}return s}checkElements(){this.targets=this.targets.filter(t=>{const e=document.querySelector(t.selector);return!e||(this.existingTargets.push(Object.assign(t,{element:e})),this.visibilityobserver.observe(e),!1)}),this.existingTargets=this.existingTargets.filter(t=>!!document.querySelector(t.selector)||(this.visibilityobserver.unobserve(t.element),this.targets.push(t),!1)),this.inViewPortTargets=this.inViewPortTargets.filter(({element:t,resolve:e})=>!this.isElementVisible(t)||(this.visibilityobserver.unobserve(t),e(t),!1))}watch(t,e){this.targets.push({selector:t,resolve:e})}clear(t){const e=this.targets.filter(e=>e.selector!==t);0===e.length&&(this.existingTargets=[],this.inViewPortTargets=[],this.mutationobserver.disconnect(),this.visibilityobserver.unobserve(t)),this.targets.length>e&&(this.targets=e,this.visibilityobserver.unobserve(t))}}class v{constructor({triggerEvent:t,triggerSelector:e,triggerDelay:n}){this.event=t,this.selector=e&&e.length?e:"body",this.delay=n,this.elementsSelectors=[],this.eventsListeners=[],this.timeouts=[],this.intervals=[],this.observers=[],this.promises=[],this.visibilityObservers=[],this.elementsWaiters=[]}static promiseDeferrer(t){const e={promise:null,resolve:null,reject:null,name:t};return e.promise=new Promise((t,n)=>{e.resolve=t,e.reject=n}),e}async onElementVisible(){const t=v.promiseDeferrer("onElementVisible");this.promises.push(t);const e=await this.onPageLoad(),n=await g("IntersectionObserver"),s=function(t,e){return ABTasty.widgetUtils||(ABTasty.widgetUtils={}),ABTasty.widgetUtils[t]||Object.assign(ABTasty.widgetUtils,{[t]:new e}),ABTasty.widgetUtils[t]}("VisibilityObserver",f);return this.visibilityObservers.push(s),n&&e&&s.watch(this.selector,t.resolve),t.promise}onPageLoad(){const t=v.promiseDeferrer("onPageLoad");this.promises.push(t);const e=()=>"complete"===document.readyState;if(e())t.resolve(!0);else{const n=()=>e()&&!clearTimeout(s)&&!t.resolve(!0),s=setTimeout(()=>t.resolve(!1),2e4),r=["readystatechange",n,{passive:!0}];this.timeouts.push(s),this.eventsListeners.push(r),document.addEventListener(...r)}return t.promise}onClick(){const t=document.createElement("style");t.type="text/css",t.id=`Click_${u()}`,t.innerHTML=`${this.selector} {\n\t\t\tcursor: pointer !important;\n\t\t\tpointer-events: all !important;\n\t\t}`,document.head.appendChild(t),this.elementsSelectors.push(`#${t.id}`);const e=v.promiseDeferrer("onClick");this.promises.push(e);const n=()=>[...document.querySelectorAll(this.selector)],s=t=>n().some(e=>e.isSameNode(t)||!!t.closest(this.selector)),r=["click",({target:t})=>!!s(t)&&(e.resolve(!0),this.clear()),{passive:!0,capture:!0}];return this.eventsListeners.push(r),document.addEventListener(...r),e.promise}onExitIntent(){const t=v.promiseDeferrer("onExitIntent");this.promises.push(t);const e=["mouseleave",async({clientY:e})=>{if(!(e>0))if(this.delay){const e=1e3*this.delay,n=setTimeout(()=>{t.resolve(!0)},e);this.timeouts.push(n)}else t.resolve(!0)},{passive:!0}],n=m("body",t=>{t.addEventListener(...e),this.eventsListeners.push([t,...e]),this.elementsWaiters=this.elementsWaiters.filter(t=>t!==n)});return this.elementsWaiters.push(n),t.promise}onDelay(){const t=v.promiseDeferrer("onDelay");this.promises.push(t);const e=1e3*this.delay,n=setTimeout(()=>{t.resolve(!0)},e);return this.timeouts.push(n),t.promise}onReengage(){const t=v.promiseDeferrer("onReengage");this.promises.push(t);const e=1e3*this.delay;let n=e;const s=[()=>(n=e,n),{passive:!0}];["click","mousemove","scroll","keypress"].forEach(t=>{document.addEventListener(t,...s),this.eventsListeners.push([t,...s])});const r=setInterval(()=>{n<=0?t.resolve(!0):n-=100},100);return this.intervals.push(r),t.promise}clear(){return this.elementsSelectors.length&&(this.elementsSelectors.forEach(t=>{document.querySelector(t)&&document.querySelector(t).remove()}),this.elementsSelectors=[]),this.eventsListeners.length&&(this.eventsListeners.forEach(t=>{const[e,...n]="string"==typeof t[0]?[document,...t]:t;e&&n.length>1&&e.removeEventListener(...n)}),this.eventsListeners=[]),this.timeouts.length&&(this.timeouts.forEach(t=>clearTimeout(t)),this.timeouts=[]),this.intervals.length&&(this.intervals.forEach(t=>clearInterval(t)),this.intervals=[]),this.observers.length&&(this.observers.forEach(t=>t.disconnect()),this.observers=[]),this.visibilityObservers.length&&(this.visibilityObservers.forEach(t=>t.clear(this.selector)),this.visibilityObservers=[]),this.promises.length&&(this.promises.forEach(t=>t.resolve(!1)),this.promises=[]),this.elementsWaiters.length&&(this.elementsWaiters.forEach(t=>t.clear()),this.elementsWaiters=[]),this}async isTriggered(){let t;switch(this.clear(),this.event){case"pageLoad":t=await this.onPageLoad(),this.clear();break;case"click":t=await this.onClick(),this.clear();break;case"exitIntent":t=await this.onExitIntent(),this.clear();break;case"delay":t=await this.onDelay(),this.clear();break;case"reengage":t=await this.onReengage(),this.clear();break;case"elementVisible":t=await this.onElementVisible(),this.clear();break;default:t=!1}return t}}class y{constructor(t,e,n){this.recurrence=t,this.isWidgetApplied=e,this.callback=n,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(t){const e=h(),{type:n}=this.recurrence?this.recurrence.getCurrentRecurrence():{type:!1},s=()=>t&&"display"===n||this.recurrenceIsDone();return!this.isWidgetApplied()&&e&&s()?(this.clearWatcher(),this.callback("rebuild",t)):(!this.isWidgetApplied()||e&&s())&&(this.isWidgetApplied()||e)||(this.clearWatcher(),this.callback("remove",t),this.watch()),this}eventHandler(){let t=h();return[250,500].forEach(e=>setTimeout(()=>500===e&&h()===t?this:(t=h(),this.decisionHandler(!1)),e)),this}observerHandler(t){const e=t.some(({removedNodes:t})=>t&&t.length),n=t.some(({addedNodes:t})=>t&&t.length);return e||n?(this.decisionHandler(!0),this):this}watch(){if(c())return this;this.clearWatcher(),document.addEventListener(...this.eventListenerParams);const t=m("body",e=>{const n=[e,{childList:!0,subtree:!0}];this.observer.observe(...n),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(t=>t.clear()),this.elementsWaiters=[]),this.observer.disconnect(),this}}const b=["pageLoad","delay","reengage"];class w{constructor(){this.uniqueId=u(),this.widgetName=l(),this.recurrenceParams=(()=>{const{displayRecurrence:t,closingRecurrence:e,validationRecurrence:n}=DATA;return!(c()||!(t||e||n))&&{displayRecurrence:t,closingRecurrence:e,validationRecurrence:n}})(),this.triggerParams=(()=>{const{triggerEvent:t,triggerEventClick:e,triggerEventExitDelay:n,triggerEventDelay:s,triggerEventReengageDelay:r}=DATA;if(c()||!t)return!1;const i=e;let o;switch(t){case"exitIntent":o=n;break;case"delay":o=s;break;case"reengage":o=r;break;default:o=0}return{triggerEvent:t,triggerSelector:i,triggerDelay:o}})(),this.recurrence=!!this.recurrenceParams&&new p(this.recurrenceParams,this.clearGivenClearables.bind(this)),this.trigger=!!this.triggerParams&&new v(this.triggerParams),this.pageWatcher=new y(this.recurrence,this.isWidgetApplied.bind(this),this.onPageChange.bind(this)),this.hasOncePerPageTrigger=!!this.trigger&&b.some(t=>t===this.trigger.event),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(t=>document.removeEventListener(...t)),this.eventsListeners=[]),this.timeouts.length&&(this.timeouts.forEach(t=>clearTimeout(t)),this.timeouts=[]),this.intervals.length&&(this.intervals.forEach(t=>clearInterval(t)),this.intervals=[]),this.observers.length&&(this.observers.forEach(t=>t.disconnect()),this.observers=[]),this.promises.length&&(this.promises.forEach(t=>t.resolve(!1)),this.promises=[]),this.elementsWaiters.length&&(this.elementsWaiters.forEach(t=>t.clear()),this.elementsWaiters=[])}isWidgetApplied(){return this.domElement&&!!this.domElement.closest("html")}removeOldDomElement(){const t=document.getElementById(this.widgetContainerId);return t&&t.remove(),this}insert(){const t=m("head",e=>(this.elementsWaiters=this.elementsWaiters.filter(e=>e!==t),e.appendChild(this.styleElement)),e=>(this.elementsWaiters=this.elementsWaiters.filter(e=>e!==t),d(e))),e=m("body",t=>(this.elementsWaiters=this.elementsWaiters.filter(t=>t!==e),this.removeOldDomElement(),t.appendChild(this.domElement)),t=>(this.elementsWaiters=this.elementsWaiters.filter(t=>t!==e),d(t)));return this.elementsWaiters.push(t,e),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():c()||this.init().then(t=>t?this.show():this),this}show(){return this.hasBeenShown||c()||window.ABTastyEvent(`${this.widgetName} 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&&!c()&&window.ABTastyEvent(`${this.widgetName} closed`,null,TEST_ID),this.closedByUser=!0,this.domElement.classList.add(this.hideClassName),this}async init(){if(!c()&&!h())return!1;if(this.trigger&&this.trigger.promises.length)return!1;const t=this.recurrence&&this.recurrence.isOver();return this.recurrence&&!t?(this.pageWatcher.watch(),!1):(this.pageWatcher.watch(),!!(c()||!this.trigger||this.trigger&&await this.trigger.isTriggered())&&(this.insert(),this.addCloseEvent(),this))}onPageChange(t,e){const n=()=>this.init().then(t=>t&&this.show());switch(e||(this.hasBeenShown=!1),t){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().show():n()}}addCloseEvent(...t){const e=this.domElement.querySelectorAll(`\n\t\t\t.${this.overlayClassName},\n\t\t\t.${this.closeButtonClassName}\n\t\t`);return t.push(...e),t.forEach(t=>{t.addEventListener("click",()=>{this.recurrence&&this.recurrence.setClosingRecurrence(),this.hide(),setTimeout(()=>this.remove(),1e3)},{passive:!0,once:!0})}),this}getDom(){const t=document.createElement("div");return t.className=`${this.basicClassName} ${this.hideClassName}`,t.id=this.widgetContainerId,t.innerHTML=`\n\t\t\t<div class="${this.overlayClassName}"></div>\n\t\t\t<div class="${this.contentClassName}">\n\t\t\t\t<button class="${this.closeButtonClassName}" ${c()?"data-abtasty-actionnable":""}>+</button>\n\t\t\t</div>`,t}getStyleTag(t=""){const e=document.createElement("style");return e.type="text/css",c()&&e.setAttribute("abtasty-script-added","true"),e.textContent=`\n\t\t\t.${this.hideClassName} {opacity: 0 !important; pointer-events: none;}\n\t\t\t${t}`,e}}class C extends w{constructor(){super(),this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){return`\n\t\t#${this.widgetContainerId} {\n\t\t\tposition: fixed;\n\t\t\ttop: 0;\n\t\t\tleft: 0;\n\t\t\twidth: 100%;\n\t\t\theight: 100%;\n\t\t\tz-index: 9999;\n\t\t\topacity: 1;\n\t\t\ttransition: opacity 0.25s ease;\n\t\t}\n\t\t#${this.widgetContainerId} .${this.overlayClassName} {\n\t\t\tposition: absolute;\n\t\t\tz-index: -1;\n\t\t\ttop: 0;\n\t\t\tleft: 0;\n\t\t\twidth: 100%;\n\t\t\theight: 100%;\n\t\t\tbackground-color: black;\n\t\t\topacity: 0.6;\n\t\t}\n\t\t#${this.widgetContainerId} .${this.contentClassName} {\n\t\t\tposition: absolute;\n\t\t\tleft: 50%;\n\t\t\ttop: 50%;\n\t\t\ttransform: translate(-50%, -50%);\n\t\t\twidth: auto;\n\t\t\theight: auto;\n\t\t}\n\t\t#${this.widgetContainerId} .${this.closeButtonClassName} {\n\t\t\tposition: absolute;\n\t\t\ttop: 0;\n\t\t\tright: 0;\n\t\t\twidth: auto;\n\t\t\theight: auto;\n\t\t\tcolor: black;\n\t\t\tbackground: none;\n\t\t\tborder: none;\n\t\t\ttransform: rotate(45deg);\n\t\t\tcursor: pointer;\n\t\t\toutline: none;\n\t\t\tfont-size: 1.8em;\n\t\t}\n\t\t\n\t\t@media screen and (max-width: 550px) and (orientation: portrait) {\n\t\t\t#${this.widgetContainerId} .${this.closeButtonClassName} {\n\t\t\t\tfont-size: 6vmin;\n\t\t\t}\n\t\t}`}}class E extends w{constructor(t){super(),this.position=t,this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){return`\n\t\t#${this.widgetContainerId} {\n\t\t\tposition: fixed;\n\t\t\t${this.position}: 0;\n\t\t\tleft: 0;\n\t\t\twidth: 100%;\n\t\t\theight: auto;\n\t\t\tz-index: 9999;\n\t\t\topacity: 1;\n\t\t\ttransition: opacity 0.25s ease;\n\t\t}\n\t\t#${this.widgetContainerId} .${this.overlayClassName} {\n\t\t\tdisplay: none;\n\t\t}\n\t\t#${this.widgetContainerId} .${this.closeButtonClassName} {\n\t\t\tposition: absolute;\n\t\t\ttop: 0;\n\t\t\tright: 0;\n\t\t\twidth: auto;\n\t\t\theight: auto;\n\t\t\tcolor: black;\n\t\t\tbackground: none;\n\t\t\tborder: none;\n\t\t\ttransform: rotate(45deg);\n\t\t\tcursor: pointer;\n\t\t\toutline: none;\n\t\t\tfont-size: 1.8em;\n\t\t}`}}class N extends w{constructor(t,e){super(),this.position=t,this.referrerElement=e,this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}insert(){const t=m("head",e=>(this.elementsWaiters=this.elementsWaiters.filter(e=>e!==t),e.appendChild(this.styleElement)),e=>(this.elementsWaiters=this.elementsWaiters.filter(e=>e!==t),d(e))),e=m(this.referrerElement,t=>(this.elementsWaiters=this.elementsWaiters.filter(t=>t!==e),this.removeOldDomElement(this.domElement.id),t.insertAdjacentElement(this.position,this.domElement)),t=>(this.elementsWaiters=this.elementsWaiters.filter(t=>t!==e),d(t)));return this.elementsWaiters.push(t,e),this}getStyles(){return`\n\t\t#${this.widgetContainerId} {\n\t\t\twidth: auto;\n\t\t\theight: auto;\n\t\t\tposition: relative;\n\t\t\tmargin: 0;\n\t\t\tpadding: 0;\n\t\t}\n\t\t#${this.widgetContainerId} .${this.overlayClassName} {\n\t\t\tdisplay: none;\n\t\t}\n\t\t#${this.widgetContainerId} .${this.closeButtonClassName} {\n\t\t\tposition: absolute;\n\t\t\ttop: 0;\n\t\t\tright: 0;\n\t\t\twidth: auto;\n\t\t\theight: auto;\n\t\t\tcolor: black;\n\t\t\tbackground: none;\n\t\t\tborder: none;\n\t\t\ttransform: rotate(45deg);\n\t\t\tcursor: pointer;\n\t\t\toutline: none;\n\t\t\tfont-size: 1.8em;\n\t\t}`}}var k=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")};function S(t,e){for(var n=0;n<e.length;n++){var s=e[n];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}var x=function(t,e,n){return e&&S(t.prototype,e),n&&S(t,n),t};function T(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e&&(s=s.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,s)}return n}var L=DATA,O=L.themeType,P=L.layout,I=L.isFeedBackQuestion,B=L.isThankYouMessage,R=L.isLegend,W=L.timeHide,j=L.stepToShow,A=L.question,D=L.feedbackQuestion,$=L.buttonText,_=L.thankYouMessage,M=L.zeroLegend,q=L.tenLegend,F=function(){function t(e){var n=e.userStyles,s=e.parentContainer;k(this,t),this.question=A,this.feedbackQuestion=D,this.userStyles=n,this.parentContainer=s,this.buttonText=$,this.thankYouMessage=_,this.legend={zeroLegend:M,tenLegend:q},this.baseClassName="nps_container",this.npsClassName="".concat(this.baseClassName,"_").concat(s.uniqueId),this.questionClassName="".concat(this.baseClassName,"_question"),this.notesClassName="".concat(this.baseClassName,"_notes"),this.feedbackQuestionClassName="".concat(this.questionClassName,"_feedback"),this.feedbackFormClassName="".concat(this.questionClassName,"_feedback_form"),this.notesButtonsClassName="".concat(this.notesClassName,"_button"),this.thankYouClassName="".concat(this.baseClassName,"_thanks"),this.hideClassName="nps_".concat(s.uniqueId,"_display_none"),this.currentNote=NaN,this.userFeedback="",this.npsContainer=this.getContainer(),this.questionElement=this.getQuestionElement(),this.notesContainer=this.getNotesElement(),this.feedbackElements=this.getFeedBackElements(),this.thankYouElement=this.getThankYouElement(),this.npsElement=this.getNPSElement(),this.styleElement=this.getStyleElement()}return x(t,[{key:"sendNote",value:function(){if(!c()&&!isNaN(this.currentNote)){try{window.abtasty.send("nps",{ns:this.currentNote,nf:this.userFeedback})}catch(t){}this.parentContainer.recurrence.setValidationRecurrence()}return this}},{key:"insertIn",value:function(t,e){return document.head.insertAdjacentElement("beforeend",this.styleElement),t.insertAdjacentElement(e,this.npsElement),this}},{key:"remove",value:function(){return this.npsElement&&this.npsElement.remove(),this.styleElement&&this.styleElement.remove(),this}},{key:"complete",value:function(){var t=this;this.sendNote(),setTimeout((function(){t.parentContainer.hide(),setTimeout((function(){t.remove()}),1e3)}),1e3*W)}},{key:"onClickNote",value:function(t){this.currentNote=Number(t.target.dataset.note),I&&this.feedbackQuestion&&this.feedbackQuestion.length?this.showFeedBack():B&&this.thankYouMessage&&this.thankYouMessage.length?this.showThankYouMessage():this.complete()}},{key:"onFeedbackSend",value:function(){B&&this.thankYouMessage&&this.thankYouMessage.length?this.showThankYouMessage():this.complete()}},{key:"showFeedBack",value:function(){var t=this;return this.npsContainer.childNodes.forEach((function(e){return e.classList.add(t.hideClassName)})),Object.values(this.feedbackElements).forEach((function(e){return e.classList.remove(t.hideClassName)})),this}},{key:"showThankYouMessage",value:function(){var t=this;return this.npsContainer.childNodes.forEach((function(e){return e.classList.add(t.hideClassName)})),this.thankYouElement.classList.remove(this.hideClassName),this.complete(),this}},{key:"getThankYouElement",value:function(){var t=document.createElement("p");return t.className="".concat(this.thankYouClassName," ").concat(this.hideClassName),t.innerHTML=this.thankYouMessage,c()&&"displayThanksStep"===j&&t.classList.remove(this.hideClassName),t}},{key:"getFeedBackElements",value:function(){var t=this,e=document.createElement("p");e.className="".concat(this.feedbackQuestionClassName," ").concat(this.hideClassName),e.innerHTML=this.feedbackQuestion;var n=document.createElement("form");n.className="".concat(this.feedbackFormClassName," ").concat(this.hideClassName),n.addEventListener("submit",(function(t){return t.preventDefault()}),{passive:!1});var s=document.createElement("input");s.className="".concat(this.feedbackQuestionClassName,"_input"),s.type="text";var r=document.createElement("button");return r.className="".concat(this.feedbackQuestionClassName,"_button"),r.innerHTML=this.buttonText,r.addEventListener("click",(function(){return t.userFeedback=s.value,t.onFeedbackSend()}),{passive:!0}),c()&&"displayFeedbackStep"===j&&[e,n].forEach((function(e){return e.classList.remove(t.hideClassName)})),n.appendChild(s),n.appendChild(r),{feedbackQuestionElement:e,feedbackFormElement:n}}},{key:"getNotesElement",value:function(){var t=this,e=document.createElement("div");e.className=this.notesClassName,c()&&"displayNoteStep"!==j&&e.classList.add(this.hideClassName);for(var n=10;n>=0;){var s=document.createElement("button");s.className=this.notesButtonsClassName,s.dataset.note=n,c()&&s.setAttribute("data-abtasty-actionnable",""),s.innerHTML+="<span>".concat(n,"</span>"),s.addEventListener("click",(function(e){return t.onClickNote(e)}),{passive:!0}),e.insertAdjacentElement("afterbegin",s),5===n&&s.insertAdjacentHTML("afterend","<br>"),n-=1}return R&&(e.insertAdjacentHTML("afterbegin","<legend>".concat(this.legend.zeroLegend,"</legend>")),e.insertAdjacentHTML("beforeend","<legend>".concat(this.legend.tenLegend,"</legend>"))),e}},{key:"getQuestionElement",value:function(){var t=document.createElement("p");return t.className=this.questionClassName,t.innerHTML=this.question,c()&&"displayNoteStep"!==j&&t.classList.add(this.hideClassName),t}},{key:"getContainer",value:function(){var t=document.createElement("div");return t.className="".concat(this.baseClassName," ").concat(this.npsClassName),t}},{key:"getNPSElement",value:function(){var t=this;return this.npsContainer.appendChild(this.questionElement),this.npsContainer.appendChild(this.notesContainer),I&&Object.values(this.feedbackElements).forEach((function(e){t.npsContainer.appendChild(e)})),B&&this.npsContainer.appendChild(this.thankYouElement),this.npsContainer}},{key:"getDefaultStyles",value:function(){var t="\n\t\t\t#".concat(this.parentContainer.widgetContainerId," .").concat(this.baseClassName,",\n\t\t\t#").concat(this.parentContainer.widgetContainerId," .").concat(this.baseClassName," *");return"\n\t\t".concat(t," {\n\t\t\twidth: auto;\n\t\t\theight: auto;\n\t\t\tmin-width: inherit;\n\t\t\tmin-height: inherit;\n\t\t\tmax-width: inherit;\n\t\t\tmax-height: inherit;\n\t\t\tline-height: 1;\n\t\t\tmargin: 0;\n\t\t\tpadding: 0;\n\t\t\tborder: none;\n\t\t\tbox-sizing: border-box;\n\t\t}\n\t\t#").concat(this.parentContainer.widgetContainerId," .").concat(this.hideClassName," {\n\t\t\tdisplay: none !important;\n\t\t}\n\t\t#").concat(this.parentContainer.widgetContainerId," .").concat(this.baseClassName," .").concat(this.notesButtonsClassName," span {\n\t\t\tpointer-events: none;\n\t\t}\n\t\tbody #").concat(this.parentContainer.widgetContainerId," .").concat(this.parentContainer.closeButtonClassName," {\n\t\t\tpadding: 0;\n\t\t\tline-height: 1;\n\t\t}\n\t\t@media (orientation: landscape) {\n\t\t\t").concat(t," {\n\t\t\t\tfont-size: .55vmax;\n\t\t\t}\n\t\t}\n\t\t@media (orientation: landscape) and (max-width: 1280px) {\n\t\t\t").concat(t," {\n\t\t\t\tfont-size: .7vmax;\n\t\t\t}\n\t\t}\n\t\t@media (orientation: landscape) and (max-width: 800px) {\n\t\t\t").concat(t," {\n\t\t\t\tfont-size: 1vmax;\n\t\t\t}\n\t\t}\n\t\t@media (orientation: portrait) {\n\t\t\t").concat(t," {\n\t\t\t\tfont-size: 1vmin;\n\t\t\t}\n\t\t}\n\t\t@media (orientation: portrait) and (max-width: 550px) {\n\t\t\t").concat(t," {\n\t\t\t\tfont-size: 2.2vmin;\n\t\t\t\tline-height: 1.3;\n\t\t\t\tmax-width: ").concat("popin"===P?"85vw":"auto",";\n\t\t\t}\n\t\t}")}},{key:"getThemeDefaultStyles",value:function(){var t="popin"===P?"75em":"auto",e="#".concat(this.parentContainer.widgetContainerId," .").concat(this.npsClassName);return"\n\t\t".concat(e,",\n\t\t").concat(e," * {\n\t\t\tdisplay: flex;\n\t\t\tflex-wrap: nowrap;\n\t\t\tjustify-content: center;\n\t\t}\n\t\t").concat(e," {\n\t\t\twidth: ").concat(t,";\n\t\t\talign-items: center;\n\t\t}\n\t\t").concat(e," .").concat(this.questionClassName,",\n\t\t").concat(e," .").concat(this.feedbackQuestionClassName,",\n\t\t").concat(e," .").concat(this.thankYouClassName," {\n\t\t\tfont-size: 2em;\n\t\t\tmargin-right: 1em;\n\t\t}\n\t\t").concat(e," .").concat(this.notesClassName," {\n\t\t\tflex-direction: row;\n\t\t}\n\t\t").concat(e," .").concat(this.notesClassName," legend {\n\t\t\talign-self: center;\n\t\t\tfont-size: 1.5em;\n\t\t}\n\t\t").concat(e," .").concat(this.notesClassName," legend:first-of-type {\n\t\t\tmargin-right: 1em;\n\t\t}\n\t\t").concat(e," .").concat(this.notesClassName," legend:last-of-type {\n\t\t\tmargin-left: 1em;\n\t\t}\n\t\t").concat(e," .").concat(this.notesButtonsClassName," {\n\t\t\twidth: 3.5em;\n\t\t\theight: 3.5em;\n\t\t}\n\t\t").concat(e," .").concat(this.notesButtonsClassName," span {\n\t\t\tfont-size: 2em;\n\t\t}\n\t\t").concat(e," .").concat(this.feedbackFormClassName," {\n\t\t\tflex-direction: row;\n\t\t}\n\t\t").concat(e," .").concat(this.feedbackFormClassName," input {\n\t\t\twidth: 45em;\n\t\t\theight: 4em;\n\t\t\tpadding: 0 0.5em;\n\t\t}\n\t\t").concat(e," .").concat(this.feedbackFormClassName," button {\n\t\t\twidth: 10em;\n\t\t\tfont-size: 1.4em;\n\t\t}\n\t\t@media screen and (max-width: 550px) and (orientation: portrait) {\n\t\t\t").concat(e," .").concat(this.questionClassName,",\n\t\t\t").concat(e," .").concat(this.feedbackQuestionClassName," ,\n\t\t\t").concat(e," .").concat(this.thankYouClassName," {\n\t\t\t\tmax-width: 90%;\n\t\t\t\t align-self: flex-start;\n\t\t\t}\n\t\t\t").concat(e," .").concat(this.notesClassName," {\n\t\t\t\tdisplay: inline-block;\n\t\t\t\twidth: 100%;\n\t\t\t\ttext-align: center;\n\t\t\t\tline-height: 5.5;\n\t\t\t\tposition: relative;\n\t\t\t\t").concat(R?"padding-bottom: 4em;":"","\n\t\t\t}\n\t\t\t").concat(e," .").concat(this.notesButtonsClassName," {\n\t\t\t\tdisplay: inline-block;\n\t\t\t\twidth: 4em;\n\t\t\t\theight: 4em;\n\t\t\t}\n\t\t\t").concat(e," .").concat(this.notesClassName," legend {\n\t\t\t\tposition: absolute;\n\t\t\t\tbottom: 0;\n\t\t\t\tleft: 0;\n\t\t\t\tmargin: 0 !important;\n\t\t\t\tfont-size: 1.25em;\n\t\t\t}\n\t\t\t").concat(e," .").concat(this.notesClassName," legend:first-of-type {\n\t\t\t\tbottom: 1.2em;\n\t\t\t}\n\t\t\t").concat(e," .").concat(this.notesClassName," legend:first-of-type::before {\n\t\t\t\tcontent: '0:';\n\t\t\t\tmargin-right: 0.4em;\n\t\t\t}\n\t\t\t").concat(e," .").concat(this.notesClassName," legend:last-of-type::before {\n\t\t\t\tcontent: '10:';\n\t\t\t\tmargin-right: 0.4em;\n\t\t\t}\n\t\t\t").concat(e," .").concat(this.feedbackFormClassName," {\n\t\t\t\tflex-direction: column;\n\t\t\t\twidth: 100%;\n\t\t\t}\n\t\t\t").concat(e," .").concat(this.feedbackFormClassName," input {\n\t\t\t\tmargin: 0;\n\t\t\t\twidth: 100%;\n\t\t\t\theight: 3em;\n\t\t\t\tfont-size: 1.8em;\n\t\t\t}\n\t\t\t").concat(e," .").concat(this.feedbackFormClassName," button {\n\t\t\t\twidth: 50%;\n\t\t\t\theight: 2.7em;\n\t\t\t\tmargin-top: 1em;\n\t\t\t\talign-self: center;\n\t\t\t\tfont-size: 1.5em;\n\t\t\t\tfont-weight: bold;\n\t\t\t}\n\t\t}")}},{key:"getUserStyles",value:function(){var t,e=this.userStyles,n=e.backgroundColor,r=e.borderColor,i=e.borderRadius,o=e.borderWidth,c=e.dropShadow,h=e.textColor,l=e.horizontalPaddingContainer,u=e.verticalPaddingContainer,d=e.horizontalMarginContainer,m=e.verticalMarginContainer,g=e.overlayColor,p=e.shadowOpacity,f=e.buttonsContrast,v=e.buttonsBorderRadius,y=e.buttonsShape,b=e.contentDirection,w=e.questionMargin,C=e.buttonsHorizontalMargin,E=e.inputBackgroundColor,N=e.inputBorderColor,k=e.inputBorderWidth,S=e.inputBorderRadius,x=e.inputTextColor,L=e.inputMarginWithButton,O=e.feedbackButtonBackgroundColor,P=e.feedbackButtonBorderColor,I=e.feedbackButtonBorderWidth,B=e.feedbackButtonBorderRadius,R=e.feedbackButtonTextColor,W=Object.entries(this.userStyles).filter((function(t){return a(t,1)[0].includes(f)})).reduce((function(t,e){var n=a(e,2),r=n[0],i=n[1],o=r.split("_".concat(f))[0],c=function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?T(Object(n),!0).forEach((function(e){s(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):T(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}({},t);return c[o]=i,c}),{}),j=W.buttonsBackgroundColor,A=W.buttonsTextColor,D=W.buttonsBorderColor,$=W.buttonsBorderWidth;switch(y){case"roundsquare":t="border-radius: ".concat(v,"px;");break;case"round":t="border-radius: 50%;";break;default:t=""}var _=c?"box-shadow: 0px 5px 10px 2px rgba(0, 0, 0, ".concat(p/100,");"):"",M="#".concat(this.parentContainer.widgetContainerId," .").concat(this.npsClassName),q="\n\t\t\t".concat(M," .").concat(this.notesButtonsClassName," {\n\t\t\t\tmargin-left: ").concat(C,"px;\n\t\t\t\tmargin-right: ").concat(C,"px;\n\t\t\t\tbackground-color: ").concat(j,";\n\t\t\t\tborder: ").concat($,"px solid ").concat(D,";\n\t\t\t\t").concat(t,"\n\t\t\t}\n\t\t\t").concat(M," .").concat(this.notesButtonsClassName," span {\n\t\t\t\tcolor: ").concat(A,";\n\t\t\t}");return"\n\t\t\tbody ".concat(M," {\n\t\t\t\tflex-direction: ").concat(b,";\n\t\t\t\tbackground-color: ").concat(n,";\n\t\t\t\tborder: ").concat(o,"px solid ").concat(r,";\n\t\t\t\tborder-radius: ").concat(i,"px;\n\t\t\t\tpadding: ").concat(u,"px ").concat(l,"px;\n\t\t\t\t").concat(_,"\n\t\t\t}\n\t\t\t").concat(M," .").concat(this.questionClassName,",\n\t\t\t").concat(M," .").concat(this.feedbackQuestionClassName," ,\n\t\t\t").concat(M," .").concat(this.thankYouClassName," {\n\t\t\t\tcolor: ").concat(h,";\n\t\t\t\tmargin-").concat("row"===b?"right":"bottom"," : ").concat(w,"px;\n\t\t\t}\n\t\t\t").concat(M," .").concat(this.thankYouClassName," {\n\t\t\t\tmargin-bottom: 0;\n\t\t\t}\n\t\t\t").concat(M," .").concat(this.notesClassName," legend {\n\t\t\t\tcolor: ").concat(h,";\n\t\t\t}\n\t\t\t").concat(q,"\n\t\t\t").concat(M," .").concat(this.feedbackFormClassName," input {\n\t\t\t\tbackground-color: ").concat(E,";\n\t\t\t\tborder: ").concat(k,"px solid ").concat(N,";\n\t\t\t\tborder-radius: ").concat(S,"px;\n\t\t\t\tcolor: ").concat(x,";\n\t\t\t\tmargin-right: ").concat(L,"px;\n\t\t\t}\n\t\t\t").concat(M," .").concat(this.feedbackFormClassName," button {\n\t\t\t\tbackground-color: ").concat(O,";\n\t\t\t\tborder: ").concat(I,"px solid ").concat(P,";\n\t\t\t\tborder-radius: ").concat(B,"px;\n\t\t\t\tcolor: ").concat(R,";\n\t\t\t}\n\t\t\tbody #").concat(this.parentContainer.widgetContainerId," {\n\t\t\t\tmargin: ").concat(m,"px ").concat(d,"px;\n\t\t\t}\n\t\t\tbody #").concat(this.parentContainer.widgetContainerId," .").concat(this.parentContainer.overlayClassName," {\n\t\t\t\tbackground-color: ").concat(g,";\n\t\t\t\topacity: 1;\n\t\t\t}\n\t\t\tbody #").concat(this.parentContainer.widgetContainerId," .").concat(this.parentContainer.closeButtonClassName," {\n\t\t\t\ttop: ").concat(u,"px;\n\t\t\t\tright: ").concat(l,"px;\n\t\t\t}")}},{key:"getStyleElement",value:function(){var t="theme"===O,e=this.getDefaultStyles(),n=t?this.getThemeDefaultStyles():"",s=t?this.getUserStyles():"",r=document.createElement("style");return r.type="text/css",c()&&r.setAttribute("abtasty-script-added","true"),r.textContent="".concat(e," ").concat(n," ").concat(s),r}}]),t}();function z(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e&&(s=s.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,s)}return n}function Y(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?z(Object(n),!0).forEach((function(e){s(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):z(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}var H=DATA,G=H.layout,V=H.bannerPosition,Q=H.npsElementReferrer,U=H.npsReferrerInsertType,K=H.contentDirection,J=H.themeType,X=H.theme;function Z(){if("customCss"===J)return!1;var t=Object.entries(DATA).filter((function(t){return a(t,1)[0].includes(X)})).reduce((function(t,e){var n=a(e,2),s=n[0],r=n[1],i=s.split("".concat(X,"_"))[1],o=Y({},t);return o[i]=r,o}),{});return Y({},t,{contentDirection:K})}function tt(){return(tt=n(t.mark((function e(){var n,s,r,i;return t.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:t.t0=G,t.next="popin"===t.t0?3:"banner"===t.t0?5:7;break;case 3:return n=new C,t.abrupt("break",9);case 5:return n=new E(V),t.abrupt("break",9);case 7:return n=new N(U,Q),t.abrupt("break",9);case 9:return s=Z(),r=n.domElement.querySelector(".".concat(n.contentClassName)),i=new F({userStyles:s,parentContainer:n}),n.children=i,i.insertIn(r,"beforeend"),n.init().then((function(t){return t&&n.show()})),t.abrupt("return",{parentContainer:n,NPS:i});case 17:case"end":return t.stop()}}),e)})))).apply(this,arguments)}!function(){tt.apply(this,arguments)}()}(); |
{ | ||
"name": "@abtasty/nps", | ||
"description": "Allow you to add a custom NPS on your website", | ||
"version": "0.5.2-0", | ||
"version": "0.5.2-1", | ||
"form": "dist/form.js", | ||
@@ -6,0 +6,0 @@ "main": "dist/main.js", |
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
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
71886