(()=>{/*!
 * Copyright 2024-2025 Simply.IN Sp. z o.o.
 *
 * NOTICE OF LICENSE
 * Licensed under the EUPL-1.2 or later.
 * You may not use this work except in compliance with the Licence.
 * Copy of the Licence is available at: https://joinup.ec.europa.eu/software/page/eupl
 * It is bundled with this package in the file LICENSE.txt
 *
 * @author    Simply.IN Sp. z o.o.
 * @copyright 2024-2025 Simply.IN Sp. z o.o.
 * @license   https://joinup.ec.europa.eu/software/page/eupl
 */$(function(){window.SimplyIn={ajax:"",phones:!1,email_field:!1,email_login_field:!1,customer_email:null,is_login:!1,last_code:!1,is_login_page:!1,on_close_refresh_page:!1,counting_interval:!1,counting_message_interval:!1,push_notification_interval:!1,autocomplete_interval:!1,validate_code_timeout:!1,validate_code_sended:!1,last_popup:"",delivery_popup:"",delivery_popup_scroll:0,popup:null,counting_value:0,counting_value_message:0,select_customer_privacy:!1,select_psgdpr:!1,submit_guest_form:!1,login_request_send:!1,last_email:"",send_sms_code_run:!1,send_email_code_run:!1,hideIconCheckout:!1,showIconCheckout:!1,new_account_listeners_inited:!1,force_login:!1,submit_email_in_progress:!1,init:async function(e={}){this.ajax=simplyin.controllers.ajax,this.is_login=simplyin.customer_email!="",this.select_customer_privacy=simplyin.select_customer_privacy,this.select_psgdpr=simplyin.select_psgdpr,this.submit_guest_form=simplyin.submit_guest_form,simplyin.display&&simplyin.display.bar_color===!1&&$("body").addClass("simplyin-bar-mono"),simplyin.display&&simplyin.display.badge_color===!1&&$("body").addClass("simplyin-badge-mono"),simplyin.display&&simplyin.display.accent_color&&document.documentElement.style.setProperty("--simplyin-accent-color",simplyin.display.accent_color),simplyin.display&&simplyin.display.font_color&&document.documentElement.style.setProperty("--simplyin-font-color",simplyin.display.font_color),!simplyin.order_sended&&(typeof simplyin.order<"u"?this.placeOrder():await this.preloadImages().then(()=>{this.initCheckout(),this.initEventListeners(),this.initEventListenersPin(),this.initEventListenersDelivery(),this.initEventListenersEditAddress(),this.initEventListenersAddParcelLocker(),this.initEventListenersNewAccount(),this.initDhlAssistantDisplay(),this.dpdshippingmodule(),this.furgonetkamodule(),this.authController(),this.initAddressForm()}),this.customer_email=simplyin.customer_email)},initCheckout:function(){this.initOpcStandard(),simplyin.customer.need_login&&simplyin.controller=="order"&&$("#checkout-personal-information-step.-current").length>0&&(simplyin.customer.need_login=!1,this.force_login=!0,this.submitEmail(!1))},preloadImages(){let e=simplyin.files_url+"/views/img/",i=["logo_smalln.svg","logo_medium.svg","edit_icon.svg","trash_icon.svg","close_icon.svg","point.svg","expand_icon.svg","dots_icon.svg","add_icon.svg"];return Promise.all(i.map(t=>new Promise(s=>{let n=new Image;n.onload=s,n.onerror=s,n.src=e+t})))},initAddressForm:function(){let e=this;simplyin.customer.logged&&simplyin.customer.logged==!0&&simplyin.customer.has_selected_address==!1&&simplyin.customer.has_token&&window.location.search.indexOf("action")==-1&&e.showPopupByType("delivery",{email:simplyin.customer_email}),simplyin.customer.point.label=="dpd"&&e.waitForElement(".dpdshipping-pudo-new-point",function(){let i={modal:function(s){}};dpdshippingSavePudoCode(simplyin.customer.point.locker_id,i);let t=$("span.dpdshipping-selected-point");dpdshippingGetPudoAddress(simplyin.customer.point.locker_id,t)},2e4)},waitForElement:function(e,i,t){if($(e).length){i();return}var s=new MutationObserver(function(){$(e).length&&(s.disconnect(),i())});s.observe(document.body,{childList:!0,subtree:!0}),t&&setTimeout(function(){s.disconnect()},t)},barEnabled:function(){return simplyin.display?!!simplyin.display.bar:!0},badgeEnabled:function(){return!0},barHtml:function(){return`
                <div class="simplyin-logo-container">
                  <div class="simplyin-logo-inner">
                    <div class="simplyin-logo-svg-wrap">
                      <span class="simplyin-logo-line"></span>
                      <span class="simplyin-logo-caption">${simplyin.labels.bar_caption}</span>
                      <img class="simplyin-logo-brand" src="${simplyin.files_url}/views/img/logo_medium.svg" alt="simply.in"/>
                      <span class="simplyin-logo-line"></span>
                    </div>
                  </div>
                </div>
            `},fieldBadgeHtml:function(){return`
                <div class="simplyin-field-badge">
                  <img class="simplyin-field-badge-logo" src="${simplyin.files_url}/views/img/logo_medium.svg" alt="simply.in"/>
                </div>
            `},injectFieldBadge:function(e){var i=$(e);!i.length||$(".simplyin-field-badge").length||(i.parent().hasClass("simplyin-field-wrap")||i.wrap('<div class="simplyin-field-wrap"></div>'),i.after(this.fieldBadgeHtml()),$(".simplyin-show-popup").is(":visible")&&$(".simplyin-field-badge").hide())},initOpcStandard:function(){if(this.email_field='#customer-form input[name="email"]',$(this.email_field).length){var e=$(this.email_field),i=e.closest(".form-group"),t=$("#customer-form");i.length&&t.length&&(t.prepend(i),this.customer_email=simplyin.customer_email,simplyin.customer_email!=""?(e.parent().append(`
                            <div class="simplyin-show-popup">
                                <div class="simplyin-show-popup-icon">
                                    <img width="30" height="30" src="${simplyin.files_url}/views/img/logo_smalln.svg"/>
                                    <svg width="12" height="13" viewBox="0 0 12 13" fill="none" xmlns="http://www.w3.org/2000/svg">
                                      <rect y="0.5" width="12" height="12" rx="6" fill="#33CC40"></rect>
                                      <path d="M3.23096 6.54276L5.07711 8.38892L8.76942 4.38892" stroke="white" stroke-width="1.23077" stroke-linecap="round" stroke-linejoin="round"></path>
                                    </svg>
                                </div>
                                <div class="simplyin-show-popup-edit">
                                    <span>${simplyin.labels.data_completed}</span>
                                    <div class="simplyin-show-popup-edit-bottom">
                                      <span>${simplyin.labels.change}</span>
                                      <svg width="14" height="15" viewBox="0 0 14 15" fill="none" xmlns="http://www.w3.org/2000/svg">
                                        <path d="M8.41604 2.74719L8.97217 2.19107C9.89359 1.26964 11.3875 1.26964 12.3089 2.19107C13.2304 3.11249 13.2304 4.60641 12.3089 5.52783L11.7528 6.08396M8.41604 2.74719C8.41604 2.74719 8.48556 3.92897 9.5283 4.97171C10.571 6.01445 11.7528 6.08396 11.7528 6.08396M8.41604 2.74719L3.30329 7.85994C2.957 8.20624 2.78385 8.37939 2.63494 8.5703C2.45928 8.79551 2.30868 9.03919 2.18581 9.29701C2.08164 9.51558 2.00421 9.74789 1.84934 10.2125L1.3535 11.7M11.7528 6.08396L6.64006 11.1967C6.29376 11.543 6.12061 11.7162 5.9297 11.8651C5.70449 12.0407 5.46082 12.1913 5.20299 12.3142C4.98442 12.4184 4.75211 12.4958 4.28751 12.6507L2.8 13.1465M2.8 13.1465L1.8375 13.4673C1.60887 13.5435 1.35679 13.484 1.18638 13.3136C1.01596 13.1432 0.956457 12.8911 1.03267 12.6625L1.3535 11.7M2.8 13.1465L1.3535 11.7" stroke="#2D40F6" stroke-width="1.6"></path>
                                      </svg>
                                    </div>
                                </div>
                            </div>
                        `),$(e).val(simplyin.customer_email),simplyin.customer.has_token||this.hideIcon()):(e.parent().append(` <br/>
                            <div class="simplyin-show-popup" style="margin-left: 0">
                                <div class="simplyin-show-popup-icon">
                                    <img width="30" height="30" src="${simplyin.files_url}/views/img/logo_smalln.svg"/>
                                    <svg width="12" height="13" viewBox="0 0 12 13" fill="none" xmlns="http://www.w3.org/2000/svg">
                                      <rect y="0.5" width="12" height="12" rx="6" fill="#33CC40"></rect>
                                      <path d="M3.23096 6.54276L5.07711 8.38892L8.76942 4.38892" stroke="white" stroke-width="1.23077" stroke-linecap="round" stroke-linejoin="round"></path>
                                    </svg>
                                </div>
                                <div class="simplyin-show-popup-edit">
                                    <span>${simplyin.labels.data_completed}</span>
                                    <div class="simplyin-show-popup-edit-bottom">
                                      <span>${simplyin.labels.change}</span>
                                      <svg width="14" height="15" viewBox="0 0 14 15" fill="none" xmlns="http://www.w3.org/2000/svg">
                                        <path d="M8.41604 2.74719L8.97217 2.19107C9.89359 1.26964 11.3875 1.26964 12.3089 2.19107C13.2304 3.11249 13.2304 4.60641 12.3089 5.52783L11.7528 6.08396M8.41604 2.74719C8.41604 2.74719 8.48556 3.92897 9.5283 4.97171C10.571 6.01445 11.7528 6.08396 11.7528 6.08396M8.41604 2.74719L3.30329 7.85994C2.957 8.20624 2.78385 8.37939 2.63494 8.5703C2.45928 8.79551 2.30868 9.03919 2.18581 9.29701C2.08164 9.51558 2.00421 9.74789 1.84934 10.2125L1.3535 11.7M11.7528 6.08396L6.64006 11.1967C6.29376 11.543 6.12061 11.7162 5.9297 11.8651C5.70449 12.0407 5.46082 12.1913 5.20299 12.3142C4.98442 12.4184 4.75211 12.4958 4.28751 12.6507L2.8 13.1465M2.8 13.1465L1.8375 13.4673C1.60887 13.5435 1.35679 13.484 1.18638 13.3136C1.01596 13.1432 0.956457 12.8911 1.03267 12.6625L1.3535 11.7M2.8 13.1465L1.3535 11.7" stroke="#2D40F6" stroke-width="1.6"></path>
                                      </svg>
                                    </div>
                                </div>
                            </div>
                        `),this.hideIcon()))}else $(".identity").parent().prepend(`
                    <div class="simplyin-identity-right">
                        <div class="simplyin-show-popup">
                            <div class="simplyin-show-popup-icon">
                                <img width="30" height="30" src="${simplyin.files_url}/views/img/logo_smalln.svg"/>
                                <svg width="12" height="13" viewBox="0 0 12 13" fill="none" xmlns="http://www.w3.org/2000/svg">
                                  <rect y="0.5" width="12" height="12" rx="6" fill="#33CC40"></rect>
                                  <path d="M3.23096 6.54276L5.07711 8.38892L8.76942 4.38892" stroke="white" stroke-width="1.23077" stroke-linecap="round" stroke-linejoin="round"></path>
                                </svg>
                            </div>
                            <div class="simplyin-show-popup-edit">
                                <span>${simplyin.labels.data_completed}</span>
                                <div class="simplyin-show-popup-edit-bottom">
                                  <span>${simplyin.labels.change}</span>
                                  <svg width="14" height="15" viewBox="0 0 14 15" fill="none" xmlns="http://www.w3.org/2000/svg">
                                    <path d="M8.41604 2.74719L8.97217 2.19107C9.89359 1.26964 11.3875 1.26964 12.3089 2.19107C13.2304 3.11249 13.2304 4.60641 12.3089 5.52783L11.7528 6.08396M8.41604 2.74719C8.41604 2.74719 8.48556 3.92897 9.5283 4.97171C10.571 6.01445 11.7528 6.08396 11.7528 6.08396M8.41604 2.74719L3.30329 7.85994C2.957 8.20624 2.78385 8.37939 2.63494 8.5703C2.45928 8.79551 2.30868 9.03919 2.18581 9.29701C2.08164 9.51558 2.00421 9.74789 1.84934 10.2125L1.3535 11.7M11.7528 6.08396L6.64006 11.1967C6.29376 11.543 6.12061 11.7162 5.9297 11.8651C5.70449 12.0407 5.46082 12.1913 5.20299 12.3142C4.98442 12.4184 4.75211 12.4958 4.28751 12.6507L2.8 13.1465M2.8 13.1465L1.8375 13.4673C1.60887 13.5435 1.35679 13.484 1.18638 13.3136C1.01596 13.1432 0.956457 12.8911 1.03267 12.6625L1.3535 11.7M2.8 13.1465L1.3535 11.7" stroke="#2D40F6" stroke-width="1.6"></path>
                                  </svg>
                                </div>
                            </div>
                        </div>
                    </div>
                `);this.barEnabled()&&$("#checkout-personal-information-step").prepend(this.barHtml()),this.badgeEnabled()&&this.injectFieldBadge(this.email_field),this.dockBadge()},initEventListeners:function(){let e=this;$(document).on("click",".simplyin-popup-close-button, .simplyin-popup-overlay",function(){e.hidePopup()}),$(document).on("click",".simplyin-show-popup",function(){e.showLastPopup()}),$(document).on("input",this.email_field,function(){e.force_login=!1;let i=!1;e.is_login&&e.customer_email!=$(this).val()&&(i=!0),e.customer_email!=$.trim($(this).val())&&(e.login_request_send=!1,e.isValidEmailAddress(e.customer_email)||e.hideIcon(),e.customer_email=$.trim($(this).val()),e.stopPushNotifications(),e.submitEmail(i))}),$(document).on("click","#simplyin-button-send-sms",function(){e.sendSmsCode(),e.stopPushNotifications()}),$(document).on("click","#simplyin-button-send-email",function(){e.sendEmailCode(),e.stopPushNotifications()})},toggleElement:function(e,i,t){let s=$("#"+i+" "+e);t?$(s).slideDown({duration:150}):$(s).slideUp({duration:150})},positionMenu:function(e,i){let t=e.offset(),s=e.outerHeight(),n=e.outerWidth();window.innerWidth<685?i.css({top:t.top+s+"px",right:n+"px",zIndex:20000001}):i.css({top:t.top+s+"px",left:t.left+"px",zIndex:20000001})},toggleDeliveryAddress:function(e){let i=this,t=$(e).data("target"),s=$(e).is(".expanded"),n=$('.popup-address-select-label-group input[type="checkbox"]').is(":checked");i.toggleElement(".popup-address-select-group",t,s)},initEventListenersPin:function(){let e=this;var i='#simplyin-input-code input[type="text"]';$(document).on("keypress",i,function(t){/[0-9]/.test(t.key)||t.preventDefault()}),$(document).on("input",i,function(){var t=$(i),s=t.index(this),n=this.value;if(n=n.replace(/\D/g,""),n.length>1){for(let l=0;l<n.length&&s+l<t.length;l++)t.eq(s+l).val(n[l]);let o=s+n.length<t.length?s+n.length:t.length-1;t.eq(o).focus().select()}else this.value=n,n.length===1&&s<t.length-1&&t.eq(s+1).focus().select();e.validatePinCode()}),$(document).on("keydown",i,function(t){var s=$(i),n=s.index(this);switch(t.key){case"Backspace":if(t.preventDefault(),this.value="",n>0){var o=s.eq(n-1);o.focus().select()}break;case"ArrowLeft":if(n>0){t.preventDefault();var o=s.eq(n-1);o.focus().select()}break;case"ArrowRight":if(n<s.length-1){t.preventDefault();var l=s.eq(n+1);l.focus().select()}break}}),$(document).on("paste",i,function(t){t.preventDefault();let s=(t.originalEvent||t).clipboardData||window.clipboardData;if(!s)return;let n=(s.getData("text")||"").replace(/\D/g,"");if(!n)return;let o=$(i),l=o.index(this);for(let p=0;p<n.length&&l<o.length;p++,l++)o.eq(l).val(n[p]);let a=o.filter((p,r)=>r.value==="");e.validatePinCode()}),$(document).on("keyup",i,e.validatePinCode)},removeContextMenu:function(){$(".dropdown-actions-menu").remove(),$(".simplyin-popup-overlay-context").remove()},deleteAddress:function(e,i){let t=this;t.removeContextMenu();let s=function(){let n={action:"deleteAddress",ajax:1,ajax_token:simplyin.ajax_token,id:e,address_type:i};$.ajax({url:t.ajax,method:"POST",data:n,dataType:"json"}).done(o=>{o.success&&(i=="billingAddresses"?$(`.popup-address-select[data-id="${e}"]`).parent().remove():$(`.popup-address-select[data-id="${e}"]`).remove(),t.removeContextMenu(),t.checkSelectedAddress(),t.last_popup="")})};t.confirmationPopup(simplyin.labels.delete_header,simplyin.labels.confirm_delete,s)},initEventListenersDelivery:function(){let e=this;$(document).on("change",'#simplyin-parcel-lockers input[name="simplyin-parcel-locker-selected"],#simplyin-delivery-points input[name="simplyin-delivery-point-selected"]',function(){$("#popup-delivery-parcel-locker-address .popup-selected-address .popup-address-label-line-1").html($(this).data("address-1")),$(this).attr("name")=="simplyin-delivery-point-selected"?$('input[name="simplyin-parcel-locker-selected"]').prop("checked",!1):$('input[name="simplyin-delivery-point-selected"]').prop("checked",!1)}),$(document).on("change",'input[name="simplyin-invoice-address"]',function(){$("#popup-invoice-address .popup-selected-address .popup-selected-address-line-1").html($(this).data("address-1")),$("#popup-invoice-address .popup-selected-address .popup-selected-address-line-2").html($(this).data("address-2"))}),$(document).on("change",'input[name="simplyin-delivery-address"]',function(){$("#popup-delivery-address .popup-selected-address .popup-selected-address-line-1").html($(this).data("address-1")),$("#popup-delivery-address .popup-selected-address .popup-selected-address-line-2").html($(this).data("address-2"))}),$(document).on("click",function(){e.removeContextMenu()}),$(document).on("click",".simplyin-button-edit",function(i){i.stopPropagation(),e.removeContextMenu(),e.editAddress($(this).data("id"),$(this).data("address-type"))}),$(document).on("click",".simplyin-button-delete",function(i){i.stopPropagation();let t=$(this).data("id"),s=$(this).data("address-type");e.deleteAddress(t,s)}),$(document).on("click",".popup-address-actions",function(i){i.stopPropagation(),e.removeContextMenu();let t=$(this).parents(".popup-address-selector").find(".popup-address-select").length,s=parseInt($(this).parents(".popup-address-selector").data("edit")),n=parseInt($(this).parents(".popup-address-selector").data("delete")),o=parseInt($(this).parents(".popup-address-selector").data("force-delete")),l=simplyin.labels.edit,a=simplyin.labels.delete,p=$('<div class="dropdown-actions-menu"><ul></ul></div>'),r=$(this).parents(".popup-address-select").data("id");if(!s&&!n)return;let d="";$(this).parents("#popup-invoice-address").length?d="billingAddresses":$(this).parents("#popup-delivery-address").length?d="shippingAddresses":d="parcelLockers",s&&$(p).find("ul").append(`
                        <li class="simplyin-button-edit edit-action" data-id="${r}" data-address-type="${d}">
                            <svg class="simplyin-action-icon" width="23" height="24" viewBox="0 0 23 24" fill="none" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="${l}">
                              <path d="M20.3103 7.2539L16.1216 3.06422C15.9823 2.92489 15.8169 2.81437 15.6349 2.73897C15.4529 2.66357 15.2578 2.62476 15.0608 2.62476C14.8638 2.62476 14.6687 2.66357 14.4867 2.73897C14.3047 2.81437 14.1393 2.92489 14 3.06422L2.43969 14.6255C2.2998 14.7642 2.18889 14.9295 2.11341 15.1115C2.03792 15.2935 1.99938 15.4887 2.00001 15.6858V19.8755C2.00001 20.2733 2.15804 20.6548 2.43935 20.9361C2.72065 21.2174 3.10218 21.3755 3.50001 21.3755H7.6897C7.88675 21.3761 8.08197 21.3375 8.26399 21.2621C8.44602 21.1866 8.61122 21.0757 8.75001 20.9358L20.3103 9.37547C20.4496 9.23617 20.5602 9.0708 20.6356 8.88879C20.711 8.70678 20.7498 8.5117 20.7498 8.31468C20.7498 8.11767 20.711 7.92259 20.6356 7.74058C20.5602 7.55857 20.4496 7.3932 20.3103 7.2539ZM7.6897 19.8755H3.50001V15.6858L11.75 7.43578L15.9397 11.6255L7.6897 19.8755ZM17 10.5642L12.8103 6.37547L15.0603 4.12547L19.25 8.31422L17 10.5642Z"/>
                            </svg>
                            ${l}
                        </li>
                    `),(t>1&&n||o)&&$(p).find("ul").append(`
                        <li class="simplyin-button-delete delete-action" data-id="${r}" data-address-type="${d}">
                            <svg class="simplyin-action-icon" width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="Usu\u0144">
                              <path d="M20.25 5.25H16.5V4.5C16.5 3.90326 16.2629 3.33097 15.841 2.90901C15.419 2.48705 14.8467 2.25 14.25 2.25H9.75C9.15326 2.25 8.58097 2.48705 8.15901 2.90901C7.73705 3.33097 7.5 3.90326 7.5 4.5V5.25H3.75C3.55109 5.25 3.36032 5.32902 3.21967 5.46967C3.07902 5.61032 3 5.80109 3 6C3 6.19891 3.07902 6.38968 3.21967 6.53033C3.36032 6.67098 3.55109 6.75 3.75 6.75H4.5V20.25C4.5 20.6478 4.65804 21.0294 4.93934 21.3107C5.22064 21.592 5.60218 21.75 6 21.75H18C18.3978 21.75 18.7794 21.592 19.0607 21.3107C19.342 21.0294 19.5 20.6478 19.5 20.25V6.75H20.25C20.4489 6.75 20.6397 6.67098 20.7803 6.53033C20.921 6.38968 21 6.19891 21 6C21 5.80109 20.921 5.61032 20.7803 5.46967C20.6397 5.32902 20.4489 5.25 20.25 5.25ZM9 4.5C9 4.30109 9.07902 4.11032 9.21967 3.96967C9.36032 3.82902 9.55109 3.75 9.75 3.75H14.25C14.4489 3.75 14.6397 3.82902 14.7803 3.96967C14.921 4.11032 15 4.30109 15 4.5V5.25H9V4.5ZM18 20.25H6V6.75H18V20.25ZM10.5 10.5V16.5C10.5 16.6989 10.421 16.8897 10.2803 17.0303C10.1397 17.171 9.94891 17.25 9.75 17.25C9.55109 17.25 9.36032 17.171 9.21967 17.0303C9.07902 16.8897 9 16.6989 9 16.5V10.5C9 10.3011 9.07902 10.1103 9.21967 9.96967C9.36032 9.82902 9.55109 9.75 9.75 9.75C9.94891 9.75 10.1397 9.82902 10.2803 9.96967C10.421 10.1103 10.5 10.3011 10.5 10.5Z"/>
                            </svg>
                            Usu\u0144
                        </li>
                    `),t>=1&&(s||n)&&$(p).find("li").length>0&&($(".simplyin-popup").parent().append(p),SimplyIn.positionMenu($(this),p))}),$(document).on("change",'.popup-address-select-label-group input[type="checkbox"]',function(i){i.preventDefault();let t=$('.popup-button-expand[data-target="popup-delivery-address"]')[0],s=$(this).parents(".popup-address-select-label-group").find('input[type="checkbox"]').is(":checked"),n=$('.popup-button-expand[data-target="popup-delivery-address"]');return!s&&!n.is(".expanded")?n.addClass("expanded"):n.removeClass("expanded"),s?$("#popup-delivery-address").find('input[type="radio"]').prop("checked",!1):$("#popup-delivery-address").find('input[type="radio"]:first').prop("checked",!0),e.toggleDeliveryAddress(t),!1}),$(window).on("resize",function(){e.removeContextMenu()}),$(document).on("change",".simplyin-delivery-type",function(i){i.preventDefault(),$(this).val()=="address"?($(".popup-delivery-address-box").show(),$(".popup-delivery-parcel-locker-box").hide()):($(".popup-delivery-parcel-locker-box .popup-button-expand").addClass("expanded"),$(".popup-delivery-address-box").hide(),$(".popup-delivery-parcel-locker-box").show())}),$(document).on("click",'.popup-button-expand[data-target="popup-invoice-address"]',function(i){i.preventDefault();let t=$(this).data("target"),s=$(this).is(".expanded");$(this).toggleClass("expanded"),e.toggleElement(".popup-address-select-group",t,!s)}),$(document).on("click",'.popup-button-expand[data-target="popup-delivery-parcel-locker-address"]',function(i){i.preventDefault();let t=$(this).data("target"),s=$(".popup-address-selector-header button.active").data("target"),n=$(".popup-address-selector-header button:not(.active)").data("target");$(this).toggleClass("expanded");let o=$(this).is(".expanded");e.toggleElement(".popup-address-select-group",t,o),$("#"+s).show(),$("#"+n).hide()}),$(document).on("click",'.popup-button-expand[data-target="popup-delivery-address"]',function(i){i.preventDefault(),$(this).toggleClass("expanded"),e.toggleDeliveryAddress(this)}),$(document).on("change",'#popup-delivery-address input[type="radio"]',function(i){i.preventDefault(),$('.popup-address-select-label-group input[type="checkbox"]').prop("checked",!1)}),$(document).on("click",".popup-address-selector-header button",function(i){i.preventDefault(),$(".popup-delivery-parcel-locker-box .popup-button-expand").addClass("expanded");let t=$(this).data("target");$(this).addClass("active").siblings().removeClass("active"),$("#"+t).show().siblings().hide()}),$(document).on("click",".popup-address-actions-add",function(i){i.preventDefault();let t=$(this).data("type");e.storeDeliveryPopup();var s={action:"addAddress",ajax:1,ajax_token:simplyin.ajax_token,address_type:t};$.ajax({url:e.ajax,method:"POST",data:s,dataType:"json"}).done(n=>{n.success&&(e.showPopupByContent(n.html),e.initAutocomplete(),$("#pickup-search").focus())})}),$(document).on("click",".popup-select-address",function(){e.selectAddress()})},initAutocomplete:function(){let e=this,i=document.querySelector(".simplyin-autocomplete #pickup-search");if(!i)return;let t=document.createElement("div");t.className="autocomplete-dropdown",t.style.position="absolute",t.style.zIndex="999999999",t.style.display="none",t.style.backgroundColor="#fff",t.style.border="1px solid #ccc",t.style.maxHeight="200px",t.style.overflowY="auto",document.body.appendChild(t);function s(){let o=i.getBoundingClientRect();t.style.width=o.width+"px",t.style.left=o.left+window.scrollX+"px",t.style.top=o.bottom+window.scrollY+"px"}i.addEventListener("input",function(o){let l=i.value;if(l.length<3){t.style.display="none";return}e.fetchAddressSuggestions({term:l},function(a){if(t.innerHTML="",!a||!a.length){t.style.display="none";return}a.forEach(p=>{let r=document.createElement("div");r.textContent=p.label||p.value||p,r.style.padding="5px 10px",r.style.cursor="pointer",r.addEventListener("mousedown",function(d){d.preventDefault(),i.value=r.textContent;let c={item:p};e.handleSelect(d,c),t.style.display="none"}),t.appendChild(r)}),s(),t.style.display="block"})}),document.addEventListener("click",function(o){!i.contains(o.target)&&!t.contains(o.target)&&(t.style.display="none")});let n=-1;i.addEventListener("keydown",function(o){let l=t.querySelectorAll("div");l.length&&(o.key==="ArrowDown"?(o.preventDefault(),n=(n+1)%l.length,l.forEach((a,p)=>a.style.background=p===n?"#ddd":"")):o.key==="ArrowUp"?(o.preventDefault(),n=(n-1+l.length)%l.length,l.forEach((a,p)=>a.style.background=p===n?"#ddd":"")):o.key==="Enter"&&(o.preventDefault(),n>=0&&(l[n].dispatchEvent(new Event("mousedown")),n=-1)))}),window.addEventListener("resize",s),window.addEventListener("scroll",s)},fetchAddressSuggestions:function(e,i){let t=this;$.ajax({url:t.ajax,method:"POST",data:{action:"searchAddress",ajax:1,ajax_token:simplyin.ajax_token,address:e.term},dataType:"json",success:function(s){if(s&&s.data){let n=t.mapAddressData(s.data);i(n)}}})},mapAddressData:function(e){return e.map(function(i){return{label:i.formatted_address,value:i.formatted_address,place_id:i.place_id,geometry:i.geometry}})},handleSelect:function(e,i){let t=this;$('.simplyin-pickup-list-item input[name="pickup-option"]').val(i.item.value);let s=i.item.geometry.location.lat,n=i.item.geometry.location.lng,o={action:"getClosestParcelLockers",ajax:1,ajax_token:simplyin.ajax_token,coordinates:{lat:s,lng:n}};$.ajax({url:SimplyIn.ajax,method:"POST",data:o,dataType:"json"}).done(l=>{l.success&&t.fillParcelsList(l)})},initEventListenersEditAddress:function(){let e=this;$(document).on("click",".simplyin-popup-addres-form button.simplyin-cancel",function(i){i.preventDefault(),e.retrieveDeliveryPopup()}),$(document).on("click",".simplyin-popup-addres-form button.simplyin-submit",function(i){i.preventDefault(),e.submitAddress()})},clearParcelsList:function(){let e=this;$(".pickup-placeholder").show(),$(".pickup-list-container").empty().hide()},fillParcelsList:function(e){let i=this;if(e.data.count){let t="";$.each(e.data.data,function(s,n){let o=n.locker,l=n.info,a=o.address,p=Math.round(l.distance*1e3),r=l.provider,d=o.desc;t+=`
                        <div class="simplyin-pickup-list-item">
                            <label class="pickup-item">
                                <input
                                    type="radio"
                                    name="pickup-option"
                                    value="${o._id}"
                                    data-id="${o.lockerId}"
                                    data-address="${a}"
                                    data-desc="${d}"
                                    data-locker-id="${o.lockerId}"
                                    data-logo-url="${r.logoUrl}"
                                    data-label="${r.name}"
                                    data-provider-id="${o.providerId}"
                                    data-service-type="${o.service_type}"
                                >
                                <div class="pickup-info">
                                    <img src="${r.logoUrl}" alt="${r.name}">
                                    <div class="pickup-details">
                                        <strong>${o.lockerId}</strong>
                                        <span>${a}</span>
                                        <span>${simplyin.labels.edit}: ${p} m</span>
                                    </div>
                                </div>
                            </label>
                        </div>
                    `}),i.clearParcelsList(),$(".pickup-list-container").html(t),$(".pickup-placeholder").hide(),$(".pickup-list-container").show()}else i.clearParcelsList()},selectNewParcel:function(e){let i=this,t=$(e).data("id"),s=$(e).data("address"),n=$(e).data("desc");$("#simplyin-pickup-number").html(t),$("#simplyin-pickup-address").html(s),$("#simplyin-pickup-info").html(n)},initEventListenersAddParcelLocker:function(){let e=this;$(document).on("change",'.simplyin-pickup-list-item input[name="pickup-option"]',function(){e.selectNewParcel(this)}),$(document).on("click",".simplyin-autocomplete button.simplyin-cancel",function(i){i.preventDefault(),e.retrieveDeliveryPopup(),$('input[name="simplyin-delivery-type"][value="parcel_locker"]').prop("checked",!0)}),$(document).on("click",".simplyin-autocomplete button.simplyin-submit",function(i){i.preventDefault();let t=$('input[name="pickup-option"]:checked');t.length&&(e.addNewParcelLocker(t),$('input[name="simplyin-delivery-type"][value="parcel_locker"]').prop("checked",!0))}),$(document).on("enter",'.simplyin-popup input[name="pickup-name"]',function(i){let t=$('input[name="pickup-option"]:checked');t.length&&e.addNewParcelLocker(t)})},addNewParcelLocker:function(e){let i=this,t={action:"submitAddress",ajax:1,ajax_token:simplyin.ajax_token,parcel:{address_type:"parcelLockers",_id:$(e).val(),logoUrl:$(e).data("logoUrl"),addressName:$.trim($("#pickup-name").val())?$.trim($("#pickup-name").val()):e.data("id"),lockerId:e.data("id"),address:e.data("address"),label:e.data("label"),providerId:e.data("providerId"),service_type:e.data("service-type")}};$.ajax({url:SimplyIn.ajax,method:"POST",data:t,dataType:"json"}).done(s=>{if(s.success&&typeof s.html<"u"){let n=$(s.html),o=n.find("#simplyin-delivery-points").html(),l=n.find("#simplyin-parcel-lockers").html();i.retrieveDeliveryPopup(),$("#simplyin-parcel-lockers").html(l),$("#simplyin-delivery-points").html(o)}})},submitAddress:function(e){let i=this,t=$("form.simplyin-popup-addres-form"),s=t.find("input[required]"),n=!0;if($.each(s,function(a,p){$(p).val()==""?($(p).parents(".form-group").addClass("error"),n=!1):$(p).parents(".form-group").removeClass("error")}),!n)return!1;let o={action:"submitAddress",ajax:1,ajax_token:simplyin.ajax_token};var l=new FormData;$.each(o,function(a,p){l.append(a,p)}),$.each(t[0].elements,function(a,p){p.name!=""&&l.append("address["+p.name+"]",p.value)}),$.ajax({url:this.ajax,method:"POST",data:l,processData:!1,contentType:!1,dataType:"json"}).done(a=>{a.success&&(a.is_valid!==!0&&typeof a.is_valid=="object"?(t.find(".form-group").removeClass("error"),$.each(a.is_valid,function(p,r){t.find('input[name="'+p+'"]').parents(".form-group").addClass("error"),t.find('input[name="'+p+'"]').parents(".form-group").find(".error-message").html(a.is_valid[p])})):a.is_valid===!0&&typeof a.address<"u"?(i.retrieveDeliveryPopup(),i.upgradeAddress(a)):a.is_valid===!0&&typeof a.add_address<"u"&&(i.retrieveDeliveryPopup(),i.addAddress(a.address,a.address_type,a.html)),i.checkSelectedAddress())})},checkSelectedAddress:function(){$('input[name="simplyin-invoice-address"]:checked').length==0&&$('input[name="simplyin-invoice-address"]:first').prop("checked",!0),$(".popup-address-checkbox .checkbox:checked")&&$('input[name="simplyin-delivery-address"]:checked').length==0&&$('input[name="simplyin-delivery-address"]:first').prop("checked",!0)},upgradeAddress:function(e){let i=e.address,t=e.address_type,s="";s=$('div[data-id="'+i._id+'"]');let n=i.addressName,o=i.street;i.appartmentNumber!=""&&(o=i.street+"/"+i.appartmentNumber),o=o+", "+i.city,s.find(".popup-address-label-line-1").html(n),s.find(".popup-address-label-line-2").html(o),s.find(".icon").html(i.icon)},addAddress:function(e,i,t){let s="",n=$(t),o=!1,l="";i=="billingAddresses"?(o=n.find("#popup-invoice-address .popup-address-select-group:last"),s=$("#popup-invoice-address"),l='input[name="simplyin-invoice-address"]:last'):i=="shippingAddresses"?(o=n.find("#popup-delivery-address .popup-address-select:last"),s=$("#popup-delivery-address").find(".popup-address-select-group"),l='input[name="simplyin-delivery-address"]:last'):i=="parcelLockers"&&(o=!1),s.length&&o!==!1&&(s.append(o),$(l).prop("checked",!0),i=="shippingAddresses"&&($('#popup-delivery-address .popup-address-checkbox input[type="checkbox"]').prop("checked",!1),s.show(),$('.popup-button-expand[data-target="popup-delivery-address"]').addClass("expanded")))},selectDefaultAddress:function(){let e=$('input[name="simplyin-invoice-address"]:checked').data("id");if(!e)return;let i=e,t={action:"selectAddress",ajax:1,ajax_token:simplyin.ajax_token,invoice_address:e,service_type:"",delivery_address:i,selected_point:""};$.ajax({url:this.ajax,method:"POST",data:t,dataType:"json"})},selectAddress:function(){let e=this,i=$('input[name="simplyin-invoice-address"]:checked').data("id"),t="",s="",n="";$('.simplyin-delivery-type[type="radio"]:checked').val()=="address"?$('.popup-address-checkbox input[type="checkbox"]').is(":checked")?t=$('input[name="simplyin-invoice-address"]:checked').data("id"):t=$('input[name="simplyin-delivery-address"]:checked').data("id"):$('input[name="simplyin-parcel-locker-selected"]:checked').length?(n="parcel",s=$('input[name="simplyin-parcel-locker-selected"]:checked').data("id")):$('input[name="simplyin-delivery-point-selected"]:checked').length&&(n="delivery",s=$('input[name="simplyin-delivery-point-selected"]:checked').data("id"));let o={action:"selectAddress",ajax:1,ajax_token:simplyin.ajax_token,invoice_address:i,service_type:n,delivery_address:t,selected_point:s};$.ajax({url:this.ajax,method:"POST",data:o,dataType:"json"}).done(l=>{l.redirect?(e.on_close_refresh_page=!0,e.hidePopup()):(e.hidePopup(),e.selectCheckbox())})},submitEmail:function(e){this.last_popup="";let i=this;if(this.is_login==!1||e){this.is_login=!1;var t=this.customer_email;if(!this.isValidEmailAddress(t)&&this.force_login===!1)return;var s={action:"submitEmail",ajax:1,ajax_token:simplyin.ajax_token,email:t,logout:e,force_login:this.force_login?1:0};$.ajax({url:i.ajax,method:"POST",data:s,dataType:"json"}).done(n=>{n.success&&n.show_popup&&(i.userUsedPushNotifications=n.userUsedPushNotifications,i.last_popup=n.html,i.last_email=t,i.login_request_send=!0,i.showPopupByContent(n.html),i.focusOnCode(),i.showIcon(),!i.is_login&&!simplyin.customer.has_token&&($(".simplyin-show-popup").not(".simplyin-show-popup-login").addClass("simplyin-confirm-profile"),$(".simplyin-show-popup").not(".simplyin-show-popup-login").find(".simplyin-show-popup-edit > span").first().text(simplyin.labels.confirm_profile),i.dockConfirmProfile()),i.phoneCheckboxManager&&(i.phoneCheckboxManager.state.userExistsInSimplyIn=!0,i.phoneCheckboxManager.hideCheckbox()),n.userUsedPushNotifications?i.checkPushNotification():i.codeStartCounting()),n.error=="NOT_FOUND"&&(i.hideIcon(),i.phoneCheckboxManager&&(i.phoneCheckboxManager.state.userExistsInSimplyIn=!1,$("#checkout-payment-step.-current").length&&!$("#simplyin-phone-checkbox").length&&i.phoneCheckboxManager.showCheckbox()),t===i.customer_email&&(simplyin.hide_phone_field=!1,i.initEventListenersNewAccount()))})}},showLastPopup:function(){let e=this;e.customer_email==""&&simplyin.customer.logged==!0&&typeof simplyin.customer.email<"u"&&(e.customer_email=simplyin.customer.email,e.submitEmail(!1)),e.is_login&&(e.last_popup?e.showPopupByContent(e.last_popup):e.showPopupByType("delivery",{email:e.customer_email})),!e.is_login&&e.login_request_send&&e.last_email!=""&&e.last_popup!=""&&(e.customer_email=e.last_email,e.submitEmail(!1))},showPopupByContent:function(e){this.last_popup=e,$(".simplyin-popup-box").length===0?this.popup=$("<div>").addClass("simplyin-popup-box").appendTo("body")[0]:this.popup=document.querySelector(".simplyin-popup-box"),$(".simplyin-popup-box").html(e),setTimeout(()=>{$(".simplyin-popup-box").addClass("visible")},100)},showPopupByType:function(e,i={}){let t=this;var s={action:"getForm",type:e,ajax:1,ajax_token:simplyin.ajax_token},n=new FormData;$.each(s,function(o,l){n.append(o,l)}),$.each(i,function(o,l){n.append(o,l)}),$.ajax({url:t.ajax,method:"POST",data:n,processData:!1,contentType:!1,dataType:"json"}).done(o=>{o.success?t.showPopupByContent(o.html):o.error=="Session expired"&&(t.is_login=!1,t.submitEmail(!1))})},hidePopup:function(){let e=this;var i=$(".simplyin-popup-box");i.length&&(i.removeClass("visible"),setTimeout(()=>{i.remove(),e.on_close_refresh_page&&window.location.reload()},300))},sendSmsCode:function(){let e=this;if(!e.send_sms_code_run){var i={action:"sendSmsCode",ajax:1,ajax_token:simplyin.ajax_token,email:this.customer_email,force_login:this.force_login?1:0};e.send_sms_code_run=!0,setTimeout(function(){e.send_sms_code_run=!1},3e4),$.ajax({url:e.ajax,method:"POST",data:i,dataType:"json"}).done(t=>{t.success&&(e.showPopupByContent(t.html),e.codeStartCounting(),e.focusOnCode())})}},sendEmailCode:function(){let e=this;if(!e.send_email_code_run){var i={action:"sendEmailCode",ajax:1,ajax_token:simplyin.ajax_token,email:this.customer_email,force_login:this.force_login?1:0};e.send_email_code_run=!0,setTimeout(function(){e.send_email_code_run=!1},3e4),$.ajax({url:e.ajax,method:"POST",data:i,dataType:"json"}).done(t=>{t.success&&(e.showPopupByContent(t.html),e.codeStartCounting(),e.focusOnCode())})}},validatePinCode:function(){let e=window.SimplyIn;e.validate_code_sended||(e.validate_code_timeout&&clearTimeout(e.validate_code_timeout),e.validate_code_timeout=setTimeout(()=>{var i='#simplyin-input-code input[type="text"]',t="";if($(i).each(function(){t+=this.value}),t.length==4){e.validate_code_sended=!0;var s={action:"checkCode",ajax:1,ajax_token:simplyin.ajax_token,email:SimplyIn.customer_email,code:t,force_login:SimplyIn.force_login?1:0};if(t==e.last_code){e.validate_code_sended=!1;return}$.ajax({url:e.ajax,method:"POST",data:s,dataType:"json"}).done(n=>{if(e.validate_code_sended=!1,n.isCodeValid==!1)$(".simplyin-popup-content .code-error-message").show(),$(".simplyin-popup-content .code-error-message").text(simplyin.labels.code_invalid),$(i).addClass("invalid").removeClass("valid");else if(n.code=="TOO_MANY_REQUESTS"){$(".simplyin-popup-content .code-error-message").show();var o=n.message.split(`
`);o.length>1?e.startCountingMessage(o):$(".simplyin-popup-content .code-error-message").html(o[0])}else n.success&&(e.stopCounting(),e.showIcon(),$(".simplyin-show-popup").removeClass("simplyin-confirm-profile"),$(".simplyin-show-popup-edit > span").first().text(simplyin.labels.data_completed),e.phoneCheckboxManager&&e.phoneCheckboxManager.hideCheckbox(!0),typeof e.showChangeDataButton=="function"&&e.showChangeDataButton(),e.is_login_page?window.location.reload():(e.showPopupByContent(n.html),e.selectDefaultAddress()),e.loginCustomer(e.customer_email),n.login_result.is_guest?($('#customer-form input[name="firstname"]').val(n.login_result.firstname).trigger("input").trigger("change"),$('#customer-form input[name="lastname"]').val(n.login_result.lastname).trigger("input").trigger("change"),e.selectCheckbox()):e.on_close_refresh_page=!0)})}else $(".simplyin-popup-content .code-error-message").hide(),$(i).addClass("valid").removeClass("invalid")},300))},isValidEmailAddress:function(e){var i=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}$/;return i.test(e)},codeStartCounting:function(){let e=this;var i=".simplyin-popup-footer .buttons",t=".simplyin-popup-footer .time",s=".simplyin-popup-footer .sent-messages";this.counting_interval&&clearInterval(this.counting_interval),this.counting_value=30,$(i).hide(),$(s).show(),this.counting_interval=setInterval(()=>{this.counting_value--,this.counting_value<=0&&(clearInterval(this.counting_interval),this.counting_value=0,$(i).show(),$(s).hide()),$(t).text(e.formatTime(this.counting_value))},1e3)},stopPushNotifications:function(){this.push_notification_interval&&(clearInterval(this.push_notification_interval),this.push_notification_interval=!1)},stopCounting:function(){this.counting_interval&&(clearInterval(this.counting_interval),this.counting_interval=!1)},checkPushNotification:function(){let e=this;this.push_notification_interval&&clearInterval(this.push_notification_interval);let i=0;this.push_notification_interval=setInterval(()=>{if(i++>60){e.stopPushNotifications();return}var t={action:"checkPushNotification",ajax:1,ajax_token:simplyin.ajax_token,email:this.customer_email};$.ajax({url:e.ajax,method:"POST",data:t,dataType:"json"}).done(s=>{s.success&&(e.stopPushNotifications(),e.showIcon(),$(".simplyin-show-popup").removeClass("simplyin-confirm-profile"),$(".simplyin-show-popup-edit > span").first().text(simplyin.labels.data_completed),e.loginCustomer(e.customer_email),e.login_request_send=!1,e.phoneCheckboxManager&&e.phoneCheckboxManager.hideCheckbox(!0),typeof e.showChangeDataButton=="function"&&e.showChangeDataButton(),e.is_login_page?window.location.reload():(e.showPopupByContent(s.html),e.selectDefaultAddress()),s.login_result.is_guest?($('#customer-form input[name="firstname"]').val(s.login_result.firstname).trigger("input").trigger("change"),$('#customer-form input[name="lastname"]').val(s.login_result.lastname).trigger("input").trigger("change")):e.on_close_refresh_page=!0)})},1e3)},startCountingMessage:function(e){let i=this;this.counting_message_interval&&clearInterval(this.counting_message_interval),this.counting_value_message=parseInt(e[1]);var t=".simplyin-popup-content .code-error-message";$(t).html(e[0]+"<br />"+i.formatTime(this.counting_value_message)),this.counting_message_interval=setInterval(()=>{this.counting_value_message--,this.counting_value_message<=0&&(clearInterval(this.counting_message_interval),this.counting_value_message=0,$(t).html(""),$(t).hide()),$(t).html(e[0]+"<br />"+i.formatTime(this.counting_value_message))},1e3)},formatTime:function(e){return e<10?"00:0"+e.toString():"00:"+e.toString()},loginCustomer:function(e){this.customer_email=e,this.is_login=!0,this.is_login_page},storeDeliveryPopup:function(){let e=this;e.delivery_popup=$(".simplyin-popup-box").children().clone(!0,!0),e.delivery_popup_scroll=$(".simplyin-popup").scrollTop()},retrieveDeliveryPopup:function(){let e=this;e.delivery_popup&&(e.showPopupByContent(e.delivery_popup),$(".simplyin-popup").length&&e.delivery_popup_scroll&&$(".simplyin-popup").scrollTop(e.delivery_popup_scroll))},editAddress:function(e,i){let t=this;t.storeDeliveryPopup();var s={action:"editAddress",ajax:1,ajax_token:simplyin.ajax_token,id:e,address_type:i};$.ajax({url:t.ajax,method:"POST",data:s,dataType:"json"}).done(n=>{n.success&&t.showPopupByContent(n.html)})},confirmationPopup:function(e,i,t){let s=this,n=$('<div class="simplyin-popup-overlay-confirmation"><div>'),o=$(`
                <div class="simplyin-confirmation-popup">
                    <div class="simplyin-popup-header-confirmation">
                        <span class="simplyin-title">
                            ${e}
                        </span>
                        <div class="simplyin-popup-close-button-confirmation">
                            <img width="20" height="21"
                                 src="${simplyin.files_url}/views/img/close_icon.svg"
                                 alt=""
                                 class="simplyin-close">
                        </div>
                    </div>
                    <div class="simplyin-message">
                        ${i}
                    </div>
                    <div class="simplyin-actions">
                        <button type="button"
                                class="simplyin-btn simplyin-btn-secondary">
                            ${simplyin.labels.cancel}
                        </button>
                        <button type="button"
                                class="simplyin-btn simplyin-btn-danger">
                            ${simplyin.labels.delete}
                        </button>
                    </div>
                </div>
            `);$("body").append(o),$("body").append(n);let l=()=>{o.remove(),n.remove(),$(document).off("keydown.simplyinConfirm")};n.on("click",function(){l()}),$(document).on("keydown.simplyinConfirm",function(a){a.key==="Escape"?l():a.key==="Enter"&&(l(),$.isFunction(t)&&t())}),o.on("click",".simplyin-popup-close-button-confirmation",l).on("click",".simplyin-btn-secondary",l).on("click",".simplyin-btn-danger",function(){l(),$.isFunction(t)&&t()})},logout:function(){e.is_login=!1;let e=this;var i={action:"logout",ajax:1,ajax_token:simplyin.ajax_token};$.ajax({url:e.ajax,method:"POST",data:i,dataType:"json"}).done(t=>{e.hidePopup()})},hideIcon:function(){typeof this.hideIconCheckout=="function"&&this.hideIconCheckout(),$(".simplyin-show-popup").hide(),$(".simplyin-field-badge").show()},showIcon:function(){typeof this.showIconCheckout=="function"&&this.showIconCheckout(),$(".simplyin-show-popup").show(),$(".simplyin-field-badge").hide()},dockConfirmProfile:function(){var e=$(".simplyin-show-popup").not(".simplyin-show-popup-login").filter(".simplyin-confirm-profile").first();if(!(!e.length||e.parent().hasClass("simplyin-field-wrap"))){var i=$(this.email_field).closest(".simplyin-field-wrap");if(i.length||(i=$(this.email_field).siblings(".simplyin-field-wrap").first()),!!i.length){var t=$('<span class="simplyin-show-popup-home" style="display:none"></span>');e.before(t),e.data("simplyinPopupHome",t),i.append(e)}}},undockConfirmProfile:function(){$(".simplyin-field-wrap > .simplyin-show-popup").not(".simplyin-show-popup-login").each(function(){var e=$(this).data("simplyinPopupHome");e&&e.length&&(e.replaceWith(this),$(this).removeData("simplyinPopupHome"))})},dockBadge:function(){var e=$(this.email_field);if(e.length){e.parent().hasClass("simplyin-field-wrap")||e.wrap('<div class="simplyin-field-wrap"></div>');var i=e.parent(),t=$(".simplyin-show-popup").not(".simplyin-show-popup-login").first();t.length&&!t.parent().hasClass("simplyin-field-wrap")&&i.append(t)}},focusOnCode:function(){$('#simplyin-input-code input[type="text"]:first').length&&$('#simplyin-input-code input[type="text"]:first').focus()},placeOrder:function(){$.ajax({url:SimplyIn.ajax,method:"POST",data:{action:"placeOrder",ajax:1,ajax_token:simplyin.ajax_token,order_token:simplyin.order.order_token,id_cart:simplyin.order.id_cart},dataType:"json"}).done(e=>{e.success})},loadPhoneCountries:function(){let e=this;$.getJSON(simplyin.files_url+"views/json/phones.json",function(i){e.phones=i})},validatePhoneNumber:function(e=!1){let i=this,t=$("#simplyin-phone-checkbox .phone-input input");if(t.length==0)return!0;let s=t.val().replace(/\D/g,""),n=$("#simplyin-phone-checkbox #simplyin-phone-country").find("option:selected").data("prefix"),o=i.phones.find(d=>d.country_code===n),l=o.phone_number_lengths.includes(s.length),a=o.mobile_begin_with.some(d=>s.startsWith(d)),p=n+s,r="";return a?r=s.replace(/(\d{3})(\d{3})(\d{3})/,"$1 $2 $3"):r=s.replace(/(\d{2})(\d{3})(\d{2})(\d{2})/,"$1 $2 $3 $4"),$(t).val(r),!l||!o||!a?(i.showValidateWarningMessage(e),!1):(i.hideValidateWarningMessage(),!0)},showValidateWarningMessage:function(e=!1){e?$("#simplyin-phone-checkbox .phone-input-warning").hide().fadeIn():$("#simplyin-phone-checkbox .phone-input-warning").show()},hideValidateWarningMessage:function(){$("#simplyin-phone-checkbox .phone-input-warning").hide()},bindNewAccountEvent:function(){let e=this,i=document.querySelector("#payment-confirmation button");if(!i)return;let t=s=>{if(!e.validatePhoneNumber(!0))return s.preventDefault(),s.stopPropagation(),s.stopImmediatePropagation(),!1};i._simplyinNewAccountHandler&&i.removeEventListener("click",i._simplyinNewAccountHandler,{capture:!0}),i.addEventListener("click",t,{capture:!0}),i._simplyinNewAccountHandler=t},unbindNewAccountEvent:function(){let e=document.querySelector("#payment-confirmation button");!e||!e._simplyinNewAccountHandler||(e.removeEventListener("click",e._simplyinNewAccountHandler,{capture:!0}),e._simplyinNewAccountHandler=null)},storeNewAccountDetails:function(e){let i=$("#simplyin-phone-checkbox .phone-input input").val(),t=$("#simplyin-phone-checkbox #simplyin-phone-country").find("option:selected").data("prefix"),s=i.replace(/\D/g,""),n=t+" "+s,o={action:"storeNewAccountDetails",ajax:1,ajax_token:simplyin.ajax_token,phone:e?n:0};$.ajax({url:SimplyIn.ajax,method:"POST",data:o,dataType:"json"}).done(l=>{})},initEventListenersNewAccount:function(){let e=this;e.initialized_new_account_events||typeof SimplyInPhoneCheckboxManager<"u"&&(e.phoneCheckboxManager=new SimplyInPhoneCheckboxManager({checkoutType:"classic",emailFieldSelector:'#customer-form input[name="email"]',containerSelector:"#checkout-payment-step .payment-options",ajaxUrl:e.ajax,ajaxToken:simplyin.ajax_token,debug:!1}),e.initialized_new_account_events=!0,$(document).off("change.simplyin blur.simplyin",'input[name="phone"]'),$(document).on("change.simplyin blur.simplyin",'input[name="phone"]',function(){var i=$("#simplyin-phone-checkbox .phone-input input");if(!($(this).closest("#simplyin-phone-checkbox").length>0)&&i.length){let o=$(this).val();if(e.phoneCheckboxManager&&typeof e.phoneCheckboxManager.removeCountryPrefix=="function"){var t=e.phoneCheckboxManager.removeCountryPrefix(o),s=t.replace(/\D/g,""),n=e.phoneCheckboxManager.getMaxPhoneLengthForSelectedCountry();i.val(s.substring(0,n)),e.phoneCheckboxManager.validatePhoneNumber(),e.phoneCheckboxManager.storePhoneNumber()}else e.phoneCheckboxManager&&typeof e.phoneCheckboxManager.parseAndSetPhoneNumber=="function"?e.phoneCheckboxManager.parseAndSetPhoneNumber(o):o.indexOf("+")!==0&&i.val(o)}}))},initDhlAssistantDisplay:function(){if(!(!simplyin.customer.point||simplyin.customer.point.label!=="dhl")){var e=simplyin.customer.point.locker_id;if(!(!e||e.trim()==="")){var i=simplyin.customer.point.address||"",t=simplyin.customer.point.address_name||e,s=t+(i?" "+i:"");this.waitForElement("#dhlassistant_messages .success.current-address",function(){$("#dhlassistant_messages .success.current-address").text(s).show(),$('button[name="confirmDeliveryOption"]').attr("disabled",!1)},2e4)}}},dpdshippingmodule:function(){if($(".dpdshipping-pudo-new-point").length&&simplyin.customer.point.label=="dpd"&&typeof dpdshippingSavePudoCode<"u"&&typeof dpdshipping_token<"u"&&typeof dpdshipping_csrf<"u"&&typeof dpdshipping_id_cart<"u"){let e={modal:function(t){}};dpdshippingSavePudoCode(simplyin.customer.point.locker_id,e);let i=$("span.dpdshipping-selected-point");dpdshippingGetPudoAddress(simplyin.customer.point.locker_id,i)}},furgonetkamodule:function(){let e=this;if(typeof furgonetkaMapCallback!="function"||!(simplyin.customer.point&&simplyin.customer.point.locker_id&&simplyin.customer.point.locker_id.trim()!==""))return;let t=function(){if($(".furgonetka-set-point").length){let s=simplyin.customer.point.label;s==="inpost"&&(s="paczkomat");let n=simplyin.id_carrier,o=document.getElementById("furgonetka-machine-"+n);if(o){let l=new MutationObserver(function(a){o.textContent.trim()!==""&&!o.classList.contains("furgonetka-hidden")&&($('.shipping-radio input[type="radio"][value="'+n+',"]').trigger("click"),l.disconnect())});l.observe(o,{childList:!0,attributes:!0,characterData:!0,subtree:!0}),setTimeout(function(){l.disconnect()},5e3)}furgonetkaMapCallback({code:simplyin.customer.point.locker_id,name:simplyin.customer.point.locker_id,type:s},n)}else requestAnimationFrame(t)};requestAnimationFrame(t)},authController:function(){let e=this,i='#login-form input[name="email"]',t="section.login-form";if($(i).length){if(e.barEnabled()){let s=$(t);s.length||(s=$(i).closest("form")),s.prepend(e.barHtml()),s.children(".simplyin-logo-container").first().addClass("simplyin-logo-container--login")}e.badgeEnabled()&&e.injectFieldBadge(i),e.email_login_field=$(i),customer_email=simplyin.customer_email,e.email_login_field.parent().append(`
                    <div class="simplyin-show-popup simplyin-show-popup-login">
                        <div class="simplyin-show-popup-icon">
                            <img width="30" height="30" src="${simplyin.files_url}/views/img/logo_smalln.svg"/>
                            <svg width="12" height="13" viewBox="0 0 12 13" fill="none" xmlns="http://www.w3.org/2000/svg">
                              <rect y="0.5" width="12" height="12" rx="6" fill="#33CC40"></rect>
                              <path d="M3.23096 6.54276L5.07711 8.38892L8.76942 4.38892" stroke="white" stroke-width="1.23077" stroke-linecap="round" stroke-linejoin="round"></path>
                            </svg>
                        </div>
                        <div class="simplyin-show-popup-edit">
                            <span>${simplyin.labels.data_completed}</span>
                            <div class="simplyin-show-popup-edit-bottom">
                              <span>${simplyin.labels.change}</span>
                              <svg width="14" height="15" viewBox="0 0 14 15" fill="none" xmlns="http://www.w3.org/2000/svg">
                                <path d="M8.41604 2.74719L8.97217 2.19107C9.89359 1.26964 11.3875 1.26964 12.3089 2.19107C13.2304 3.11249 13.2304 4.60641 12.3089 5.52783L11.7528 6.08396M8.41604 2.74719C8.41604 2.74719 8.48556 3.92897 9.5283 4.97171C10.571 6.01445 11.7528 6.08396 11.7528 6.08396M8.41604 2.74719L3.30329 7.85994C2.957 8.20624 2.78385 8.37939 2.63494 8.5703C2.45928 8.79551 2.30868 9.03919 2.18581 9.29701C2.08164 9.51558 2.00421 9.74789 1.84934 10.2125L1.3535 11.7M11.7528 6.08396L6.64006 11.1967C6.29376 11.543 6.12061 11.7162 5.9297 11.8651C5.70449 12.0407 5.46082 12.1913 5.20299 12.3142C4.98442 12.4184 4.75211 12.4958 4.28751 12.6507L2.8 13.1465M2.8 13.1465L1.8375 13.4673C1.60887 13.5435 1.35679 13.484 1.18638 13.3136C1.01596 13.1432 0.956457 12.8911 1.03267 12.6625L1.3535 11.7M2.8 13.1465L1.3535 11.7" stroke="#2D40F6" stroke-width="1.6"></path>
                              </svg>
                            </div>
                        </div>
                    </div>
                `),this.hideIconLogin(),e.email_login_field.parent().addClass("simplyin-display-flex"),$(document).on("input",i,function(){let s=!1;e.is_login&&e.customer_email!=$(this).val()&&(s=!0),e.customer_email=$.trim($(this).val()),e.submitEmailLogin(s)})}},submitEmailLogin:function(e){this.last_popup="";let i=this;if(this.is_login==!1||e){this.is_login=!1;var t=this.customer_email;if(!this.isValidEmailAddress(t)||i.login_request_send&&i.last_email==t||(i.is_login_page=!0,!this.isValidEmailAddress(t))||i.login_request_send&&i.last_email==t)return;var s={action:"submitEmail",login:1,ajax:1,ajax_token:simplyin.ajax_token,email:t,logout:e};i.login_request_send=!0,i.last_email=t,$.ajax({url:i.ajax,method:"POST",data:s,dataType:"json"}).done(n=>{n.success&&n.show_popup?(i.userUsedPushNotifications=n.userUsedPushNotifications,i.showPopupByContent(n.html),i.focusOnCode(),i.showIconLogin(),simplyin.hide_phone_field=!0,n.userUsedPushNotifications?i.checkPushNotification():i.codeStartCounting()):n.error=="NOT_FOUND"&&i.hideIconLogin()})}},hideIconLogin:function(){$(".simplyin-show-popup-login").hide()},showIconLogin:function(){$(".simplyin-show-popup-login").show()},selectCheckbox:function(){let e=this;if(e.select_customer_privacy&&$('input[name="customer_privacy"]').length&&$('input[name="customer_privacy"]').prop("checked",!0),e.select_psgdpr&&$('input[name="psgdpr"]').length&&$('input[name="psgdpr"]').prop("checked",!0),e.submit_guest_form)$("#customer-form").find('button[type="submit"]').trigger("click");else return!1}},simplyin.checkout=="classic"&&SimplyIn.init()});})();
