@abtasty/social-proof 1.0.3 → 1.1.0-2

Sign up to get free protection for your applications and to get access to all the features.
package/README.md ADDED
@@ -0,0 +1,52 @@
1
+ # AB-tasty stress-test
2
+
3
+ This widget was generated using AB Tasty Widget CLI. You can find more infomation and documentation about widgets at https://abtasty.gitbooks.io/widget/.
4
+
5
+ ## Preview your widget
6
+
7
+ Launch your widget in a new window and watch for changes.
8
+ ```bash
9
+ npm start
10
+ ```
11
+
12
+ ## Main files
13
+
14
+ * `main.js`
15
+ Main source code of your widget
16
+ * `form.js`
17
+ Configuration form for your widget
18
+ * `icon.png`
19
+ Icon for your widget (recommended size: 200x200px)
20
+
21
+ You can specify each file location in the `package.json` like this:
22
+ ```json
23
+ "main": "dist/main.js",
24
+ "form": "dist/form.js",
25
+ "icon": "icon.png",
26
+ ```
27
+
28
+ ## Included
29
+
30
+ * [Rollup.js](https://rollupjs.org/) module bundler (like Webpack but smaller and faster).
31
+ * ES6 support using [Babel](https://babeljs.io/).
32
+ * JavaScript Linting with [ESLint](http://eslint.org/) and [Airbnb style](https://github.com/airbnb/javascript).
33
+ * JavaScript minified with [UglifyJS](https://github.com/mishoo/UglifyJS2).
34
+ * [Prettier](https://prettier.io/) to format code.
35
+
36
+
37
+
38
+ **We heard your widget have an UI, so we allowed ourselves to include some extra:**
39
+ * [Pug](https://github.com/aMarCruz/rollup-plugin-pug) (aka Jade) to transforms html files into JS template.
40
+ * [PostCSS](https://github.com/egoist/rollup-plugin-postcss) to automatically append your CSS to head just using `import 'yourstyle.css'` and also use CSS plugins including:
41
+ * [CSSnext](http://cssnext.io/) to use the latest CSS syntax today.
42
+ * [cssnano](http://cssnano.co/) to minify CSS.
43
+
44
+
45
+
46
+ ## Add your widget to AB Tasty
47
+
48
+ 1. First, you'll need to have your widget on NPM:
49
+ * Create a minified bundle with `npm run build`
50
+ * Bump the version of your widget ([using semver](http://semver.org/)) with `npm version [patch|minor|major]`
51
+ * Publish it to NPM: `npm publish`
52
+ 2. Once your widget is on NPM, you can now add it on AB Tasty at https://marketplace.abtasty.com/publish.
package/dist/form.js CHANGED
@@ -1 +1 @@
1
- !function(e,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):(e=e||self).widgetForm=r()}(this,(function(){"use strict";var e=function(e,r){(null==r||r>e.length)&&(r=e.length);for(var a=0,n=new Array(r);a<r;a++)n[a]=e[a];return n};var r=function(r){if(Array.isArray(r))return e(r)};var a=function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)};var n=function(r,a){if(r){if("string"==typeof r)return e(r,a);var n=Object.prototype.toString.call(r).slice(8,-1);return"Object"===n&&r.constructor&&(n=r.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(r,a):void 0}};var t=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")};var o=function(e){return r(e)||a(e)||n(e)||t()};const l={en:"Recurrence",fr:"Récurrence",es:"Recurrencia",de:"Wiederholung"},i={en:`${l.en} of the display`,fr:`${l.fr} de l'affichage`,es:`${l.es} de visualización`,de:`${l.de} der Anzeige`},s={en:`${l.en} after closure`,fr:`${l.fr} après fermeture`,es:`${l.es} tras el cierre`,de:`${l.de} nach Schließung`},d={en:`${l.en} after validation`,fr:`${l.fr} après validation`,es:`${l.es} tras la validación`,de:`${l.de} nach der Validierung`},c="style",u="content",p="conditions",f="slider",m="group",h="https://widgets-images.abtasty.com/",g={category:"conditions",type:"select",options:[{label:{en:"Every time",fr:"Tout le temps",es:"Todo el tiempo",de:"Jedes Mal"},value:"-1"},{label:{en:"Every session",fr:"Chaque session",es:"A cada sesión",de:"Jede Session"},value:"0"},{label:{en:"Everyday",fr:"Chaque jour",es:"Cada día",de:"Jeden Tag"},value:"1"},{label:{en:"Every week",fr:"Chaque semaine",es:"Cada semana",de:"Jede Woche"},value:"7"},{label:{en:"Every month",fr:"Chaque mois",es:"Cada mes",de:"Jeden Monat"},value:"30"},{label:{en:"Once per user (no recurrence)",fr:"Une fois par visiteur (pas de récurrence)",es:"Una vez por usuario (sin recurrencia)",de:"Einmal pro User (keine Wiederholung)"},value:"365"}],value:"-1"},b={...g,label:s,propName:"closingRecurrence"},y={category:"conditions",type:m,label:l,collapsible:!0,children:[{...g,label:i,propName:"displayRecurrence"},b,{...g,label:d,propName:"validationRecurrence"}]},v={category:c,type:"colorpicker",label:{en:"Background color",fr:"Couleur de fond",es:"Color de fondo",de:"Hintergrundfarbe"},propName:"backgroundColor",value:"rgba(247, 247, 247, 1)"},w={category:c,type:"colorpicker",label:{en:"Border color",fr:"Couleur de la bordure",es:"Color del borde",de:"Randfarbe"},propName:"borderColor",value:"rgba(0, 127, 145, 1)"},S={category:c,type:"slider",label:{en:"Border radius",fr:"Courbure des coins",es:"Radio del borde",de:"Randradius"},propName:"borderRadius",value:4,unit:"px"},z={category:c,type:"slider",label:{en:"Border thickness",fr:"Épaisseur de la bordure",es:"Grosor del borde",de:"Randdicke"},propName:"borderWidth",value:2,min:0,max:50,unit:"px"},C={category:c,type:"colorpicker",label:{en:"Text color",fr:"Couleur du texte",es:"Color del texto",de:"Textfarbe"},propName:"textColor",value:"rgba(57, 57, 57, 1)"},A={category:c,type:"radioImage",label:{en:"Text alignment",fr:"Alignement du texte",es:"Alineación del texto",de:"Textausrichtung"},propName:"textAlign",value:"center",options:[{label:{en:"Left",fr:"Gauche",es:"Izquierda",de:"Links"},value:"left",src:"https://gitlab.com/builat/staticimages/raw/master/textAlignLeftSmall.png"},{label:{en:"Center",fr:"Centre",es:"Centro",de:"Mittig"},value:"center",src:"https://gitlab.com/builat/staticimages/raw/master/textAlignCenterSmall.png"},{label:{en:"Right",fr:"Droite",es:"Derecha",de:"Recht"},value:"right",src:"https://gitlab.com/builat/staticimages/raw/master/textAlignRightSmall.png"}]},N={category:c,type:"slider",unit:"px",value:0},x={...N,label:{en:"Horizontal margin",fr:"Marges horizontales",es:"Margen horizontal",de:"Horizontaler Rand"},propName:"containerMarginHorizontal"},P={...N,label:{en:"Vertical margin",fr:"Marges verticales",es:"Margen vertical",de:"Vertikaler Rand"},propName:"containerMarginVertical"},O={...N,value:60,label:{en:"Horizontal padding",fr:"Padding horizontal",es:"Relleno horizontal",de:"Horizontale Polsterung"},propName:"containerPaddingHorizontal"},T={...N,value:34,label:{en:"Vertical padding",fr:"Padding vertical",es:"Acolchado vertical",de:"Vertikale Polsterung"},propName:"containerPaddingVertical"},k={category:c,type:"switch",label:{en:"Drop shadow",fr:"Ombre portée",es:"Sombra paralela",de:"Schlagschatten"},propName:"dropShadow",value:!1},E={category:c,type:"colorpicker",label:{en:"Drop shadow color",fr:"Couleur de l'ombre portée",es:"Color de la sombra paralela",de:"Schlagschattenfarbe"},propName:"dropShadowColor",value:"rgba(57, 57, 57, 0.25);"},I={category:c,type:"slider",label:{en:"Drop shadow blur radius (px)",fr:"Longueur de l'ombre portée (px)",es:"Ancho de sombra paralela (px)",de:"Radius der Schlagschattenunschärfe (px)"},propName:"dropShadowBlur",value:10,unit:"px"},j={category:c,type:"switch",label:{en:"Display close button",fr:"Afficher la croix de fermeture",es:"Mostrar botón de cierre",de:"Schließen-Button anzeigen"},propName:"closeButton",value:!0},D={category:c,type:"colorpicker",label:{en:"Overlay color",fr:"Couleur de l'arrière-plan",es:"Color del segundo plano",de:"Overlay-Farbe"},propName:"overlayColor",value:"rgba(0, 0, 0, 0.6)"},B={category:c,type:"switch",label:{en:"Overlay clickable to hide widget",fr:"Fond translucide clicable pour masquer le widget",es:"Fondo translúcido clicable para ocultar el widget",de:"Overlay anklickbar, um das Widget auszublenden"},propName:"overlayClickable",value:!0},R=[{field:z.propName,value:e=>e>0}];w.conditions=R;const $={category:c,type:m,label:{en:"Border",fr:"Bordure",es:"Borde",de:"Rand"},collapsible:!0,children:[z,S,w]},M={category:c,type:m,label:{en:"Text",fr:"Texte",es:"Texto",de:"Text"},collapsible:!0,children:[A,C]},V=[{field:"dropShadow",value:!0}];E.conditions=V,I.conditions=V;const U={category:c,type:m,label:{en:"Container",fr:"Conteneur",es:"Contenedor",de:"Container"},collapsible:!0,children:[x,P,O,T,v,k,E,I,j]},W={category:c,type:m,label:{en:"Overlay",fr:"Fond translucide",es:"Fondo translúcido",de:"Overlay"},collapsible:!0,children:[D,B],conditions:[{field:"layout",value:"popin"}]},q={category:"layout",type:"radioImage",propName:"layout",label:{en:"Select a layout",fr:"Choisissez un modèle",es:"Selecciona un diseño",de:"Wählen Sie ein Layout"},value:"popin",options:[{label:{en:"Modal",fr:"Pop-in",es:"Pop-in",de:"Pop-in"},value:"popin",src:`${h}layout-modal.png`},{label:{en:"Top banner",fr:"Bannière en en-tête",es:"Bandera en cabecera",de:"Banner oben"},value:"bannerTop",src:`${h}layout-top-banner.png`},{label:{en:"Bottom banner",fr:"Bannière en pied-de-page",es:"Bandera al pie de página",de:"Banner unten"},value:"bannerBottom",src:`${h}layout-bottom-banner.png`},{label:{en:"Free placement",fr:"Placement libre",es:"Integrado",de:"Freie Platzierung "},value:"free",src:`${h}layout-free-placement.png`}]},H={category:"layout",type:"selectelement",propName:"elementReferrer",label:{en:"Select the element that will contain the widget",fr:"Sélectionnez l'élément qui va contenir le widget",es:"Seleccione el elemento que contendrá el widget",de:"Wählen Sie das Element aus, das das Widget enthalten soll"},value:"body"},F={category:"layout",type:"radio",propName:"referrerInsertType",value:"beforeend",label:{en:"Select the position in relation to this element",fr:"Choisissez la position par rapport à cet élément",es:"Seleccione la posición en relación con este elemento",de:"Wählen Sie die Position in Bezug auf dieses Element"},options:[{label:{en:"Before",fr:"Avant",es:"Antes",de:"Vor"},value:"beforebegin"},{label:{en:"At the start",fr:"Au début",es:"Al principio",de:"Am Anfang"},value:"afterbegin"},{label:{en:"Before end",fr:"À la fin",es:"Al final",de:"Am ende"},value:"beforeend"},{label:{en:"After",fr:"Après",es:"Después",de:"Hinter"},value:"afterend"}]},Q=[{field:"layout",value:"free"}];H.conditions=Q,F.conditions=Q;var L=o({category:"layout",type:m,label:{en:"Layout",fr:"Modèle",es:"Diseño",de:"Layout"},collapsible:!0,children:[q,H,F]}.children);var _=function(e,r,a){return r in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e};function J(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),a.push.apply(a,n)}return a}function G(e){for(var r=1;r<arguments.length;r++){var a=null!=arguments[r]?arguments[r]:{};r%2?J(Object(a),!0).forEach((function(r){_(e,r,a[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):J(Object(a)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(a,r))}))}return e}var K={category:u,propName:"socialProofContentType",type:"select",value:1,label:{en:"Select the type of content you want to display",fr:"Choisissez le type de contenu à afficher",es:"Selecciona el tipo de contenido que quieres mostrar",de:"Wählen Sie die Art des Inhalts, den Sie anzeigen wollen"},options:[{label:{en:"Number of purchases",fr:"Nombre d'achats",es:"Número de compras",de:"Anzahl der Käufe"},value:1},{label:{en:"Number of views",fr:"Nombre de vues",es:"Número de visualizaciones",de:"Anzahl der Aufrufe"},value:2}]},Z={category:u,type:"textarea"},X="Create your own content with the dynamic tags.",Y="Créez votre propre contenu avec les variables.",ee="Crea tu propio contenido con las variables.",re="Erstellen Sie Ihren eigenen Inhalt mit den dynamischen Tags.",ae="Use !period! and !unit! to display the period duration selected and its unit (hours or days).",ne="Utilisez !period! et !unit! pour afficher la durée de la période sélectionnée et son unité (heures ou jours).",te="Usa !period! y !unit! para mostrar la duración del período seleccionado y su unidad (horas o días).",oe="Verwenden Sie! Zeitraum !period! und !unit! um die ausgewählte Periodendauer und ihre Einheit (Stunden oder Tage) anzuzeigen.",le=[{category:u,propName:"daysTranslations",type:"hidden",value:{en:"days",fr:"jours",es:"días",de:"Tagen"}},{category:u,propName:"hoursTranslations",type:"hidden",value:{en:"hours",fr:"heures",es:"horas",de:"Stunden"}},K,{category:u,propName:"viewInterval",type:"select",value:"count_72hours",label:{en:"Select a period to display",fr:"Choisissez une période à afficher",es:"Seleccione un período para mostrar",de:"Wählen Sie einen Zeitraum für die Anzeige aus"},options:[{label:{en:"In the last 3 hours",fr:"Dans les 3 dernières heures",de:"In den letzen 3 Stunden",es:"En las últimas 3 horas"},value:"count_3hours"},{label:{en:"In the last 12 hours",fr:"Dans les 12 dernières heures",de:"In den letzen 12 Stunden",es:"En las últimas 12 horas"},value:"count_12hours"},{label:{en:"In the last 24 hours",fr:"Dans les 24 dernières heures",de:"In den letzten 24 Stunden",es:"En las últimas 24 horas"},value:"count_24hours"},{label:{en:"In the last 3 days",fr:"Dans les 3 derniers jours",de:"In den letzen 3 Tagen",es:"En los últimos 3 días"},value:"count_72hours"},{label:{en:"In the last 7 days",fr:"Dans les 7 derniers jours",de:"In den letzen 7 Tagen",es:"En los últmos 7 días"},value:"count_168hours"}]},G({},Z,{label:{en:"".concat(X,"\n\nUse !purchaseQty! for the number of purchased products.\n\n").concat(ae),fr:"".concat(Y,"\n\nUtilisez !purchaseQty! pour afficher le nombre de produits achetés.\n\n").concat(ne),es:"".concat(ee,"\n\nUsa !purchaseQty! por la cantidad de productos comprados.\n\n").concat(te),de:"".concat(re,"\n\nVerwenden Sie !purchaseQty! für die Anzahl der gekauften Produkte.\n\n").concat(oe)},propName:"socialProofContentPurchase",value:{en:"This item has been purchased !purchaseQty! times in the last !period! !unit!",fr:"Ce produit a été acheté !purchaseQty! fois depuis !period! !unit!",es:"Este producto se ha comprado !purchaseQty! veces en las últimas !period! !unit!",de:"Dieses Produkt wurde in den letzten !period! !unit! !purchaseQty! mal aufgerufen"},conditions:[{field:K.propName,value:1}]}),G({},Z,{label:{en:"".concat(X,"\n\nUse !views! for the number of pages seen.\n\n").concat(ae),fr:"".concat(Y,"\n\nUtilisez !views! pour afficher le nombre de pages vues.\n\n").concat(ne),es:"".concat(ee,"\n\nUsa !views! por el número de páginas vistas.\n\n").concat(te),de:"".concat(re,"\n\nVerwenden Sie !views! für die Anzahl der gesehenen Seiten.\n\n").concat(oe)},propName:"socialProofContentView",value:{en:"This page has been viewed !views! times in the last !period! !unit!",fr:"Cette page a été vue !views! fois depuis !period! !unit!",es:"Esta página se ha visto !views! veces en las últimas !period! !unit!",de:"Diese Seite wurde in den letzten !period! !unit! !views! mal gekauft"},conditions:[{field:K.propName,value:2}]})];M.collapsed=!1;var ie=[M,U,$,W],se={category:p,type:m,label:{en:"Triggering",fr:"Déclenchement",es:"Gatillo",de:"Triggern"},collapsible:!0,collapsed:!1,children:[{category:p,type:f,propName:"triggerSocialProofMinPurchases",label:{en:"Enter the minimum number of purchases to display the widget.",fr:"Entrez le minimum de produits achetés afin d'afficher le widget.",es:"Introduce el número de compras mínimo para mostrar el widget.",de:"Geben Sie die minimale Anzahl von gesehenen Seiten oder Käufen an, nach der das Widget angezeigt werden soll."},min:1,max:1e3,value:50,conditions:[{field:"socialProofContentType",value:1}]},{category:p,type:f,propName:"triggerSocialProofMinPageViews",label:{en:"Enter the minimum number of page views to display the widget.",fr:"Entrez le minimum de pages vues afin d'afficher le widget.",es:"Introduce el número de visitas mínimo para mostrar el widget."},min:1,max:1e3,value:200,conditions:[{field:"socialProofContentType",value:2}]},{category:p,type:"switch",propName:"autoHide",value:!1,label:{en:"Auto-hide after x seconds",fr:"Auto-masquer après x secondes",es:"Ocultar automáticamente después de x segundos",de:"Automatisches Ausblenden nach x Sekunden"}},{category:p,type:f,propName:"timeHide",min:5,max:120,value:10,label:{en:"Delay",fr:"Délai",es:"Retraso",de:"Verzögert"},conditions:[{field:"autoHide",value:!0}]}]};y.children=[y.children[0],y.children[1]];var de=[se,y];return[].concat(o(L),o(le),o(ie),o(de))}));
1
+ !function(e,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o():"function"==typeof define&&define.amd?define(o):(e=e||self).widgetForm=o()}(this,(function(){"use strict";var e=function(e,o){(null==o||o>e.length)&&(o=e.length);for(var t=0,n=new Array(o);t<o;t++)n[t]=e[t];return n};var o=function(o){if(Array.isArray(o))return e(o)};var t=function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)};var n=function(o,t){if(o){if("string"==typeof o)return e(o,t);var n=Object.prototype.toString.call(o).slice(8,-1);return"Object"===n&&o.constructor&&(n=o.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(o,t):void 0}};var a=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")};var r=function(e){return o(e)||t(e)||n(e)||a()};const i="style",l="content",c="conditions",s="hidden",d="select",p="switch",u="slider",m="group",_="https://widgets-images.abtasty.com/",g={category:"conditions",type:"slider",min:1},y=[{...g,propName:"day",label:"widget_common_conditions_recurrence_ifOptionVariable_labelDays",value:5,max:395},{...g,propName:"week",label:"widget_common_conditions_recurrence_ifOptionVariable_labelWeeks",value:2,max:56},{...g,propName:"month",label:"widget_common_conditions_recurrence_ifOptionVariable_labelMonths",value:1,max:13}],b={category:"conditions",type:"select",options:[{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"}],value:"everytime"},f={...b,label:"widget_common_conditions_recurrence_label_widgetDisplayed",propName:"displayRecurrence"},v=y.map(e=>({...e,propName:`${f.propName}_${e.propName}`,conditions:[{field:f.propName,value:e.propName}]})),h={...b,label:"widget_common_conditions_recurrence_label_widgetDisplayedAfterClosure",propName:"closingRecurrence"},w=y.map(e=>({...e,propName:`${h.propName}_${e.propName}`,conditions:[{field:h.propName,value:e.propName}]})),N={...b,label:"widget_common_conditions_recurrence_label_widgetDisplayedAfterSubmission",propName:"validationRecurrence"},S=y.map(e=>({...e,propName:`${N.propName}_${e.propName}`,conditions:[{field:N.propName,value:e.propName}]})),k={category:"conditions",type:m,label:"widget_common_conditions_recurrence_blockTitle",collapsible:!0,children:[f,...v,h,...w,N,...S]},x={pageLoad:{label:"widget_common_conditions_triggering_option_pageload",value:"pageLoad"},direct:{label:"widget_common_conditions_triggering_option_asap",value:"direct"},click:{label:"widget_common_conditions_triggering_option_click",value:"click"},exitIntent:{label:"widget_common_conditions_triggering_option_exitIntent",value:"exitIntent"},reengage:{label:"widget_common_conditions_triggering_option_afterXSecondsOfInactivity",value:"reengage"},elementVisible:{label:"widget_common_conditions_triggering_option_elementVisible",value:"elementVisible"},customScript:{label:"widget_common_conditions_triggering_option_customTrigger",value:"script"}},P=(Object.keys(x).map(e=>x[e]),{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:`${_}layout/icon-layout-modal.png`},{label:"widget_common_layout_option_topBanner",value:"bannerTop",src:`${_}layout/icon-layout-topBanner.png`},{label:"widget_common_layout_option_bottomBanner",value:"bannerBottom",src:`${_}layout/icon-layout-bottomBanner.png`},{label:"widget_common_layout_option_freePlacement",value:"free",src:`${_}layout/icon-layout-freePlacement.png`}]}),T={category:"layout",type:"selectelement",propName:"elementReferrer",label:"widget_common_layout_label_selectElementContainWidget",value:"body"},C={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"}]},z=[{field:"layout",value:"free"}];T.conditions=z,C.conditions=z;const I={category:"layout",type:m,label:"widget_common_tabName_layout",collapsible:!0,children:[P,T,C]},O={category:i,type:"colorpicker",label:"widget_common_style_container_label_backgroundColor",propName:"backgroundColor",value:"rgba(247, 247, 247, 1)"},A={category:i,type:"colorpicker",label:"widget_common_style_border_label_borderColor",propName:"borderColor",value:"rgba(0, 127, 145, 1)"},j={category:i,type:"slider",label:"widget_common_style_border_label_borderRadius",propName:"borderRadius",value:4,unit:"px"},E={category:i,type:"slider",label:"widget_common_style_border_label_borderThickness",propName:"borderWidth",value:2,min:0,max:50,unit:"px"},D={category:i,type:"colorpicker",label:"widget_common_style_text_label_textColor",propName:"textColor",value:"rgba(57, 57, 57, 1)"},$={category:i,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:`${_}style/icon-text-alignLeft.png`},{label:"widget_common_style_text_textAlignment_option_center",value:"center",src:`${_}style/icon-text-alignCenter.png`},{label:"widget_common_style_text_textAlignment_option_right",value:"right",src:`${_}style/icon-text-alignRight.png`}]},U={category:i,type:"areainput"},V={...U,label:"widget_common_style_container_label_margin",propName:"containerMargin",value:[{top:0,left:0,bottom:0,right:0}]},B={...U,label:"widget_common_style_container_label_padding",propName:"containerPadding",value:[{top:35,left:60,bottom:35,right:60}]},Q={category:i,type:"switch",label:"widget_common_style_container_dropShadow_blockTitle",propName:"dropShadow",value:!1},R={category:i,type:"colorpicker",label:"widget_common_style_container_dropShadow_label_color",propName:"dropShadowColor",value:"rgba(57, 57, 57, 0.25);"},W={category:i,type:"slider",label:"widget_common_style_container_dropShadow_label_blurRadius",propName:"dropShadowBlur",value:10,unit:"px"},M={category:i,type:"switch",label:"widget_common_style_container_label_displayCloseButton",propName:"closeButton",value:!0},X={category:i,type:"colorpicker",label:"widget_common_style_overlay_label_overlayColor",propName:"overlayColor",value:"rgba(0, 0, 0, 0.6)"},H={category:i,type:"switch",label:"widget_common_style_overlay_label_overlayClickable",propName:"overlayClickable",value:!0},L=[{field:E.propName,value:e=>e>0}];A.conditions=L;const q={category:i,type:m,label:"widget_common_style_blockTitle_border",collapsible:!0,children:[E,A,j]},K={category:i,type:m,label:"widget_common_style_blockTitle_text",collapsible:!0,children:[$,D]},Z=[{field:"dropShadow",value:!0}];R.conditions=Z,W.conditions=Z;const F={category:i,type:m,label:"widget_common_style_blockTitle_container",collapsible:!0,children:[V,B,O,Q,R,W,M]},G={category:i,type:m,label:"widget_common_style_blockTitle_overlay",collapsible:!0,children:[X,H],conditions:[{field:"layout",value:"popin"}]};var J=r(I.children);var Y=function(e,o,t){return o in e?Object.defineProperty(e,o,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[o]=t,e};function ee(e,o){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);o&&(n=n.filter((function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable}))),t.push.apply(t,n)}return t}function oe(e){for(var o=1;o<arguments.length;o++){var t=null!=arguments[o]?arguments[o]:{};o%2?ee(Object(t),!0).forEach((function(o){Y(e,o,t[o])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ee(Object(t)).forEach((function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(t,o))}))}return e}var te={category:l,propName:"socialProofContentType",type:d,value:1,label:{en:"Select the type of content you want to display",fr:"Choisissez le type de contenu à afficher",es:"Selecciona el tipo de contenido que quieres mostrar",de:"Wählen Sie die Art des Inhalts, den Sie anzeigen wollen"},options:[{label:{en:"Number of purchases",fr:"Nombre d'achats",es:"Número de compras",de:"Anzahl der Käufe"},value:1},{label:{en:"Number of views",fr:"Nombre de vues",es:"Número de visualizaciones",de:"Anzahl der Aufrufe"},value:2}]},ne={category:l,type:"variablesinput"},ae="Create your own content with the dynamic tags.",re="Créez votre propre contenu avec les variables.",ie="Crea tu propio contenido con las variables.",le="Erstellen Sie Ihren eigenen Inhalt mit den dynamischen Tags.",ce="Use !period! and !unit! to display the period duration selected and its unit (hours or days).",se="Utilisez !period! et !unit! pour afficher la durée de la période sélectionnée et son unité (heures ou jours).",de="Usa !period! y !unit! para mostrar la duración del período seleccionado y su unidad (horas o días).",pe="Verwenden Sie! Zeitraum !period! und !unit! um die ausgewählte Periodendauer und ihre Einheit (Stunden oder Tage) anzuzeigen.",ue=[{category:"content",propName:"socialProofInfo",type:"inlinenotification",label:"widget_socialProof_content_alert_transactionTag",hrefUrl:"https://abtasty.zendesk.com/hc/en-us/articles/360034533374"},{category:l,propName:"daysTranslations",type:s,value:{en:"days",fr:"jours",es:"días",de:"Tagen"}},{category:l,propName:"hoursTranslations",type:s,value:{en:"hours",fr:"heures",es:"horas",de:"Stunden"}},te,{category:l,propName:"viewInterval",type:d,value:"count_72hours",label:{en:"Select a period to display",fr:"Choisissez une période à afficher",es:"Seleccione un período para mostrar",de:"Wählen Sie einen Zeitraum für die Anzeige aus"},options:[{label:{en:"In the last 3 hours",fr:"Dans les 3 dernières heures",de:"In den letzen 3 Stunden",es:"En las últimas 3 horas"},value:"count_3hours"},{label:{en:"In the last 12 hours",fr:"Dans les 12 dernières heures",de:"In den letzen 12 Stunden",es:"En las últimas 12 horas"},value:"count_12hours"},{label:{en:"In the last 24 hours",fr:"Dans les 24 dernières heures",de:"In den letzten 24 Stunden",es:"En las últimas 24 horas"},value:"count_24hours"},{label:{en:"In the last 3 days",fr:"Dans les 3 derniers jours",de:"In den letzen 3 Tagen",es:"En los últimos 3 días"},value:"count_72hours"},{label:{en:"In the last 7 days",fr:"Dans les 7 derniers jours",de:"In den letzen 7 Tagen",es:"En los últmos 7 días"},value:"count_168hours"}]},oe({},ne,{label:{en:"".concat(ae,"\n\nUse !purchaseQty! for the number of purchased products.\n\n").concat(ce),fr:"".concat(re,"\n\nUtilisez !purchaseQty! pour afficher le nombre de produits achetés.\n\n").concat(se),es:"".concat(ie,"\n\nUsa !purchaseQty! por la cantidad de productos comprados.\n\n").concat(de),de:"".concat(le,"\n\nVerwenden Sie !purchaseQty! für die Anzahl der gekauften Produkte.\n\n").concat(pe)},propName:"socialProofContentPurchase",value:{en:"This item has been purchased !purchaseQty! times in the last !period! !unit!",fr:"Ce produit a été acheté !purchaseQty! fois depuis !period! !unit!",es:"Este producto se ha comprado !purchaseQty! veces en las últimas !period! !unit!",de:"Dieses Produkt wurde in den letzten !period! !unit! !purchaseQty! mal aufgerufen"},conditions:[{field:te.propName,value:1}],vars:["purchaseQty","period","unit"]}),oe({},ne,{label:{en:"".concat(ae,"\n\nUse !views! for the number of pages seen.\n\n").concat(ce),fr:"".concat(re,"\n\nUtilisez !views! pour afficher le nombre de pages vues.\n\n").concat(se),es:"".concat(ie,"\n\nUsa !views! por el número de páginas vistas.\n\n").concat(de),de:"".concat(le,"\n\nVerwenden Sie !views! für die Anzahl der gesehenen Seiten.\n\n").concat(pe)},propName:"socialProofContentView",value:{en:"This page has been viewed !views! times in the last !period! !unit!",fr:"Cette page a été vue !views! fois depuis !period! !unit!",es:"Esta página se ha visto !views! veces en las últimas !period! !unit!",de:"Diese Seite wurde in den letzten !period! !unit! !views! mal gekauft"},conditions:[{field:te.propName,value:2}],vars:["views","period","unit"]})];K.collapsed=!1;var me=[K,F,q,G],_e={category:c,type:m,label:"widget_common_conditions_triggering_blockTitle",collapsible:!0,collapsed:!1,children:[{category:c,type:u,propName:"triggerSocialProofMinPurchases",label:{en:"Enter the minimum number of purchases to display the widget.",fr:"Entrez le minimum de produits achetés afin d'afficher le widget.",es:"Introduce el número de compras mínimo para mostrar el widget.",de:"Geben Sie die minimale Anzahl von gesehenen Seiten oder Käufen an, nach der das Widget angezeigt werden soll."},min:1,max:1e3,value:50,conditions:[{field:"socialProofContentType",value:1}]},{category:c,type:u,propName:"triggerSocialProofMinPageViews",label:{en:"Enter the minimum number of page views to display the widget.",fr:"Entrez le minimum de pages vues afin d'afficher le widget.",es:"Introduce el número de visitas mínimo para mostrar el widget."},min:1,max:1e3,value:200,conditions:[{field:"socialProofContentType",value:2}]},{category:c,type:p,propName:"autoHide",value:!1,label:"widget_common_conditions_triggering_autohide_toggler_label_autoHideAfterXSeconds"},{category:c,type:u,propName:"timeHide",min:5,max:120,value:10,label:"widget_common_conditions_triggering_delay_label",conditions:[{field:"autoHide",value:!0}]}]},ge={category:c,type:m,label:"widget_socialProof_conditions_noTrimParamUrl_blockTitle",collapsible:!0,collapsed:!0,children:[{category:c,type:p,propName:"spNoTrim",value:!1,label:"widget_socialProof_conditions_noTrimParamUrl_toggler_label"}]};k.children=k.children.filter((function(e){return e.propName.indexOf("validationRecurrence")<0}));var ye=[_e,k,ge];return[].concat(r(J),r(ue),r(me),r(ye))}));
package/dist/main.js CHANGED
@@ -1 +1 @@
1
- !function(){"use strict";const e="https://social-proof-api.abtasty.com/clients/",t=()=>Object.prototype.hasOwnProperty.call(window,"ABTastyEditor");const s=()=>{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=()=>!!window.ABTasty.getTestsOnPage()[TEST_ID]||(()=>{const e=!!document.getElementById("ABTastyPreviewBar"),t=location.href.includes("ab_project=preview");return e||t})(),r=()=>{const{type:e}=DATA;return`${PACKAGE.replace("@abtasty/","")}${e?`_${e}`:""}`},n=()=>{const e=r();return`${e.charAt(0).toUpperCase()}${e.slice(1)}`.split("-").join(" ")},o=()=>`${PLUGIN_ID.split("-")[0]}_${TEST_ID}`,a=(...e)=>{e.unshift(`[AB Tasty Widget] ${PACKAGE}:`),console.log(...e)},c=e=>{if((()=>{if(t())return!1;const e=ABTasty.getTestsOnPage()[TEST_ID];return!!e&&Object.keys(e.targetings.qaParameters).length>0})()){const t=n();window.console.log(`%c${t} - QA Mode for campaign ${TEST_ID}\n${e}`,"background-color: rgba(0, 127, 145, 1); color: rgba(247, 247, 247, 1)")}},l=(e,t,s)=>{let i=0,r=0;try{document.querySelector(e)}catch(t){const i=`Selector «${e}» not valid.`;return a(i),"function"==typeof s&&s(i)}function n(){clearInterval(r),clearTimeout(i)}return i=setTimeout(()=>{n();const t=`Can't find element «${e}».`;return a(t),"function"==typeof s&&s(t)},1e4),r=setInterval(()=>{const s=document.querySelector(e);return null!==s?(n(),"function"==typeof t&&t(s)):s},200),{clear:n}};async function h(e){let t;switch(e){case"IntersectionObserver":t=await("IntersectionObserver"in window&&"IntersectionObserverEntry"in window&&"intersectionRatio"in window.IntersectionObserverEntry.prototype||function(e){return new Promise((t,s)=>{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=s})}(""));break;default:t=!0}return t}class d{constructor({displayRecurrence:e,closingRecurrence:t,validationRecurrence:s},i){this.displayRecurrence=parseFloat(e),this.closingRecurrence=parseFloat(t),this.validationRecurrence=parseFloat(s),this.onSetCallback=i,this.widgetName=r(),this.uniqueId=o(),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]:s,...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 s=this.getTypeOfStorage(e);if(!s&&"object"!=typeof s)return!1;const{storageString:i,storageMethod:r}=s,n=this.getStamp(e),o={type:t,stamp:n},{type:a}=this.getCurrentRecurrence(),c=()=>{const e=this.getSessionRecurrence(),t=this.getLocalRecurrence();let s;"session"===i?e?s=this.removeSessionRecurrenceStorage():(this.removeLocalRecurrenceStorage(),s=this.getSessionRecurrenceStorageParsed()):"local"===i&&(t?s=this.removeLocalRecurrenceStorage():(this.removeSessionRecurrenceStorage(),s=this.getLocalRecurrenceStorageParsed()));const n=s?{[this.recurrenceKey]:o,...s}:{[this.recurrenceKey]:o};r.setItem("ABTastyWidgets",JSON.stringify(n)),this.onSetCallback&&"function"==typeof this.onSetCallback&&this.onSetCallback()};if(!r)return!1;if(a&&"validation"!==t)if("closing"===t&&"validation"!==a)c();else{if("display"!==t||"validation"===a||"closing"===a)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 u{constructor(){this.targets=[],this.existingTargets=[],this.inViewPortTargets=[],this.visibilityobserver=this.startVisibilityObserver(),this.mutationobserver=this.startMutationObserver()}intersectionHandler(e){e.forEach(e=>{e.isIntersecting?(this.existingTargets=this.existingTargets.filter(t=>t.element!==e.target||(this.inViewPortTargets.push(t),!1)),this.checkElements()):this.inViewPortTargets=this.inViewPortTargets.filter(t=>t.element!==e.target||(this.existingTargets.push(t),!1))})}startVisibilityObserver(){return new IntersectionObserver(this.intersectionHandler.bind(this),{root:null,rootMargin:"0px",threshold:0})}startMutationObserver(){const e=new MutationObserver(this.checkElements.bind(this));return e.observe(document,{attributes:!0,childList:!0,subtree:!0}),e}isElementVisible(e){return this.isElementTopmost(e)&&this.isElementOpaque(e)}isElementOpaque(e){return"HTML"===function e(t,s){return s(t)||!t.parentElement?t:e(t.parentElement,s)}(e,e=>"0"===window.getComputedStyle(e).opacity).nodeName}isElementTopmost(e){const t=e.getBoundingClientRect(),s=[[t.left,t.top],[t.right,t.top],[t.left,t.bottom],[t.right,t.bottom],[t.left+t.width/2,t.top],[t.left+t.width/2,t.bottom],[t.left,t.height/2],[t.right,t.height/2],[t.left+t.left/2,t.height/2]];let i=!1,r=0;for(;!i&&r<s.length;){const t=document.elementFromPoint(...s[r]);i=e===t||e.contains(t),r+=1}return i}checkElements(){this.targets=this.targets.filter(e=>{const t=document.querySelector(e.selector);return!t||(this.existingTargets.push(Object.assign(e,{element:t})),this.visibilityobserver.observe(t),!1)}),this.existingTargets=this.existingTargets.filter(e=>!!document.querySelector(e.selector)||(this.visibilityobserver.unobserve(e.element),this.targets.push(e),!1)),this.inViewPortTargets=this.inViewPortTargets.filter(({element:e,resolve:t})=>!this.isElementVisible(e)||(this.visibilityobserver.unobserve(e),t(e),!1))}watch(e,t){this.targets.push({selector:e,resolve:t})}clear(e){const t=this.targets.filter(t=>t.selector!==e);0===t.length&&(this.existingTargets=[],this.inViewPortTargets=[],this.mutationobserver.disconnect(),this.visibilityobserver.unobserve(document.querySelector(e))),this.targets.length>t&&(this.targets=t,this.visibilityobserver.unobserve(document.querySelector(e)))}}class g{constructor({triggerEvent:e,triggerSelector:t,triggerDelay:s}){this.event=e,this.selector=t&&t.length?t:"body",this.delay=s,this.elementsSelectors=[],this.eventsListeners=[],this.timeouts=[],this.intervals=[],this.observers=[],this.promises=[],this.visibilityObservers=[],this.elementsWaiters=[]}static promiseDeferrer(e){const t={promise:null,resolve:null,reject:null,name:e};return t.promise=new Promise((e,s)=>{t.resolve=e,t.reject=s}),t}async onElementVisible(){const e=g.promiseDeferrer("onElementVisible");this.promises.push(e);const t=await this.onPageLoad(),s=await h("IntersectionObserver"),i=function(e,t){return ABTasty.widgetUtils||(ABTasty.widgetUtils={}),ABTasty.widgetUtils[e]||Object.assign(ABTasty.widgetUtils,{[e]:new t}),ABTasty.widgetUtils[e]}("VisibilityObserver",u);return this.visibilityObservers.push(i),s&&t&&i.watch(this.selector,e.resolve),e.promise}onPageLoad(){const e=g.promiseDeferrer("onPageLoad");this.promises.push(e);const t=()=>"complete"===document.readyState;if(t())e.resolve(!0);else{const s=()=>t()&&!clearTimeout(i)&&!e.resolve(!0),i=setTimeout(()=>e.resolve(!1),2e4),r=["readystatechange",s,{passive:!0}];this.timeouts.push(i),this.eventsListeners.push(r),document.addEventListener(...r)}return e.promise}onClick(){const e=document.createElement("style");e.type="text/css",e.id=`Click_${o()}`,e.innerHTML=`${this.selector} {\n\t\t\tcursor: pointer !important;\n\t\t\tpointer-events: all !important;\n\t\t}`,document.head.appendChild(e),this.elementsSelectors.push(`#${e.id}`);const t=g.promiseDeferrer("onClick");this.promises.push(t);const s=()=>[...document.querySelectorAll(this.selector)],i=e=>s().some(t=>t.isSameNode(e)||!!e.closest(this.selector)),r=["click",({target:e})=>!!i(e)&&(t.resolve(!0),this.clear()),{passive:!0,capture:!0}];return this.eventsListeners.push(r),document.addEventListener(...r),t.promise}onExitIntent(){const e=g.promiseDeferrer("onExitIntent");this.promises.push(e);const t=["mouseleave",async({clientY:t})=>{if(!(t>0))if(this.delay){const t=1e3*this.delay,s=setTimeout(()=>{e.resolve(!0)},t);this.timeouts.push(s)}else e.resolve(!0)},{passive:!0}],s=l("body",e=>{e.addEventListener(...t),this.eventsListeners.push([e,...t]),this.elementsWaiters=this.elementsWaiters.filter(e=>e!==s)});return this.elementsWaiters.push(s),e.promise}onDelay(){const e=g.promiseDeferrer("onDelay");this.promises.push(e);const t=1e3*this.delay,s=setTimeout(()=>{e.resolve(!0)},t);return this.timeouts.push(s),e.promise}onReengage(){const e=g.promiseDeferrer("onReengage");this.promises.push(e);const t=1e3*this.delay;let s=t;const i=[()=>(s=t,s),{passive:!0}];["click","mousemove","scroll","keypress"].forEach(e=>{document.addEventListener(e,...i),this.eventsListeners.push([e,...i])});const r=setInterval(()=>{s<=0?e.resolve(!0):s-=100},100);return this.intervals.push(r),e.promise}getSocialProofPurchases(){const t=g.promiseDeferrer("getSocialProofPurchases");this.promises.push(t);const i=window.ABTastyProductKey,r=s(),{viewInterval:n,triggerSocialProofMinPurchases:o}=DATA;return i||(c("Not able to find ABTastyProductKey, impossible to call the API."),t.resolve(!1)),i&&r?fetch(`${e}${r}/metrics/i?key=${i}`).then(e=>e.ok&&e.json()).then(e=>(e=>{if(void 0===n||void 0===o)return!1;const t=e[n]&&e[n]>=o;return t||c(`Widget will not be shown, product has been purchased ${e[n]} times while ${o} are required`),t})(e)&&t.resolve(e[n])).catch(()=>c("Failed to fetch datas from server.")):t.resolve(!1),t.promise}getSocialProofPageViews(){const t=g.promiseDeferrer("getSocialProofPageViews");this.promises.push(t);const i=encodeURIComponent(`${window.location.pathname}`),r=s(),{viewInterval:n,triggerSocialProofMinPageViews:o}=DATA;return i&&r?fetch(`${e}${r}/metrics/pv?key=${i}`).then(e=>e.ok&&e.json()).then(e=>(e=>{if(void 0===n||void 0===o)return!1;const t=e[n]&&e[n]>=o;return t||c(`Widget will not be shown, page has been seen ${e[n]} times while ${o} are required`),t})(e)&&t.resolve(e[n])).catch(()=>c("Failed to fetch datas from server.")):t.resolve(!1),t.promise}clear(){return this.elementsSelectors.length&&(this.elementsSelectors.forEach(e=>{document.querySelector(e)&&document.querySelector(e).remove()}),this.elementsSelectors=[]),this.eventsListeners.length&&(this.eventsListeners.forEach(e=>{const[t,...s]="string"==typeof e[0]?[document,...e]:e;t&&s.length>1&&t.removeEventListener(...s)}),this.eventsListeners=[]),this.timeouts.length&&(this.timeouts.forEach(e=>clearTimeout(e)),this.timeouts=[]),this.intervals.length&&(this.intervals.forEach(e=>clearInterval(e)),this.intervals=[]),this.observers.length&&(this.observers.forEach(e=>e.disconnect()),this.observers=[]),this.visibilityObservers.length&&(this.visibilityObservers.forEach(e=>e.clear(this.selector)),this.visibilityObservers=[]),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(){let e;switch(this.clear(),this.event){case"pageLoad":e=await this.onPageLoad(),this.clear();break;case"click":e=await this.onClick(),this.clear();break;case"exitIntent":e=await this.onExitIntent(),this.clear();break;case"delay":e=await this.onDelay(),this.clear();break;case"reengage":e=await this.onReengage(),this.clear();break;case"elementVisible":e=await this.onElementVisible(),this.clear();break;case"socialProofPurchases":e=await this.getSocialProofPurchases(),this.clear();break;case"socialProofPageViews":e=await this.getSocialProofPageViews(),this.clear();break;default:e=!1}return e}}class m{constructor(e,t,s){this.recurrence=e,this.isWidgetApplied=t,this.callback=s,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=i(),{type:s}=this.recurrence?this.recurrence.getCurrentRecurrence():{type:!1},r=()=>e&&"display"===s||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=i();return[250,500].forEach(t=>setTimeout(()=>500===t&&i()===e?this:(e=i(),this.decisionHandler(!1)),t)),this}observerHandler(e){const t=e.some(({removedNodes:e})=>e&&e.length),s=e.some(({addedNodes:e})=>e&&e.length);return t||s?(this.decisionHandler(!0),this):this}watch(){if(t())return this;this.clearWatcher(),document.addEventListener(...this.eventListenerParams);const e=l("body",t=>{const s=[t,{childList:!0,subtree:!0}];this.observer.observe(...s),this.elementsWaiters=this.elementsWaiters.filter(t=>t!==e)});return this.elementsWaiters.push(e),this}clearWatcher(){return document.removeEventListener(...this.eventListenerParams),this.elementsWaiters.length&&(this.elementsWaiters.forEach(e=>e.clear()),this.elementsWaiters=[]),this.observer.disconnect(),this}}const p=["pageLoad","delay","reengage","socialProofPurchases","socialProofPageViews"];class v{constructor(){this.children=void 0,this.uniqueId=o(),this.widgetName=r(),this.prettyName=n(),this.recurrenceParams=(()=>{const{displayRecurrence:e,closingRecurrence:s,validationRecurrence:i}=DATA;return!(t()||!(e||s||i))&&{displayRecurrence:e,closingRecurrence:s,validationRecurrence:i}})(),this.triggerParams=(()=>{let{triggerEvent:e}=DATA;const{triggerEventClick:s,triggerEventExitDelay:i,triggerEventDelay:r,triggerEventReengageDelay:n,socialProofContentType:o,triggerEventElementVisible:a}=DATA;if(t()||!e&&!o)return!1;let c,l;switch(e){case"click":c=s;break;case"elementVisible":c=a;break;default:l="body"}switch(e){case"exitIntent":l=i;break;case"delay":l=r;break;case"reengage":l=n;break;default:l=0}return o&&(e=1===o?"socialProofPurchases":"socialProofPageViews"),{triggerEvent:e,triggerSelector:c,triggerDelay:l}})(),this.recurrence=!!this.recurrenceParams&&new d(this.recurrenceParams,this.clearGivenClearables.bind(this)),this.trigger=!!this.triggerParams&&new g(this.triggerParams),this.pageWatcher=new m(this.recurrence,this.isWidgetApplied.bind(this),this.onPageChange.bind(this)),this.hasOncePerPageTrigger=!!this.trigger&&p.some(e=>e===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(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,s)=>{this.elementsWaiters=this.elementsWaiters.filter(e=>e!==t),c(e),s(e)},t=new Promise((t,s)=>{const i=l("head",e=>{this.elementsWaiters=this.elementsWaiters.filter(e=>e!==i),t(e.appendChild(this.styleElement))},t=>e(t,i,s));this.elementsWaiters.push(i)}),s=new Promise((t,s)=>{const{layout:i,elementReferrer:r,referrerInsertType:n}=DATA,{selector:o,position:a}="string"==typeof i&&"free"===i&&"string"==typeof r&&"string"==typeof n?{selector:r,position:n}:{selector:"body",position:"beforeend"},c=l(o,e=>{this.elementsWaiters=this.elementsWaiters.filter(e=>e!==c),this.removeOldDomElement(),t(e.insertAdjacentElement(a,this.domElement))},t=>e(t,c,s));this.elementsWaiters.push(c)});return Promise.all([s,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():t()||this.init().then(({response:e})=>e?this.show():this),this}show(){return this.hasBeenShown||t()||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&&!t()&&window.ABTastyEvent(`${this.prettyName} closed`,null,TEST_ID),this.closedByUser=!0,this.domElement.classList.add(this.hideClassName),this}async init(e){if(!t()&&!i())return!1;if(this.trigger&&this.trigger.promises.length)return!1;const s=this.recurrence&&this.recurrence.isOver();if(this.recurrence&&!s)return this.pageWatcher.watch(),!1;this.pageWatcher.watch();const r=t()||!this.trigger||this.trigger&&await this.trigger.isTriggered();return!!r&&(await this.insert(),this.addCloseEvent(),t()||e||this.hasBeenShown||void 0===this.children||"function"!=typeof this.children.refreshContent||this.children.refreshContent(r),{container:this,response:r})}onPageChange(e,t){const s=()=>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()):s()}}addCloseEvent(...e){const{closeButton:t,overlayClickable:s,layout:i}=DATA,r=[];if(void 0!==s&&s&&void 0!==i&&"popin"===i&&r.push(`.${this.overlayClassName}`),void 0!==t&&t&&r.push(`.${this.closeButtonClassName}`),!r.length)return this;const n=this.domElement.querySelectorAll(r.join(", "));return n.length?(e.push(...n),e.forEach(e=>{e.addEventListener("click",()=>{this.recurrence&&this.recurrence.setClosingRecurrence(),this.hide(),setTimeout(()=>this.remove(),1e3)},{passive:!0,once:!0})}),this):this}getDom(){const{closeButton:e,layout:s}=DATA,i=document.createElement("div");return i.className=`${this.basicClassName} ${this.hideClassName}`,i.id=this.widgetContainerId,i.innerHTML=`\n\t\t\t${void 0!==s&&"popin"===s?`<div class="${this.overlayClassName}"></div>`:""}\n\t\t\t<div class="${this.contentClassName}">\n\t\t\t\t${e?`<button class="${this.closeButtonClassName}" ${t()?"data-abtasty-actionnable":""}><svg viewBox="0 0 16 16">\n\t<defs><path id="prefix__a" d="M12 4.991L11.009 4 8 7.009 4.991 4 4 4.991 7.009 8 4 11.009 4.991 12 8 8.991 11.009 12 12 11.009 8.991 8z"></path></defs>\n\t<g><use xlink:href="#prefix__a"></use></g>\n</svg></button>`:""}\n\t\t\t</div>`,i}getStyleTag(e=""){const{layout:s,backgroundColor:i,backgroundImage:r,borderColor:n,borderRadius:o,borderWidth:a,textColor:c,textAlign:l,overlayColor:h,dropShadow:d,dropShadowColor:u,dropShadowBlur:g,containerMarginHorizontal:m,containerMarginVertical:p,containerPaddingHorizontal:v,containerPaddingVertical:y,closeButton:b,buttonsBorderWidth:w,buttonsBorderColor:f,buttonsBorderRadius:S,buttonsBackgroundColor:T,buttonsTextColor:E}=DATA,C=document.createElement("style");C.type="text/css",t()&&C.setAttribute("abtasty-script-added","true");const $=void 0!==i?`background-color: ${i};`:"",A=void 0!==r?`background-image: url(${r});`:"",P=void 0!==o?`border-radius: ${o}px;`:"",I=void 0!==a&&a?`border-width: ${a}px; border-style: solid;`:"",R=[n,a].every(e=>void 0!==e)&&a?`border-color: ${n};`:"",x=void 0!==c?`color: ${c}; fill: ${c};`:"",k=void 0!==l?`text-align: ${l};`:"",B=void 0!==d&&d?`box-shadow: 0 5px ${g}px 0 ${u};`:"",N=[m,p].every(e=>void 0!==e)?`margin: ${p}px ${m}px;`:"",D=void 0!==m&&void 0===p?`margin-left: ${m}px; margin-right: ${m}px;`:"",W=void 0!==p&&void 0===m?`margin-top: ${p}px; margin-bottom: ${p}px;`:"",L=[v,y].every(e=>void 0!==e)?`padding: ${y}px ${v}px;`:"",O=void 0!==v&&void 0===y?`padding-left: ${v}px; padding-right: ${v}px;`:"",_=void 0!==y&&void 0===v?`padding-top: ${y}px; padding-bottom: ${y}px;`:"",V=void 0!==w&&w?`border-width: ${w}px; border-style: solid;`:"",j=[f,w].every(e=>void 0!==e)&&w?`border-color: ${f};`:"",q=void 0!==S?`border-radius: ${S}px;`:"",M=void 0!==T?`background-color: ${T};`:"",H=void 0!==E?`color: ${E};`:"",U=[s,h].every(e=>void 0!==e)&&"popin"===s?[`#${this.widgetContainerId} .${this.overlayClassName} {`,`background-color: ${h};`,"}"].join(""):"",G=void 0!==b&&b?[`#${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;",x,"}"].join(""):"";return C.textContent=[`.${this.hideClassName} {`,"opacity: 0 !important;","pointer-events: none;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,$,A,P,I,R,x,k,B,N,D,W,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,"display: block;","line-height: 1;",L,O,_,"}",`#${this.widgetContainerId} .${this.contentClassName} > * a, `,`#${this.widgetContainerId} .${this.contentClassName} > * button {`,V,j,q,M,H,"}",U,G,`${e}`].join(""),C}}class y extends v{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;","}"].join("")}}class b extends v{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 w extends v{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("")}}var f=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")};function S(e,t){for(var s=0;s<t.length;s++){var i=t[s];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var T=function(e,t,s){return t&&S(e.prototype,t),s&&S(e,s),e},E=["count_72hours","count_168hours"],C=function(){function e(t){var s=t.parentContainer,i=t.response;f(this,e),this.parentContainer=s,this.spDatas=i,this.baseClassName="socialproof_container",this.spClassName="".concat(this.baseClassName,"_").concat(s.uniqueId),this.spElement=this.getSPElement(),this.styleElement=this.getStyleElement()}return T(e,[{key:"getSPText",value:function(){var t=DATA,s=t.socialProofContentType,i=t.socialProofContentPurchase,r=t.socialProofContentView,n=t.viewInterval;return(1===s?i:r).replace("!purchaseQty!",this.spDatas?'<span class="purchase_quantity">'.concat(this.spDatas,"</span>"):'<span class="purchase_quantity">0 (example)</span>').replace("!views!",this.spDatas?'<span class="pageview_number">'.concat(this.spDatas,"</span>"):'<span class="pageview_number">0 (example)</span>').replace("!period!",'<span class="period">'.concat(e.getPeriod(n),"</span>")).replace("!unit!",'<span class="unit">'.concat(e.getUnits(n),"</span>"))}},{key:"refreshContent",value:function(e){this.spDatas=e;var t=this.getSPText();return this.spElement.querySelector("p").innerHTML=t,this}},{key:"getSPElement",value:function(){var e=document.createElement("div"),t=this.getSPText();return e.className=this.spClassName,e.innerHTML="<p>".concat(t,"</p>"),e}},{key:"insertIn",value:function(e,t){return document.head.insertAdjacentElement("beforeend",this.styleElement),e.insertAdjacentElement(t,this.spElement),this}},{key:"getStyleElement",value:function(){var e=DATA,s=e.textColor,i=e.textAlign,r=document.createElement("style");r.type="text/css",t()&&r.setAttribute("abtasty-script-added","true");var n=void 0!==s?"color: ".concat(s,";"):"",o=void 0!==i?"text-align: ".concat(i,";"):"";return r.textContent=["#".concat(this.parentContainer.widgetContainerId," .").concat(this.spClassName," p {"),"margin: 0;","white-space: pre-line;",n,o,"}",n&&n.length?["#".concat(this.parentContainer.widgetContainerId," .").concat(this.spClassName," span {"),n,"}"].join(""):""].join(""),r}}],[{key:"getPeriod",value:function(e){return e.split(/(?:count_|hours)+/)[1]/(E.includes(e)?24:1)}},{key:"getUnits",value:function(e){var t=DATA,s=t.daysTranslations,i=t.hoursTranslations;return E.includes(e)?s:i}}]),e}();!function(){c("Widget launch");var e=DATA,s=e.autoHide,i=e.timeHide,r=(()=>{const{layout:e}=DATA;let t;switch(e){case"popin":t=new y;break;case"bannerTop":case"bannerBottom":t=new b;break;case"free":t=new w;break;default:t=new v}return t})(),n=r.domElement.querySelector(".".concat(r.contentClassName)),o=new C({parentContainer:r});r.children=o,o.insertIn(n,"beforeend"),r.init(!0).then((function(e){var n=e.response;t()||"number"!=typeof n||o.refreshContent(n),n&&(r.show(),!t()&&"boolean"==typeof s&&"number"==typeof i&&s&&setTimeout((function(){r.hide()}),1e3*i))}))}()}();
1
+ !function(){"use strict";const e=()=>Object.prototype.hasOwnProperty.call(window,"ABTastyEditor");const t=()=>{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},s=()=>!!window.ABTasty.getTestsOnPage()[TEST_ID]||(()=>{const e=!!document.getElementById("ABTastyPreviewBar"),t=location.href.includes("ab_project=preview");return e||t})(),i=()=>{if(e())return!1;const t=ABTasty.getTestsOnPage()[TEST_ID];return!!t&&Object.keys(t.targetings.qaParameters).length>0},r="https://social-proof-api.abtasty.com/clients/",n=()=>{const{type:e}=DATA;return`${PACKAGE.replace("@abtasty/","")}${e?`_${e}`:""}`},o=()=>{const e=n();return`${e.charAt(0).toUpperCase()}${e.slice(1)}`.split("-").join(" ")},a=()=>`${PLUGIN_ID.split("-")[0]}_${TEST_ID}`,c=(...e)=>{e.unshift(`[AB Tasty Widget] ${PACKAGE}:`),console.log(...e)},l=e=>{if(i()){const t=o();window.console.log(`%c${t} - QA Mode for campaign ${TEST_ID}\n${e}`,"background-color: rgba(0, 127, 145, 1); color: rgba(247, 247, 247, 1)")}},h=e=>{const t={promise:null,resolve:null,reject:null,name:e};return t.promise=new Promise((e,s)=>{t.resolve=e,t.reject=s}),t},d=(e,t,s)=>{let i=0,r=0;try{document.querySelector(e)}catch(t){const i=`Selector «${e}» not valid.`;return c(i),"function"==typeof s&&s(i)}function n(){clearInterval(r),clearTimeout(i)}return i=setTimeout(()=>{n();const t=`Can't find element «${e}».`;return c(t),"function"==typeof s&&s(t)},1e4),r=setInterval(()=>{const s=document.querySelector(e);return null!==s?(n(),"function"==typeof t&&t(s)):s},200),{clear:n}};async function u(e){let t;switch(e){case"IntersectionObserver":t=await("IntersectionObserver"in window&&"IntersectionObserverEntry"in window&&"intersectionRatio"in window.IntersectionObserverEntry.prototype||function(e){return new Promise((t,s)=>{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=s})}("https://polyfill.io/v3/polyfill.min.js?flags=gated&features=IntersectionObserver"));break;default:t=!0}return t}class g{constructor({displayRecurrence:e,closingRecurrence:t,validationRecurrence:s},i){this.displayRecurrence=parseFloat(e),this.closingRecurrence=parseFloat(t),this.validationRecurrence=parseFloat(s),this.onSetCallback=i,this.widgetName=n(),this.uniqueId=a(),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]:s,...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 s=this.getTypeOfStorage(e);if(!s&&"object"!=typeof s)return!1;const{storageString:i,storageMethod:r}=s,n=this.getStamp(e),o={type:t,stamp:n},{type:a}=this.getCurrentRecurrence(),c=()=>{const e=this.getSessionRecurrence(),t=this.getLocalRecurrence();let s;"session"===i?e?s=this.removeSessionRecurrenceStorage():(this.removeLocalRecurrenceStorage(),s=this.getSessionRecurrenceStorageParsed()):"local"===i&&(t?s=this.removeLocalRecurrenceStorage():(this.removeSessionRecurrenceStorage(),s=this.getLocalRecurrenceStorageParsed()));const n=s?{[this.recurrenceKey]:o,...s}:{[this.recurrenceKey]:o};r.setItem("ABTastyWidgets",JSON.stringify(n)),this.onSetCallback&&"function"==typeof this.onSetCallback&&this.onSetCallback()};if(!r)return!1;if(a&&"validation"!==t)if("closing"===t&&"validation"!==a)c();else{if("display"!==t||"validation"===a||"closing"===a)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 m{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 e.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),e}onMouseOver({target:e,path:t}){const s=this.inViewportTargets.find(({element:s,selector:i})=>{if(s.isSameNode(e))return!0;const r=[...e.querySelectorAll(i)];if(r.length&&r.includes(s))return!0;if(t.includes(s))return!0;const n=[...e.parentElement.children],o=n.findIndex(t=>t.isSameNode(e)),a=n.filter((e,t)=>t>o);if(a.length){if(a.includes(s))return!0;if(a.some(e=>[...e.querySelectorAll(i)].includes(s)))return!0}return!1});if(s&&this.isElementVisible(s.element)){const{selector:e,element:t,uniqueId:i}=s,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"===function e(t,s){return s(t)||!t.parentElement?t:e(t.parentElement,s)}(e,e=>"0"===window.getComputedStyle(e).opacity).nodeName}isElementTopmost(e){const t=e.getBoundingClientRect(),s=[[t.left,t.top],[t.right,t.top],[t.left,t.bottom],[t.right,t.bottom],[t.left+t.width/2,t.top],[t.left+t.width/2,t.bottom],[t.left,t.height/2],[t.right,t.height/2],[t.left+t.left/2,t.height/2]];let i=!1,r=0;for(;!i&&r<s.length;){const t=document.elementFromPoint(...s[r]);i=e===t||e.contains(t),r+=1}return i}checkElements(){this.targets.forEach(({selector:e,uniqueId:t})=>{const s=document.querySelector(e);s&&!this.existingTargets.find(e=>e.element===s&&e.uniqueId===t)&&(this.existingTargets.push({element:s,selector:e,uniqueId:t}),this.visibilityObserver.observe(s))}),this.existingTargets=this.existingTargets.filter(({selector:e,element:t})=>!!document.querySelector(e)||(this.visibilityObserver.unobserve(t),!1)),this.inViewportTargets=this.inViewportTargets.filter(({selector:e,element:t,uniqueId:s})=>{if(t.matches(e)&&this.isElementVisible(t)){const i=this.targets.find(t=>t.selector===e&&t.uniqueId===s);return i&&i.resolve(t),this.clear(e,s),!1}return!0})}watch(e,t,s){this.targets.push({selector:e,resolve:t,uniqueId:s}),this.startMutationObserver()}clear(e,t){[this.targets,this.existingTargets,this.inViewportTargets]=[this.targets,this.existingTargets,this.inViewportTargets].map(s=>s.filter(({selector:s,uniqueId:i})=>s!==e&&i!==t)),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:s}){this.event=e,this.selector=t&&t.length?t:"body",this.delay=1e3*s,this.elementsSelectors=[],this.eventsListeners=[],this.timeouts=[],this.intervals=[],this.observers=[],this.promises=[],this.visibilityObservers=[],this.elementsWaiters=[]}async onElementVisible({promise:e,resolve:t}){const s=h(`${this.event}DomReady`);this.promises.push(s);const i=await this.onPageLoad(s),r=await u("IntersectionObserver"),n=function(e,t){return ABTasty.widgetUtils||(ABTasty.widgetUtils={}),ABTasty.widgetUtils[e]||Object.assign(ABTasty.widgetUtils,{[e]:new t}),ABTasty.widgetUtils[e]}("VisibilityObserver",m);if(this.visibilityObservers.push(n),r&&i){const e=a();n.watch(this.selector,t,e)}return e}onPageLoad({promise:e,resolve:t}){const s=()=>"complete"===document.readyState;if(!s()){const e=["readystatechange",()=>s()&&t(!0),{passive:!0}];this.eventsListeners.push(e),document.addEventListener(...e)}return t(!0),e}onClick({promise:e,resolve:t}){const s=document.createElement("style");s.type="text/css",s.id=`Click_${a()}`,s.innerHTML=`${this.selector} {\n\t\t\tcursor: pointer !important;\n\t\t\tpointer-events: all !important;\n\t\t}`,document.head.appendChild(s),this.elementsSelectors.push(`#${s.id}`);const i=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 s=["mouseleave",async({clientY:e})=>{e<=0&&t(!0)},{passive:!0}],i=d("body",e=>{e.addEventListener(...s),this.eventsListeners.push([e,...s]),this.elementsWaiters=this.elementsWaiters.filter(e=>e!==i)});return this.elementsWaiters.push(i),e}onReengage({promise:e,resolve:t}){const s=this.delay;let i=s;const r=[()=>(i=s,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:s}=DATA;return new Function(`return new Promise(async resolve => {${s}})`)().then(e=>e&&t(!0)),e}getSocialProofPurchases({promise:e,resolve:s}){const i=window.ABTastyProductKey,n=t(),{viewInterval:o,triggerSocialProofMinPurchases:a,spNoTrim:c}=DATA;return i||(l("Not able to find ABTastyProductKey, impossible to call the API."),s(!1)),i&&n?fetch(`${r}${n}/metrics/i?key=${i}${c?"&noTrim=true":""}`).then(e=>e.ok&&e.json()).then(e=>(e=>{if(void 0===o||void 0===a)return!1;const t=e[o]&&e[o]>=a;return t||l(`Widget will not be shown, product has been purchased ${e[o]} times while ${a} are required`),t})(e)&&s(e[o])).catch(()=>l("Failed to fetch datas from server.")):s(!1),e}getSocialProofPageViews({promise:e,resolve:s}){const i=encodeURIComponent(`${window.location.pathname}`),n=t(),{viewInterval:o,triggerSocialProofMinPageViews:a,spNoTrim:c}=DATA;return i&&n?fetch(`${r}${n}/metrics/pv?key=${i}${c?"&noTrim=true":""}`).then(e=>e.ok&&e.json()).then(e=>(e=>{if(void 0===o||void 0===a)return!1;const t=e[o]&&e[o]>=a;return t||l(`Widget will not be shown, page has been seen ${e[o]} times while ${a} are required`),t})(e)&&s(e[o])).catch(()=>l("Failed to fetch datas from server.")):s(!1),e}clear(){if(this.elementsSelectors.length&&(this.elementsSelectors.forEach(e=>{document.querySelector(e)&&document.querySelector(e).remove()}),this.elementsSelectors=[]),this.eventsListeners.length&&(this.eventsListeners.forEach(e=>{const[t,...s]="string"==typeof e[0]?[document,...e]:e;t&&s.length>1&&t.removeEventListener(...s)}),this.eventsListeners=[]),this.timeouts.length&&(this.timeouts.forEach(e=>clearTimeout(e)),this.timeouts=[]),this.intervals.length&&(this.intervals.forEach(e=>clearInterval(e)),this.intervals=[]),this.observers.length&&(this.observers.forEach(e=>e.disconnect()),this.observers=[]),this.visibilityObservers.length){const e=a();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=h(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)},s=!Object.prototype.hasOwnProperty.call(t,this.event)||await t[this.event]();return this.clear(),"reengage"!==this.event&&this.delay?s&&await(async()=>{const e=h(`${this.event}Delay`);return this.promises.push(e),setTimeout(()=>{e.resolve(!0),this.clear()},this.delay),e.promise})():s}}class v{constructor(e,t,s){this.recurrence=e,this.isWidgetApplied=t,this.callback=s,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:i}=this.recurrence?this.recurrence.getCurrentRecurrence():{type:!1},r=()=>e&&"display"===i||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),s=e.some(({addedNodes:e})=>e&&e.length);return t||s?(this.decisionHandler(!0),this):this}watch(){if(e())return this;this.clearWatcher(),document.addEventListener(...this.eventListenerParams);const t=d("body",e=>{const s=[e,{childList:!0,subtree:!0}];this.observer.observe(...s),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 y{constructor(){this.children=void 0,this.uniqueId=a(),this.widgetName=n(),this.prettyName=o(),this.recurrenceParams=(()=>{const{displayRecurrence:t,closingRecurrence:s,validationRecurrence:i}=DATA;if(e()||!t&&!s&&!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")),s&&(n.closingRecurrence=r[s]("closingRecurrence")),i&&(n.validationRecurrence=r[i]("validationRecurrence")),n})(),this.triggerParams=(()=>{let{triggerEvent:t}=DATA;const{triggerEventClick:s,triggerEventReengageDelay:i,socialProofContentType:r,triggerEventElementVisible:n,triggerEventDelay:o}=DATA;if(e()||!t&&!r)return!1;const a={click:()=>s,elementVisible:()=>n},c=Object.prototype.hasOwnProperty.call(a,t)?a[t]():"body",l="reengage"===t?i:o;return r&&(t=1===r?"socialProofPurchases":"socialProofPageViews"),{triggerEvent:t,triggerSelector:c,triggerDelay:l}})(),this.recurrence=!!this.recurrenceParams&&new g(this.recurrenceParams,this.clearGivenClearables.bind(this)),this.trigger=!!this.triggerParams&&new p(this.triggerParams),this.pageWatcher=new v(this.recurrence,this.isWidgetApplied.bind(this),this.onPageChange.bind(this)),this.hasOncePerPageTrigger=(()=>{const{isOncePerPageTrigger:e,triggerEvent:t}=DATA;return!(!e||!["click","script"].includes(t))||["pageLoad","direct","reengage","socialProofPurchases","socialProofPageViews","elementVisible"].some(e=>e===t)})(),this.basicClassName=`ab_widget_container_${this.widgetName}`,this.widgetContainerId=`${this.basicClassName}_${this.uniqueId}`,this.contentClassName=`${this.basicClassName}_content`,this.overlayClassName=`${this.basicClassName}_overlay`,this.closeButtonClassName=`${this.basicClassName}_close_button`,this.hideClassName=`ab_hide_${this.uniqueId}`,this.domElement=this.getDom(),this.hasBeenShown=!1,this.closedByUser=!1,this.eventsListeners=[],this.timeouts=[],this.intervals=[],this.observers=[],this.promises=[],this.elementsWaiters=[]}clearGivenClearables(){this.eventsListeners.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,s)=>{this.elementsWaiters=this.elementsWaiters.filter(e=>e!==t),l(e),s(e)},t=new Promise((t,s)=>{const i=d("head",e=>{this.elementsWaiters=this.elementsWaiters.filter(e=>e!==i),t(e.appendChild(this.styleElement))},t=>e(t,i,s));this.elementsWaiters.push(i)}),s=new Promise((t,s)=>{const{layout:i,elementReferrer:r,referrerInsertType:n}=DATA,{selector:o,position:a}="string"==typeof i&&"free"===i&&"string"==typeof r&&"string"==typeof n?{selector:r,position:n}:{selector:"body",position:"beforeend"},c=d(o,e=>{this.elementsWaiters=this.elementsWaiters.filter(e=>e!==c),this.removeOldDomElement(),t(e.insertAdjacentElement(a,this.domElement))},t=>e(t,c,s));this.elementsWaiters.push(c)});return Promise.all([s,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 i=this.recurrence&&this.recurrence.isOver();if(this.recurrence&&!i)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 s=()=>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()):s()}}addCloseEvent(...e){const{closeButton:t,overlayClickable:s,layout:i}=DATA,r=[];if(void 0!==s&&s&&void 0!==i&&"popin"===i&&r.push(`.${this.overlayClassName}`),void 0!==t&&t&&r.push(`.${this.closeButtonClassName}`),!r.length)return this;const n=this.domElement.querySelectorAll(r.join(", "));return n.length?(e.push(...n),e.forEach(e=>{e.addEventListener("click",()=>{this.recurrence&&this.recurrence.setClosingRecurrence(),this.hide(),setTimeout(()=>this.remove(),1e3)},{passive:!0,once:!0})}),this):this}getDom(){const{closeButton:t,layout:s}=DATA,i=document.createElement("div");return i.className=`${this.basicClassName} ${this.hideClassName}`,i.id=this.widgetContainerId,i.innerHTML=`\n\t\t\t${void 0!==s&&"popin"===s?`<div class="${this.overlayClassName}"></div>`:""}\n\t\t\t<div class="${this.contentClassName}">\n\t\t\t\t${t?`<button class="${this.closeButtonClassName}" ${e()?"data-abtasty-actionnable":""}><svg viewBox="0 0 16 16">\n\t<defs><path id="prefix__a" d="M12 4.991L11.009 4 8 7.009 4.991 4 4 4.991 7.009 8 4 11.009 4.991 12 8 8.991 11.009 12 12 11.009 8.991 8z"></path></defs>\n\t<g><use xlink:href="#prefix__a"></use></g>\n</svg></button>`:""}\n\t\t\t</div>`,i}getStyleTag(t=""){const{noStyles:s,layout:i}=DATA,{backgroundColor:r,backgroundImage:n,borderColor:o,borderRadius:a,borderWidth:c,textColor:l,textAlign:h,overlayColor:d,dropShadow:u,dropShadowColor:g,dropShadowBlur:m,containerMargin:p,containerPadding:v,closeButton:y,buttonsBorderWidth:w,buttonsBorderColor:b,buttonsBorderRadius:f,buttonsBackgroundColor:S,buttonsTextColor:T}=s?{}:DATA,_=document.createElement("style");_.type="text/css",e()&&_.setAttribute("abtasty-script-added","true");const $=`background-color: ${void 0!==r?r:"rgba(255, 255, 255, 1)"};`,E=void 0!==n?`background-image: url(${n});`:"",C=void 0!==a?`border-radius: ${a}px;`:"",A=void 0!==c&&c?`border-width: ${c}px; border-style: solid;`:"",N=[o,c].every(e=>void 0!==e)&&c?`border-color: ${o};`:"",P=void 0!==l?`color: ${l}; fill: ${l};`:"",I=void 0!==h?`text-align: ${h};`:"",x=void 0!==u&&u?`box-shadow: 0 5px ${m}px 0 ${g};`:"",R=p instanceof Array&&1===p.length&&p[0],O=R?`margin: ${R.top}px ${R.right}px ${R.bottom}px ${R.left}px;`:"",B=R?`margin: calc(${R.top}px * 0.5) calc(${R.right}px * 0.5) calc(${R.bottom}px * 0.5) calc(${R.left}px * 0.5);`:"",k=v instanceof Array&&1===v.length&&v[0],W=k?`padding: ${k.top}px ${k.right}px ${k.bottom}px ${k.left}px;`:"",D=k?`padding: calc(${k.top}px * 0.5) calc(${k.right}px * 0.5) calc(${k.bottom}px * 0.5) calc(${k.left}px * 0.5);`:"",L=void 0!==w&&w?`border-width: ${w}px; border-style: solid;`:"",V=[b,w].every(e=>void 0!==e)&&w?`border-color: ${b};`:"",q=void 0!==f?`border-radius: ${f}px;`:"",j=void 0!==S?`background-color: ${S};`:"",M=void 0!==T?`color: ${T};`:"",H=void 0!==i&&"popin"===i?[`#${this.widgetContainerId} .${this.overlayClassName} {`,`background-color: ${void 0!==d?d:"rgba(0, 0, 0, 0.6)"};`,"}"].join(""):"",U=s||void 0!==y&&y?[`#${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 _.textContent=[`.${this.hideClassName} {`,"opacity: 0 !important;","pointer-events: none;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,$,E,C,A,N,P,I,x,O,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,"display: block;","line-height: 1;",W,"}",`#${this.widgetContainerId} .${this.contentClassName} > * a, `,`#${this.widgetContainerId} .${this.contentClassName} > * button {`,L,V,q,j,M,"}","@media screen and (max-width: 549px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,B,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,D,"}","}",H,U,`${t}`].join(""),_}}class w extends y{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: 549px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,"max-width: 94vw;","}","}"].join("")}}class b extends y{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 f extends y{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 S={category:"conditions",type:"slider",min:1},T=[{...S,propName:"day",label:"widget_common_conditions_recurrence_ifOptionVariable_labelDays",value:5,max:395},{...S,propName:"week",label:"widget_common_conditions_recurrence_ifOptionVariable_labelWeeks",value:2,max:56},{...S,propName:"month",label:"widget_common_conditions_recurrence_ifOptionVariable_labelMonths",value:1,max:13}],_={category:"conditions",type:"select",options:[{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"}],value:"everytime"},$={..._,label:"widget_common_conditions_recurrence_label_widgetDisplayed",propName:"displayRecurrence"},E=(T.map(e=>({...e,propName:`${$.propName}_${e.propName}`,conditions:[{field:$.propName,value:e.propName}]})),{..._,label:"widget_common_conditions_recurrence_label_widgetDisplayedAfterClosure",propName:"closingRecurrence"}),C=(T.map(e=>({...e,propName:`${E.propName}_${e.propName}`,conditions:[{field:E.propName,value:e.propName}]})),{..._,label:"widget_common_conditions_recurrence_label_widgetDisplayedAfterSubmission",propName:"validationRecurrence"}),A=(T.map(e=>({...e,propName:`${C.propName}_${e.propName}`,conditions:[{field:C.propName,value:e.propName}]})),{pageLoad:{label:"widget_common_conditions_triggering_option_pageload",value:"pageLoad"},direct:{label:"widget_common_conditions_triggering_option_asap",value:"direct"},click:{label:"widget_common_conditions_triggering_option_click",value:"click"},exitIntent:{label:"widget_common_conditions_triggering_option_exitIntent",value:"exitIntent"},reengage:{label:"widget_common_conditions_triggering_option_afterXSecondsOfInactivity",value:"reengage"},elementVisible:{label:"widget_common_conditions_triggering_option_elementVisible",value:"elementVisible"},customScript:{label:"widget_common_conditions_triggering_option_customTrigger",value:"script"}});Object.keys(A).map(e=>A[e]);var N=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")};function P(e,t){for(var s=0;s<t.length;s++){var i=t[s];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var I=function(e,t,s){return t&&P(e.prototype,t),s&&P(e,s),e},x=["count_72hours","count_168hours"],R=function(){function t(e){var s=e.parentContainer,i=e.response;N(this,t),this.parentContainer=s,this.spDatas=i,this.baseClassName="socialproof_container",this.spClassName="".concat(this.baseClassName,"_").concat(s.uniqueId),this.spElement=this.getSPElement(),this.styleElement=this.getStyleElement()}return I(t,[{key:"getSPText",value:function(){var e=DATA,s=e.socialProofContentType,i=e.socialProofContentPurchase,r=e.socialProofContentView,n=e.viewInterval;return(1===s?i:r).replace("!purchaseQty!",this.spDatas?'<span class="purchase_quantity">'.concat(this.spDatas,"</span>"):'<span class="purchase_quantity">0 (example)</span>').replace("!views!",this.spDatas?'<span class="pageview_number">'.concat(this.spDatas,"</span>"):'<span class="pageview_number">0 (example)</span>').replace("!period!",'<span class="period">'.concat(t.getPeriod(n),"</span>")).replace("!unit!",'<span class="unit">'.concat(t.getUnits(n),"</span>"))}},{key:"refreshContent",value:function(e){this.spDatas=e;var t=this.getSPText();return this.spElement.innerHTML=t,this}},{key:"getSPElement",value:function(){var e=document.createElement("div"),t=this.getSPText();return e.className=this.spClassName,e.innerHTML=t,e}},{key:"insertIn",value:function(e,t){return document.head.insertAdjacentElement("beforeend",this.styleElement),e.insertAdjacentElement(t,this.spElement),this}},{key:"getStyleElement",value:function(){var t=DATA,s=t.textColor,i=t.textAlign,r=document.createElement("style");r.type="text/css",e()&&r.setAttribute("abtasty-script-added","true");var n=void 0!==s?"color: ".concat(s,";"):"",o=void 0!==i?"text-align: ".concat(i,";"):"";return r.textContent=["#".concat(this.parentContainer.widgetContainerId," .").concat(this.spClassName," p {"),"margin: 0;","white-space: pre-line;",n,o,"}",n&&n.length?["#".concat(this.parentContainer.widgetContainerId," .").concat(this.spClassName," span {"),n,"}"].join(""):""].join(""),r}}],[{key:"getPeriod",value:function(e){return e.split(/(?:count_|hours)+/)[1]/(x.includes(e)?24:1)}},{key:"getUnits",value:function(e){var t=DATA,s=t.daysTranslations,i=t.hoursTranslations;return x.includes(e)?s:i}}]),t}();!function(){l("Widget launch");var t=DATA,s=t.autoHide,i=t.timeHide,r=(()=>{const{layout:e}=DATA;let t;switch(e){case"popin":t=new w;break;case"bannerTop":case"bannerBottom":t=new b;break;case"free":t=new f;break;default:t=new y}return t})(),n=r.domElement.querySelector(".".concat(r.contentClassName)),o=new R({parentContainer:r});r.children=o,o.insertIn(n,"beforeend"),r.init(!0).then((function(t){var n=t.response;e()||"number"!=typeof n||o.refreshContent(n),n&&(r.show(),!e()&&"boolean"==typeof s&&"number"==typeof i&&s&&setTimeout((function(){r.hide()}),1e3*i))}))}()}();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@abtasty/social-proof",
3
3
  "description": "simple",
4
- "version": "1.0.3",
4
+ "version": "1.1.0-2",
5
5
  "main": "dist/main.js",
6
6
  "form": "dist/form.js",
7
7
  "icon": "icon.png",
@@ -16,7 +16,9 @@
16
16
  "buildtestdeps": "rollup -c rolluptests.config.js",
17
17
  "watch": "rollup -c --watch",
18
18
  "build": "rollup -c",
19
- "serve": "widget serve"
19
+ "serve": "widget serve",
20
+ "prepare": "npm run build",
21
+ "postpublish": "echo 'Your widget is on NPM. You can now add your widget to AB Tasty Marketplace at https://marketplace.abtasty.com/add'"
20
22
  },
21
23
  "devDependencies": {
22
24
  "@babel/core": "^7.8.4",
@@ -35,11 +37,11 @@
35
37
  "rollup-plugin-eslint": "^7.0.0"
36
38
  },
37
39
  "dependencies": {
38
- "@abtasty/widget-utils": "1.15.1",
40
+ "@abtasty/widget-utils": "1.16.4-0",
39
41
  "@babel/plugin-proposal-object-rest-spread": "^7.8.3",
40
42
  "@rollup/plugin-commonjs": "^11.0.1",
41
43
  "@rollup/plugin-node-resolve": "^7.0.0",
42
44
  "babel-eslint": "^10.0.3",
43
45
  "rollup-plugin-terser": "^5.2.0"
44
46
  }
45
- }
47
+ }