@abtasty/nps 1.0.3 → 1.1.0

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
+ # NPS
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,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,l=new Array(o);t<o;t++)l[t]=e[t];return l};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 l=function(o,t){if(o){if("string"==typeof o)return e(o,t);var l=Object.prototype.toString.call(o).slice(8,-1);return"Object"===l&&o.constructor&&(l=o.constructor.name),"Map"===l||"Set"===l?Array.from(l):"Arguments"===l||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(l)?e(o,t):void 0}};var n=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 a=function(e){return o(e)||t(e)||l(e)||n()};const i="style",r="content",_="conditions",c="text",p="textarea",d="switch",g="slider",s="group",m="https://widgets-images.abtasty.com/",u="rgba(247, 247, 247, 1)",y={category:_,type:g,min:1},b=[{...y,propName:"day",label:"widget_common_conditions_recurrence_ifOptionVariable_labelDays",value:5,max:395},{...y,propName:"week",label:"widget_common_conditions_recurrence_ifOptionVariable_labelWeeks",value:2,max:56},{...y,propName:"month",label:"widget_common_conditions_recurrence_ifOptionVariable_labelMonths",value:1,max:13}],v={category:_,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"},w={...v,label:"widget_common_conditions_recurrence_label_widgetDisplayed",propName:"displayRecurrence"},f=b.map(e=>({...e,propName:`${w.propName}_${e.propName}`,conditions:[{field:w.propName,value:e.propName}]})),h={...v,label:"widget_common_conditions_recurrence_label_widgetDisplayedAfterClosure",propName:"closingRecurrence"},N=b.map(e=>({...e,propName:`${h.propName}_${e.propName}`,conditions:[{field:h.propName,value:e.propName}]})),k={...v,label:"widget_common_conditions_recurrence_label_widgetDisplayedAfterSubmission",propName:"validationRecurrence"},x=b.map(e=>({...e,propName:`${k.propName}_${e.propName}`,conditions:[{field:k.propName,value:e.propName}]})),S={category:_,type:s,label:"widget_common_conditions_recurrence_blockTitle",collapsible:!0,children:[w,...f,h,...N,k,...x]},T={category:_,type:g,propName:"triggerEventDelay",label:"widget_common_conditions_triggering_delay_label",min:0,max:60,value:0},C={...T,propName:"triggerEventReengageDelay",value:10,max:180},E={category:_,type:"selectelement",propName:"triggerEventClick",value:"body"},B={...E,propName:"triggerEventElementVisible"},A={category:_,type:"textarea",label:"widget_common_conditions_triggering_option_customTrigger",propName:"triggerEventCustomScript",value:"/* In this example snippet, the widget will be triggered as soon as any scroll is detected.\nCreate your own by resolving resolve() with true (which does trigger) or false (which doesn't trigger) */\n\nfunction launchIfScroll() {\n\treturn new Promise(resolve => {\n\t\tdocument.addEventListener('scroll', () => resolve(true), {once: true});\n\t});\n}\n\nconst result = await launchIfScroll();\nreturn resolve(result);",rows:15},L={pageLoad:{label:"widget_common_conditions_triggering_option_pageload",value:"pageLoad"},direct:{label:"widget_common_conditions_triggering_option_asap",value:"direct"},exitIntent:{label:"widget_common_conditions_triggering_option_exitIntent",value:"exitIntent"},reengage:{label:"widget_common_conditions_triggering_option_afterXSecondsOfInactivity",value:"reengage"},click:{label:"widget_common_conditions_triggering_option_click",value:"click"},elementVisible:{label:"widget_common_conditions_triggering_option_elementVisible",value:"elementVisible"},customScript:{label:"widget_common_conditions_triggering_option_customTrigger",value:"script"}},I={category:_,type:"switch",propName:"isOncePerPageTrigger",value:!0,label:"widget_common_conditions_triggering_label_triggerOnlyOnce"},O={category:_,type:"switch",propName:"autoHide",value:!0,label:"widget_common_conditions_triggering_autohide_toggler_label_autoHideAfterRedirection"},R={category:_,type:g,propName:"timeHide",value:2,max:120,label:"widget_common_conditions_triggering_autohide_toggler_label_autoHideAfterXSeconds",conditions:[{field:"autoHide",value:!0}]},M={category:_,type:"select",label:"widget_common_conditions_triggering_label",options:Object.keys(L).map(e=>L[e]),propName:"triggerEvent",value:"pageLoad"};E.conditions=[{field:"triggerEvent",value:"click"}],C.conditions=[{field:"triggerEvent",value:"reengage"}],B.conditions=[{field:"triggerEvent",value:"elementVisible"}],A.conditions=[{field:"triggerEvent",value:"script"}],T.conditions=[{field:"triggerEvent",value:e=>"reengage"!==e}],I.conditions=[{field:"triggerEvent",value:e=>"click"===e||"script"===e}];const P={category:_,type:s,label:"widget_common_conditions_triggering_blockTitle",collapsible:!0,children:[M,...[E,B,A,I,C,T]]},V={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:m+"layout/icon-layout-modal.png"},{label:"widget_common_layout_option_topBanner",value:"bannerTop",src:m+"layout/icon-layout-topBanner.png"},{label:"widget_common_layout_option_bottomBanner",value:"bannerBottom",src:m+"layout/icon-layout-bottomBanner.png"},{label:"widget_common_layout_option_freePlacement",value:"free",src:m+"layout/icon-layout-freePlacement.png"}]},D={category:"layout",type:"selectelement",propName:"elementReferrer",label:"widget_common_layout_label_selectElementContainWidget",value:"body"},Q={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"}]},Y=[{field:"layout",value:"free"}];D.conditions=Y,Q.conditions=Y;const $={category:"layout",type:s,label:"widget_common_tabName_layout",collapsible:!0,children:[V,D,Q]},j={category:i,type:"colorpicker",label:"widget_common_style_container_label_backgroundColor",propName:"backgroundColor",value:u},H={category:i,type:"colorpicker",label:"widget_common_style_border_label_borderColor",propName:"borderColor",value:"rgba(0, 127, 145, 1)"},W={category:i,type:g,label:"widget_common_style_border_label_borderRadius",propName:"borderRadius",value:4,unit:"px"},X={category:i,type:g,label:"widget_common_style_border_label_borderThickness",propName:"borderWidth",value:2,min:0,max:50,unit:"px"},q={category:i,type:"colorpicker",label:"widget_common_style_text_label_textColor",propName:"textColor",value:"rgba(57, 57, 57, 1)"},F={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:m+"style/icon-text-alignLeft.png"},{label:"widget_common_style_text_textAlignment_option_center",value:"center",src:m+"style/icon-text-alignCenter.png"},{label:"widget_common_style_text_textAlignment_option_right",value:"right",src:m+"style/icon-text-alignRight.png"}]},z={category:i,type:"areainput"},U={...z,label:"widget_common_style_container_label_margin",propName:"containerMargin",value:[{top:0,left:0,bottom:0,right:0}]},G={...z,label:"widget_common_style_container_label_padding",propName:"containerPadding",value:[{top:35,left:60,bottom:35,right:60}]},J={category:i,type:"switch",label:"widget_common_style_container_dropShadow_blockTitle",propName:"dropShadow",value:!1},K={category:i,type:"colorpicker",label:"widget_common_style_container_dropShadow_label_color",propName:"dropShadowColor",value:"rgba(57, 57, 57, 0.25);"},Z={category:i,type:g,label:"widget_common_style_container_dropShadow_label_blurRadius",propName:"dropShadowBlur",value:10,unit:"px"},ee={category:i,type:"switch",label:"widget_common_style_container_label_displayCloseButton",propName:"closeButton",value:!0},oe={category:i,type:"colorpicker",label:"widget_common_style_overlay_label_overlayColor",propName:"overlayColor",value:"rgba(0, 0, 0, 0.6)"},te={category:i,type:"switch",label:"widget_common_style_overlay_label_overlayClickable",propName:"overlayClickable",value:!0},le={category:i,type:g,label:"widget_common_style_buttons_label_buttonBorderThickness",propName:"buttonsBorderWidth",value:1,min:0,max:30,unit:"px"},ne={category:i,type:"colorpicker",label:"widget_common_style_buttons_label_buttonBorderColor",propName:"buttonsBorderColor",value:"rgba(87, 184, 199, 1)"},ae={category:i,type:g,label:"widget_common_style_buttons_label_buttonBorderRadius",propName:"buttonsBorderRadius",value:4,min:0,max:30,unit:"px"},ie={category:i,type:"colorpicker",label:"widget_common_style_buttons_label_buttonBackgroundColor",propName:"buttonsBackgroundColor",value:"rgba(0, 127, 145, 1)"},re={category:i,type:"colorpicker",label:"widget_common_style_buttons_label_buttonTextColor",propName:"buttonsTextColor",value:u},_e=[{field:X.propName,value:e=>e>0}];H.conditions=_e;const ce={category:i,type:s,label:"widget_common_style_blockTitle_border",collapsible:!0,children:[X,H,W]},pe={category:i,type:s,label:"widget_common_style_blockTitle_text",collapsible:!0,children:[F,q]},de=[{field:"dropShadow",value:!0}];K.conditions=de,Z.conditions=de;const ge={category:i,type:s,label:"widget_common_style_blockTitle_container",collapsible:!0,children:[U,G,j,J,K,Z,ee]},se={category:i,type:s,label:"widget_common_style_blockTitle_overlay",collapsible:!0,children:[oe,te],conditions:[{field:"layout",value:"popin"}]},me=[{field:le.propName,value:e=>e>0}];ne.conditions=me;const ue={category:i,type:s,label:"widget_common_style_blockTitle_buttons",collapsible:!0,children:[le,ne,ae,ie,re]};var ye=[{field:"isFeedBackQuestion",value:!0}],be=[{field:"isLegend",value:!0}],ve=[{category:r,type:p,propName:"question",label:"widget_nps_content_question_label",value:"widget_nps_content_question_default"},{category:r,type:d,propName:"isLegend",label:"widget_nps_content_legend_toggler_label_displayLegend",value:!1},{category:r,type:c,propName:"minLegend",label:"widget_nps_content_legend_label_minLegend",value:"widget_nps_content_legend_default_minLegend",conditions:be},{category:r,type:c,propName:"maxLegend",label:"widget_nps_content_legend_label_maxLegend",value:"widget_nps_content_legend_default_maxLegend",conditions:be},{category:r,type:d,propName:"isFeedBackQuestion",label:"widget_nps_content_oeq_toggler_label_askOpenEndedQuestion",value:!1},{category:r,type:p,propName:"feedbackQuestion",label:"widget_nps_style_preview_option_openEndedQuestion",value:"widget_nps_content_defaultOpenEndedQuestionValue",conditions:ye},{category:r,type:c,propName:"buttonText",label:"widget_nps_content_buttonText_label",value:"widget_nps_content_buttonText_default_send",conditions:ye},{category:r,type:d,propName:"isThankYouMessage",label:"widget_nps_content_tym_toggler_label_displayThankYouMessage",value:!1},{category:r,type:p,propName:"thankYouMessage",label:"widget_nps_content_tym_label_thankYouMessage",value:"widget_nps_content_tym_default_thankYouMessage",conditions:[{field:"isThankYouMessage",value:!0}]}],we=a($.children);P.collapsed=!1,O.label="widget_common_conditions_triggering_autohide_toggler_label_autoHideAfterSubmit",P.children.push(O),P.children.push(R);var fe=[P,S],he={category:i,type:s,label:{en:"Preview",fr:"Prévisualisation",es:"Previsualización",de:"Vorschau"},collapsible:!0,collapsed:!1,children:[{category:i,type:"radio",propName:"stepToShow",value:"displayNoteStep",label:"widget_nps_style_preview_label_selectStep",options:[{label:"widget_nps_style_preview_option_npsScore",value:"displayNoteStep"},{label:"widget_nps_style_preview_option_openEndedQuestion",value:"displayFeedbackStep"},{label:"widget_nps_style_preview_option_thankYouMessage",value:"displayThanksStep"}]}]},Ne={category:i,type:d,propName:"noStyles",value:!1,label:"widget_common_style_theme_option_custom"},ke=function(e){return!e.noStyles};pe.condition=ke,ue.condition=ke,ge.condition=ke,ce.condition=ke,se.condition=ke,he.collapsed=!1,pe.collapsed=!1;var xe=[he,Ne,pe,ue,ge,ce,se];return[].concat(a(fe),a(ve),a(we),a(xe))}));
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,l=new Array(o);t<o;t++)l[t]=e[t];return l};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 l=function(o,t){if(o){if("string"==typeof o)return e(o,t);var l=Object.prototype.toString.call(o).slice(8,-1);return"Object"===l&&o.constructor&&(l=o.constructor.name),"Map"===l||"Set"===l?Array.from(l):"Arguments"===l||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(l)?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 n=function(e){return o(e)||t(e)||l(e)||a()};const i="style",r="content",_="conditions",c="text",p="textarea",g="switch",d="slider",m="group",s="https://widgets-images.abtasty.com/",u="rgba(247, 247, 247, 1)",b={category:_,type:d,min:1},y=[{...b,propName:"day",label:"widget_common_conditions_recurrence_ifOptionVariable_labelDays",value:5,max:395},{...b,propName:"week",label:"widget_common_conditions_recurrence_ifOptionVariable_labelWeeks",value:2,max:56},{...b,propName:"month",label:"widget_common_conditions_recurrence_ifOptionVariable_labelMonths",value:1,max:13}],v={category:_,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"},w={...v,label:"widget_common_conditions_recurrence_label_widgetDisplayed",propName:"displayRecurrence"},f=y.map(e=>({...e,propName:`${w.propName}_${e.propName}`,conditions:[{field:w.propName,value:e.propName}]})),N={...v,label:"widget_common_conditions_recurrence_label_widgetDisplayedAfterClosure",propName:"closingRecurrence"},k=y.map(e=>({...e,propName:`${N.propName}_${e.propName}`,conditions:[{field:N.propName,value:e.propName}]})),h={...v,label:"widget_common_conditions_recurrence_label_widgetDisplayedAfterSubmission",propName:"validationRecurrence"},x=y.map(e=>({...e,propName:`${h.propName}_${e.propName}`,conditions:[{field:h.propName,value:e.propName}]}));N.condition=({closeButton:e,layout:o,overlayClickable:t})=>!("popin"===o&&!1===e&&!1===t||void 0!==o&&"popin"!==o&&!1===e);const I={category:_,type:m,label:"widget_common_conditions_recurrence_blockTitle",collapsible:!0,children:[w,...f,N,...k,h,...x]},S={category:_,type:d,propName:"triggerEventDelay",label:"widget_common_conditions_triggering_delay_label",min:0,max:60,value:0},T={...S,propName:"triggerEventReengageDelay",value:10,max:180},C={category:_,type:"selectelement",propName:"triggerEventClick",value:"body"},B={...C,propName:"triggerEventElementVisible"},E={category:_,type:"textarea",label:"widget_common_conditions_triggering_option_customTrigger",propName:"triggerEventCustomScript",value:"/* In this example snippet, the widget will be triggered as soon as any scroll is detected.\nCreate your own by resolving resolve() with true (which does trigger) or false (which doesn't trigger) */\n\nfunction launchIfScroll() {\n\treturn new Promise(resolve => {\n\t\tdocument.addEventListener('scroll', () => resolve(true), {once: true});\n\t});\n}\n\nconst result = await launchIfScroll();\nreturn resolve(result);",rows:15},P={pageLoad:{label:"widget_common_conditions_triggering_option_pageload",value:"pageLoad"},direct:{label:"widget_common_conditions_triggering_option_asap",value:"direct"},exitIntent:{label:"widget_common_conditions_triggering_option_exitIntent",value:"exitIntent"},reengage:{label:"widget_common_conditions_triggering_option_afterXSecondsOfInactivity",value:"reengage"},click:{label:"widget_common_conditions_triggering_option_click",value:"click"},elementVisible:{label:"widget_common_conditions_triggering_option_elementVisible",value:"elementVisible"},customScript:{label:"widget_common_conditions_triggering_option_customTrigger",value:"script"}},A={category:_,type:g,propName:"isOncePerPageTrigger",value:!0,label:"widget_common_conditions_triggering_label_triggerOnlyOnce"},O={category:_,type:g,propName:"autoHide",value:!0,label:"widget_common_conditions_triggering_autohide_toggler_label_autoHideAfterRedirection"},L={category:_,type:d,propName:"timeHide",value:2,max:120,label:"widget_common_conditions_triggering_autohide_toggler_label_autoHideAfterXSeconds",conditions:[{field:"autoHide",value:!0}]},U={category:_,type:"select",label:"widget_common_conditions_triggering_label",options:Object.keys(P).map(e=>P[e]),propName:"triggerEvent",value:"pageLoad"};C.conditions=[{field:"triggerEvent",value:"click"}],T.conditions=[{field:"triggerEvent",value:"reengage"}],B.conditions=[{field:"triggerEvent",value:"elementVisible"}],E.conditions=[{field:"triggerEvent",value:"script"}],S.conditions=[{field:"triggerEvent",value:e=>"reengage"!==e}],A.conditions=[{field:"triggerEvent",value:e=>"click"===e||"script"===e}];const R={category:_,type:m,label:"widget_common_conditions_triggering_blockTitle",collapsible:!0,children:[U,...[C,B,E,A,T,S]]},M={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:s+"layout/icon-layout-modal.png"},{label:"widget_common_layout_option_topBanner",value:"bannerTop",src:s+"layout/icon-layout-topBanner.png"},{label:"widget_common_layout_option_bottomBanner",value:"bannerBottom",src:s+"layout/icon-layout-bottomBanner.png"},{label:"widget_common_layout_option_freePlacement",value:"free",src:s+"layout/icon-layout-freePlacement.png"}]},V={category:"layout",type:"selectelement",propName:"elementReferrer",label:"widget_common_layout_label_selectElementContainWidget",value:"body"},Q={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"}]},Y=[{field:"layout",value:"free"}];V.conditions=Y,Q.conditions=Y;const D={category:"layout",type:m,label:"widget_common_tabName_layout",collapsible:!0,children:[M,V,Q]},$={category:i,type:"colorpicker",label:"widget_common_style_container_label_backgroundColor",propName:"backgroundColor",value:u},j={category:i,type:g,label:"widget_common_style_toggler_label_backgroundImage",propName:"isBackgroundImage",value:!1},H={category:i,type:"mediaupload",label:"widget_common_style_toggler_label_backgroundImage",propName:"backgroundImage",value:""},F={category:i,type:"radio",label:"widget_common_style_backgroundImageUploader_imageOptions_label",propName:"backgroundSize",value:"cover",options:[{label:"widget_common_style_backgroundImageUploader_imageOptions_option_cover",value:"cover"},{label:"widget_common_style_backgroundImageUploader_imageOptions_option_contain",value:"contain"},{label:"widget_common_style_backgroundImageUploader_imageOptions_option_fill",value:"100% 100%"},{label:"widget_common_style_backgroundImageUploader_imageOptions_option_none",value:"auto"}]},W={category:i,type:"select",label:"widget_common_style_backgroundImageUploader_imagePosition_select_label",propName:"backgroundPosition",value:"center",options:[{label:"widget_common_style_backgroundImageUploader_imagePosition_option_top",value:"top"},{label:"widget_common_style_backgroundImageUploader_imagePosition_option_bottom",value:"bottom"},{label:"widget_common_style_backgroundImageUploader_imagePosition_option_center",value:"center"},{label:"widget_common_style_backgroundImageUploader_imagePosition_option_left",value:"left"},{label:"widget_common_style_backgroundImageUploader_imagePosition_option_right",value:"right"},{label:"widget_common_style_backgroundImageUploader_imagePosition_option_topLeft",value:"top left"},{label:"widget_common_style_backgroundImageUploader_imagePosition_option_topRight",value:"top right"},{label:"widget_common_style_backgroundImageUploader_imagePosition_option_bottomLeft",value:"bottom left"},{label:"widget_common_style_backgroundImageUploader_imagePosition_option_bottomRight",value:"bottom right"}]},X={category:i,type:g,label:"widget_common_style_backgroundImageUploader_toggler_repeatBackgroundImage",propName:"backgroundRepeat",value:!1},q={category:i,type:"colorpicker",label:"widget_common_style_border_label_borderColor",propName:"borderColor",value:"rgba(0, 127, 145, 1)"},z={category:i,type:d,label:"widget_common_style_border_label_borderRadius",propName:"borderRadius",value:4,unit:"px"},G={category:i,type:d,label:"widget_common_style_border_label_borderThickness",propName:"borderWidth",value:2,min:0,max:50,unit:"px"},J={category:i,type:"colorpicker",label:"widget_common_style_text_label_textColor",propName:"textColor",value:"rgba(57, 57, 57, 1)"},K={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:s+"style/icon-text-alignLeft.png"},{label:"widget_common_style_text_textAlignment_option_center",value:"center",src:s+"style/icon-text-alignCenter.png"},{label:"widget_common_style_text_textAlignment_option_right",value:"right",src:s+"style/icon-text-alignRight.png"}]},Z={category:i,type:"areainput"},ee={...Z,label:"widget_common_style_container_label_margin",propName:"containerMargin",value:[{top:0,left:0,bottom:0,right:0}]},oe={...Z,label:"widget_common_style_container_label_padding",propName:"containerPadding",value:[{top:35,left:60,bottom:35,right:60}]},te={category:i,type:g,label:"widget_common_style_container_dropShadow_blockTitle",propName:"dropShadow",value:!1},le={category:i,type:"colorpicker",label:"widget_common_style_container_dropShadow_label_color",propName:"dropShadowColor",value:"rgba(57, 57, 57, 0.25);"},ae={category:i,type:d,label:"widget_common_style_container_dropShadow_label_blurRadius",propName:"dropShadowBlur",value:10,unit:"px"},ne={category:i,type:g,label:"widget_common_style_container_label_displayCloseButton",propName:"closeButton",value:!0},ie={category:i,type:"colorpicker",label:"widget_common_style_overlay_label_overlayColor",propName:"overlayColor",value:"rgba(0, 0, 0, 0.6)"},re={category:i,type:g,label:"widget_common_style_overlay_label_overlayClickable",propName:"overlayClickable",value:!0},_e={category:i,type:d,label:"widget_common_style_buttons_label_buttonBorderThickness",propName:"buttonsBorderWidth",value:1,min:0,max:30,unit:"px"},ce={category:i,type:"colorpicker",label:"widget_common_style_buttons_label_buttonBorderColor",propName:"buttonsBorderColor",value:"rgba(87, 184, 199, 1)"},pe={category:i,type:d,label:"widget_common_style_buttons_label_buttonBorderRadius",propName:"buttonsBorderRadius",value:4,min:0,max:30,unit:"px"},ge={category:i,type:"colorpicker",label:"widget_common_style_buttons_label_buttonBackgroundColor",propName:"buttonsBackgroundColor",value:"rgba(0, 127, 145, 1)"},de={category:i,type:"colorpicker",label:"widget_common_style_buttons_label_buttonTextColor",propName:"buttonsTextColor",value:u},me={field:j.propName,value:!0},se={field:F.propName,value:e=>"cover"!==e},ue={field:F.propName,value:e=>"100% 100%"!==e};H.conditions=[me],F.conditions=[me],W.conditions=[me,ue],X.conditions=[me,ue,se];const be=[$,j,H,F,W,X],ye=[{field:G.propName,value:e=>e>0}];q.conditions=ye;const ve={category:i,type:m,label:"widget_common_style_blockTitle_border",collapsible:!0,children:[G,q,z]},we={category:i,type:m,label:"widget_common_style_blockTitle_text",collapsible:!0,children:[K,J]},fe=[{field:"dropShadow",value:!0}];le.conditions=fe,ae.conditions=fe;const Ne={category:i,type:m,label:"widget_common_style_blockTitle_container",collapsible:!0,children:[ee,oe,...be,te,le,ae,ne]},ke={category:i,type:m,label:"widget_common_style_blockTitle_overlay",collapsible:!0,children:[ie,re],conditions:[{field:"layout",value:"popin"}]},he=[{field:_e.propName,value:e=>e>0}];ce.conditions=he;const xe={category:i,type:m,label:"widget_common_style_blockTitle_buttons",collapsible:!0,children:[_e,ce,pe,ge,de]};var Ie=[{field:"isFeedBackQuestion",value:!0}],Se=[{field:"isLegend",value:!0}],Te=[{category:r,type:p,propName:"question",label:"widget_nps_content_question_label",value:"widget_nps_content_question_default"},{category:r,type:g,propName:"isLegend",label:"widget_nps_content_legend_toggler_label_displayLegend",value:!1},{category:r,type:c,propName:"minLegend",label:"widget_nps_content_legend_label_minLegend",value:"widget_nps_content_legend_default_minLegend",conditions:Se},{category:r,type:c,propName:"maxLegend",label:"widget_nps_content_legend_label_maxLegend",value:"widget_nps_content_legend_default_maxLegend",conditions:Se},{category:r,type:g,propName:"isFeedBackQuestion",label:"widget_nps_content_oeq_toggler_label_askOpenEndedQuestion",value:!1},{category:r,type:p,propName:"feedbackQuestion",label:"widget_nps_style_preview_option_openEndedQuestion",value:"widget_nps_content_defaultOpenEndedQuestionValue",conditions:Ie},{category:r,type:c,propName:"buttonText",label:"widget_nps_content_buttonText_label",value:"widget_nps_content_buttonText_default_send",conditions:Ie},{category:r,type:g,propName:"isThankYouMessage",label:"widget_nps_content_tym_toggler_label_displayThankYouMessage",value:!1},{category:r,type:p,propName:"thankYouMessage",label:"widget_nps_content_tym_label_thankYouMessage",value:"widget_nps_content_tym_default_thankYouMessage",conditions:[{field:"isThankYouMessage",value:!0}]}],Ce=n(D.children);R.collapsed=!1,O.label="widget_common_conditions_triggering_autohide_toggler_label_autoHideAfterSubmit",R.children.push(O),R.children.push(L);var Be=[R,I],Ee={category:i,type:m,label:{en:"Preview",fr:"Prévisualisation",es:"Previsualización",de:"Vorschau"},collapsible:!0,collapsed:!1,children:[{category:i,type:"radio",propName:"stepToShow",value:"displayNoteStep",label:"widget_nps_style_preview_label_selectStep",options:[{label:"widget_nps_style_preview_option_npsScore",value:"displayNoteStep"},{label:"widget_nps_style_preview_option_openEndedQuestion",value:"displayFeedbackStep",conditions:[{field:"isFeedBackQuestion",value:!0}],fallback:"displayNoteStep"},{label:"widget_nps_style_preview_option_thankYouMessage",value:"displayThanksStep",conditions:[{field:"isThankYouMessage",value:!0}],fallback:"displayNoteStep"}]}]},Pe={category:i,type:g,propName:"noStyles",value:!1,label:"widget_common_style_theme_option_custom"},Ae=function(e){return!e.noStyles};we.condition=Ae,xe.condition=Ae,Ne.condition=Ae,ve.condition=Ae,ke.condition=Ae,Ee.collapsed=!1,we.collapsed=!1;var Oe=[Ee,Pe,we,xe,Ne,ve,ke];return[].concat(n(Be),n(Te),n(Ce),n(Oe))}));
package/dist/main.js CHANGED
@@ -1 +1 @@
1
- !function(){"use strict";var e=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e){var t=function(e){var t=Object.prototype,n=t.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},s=i.iterator||"@@iterator",r=i.asyncIterator||"@@asyncIterator",o=i.toStringTag||"@@toStringTag";function a(e,t,n,i){var s=t&&t.prototype instanceof h?t:h,r=Object.create(s.prototype),o=new C(i||[]);return r._invoke=function(e,t,n){var i="suspendedStart";return function(s,r){if("executing"===i)throw new Error("Generator is already running");if("completed"===i){if("throw"===s)throw r;return S()}for(n.method=s,n.arg=r;;){var o=n.delegate;if(o){var a=b(o,n);if(a){if(a===l)continue;return a}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===i)throw i="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i="executing";var h=c(e,t,n);if("normal"===h.type){if(i=n.done?"completed":"suspendedYield",h.arg===l)continue;return{value:h.arg,done:n.done}}"throw"===h.type&&(i="completed",n.method="throw",n.arg=h.arg)}}}(e,n,o),r}function c(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=a;var l={};function h(){}function u(){}function d(){}var m={};m[s]=function(){return this};var g=Object.getPrototypeOf,p=g&&g(g(N([])));p&&p!==t&&n.call(p,s)&&(m=p);var v=d.prototype=h.prototype=Object.create(m);function f(e){["next","throw","return"].forEach((function(t){e[t]=function(e){return this._invoke(t,e)}}))}function y(e,t){var i;this._invoke=function(s,r){function o(){return new t((function(i,o){!function i(s,r,o,a){var l=c(e[s],e,r);if("throw"!==l.type){var h=l.arg,u=h.value;return u&&"object"==typeof u&&n.call(u,"__await")?t.resolve(u.__await).then((function(e){i("next",e,o,a)}),(function(e){i("throw",e,o,a)})):t.resolve(u).then((function(e){h.value=e,o(h)}),(function(e){return i("throw",e,o,a)}))}a(l.arg)}(s,r,i,o)}))}return i=i?i.then(o,o):o()}}function b(e,t){var n=e.iterator[t.method];if(void 0===n){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,b(e,t),"throw"===t.method))return l;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var i=c(n,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,l;var s=i.arg;return s?s.done?(t[e.resultName]=s.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):s:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,l)}function w(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function E(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function C(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(w,this),this.reset(!0)}function N(e){if(e){var t=e[s];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,r=function t(){for(;++i<e.length;)if(n.call(e,i))return t.value=e[i],t.done=!1,t;return t.value=void 0,t.done=!0,t};return r.next=r}}return{next:S}}function S(){return{value:void 0,done:!0}}return u.prototype=v.constructor=d,d.constructor=u,d[o]=u.displayName="GeneratorFunction",e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===u||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,o in e||(e[o]="GeneratorFunction")),e.prototype=Object.create(v),e},e.awrap=function(e){return{__await:e}},f(y.prototype),y.prototype[r]=function(){return this},e.AsyncIterator=y,e.async=function(t,n,i,s,r){void 0===r&&(r=Promise);var o=new y(a(t,n,i,s),r);return e.isGeneratorFunction(n)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},f(v),v[o]="Generator",v[s]=function(){return this},v.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var i=t.pop();if(i in e)return n.value=i,n.done=!1,n}return n.done=!0,n}},e.values=N,C.prototype={constructor:C,reset:function(e){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(E),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function i(n,i){return o.type="throw",o.arg=e,t.next=n,i&&(t.method="next",t.arg=void 0),!!i}for(var s=this.tryEntries.length-1;s>=0;--s){var r=this.tryEntries[s],o=r.completion;if("root"===r.tryLoc)return i("end");if(r.tryLoc<=this.prev){var a=n.call(r,"catchLoc"),c=n.call(r,"finallyLoc");if(a&&c){if(this.prev<r.catchLoc)return i(r.catchLoc,!0);if(this.prev<r.finallyLoc)return i(r.finallyLoc)}else if(a){if(this.prev<r.catchLoc)return i(r.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<r.finallyLoc)return i(r.finallyLoc)}}}},abrupt:function(e,t){for(var i=this.tryEntries.length-1;i>=0;--i){var s=this.tryEntries[i];if(s.tryLoc<=this.prev&&n.call(s,"finallyLoc")&&this.prev<s.finallyLoc){var r=s;break}}r&&("break"===e||"continue"===e)&&r.tryLoc<=t&&t<=r.finallyLoc&&(r=null);var o=r?r.completion:{};return o.type=e,o.arg=t,r?(this.method="next",this.next=r.finallyLoc,l):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),l},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),E(n),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var i=n.completion;if("throw"===i.type){var s=i.arg;E(n)}return s}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:N(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),l}},e}(e.exports);try{regeneratorRuntime=t}catch(e){Function("r","regeneratorRuntime = r")(t)}}));function t(e,t,n,i,s,r,o){try{var a=e[r](o),c=a.value}catch(e){return void n(e)}a.done?t(c):Promise.resolve(c).then(i,s)}var n=function(e){return function(){var n=this,i=arguments;return new Promise((function(s,r){var o=e.apply(n,i);function a(e){t(o,s,r,a,c,"next",e)}function c(e){t(o,s,r,a,c,"throw",e)}a(void 0)}))}};const i=()=>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},r=()=>!!window.ABTasty.getTestsOnPage()[TEST_ID]||(()=>{const e=!!document.getElementById("ABTastyPreviewBar"),t=location.href.includes("ab_project=preview");return e||t})(),o=()=>{if(i())return!1;const e=ABTasty.getTestsOnPage()[TEST_ID];return!!e&&Object.keys(e.targetings.qaParameters).length>0},a="conditions",c="https://social-proof-api.abtasty.com/clients/",l=()=>{const{type:e}=DATA;return`${PACKAGE.replace("@abtasty/","")}${e?"_"+e:""}`},h=()=>{const e=l();return`${e.charAt(0).toUpperCase()}${e.slice(1)}`.split("-").join(" ")},u=()=>`${PLUGIN_ID.split("-")[0]}_${TEST_ID}`,d=(...e)=>{e.unshift(`[AB Tasty Widget] ${PACKAGE}:`),console.log(...e)},m=e=>{if(o()){const t=h();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)")}},g=e=>{const t={promise:null,resolve:null,reject:null,name:e};return t.promise=new Promise((e,n)=>{t.resolve=e,t.reject=n}),t},p=(e,t,n)=>{let i=0,s=0;try{document.querySelector(e)}catch(t){const i=`Selector «${e}» not valid.`;return d(i),"function"==typeof n&&n(i)}function r(){clearInterval(s),clearTimeout(i)}return i=setTimeout(()=>{r();const t=`Can't find element «${e}».`;return d(t),"function"==typeof n&&n(t)},1e4),s=setInterval(()=>{const n=document.querySelector(e);return null!==n?(r(),"function"==typeof t&&t(n)):n},200),{clear:r}};async function v(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,n)=>{const i=window.document.getElementsByTagName("script")[0],s=window.document.createElement("script");s.src=e,i.parentNode.insertBefore(s,i),s.onload=t,s.onerror=n})}(""));break;default:t=!0}return t}class f{constructor({displayRecurrence:e,closingRecurrence:t,validationRecurrence:n},i){this.displayRecurrence=parseFloat(e),this.closingRecurrence=parseFloat(t),this.validationRecurrence=parseFloat(n),this.onSetCallback=i,this.widgetName=l(),this.uniqueId=u(),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]:n,...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 n=this.getTypeOfStorage(e);if(!n&&"object"!=typeof n)return!1;const{storageString:i,storageMethod:s}=n,r=this.getStamp(e),o={type:t,stamp:r},{type:a}=this.getCurrentRecurrence(),c=()=>{const e=this.getSessionRecurrence(),t=this.getLocalRecurrence();let n;"session"===i?e?n=this.removeSessionRecurrenceStorage():(this.removeLocalRecurrenceStorage(),n=this.getSessionRecurrenceStorageParsed()):"local"===i&&(t?n=this.removeLocalRecurrenceStorage():(this.removeSessionRecurrenceStorage(),n=this.getLocalRecurrenceStorageParsed()));const r=n?{[this.recurrenceKey]:o,...n}:{[this.recurrenceKey]:o};s.setItem("ABTastyWidgets",JSON.stringify(r)),this.onSetCallback&&"function"==typeof this.onSetCallback&&this.onSetCallback()};if(!s)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 r}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 y{constructor(){this.targets=[],this.existingTargets=[],this.inViewportTargets=[],this.visibilityObserver=this.startVisibilityObserver(),this.mutationObserver=this.startMutationObserver(),this.mouseOverEvent=this.mouseOverHandler()}intersectionHandler(e){e.forEach(e=>{e.isIntersecting?(this.existingTargets.forEach(t=>{t.element.isSameNode(e.target)&&(this.inViewportTargets.push(t),this.mouseOverEvent.start())}),this.checkElements()):this.inViewportTargets=this.inViewportTargets.filter(t=>!t.element.isSameNode(e.target)||(this.mouseOverEvent.clear(),!1))})}startVisibilityObserver(){return new IntersectionObserver(this.intersectionHandler.bind(this),{root:null,rootMargin:"0px",threshold:0})}startMutationObserver(){const e=this.mutationObserver||new MutationObserver(this.checkElements.bind(this));return document.body&&e.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),e}onMouseOver({target:e,path:t}){const n=this.inViewportTargets.find(({element:n,selector:i})=>{if(n.isSameNode(e))return!0;const s=[...e.querySelectorAll(i)];if(s.length&&s.includes(n))return!0;if(t.includes(n))return!0;const r=[...e.parentElement.children],o=r.findIndex(t=>t.isSameNode(e)),a=r.filter((e,t)=>t>o);if(a.length){if(a.includes(n))return!0;if(a.some(e=>[...e.querySelectorAll(i)].includes(n)))return!0}return!1});if(n&&this.isElementVisible(n.element)){const{selector:e,element:t,uniqueId:i}=n,s=this.targets.find(t=>t.selector===e&&t.uniqueId===i);s&&s.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,n){return n(t)||!t.parentElement?t:e(t.parentElement,n)}(e,e=>"0"===window.getComputedStyle(e).opacity).nodeName}isElementTopmost(e){const t=e.getBoundingClientRect(),n=[[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,s=0;for(;!i&&s<n.length;){const t=document.elementFromPoint(...n[s]);i=e===t||e.contains(t),s+=1}return i}checkElements(){this.targets.forEach(({selector:e,uniqueId:t})=>{const n=document.querySelector(e);n&&!this.existingTargets.find(n=>n.element.matches(e)&&n.uniqueId===t)&&(this.existingTargets.push({element:n,selector:e,uniqueId:t}),this.visibilityObserver.observe(n))}),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:n})=>{if(t.matches(e)&&this.isElementVisible(t)){const i=this.targets.find(t=>t.selector===e&&t.uniqueId===n);return i&&i.resolve(t),this.clear(e,n),!1}return!0})}watch(e,t,n){this.targets.push({selector:e,resolve:t,uniqueId:n});const i=()=>{this.startMutationObserver(),this.checkElements()};document.body?i():p("body",i)}clear(e,t){[this.targets,this.existingTargets,this.inViewportTargets]=[this.targets,this.existingTargets,this.inViewportTargets].map(n=>n.filter(({selector:n,uniqueId:i})=>n!==e&&i!==t)),this.visibilityObserver.unobserve(document.querySelector(e)),0===this.targets.length&&this.mutationObserver.disconnect(),0===this.inViewportTargets.length&&this.mouseOverEvent.clear()}}class b{constructor({triggerEvent:e,triggerSelector:t,triggerDelay:n}){this.event=e,this.selector=t&&t.length?t:"body",this.delay=1e3*n,this.elementsSelectors=[],this.eventsListeners=[],this.timeouts=[],this.intervals=[],this.observers=[],this.promises=[],this.visibilityObservers=[],this.elementsWaiters=[]}async onElementVisible({promise:e,resolve:t}){const n=g(this.event+"DomReady");this.promises.push(n);const i=await this.onPageLoad(n),s=await v("IntersectionObserver"),r=function(e,t){return ABTasty.widgetUtils||(ABTasty.widgetUtils={}),ABTasty.widgetUtils[e]||Object.assign(ABTasty.widgetUtils,{[e]:new t}),ABTasty.widgetUtils[e]}("VisibilityObserver",y);if(this.visibilityObservers.push(r),s&&i){const e=u();r.watch(this.selector,t,e)}return e}onPageLoad({promise:e,resolve:t}){const n=()=>"complete"===document.readyState;if(!n()){const e=["readystatechange",()=>n()&&t(!0),{passive:!0}];this.eventsListeners.push(e),document.addEventListener(...e)}return t(!0),e}onClick({promise:e,resolve:t}){const n=document.createElement("style");n.type="text/css",n.id="Click_"+u(),n.innerHTML=this.selector+" {\n\t\t\tcursor: pointer !important;\n\t\t\tpointer-events: all !important;\n\t\t}",document.head.appendChild(n),this.elementsSelectors.push("#"+n.id);const i=e=>[...document.querySelectorAll(this.selector)].some(t=>t.isSameNode(e)||!!e.closest(this.selector)),s=["click",({target:e})=>i(e)&&t(!0),{passive:!0,capture:!0}];return this.eventsListeners.push(s),document.addEventListener(...s),e}onExitIntent({promise:e,resolve:t}){const n=["mouseleave",async({clientY:e})=>{e<=0&&t(!0)},{passive:!0}],i=p("body",e=>{e.addEventListener(...n),this.eventsListeners.push([e,...n]),this.elementsWaiters=this.elementsWaiters.filter(e=>e!==i)});return this.elementsWaiters.push(i),e}onReengage({promise:e,resolve:t}){const n=this.delay;let i=n;const s=[()=>(i=n,i),{passive:!0}];["click","mousemove","scroll","keypress"].forEach(e=>{document.addEventListener(e,...s),this.eventsListeners.push([e,...s])});const r=setInterval(()=>{i<=0?t(!0):i-=100},100);return this.intervals.push(r),e}onCustomTrigger({promise:e,resolve:t}){const{triggerEventCustomScript:n}=DATA;return new Function(`return new Promise(async resolve => {${n}})`)().then(e=>e&&t(!0)),e}getSocialProofPurchases({promise:e,resolve:t}){const n=window.ABTastyProductKey,i=s(),{viewInterval:r,triggerSocialProofMinPurchases:o,spNoTrim:a}=DATA;return n||(m("Not able to find ABTastyProductKey, impossible to call the API."),t(!1)),n&&i?fetch(`${c}${i}/metrics/i?key=${n}${a?"&noTrim=true":""}`).then(e=>e.ok&&e.json()).then(e=>(e=>{if(void 0===r||void 0===o)return!1;const t=e[r]&&e[r]>=o;return t||m(`Widget will not be shown, product has been purchased ${e[r]} times while ${o} are required`),t})(e)&&t(e[r])).catch(()=>m("Failed to fetch datas from server.")):t(!1),e}getSocialProofPageViews({promise:e,resolve:t}){const n=encodeURIComponent(""+window.location.pathname),i=s(),{viewInterval:r,triggerSocialProofMinPageViews:o}=DATA;return n&&i?fetch(`${c}${i}/metrics/pv?key=${n}`).then(e=>e.ok&&e.json()).then(e=>(e=>{if(void 0===r||void 0===o)return!1;const t=e[r]&&e[r]>=o;return t||m(`Widget will not be shown, page has been seen ${e[r]} times while ${o} are required`),t})(e)&&t(e[r])).catch(()=>m("Failed to fetch datas from server.")):t(!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,...n]="string"==typeof e[0]?[document,...e]:e;t&&n.length>1&&t.removeEventListener(...n)}),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=u();this.visibilityObservers.forEach(t=>t.clear(this.selector,e)),this.visibilityObservers=[]}return this.promises.length&&(this.promises.forEach(e=>e.resolve(!1)),this.promises=[]),this.elementsWaiters.length&&(this.elementsWaiters.forEach(e=>e.clear()),this.elementsWaiters=[]),this}async isTriggered(){this.clear();const e=g(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)},n=!Object.prototype.hasOwnProperty.call(t,this.event)||await t[this.event]();return this.clear(),"reengage"!==this.event&&this.delay?n&&await(async()=>{const e=g(this.event+"Delay");return this.promises.push(e),setTimeout(()=>{e.resolve(!0),this.clear()},this.delay),e.promise})():n}}class w{constructor(e,t,n){this.recurrence=e,this.isWidgetApplied=t,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(e){const t=r(),{type:n}=this.recurrence?this.recurrence.getCurrentRecurrence():{type:!1},i=()=>e&&"display"===n||this.recurrenceIsDone();return!this.isWidgetApplied()&&t&&i()?(this.clearWatcher(),this.callback("rebuild",e)):(!this.isWidgetApplied()||t&&i())&&(this.isWidgetApplied()||t)||(this.clearWatcher(),this.callback("remove",e),this.watch()),this}eventHandler(){let e=r();return[250,500].forEach(t=>setTimeout(()=>500===t&&r()===e?this:(e=r(),this.decisionHandler(!1)),t)),this}observerHandler(e){const t=e.some(({removedNodes:e})=>e&&e.length),n=e.some(({addedNodes:e})=>e&&e.length);return t||n?(this.decisionHandler(!0),this):this}watch(){if(i())return this;this.clearWatcher(),document.addEventListener(...this.eventListenerParams);const e=p("body",t=>{const n=[t,{childList:!0,subtree:!0}];this.observer.observe(...n),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}}class E{constructor(){this.children=void 0,this.uniqueId=u(),this.widgetName=l(),this.prettyName=h(),this.recurrenceParams=(()=>{const{displayRecurrence:e,closingRecurrence:t,validationRecurrence:n}=DATA;if(i()||!e&&!t&&!n)return!1;const s={everytime:()=>-1,session:()=>0,once:()=>395,day:e=>DATA[e+"_day"],week:e=>7*DATA[e+"_week"],month:e=>30.5*DATA[e+"_month"]},r={};return e&&(r.displayRecurrence=s[e]("displayRecurrence")),t&&(r.closingRecurrence=s[t]("closingRecurrence")),n&&(r.validationRecurrence=s[n]("validationRecurrence")),r})(),this.triggerParams=(()=>{let{triggerEvent:e}=DATA;const{triggerEventClick:t,triggerEventReengageDelay:n,socialProofContentType:s,triggerEventElementVisible:r,triggerEventDelay:o}=DATA;if(i()||!e&&!s)return!1;const a={click:()=>t,elementVisible:()=>r},c=Object.prototype.hasOwnProperty.call(a,e)?a[e]():"body",l="reengage"===e?n:o;return s&&(e=1===s?"socialProofPurchases":"socialProofPageViews"),{triggerEvent:e,triggerSelector:c,triggerDelay:l}})(),this.recurrence=!!this.recurrenceParams&&new f(this.recurrenceParams,this.clearGivenClearables.bind(this)),this.trigger=!!this.triggerParams&&new b(this.triggerParams),this.pageWatcher=new w(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,n)=>{this.elementsWaiters=this.elementsWaiters.filter(e=>e!==t),m(e),n(e)},t=new Promise((t,n)=>{const i=p("head",e=>{this.elementsWaiters=this.elementsWaiters.filter(e=>e!==i),t(e.appendChild(this.styleElement))},t=>e(t,i,n));this.elementsWaiters.push(i)}),n=new Promise((t,n)=>{const{layout:i,elementReferrer:s,referrerInsertType:r}=DATA,{selector:o,position:a}="string"==typeof i&&"free"===i&&"string"==typeof s&&"string"==typeof r?{selector:s,position:r}:{selector:"body",position:"beforeend"},c=p(o,e=>{this.elementsWaiters=this.elementsWaiters.filter(e=>e!==c),this.removeOldDomElement(),t(e.insertAdjacentElement(a,this.domElement))},t=>e(t,c,n));this.elementsWaiters.push(c)});return Promise.all([n,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():i()||this.init().then(({response:e})=>e?this.show():this),this}show(){return this.hasBeenShown||i()||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&&!i()&&window.ABTastyEvent(this.prettyName+" closed",null,TEST_ID),this.closedByUser=!0,this.domElement.classList.add(this.hideClassName),this}async init(e){if(!i()&&!r())return!1;if(this.trigger&&this.trigger.promises.length)return!1;const t=this.recurrence&&this.recurrence.isOver();if(this.recurrence&&!t)return this.pageWatcher.watch(),!1;this.pageWatcher.watch();const n=i()||!this.trigger||this.trigger&&await this.trigger.isTriggered();return!!n&&(await this.insert(),this.addCloseEvent(),i()||e||this.hasBeenShown||void 0===this.children||"function"!=typeof this.children.refreshContent||this.children.refreshContent(n),{container:this,response:n})}onPageChange(e,t){const n=()=>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()):n()}}addCloseEvent(...e){const{closeButton:t,overlayClickable:n,layout:i}=DATA,s=[];if(void 0!==n&&n&&void 0!==i&&"popin"===i&&s.push("."+this.overlayClassName),void 0!==t&&t&&s.push("."+this.closeButtonClassName),!s.length)return this;const r=this.domElement.querySelectorAll(s.join(", "));return r.length?(e.push(...r),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:t}=DATA,n=document.createElement("div");return n.className=`${this.basicClassName} ${this.hideClassName}`,n.id=this.widgetContainerId,n.innerHTML=`\n\t\t\t${void 0!==t&&"popin"===t?`<div class="${this.overlayClassName}"></div>`:""}\n\t\t\t<div class="${this.contentClassName}">\n\t\t\t\t${e?`<button class="${this.closeButtonClassName}" ${i()?"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>`,n}getStyleTag(e=""){const{noStyles:t,layout:n}=DATA,{backgroundColor:s,backgroundImage:r,borderColor:o,borderRadius:a,borderWidth:c,textColor:l,textAlign:h,overlayColor:u,dropShadow:d,dropShadowColor:m,dropShadowBlur:g,containerMargin:p,containerPadding:v,closeButton:f,buttonsBorderWidth:y,buttonsBorderColor:b,buttonsBorderRadius:w,buttonsBackgroundColor:E,buttonsTextColor:C}=t?{}:DATA,N=document.createElement("style");N.type="text/css",i()&&N.setAttribute("abtasty-script-added","true");const S=`background-color: ${void 0!==s?s:"rgba(255, 255, 255, 1)"};`,_=void 0!==r?`background-image: url(${r});`:"",T=void 0!==a?`border-radius: ${a}px;`:"",x=void 0!==c&&c?`border-width: ${c}px; border-style: solid;`:"",k=[o,c].every(e=>void 0!==e)&&c?`border-color: ${o};`:"",A=void 0!==l?`color: ${l}; fill: ${l};`:"",$=void 0!==h?`text-align: ${h};`:"",L=void 0!==d&&d?`box-shadow: 0 5px ${g}px 0 ${m};`:"",I=p instanceof Array&&1===p.length&&p[0],P=I?`margin: ${I.top}px ${I.right}px ${I.bottom}px ${I.left}px;`:"",O=I?`margin: calc(${I.top}px * 0.5) calc(${I.right}px * 0.5) calc(${I.bottom}px * 0.5) calc(${I.left}px * 0.5);`:"",R=v instanceof Array&&1===v.length&&v[0],B=R?`padding: ${R.top}px ${R.right}px ${R.bottom}px ${R.left}px;`:"",W=R?`padding: calc(${R.top}px * 0.5) calc(${R.right}px * 0.5) calc(${R.bottom}px * 0.5) calc(${R.left}px * 0.5);`:"",D=void 0!==y&&y?`border-width: ${y}px; border-style: solid;`:"",j=[b,y].every(e=>void 0!==e)&&y?`border-color: ${b};`:"",q=void 0!==w?`border-radius: ${w}px;`:"",V=void 0!==E?`background-color: ${E};`:"",M=void 0!==C?`color: ${C};`:"",F=void 0!==n&&"popin"===n?[`#${this.widgetContainerId} .${this.overlayClassName} {`,`background-color: ${void 0!==u?u:"rgba(0, 0, 0, 0.6)"};`,"}"].join(""):"",H=t||void 0!==f&&f?[`#${this.widgetContainerId} .${this.contentClassName} .${this.closeButtonClassName} {`,"position: absolute;","top: 8px;","right: 8px;","width: auto;","height: auto;","background: none;","border: none;","cursor: pointer;","outline: none;","padding: 0;","margin: 0;","}",`#${this.widgetContainerId} .${this.contentClassName} .${this.closeButtonClassName} svg {`,"pointer-events: none;","width: 16px;","height: 16px;",A,"}"].join(""):"";return N.textContent=[`.${this.hideClassName} {`,"opacity: 0 !important;","pointer-events: none;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,S,_,T,x,k,A,$,L,P,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,"display: block;","line-height: 1;",B,"}",`#${this.widgetContainerId} .${this.contentClassName} > * a, `,`#${this.widgetContainerId} .${this.contentClassName} > * button {`,D,j,q,V,M,"}","@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,O,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,W,"}","}",F,H,""+e].join(""),N}}class C extends E{constructor(){super(),this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){return[`#${this.widgetContainerId} {`,"position: fixed;","top: 0;","left: 0;","width: 100%;","height: 100%;","z-index: 9999;","opacity: 1;","transition: opacity 0.25s ease;","}",`#${this.widgetContainerId} .${this.overlayClassName} {`,"position: absolute;","z-index: -1;","top: 0;","left: 0;","width: 100%;","height: 100%;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: absolute;","left: 50%;","top: 50%;","transform: translate(-50%, -50%);","width: auto;","height: auto;","}","@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,"max-width: 94vw;","}","}"].join("")}}class N extends E{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 S extends E{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 _=()=>{const{layout:e}=DATA;let t;switch(e){case"popin":t=new C;break;case"bannerTop":case"bannerBottom":t=new N;break;case"free":t=new S;break;default:t=new E}return t},T={category:a,type:"slider",min:1},x=[{...T,propName:"day",label:"widget_common_conditions_recurrence_ifOptionVariable_labelDays",value:5,max:395},{...T,propName:"week",label:"widget_common_conditions_recurrence_ifOptionVariable_labelWeeks",value:2,max:56},{...T,propName:"month",label:"widget_common_conditions_recurrence_ifOptionVariable_labelMonths",value:1,max:13}],k={category:a,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"},A={...k,label:"widget_common_conditions_recurrence_label_widgetDisplayed",propName:"displayRecurrence"},$=(x.map(e=>({...e,propName:`${A.propName}_${e.propName}`,conditions:[{field:A.propName,value:e.propName}]})),{...k,label:"widget_common_conditions_recurrence_label_widgetDisplayedAfterClosure",propName:"closingRecurrence"}),L=(x.map(e=>({...e,propName:`${$.propName}_${e.propName}`,conditions:[{field:$.propName,value:e.propName}]})),{...k,label:"widget_common_conditions_recurrence_label_widgetDisplayedAfterSubmission",propName:"validationRecurrence"}),I=(x.map(e=>({...e,propName:`${L.propName}_${e.propName}`,conditions:[{field:L.propName,value:e.propName}]})),{pageLoad:{label:"widget_common_conditions_triggering_option_pageload",value:"pageLoad"},direct:{label:"widget_common_conditions_triggering_option_asap",value:"direct"},exitIntent:{label:"widget_common_conditions_triggering_option_exitIntent",value:"exitIntent"},reengage:{label:"widget_common_conditions_triggering_option_afterXSecondsOfInactivity",value:"reengage"},click:{label:"widget_common_conditions_triggering_option_click",value:"click"},elementVisible:{label:"widget_common_conditions_triggering_option_elementVisible",value:"elementVisible"},customScript:{label:"widget_common_conditions_triggering_option_customTrigger",value:"script"}});Object.keys(I).map(e=>I[e]);var P=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")};function O(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var R=function(e,t,n){return t&&O(e.prototype,t),n&&O(e,n),e},B=DATA,W=B.isFeedBackQuestion,D=B.isThankYouMessage,j=B.autoHide,q=B.timeHide,V=B.stepToShow,M=B.question,F=B.feedbackQuestion,H=B.buttonText,Y=B.thankYouMessage,G=B.isLegend,U=B.minLegend,z=B.maxLegend,K=B.noStyles,Q=function(){function e(t){var n=t.parentContainer;P(this,e),this.parentContainer=n,this.baseClassName="nps_container",this.className="".concat(this.baseClassName,"_").concat(n.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(n.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 R(e,[{key:"sendNote",value:function(){if(!i()&&!isNaN(this.currentNote)){try{window.abtasty.send("nps",{ns:this.currentNote,nf:this.userFeedback})}catch(e){m("Not able to send NPS hit due to old tag version (< 3.0)")}this.parentContainer.recurrence.setValidationRecurrence()}return this}},{key:"insertIn",value:function(e,t){return document.head.insertAdjacentElement("beforeend",this.styleElement),e.insertAdjacentElement(t,this.npsElement),this}},{key:"complete",value:function(){var e=this;return this.sendNote(),j?(setTimeout((function(){e.parentContainer.hide(),setTimeout((function(){e.parentContainer.remove(),e.showNotes(),e.currentNote=NaN,e.userFeedback="",e.feedbackElements.feedbackFormElement.querySelector("textarea").value=""}),1e3)}),1e3*q),this):this}},{key:"onClickNote",value:function(e){this.currentNote=Number(e.target.dataset.note),W&&F&&F.length?this.showFeedBack():D&&Y&&Y.length?this.showThankYouMessage():this.complete()}},{key:"onFeedbackSend",value:function(){D&&Y&&Y.length?this.showThankYouMessage():this.complete()}},{key:"showNotes",value:function(){var e=this;return this.npsContainer.childNodes.forEach((function(t){return t.classList.add(e.hideClassName)})),[this.questionElement,this.notesContainer].forEach((function(t){return t.classList.remove(e.hideClassName)})),this}},{key:"showFeedBack",value:function(){var e=this;return this.npsContainer.childNodes.forEach((function(t){return t.classList.add(e.hideClassName)})),Object.values(this.feedbackElements).forEach((function(t){return t.classList.remove(e.hideClassName)})),this}},{key:"showThankYouMessage",value:function(){var e=this;return this.npsContainer.childNodes.forEach((function(t){return t.classList.add(e.hideClassName)})),this.thankYouElement.classList.remove(this.hideClassName),this.complete(),this}},{key:"getThankYouElement",value:function(){var e=document.createElement("p");return e.className="".concat(this.thankYouClassName," ").concat(this.hideClassName),e.innerHTML=Y,i()&&"displayThanksStep"===V&&e.classList.remove(this.hideClassName),e}},{key:"getFeedBackElements",value:function(){var e=this,t=document.createElement("p");t.className="".concat(this.feedbackQuestionClassName," ").concat(this.hideClassName),t.innerHTML=F;var n=document.createElement("form");n.className="".concat(this.feedbackFormClassName," ").concat(this.hideClassName),n.addEventListener("submit",(function(e){return e.preventDefault()}),{passive:!1});var s=document.createElement("textarea");s.className="".concat(this.feedbackQuestionClassName,"_textarea");var r=document.createElement("button");return r.className="".concat(this.feedbackQuestionClassName,"_button"),r.innerHTML="<span>".concat(H,"</span>"),r.addEventListener("click",(function(){return e.userFeedback=s.value,e.onFeedbackSend()}),{passive:!0}),i()&&"displayFeedbackStep"===V&&[t,n].forEach((function(t){return t.classList.remove(e.hideClassName)})),n.appendChild(s),n.appendChild(r),{feedbackQuestionElement:t,feedbackFormElement:n}}},{key:"getNotesElement",value:function(){var e=this,t=document.createElement("div");t.className=this.notesClassName,i()&&"displayNoteStep"!==V&&t.classList.add(this.hideClassName);for(var n=10;n>=0;){var s=document.createElement("button");s.className=this.notesButtonsClassName,s.dataset.note=n,i()&&s.setAttribute("data-abtasty-actionnable",""),s.innerHTML+="<span>".concat(n,"</span>"),s.addEventListener("click",(function(t){return e.onClickNote(t)}),{passive:!0}),t.insertAdjacentElement("afterbegin",s),5===n&&s.insertAdjacentHTML("afterend","<br>"),n-=1}return G&&(t.insertAdjacentHTML("afterbegin","<legend>".concat(U,"</legend>")),t.insertAdjacentHTML("beforeend","<legend>".concat(z,"</legend>"))),t}},{key:"getQuestionElement",value:function(){var e=document.createElement("p");return e.className=this.questionClassName,e.innerHTML=M,i()&&"displayNoteStep"!==V&&e.classList.add(this.hideClassName),e}},{key:"getContainer",value:function(){var e=document.createElement("div");return e.className="".concat(this.baseClassName," ").concat(this.className),e}},{key:"getNPSElement",value:function(){var e=this;return this.npsContainer.appendChild(this.questionElement),this.npsContainer.appendChild(this.notesContainer),W&&Object.values(this.feedbackElements).forEach((function(t){e.npsContainer.appendChild(t)})),D&&this.npsContainer.appendChild(this.thankYouElement),this.npsContainer}},{key:"getStyleElement",value:function(){var e=document.createElement("style");if(e.type="text/css",i()&&e.setAttribute("abtasty-script-added","true"),K)e.textContent=["#".concat(this.parentContainer.widgetContainerId," .").concat(this.className," .").concat(this.hideClassName," {"),"display: none !important;","}"].join("");else{var t=DATA.containerPadding,n=t instanceof Array&&1===t.length&&t[0],s="#".concat(this.parentContainer.widgetContainerId," .").concat(this.className);e.textContent=["".concat(s," .").concat(this.hideClassName," {"),"display: none !important;","}","".concat(s,","),"".concat(s," * {"),"all: unset;","box-sizing: border-box;","font-size: 10px;","line-height: 1;","font-family: sans-serif;","}","".concat(s," > * {"),"display: block;","width: 100%;","}","".concat(s," .").concat(this.notesClassName," {"),"position: relative;","display: inline-block;","width: auto;","}","".concat(s," p {"),"margin-bottom: 15px;","font-size: 1.4em;","}","".concat(s," button {"),"vertical-align: middle;","cursor: pointer;","text-align: center;","}","".concat(s," button span {"),"font-size: 1.4em;","pointer-events: none;","}","".concat(s," .").concat(this.notesClassName," button {"),"margin: 0 5px;","width: 30px;","height: 30px;","}","".concat(s," .").concat(this.feedbackFormClassName," span {"),"display: block;","padding: 6px 24px;","}",G?["".concat(s," legend {"),"position: absolute;","text-decoration: none;","border: none;","font-size: 1em;","}","".concat(s," legend:nth-of-type(2) {"),"left: auto;","right: 0;","}"].join(""):"","".concat(s," textarea {"),"display: block;","width: 100%;","min-width: 310px;","min-height: 60px;","font-size: 1.4em;","border: 1px solid grey;","border-radius: 4px;","resize: vertical;","margin-bottom: 10px;","text-align: left;","padding: 5px;","}","".concat(s," .").concat(this.thankYouClassName," {"),"margin-bottom: 0;","}","@media screen and (min-width: 580px) {","".concat(s," {"),"min-width: 560px;","}",G?["".concat(s," .").concat(this.notesClassName," {"),"padding-top: 22px","}","".concat(s," legend {"),"top: 0;","left: 0;","display: inline-block;","width: auto;","}"].join(""):"","".concat(s," br {"),"display: none","}","}","@media screen and (max-width: 579px) {","".concat(s," {"),"min-width: ".concat(240+(n.left+n.right/2),"px;"),"}","".concat(s," .").concat(this.notesClassName," button {"),"margin-bottom: 5px;","}","".concat(s," br {"),"display: block","}",G?["".concat(s," .").concat(this.notesClassName," {"),"padding-bottom: 35px;","}","".concat(s," legend {"),"bottom: 0;","left: 50%;","transform: translateX(-50%)","}","".concat(s," legend:nth-of-type(1) {"),"bottom: 15px;","}","".concat(s," legend:nth-of-type(2) {"),"left: 50%;","right: unset;","}","".concat(s," legend:nth-of-type(1)::before {"),'content: "0: ";',"}","".concat(s," legend:nth-of-type(2)::before{"),'content: "10: ";',"}"].join(""):"","".concat(s," textarea {"),"min-width: auto;","}","}"].join("")}return e}}]),e}();function X(){return(X=n(e.mark((function t(){var n,i,s;return e.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=_(),i=n.domElement.querySelector(".".concat(n.contentClassName)),s=new Q({parentContainer:n}),n.children=s,s.insertIn(i,"beforeend"),n.init().then((function(e){return e.response&&n.show()})),e.abrupt("return",{parentContainer:n,NPS:s});case 8:case"end":return e.stop()}}),t)})))).apply(this,arguments)}!function(){X.apply(this,arguments)}()}();
1
+ !function(){"use strict";var e=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e){var t=function(e){var t=Object.prototype,n=t.hasOwnProperty,s="function"==typeof Symbol?Symbol:{},i=s.iterator||"@@iterator",r=s.asyncIterator||"@@asyncIterator",o=s.toStringTag||"@@toStringTag";function a(e,t,n,s){var i=t&&t.prototype instanceof h?t:h,r=Object.create(i.prototype),o=new C(s||[]);return r._invoke=function(e,t,n){var s="suspendedStart";return function(i,r){if("executing"===s)throw new Error("Generator is already running");if("completed"===s){if("throw"===i)throw r;return N()}for(n.method=i,n.arg=r;;){var o=n.delegate;if(o){var a=b(o,n);if(a){if(a===l)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 h=c(e,t,n);if("normal"===h.type){if(s=n.done?"completed":"suspendedYield",h.arg===l)continue;return{value:h.arg,done:n.done}}"throw"===h.type&&(s="completed",n.method="throw",n.arg=h.arg)}}}(e,n,o),r}function c(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=a;var l={};function h(){}function u(){}function d(){}var m={};m[i]=function(){return this};var g=Object.getPrototypeOf,p=g&&g(g(S([])));p&&p!==t&&n.call(p,i)&&(m=p);var v=d.prototype=h.prototype=Object.create(m);function f(e){["next","throw","return"].forEach((function(t){e[t]=function(e){return this._invoke(t,e)}}))}function y(e,t){var s;this._invoke=function(i,r){function o(){return new t((function(s,o){!function s(i,r,o,a){var l=c(e[i],e,r);if("throw"!==l.type){var h=l.arg,u=h.value;return u&&"object"==typeof u&&n.call(u,"__await")?t.resolve(u.__await).then((function(e){s("next",e,o,a)}),(function(e){s("throw",e,o,a)})):t.resolve(u).then((function(e){h.value=e,o(h)}),(function(e){return s("throw",e,o,a)}))}a(l.arg)}(i,r,s,o)}))}return s=s?s.then(o,o):o()}}function b(e,t){var n=e.iterator[t.method];if(void 0===n){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,b(e,t),"throw"===t.method))return l;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var s=c(n,e.iterator,t.arg);if("throw"===s.type)return t.method="throw",t.arg=s.arg,t.delegate=null,l;var i=s.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,l)}function w(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function E(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function C(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(w,this),this.reset(!0)}function S(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var s=-1,r=function t(){for(;++s<e.length;)if(n.call(e,s))return t.value=e[s],t.done=!1,t;return t.value=void 0,t.done=!0,t};return r.next=r}}return{next:N}}function N(){return{value:void 0,done:!0}}return u.prototype=v.constructor=d,d.constructor=u,d[o]=u.displayName="GeneratorFunction",e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===u||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,o in e||(e[o]="GeneratorFunction")),e.prototype=Object.create(v),e},e.awrap=function(e){return{__await:e}},f(y.prototype),y.prototype[r]=function(){return this},e.AsyncIterator=y,e.async=function(t,n,s,i,r){void 0===r&&(r=Promise);var o=new y(a(t,n,s,i),r);return e.isGeneratorFunction(n)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},f(v),v[o]="Generator",v[i]=function(){return this},v.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var s=t.pop();if(s in e)return n.value=s,n.done=!1,n}return n.done=!0,n}},e.values=S,C.prototype={constructor:C,reset:function(e){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(E),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function s(n,s){return o.type="throw",o.arg=e,t.next=n,s&&(t.method="next",t.arg=void 0),!!s}for(var i=this.tryEntries.length-1;i>=0;--i){var r=this.tryEntries[i],o=r.completion;if("root"===r.tryLoc)return s("end");if(r.tryLoc<=this.prev){var a=n.call(r,"catchLoc"),c=n.call(r,"finallyLoc");if(a&&c){if(this.prev<r.catchLoc)return s(r.catchLoc,!0);if(this.prev<r.finallyLoc)return s(r.finallyLoc)}else if(a){if(this.prev<r.catchLoc)return s(r.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<r.finallyLoc)return s(r.finallyLoc)}}}},abrupt:function(e,t){for(var s=this.tryEntries.length-1;s>=0;--s){var i=this.tryEntries[s];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var r=i;break}}r&&("break"===e||"continue"===e)&&r.tryLoc<=t&&t<=r.finallyLoc&&(r=null);var o=r?r.completion:{};return o.type=e,o.arg=t,r?(this.method="next",this.next=r.finallyLoc,l):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),l},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),E(n),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var s=n.completion;if("throw"===s.type){var i=s.arg;E(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:S(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),l}},e}(e.exports);try{regeneratorRuntime=t}catch(e){Function("r","regeneratorRuntime = r")(t)}}));function t(e,t,n,s,i,r,o){try{var a=e[r](o),c=a.value}catch(e){return void n(e)}a.done?t(c):Promise.resolve(c).then(s,i)}var n=function(e){return function(){var n=this,s=arguments;return new Promise((function(i,r){var o=e.apply(n,s);function a(e){t(o,i,r,a,c,"next",e)}function c(e){t(o,i,r,a,c,"throw",e)}a(void 0)}))}};const s=()=>Object.prototype.hasOwnProperty.call(window,"ABTastyEditor");const i=()=>{let e;return window.ABTasty||window.ABTASTY_S?(window.ABTASTY_S&&window.ABTASTY_S.USER&&window.ABTASTY_S.USER.accountIdentifier&&window.ABTASTY_S.USER.accountIdentifier.length?e=window.ABTASTY_S.USER.accountIdentifier:window.ABTasty&&window.ABTasty.getAccountSettings&&"function"==typeof window.ABTasty.getAccountSettings?e=window.ABTasty.getAccountSettings().identifier:window.ABTasty&&window.ABTasty.accountSettings&&(e=window.ABTasty.accountSettings.identifier),e):e},r=()=>{const e=!!document.getElementById("ABTastyPreviewBar"),t=location.href.includes("ab_project=preview");return e||t},o=()=>r()||!!window.ABTasty.getTestsOnPage()[TEST_ID],a=()=>{if(s()||r())return!1;const e=ABTasty.getTestsOnPage()[TEST_ID];return!!e&&Object.keys(e.targetings.qaParameters).length>0},c="conditions",l="https://social-proof-api.abtasty.com/clients/",h=()=>{const{type:e}=DATA;return`${PACKAGE.replace("@abtasty/","")}${e?"_"+e:""}`},u=()=>{const e=h();return`${e.charAt(0).toUpperCase()}${e.slice(1)}`.split("-").join(" ")},d=()=>`${PLUGIN_ID.split("-")[0]}_${TEST_ID}`,m=(...e)=>{e.unshift(`[AB Tasty Widget] ${PACKAGE}:`),console.log(...e)},g=e=>{if(a()){const t=u();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)")}},p=e=>{const t={promise:null,resolve:null,reject:null,name:e};return t.promise=new Promise((e,n)=>{t.resolve=e,t.reject=n}),t},v=(e,t,n)=>{let s=0,i=0;try{document.querySelector(e)}catch(t){const s=`Selector «${e}» not valid.`;return m(s),"function"==typeof n&&n(s)}function r(){clearInterval(i),clearTimeout(s)}return s=setTimeout(()=>{r();const t=`Can't find element «${e}».`;return m(t),"function"==typeof n&&n(t)},1e4),i=setInterval(()=>{const n=document.querySelector(e);return null!==n?(r(),"function"==typeof t&&t(n)):n},200),{clear:r}};async function f(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,n)=>{const s=window.document.getElementsByTagName("script")[0],i=window.document.createElement("script");i.src=e,s.parentNode.insertBefore(i,s),i.onload=t,i.onerror=n})}("https://polyfill.io/v3/polyfill.min.js?flags=gated&features=IntersectionObserver"));break;default:t=!0}return t}class y{constructor({displayRecurrence:e,closingRecurrence:t,validationRecurrence:n},s){this.displayRecurrence=parseFloat(e),this.closingRecurrence=parseFloat(t),this.validationRecurrence=parseFloat(n),this.onSetCallback=s,this.widgetName=h(),this.uniqueId=d(),this.recurrenceKey=`${this.widgetName}_${this.uniqueId}`,this.isListeningStorageEvent=this.listenStorageEvent()}onStorage({key:e}){const t=localStorage.getItem("ABTastyWidgetsTemporary"),n=sessionStorage.getItem("ABTastyWidgets");"ABTastyData"===e&&!t&&n&&localStorage.setItem("ABTastyWidgetsTemporary",n)}listenStorageEvent(){return this.isListeningStorageEvent||window.addEventListener("storage",this.onStorage.bind(this)),!0}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]:n,...s}=t;return Object.entries(s).length?(e.setItem("ABTastyWidgets",JSON.stringify(s)),s):(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=localStorage.getItem("ABTastyWidgetsTemporary"),t=!(!e||!e.includes(this.recurrenceKey))||this.getSessionRecurrence();e&&(sessionStorage.setItem("ABTastyWidgets",e),localStorage.removeItem("ABTastyWidgetsTemporary"));const n=this.getLocalRecurrence(),s=(n?parseFloat(n.stamp):0)<(new Date).getTime();return s&&this.removeLocalRecurrenceStorage(),s&&!this.getLocalRecurrence()&&!t}setRecurrence(e,t){0!==e&&(window.removeEventListener("storage",this.onStorage.bind(this)),this.isListeningStorageEvent=!1);const n=this.getTypeOfStorage(e);if(r()||!n&&"object"!=typeof n)return!1;const{storageString:s,storageMethod:i}=n,o=this.getStamp(e),a={type:t,stamp:o},{type:c}=this.getCurrentRecurrence(),l=()=>{const e=this.getSessionRecurrence(),t=this.getLocalRecurrence();let n;"session"===s?e?n=this.removeSessionRecurrenceStorage():(this.removeLocalRecurrenceStorage(),n=this.getSessionRecurrenceStorageParsed()):"local"===s&&(t?n=this.removeLocalRecurrenceStorage():(this.removeSessionRecurrenceStorage(),n=this.getLocalRecurrenceStorageParsed()));const r=n?{[this.recurrenceKey]:a,...n}:{[this.recurrenceKey]:a};i.setItem("ABTastyWidgets",JSON.stringify(r)),this.onSetCallback&&"function"==typeof this.onSetCallback&&this.onSetCallback()};if(!i)return!1;if(c&&"validation"!==t)if("closing"===t&&"validation"!==c)l();else{if("display"!==t||"validation"===c||"closing"===c)return!1;l()}else l();return o}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 b{constructor(){this.targets=[],this.existingTargets=[],this.inViewportTargets=[],this.visibilityObserver=this.startVisibilityObserver(),this.mutationObserver=this.startMutationObserver(),this.mouseOverEvent=this.mouseOverHandler()}intersectionHandler(e){e.forEach(e=>{e.isIntersecting?(this.existingTargets.forEach(t=>{t.element.isSameNode(e.target)&&(this.inViewportTargets.push(t),this.mouseOverEvent.start())}),this.checkElements()):this.inViewportTargets=this.inViewportTargets.filter(t=>!t.element.isSameNode(e.target)||(this.mouseOverEvent.clear(),!1))})}startVisibilityObserver(){return new IntersectionObserver(this.intersectionHandler.bind(this),{root:null,rootMargin:"0px",threshold:0})}startMutationObserver(){const e=this.mutationObserver||new MutationObserver(this.checkElements.bind(this));return document.body&&e.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),e}onMouseOver({target:e,path:t}){const n=this.inViewportTargets.find(({element:n,selector:s})=>{if(n.isSameNode(e))return!0;const i=[...e.querySelectorAll(s)];if(i.length&&i.includes(n))return!0;if(t.includes(n))return!0;const r=[...e.parentElement.children],o=r.findIndex(t=>t.isSameNode(e)),a=r.filter((e,t)=>t>o);if(a.length){if(a.includes(n))return!0;if(a.some(e=>[...e.querySelectorAll(s)].includes(n)))return!0}return!1});if(n&&this.isElementVisible(n.element)){const{selector:e,element:t,uniqueId:s}=n,i=this.targets.find(t=>t.selector===e&&t.uniqueId===s);i&&i.resolve(t),this.clear(e,s)}}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,n){return n(t)||!t.parentElement?t:e(t.parentElement,n)}(e,e=>"0"===window.getComputedStyle(e).opacity).nodeName}isElementTopmost(e){const t=e.getBoundingClientRect(),n=[[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 s=!1,i=0;for(;!s&&i<n.length;){const t=document.elementFromPoint(...n[i]);s=e===t||e.contains(t),i+=1}return s}checkElements(){this.targets.forEach(({selector:e,uniqueId:t})=>{const n=document.querySelector(e);n&&!this.existingTargets.find(n=>n.element.matches(e)&&n.uniqueId===t)&&(this.existingTargets.push({element:n,selector:e,uniqueId:t}),this.visibilityObserver.observe(n))}),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:n})=>{if(t.matches(e)&&this.isElementVisible(t)){const s=this.targets.find(t=>t.selector===e&&t.uniqueId===n);return s&&s.resolve(t),this.clear(e,n),!1}return!0})}watch(e,t,n){this.targets.push({selector:e,resolve:t,uniqueId:n});const s=()=>{this.startMutationObserver(),this.checkElements()};document.body?s():v("body",s)}clear(e,t){[this.targets,this.existingTargets,this.inViewportTargets]=[this.targets,this.existingTargets,this.inViewportTargets].map(n=>n.filter(({selector:n,uniqueId:s})=>n!==e&&s!==t)),this.visibilityObserver.unobserve(document.querySelector(e)),0===this.targets.length&&this.mutationObserver.disconnect(),0===this.inViewportTargets.length&&this.mouseOverEvent.clear()}}class w{constructor({triggerEvent:e,triggerSelector:t,triggerDelay:n}){this.event=e,this.selector=t&&t.length?t:"body",this.delay=1e3*n,this.elementsSelectors=[],this.eventsListeners=[],this.timeouts=[],this.intervals=[],this.observers=[],this.promises=[],this.visibilityObservers=[],this.elementsWaiters=[]}async onElementVisible({promise:e,resolve:t}){const n=p(this.event+"DomReady");this.promises.push(n);const s=await this.onPageLoad(n),i=await f("IntersectionObserver"),r=function(e,t){return ABTasty.widgetUtils||(ABTasty.widgetUtils={}),ABTasty.widgetUtils[e]||Object.assign(ABTasty.widgetUtils,{[e]:new t}),ABTasty.widgetUtils[e]}("VisibilityObserver",b);if(this.visibilityObservers.push(r),i&&s){const e=d();r.watch(this.selector,t,e)}return e}onPageLoad({promise:e,resolve:t}){const n=()=>"complete"===document.readyState;if(!n()){const s=["readystatechange",()=>n()&&t(!0),{passive:!0}];return this.eventsListeners.push(s),document.addEventListener(...s),e}return t(!0),e}onClick({promise:e,resolve:t}){const n=document.createElement("style");n.type="text/css",n.id="Click_"+d(),n.innerHTML=this.selector+" {\n\t\t\tcursor: pointer !important;\n\t\t\tpointer-events: all !important;\n\t\t}",document.head.appendChild(n),this.elementsSelectors.push("#"+n.id);const s=e=>[...document.querySelectorAll(this.selector)].some(t=>t.isSameNode(e)||!!e.closest(this.selector)),i=["click",({target:e})=>s(e)&&t(!0),{passive:!0,capture:!0}];return this.eventsListeners.push(i),document.addEventListener(...i),e}onExitIntent({promise:e,resolve:t}){const n=["mouseleave",async({clientY:e})=>{e<=0&&t(!0)},{passive:!0}],s=v("body",e=>{e.addEventListener(...n),this.eventsListeners.push([e,...n]),this.elementsWaiters=this.elementsWaiters.filter(e=>e!==s)});return this.elementsWaiters.push(s),e}onReengage({promise:e,resolve:t}){const n=this.delay;let s=n;const i=[()=>(s=n,s),{passive:!0}];["click","mousemove","scroll","keypress"].forEach(e=>{document.addEventListener(e,...i),this.eventsListeners.push([e,...i])});const r=setInterval(()=>{s<=0?t(!0):s-=100},100);return this.intervals.push(r),e}onCustomTrigger({promise:e,resolve:t}){const{triggerEventCustomScript:n}=DATA;return new Function(`return new Promise(async resolve => {${n}})`)().then(e=>e&&t(!0)),e}getSocialProofPurchases({promise:e,resolve:t}){const n=window.ABTastyProductKey,s=i(),{viewInterval:r,triggerSocialProofMinPurchases:o,spNoTrim:a}=DATA;return n||(g("Not able to find ABTastyProductKey, impossible to call the API."),t(!1)),n&&s?fetch(`${l}${s}/metrics/i?key=${n}${a?"&noTrim=true":""}`).then(e=>e.ok&&e.json()).then(e=>(e=>{if(void 0===r||void 0===o)return!1;const t=e[r]&&e[r]>=o;return t||g(`Widget will not be shown, product has been purchased ${e[r]} times while ${o} are required`),t})(e)&&t(e[r])).catch(()=>g("Failed to fetch datas from server.")):t(!1),e}getSocialProofPageViews({promise:e,resolve:t}){const n=encodeURIComponent(""+window.location.pathname),s=i(),{viewInterval:r,triggerSocialProofMinPageViews:o}=DATA;return n&&s?fetch(`${l}${s}/metrics/pv?key=${n}`).then(e=>e.ok&&e.json()).then(e=>(e=>{if(void 0===r||void 0===o)return!1;const t=e[r]&&e[r]>=o;return t||g(`Widget will not be shown, page has been seen ${e[r]} times while ${o} are required`),t})(e)&&t(e[r])).catch(()=>g("Failed to fetch datas from server.")):t(!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,...n]="string"==typeof e[0]?[document,...e]:e;t&&n.length>1&&t.removeEventListener(...n)}),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=d();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=p(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)},n=!Object.prototype.hasOwnProperty.call(t,this.event)||await t[this.event]();return this.clear(),"reengage"!==this.event&&this.delay?n&&await(async()=>{const e=p(this.event+"Delay");return this.promises.push(e),setTimeout(()=>{e.resolve(!0),this.clear()},this.delay),e.promise})():n}}class E{constructor(e,t,n){this.recurrence=e,this.isWidgetApplied=t,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(e){const t=o(),{type:n}=this.recurrence?this.recurrence.getCurrentRecurrence():{type:!1},s=()=>e&&"display"===n||this.recurrenceIsDone();return!this.isWidgetApplied()&&t&&s()?(this.clearWatcher(),this.callback("rebuild",e)):(!this.isWidgetApplied()||t&&s())&&(this.isWidgetApplied()||t)||(this.clearWatcher(),this.callback("remove",e),this.watch()),this}eventHandler(){let e=o();return[250,500].forEach(t=>setTimeout(()=>500===t&&o()===e?this:(e=o(),this.decisionHandler(!1)),t)),this}observerHandler(e){const t=e.some(({removedNodes:e})=>e&&e.length),n=e.some(({addedNodes:e})=>e&&e.length);return t||n?(this.decisionHandler(!0),this):this}watch(){if(s())return this;this.clearWatcher(),document.addEventListener(...this.eventListenerParams);const e=v("body",t=>{const n=[t,{childList:!0,subtree:!0}];this.observer.observe(...n),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}}class C{constructor(){this.children=void 0,this.uniqueId=d(),this.widgetName=h(),this.prettyName=u(),this.recurrenceParams=(()=>{const{displayRecurrence:e,closingRecurrence:t,validationRecurrence:n}=DATA;if(s()||!e&&!t&&!n)return!1;const i={everytime:()=>-1,session:()=>0,once:()=>395,day:e=>DATA[e+"_day"],week:e=>7*DATA[e+"_week"],month:e=>30.5*DATA[e+"_month"]},r={};return e&&(r.displayRecurrence=i[e]("displayRecurrence")),t&&(r.closingRecurrence=i[t]("closingRecurrence")),n&&(r.validationRecurrence=i[n]("validationRecurrence")),r})(),this.triggerParams=(()=>{let{triggerEvent:e}=DATA;const{triggerEventClick:t,triggerEventReengageDelay:n,socialProofContentType:i,triggerEventElementVisible:r,triggerEventDelay:o}=DATA;if(s()||!e&&!i)return!1;const a={click:()=>t,elementVisible:()=>r},c=Object.prototype.hasOwnProperty.call(a,e)?a[e]():"body",l="reengage"===e?n:o;return i&&(e=1===i?"socialProofPurchases":"socialProofPageViews"),{triggerEvent:e,triggerSelector:c,triggerDelay:l}})(),this.recurrence=!!this.recurrenceParams&&new y(this.recurrenceParams,this.clearGivenClearables.bind(this)),this.trigger=!!this.triggerParams&&new w(this.triggerParams),this.pageWatcher=new E(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,n)=>{this.elementsWaiters=this.elementsWaiters.filter(e=>e!==t),g(e),n(e)},t=new Promise((t,n)=>{const s=v("head",e=>{this.elementsWaiters=this.elementsWaiters.filter(e=>e!==s),t(e.appendChild(this.styleElement))},t=>e(t,s,n));this.elementsWaiters.push(s)}),n=new Promise((t,n)=>{const{layout:s,elementReferrer:i,referrerInsertType:r}=DATA,{selector:o,position:a}="string"==typeof s&&"free"===s&&"string"==typeof i&&"string"==typeof r?{selector:i,position:r}:{selector:"body",position:"beforeend"},c=v(o,e=>{this.elementsWaiters=this.elementsWaiters.filter(e=>e!==c),this.removeOldDomElement(),t(e.insertAdjacentElement(a,this.domElement))},t=>e(t,c,n));this.elementsWaiters.push(c)});return Promise.all([n,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():s()||this.init().then(({response:e})=>e?this.show():this),this}show(){return this.hasBeenShown||s()||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&&!s()&&window.ABTastyEvent(this.prettyName+" closed",null,TEST_ID),this.closedByUser=!0,this.domElement.classList.add(this.hideClassName),this}async init(e){if(!s()&&!o())return!1;if(this.trigger&&this.trigger.promises.length)return!1;const t=this.recurrence&&this.recurrence.isOver();if(this.recurrence&&!t)return this.pageWatcher.watch(),!1;this.pageWatcher.watch();const n=s()||!this.trigger||this.trigger&&await this.trigger.isTriggered();return!!n&&(await this.insert(),this.addCloseEvent(),s()||e||this.hasBeenShown||void 0===this.children||"function"!=typeof this.children.refreshContent||this.children.refreshContent(n),{container:this,response:n})}onPageChange(e,t){const n=()=>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()):n()}}addCloseEvent(...e){const{closeButton:t,overlayClickable:n,layout:i}=DATA,r=[];if(void 0!==n&&n&&void 0!==i&&"popin"===i&&r.push("."+this.overlayClassName),void 0!==t&&t&&r.push("."+this.closeButtonClassName),!r.length)return this;const o=this.domElement.querySelectorAll(r.join(", "));return o.length?(e.push(...o),e.forEach(e=>{s()&&(e.dataset.abtastyActionnable="true"),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:t}=DATA,n=document.createElement("div");return n.className=`${this.basicClassName} ${this.hideClassName}`,n.id=this.widgetContainerId,n.innerHTML=`\n\t\t\t${void 0!==t&&"popin"===t?`<div class="${this.overlayClassName}"></div>`:""}\n\t\t\t<div class="${this.contentClassName}">\n\t\t\t\t${e?`<button class="${this.closeButtonClassName}"><svg viewBox="0 0 16 16">\n\t<defs><path id="prefix__a" d="M12 4.991L11.009 4 8 7.009 4.991 4 4 4.991 7.009 8 4 11.009 4.991 12 8 8.991 11.009 12 12 11.009 8.991 8z"></path></defs>\n\t<g><use xlink:href="#prefix__a"></use></g>\n</svg></button>`:""}\n\t\t\t</div>`,n}getStyleTag(e=""){const{noStyles:t,layout:n}=DATA,{backgroundColor:i,isBackgroundImage:r,backgroundImage:o,backgroundSize:a,backgroundPosition:c,backgroundRepeat:l,borderColor:h,borderRadius:u,borderWidth:d,textColor:m,textAlign:g,overlayColor:p,dropShadow:v,dropShadowColor:f,dropShadowBlur:y,containerMargin:b,containerPadding:w,closeButton:E,buttonsBorderWidth:C,buttonsBorderColor:S,buttonsBorderRadius:N,buttonsBackgroundColor:T,buttonsTextColor:_}=t?{}:DATA,x=document.createElement("style");x.type="text/css",s()&&x.setAttribute("abtasty-script-added","true");const k=`background: ${["string"==typeof i?i:"rgba(255, 255, 255, 1)",r&&"string"==typeof o&&o.length?`url(${o})`:"",r&&"string"==typeof c&&"100% 100%"!==a?c:"0 0",r&&"string"==typeof a?"/ "+a:"/ auto",r&&l&&!["cover","100% 100%"].includes(a)?"repeat":"no-repeat"].join(" ").trim()};`,A="number"==typeof d&&d>0,L=`border: ${[A?d+"px":"unset",A?"solid":"",A&&"string"==typeof h&&h.length?h:""].join(" ").trim()};`,$=void 0!==u?`border-radius: ${u}px;`:"",I=void 0!==m?`color: ${m}; fill: ${m};`:"",P=void 0!==g?`text-align: ${g};`:"",B=void 0!==v&&v?`box-shadow: 0 5px ${y}px 0 ${f};`:"",O=b instanceof Array&&1===b.length&&b[0],R=O?`margin: ${O.top}px ${O.right}px ${O.bottom}px ${O.left}px;`:"",W=O?`margin: calc(${O.top}px * 0.5) calc(${O.right}px * 0.5) calc(${O.bottom}px * 0.5) calc(${O.left}px * 0.5);`:"",D=w instanceof Array&&1===w.length&&w[0],j=D?`padding: ${D.top}px ${D.right}px ${D.bottom}px ${D.left}px;`:"",q=D?`padding: calc(${D.top}px * 0.5) calc(${D.right}px * 0.5) calc(${D.bottom}px * 0.5) calc(${D.left}px * 0.5);`:"",V=void 0!==C&&C?`border-width: ${C}px; border-style: solid;`:"",M=[S,C].every(e=>void 0!==e)&&C?`border-color: ${S};`:"",F=void 0!==N?`border-radius: ${N}px;`:"",H=void 0!==T?`background-color: ${T};`:"",Y=void 0!==_?`color: ${_};`:"",G=void 0!==n&&"popin"===n?[`#${this.widgetContainerId} .${this.overlayClassName} {`,`background-color: ${void 0!==p?p:"rgba(0, 0, 0, 0.6)"};`,"}"].join(""):"",U=t||void 0!==E&&E?[`#${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;",I,"}"].join(""):"";return x.textContent=[`.${this.hideClassName} {`,"opacity: 0 !important;","pointer-events: none;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,k,$,L,I,P,B,R,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,"display: block;","line-height: 1;","text-indent: unset;",j,"}",`#${this.widgetContainerId} .${this.contentClassName} > * a, `,`#${this.widgetContainerId} .${this.contentClassName} > * button {`,V,M,F,H,Y,"}","@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,W,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,q,"}","}",G,U,""+e].join(""),x}}class S extends C{constructor(){super(),this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){return[`#${this.widgetContainerId} {`,"position: fixed;","top: 0;","left: 0;","width: 100%;","height: 100%;","z-index: 9999;","opacity: 1;","transition: opacity 0.25s ease;","}",`#${this.widgetContainerId} .${this.overlayClassName} {`,"position: absolute;","z-index: -1;","top: 0;","left: 0;","width: 100%;","height: 100%;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: absolute;","left: 50%;","top: 50%;","transform: translate(-50%, -50%);","width: auto;","height: auto;","}","@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,"max-width: 94vw;","}","}"].join("")}}class N extends C{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 T extends C{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 _=()=>{const{layout:e}=DATA;let t;switch(e){case"popin":t=new S;break;case"bannerTop":case"bannerBottom":t=new N;break;case"free":t=new T;break;default:t=new C}return t},x={category:c,type:"slider",min:1},k=[{...x,propName:"day",label:"widget_common_conditions_recurrence_ifOptionVariable_labelDays",value:5,max:395},{...x,propName:"week",label:"widget_common_conditions_recurrence_ifOptionVariable_labelWeeks",value:2,max:56},{...x,propName:"month",label:"widget_common_conditions_recurrence_ifOptionVariable_labelMonths",value:1,max:13}],A={category:c,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"},L={...A,label:"widget_common_conditions_recurrence_label_widgetDisplayed",propName:"displayRecurrence"},$=(k.map(e=>({...e,propName:`${L.propName}_${e.propName}`,conditions:[{field:L.propName,value:e.propName}]})),{...A,label:"widget_common_conditions_recurrence_label_widgetDisplayedAfterClosure",propName:"closingRecurrence"}),I=(k.map(e=>({...e,propName:`${$.propName}_${e.propName}`,conditions:[{field:$.propName,value:e.propName}]})),{...A,label:"widget_common_conditions_recurrence_label_widgetDisplayedAfterSubmission",propName:"validationRecurrence"});k.map(e=>({...e,propName:`${I.propName}_${e.propName}`,conditions:[{field:I.propName,value:e.propName}]}));$.condition=({closeButton:e,layout:t,overlayClickable:n})=>!("popin"===t&&!1===e&&!1===n||void 0!==t&&"popin"!==t&&!1===e);const P={pageLoad:{label:"widget_common_conditions_triggering_option_pageload",value:"pageLoad"},direct:{label:"widget_common_conditions_triggering_option_asap",value:"direct"},exitIntent:{label:"widget_common_conditions_triggering_option_exitIntent",value:"exitIntent"},reengage:{label:"widget_common_conditions_triggering_option_afterXSecondsOfInactivity",value:"reengage"},click:{label:"widget_common_conditions_triggering_option_click",value:"click"},elementVisible:{label:"widget_common_conditions_triggering_option_elementVisible",value:"elementVisible"},customScript:{label:"widget_common_conditions_triggering_option_customTrigger",value:"script"}};Object.keys(P).map(e=>P[e]);var B=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")};function O(e,t){for(var n=0;n<t.length;n++){var s=t[n];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,s.key,s)}}var R=function(e,t,n){return t&&O(e.prototype,t),n&&O(e,n),e},W=DATA,D=W.isFeedBackQuestion,j=W.isThankYouMessage,q=W.autoHide,V=W.timeHide,M=W.stepToShow,F=W.question,H=W.feedbackQuestion,Y=W.buttonText,G=W.thankYouMessage,U=W.isLegend,z=W.minLegend,K=W.maxLegend,Q=W.noStyles,X=function(){function e(t){var n=t.parentContainer;B(this,e),this.parentContainer=n,this.baseClassName="nps_container",this.className="".concat(this.baseClassName,"_").concat(n.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(n.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 R(e,[{key:"sendNote",value:function(){if(!s()&&!isNaN(this.currentNote)){try{window.abtasty.send("nps",{ns:this.currentNote,nf:this.userFeedback})}catch(e){g("Not able to send NPS hit due to old tag version (< 3.0)")}this.parentContainer.recurrence.setValidationRecurrence()}return this}},{key:"insertIn",value:function(e,t){return document.head.insertAdjacentElement("beforeend",this.styleElement),e.insertAdjacentElement(t,this.npsElement),this}},{key:"complete",value:function(){var e=this;return this.sendNote(),q?(setTimeout((function(){e.parentContainer.hide(),setTimeout((function(){e.parentContainer.remove(),e.showNotes(),e.currentNote=NaN,e.userFeedback="",e.feedbackElements.feedbackFormElement.querySelector("textarea").value=""}),1e3)}),1e3*V),this):this}},{key:"onClickNote",value:function(e){this.currentNote=Number(e.target.dataset.note),D&&H&&H.length?this.showFeedBack():j&&G&&G.length?this.showThankYouMessage():this.complete()}},{key:"onFeedbackSend",value:function(){j&&G&&G.length?this.showThankYouMessage():this.complete()}},{key:"showNotes",value:function(){var e=this;return this.npsContainer.childNodes.forEach((function(t){return t.classList.add(e.hideClassName)})),[this.questionElement,this.notesContainer].forEach((function(t){return t.classList.remove(e.hideClassName)})),this}},{key:"showFeedBack",value:function(){var e=this;return this.npsContainer.childNodes.forEach((function(t){return t.classList.add(e.hideClassName)})),Object.values(this.feedbackElements).forEach((function(t){return t.classList.remove(e.hideClassName)})),this}},{key:"showThankYouMessage",value:function(){var e=this;return this.npsContainer.childNodes.forEach((function(t){return t.classList.add(e.hideClassName)})),this.thankYouElement.classList.remove(this.hideClassName),this.complete(),this}},{key:"getThankYouElement",value:function(){var e=document.createElement("p");return e.className="".concat(this.thankYouClassName," ").concat(this.hideClassName),e.innerHTML=G,s()&&"displayThanksStep"===M&&e.classList.remove(this.hideClassName),e}},{key:"getFeedBackElements",value:function(){var e=this,t=document.createElement("p");t.className="".concat(this.feedbackQuestionClassName," ").concat(this.hideClassName),t.innerHTML=H;var n=document.createElement("form");n.className="".concat(this.feedbackFormClassName," ").concat(this.hideClassName),n.addEventListener("submit",(function(e){return e.preventDefault()}),{passive:!1});var i=document.createElement("textarea");i.className="".concat(this.feedbackQuestionClassName,"_textarea");var r=document.createElement("button");return r.className="".concat(this.feedbackQuestionClassName,"_button"),r.innerHTML="<span>".concat(Y,"</span>"),r.addEventListener("click",(function(){return e.userFeedback=i.value,e.onFeedbackSend()}),{passive:!0}),s()&&"displayFeedbackStep"===M&&[t,n].forEach((function(t){return t.classList.remove(e.hideClassName)})),n.appendChild(i),n.appendChild(r),{feedbackQuestionElement:t,feedbackFormElement:n}}},{key:"getNotesElement",value:function(){var e=this,t=document.createElement("div");t.className=this.notesClassName,s()&&"displayNoteStep"!==M&&t.classList.add(this.hideClassName);for(var n=10;n>=0;){var i=document.createElement("button");i.className=this.notesButtonsClassName,i.dataset.note=n,s()&&i.setAttribute("data-abtasty-actionnable",""),i.innerHTML+="<span>".concat(n,"</span>"),i.addEventListener("click",(function(t){return e.onClickNote(t)}),{passive:!0}),t.insertAdjacentElement("afterbegin",i),5===n&&i.insertAdjacentHTML("afterend","<br>"),n-=1}return U&&(t.insertAdjacentHTML("afterbegin","<legend>".concat(z,"</legend>")),t.insertAdjacentHTML("beforeend","<legend>".concat(K,"</legend>"))),t}},{key:"getQuestionElement",value:function(){var e=document.createElement("p");return e.className=this.questionClassName,e.innerHTML=F,s()&&"displayNoteStep"!==M&&e.classList.add(this.hideClassName),e}},{key:"getContainer",value:function(){var e=document.createElement("div");return e.className="".concat(this.baseClassName," ").concat(this.className),e}},{key:"getNPSElement",value:function(){var e=this;return this.npsContainer.appendChild(this.questionElement),this.npsContainer.appendChild(this.notesContainer),D&&Object.values(this.feedbackElements).forEach((function(t){e.npsContainer.appendChild(t)})),j&&this.npsContainer.appendChild(this.thankYouElement),this.npsContainer}},{key:"getStyleElement",value:function(){var e=document.createElement("style");if(e.type="text/css",s()&&e.setAttribute("abtasty-script-added","true"),Q)e.textContent=["#".concat(this.parentContainer.widgetContainerId," .").concat(this.className," .").concat(this.hideClassName," {"),"display: none !important;","}"].join("");else{var t=DATA.containerPadding,n=t instanceof Array&&1===t.length&&t[0],i="#".concat(this.parentContainer.widgetContainerId," .").concat(this.className);e.textContent=["".concat(i," .").concat(this.hideClassName," {"),"display: none !important;","}","".concat(i,","),"".concat(i," * {"),"all: unset;","box-sizing: border-box;","font-size: 10px;","line-height: 1;","font-family: sans-serif;","}","".concat(i," > * {"),"display: block;","width: 100%;","}","".concat(i," .").concat(this.notesClassName," {"),"position: relative;","display: inline-block;","width: auto;","}","".concat(i," p {"),"margin-bottom: 15px;","font-size: 1.4em;","}","".concat(i," button {"),"vertical-align: middle;","cursor: pointer;","text-align: center;","}","".concat(i," button span {"),"font-size: 1.4em;","pointer-events: none;","}","".concat(i," .").concat(this.notesClassName," button {"),"margin: 0 5px;","width: 30px;","height: 30px;","}","".concat(i," .").concat(this.feedbackFormClassName," span {"),"display: block;","padding: 6px 24px;","}",U?["".concat(i," legend {"),"position: absolute;","text-decoration: none;","border: none;","font-size: 1em;","}","".concat(i," legend:nth-of-type(2) {"),"left: auto;","right: 0;","}"].join(""):"","".concat(i," textarea {"),"display: block;","width: 100%;","min-width: 310px;","min-height: 60px;","font-size: 1.4em;","border: 1px solid grey;","border-radius: 4px;","resize: vertical;","margin-bottom: 10px;","text-align: left;","padding: 5px;","}","".concat(i," .").concat(this.thankYouClassName," {"),"margin-bottom: 0;","}","@media screen and (min-width: 580px) {","".concat(i," {"),"min-width: 560px;","}",U?["".concat(i," .").concat(this.notesClassName," {"),"padding-top: 22px","}","".concat(i," legend {"),"top: 0;","left: 0;","display: inline-block;","width: auto;","}"].join(""):"","".concat(i," br {"),"display: none","}","}","@media screen and (max-width: 579px) {","".concat(i," {"),"min-width: ".concat(240+(n.left+n.right/2),"px;"),"}","".concat(i," .").concat(this.notesClassName," button {"),"margin-bottom: 5px;","}","".concat(i," br {"),"display: block","}",U?["".concat(i," .").concat(this.notesClassName," {"),"padding-bottom: 35px;","}","".concat(i," legend {"),"bottom: 0;","left: 50%;","transform: translateX(-50%)","}","".concat(i," legend:nth-of-type(1) {"),"bottom: 15px;","}","".concat(i," legend:nth-of-type(2) {"),"left: 50%;","right: unset;","}","".concat(i," legend:nth-of-type(1)::before {"),'content: "0: ";',"}","".concat(i," legend:nth-of-type(2)::before{"),'content: "10: ";',"}"].join(""):"","".concat(i," textarea {"),"min-width: auto;","}","}"].join("")}return e}}]),e}();function J(){return(J=n(e.mark((function t(){var n,s,i;return e.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=_(),s=n.domElement.querySelector(".".concat(n.contentClassName)),i=new X({parentContainer:n}),n.children=i,i.insertIn(s,"beforeend"),n.init().then((function(e){return e.response&&n.show()})),e.abrupt("return",{parentContainer:n,NPS:i});case 8:case"end":return e.stop()}}),t)})))).apply(this,arguments)}!function(){J.apply(this,arguments)}()}();
package/package.json CHANGED
@@ -1,43 +1,44 @@
1
- {
2
- "name": "@abtasty/nps",
3
- "description": "Allow you to add a custom NPS on your website",
4
- "version": "1.0.3",
5
- "form": "dist/form.js",
6
- "main": "dist/main.js",
7
- "files": [
8
- "dist"
9
- ],
10
- "repository": "abtasty/widget",
11
- "author": "Jonathan Granger",
12
- "license": "MIT",
13
- "scripts": {
14
- "start": "concurrently --kill-others \"npm run watch\" \"npm run serve\"",
15
- "watch": "rollup -c --watch",
16
- "build": "rollup -c",
17
- "serve": "widget serve"
18
- },
19
- "devDependencies": {
20
- "@babel/core": "^7.8.4",
21
- "@babel/plugin-transform-classes": "^7.8.3",
22
- "@babel/plugin-transform-runtime": "^7.8.3",
23
- "@babel/preset-env": "^7.8.4",
24
- "@babel/runtime": "^7.4.2",
25
- "concurrently": "^5.1.0",
26
- "eslint": "^6.8.0",
27
- "eslint-config-airbnb-base": "^14.1.0",
28
- "eslint-config-prettier": "^6.10.1",
29
- "eslint-import-resolver-node": "^0.3.2",
30
- "eslint-plugin-import": "^2.8.0",
31
- "rollup": "^2.6.1",
32
- "rollup-plugin-babel": "^4.3.3",
33
- "rollup-plugin-eslint": "^7.0.0"
34
- },
35
- "dependencies": {
36
- "@abtasty/widget-utils": "1.16.6",
37
- "@babel/plugin-proposal-object-rest-spread": "^7.8.3",
38
- "@rollup/plugin-commonjs": "^11.0.1",
39
- "@rollup/plugin-node-resolve": "^7.0.0",
40
- "babel-eslint": "^10.0.3",
41
- "rollup-plugin-terser": "^5.2.0"
42
- }
43
- }
1
+ {
2
+ "name": "@abtasty/nps",
3
+ "description": "Allow you to add a custom NPS on your website",
4
+ "version": "1.1.0",
5
+ "form": "dist/form.js",
6
+ "main": "dist/main.js",
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "repository": "abtasty/widget",
11
+ "author": "Jonathan Granger",
12
+ "license": "MIT",
13
+ "scripts": {
14
+ "start": "concurrently --kill-others \"npm run watch\" \"npm run serve\"",
15
+ "watch": "rollup -c --watch",
16
+ "build": "rollup -c",
17
+ "serve": "widget serve",
18
+ "prepare": "npm run build"
19
+ },
20
+ "devDependencies": {
21
+ "@babel/core": "^7.8.4",
22
+ "@babel/plugin-transform-classes": "^7.8.3",
23
+ "@babel/plugin-transform-runtime": "^7.8.3",
24
+ "@babel/preset-env": "^7.8.4",
25
+ "@babel/runtime": "^7.4.2",
26
+ "concurrently": "^5.1.0",
27
+ "eslint": "^6.8.0",
28
+ "eslint-config-airbnb-base": "^14.1.0",
29
+ "eslint-config-prettier": "^6.10.1",
30
+ "eslint-import-resolver-node": "^0.3.2",
31
+ "eslint-plugin-import": "^2.8.0",
32
+ "rollup": "^2.6.1",
33
+ "rollup-plugin-babel": "^4.3.3",
34
+ "rollup-plugin-eslint": "^7.0.0"
35
+ },
36
+ "dependencies": {
37
+ "@abtasty/widget-utils": "1.16.11",
38
+ "@babel/plugin-proposal-object-rest-spread": "^7.8.3",
39
+ "@rollup/plugin-commonjs": "^11.0.1",
40
+ "@rollup/plugin-node-resolve": "^7.0.0",
41
+ "babel-eslint": "^10.0.3",
42
+ "rollup-plugin-terser": "^5.2.0"
43
+ }
44
+ }