@abtasty/progress-bar 1.0.1-1 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
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,a=new Array(o);t<o;t++)a[t]=e[t];return a};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 a=function(o,t){if(o){if("string"==typeof o)return e(o,t);var a=Object.prototype.toString.call(o).slice(8,-1);return"Object"===a&&o.constructor&&(a=o.constructor.name),"Map"===a||"Set"===a?Array.from(o):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?e(o,t):void 0}};var r=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 l=function(e){return o(e)||t(e)||a(e)||r()};const n="style",i="content",c="conditions",_="select",p="colorpicker",s="textarea",g="switch",d="slider",u="group",m="https://widgets-images.abtasty.com/",b={category:c,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: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"},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"},B=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"},k=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 x={category:c,type:u,label:"widget_common_conditions_recurrence_blockTitle",collapsible:!0,children:[w,...f,N,...B,h,...k]},O={category:c,type:d,propName:"triggerEventDelay",label:"widget_common_conditions_triggering_delay_label",min:0,max:60,value:0},I={...O,propName:"triggerEventReengageDelay",value:10,max:180},P={category:c,type:"selectelement",propName:"triggerEventClick",value:"body"},C={...P,propName:"triggerEventElementVisible"},V={category:c,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},E={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"}},S={category:c,type:g,propName:"isOncePerPageTrigger",value:!0,label:"widget_common_conditions_triggering_label_triggerOnlyOnce"},T={category:c,type:"select",label:"widget_common_conditions_triggering_label",options:Object.keys(E).map(e=>E[e]),propName:"triggerEvent",value:"pageLoad"};P.conditions=[{field:"triggerEvent",value:"click"}],I.conditions=[{field:"triggerEvent",value:"reengage"}],C.conditions=[{field:"triggerEvent",value:"elementVisible"}],V.conditions=[{field:"triggerEvent",value:"script"}],O.conditions=[{field:"triggerEvent",value:e=>"reengage"!==e}],S.conditions=[{field:"triggerEvent",value:e=>"click"===e||"script"===e}];const R={category:c,type:u,label:"widget_common_conditions_triggering_blockTitle",collapsible:!0,children:[T,...[P,C,V,S,I,O]]},L={category:"layout",type:"selectelement",propName:"elementReferrer",label:"widget_common_layout_label_selectElementContainWidget",value:"body"},j={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"}]},U=[{field:"layout",value:"free"}];L.conditions=U,j.conditions=U;const A={category:n,type:"colorpicker",label:"widget_common_style_container_label_backgroundColor",propName:"backgroundColor",value:"rgba(247, 247, 247, 1)"},D={category:n,type:g,label:"widget_common_style_toggler_label_backgroundImage",propName:"isBackgroundImage",value:!1},G={category:n,type:"mediaupload",label:"widget_common_style_toggler_label_backgroundImage",propName:"backgroundImage",value:""},$={category:n,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"}]},M={category:n,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"}]},Q={category:n,type:g,label:"widget_common_style_backgroundImageUploader_toggler_repeatBackgroundImage",propName:"backgroundRepeat",value:!1},W={category:n,type:"colorpicker",label:"widget_common_style_border_label_borderColor",propName:"borderColor",value:"rgba(0, 127, 145, 1)"},X={category:n,type:d,label:"widget_common_style_border_label_borderRadius",propName:"borderRadius",value:4,unit:"px"},H={category:n,type:d,label:"widget_common_style_border_label_borderThickness",propName:"borderWidth",value:2,min:0,max:50,unit:"px"},J={category:n,type:"colorpicker",label:"widget_common_style_text_label_textColor",propName:"textColor",value:"rgba(57, 57, 57, 1)"},q={category:n,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:n,type:"areainput"},F={...z,label:"widget_common_style_container_label_margin",propName:"containerMargin",value:[{top:0,left:0,bottom:0,right:0}]},K={...z,label:"widget_common_style_container_label_padding",propName:"containerPadding",value:[{top:35,left:60,bottom:35,right:60}]},Y={category:n,type:g,label:"widget_common_style_container_dropShadow_blockTitle",propName:"dropShadow",value:!1},Z={category:n,type:"colorpicker",label:"widget_common_style_container_dropShadow_label_color",propName:"dropShadowColor",value:"rgba(57, 57, 57, 0.25);"},ee={category:n,type:d,label:"widget_common_style_container_dropShadow_label_blurRadius",propName:"dropShadowBlur",value:10,unit:"px"},oe={category:n,type:g,label:"widget_common_style_container_label_displayCloseButton",propName:"closeButton",value:!0},te={field:D.propName,value:!0},ae={field:$.propName,value:e=>"cover"!==e},re={field:$.propName,value:e=>"100% 100%"!==e};G.conditions=[te],$.conditions=[te],M.conditions=[te,re],Q.conditions=[te,re,ae];const le=[A,D,G,$,M,Q],ne=[{field:H.propName,value:e=>e>0}];W.conditions=ne;const ie={category:n,type:u,label:"widget_common_style_blockTitle_border",collapsible:!0,children:[H,W,X]},ce={category:n,type:u,label:"widget_common_style_blockTitle_text",collapsible:!0,children:[q,J]},_e=[{field:"dropShadow",value:!0}];Z.conditions=_e,ee.conditions=_e;const pe={category:n,type:u,label:"widget_common_style_blockTitle_container",collapsible:!0,children:[F,K,...le,Y,Z,ee,oe]};var se=[{category:"layout",type:"hidden",propName:"layout",value:"free"},L,j,{category:"layout",type:"radioImage",propName:"subLayout",label:"widget_progressBar_layout_selectProgressBarLayout_label",value:"customTextVariables",style:"big",options:[{value:"customTextVariables",label:"widget_progressBar_layout_selectProgressBarLayout_progressBarIntegrated_option",src:"".concat(m,"layout/icon-layout-progressBar-sentence.png")},{value:"customLabelVariables",label:"widget_progressBar_layout_selectProgressBarLayout_progressBarLabelVariable_option",src:"".concat(m,"layout/icon-layout-progressBar-label.png")},{value:"progressBarOnly",label:"widget_progressBar_layout_selectProgressBarLayout_progressBarOnly_option",src:"".concat(m,"layout/icon-layout-progressBar-only.png")}]}];var ge=function(e,o,t){return o in e?Object.defineProperty(e,o,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[o]=t,e};function de(e,o){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);o&&(a=a.filter((function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable}))),t.push.apply(t,a)}return t}function ue(e){for(var o=1;o<arguments.length;o++){var t=null!=arguments[o]?arguments[o]:{};o%2?de(Object(t),!0).forEach((function(o){ge(e,o,t[o])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):de(Object(t)).forEach((function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(t,o))}))}return e}var me=[{field:"subLayout",value:function(e){return"progressBarOnly"!==e}}],be={category:i,type:"radio",propName:"variableType",value:"element",options:[{label:"widget_progressBar_content_variable_selectElement_label",value:"element"},{label:"widget_progressBar_content_variable_radioVariableValueCollection_customJs_option",value:"javascript"}]},ye={category:i,type:_,propName:"variableUnitType",label:"widget_progressBar_content_variable_select_displayVariable_label",value:"value",options:[{label:"widget_progressBar_content_variable_select_displayVariable_value_option",value:"value"},{label:"widget_progressBar_content_variable_select_displayVariable_percentage_option",value:"percent"}],conditions:me},ve={category:i,type:_,propName:"variableDisplayingValue",label:"widget_progressBar_content_variable_select_displayVariableRelationQuantity_label",value:"remaining",options:[{label:"widget_progressBar_content_variable_select_displayVariableRelationQuantity_remaining_option",value:"remaining"},{label:"widget_progressBar_content_variable_select_displayVariableRelationQuantity_accumulated_option",value:"accumulated"}],conditions:me},we={category:i,type:s,propName:"textVariablesContent",label:"widget_common_content_message_dragNDrop_label",conditions:[{field:"subLayout",value:"customTextVariables"}]},fe=[{category:i,propName:"progressBarInfo",type:"inlinenotification",label:"widget_progressBar_content_dedicatedHtmlElement_alert"},be,{category:i,type:"selectelement",propName:"variableElement",label:"widget_progressBar_content_variable_radioVariableValueCollection_selectElement_option",value:"body",conditions:[{field:be.propName,value:"element"}]},{category:i,type:s,propName:"variableJavascript",value:"/* run the update() function whenever you need to update the progress bar */\nvar counter = 0;\nsetInterval(function () {\n if(counter > 90) {\n counter = 0;\n } else {\n counter += 10;\n }\n update(counter);\n},1000);\n ",conditions:[{field:be.propName,value:"javascript"}]},{category:i,type:"number",propName:"reachQuantity",label:"widget_progressBar_content_quantityToReach_input_label",value:100,min:1},ye,ve,ue(ue({},we),{},{propName:"".concat(we.propName,"_").concat(ye.options[0].value,"_").concat(ve.options[0].value),value:"widget_progressBar_content_textarea_default_valueRemaining",conditions:[].concat(l(we.conditions),[{field:ye.propName,value:ye.options[0].value},{field:ve.propName,value:ve.options[0].value}])}),ue(ue({},we),{},{propName:"".concat(we.propName,"_").concat(ye.options[0].value,"_").concat(ve.options[1].value),value:"widget_progressBar_content_textarea_default_valueAccumulated",conditions:[].concat(l(we.conditions),[{field:ye.propName,value:ye.options[0].value},{field:ve.propName,value:ve.options[1].value}])}),ue(ue({},we),{},{value:"widget_progressBar_content_textarea_default_percentageRemaining",propName:"".concat(we.propName,"_").concat(ye.options[1].value,"_").concat(ve.options[0].value),conditions:[].concat(l(we.conditions),[{field:ye.propName,value:ye.options[1].value},{field:ve.propName,value:ve.options[0].value}])}),ue(ue({},we),{},{propName:"".concat(we.propName,"_").concat(ye.options[1].value,"_").concat(ve.options[1].value),value:"widget_progressBar_content_textarea_default_percentageAccumulated",conditions:[].concat(l(we.conditions),[{field:ye.propName,value:ye.options[1].value},{field:ve.propName,value:ve.options[1].value}])}),{category:i,type:"text",label:"widget_progressBar_content_input_label_label",value:"widget_progressBar_content_input_label_default",propName:"textLabelContent",conditions:[{field:"subLayout",value:"customLabelVariables"}]}],Ne={category:n,type:g,label:"widget_progressBar_style_progressBarGroup_toggler_colorblindModeSripes_label",propName:"colorBlindMode",value:!1},Be={category:n,type:u,label:"widget_progressBar_style_progressBarGroup_blockTitle",collapsible:!0,collapsed:!1,children:[{category:n,type:p,label:"widget_progressBar_style_progressBarGroup_colorPicker_progressBarColor_label",propName:"progressBarColor",value:"rgba(0, 127, 145, 1)"},{category:n,type:p,label:"widget_progressBar_style_progressBarGroup_colorPicker_progressBarBackgroundColor_label",propName:"progressBarBackgroundColor",value:"#E1E1E1"},Ne,{category:n,type:p,label:"widget_progressBar_style_progressBarGroup_colorPicker_stripesColor_label",propName:"progressBarStripesColor",value:"rgba(255, 255, 255, 0.8)",conditions:[{field:Ne.propName}]},{category:n,type:d,label:"widget_progressBar_style_progressBarGroup_slider_progressBarHeight_label",propName:"progressBarHeight",value:8,min:0,max:50},{category:n,type:d,label:"widget_progressBar_style_progressBarGroup_slider_progressBarRadius_label",propName:"progressBarBorderRadius",value:4,min:0,max:30}]};Be.collapsed=!1,ce.conditions=[{field:"subLayout",value:function(e){return"progressBarOnly"!==e}}],ce.children.find((function(e){return"textAlign"===e.propName})).conditions=[{field:"subLayout",value:"customTextVariables"}],pe.children.find((function(e){return"closeButton"===e.propName})).value=!1;var he=[Be,ce,pe,ie];R.collapsed=!1;var ke=x.children.find((function(e){return"validationRecurrence"===e.propName})),xe=x.children.find((function(e){return"closingRecurrence"===e.propName}));ke.label="widget_progressBar_conditions_recurrenceCompleted_select_label",xe.conditions=[{field:"closeButton"}];var Oe=[R,x];return[].concat(l(se),l(fe),l(he),l(Oe))}));
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,r=new Array(o);t<o;t++)r[t]=e[t];return r};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 r=function(o,t){if(o){if("string"==typeof o)return e(o,t);var r=Object.prototype.toString.call(o).slice(8,-1);return"Object"===r&&o.constructor&&(r=o.constructor.name),"Map"===r||"Set"===r?Array.from(o):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?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 l=function(e){return o(e)||t(e)||r(e)||a()};const n="style",i="content",c="conditions",p="select",s="colorpicker",_="textarea",g="slider",u="group",d="https://widgets-images.abtasty.com/",m={category:c,type:g,min:1},b=[{...m,propName:"day",label:"widget_common_conditions_recurrence_ifOptionVariable_labelDays",value:5,max:395},{...m,propName:"week",label:"widget_common_conditions_recurrence_ifOptionVariable_labelWeeks",value:2,max:56},{...m,propName:"month",label:"widget_common_conditions_recurrence_ifOptionVariable_labelMonths",value:1,max:13}],y={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"},v={...y,label:"widget_common_conditions_recurrence_label_widgetDisplayed",propName:"displayRecurrence"},f=b.map(e=>({...e,propName:`${v.propName}_${e.propName}`,conditions:[{field:v.propName,value:e.propName}]})),w={...y,label:"widget_common_conditions_recurrence_label_widgetDisplayedAfterClosure",propName:"closingRecurrence"},N=b.map(e=>({...e,propName:`${w.propName}_${e.propName}`,conditions:[{field:w.propName,value:e.propName}]})),B={...y,label:"widget_common_conditions_recurrence_label_widgetDisplayedAfterSubmission",propName:"validationRecurrence"},h=b.map(e=>({...e,propName:`${B.propName}_${e.propName}`,conditions:[{field:B.propName,value:e.propName}]})),x={category:c,type:u,label:"widget_common_conditions_recurrence_blockTitle",collapsible:!0,children:[v,...f,w,...N,B,...h]},O={category:c,type:g,propName:"triggerEventDelay",label:"widget_common_conditions_triggering_delay_label",min:0,max:60,value:0},k={...O,propName:"triggerEventReengageDelay",value:10,max:180},V={category:c,type:"selectelement",propName:"triggerEventClick",value:"body"},C={...V,propName:"triggerEventElementVisible"},E={category:c,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},S={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"}},T={category:c,type:"switch",propName:"isOncePerPageTrigger",value:!0,label:"widget_common_conditions_triggering_label_triggerOnlyOnce"},P={category:c,type:"select",label:"widget_common_conditions_triggering_label",options:Object.keys(S).map(e=>S[e]),propName:"triggerEvent",value:"pageLoad"};V.conditions=[{field:"triggerEvent",value:"click"}],k.conditions=[{field:"triggerEvent",value:"reengage"}],C.conditions=[{field:"triggerEvent",value:"elementVisible"}],E.conditions=[{field:"triggerEvent",value:"script"}],O.conditions=[{field:"triggerEvent",value:e=>"reengage"!==e}],T.conditions=[{field:"triggerEvent",value:e=>"click"===e||"script"===e}];const j={category:c,type:u,label:"widget_common_conditions_triggering_blockTitle",collapsible:!0,children:[P,...[V,C,E,T,k,O]]},L={category:"layout",type:"selectelement",propName:"elementReferrer",label:"widget_common_layout_label_selectElementContainWidget",value:"body"},R={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"}]},A=[{field:"layout",value:"free"}];L.conditions=A,R.conditions=A;const I={category:n,type:"colorpicker",label:"widget_common_style_container_label_backgroundColor",propName:"backgroundColor",value:"rgba(247, 247, 247, 1)"},D={category:n,type:"colorpicker",label:"widget_common_style_border_label_borderColor",propName:"borderColor",value:"rgba(0, 127, 145, 1)"},G={category:n,type:g,label:"widget_common_style_border_label_borderRadius",propName:"borderRadius",value:4,unit:"px"},$={category:n,type:g,label:"widget_common_style_border_label_borderThickness",propName:"borderWidth",value:2,min:0,max:50,unit:"px"},M={category:n,type:"colorpicker",label:"widget_common_style_text_label_textColor",propName:"textColor",value:"rgba(57, 57, 57, 1)"},Q={category:n,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:d+"style/icon-text-alignLeft.png"},{label:"widget_common_style_text_textAlignment_option_center",value:"center",src:d+"style/icon-text-alignCenter.png"},{label:"widget_common_style_text_textAlignment_option_right",value:"right",src:d+"style/icon-text-alignRight.png"}]},W={category:n,type:"areainput"},X={...W,label:"widget_common_style_container_label_margin",propName:"containerMargin",value:[{top:0,left:0,bottom:0,right:0}]},H={...W,label:"widget_common_style_container_label_padding",propName:"containerPadding",value:[{top:35,left:60,bottom:35,right:60}]},J={category:n,type:"switch",label:"widget_common_style_container_dropShadow_blockTitle",propName:"dropShadow",value:!1},U={category:n,type:"colorpicker",label:"widget_common_style_container_dropShadow_label_color",propName:"dropShadowColor",value:"rgba(57, 57, 57, 0.25);"},q={category:n,type:g,label:"widget_common_style_container_dropShadow_label_blurRadius",propName:"dropShadowBlur",value:10,unit:"px"},F={category:n,type:"switch",label:"widget_common_style_container_label_displayCloseButton",propName:"closeButton",value:!0},z=[{field:$.propName,value:e=>e>0}];D.conditions=z;const K={category:n,type:u,label:"widget_common_style_blockTitle_border",collapsible:!0,children:[$,D,G]},Y={category:n,type:u,label:"widget_common_style_blockTitle_text",collapsible:!0,children:[Q,M]},Z=[{field:"dropShadow",value:!0}];U.conditions=Z,q.conditions=Z;const ee={category:n,type:u,label:"widget_common_style_blockTitle_container",collapsible:!0,children:[X,H,I,J,U,q,F]};var oe=[{category:"layout",type:"hidden",propName:"layout",value:"free"},L,R,{category:"layout",type:"radioImage",propName:"subLayout",label:"widget_progressBar_layout_selectProgressBarLayout_label",value:"customTextVariables",style:"big",options:[{value:"customTextVariables",label:"widget_progressBar_layout_selectProgressBarLayout_progressBarIntegrated_option",src:"".concat(d,"layout/icon-layout-progressBar-sentence.png")},{value:"customLabelVariables",label:"widget_progressBar_layout_selectProgressBarLayout_progressBarLabelVariable_option",src:"".concat(d,"layout/icon-layout-progressBar-label.png")},{value:"progressBarOnly",label:"widget_progressBar_layout_selectProgressBarLayout_progressBarOnly_option",src:"".concat(d,"layout/icon-layout-progressBar-only.png")}]}];var te=function(e,o,t){return o in e?Object.defineProperty(e,o,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[o]=t,e};function re(e,o){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);o&&(r=r.filter((function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable}))),t.push.apply(t,r)}return t}function ae(e){for(var o=1;o<arguments.length;o++){var t=null!=arguments[o]?arguments[o]:{};o%2?re(Object(t),!0).forEach((function(o){te(e,o,t[o])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):re(Object(t)).forEach((function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(t,o))}))}return e}var le=[{field:"subLayout",value:function(e){return"progressBarOnly"!==e}}],ne={category:i,type:"radio",propName:"variableType",value:"element",options:[{label:"widget_progressBar_content_variable_selectElement_label",value:"element"},{label:"widget_progressBar_content_variable_radioVariableValueCollection_customJs_option",value:"javascript"}]},ie={category:i,type:p,propName:"variableUnitType",label:"widget_progressBar_content_variable_select_displayVariable_label",value:"value",options:[{label:"widget_progressBar_content_variable_select_displayVariable_value_option",value:"value"},{label:"widget_progressBar_content_variable_select_displayVariable_percentage_option",value:"percent"}],conditions:le},ce={category:i,type:p,propName:"variableDisplayingValue",label:"widget_progressBar_content_variable_select_displayVariableRelationQuantity_label",value:"remaining",options:[{label:"widget_progressBar_content_variable_select_displayVariableRelationQuantity_remaining_option",value:"remaining"},{label:"widget_progressBar_content_variable_select_displayVariableRelationQuantity_accumulated_option",value:"accumulated"}],conditions:le},pe={category:i,type:_,propName:"textVariablesContent",label:"widget_common_content_message_dragNDrop_label",conditions:[{field:"subLayout",value:"customTextVariables"}]},se=[{category:i,propName:"progressBarInfo",type:"inlinenotification",label:"widget_progressBar_content_dedicatedHtmlElement_alert"},ne,{category:i,type:"selectelement",propName:"variableElement",label:"widget_progressBar_content_variable_radioVariableValueCollection_selectElement_option",value:"body",conditions:[{field:ne.propName,value:"element"}]},{category:i,type:_,propName:"variableJavascript",value:"/* run the update() function whenever you need to update the progress bar */\nvar counter = 0;\nsetInterval(function () {\n if(counter > 90) {\n counter = 0;\n } else {\n counter += 10;\n }\n update(counter);\n},1000);\n ",conditions:[{field:ne.propName,value:"javascript"}]},{category:i,type:"number",propName:"reachQuantity",label:"widget_progressBar_content_quantityToReach_input_label",value:100,min:1},ie,ce,ae(ae({},pe),{},{propName:"".concat(pe.propName,"_").concat(ie.options[0].value,"_").concat(ce.options[0].value),value:"widget_progressBar_content_textarea_default_valueRemaining",conditions:[].concat(l(pe.conditions),[{field:ie.propName,value:ie.options[0].value},{field:ce.propName,value:ce.options[0].value}])}),ae(ae({},pe),{},{propName:"".concat(pe.propName,"_").concat(ie.options[0].value,"_").concat(ce.options[1].value),value:"widget_progressBar_content_textarea_default_valueAccumulated",conditions:[].concat(l(pe.conditions),[{field:ie.propName,value:ie.options[0].value},{field:ce.propName,value:ce.options[1].value}])}),ae(ae({},pe),{},{value:"widget_progressBar_content_textarea_default_percentageRemaining",propName:"".concat(pe.propName,"_").concat(ie.options[1].value,"_").concat(ce.options[0].value),conditions:[].concat(l(pe.conditions),[{field:ie.propName,value:ie.options[1].value},{field:ce.propName,value:ce.options[0].value}])}),ae(ae({},pe),{},{propName:"".concat(pe.propName,"_").concat(ie.options[1].value,"_").concat(ce.options[1].value),value:"widget_progressBar_content_textarea_default_percentageAccumulated",conditions:[].concat(l(pe.conditions),[{field:ie.propName,value:ie.options[1].value},{field:ce.propName,value:ce.options[1].value}])}),{category:i,type:"text",label:"widget_progressBar_content_input_label_label",value:"widget_progressBar_content_input_label_default",propName:"textLabelContent",conditions:[{field:"subLayout",value:"customLabelVariables"}]}],_e={category:n,type:"switch",label:"widget_progressBar_style_progressBarGroup_toggler_colorblindModeSripes_label",propName:"colorBlindMode",value:!1},ge={category:n,type:u,label:"widget_progressBar_style_progressBarGroup_blockTitle",collapsible:!0,collapsed:!1,children:[{category:n,type:s,label:"widget_progressBar_style_progressBarGroup_colorPicker_progressBarColor_label",propName:"progressBarColor",value:"rgba(0, 127, 145, 1)"},{category:n,type:s,label:"widget_progressBar_style_progressBarGroup_colorPicker_progressBarBackgroundColor_label",propName:"progressBarBackgroundColor",value:"#E1E1E1"},_e,{category:n,type:s,label:"widget_progressBar_style_progressBarGroup_colorPicker_stripesColor_label",propName:"progressBarStripesColor",value:"rgba(255, 255, 255, 0.8)",conditions:[{field:_e.propName}]},{category:n,type:g,label:"widget_progressBar_style_progressBarGroup_slider_progressBarHeight_label",propName:"progressBarHeight",value:8,min:0,max:50},{category:n,type:g,label:"widget_progressBar_style_progressBarGroup_slider_progressBarRadius_label",propName:"progressBarBorderRadius",value:4,min:0,max:30}]};ge.collapsed=!1,Y.conditions=[{field:"subLayout",value:function(e){return"progressBarOnly"!==e}}],Y.children.find((function(e){return"textAlign"===e.propName})).conditions=[{field:"subLayout",value:"customTextVariables"}],ee.children.find((function(e){return"closeButton"===e.propName})).value=!1;var ue=[ge,Y,ee,K];j.collapsed=!1;var de=x.children.find((function(e){return"validationRecurrence"===e.propName})),me=x.children.find((function(e){return"closingRecurrence"===e.propName}));de.label="widget_progressBar_conditions_recurrenceCompleted_select_label",me.conditions=[{field:"closeButton"}];var be=[j,x];return[].concat(l(oe),l(se),l(ue),l(be))}));
package/dist/main.js CHANGED
@@ -1 +1 @@
1
- !function(){"use strict";const e=()=>Object.prototype.hasOwnProperty.call(window,"ABTastyEditor");const t=()=>{let e;return window.ABTasty||window.ABTASTY_S?(window.ABTASTY_S&&window.ABTASTY_S.USER&&window.ABTASTY_S.USER.accountIdentifier&&window.ABTASTY_S.USER.accountIdentifier.length?e=window.ABTASTY_S.USER.accountIdentifier:window.ABTasty&&window.ABTasty.getAccountSettings&&"function"==typeof window.ABTasty.getAccountSettings?e=window.ABTasty.getAccountSettings().identifier:window.ABTasty&&window.ABTasty.accountSettings&&(e=window.ABTasty.accountSettings.identifier),e):e},r=()=>{const e=!!document.getElementById("ABTastyPreviewBar"),t=location.href.includes("ab_project=preview");return e||t},n=()=>r()||!!window.ABTasty.getTestsOnPage()[TEST_ID],s=()=>{if(e()||r())return!1;const t=ABTasty.getTestsOnPage()[TEST_ID];return!!t&&Object.keys(t.targetings.qaParameters).length>0},i="conditions",o="https://social-proof-api.abtasty.com/clients/",a=()=>{const{type:e}=DATA;return`${PACKAGE.replace("@abtasty/","")}${e?"_"+e:""}`},c=()=>{const e=a();return`${e.charAt(0).toUpperCase()}${e.slice(1)}`.split("-").join(" ")},l=()=>`${PLUGIN_ID.split("-")[0]}_${TEST_ID}`,h=(...e)=>{e.unshift(`[AB Tasty Widget] ${PACKAGE}:`),console.log(...e)},u=e=>{if(s()){const t=c();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)")}},d=e=>{const t={promise:null,resolve:null,reject:null,name:e};return t.promise=new Promise((e,r)=>{t.resolve=e,t.reject=r}),t},g=(e,t,r)=>{let n=0,s=0;try{document.querySelector(e)}catch(t){const n=`Selector «${e}» not valid.`;return h(n),"function"==typeof r&&r(n)}function i(){clearInterval(s),clearTimeout(n)}return n=setTimeout(()=>{i();const t=`Can't find element «${e}».`;return h(t),"function"==typeof r&&r(t)},1e4),s=setInterval(()=>{const r=document.querySelector(e);return null!==r?(i(),"function"==typeof t&&t(r)):r},200),{clear:i}};async function m(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,r)=>{const n=window.document.getElementsByTagName("script")[0],s=window.document.createElement("script");s.src=e,n.parentNode.insertBefore(s,n),s.onload=t,s.onerror=r})}("https://polyfill.io/v3/polyfill.min.js?flags=gated&features=IntersectionObserver"));break;default:t=!0}return t}class p{constructor({displayRecurrence:e,closingRecurrence:t,validationRecurrence:r},n){this.displayRecurrence=parseFloat(e),this.closingRecurrence=parseFloat(t),this.validationRecurrence=parseFloat(r),this.onSetCallback=n,this.widgetName=a(),this.uniqueId=l(),this.recurrenceKey=`${this.widgetName}_${this.uniqueId}`,this.isListeningStorageEvent=this.listenStorageEvent()}onStorage({key:e}){const t=localStorage.getItem("ABTastyWidgetsTemporary"),r=sessionStorage.getItem("ABTastyWidgets");"ABTastyData"===e&&!t&&r&&localStorage.setItem("ABTastyWidgetsTemporary",r)}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]:r,...n}=t;return Object.entries(n).length?(e.setItem("ABTastyWidgets",JSON.stringify(n)),n):(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 r=this.getLocalRecurrence(),n=(r?parseFloat(r.stamp):0)<(new Date).getTime();return n&&this.removeLocalRecurrenceStorage(),n&&!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 r;"session"===s?e?r=this.removeSessionRecurrenceStorage():(this.removeLocalRecurrenceStorage(),r=this.getSessionRecurrenceStorageParsed()):"local"===s&&(t?r=this.removeLocalRecurrenceStorage():(this.removeSessionRecurrenceStorage(),r=this.getLocalRecurrenceStorageParsed()));const n=r?{[this.recurrenceKey]:a,...r}:{[this.recurrenceKey]:a};i.setItem("ABTastyWidgets",JSON.stringify(n)),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 v{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 r=this.inViewportTargets.find(({element:r,selector:n})=>{if(r.isSameNode(e))return!0;const s=[...e.querySelectorAll(n)];if(s.length&&s.includes(r))return!0;if(t.includes(r))return!0;const i=[...e.parentElement.children],o=i.findIndex(t=>t.isSameNode(e)),a=i.filter((e,t)=>t>o);if(a.length){if(a.includes(r))return!0;if(a.some(e=>[...e.querySelectorAll(n)].includes(r)))return!0}return!1});if(r&&this.isElementVisible(r.element)){const{selector:e,element:t,uniqueId:n}=r,s=this.targets.find(t=>t.selector===e&&t.uniqueId===n);s&&s.resolve(t),this.clear(e,n)}}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,r){return r(t)||!t.parentElement?t:e(t.parentElement,r)}(e,e=>"0"===window.getComputedStyle(e).opacity).nodeName}isElementTopmost(e){const t=e.getBoundingClientRect(),r=[[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 n=!1,s=0;for(;!n&&s<r.length;){const t=document.elementFromPoint(...r[s]);n=e===t||e.contains(t),s+=1}return n}checkElements(){this.targets.forEach(({selector:e,uniqueId:t})=>{const r=document.querySelector(e);r&&!this.existingTargets.find(r=>r.element.matches(e)&&r.uniqueId===t)&&(this.existingTargets.push({element:r,selector:e,uniqueId:t}),this.visibilityObserver.observe(r))}),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:r})=>{if(t.matches(e)&&this.isElementVisible(t)){const n=this.targets.find(t=>t.selector===e&&t.uniqueId===r);return n&&n.resolve(t),this.clear(e,r),!1}return!0})}watch(e,t,r){this.targets.push({selector:e,resolve:t,uniqueId:r});const n=()=>{this.startMutationObserver(),this.checkElements()};document.body?n():g("body",n)}clear(e,t){[this.targets,this.existingTargets,this.inViewportTargets]=[this.targets,this.existingTargets,this.inViewportTargets].map(r=>r.filter(({selector:r,uniqueId:n})=>r!==e&&n!==t)),this.visibilityObserver.unobserve(document.querySelector(e)),0===this.targets.length&&this.mutationObserver.disconnect(),0===this.inViewportTargets.length&&this.mouseOverEvent.clear()}}class y{constructor({triggerEvent:e,triggerSelector:t,triggerDelay:r}){this.event=e,this.selector=t&&t.length?t:"body",this.delay=1e3*r,this.elementsSelectors=[],this.eventsListeners=[],this.timeouts=[],this.intervals=[],this.observers=[],this.promises=[],this.visibilityObservers=[],this.elementsWaiters=[]}async onElementVisible({promise:e,resolve:t}){const r=d(this.event+"DomReady");this.promises.push(r);const n=await this.onPageLoad(r),s=await m("IntersectionObserver"),i=function(e,t){return ABTasty.widgetUtils||(ABTasty.widgetUtils={}),ABTasty.widgetUtils[e]||Object.assign(ABTasty.widgetUtils,{[e]:new t}),ABTasty.widgetUtils[e]}("VisibilityObserver",v);if(this.visibilityObservers.push(i),s&&n){const e=l();i.watch(this.selector,t,e)}return e}onPageLoad({promise:e,resolve:t}){const r=()=>"complete"===document.readyState;if(!r()){const n=["readystatechange",()=>r()&&t(!0),{passive:!0}];return this.eventsListeners.push(n),document.addEventListener(...n),e}return t(!0),e}onClick({promise:e,resolve:t}){const r=document.createElement("style");r.type="text/css",r.id="Click_"+l(),r.innerHTML=this.selector+" {\n\t\t\tcursor: pointer !important;\n\t\t\tpointer-events: all !important;\n\t\t}",document.head.appendChild(r),this.elementsSelectors.push("#"+r.id);const n=e=>[...document.querySelectorAll(this.selector)].some(t=>t.isSameNode(e)||!!e.closest(this.selector)),s=["click",({target:e})=>n(e)&&t(!0),{passive:!0,capture:!0}];return this.eventsListeners.push(s),document.addEventListener(...s),e}onExitIntent({promise:e,resolve:t}){const r=["mouseleave",async({clientY:e})=>{e<=0&&t(!0)},{passive:!0}],n=g("body",e=>{e.addEventListener(...r),this.eventsListeners.push([e,...r]),this.elementsWaiters=this.elementsWaiters.filter(e=>e!==n)});return this.elementsWaiters.push(n),e}onReengage({promise:e,resolve:t}){const r=this.delay;let n=r;const s=[()=>(n=r,n),{passive:!0}];["click","mousemove","scroll","keypress"].forEach(e=>{document.addEventListener(e,...s),this.eventsListeners.push([e,...s])});const i=setInterval(()=>{n<=0?t(!0):n-=100},100);return this.intervals.push(i),e}onCustomTrigger({promise:e,resolve:t}){const{triggerEventCustomScript:r}=DATA;return new Function(`return new Promise(async resolve => {${r}})`)().then(e=>e&&t(!0)),e}getSocialProofPurchases({promise:e,resolve:r}){const n=window.ABTastyProductKey,s=t(),{viewInterval:i,triggerSocialProofMinPurchases:a,spNoTrim:c}=DATA;return n||(u("Not able to find ABTastyProductKey, impossible to call the API."),r(!1)),n&&s?fetch(`${o}${s}/metrics/i?key=${n}${c?"&noTrim=true":""}`).then(e=>e.ok&&e.json()).then(e=>(e=>{if(void 0===i||void 0===a)return!1;const t=e[i]&&e[i]>=a;return t||u(`Widget will not be shown, product has been purchased ${e[i]} times while ${a} are required`),t})(e)&&r(e[i])).catch(()=>u("Failed to fetch datas from server.")):r(!1),e}getSocialProofPageViews({promise:e,resolve:r}){const n=encodeURIComponent(""+window.location.pathname),s=t(),{viewInterval:i,triggerSocialProofMinPageViews:a}=DATA;return n&&s?fetch(`${o}${s}/metrics/pv?key=${n}`).then(e=>e.ok&&e.json()).then(e=>(e=>{if(void 0===i||void 0===a)return!1;const t=e[i]&&e[i]>=a;return t||u(`Widget will not be shown, page has been seen ${e[i]} times while ${a} are required`),t})(e)&&r(e[i])).catch(()=>u("Failed to fetch datas from server.")):r(!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,...r]="string"==typeof e[0]?[document,...e]:e;t&&r.length>1&&t.removeEventListener(...r)}),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=l();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=d(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)},r=!Object.prototype.hasOwnProperty.call(t,this.event)||await t[this.event]();return this.clear(),"reengage"!==this.event&&this.delay?r&&await(async()=>{const e=d(this.event+"Delay");return this.promises.push(e),setTimeout(()=>{e.resolve(!0),this.clear()},this.delay),e.promise})():r}}class b{constructor(e,t,r){this.recurrence=e,this.isWidgetApplied=t,this.callback=r,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=n(),{type:r}=this.recurrence?this.recurrence.getCurrentRecurrence():{type:!1},s=()=>e&&"display"===r||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=n();return[250,500].forEach(t=>setTimeout(()=>500===t&&n()===e?this:(e=n(),this.decisionHandler(!1)),t)),this}observerHandler(e){const t=e.some(({removedNodes:e})=>e&&e.length),r=e.some(({addedNodes:e})=>e&&e.length);return t||r?(this.decisionHandler(!0),this):this}watch(){if(e())return this;this.clearWatcher(),document.addEventListener(...this.eventListenerParams);const t=g("body",e=>{const r=[e,{childList:!0,subtree:!0}];this.observer.observe(...r),this.elementsWaiters=this.elementsWaiters.filter(e=>e!==t)});return this.elementsWaiters.push(t),this}clearWatcher(){return document.removeEventListener(...this.eventListenerParams),this.elementsWaiters.length&&(this.elementsWaiters.forEach(e=>e.clear()),this.elementsWaiters=[]),this.observer.disconnect(),this}}class f{constructor(){this.children=void 0,this.uniqueId=l(),this.widgetName=a(),this.prettyName=c(),this.recurrenceParams=(()=>{const{displayRecurrence:t,closingRecurrence:r,validationRecurrence:n}=DATA;if(e()||!t&&!r&&!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"]},i={};return t&&(i.displayRecurrence=s[t]("displayRecurrence")),r&&(i.closingRecurrence=s[r]("closingRecurrence")),n&&(i.validationRecurrence=s[n]("validationRecurrence")),i})(),this.triggerParams=(()=>{let{triggerEvent:t}=DATA;const{triggerEventClick:r,triggerEventReengageDelay:n,socialProofContentType:s,triggerEventElementVisible:i,triggerEventDelay:o}=DATA;if(e()||!t&&!s)return!1;const a={click:()=>r,elementVisible:()=>i},c=Object.prototype.hasOwnProperty.call(a,t)?a[t]():"body",l="reengage"===t?n:o;return s&&(t=1===s?"socialProofPurchases":"socialProofPageViews"),{triggerEvent:t,triggerSelector:c,triggerDelay:l}})(),this.recurrence=!!this.recurrenceParams&&new p(this.recurrenceParams,this.clearGivenClearables.bind(this)),this.trigger=!!this.triggerParams&&new y(this.triggerParams),this.pageWatcher=new b(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,r)=>{this.elementsWaiters=this.elementsWaiters.filter(e=>e!==t),u(e),r(e)},t=new Promise((t,r)=>{const n=g("head",e=>{this.elementsWaiters=this.elementsWaiters.filter(e=>e!==n),t(e.appendChild(this.styleElement))},t=>e(t,n,r));this.elementsWaiters.push(n)}),r=new Promise((t,r)=>{const{layout:n,elementReferrer:s,referrerInsertType:i}=DATA,{selector:o,position:a}="string"==typeof n&&"free"===n&&"string"==typeof s&&"string"==typeof i?{selector:s,position:i}:{selector:"body",position:"beforeend"},c=g(o,e=>{this.elementsWaiters=this.elementsWaiters.filter(e=>e!==c),this.removeOldDomElement(),t(e.insertAdjacentElement(a,this.domElement))},t=>e(t,c,r));this.elementsWaiters.push(c)});return Promise.all([r,t]).then(()=>this)}remove(){return this.pageWatcher.clearWatcher(),this.domElement&&this.domElement.closest("html")&&this.domElement.remove(),this.styleElement&&this.styleElement.closest("html")&&this.styleElement.remove(),this.hasOncePerPageTrigger?this.pageWatcher.watch():e()||this.init().then(({response:e})=>e?this.show():this),this}show(){return this.hasBeenShown||e()||window.ABTastyEvent(this.prettyName+" displayed",null,TEST_ID),this.closedByUser=!1,this.domElement.classList.remove(this.hideClassName),this.recurrence&&this.recurrence.setDisplayRecurrence(),this.hasBeenShown=!0,this.pageWatcher.watch(),this}hide(){return this.hasBeenShown&&!e()&&window.ABTastyEvent(this.prettyName+" closed",null,TEST_ID),this.closedByUser=!0,this.domElement.classList.add(this.hideClassName),this}async init(t){if(!e()&&!n())return!1;if(this.trigger&&this.trigger.promises.length)return!1;const r=this.recurrence&&this.recurrence.isOver();if(this.recurrence&&!r)return this.pageWatcher.watch(),!1;this.pageWatcher.watch();const s=e()||!this.trigger||this.trigger&&await this.trigger.isTriggered();return!!s&&(await this.insert(),this.addCloseEvent(),e()||t||this.hasBeenShown||void 0===this.children||"function"!=typeof this.children.refreshContent||this.children.refreshContent(s),{container:this,response:s})}onPageChange(e,t){const r=()=>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()):r()}}addCloseEvent(...t){const{closeButton:r,overlayClickable:n,layout:s}=DATA,i=[];if(void 0!==n&&n&&void 0!==s&&"popin"===s&&i.push("."+this.overlayClassName),void 0!==r&&r&&i.push("."+this.closeButtonClassName),!i.length)return this;const o=this.domElement.querySelectorAll(i.join(", "));return o.length?(t.push(...o),t.forEach(t=>{e()&&(t.dataset.abtastyActionnable="true"),t.addEventListener("click",()=>{this.recurrence&&this.recurrence.setClosingRecurrence(),this.hide(),setTimeout(()=>this.remove(),1e3)},{passive:!0,once:!0})}),this):this}getDom(){const{closeButton:e,layout:t}=DATA,r=document.createElement("div");return r.className=`${this.basicClassName} ${this.hideClassName}`,r.id=this.widgetContainerId,r.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>`,r}getStyleTag(t=""){const{noStyles:r,layout:n}=DATA,{backgroundColor:s,isBackgroundImage:i,backgroundImage:o,backgroundSize:a,backgroundPosition:c,backgroundRepeat:l,borderColor:h,borderRadius:u,borderWidth:d,textColor:g,textAlign:m,overlayColor:p,dropShadow:v,dropShadowColor:y,dropShadowBlur:b,containerMargin:f,containerPadding:w,closeButton:S,buttonsBorderWidth:_,buttonsBorderColor:T,buttonsBorderRadius:C,buttonsBackgroundColor:E,buttonsTextColor:A}=r?{}:DATA,$=document.createElement("style");$.type="text/css",e()&&$.setAttribute("abtasty-script-added","true");const x=`background: ${["string"==typeof s?s:"rgba(255, 255, 255, 1)",i&&"string"==typeof o&&o.length?`url(${o})`:"",i&&"string"==typeof c&&"100% 100%"!==a?c:"0 0",i&&"string"==typeof a?"/ "+a:"/ auto",i&&l&&!["cover","100% 100%"].includes(a)?"repeat":"no-repeat"].join(" ").trim()};`,B="number"==typeof d&&d>0,I=`border: ${[B?d+"px":"unset",B?"solid":"",B&&"string"==typeof h&&h.length?h:""].join(" ").trim()};`,N=void 0!==u?`border-radius: ${u}px;`:"",R=void 0!==g?`color: ${g}; fill: ${g};`:"",P=void 0!==m?`text-align: ${m};`:"",k=void 0!==v&&v?`box-shadow: 0 5px ${b}px 0 ${y};`:"",O=f instanceof Array&&1===f.length&&f[0],L=O?`margin: ${O.top}px ${O.right}px ${O.bottom}px ${O.left}px;`:"",V=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);`:"",W=w instanceof Array&&1===w.length&&w[0],D=W?`padding: ${W.top}px ${W.right}px ${W.bottom}px ${W.left}px;`:"",j=W?`padding: calc(${W.top}px * 0.5) calc(${W.right}px * 0.5) calc(${W.bottom}px * 0.5) calc(${W.left}px * 0.5);`:"",q=void 0!==_&&_?`border-width: ${_}px; border-style: solid;`:"",H=[T,_].every(e=>void 0!==e)&&_?`border-color: ${T};`:"",U=void 0!==C?`border-radius: ${C}px;`:"",M=void 0!==E?`background-color: ${E};`:"",F=void 0!==A?`color: ${A};`:"",G=void 0!==n&&"popin"===n?[`#${this.widgetContainerId} .${this.overlayClassName} {`,`background-color: ${void 0!==p?p:"rgba(0, 0, 0, 0.6)"};`,"}"].join(""):"",K=r||void 0!==S&&S?[`#${this.widgetContainerId} .${this.contentClassName} .${this.closeButtonClassName} {`,"position: absolute;","top: 8px;","right: 8px;","width: auto;","height: auto;","background: none;","border: none;","cursor: pointer;","outline: none;","padding: 0;","margin: 0;","}",`#${this.widgetContainerId} .${this.contentClassName} .${this.closeButtonClassName} svg {`,"pointer-events: none;","width: 16px;","height: 16px;",R,"}"].join(""):"";return $.textContent=[`.${this.hideClassName} {`,"opacity: 0 !important;","pointer-events: none;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,x,N,I,R,P,k,L,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,"display: block;","line-height: 1;","text-indent: unset;",D,"}",`#${this.widgetContainerId} .${this.contentClassName} > * a, `,`#${this.widgetContainerId} .${this.contentClassName} > * button {`,q,H,U,M,F,"}","@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,V,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,j,"}","}",G,K,""+t].join(""),$}}class w extends f{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 S extends f{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 _ extends f{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 T={category:i,type:"slider",min:1},C=[{...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}],E={category:i,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={...E,label:"widget_common_conditions_recurrence_label_widgetDisplayed",propName:"displayRecurrence"},$=(C.map(e=>({...e,propName:`${A.propName}_${e.propName}`,conditions:[{field:A.propName,value:e.propName}]})),{...E,label:"widget_common_conditions_recurrence_label_widgetDisplayedAfterClosure",propName:"closingRecurrence"}),x=(C.map(e=>({...e,propName:`${$.propName}_${e.propName}`,conditions:[{field:$.propName,value:e.propName}]})),{...E,label:"widget_common_conditions_recurrence_label_widgetDisplayedAfterSubmission",propName:"validationRecurrence"});C.map(e=>({...e,propName:`${x.propName}_${e.propName}`,conditions:[{field:x.propName,value:e.propName}]}));$.condition=({closeButton:e,layout:t,overlayClickable:r})=>!("popin"===t&&!1===e&&!1===r||void 0!==t&&"popin"!==t&&!1===e);const B={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(B).map(e=>B[e]);var I=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")};function N(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var R=function(e,t,r){return t&&N(e.prototype,t),r&&N(e,r),e};var P=function(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))};function k(){var e=P(['\n\t\t<div class="','">\n\t\t\t',"\n\t\t\t","\n\t\t</div>\n\t"]);return k=function(){return e},e}function O(){var e=P(['\n\t\t\t\t<dl class="abtasty_progress_definition">\n\t\t\t\t\t<dt class="abtasty_progress_label">','</dt>\n\t\t\t\t\t<dd class="abtasty_progress_value">',"</dd>\n\t\t\t\t</dl>\n\t\t\t"]);return O=function(){return e},e}function L(){var e=P(['\n\t\t\t\t<p class="abtasty_progress_definition">',"</p>\n\t\t\t"]);return L=function(){return e},e}function V(){var e=P(['\n\t\t<div class="abtasty_progress_pbar">\n\t\t\t<div\n\t\t\t\tclass="abtasty_progress_indicator"\n\t\t\t\tstyle="transform: ',' !important;"\n\t\t\t></div>\n\t\t</div>\n\t']);return V=function(){return e},e}function W(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];return e.reduce((function(e,t,n){return e+r[n-1]+t}))}function D(e){return Math.floor(100*e)/100}function j(e){var t=this,r=e.reachQuantity,n=e.colorBlindMode,s=e.progressBarStripesColor,i=e.progressBarBackgroundColor,o=e.progressBarColor,a=e.progressBarBorderRadius,c=e.progressBarHeight;function l(e){return"translateX(".concat(Math.min(e,r)/r*100-100,"%)")}this.addStyleRules([".abtasty_progress_pbar {\n background-color: ".concat(i,";\n border-radius: ").concat(a,"px;\n overflow: hidden;\n }"),".abtasty_progress_indicator {\n height: ".concat(c,"px;\n background-color: ").concat(o,";\n transition: transform 0.5s ease-out;\n transform: translateX(-100%);\n border-top-right-radius: ").concat(a,"px;\n border-bottom-right-radius: ").concat(a,"px;\n }"),n?"\n .abtasty_progress_indicator {\n background-image: repeating-linear-gradient(-45deg,\n transparent,\n transparent 7px,\n ".concat(s," 6px,\n ").concat(s," 14px);\n }"):""]);var h=this.parentContainer.domElement.getElementsByClassName("abtasty_progress_indicator");return this.eventHub.on("valueUpdated",(function(){Array.from(h).forEach((function(e){e.style.setProperty("transform",l(t.value.numericValue),"important")}))})),W(V(),l(this.value.numericValue))}function q(e){var t=this,r=e.reachQuantity,n=e.textLabelContent,s=e.subLayout,i=e.textColor,o=e.textAlign;this.addStyleRules([".abtasty_progress_definition {\n font-size: 12px;\n color: ".concat(i,";\n margin: 7px 0 0 0;\n text-align: ").concat(o,";\n word-break: break-word;\n }"),".abtasty_progress_label {\n margin: 0;\n font-family: inherit;\n color: inherit;\n font-size: inherit;\n word-break: break-word;\n }",".abtasty_progress_value {\n margin: 0;\n font-family: inherit;\n color: inherit;\n font-size: inherit;\n word-break: initial;\n }"]);var a=this.parentContainer.domElement.getElementsByClassName("abtasty_progress_value");return this.eventHub.on("valueUpdated",(function(e){Array.from(a).forEach((function(e){e.textContent=D(t.value.displayingValue)}))})),{customTextVariables:function(){var e=t.textVariablesContent.replace("!variable!",'<span class="abtasty_progress_value">'.concat(D(t.value.displayingValue),"</span>")).replace("!quantityToReach!",'<span class="abtasty_progress_max">'.concat(r,"</span>"));return W(L(),e)},customLabelVariables:function(){return t.addStyleRules([".abtasty_progress_definition {\n display: flex;\n justify-content: space-between;\n }",".abtasty_progress_label {\n flex-basis: 66%;\n text-align: left;\n }"]),W(O(),n,t.value.displayingValue)},progressBarOnly:function(){return""}}[s]()}function H(e){var t=e.reachQuantity,r=e.subLayout,n=e.textLabelContent,s=e.progressBarStripesColor,i=e.progressBarBackgroundColor,o=e.progressBarColor,a=e.colorBlindMode,c=e.progressBarBorderRadius,l=e.progressBarHeight,h=e.textColor,u=e.textAlign;return W(k(),this.className,j.call(this,{reachQuantity:t,progressBarStripesColor:s,progressBarBackgroundColor:i,progressBarColor:o,colorBlindMode:a,progressBarBorderRadius:c,progressBarHeight:l}),q.call(this,{subLayout:r,textLabelContent:n,reachQuantity:t,textColor:h,textAlign:u}))}var U=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n};var M=function(e){if(Array.isArray(e))return U(e)};var F=function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)};var G=function(e,t){if(e){if("string"==typeof e)return U(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?U(e,t):void 0}};var K=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 z=function(e){return M(e)||F(e)||G(e)||K()},Q=/\s/g,Y=/\d(\d|\.|\s|,)*/,X=/(\d)(,)(\d{3,})/gi,J=/(\d)(,)(\d{1,2})$/gm,Z=/(\d+)(\.)(\d+)(,)(\d+)$/gm,ee=/(,)(\d{3,})/g;var te=function(){function t(e){var r=e.parentContainer;I(this,t),this.eventHub={hub:Object.create(null),emit:function(e,t){(this.hub[e]||[]).forEach((function(e){return e(t)}))},on:function(e,t){this.hub[e]||(this.hub[e]=[]),this.hub[e].push(t)},off:function(e,t){var r=(this.hub[e]||[]).findIndex((function(e){return e===t}));r>-1&&this.hub[e].splice(r,1),0===this.hub[e].length&&delete this.hub[e]}},this.renderContent=H,this.parentContainer=r,this.baseClassName="progressbar_container",this.className="".concat(this.baseClassName,"_").concat(r.uniqueId),this.styleRules=[],this.externalValue=0,this.value=this.getValue(),this.contentElement=this.getContentElement(),this.styleElement=this.getStyleElement(),this.sourceValueObserver=new MutationObserver(this.handleValueUpdate.bind(this)),this.parentContainer.children=this}return R(t,[{key:"start",value:function(t){var r=this;this.eventHub.on("refreshContent",(function(){"element"===t.variableType&&r.eventHub.emit("valueElementUpdated")})),this.eventHub.on("valueElementUpdated",(function(){r.value=r.getValue(),r.eventHub.emit("valueUpdated")})),this.eventHub.on("sourceElementPresence",(function(e){e?(r.value=r.getValue(),r.eventHub.emit("valueElementUpdated"),r.parentContainer.domElement.hidden=!1,r.sourceValueObserver.observe(e,{childList:!0,subtree:!0,attributes:!1,characterData:!0})):(r.sourceValueObserver.disconnect(),r.parentContainer.domElement.hidden=!0,u("source element could not be found, hiding the progress bar widget"))})),this.eventHub.on("externalUpdate",(function(e){r.externalValue=Number.parseFloat(e),r.value=r.getValue(),r.eventHub.emit("valueUpdated")})),e()||this.eventHub.on("valueUpdated",(function(){r.isGoalReached(t.reachQuantity)})),"javascript"===t.variableType&&this.getValueFromScript(),"element"===t.variableType&&(this.sourceElementObserver=function(e,t){var r=document.querySelector(e);t(r);var n=new MutationObserver((function(n){n.forEach((function(n){if(!r&&n.addedNodes.length&&(r=z(n.addedNodes).find((function(t){return 1===t.nodeType&&(t.matches(e)||t.querySelector(e))})))&&t(r),r&&n.removedNodes.length){var s=z(n.removedNodes);(s.includes(r)||s.find((function(e){return e.contains(r)})))&&(r=null,t(!1))}}))}));return n.observe(document.body,{childList:!0,subtree:!0}),n}(t.variableElement,(function(e){r.eventHub.emit("sourceElementPresence",e)})))}},{key:"handleValueUpdate",value:function(e){var t=this;e.forEach((function(){t.eventHub.emit("valueElementUpdated")}))}},{key:"isGoalReached",value:function(e){this.value.numericValue>=e&&(this.parentContainer.recurrence.setValidationRecurrence(),u("target goal has been reached"))}},{key:"insertInParentContainer",value:function(){var e=this.parentContainer.domElement.querySelector(".".concat(this.parentContainer.contentClassName));document.head.appendChild(this.styleElement),e.appendChild(this.contentElement)}},{key:"refreshContent",value:function(){this.eventHub.emit("refreshContent")}},{key:"getValueFromElement",value:function(){var e=DATA.variableElement,t=document.querySelector(e),r=t?t.textContent:"0";return t===document.body?67:function(e){var t=e.match(Y);t||u("could not parse source value, using 0");var r=t?t[0]:"0";return r=r.replace(X,"$1$3").replace(ee,"$2").replace(Q,"").replace(Z,"$1$3.$5").replace(J,"$1.$3"),r=Number.parseFloat(r)}(r)}},{key:"getValueFromScript",value:function(){var e=DATA.variableJavascript,t=this.eventHub,r={update:function(e){return t.emit("externalUpdate",e),e}};new Function("(function externalUpdater(update){".concat(e,"})(this.update)")).call(r)}},{key:"getValue",value:function(){var e=this,t=DATA,r=t.variableType,n=t.variableDisplayingValue,s=t.reachQuantity,i=t.variableUnitType,o={element:function(){return e.getValueFromElement()},javascript:function(){return e.externalValue}}[r](),a={remaining:function(){return Math.max(0,s-o)},accumulated:function(){return o}}[n](),c={value:function(){return a},percent:function(){return Math.min(a,s)/s*100}}[i]();return{numericValue:o,calculatedValue:a,displayingValue:c}}},{key:"getContentElement",value:function(){var e=DATA,t=e.variableDisplayingValue,r=e.variableUnitType;this.textVariablesContent=DATA["textVariablesContent_".concat(r,"_").concat(t)];var n=document.createElement("div");return n.insertAdjacentHTML("beforeend",this.renderContent(DATA)),n}},{key:"addStyleRules",value:function(e){this.styleRules=this.styleRules.concat(e.map(function(e){return(e=e.replace(/;/g," !important;")).indexOf("{")>1?"#".concat(this.parentContainer.widgetContainerId," .").concat(this.className," ").concat(e):e}.bind(this)))}},{key:"getStyleElement",value:function(){var t=DATA,r=t.textColor,n=t.textAlign,s=document.createElement("style");s.type="text/css",e()&&s.setAttribute("abtasty-script-added","true");var i=void 0!==r?"color: ".concat(r,";"):"",o=void 0!==n?"text-align: ".concat(n,";"):"";return this.addStyleRules(["p {","margin: 0;","white-space: pre-line;",i,o,"}",i&&i.length?["span {",i,"}"].join(""):""]),s.textContent=this.styleRules.join(" "),s}}]),t}();!function(){u("Widget launch");var e=(()=>{const{layout:e}=DATA;let t;switch(e){case"popin":t=new w;break;case"bannerTop":case"bannerBottom":t=new S;break;case"free":t=new _;break;default:t=new f}return t})(),t=new te({parentContainer:e});e.init(!0).then((function(r){r.response&&(t.insertInParentContainer(),t.start(DATA),e.show())}))}()}();
1
+ !function(){"use strict";const e=()=>Object.prototype.hasOwnProperty.call(window,"ABTastyEditor");const t=()=>{let e;return window.ABTasty||window.ABTASTY_S?(window.ABTASTY_S&&window.ABTASTY_S.USER&&window.ABTASTY_S.USER.accountIdentifier&&window.ABTASTY_S.USER.accountIdentifier.length?e=window.ABTASTY_S.USER.accountIdentifier:window.ABTasty&&window.ABTasty.getAccountSettings&&"function"==typeof window.ABTasty.getAccountSettings?e=window.ABTasty.getAccountSettings().identifier:window.ABTasty&&window.ABTasty.accountSettings&&(e=window.ABTasty.accountSettings.identifier),e):e},r=()=>!!window.ABTasty.getTestsOnPage()[TEST_ID]||(()=>{const e=!!document.getElementById("ABTastyPreviewBar"),t=location.href.includes("ab_project=preview");return e||t})(),n=()=>{if(e())return!1;const t=ABTasty.getTestsOnPage()[TEST_ID];return!!t&&Object.keys(t.targetings.qaParameters).length>0},s="conditions",i="https://social-proof-api.abtasty.com/clients/",o=()=>{const{type:e}=DATA;return`${PACKAGE.replace("@abtasty/","")}${e?"_"+e:""}`},a=()=>{const e=o();return`${e.charAt(0).toUpperCase()}${e.slice(1)}`.split("-").join(" ")},c=()=>`${PLUGIN_ID.split("-")[0]}_${TEST_ID}`,l=(...e)=>{e.unshift(`[AB Tasty Widget] ${PACKAGE}:`),console.log(...e)},h=e=>{if(n()){const t=a();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)")}},u=e=>{const t={promise:null,resolve:null,reject:null,name:e};return t.promise=new Promise((e,r)=>{t.resolve=e,t.reject=r}),t},d=(e,t,r)=>{let n=0,s=0;try{document.querySelector(e)}catch(t){const n=`Selector «${e}» not valid.`;return l(n),"function"==typeof r&&r(n)}function i(){clearInterval(s),clearTimeout(n)}return n=setTimeout(()=>{i();const t=`Can't find element «${e}».`;return l(t),"function"==typeof r&&r(t)},1e4),s=setInterval(()=>{const r=document.querySelector(e);return null!==r?(i(),"function"==typeof t&&t(r)):r},200),{clear:i}};async function g(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,r)=>{const n=window.document.getElementsByTagName("script")[0],s=window.document.createElement("script");s.src=e,n.parentNode.insertBefore(s,n),s.onload=t,s.onerror=r})}(""));break;default:t=!0}return t}class m{constructor({displayRecurrence:e,closingRecurrence:t,validationRecurrence:r},n){this.displayRecurrence=parseFloat(e),this.closingRecurrence=parseFloat(t),this.validationRecurrence=parseFloat(r),this.onSetCallback=n,this.widgetName=o(),this.uniqueId=c(),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]:r,...n}=t;return Object.entries(n).length?(e.setItem("ABTastyWidgets",JSON.stringify(n)),n):(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 r=this.getTypeOfStorage(e);if(!r&&"object"!=typeof r)return!1;const{storageString:n,storageMethod:s}=r,i=this.getStamp(e),o={type:t,stamp:i},{type:a}=this.getCurrentRecurrence(),c=()=>{const e=this.getSessionRecurrence(),t=this.getLocalRecurrence();let r;"session"===n?e?r=this.removeSessionRecurrenceStorage():(this.removeLocalRecurrenceStorage(),r=this.getSessionRecurrenceStorageParsed()):"local"===n&&(t?r=this.removeLocalRecurrenceStorage():(this.removeSessionRecurrenceStorage(),r=this.getLocalRecurrenceStorageParsed()));const i=r?{[this.recurrenceKey]:o,...r}:{[this.recurrenceKey]:o};s.setItem("ABTastyWidgets",JSON.stringify(i)),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 i}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 p{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)),t=()=>e.observe(document.body,{attributes:!0,childList:!0,subtree:!0});return document.body?t():d("body",t),e}onMouseOver({target:e,path:t}){const r=this.inViewportTargets.find(({element:r,selector:n})=>{if(r.isSameNode(e))return!0;const s=[...e.querySelectorAll(n)];if(s.length&&s.includes(r))return!0;if(t.includes(r))return!0;const i=[...e.parentElement.children],o=i.findIndex(t=>t.isSameNode(e)),a=i.filter((e,t)=>t>o);if(a.length){if(a.includes(r))return!0;if(a.some(e=>[...e.querySelectorAll(n)].includes(r)))return!0}return!1});if(r&&this.isElementVisible(r.element)){const{selector:e,element:t,uniqueId:n}=r,s=this.targets.find(t=>t.selector===e&&t.uniqueId===n);s&&s.resolve(t),this.clear(e,n)}}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,r){return r(t)||!t.parentElement?t:e(t.parentElement,r)}(e,e=>"0"===window.getComputedStyle(e).opacity).nodeName}isElementTopmost(e){const t=e.getBoundingClientRect(),r=[[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 n=!1,s=0;for(;!n&&s<r.length;){const t=document.elementFromPoint(...r[s]);n=e===t||e.contains(t),s+=1}return n}checkElements(){this.targets.forEach(({selector:e,uniqueId:t})=>{const r=document.querySelector(e);r&&!this.existingTargets.find(e=>e.element===r&&e.uniqueId===t)&&(this.existingTargets.push({element:r,selector:e,uniqueId:t}),this.visibilityObserver.observe(r))}),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:r})=>{if(t.matches(e)&&this.isElementVisible(t)){const n=this.targets.find(t=>t.selector===e&&t.uniqueId===r);return n&&n.resolve(t),this.clear(e,r),!1}return!0})}watch(e,t,r){this.targets.push({selector:e,resolve:t,uniqueId:r}),this.startMutationObserver(),this.checkElements()}clear(e,t){[this.targets,this.existingTargets,this.inViewportTargets]=[this.targets,this.existingTargets,this.inViewportTargets].map(r=>r.filter(({selector:r,uniqueId:n})=>r!==e&&n!==t)),this.visibilityObserver.unobserve(document.querySelector(e)),0===this.targets.length&&this.mutationObserver.disconnect(),0===this.inViewportTargets.length&&this.mouseOverEvent.clear()}}class v{constructor({triggerEvent:e,triggerSelector:t,triggerDelay:r}){this.event=e,this.selector=t&&t.length?t:"body",this.delay=1e3*r,this.elementsSelectors=[],this.eventsListeners=[],this.timeouts=[],this.intervals=[],this.observers=[],this.promises=[],this.visibilityObservers=[],this.elementsWaiters=[]}async onElementVisible({promise:e,resolve:t}){const r=u(this.event+"DomReady");this.promises.push(r);const n=await this.onPageLoad(r),s=await g("IntersectionObserver"),i=function(e,t){return ABTasty.widgetUtils||(ABTasty.widgetUtils={}),ABTasty.widgetUtils[e]||Object.assign(ABTasty.widgetUtils,{[e]:new t}),ABTasty.widgetUtils[e]}("VisibilityObserver",p);if(this.visibilityObservers.push(i),s&&n){const e=c();i.watch(this.selector,t,e)}return e}onPageLoad({promise:e,resolve:t}){const r=()=>"complete"===document.readyState;if(!r()){const e=["readystatechange",()=>r()&&t(!0),{passive:!0}];this.eventsListeners.push(e),document.addEventListener(...e)}return t(!0),e}onClick({promise:e,resolve:t}){const r=document.createElement("style");r.type="text/css",r.id="Click_"+c(),r.innerHTML=this.selector+" {\n\t\t\tcursor: pointer !important;\n\t\t\tpointer-events: all !important;\n\t\t}",document.head.appendChild(r),this.elementsSelectors.push("#"+r.id);const n=e=>[...document.querySelectorAll(this.selector)].some(t=>t.isSameNode(e)||!!e.closest(this.selector)),s=["click",({target:e})=>n(e)&&t(!0),{passive:!0,capture:!0}];return this.eventsListeners.push(s),document.addEventListener(...s),e}onExitIntent({promise:e,resolve:t}){const r=["mouseleave",async({clientY:e})=>{e<=0&&t(!0)},{passive:!0}],n=d("body",e=>{e.addEventListener(...r),this.eventsListeners.push([e,...r]),this.elementsWaiters=this.elementsWaiters.filter(e=>e!==n)});return this.elementsWaiters.push(n),e}onReengage({promise:e,resolve:t}){const r=this.delay;let n=r;const s=[()=>(n=r,n),{passive:!0}];["click","mousemove","scroll","keypress"].forEach(e=>{document.addEventListener(e,...s),this.eventsListeners.push([e,...s])});const i=setInterval(()=>{n<=0?t(!0):n-=100},100);return this.intervals.push(i),e}onCustomTrigger({promise:e,resolve:t}){const{triggerEventCustomScript:r}=DATA;return new Function(`return new Promise(async resolve => {${r}})`)().then(e=>e&&t(!0)),e}getSocialProofPurchases({promise:e,resolve:r}){const n=window.ABTastyProductKey,s=t(),{viewInterval:o,triggerSocialProofMinPurchases:a,spNoTrim:c}=DATA;return n||(h("Not able to find ABTastyProductKey, impossible to call the API."),r(!1)),n&&s?fetch(`${i}${s}/metrics/i?key=${n}${c?"&noTrim=true":""}`).then(e=>e.ok&&e.json()).then(e=>(e=>{if(void 0===o||void 0===a)return!1;const t=e[o]&&e[o]>=a;return t||h(`Widget will not be shown, product has been purchased ${e[o]} times while ${a} are required`),t})(e)&&r(e[o])).catch(()=>h("Failed to fetch datas from server.")):r(!1),e}getSocialProofPageViews({promise:e,resolve:r}){const n=encodeURIComponent(""+window.location.pathname),s=t(),{viewInterval:o,triggerSocialProofMinPageViews:a}=DATA;return n&&s?fetch(`${i}${s}/metrics/pv?key=${n}`).then(e=>e.ok&&e.json()).then(e=>(e=>{if(void 0===o||void 0===a)return!1;const t=e[o]&&e[o]>=a;return t||h(`Widget will not be shown, page has been seen ${e[o]} times while ${a} are required`),t})(e)&&r(e[o])).catch(()=>h("Failed to fetch datas from server.")):r(!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,...r]="string"==typeof e[0]?[document,...e]:e;t&&r.length>1&&t.removeEventListener(...r)}),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=c();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=u(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)},r=!Object.prototype.hasOwnProperty.call(t,this.event)||await t[this.event]();return this.clear(),"reengage"!==this.event&&this.delay?r&&await(async()=>{const e=u(this.event+"Delay");return this.promises.push(e),setTimeout(()=>{e.resolve(!0),this.clear()},this.delay),e.promise})():r}}class b{constructor(e,t,r){this.recurrence=e,this.isWidgetApplied=t,this.callback=r,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},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=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),r=e.some(({addedNodes:e})=>e&&e.length);return t||r?(this.decisionHandler(!0),this):this}watch(){if(e())return this;this.clearWatcher(),document.addEventListener(...this.eventListenerParams);const t=d("body",e=>{const r=[e,{childList:!0,subtree:!0}];this.observer.observe(...r),this.elementsWaiters=this.elementsWaiters.filter(e=>e!==t)});return this.elementsWaiters.push(t),this}clearWatcher(){return document.removeEventListener(...this.eventListenerParams),this.elementsWaiters.length&&(this.elementsWaiters.forEach(e=>e.clear()),this.elementsWaiters=[]),this.observer.disconnect(),this}}class y{constructor(){this.children=void 0,this.uniqueId=c(),this.widgetName=o(),this.prettyName=a(),this.recurrenceParams=(()=>{const{displayRecurrence:t,closingRecurrence:r,validationRecurrence:n}=DATA;if(e()||!t&&!r&&!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"]},i={};return t&&(i.displayRecurrence=s[t]("displayRecurrence")),r&&(i.closingRecurrence=s[r]("closingRecurrence")),n&&(i.validationRecurrence=s[n]("validationRecurrence")),i})(),this.triggerParams=(()=>{let{triggerEvent:t}=DATA;const{triggerEventClick:r,triggerEventReengageDelay:n,socialProofContentType:s,triggerEventElementVisible:i,triggerEventDelay:o}=DATA;if(e()||!t&&!s)return!1;const a={click:()=>r,elementVisible:()=>i},c=Object.prototype.hasOwnProperty.call(a,t)?a[t]():"body",l="reengage"===t?n:o;return s&&(t=1===s?"socialProofPurchases":"socialProofPageViews"),{triggerEvent:t,triggerSelector:c,triggerDelay:l}})(),this.recurrence=!!this.recurrenceParams&&new m(this.recurrenceParams,this.clearGivenClearables.bind(this)),this.trigger=!!this.triggerParams&&new v(this.triggerParams),this.pageWatcher=new b(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,r)=>{this.elementsWaiters=this.elementsWaiters.filter(e=>e!==t),h(e),r(e)},t=new Promise((t,r)=>{const n=d("head",e=>{this.elementsWaiters=this.elementsWaiters.filter(e=>e!==n),t(e.appendChild(this.styleElement))},t=>e(t,n,r));this.elementsWaiters.push(n)}),r=new Promise((t,r)=>{const{layout:n,elementReferrer:s,referrerInsertType:i}=DATA,{selector:o,position:a}="string"==typeof n&&"free"===n&&"string"==typeof s&&"string"==typeof i?{selector:s,position:i}:{selector:"body",position:"beforeend"},c=d(o,e=>{this.elementsWaiters=this.elementsWaiters.filter(e=>e!==c),this.removeOldDomElement(),t(e.insertAdjacentElement(a,this.domElement))},t=>e(t,c,r));this.elementsWaiters.push(c)});return Promise.all([r,t]).then(()=>this)}remove(){return this.pageWatcher.clearWatcher(),this.domElement&&this.domElement.closest("html")&&this.domElement.remove(),this.styleElement&&this.styleElement.closest("html")&&this.styleElement.remove(),this.hasOncePerPageTrigger?this.pageWatcher.watch():e()||this.init().then(({response:e})=>e?this.show():this),this}show(){return this.hasBeenShown||e()||window.ABTastyEvent(this.prettyName+" displayed",null,TEST_ID),this.closedByUser=!1,this.domElement.classList.remove(this.hideClassName),this.recurrence&&this.recurrence.setDisplayRecurrence(),this.hasBeenShown=!0,this.pageWatcher.watch(),this}hide(){return this.hasBeenShown&&!e()&&window.ABTastyEvent(this.prettyName+" closed",null,TEST_ID),this.closedByUser=!0,this.domElement.classList.add(this.hideClassName),this}async init(t){if(!e()&&!r())return!1;if(this.trigger&&this.trigger.promises.length)return!1;const n=this.recurrence&&this.recurrence.isOver();if(this.recurrence&&!n)return this.pageWatcher.watch(),!1;this.pageWatcher.watch();const s=e()||!this.trigger||this.trigger&&await this.trigger.isTriggered();return!!s&&(await this.insert(),this.addCloseEvent(),e()||t||this.hasBeenShown||void 0===this.children||"function"!=typeof this.children.refreshContent||this.children.refreshContent(s),{container:this,response:s})}onPageChange(e,t){const r=()=>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()):r()}}addCloseEvent(...e){const{closeButton:t,overlayClickable:r,layout:n}=DATA,s=[];if(void 0!==r&&r&&void 0!==n&&"popin"===n&&s.push("."+this.overlayClassName),void 0!==t&&t&&s.push("."+this.closeButtonClassName),!s.length)return this;const i=this.domElement.querySelectorAll(s.join(", "));return i.length?(e.push(...i),e.forEach(e=>{e.addEventListener("click",()=>{this.recurrence&&this.recurrence.setClosingRecurrence(),this.hide(),setTimeout(()=>this.remove(),1e3)},{passive:!0,once:!0})}),this):this}getDom(){const{closeButton:t,layout:r}=DATA,n=document.createElement("div");return n.className=`${this.basicClassName} ${this.hideClassName}`,n.id=this.widgetContainerId,n.innerHTML=`\n\t\t\t${void 0!==r&&"popin"===r?`<div class="${this.overlayClassName}"></div>`:""}\n\t\t\t<div class="${this.contentClassName}">\n\t\t\t\t${t?`<button class="${this.closeButtonClassName}" ${e()?"data-abtasty-actionnable":""}><svg viewBox="0 0 16 16">\n\t<defs><path id="prefix__a" d="M12 4.991L11.009 4 8 7.009 4.991 4 4 4.991 7.009 8 4 11.009 4.991 12 8 8.991 11.009 12 12 11.009 8.991 8z"></path></defs>\n\t<g><use xlink:href="#prefix__a"></use></g>\n</svg></button>`:""}\n\t\t\t</div>`,n}getStyleTag(t=""){const{noStyles:r,layout:n}=DATA,{backgroundColor:s,backgroundImage:i,borderColor:o,borderRadius:a,borderWidth:c,textColor:l,textAlign:h,overlayColor:u,dropShadow:d,dropShadowColor:g,dropShadowBlur:m,containerMargin:p,containerPadding:v,closeButton:b,buttonsBorderWidth:y,buttonsBorderColor:f,buttonsBorderRadius:w,buttonsBackgroundColor:_,buttonsTextColor:S}=r?{}:DATA,C=document.createElement("style");C.type="text/css",e()&&C.setAttribute("abtasty-script-added","true");const T=`background-color: ${void 0!==s?s:"rgba(255, 255, 255, 1)"};`,E=void 0!==i?`background-image: url(${i});`:"",A=void 0!==a?`border-radius: ${a}px;`:"",$=void 0!==c&&c?`border-width: ${c}px; border-style: solid;`:"",x=[o,c].every(e=>void 0!==e)&&c?`border-color: ${o};`:"",N=void 0!==l?`color: ${l}; fill: ${l};`:"",B=void 0!==h?`text-align: ${h};`:"",R=void 0!==d&&d?`box-shadow: 0 5px ${m}px 0 ${g};`:"",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);`:"",k=v instanceof Array&&1===v.length&&v[0],V=k?`padding: ${k.top}px ${k.right}px ${k.bottom}px ${k.left}px;`:"",L=k?`padding: calc(${k.top}px * 0.5) calc(${k.right}px * 0.5) calc(${k.bottom}px * 0.5) calc(${k.left}px * 0.5);`:"",W=void 0!==y&&y?`border-width: ${y}px; border-style: solid;`:"",D=[f,y].every(e=>void 0!==e)&&y?`border-color: ${f};`:"",j=void 0!==w?`border-radius: ${w}px;`:"",q=void 0!==_?`background-color: ${_};`:"",H=void 0!==S?`color: ${S};`:"",U=void 0!==n&&"popin"===n?[`#${this.widgetContainerId} .${this.overlayClassName} {`,`background-color: ${void 0!==u?u:"rgba(0, 0, 0, 0.6)"};`,"}"].join(""):"",M=r||void 0!==b&&b?[`#${this.widgetContainerId} .${this.contentClassName} .${this.closeButtonClassName} {`,"position: absolute;","top: 8px;","right: 8px;","width: auto;","height: auto;","background: none;","border: none;","cursor: pointer;","outline: none;","padding: 0;","margin: 0;","}",`#${this.widgetContainerId} .${this.contentClassName} .${this.closeButtonClassName} svg {`,"pointer-events: none;","width: 16px;","height: 16px;",N,"}"].join(""):"";return C.textContent=[`.${this.hideClassName} {`,"opacity: 0 !important;","pointer-events: none;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,T,E,A,$,x,N,B,R,P,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,"display: block;","line-height: 1;",V,"}",`#${this.widgetContainerId} .${this.contentClassName} > * a, `,`#${this.widgetContainerId} .${this.contentClassName} > * button {`,W,D,j,q,H,"}","@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,O,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,L,"}","}",U,M,""+t].join(""),C}}class f extends y{constructor(){super(),this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){return[`#${this.widgetContainerId} {`,"position: fixed;","top: 0;","left: 0;","width: 100%;","height: 100%;","z-index: 9999;","opacity: 1;","transition: opacity 0.25s ease;","}",`#${this.widgetContainerId} .${this.overlayClassName} {`,"position: absolute;","z-index: -1;","top: 0;","left: 0;","width: 100%;","height: 100%;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: absolute;","left: 50%;","top: 50%;","transform: translate(-50%, -50%);","width: auto;","height: auto;","}","@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,"max-width: 94vw;","}","}"].join("")}}class w extends y{constructor(){super(),this.position="string"==typeof DATA.layout&&"bannerTop"===DATA.layout?"top":"bottom",this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){return[`#${this.widgetContainerId} {`,"position: fixed;",this.position+": 0;","left: 0;","width: 100%;","height: auto;","z-index: 9999;","opacity: 1;","transition: opacity 0.25s ease;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: relative;","}"].join("")}}class _ extends y{constructor(){super(),this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){return[`#${this.widgetContainerId} {`,"width: auto;","height: auto;","margin: 0;","padding: 0;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: relative;","}"].join("")}}const S={category:s,type:"slider",min:1},C=[{...S,propName:"day",label:"widget_common_conditions_recurrence_ifOptionVariable_labelDays",value:5,max:395},{...S,propName:"week",label:"widget_common_conditions_recurrence_ifOptionVariable_labelWeeks",value:2,max:56},{...S,propName:"month",label:"widget_common_conditions_recurrence_ifOptionVariable_labelMonths",value:1,max:13}],T={category:s,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"},E={...T,label:"widget_common_conditions_recurrence_label_widgetDisplayed",propName:"displayRecurrence"},A=(C.map(e=>({...e,propName:`${E.propName}_${e.propName}`,conditions:[{field:E.propName,value:e.propName}]})),{...T,label:"widget_common_conditions_recurrence_label_widgetDisplayedAfterClosure",propName:"closingRecurrence"}),$=(C.map(e=>({...e,propName:`${A.propName}_${e.propName}`,conditions:[{field:A.propName,value:e.propName}]})),{...T,label:"widget_common_conditions_recurrence_label_widgetDisplayedAfterSubmission",propName:"validationRecurrence"}),x=(C.map(e=>({...e,propName:`${$.propName}_${e.propName}`,conditions:[{field:$.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(x).map(e=>x[e]);var N=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")};function B(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var R=function(e,t,r){return t&&B(e.prototype,t),r&&B(e,r),e};var I=function(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))};function P(){var e=I(['\n\t\t<div class="','">\n\t\t\t',"\n\t\t\t","\n\t\t</div>\n\t"]);return P=function(){return e},e}function O(){var e=I(['\n\t\t\t\t<dl class="abtasty_progress_definition">\n\t\t\t\t\t<dt class="abtasty_progress_label">','</dt>\n\t\t\t\t\t<dd class="abtasty_progress_value">',"</dd>\n\t\t\t\t</dl>\n\t\t\t"]);return O=function(){return e},e}function k(){var e=I(['\n\t\t\t\t<p class="abtasty_progress_definition">',"</p>\n\t\t\t"]);return k=function(){return e},e}function V(){var e=I(['\n\t\t<div class="abtasty_progress_pbar">\n\t\t\t<div\n\t\t\t\tclass="abtasty_progress_indicator"\n\t\t\t\tstyle="transform: ',' !important;"\n\t\t\t></div>\n\t\t</div>\n\t']);return V=function(){return e},e}function L(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];return e.reduce((function(e,t,n){return e+r[n-1]+t}))}function W(e){return Math.floor(100*e)/100}function D(e){var t=this,r=e.reachQuantity,n=e.colorBlindMode,s=e.progressBarStripesColor,i=e.progressBarBackgroundColor,o=e.progressBarColor,a=e.progressBarBorderRadius,c=e.progressBarHeight;function l(e){return"translateX(".concat(Math.min(e,r)/r*100-100,"%)")}this.addStyleRules([".abtasty_progress_pbar {\n background-color: ".concat(i,";\n border-radius: ").concat(a,"px;\n overflow: hidden;\n }"),".abtasty_progress_indicator {\n height: ".concat(c,"px;\n background-color: ").concat(o,";\n transition: transform 0.5s ease-out;\n transform: translateX(-100%);\n border-top-right-radius: ").concat(a,"px;\n border-bottom-right-radius: ").concat(a,"px;\n }"),n?"\n .abtasty_progress_indicator {\n background-image: repeating-linear-gradient(-45deg,\n transparent,\n transparent 7px,\n ".concat(s," 6px,\n ").concat(s," 14px);\n }"):""]);var h=this.parentContainer.domElement.getElementsByClassName("abtasty_progress_indicator");return this.eventHub.on("valueUpdated",(function(){Array.from(h).forEach((function(e){e.style.setProperty("transform",l(t.value.numericValue),"important")}))})),L(V(),l(this.value.numericValue))}function j(e){var t=this,r=e.reachQuantity,n=e.textLabelContent,s=e.subLayout,i=e.textColor,o=e.textAlign;this.addStyleRules([".abtasty_progress_definition {\n font-size: 12px;\n color: ".concat(i,";\n margin: 7px 0 0 0;\n text-align: ").concat(o,";\n word-break: break-word;\n }"),".abtasty_progress_label {\n margin: 0;\n font-family: inherit;\n color: inherit;\n font-size: inherit;\n word-break: break-word;\n }",".abtasty_progress_value {\n margin: 0;\n font-family: inherit;\n color: inherit;\n font-size: inherit;\n word-break: initial;\n }"]);var a=this.parentContainer.domElement.getElementsByClassName("abtasty_progress_value");return this.eventHub.on("valueUpdated",(function(e){Array.from(a).forEach((function(e){e.textContent=W(t.value.displayingValue)}))})),{customTextVariables:function(){var e=t.textVariablesContent.replace("!variable!",'<span class="abtasty_progress_value">'.concat(W(t.value.displayingValue),"</span>")).replace("!quantityToReach!",'<span class="abtasty_progress_max">'.concat(r,"</span>"));return L(k(),e)},customLabelVariables:function(){return t.addStyleRules([".abtasty_progress_definition {\n display: flex;\n justify-content: space-between;\n }",".abtasty_progress_label {\n flex-basis: 66%;\n text-align: left;\n }"]),L(O(),n,t.value.displayingValue)},progressBarOnly:function(){return""}}[s]()}function q(e){var t=e.reachQuantity,r=e.subLayout,n=e.textLabelContent,s=e.progressBarStripesColor,i=e.progressBarBackgroundColor,o=e.progressBarColor,a=e.colorBlindMode,c=e.progressBarBorderRadius,l=e.progressBarHeight,h=e.textColor,u=e.textAlign;return L(P(),this.className,D.call(this,{reachQuantity:t,progressBarStripesColor:s,progressBarBackgroundColor:i,progressBarColor:o,colorBlindMode:a,progressBarBorderRadius:c,progressBarHeight:l}),j.call(this,{subLayout:r,textLabelContent:n,reachQuantity:t,textColor:h,textAlign:u}))}var H=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n};var U=function(e){if(Array.isArray(e))return H(e)};var M=function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)};var F=function(e,t){if(e){if("string"==typeof e)return H(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?H(e,t):void 0}};var G=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 K=function(e){return U(e)||M(e)||F(e)||G()},z=/\s/g,Q=/\d(\d|\.|\s|,)*/,Y=/(\d)(,)(\d{3,})/gi,X=/(\d)(,)(\d{1,2})$/gm,J=/(\d+)(\.)(\d+)(,)(\d+)$/gm,Z=/(,)(\d{3,})/g;var ee=function(){function t(e){var r=e.parentContainer;N(this,t),this.eventHub={hub:Object.create(null),emit:function(e,t){(this.hub[e]||[]).forEach((function(e){return e(t)}))},on:function(e,t){this.hub[e]||(this.hub[e]=[]),this.hub[e].push(t)},off:function(e,t){var r=(this.hub[e]||[]).findIndex((function(e){return e===t}));r>-1&&this.hub[e].splice(r,1),0===this.hub[e].length&&delete this.hub[e]}},this.renderContent=q,this.parentContainer=r,this.baseClassName="progressbar_container",this.className="".concat(this.baseClassName,"_").concat(r.uniqueId),this.styleRules=[],this.externalValue=0,this.value=this.getValue(),this.contentElement=this.getContentElement(),this.styleElement=this.getStyleElement(),this.sourceValueObserver=new MutationObserver(this.handleValueUpdate.bind(this)),this.parentContainer.children=this}return R(t,[{key:"start",value:function(t){var r=this;this.eventHub.on("refreshContent",(function(){"element"===t.variableType&&r.eventHub.emit("valueElementUpdated")})),this.eventHub.on("valueElementUpdated",(function(){r.value=r.getValue(),r.eventHub.emit("valueUpdated")})),this.eventHub.on("sourceElementPresence",(function(e){e?(r.value=r.getValue(),r.eventHub.emit("valueElementUpdated"),r.parentContainer.domElement.hidden=!1,r.sourceValueObserver.observe(e,{childList:!0,subtree:!0,attributes:!1,characterData:!0})):(r.sourceValueObserver.disconnect(),r.parentContainer.domElement.hidden=!0,h("source element could not be found, hiding the progress bar widget"))})),this.eventHub.on("externalUpdate",(function(e){r.externalValue=Number.parseFloat(e),r.value=r.getValue(),r.eventHub.emit("valueUpdated")})),e()||this.eventHub.on("valueUpdated",(function(){r.isGoalReached(t.reachQuantity)})),"javascript"===t.variableType&&this.getValueFromScript(),"element"===t.variableType&&(this.sourceElementObserver=function(e,t){var r=document.querySelector(e);t(r);var n=new MutationObserver((function(n){n.forEach((function(n){if(!r&&n.addedNodes.length&&(r=K(n.addedNodes).find((function(t){return 1===t.nodeType&&(t.matches(e)||t.querySelector(e))})))&&t(r),r&&n.removedNodes.length){var s=K(n.removedNodes);(s.includes(r)||s.find((function(e){return e.contains(r)})))&&(r=null,t(!1))}}))}));return n.observe(document.body,{childList:!0,subtree:!0}),n}(t.variableElement,(function(e){r.eventHub.emit("sourceElementPresence",e)})))}},{key:"handleValueUpdate",value:function(e){var t=this;e.forEach((function(){t.eventHub.emit("valueElementUpdated")}))}},{key:"isGoalReached",value:function(e){this.value.numericValue>=e&&(this.parentContainer.recurrence.setValidationRecurrence(),h("target goal has been reached"))}},{key:"insertInParentContainer",value:function(){var e=this.parentContainer.domElement.querySelector(".".concat(this.parentContainer.contentClassName));document.head.appendChild(this.styleElement),e.appendChild(this.contentElement)}},{key:"refreshContent",value:function(){this.eventHub.emit("refreshContent")}},{key:"getValueFromElement",value:function(){var e=DATA.variableElement,t=document.querySelector(e),r=t?t.textContent:"0";return t===document.body?67:function(e){var t=e.match(Q);t||h("could not parse source value, using 0");var r=t?t[0]:"0";return r=r.replace(Y,"$1$3").replace(Z,"$2").replace(z,"").replace(J,"$1$3.$5").replace(X,"$1.$3"),r=Number.parseFloat(r)}(r)}},{key:"getValueFromScript",value:function(){var e=DATA.variableJavascript,t=this.eventHub,r={update:function(e){return t.emit("externalUpdate",e),e}};new Function("(function externalUpdater(update){".concat(e,"})(this.update)")).call(r)}},{key:"getValue",value:function(){var e=this,t=DATA,r=t.variableType,n=t.variableDisplayingValue,s=t.reachQuantity,i=t.variableUnitType,o={element:function(){return e.getValueFromElement()},javascript:function(){return e.externalValue}}[r](),a={remaining:function(){return Math.max(0,s-o)},accumulated:function(){return o}}[n](),c={value:function(){return a},percent:function(){return Math.min(a,s)/s*100}}[i]();return{numericValue:o,calculatedValue:a,displayingValue:c}}},{key:"getContentElement",value:function(){var e=DATA,t=e.variableDisplayingValue,r=e.variableUnitType;this.textVariablesContent=DATA["textVariablesContent_".concat(r,"_").concat(t)];var n=document.createElement("div");return n.insertAdjacentHTML("beforeend",this.renderContent(DATA)),n}},{key:"addStyleRules",value:function(e){this.styleRules=this.styleRules.concat(e.map(function(e){return(e=e.replace(/;/g," !important;")).indexOf("{")>1?"#".concat(this.parentContainer.widgetContainerId," .").concat(this.className," ").concat(e):e}.bind(this)))}},{key:"getStyleElement",value:function(){var t=DATA,r=t.textColor,n=t.textAlign,s=document.createElement("style");s.type="text/css",e()&&s.setAttribute("abtasty-script-added","true");var i=void 0!==r?"color: ".concat(r,";"):"",o=void 0!==n?"text-align: ".concat(n,";"):"";return this.addStyleRules(["p {","margin: 0;","white-space: pre-line;",i,o,"}",i&&i.length?["span {",i,"}"].join(""):""]),s.textContent=this.styleRules.join(" "),s}}]),t}();!function(){h("Widget launch");var e=(()=>{const{layout:e}=DATA;let t;switch(e){case"popin":t=new f;break;case"bannerTop":case"bannerBottom":t=new w;break;case"free":t=new _;break;default:t=new y}return t})(),t=new ee({parentContainer:e});e.init(!0).then((function(r){r.response&&(t.insertInParentContainer(),t.start(DATA),e.show())}))}()}();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@abtasty/progress-bar",
3
3
  "description": "Allow you to add a progress bar on you website",
4
- "version": "1.0.1-1",
4
+ "version": "1.0.1",
5
5
  "form": "dist/form.js",
6
6
  "main": "dist/main.js",
7
7
  "files": [
@@ -15,8 +15,7 @@
15
15
  "buildtestdeps": "rollup -c rolluptests.config.js",
16
16
  "watch": "rollup -c --watch",
17
17
  "build": "rollup -c",
18
- "serve": "widget serve",
19
- "prepare": "npm run build"
18
+ "serve": "widget serve"
20
19
  },
21
20
  "devDependencies": {
22
21
  "@babel/core": "^7.9.6",
@@ -35,11 +34,11 @@
35
34
  "rollup-plugin-eslint": "^7.0.0"
36
35
  },
37
36
  "dependencies": {
38
- "@abtasty/widget-utils": "^1.16.11",
37
+ "@abtasty/widget-utils": "1.16.6",
39
38
  "@babel/plugin-proposal-object-rest-spread": "^7.9.6",
40
39
  "@rollup/plugin-commonjs": "^11.0.1",
41
40
  "@rollup/plugin-node-resolve": "^7.0.0",
42
41
  "babel-eslint": "^10.0.3",
43
42
  "rollup-plugin-terser": "^5.2.0"
44
43
  }
45
- }
44
+ }
package/README.md DELETED
@@ -1,75 +0,0 @@
1
- # AB-tasty progress-bar
2
-
3
- The ABTasty Progress Bar Widget will display a progress bar.
4
-
5
- ## Code organisation
6
-
7
- ![Progress Bar Architecture](./progress_bar_architecture.png)
8
-
9
- ### Inserting the widget on the page
10
-
11
- This is completely handled by the Widget-Utils. It takes care of deciding when and how to insert the widget on the page. It also handles recurrence management. Finally, it also handles the widget's form generation by importing the necessary components to be displayed in the editor.
12
-
13
- ### Widget internal updates
14
-
15
- The widget has to react to changes coming either form updates to a specified DOM element (`DATA.variableElement`) or from a javascript callback from the client (`DATA.variableType` is `javascript`).
16
-
17
- The widget internally uses an observer pattern, via an Event Hub. The observable events are:
18
-
19
- - `valueElementUpdated`: the source DOM value has changed
20
- - `externalUpdate`: the source value was updated from javascript callback (client code)
21
- - `sourceElementPresence`: the source DOM element was either removed or added to the DOM
22
- - `valueUpdated`: the value to display was updated either from the DOM or a javascript callback.
23
- - `refreshContent`: triggered by the widget-utils, when the widget is removed and has to display again
24
-
25
- ## Tests
26
-
27
- The test setup and spec files are located in `test` directory. To actually run the tests you need to clone and install the [Widgets Testrunner](https://gitlab.com/abtasty/widget/widgets-testrunner) repo in your Widgets directory. Please check the testrunner documentation for an up to date guide on running the Widget tests.
28
-
29
- This widget was generated using AB Tasty Widget CLI. You can find more infomation and documentation about widgets at https://abtasty.gitbooks.io/widget/.
30
-
31
- ## Preview your widget
32
-
33
- Launch your widget in a new window and watch for changes.
34
- ```bash
35
- npm start
36
- ```
37
-
38
- ## Main files
39
-
40
- * `main.js`
41
- Main source code of your widget
42
- * `form.js`
43
- Configuration form for your widget
44
-
45
- You can specify each file location in the `package.json` like this:
46
- ```json
47
- "main": "dist/main.js",
48
- "form": "dist/form.js",
49
- ```
50
-
51
- ## Included
52
-
53
- * [Rollup.js](https://rollupjs.org/) module bundler (like Webpack but smaller and faster).
54
- * ES6 support using [Babel](https://babeljs.io/).
55
- * JavaScript Linting with [ESLint](http://eslint.org/) and [Airbnb style](https://github.com/airbnb/javascript).
56
- * JavaScript minified with [UglifyJS](https://github.com/mishoo/UglifyJS2).
57
- * [Prettier](https://prettier.io/) to format code.
58
-
59
-
60
-
61
- **We heard your widget have an UI, so we allowed ourselves to include some extra:**
62
- * [Pug](https://github.com/aMarCruz/rollup-plugin-pug) (aka Jade) to transforms html files into JS template.
63
- * [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:
64
- * [CSSnext](http://cssnext.io/) to use the latest CSS syntax today.
65
- * [cssnano](http://cssnano.co/) to minify CSS.
66
-
67
-
68
-
69
- ## Add your widget to AB Tasty
70
-
71
- 1. First, you'll need to have your widget on NPM:
72
- * Create a minified bundle with `npm run build`
73
- * Bump the version of your widget ([using semver](http://semver.org/)) with `npm version [patch|minor|major]`
74
- * Publish it to NPM: `npm publish`
75
- 2. Once your widget is on NPM, you can now add it on AB Tasty at https://marketplace.abtasty.com/publish.