(()=>{"use strict";jQuery(function(t){t(".product form.cart").length&&function(t){var e=function(t){return new(Backbone.Model.extend({get_schemes_count:function(){var t=this.get("schemes"),e=0;for(var i in t)t.hasOwnProperty(i)&&e++;return e},get_active_scheme_key:function(){return this.get("active_scheme_key")},get_last_active_scheme_key:function(){return this.previous("active_scheme_key")},set_active_scheme:function(t){this.set({active_scheme_key:"0"!==t&&t})},set_schemes:function(t){this.set({schemes:t})},is_active_scheme_prorated:function(){return this.get_scheme_prop(this.get_active_scheme_key(),"is_prorated")},was_last_active_scheme_prorated:function(){return this.get_scheme_prop(this.get_last_active_scheme_key(),"is_prorated")},active_scheme_has_signup_fee:function(){var t=this.get_scheme_prop(this.get_active_scheme_key(),"signup_fee");return parseFloat(t)>0},last_active_scheme_had_signup_fee:function(){var t=this.get_scheme_prop(this.get_last_active_scheme_key(),"signup_fee");return parseFloat(t)>0},active_scheme_requires_upfront_charge:function(){return this.is_active_scheme_prorated()||this.active_scheme_has_signup_fee()},last_active_scheme_required_upfront_charge:function(){return this.was_last_active_scheme_prorated()||this.last_active_scheme_had_signup_fee()},get_scheme_prop:function(t,e){var i=this.get("schemes");return void 0===i[t]||void 0===i[t][e]?null:i[t][e]},initialize:function(){this.set({schemes:{},active_scheme_key:""})}}))(t)},i=function(e){return new(Backbone.View.extend({product:!1,$el_content:!1,$el_options:!1,$el_dropdown:!1,$el_prompt:!1,$el_option_items:!1,$el_option_inputs:!1,$el_button:!1,add_to_cart_button_text:!1,sign_up_button_text:!1,prompt_type:"",variation:!1,variation_options_render_location:"price_html",events:{"change select.wcsatt-options-product-dropdown":"dropdown_scheme_changed","change .wcsatt-options-prompt-action-input":"action_link_clicked","change .wcsatt-options-product-wrapper input":"active_scheme_changed",show_variation:"variation_found",reset_data:"reset_schemes"},action_link_clicked:function(t){var e=this.model,i="one-time"===this.get_prompt_val(),s=!1;if(e.get_active_scheme_key()){if(!i)return!1;e.set_active_scheme(!1),this.$el_option_inputs.filter('[value="0"]').prop("checked",!0),this.has_dropdown()&&this.$el_dropdown.val("0"),s=this.maybe_toggle_options()}else{if(i)return!1;var o=this.$el_option_inputs.filter(":checked");if("0"===o.val()){var a=this.$el_option_inputs.filter('[value!="0"]').first();a.prop("checked",!0).trigger("change"),this.has_dropdown()&&this.$el_dropdown.val(a.val())}else e.set_active_scheme(o.val()),this.has_dropdown()&&this.$el_dropdown.val(o.val());s=this.maybe_toggle_options()}if(!s)return!1},dropdown_scheme_changed:function(t){var e=this.$el_dropdown.val();this.$el_option_inputs.filter('[value="'+e+'"]').prop("checked",!0).trigger("change")},active_scheme_changed:function(t){this.model.set_active_scheme(t.currentTarget.value)},variation_found:function(t,e){this.$el.hasClass("variations_form")&&(this.variation=e,"before_add_to_cart_button"===this.variation_options_render_location&&this.$el_content.replaceWith(e.satt_options_html),this.initialize({$el_content:this.$el.find(".wcsatt-options-wrapper")}),"before_add_to_cart_button"===this.variation_options_render_location&&this.$el_option_inputs.length>1&&this.$el_content.slideDown(200))},variation_selected:function(){return!1!==this.variation},reset_schemes:function(){this.$el.hasClass("variations_form")&&(this.variation=!1,"before_add_to_cart_button"===this.variation_options_render_location&&this.$el_content.slideUp(200),this.model.set_schemes({}),this.model.set_active_scheme(!1))},has_schemes:function(){return this.$el_content.length>0},has_prompt:function(t){return this.$el_prompt.length>0&&(!t||t===this.get_prompt_type())},has_dropdown:function(){return this.$el_dropdown&&this.$el_dropdown.length>0},get_prompt_type:function(){return this.$el_prompt.data("prompt_type")},get_prompt_val:function(){var t=!1;return this.has_prompt("radio")||this.has_prompt("checkbox")?((this.has_prompt("checkbox")&&!1===this.$el_prompt.find(".wcsatt-options-prompt-action-input").is(":checked")||this.has_prompt("radio")&&this.$el_prompt.find('.wcsatt-options-prompt-action-input[value="no"]').is(":checked"))&&(t=!0),t?"one-time":"subscribe"):null},find_schemes:function(){var e={};return this.has_schemes()&&(this.$el_option_items=this.$el_options.find("li"),this.$el_option_inputs=this.$el_options.find("input"),this.$el_option_inputs.filter('[value!="0"]').each(function(){var i=t(this).data("custom_data");e[i.subscription_scheme.key]=i.subscription_scheme})),e},maybe_toggle_options:function(t){var e=this,i=(t=void 0!==t&&t)?0:200;if(!0===e.$el_content.data("animating"))return!1;if(e.$el_content.hasClass("closed")){if(e.$el_content.removeClass("closed").addClass("open"),e.model.get_schemes_count()<2)return e.$el_options.find(".wcsatt-options-product-dropdown, .wcsatt-options-product-dropdown-label").hide(),e.$el_options.show(),!0;t?e.$el_options.show():(e.$el_content.data("animating",!0),setTimeout(function(){e.$el_options.slideDown({duration:i,queue:!1,always:function(){e.$el_content.data("animating",!1)}})},10))}else t?e.$el_options.hide():(e.$el_content.data("animating",!0),setTimeout(function(){e.$el_options.slideUp({duration:i,queue:!1,always:function(){e.$el_content.data("animating",!1)}})},10)),e.$el_content.removeClass("open").addClass("closed");return!0},schemes_visible:function(){return this.$el_content.hasClass("open")},update_button_text:function(){this.model.get_active_scheme_key()?!this.model.get_last_active_scheme_key()&&this.sign_up_button_text&&this.$el_button.text(this.sign_up_button_text):this.model.get_last_active_scheme_key()&&this.$el_button.text(this.add_to_cart_button_text)},update_detail_lines:function(){var t=this.model.get_active_scheme_key(),e=this.model.get("schemes"),i=e&&t?e[t]:null;this.update_detail_line("trial",i&&i.trial_length>0&&i.trial_label?wcsatt_single_product_params.i18n_free_trial_label.replace("%s",i.trial_label):""),this.update_detail_line("signup-fee",i&&i.signup_fee>0&&i.signup_fee_formatted?wcsatt_single_product_params.i18n_signup_fee_label.replace("%s",i.signup_fee_formatted):"")},update_detail_line:function(e,i){var s="woocommerce-subscriptions-apfs-product__"+e,o=this.$el_options.find(".wcsatt-options-product-details"),a=o.find("."+s);i?(a.length||(a=t("<p>").addClass(s),o.append(a)),a.text(i)):a.remove()},initialize:function(t){if(this.variation_options_render_location=t.$el_content.hasClass("wcsatt-options-wrapper--variation")?"before_add_to_cart_button":"price_html",this.$el_content=t.$el_content,this.$el_options=t.$el_content.find(".wcsatt-options-product-wrapper"),this.$el_prompt=t.$el_content.find(".wcsatt-options-product-prompt"),this.$el_dropdown=t.$el_content.find(".wcsatt-options-product-dropdown"),this.model.set_schemes(this.find_schemes()),t.product&&(this.product=t.product,this.$el_button=t.product.$form.find(".single_add_to_cart_button").last(),this.add_to_cart_button_text=this.$el_button.text(),this.listenTo(this.model,"change:active_scheme_key",this.update_button_text),this.listenTo(this.model,"change:active_scheme_key",this.update_detail_lines)),this.has_schemes()){this.sign_up_button_text=this.$el_content.data("sign_up_text");var e=this.$el_option_inputs.filter('[value="'+this.model.get_active_scheme_key()+'"]');if(e.length>0?e.prop("checked",!0):this.$el_option_inputs.filter(":checked").trigger("change"),this.$el_option_inputs.length<=1&&this.$el_content.hide(),this.has_dropdown()&&(this.schemes_visible()?this.$el_options.show():this.$el_options.hide(),this.model.get_active_scheme_key()?(this.schemes_visible()||this.maybe_toggle_options(!0),this.has_prompt("checkbox")?this.$el_prompt.find(".wcsatt-options-prompt-action-input").prop("checked",!0):this.has_prompt("radio")&&this.$el_prompt.find('.wcsatt-options-prompt-action-input[value="yes"]').prop("checked",!0),this.$el_dropdown.val(this.model.get_active_scheme_key())):this.model.get_active_scheme_key()||(this.schemes_visible()&&this.maybe_toggle_options(!0),this.has_prompt("checkbox")?this.$el_prompt.find(".wcsatt-options-prompt-action-input").prop("checked",!1):this.has_prompt("radio")&&this.$el_prompt.find('.wcsatt-options-prompt-action-input[value="no"]').prop("checked",!0))),this.has_dropdown()){var i=this;setTimeout(function(){i.has_prompt("checkbox")?i.$el_prompt.find(".wcsatt-options-prompt-action-input").trigger("change"):i.$el_prompt.find(".wcsatt-options-prompt-action-input").filter(":checked").trigger("change")},10)}}else this.variation_selected()?this.model.set_active_scheme(null):this.model.set_active_scheme(!1)}}))(e)},s=function(e){return new(Backbone.Model.extend({product:!1,xhr:!1,cached_responses:{},set_scheme_key:function(t){this.set({scheme_key:t})},get_scheme_key:function(){return this.get("scheme_key")},get_matching_subscriptions_html:function(){var e=this,i=this.product.schemes_model.get_active_scheme_key();if(this.xhr&&this.xhr.abort(),i=!1===i?"0":i,void 0!==this.cached_responses[i])e.set({html:this.cached_responses[i]}),e.trigger("matching_subscriptions_loaded");else{var s={action:"wcsatt_load_subscriptions_matching_product",product_id:this.product.get_product_id(),subscription_scheme:i};this.xhr=t.post(wcsatt_single_product_params.wc_ajax_url.toString().replace("%%endpoint%%",s.action),s,function(t){"success"===t.result?(e.set({html:t.html}),e.cached_responses[s.subscription_scheme]=t.html):(e.set({html:!1}),e.attributes.scheme_key=!1),e.trigger("matching_subscriptions_loaded")})}},active_scheme_changed:function(){this.xhr&&this.xhr.abort()},initialize:function(t){this.product=t.product,this.set({scheme_key:"",html:!1}),this.listenTo(this.product.schemes_model,"change:active_scheme_key",this.active_scheme_changed),this.on("change:scheme_key",this.get_matching_subscriptions_html)}}))(e)},o=function(t){return new(Backbone.View.extend({$el_content:!1,product:!1,block_params:{message:null,fadeIn:0,fadeOut:0,overlayCSS:{background:"rgba(255, 255, 255, 0)",opacity:1}},events:{"click .wcsatt-add-to-subscription-action-input":"action_link_clicked"},action_link_clicked:function(){var t=this.model,e=this,i=!1;if(this.matching_subscriptions_visible()||this.model.get_scheme_key()===this.product.schemes_model.get_active_scheme_key()?i=this.toggle():(i=!0,this.$el.block(this.block_params),setTimeout(function(){t.set_scheme_key(e.product.schemes_model.get_active_scheme_key())},200)),!i)return!1},active_scheme_changed:function(){var t=this,e=!0;(!1===this.product.schemes_model.get_active_scheme_key()||this.product.schemes_model.active_scheme_requires_upfront_charge())&&(e=!1),e?(t.$el.hasClass("open")&&t.model.get_scheme_key()!==t.product.schemes_model.get_active_scheme_key()&&(t.$el.block(t.block_params),(!1===t.product.schemes_model.get_last_active_scheme_key()||this.product.schemes_model.last_active_scheme_required_upfront_charge())&&t.toggle(!0),setTimeout(function(){t.model.set_scheme_key(t.product.schemes_model.get_active_scheme_key())},250)),setTimeout(function(){t.$el.slideDown(200).removeClass("inactive").addClass("active")},50)):this.$el.slideUp(200).removeClass("active").addClass("inactive")},add_to_subscription_button_clicked:function(t){var e=t.data.view.product.$form.find(".single_add_to_cart_button").last();if(e.hasClass("disabled"))return e.click(),!1},toggle:function(t){var e=this,i=(t=void 0!==t&&t)?0:200;return!0!==e.$el.data("animating")&&(e.$el.hasClass("closed")?(setTimeout(function(){e.$el_content.slideDown({duration:i,queue:!1,always:function(){e.$el.data("animating",!1)}})},10),e.$el.removeClass("closed").addClass("open"),e.$el.data("animating",!0)):(setTimeout(function(){e.$el_content.slideUp({duration:i,queue:!1,always:function(){e.$el.data("animating",!1)}})},10),e.$el.removeClass("open").addClass("closed"),e.$el.data("animating",!0)),!0)},matching_subscriptions_visible:function(){return this.$el_content.is(":visible")},matching_subscriptions_loaded:function(){this.render()},render:function(){var t=this.model.get("html");this.$el.unblock(),!1===t?(window.alert(wcsatt_single_product_params.i18n_subs_load_error),this.matching_subscriptions_visible()&&this.toggle(),this.$el.find("input.wcsatt-add-to-subscription-action-input").prop("checked",!1)):(this.$el_content.html(t),this.matching_subscriptions_visible()||this.toggle())},initialize:function(t){this.product=t.product,this.$el_content=t.$el_content,this.listenTo(this.model,"matching_subscriptions_loaded",this.matching_subscriptions_loaded),this.listenTo(this.product.schemes_model,"change:active_scheme_key",this.active_scheme_changed),this.$el_content.on("click",".wcsatt-add-to-subscription-button",{view:this},this.add_to_subscription_button_clicked)}}))(t)},a=function(t){this.$form=t,this.schemes_model=!1,this.schemes_view=!1,this.matching_subscriptions_model=!1,this.matching_subscriptions_view=!1,this.initialize=function(){this.schemes_model=new e({product:this}),this.matching_subscriptions_model=new s({product:this}),this.schemes_view=new i({product:this,model:this.schemes_model,el:t,$el_content:t.find(".wcsatt-options-wrapper")}),this.matching_subscriptions_view=new o({product:this,model:this.matching_subscriptions_model,el:t.find(".wcsatt-add-to-subscription-wrapper"),$el_content:t.find(".wcsatt-add-to-subscription-options")}),-1!=window.location.href.indexOf("switch-subscription")&&-1!=window.location.href.indexOf("item")&&t.prop("action",""),t.on("submit",{view:this.schemes_view},this.form_submitted),this.pao=new n(this)},this.get_product_id=function(){return t.find(".wcsatt-add-to-subscription-wrapper").data("product_id")},this.form_submitted=function(t){var e=t.data.view;"one-time"===e.get_prompt_val()&&e.$el_option_inputs.filter('[value="0"]').prop("checked",!0)},this.round_number=function(t,e){var i=Math.pow(10,e),s=t*i;return Math.round(s)/i}},n=function(t){var e=this;this.$addons_totals=!1,this.$discount_addons_data=t.$form.find(".wcsatt-pao-data"),this.initialize=function(){if(!t.$form.hasClass("bundle_form")&&!t.$form.hasClass("composite_form")){var e=t.$form.find("#product-addons-total");if(e.length>0&&1==e.data("show-sub-total")){var i="yes"===this.$discount_addons_data.data("discount_addons");this.$addons_totals=e,i?(t.schemes_view.$el_content.insertAfter(e),e.addClass("subscription-details-hidden")):t.schemes_view.$el_content.insertBefore(t.$form.find(".wc-pao-addon-container").first()),i||(t.schemes_model.on("change:active_scheme_key",this.active_scheme_changed),t.$form.on("show_variation",this.variation_changed)),t.schemes_model.get_active_scheme_key()&&this.active_scheme_changed()}}},this.active_scheme_changed=function(){var i=!1===t.schemes_model.get_active_scheme_key()?"0":t.schemes_model.get_active_scheme_key(),s=t.schemes_view.$el_options.find('input[value="'+i+'"]').data("custom_data"),o=!!s&&s.display_price,a=!!s&&s.raw_price;!1!==o&&!1!==a&&(e.$addons_totals.data("price",o),e.$addons_totals.data("raw-price",a),t.$form.trigger("woocommerce-product-addons-update"))},this.variation_changed=function(){e.active_scheme_changed()},this.initialize()},c=function(t){if(!t.schemes_view.has_prompt("radio")&&!t.schemes_view.has_prompt("checkbox"))return null;var e=t.schemes_view.$el_prompt.find('.wcsatt-options-prompt-action-input[value="yes"]').closest(".wcsatt-options-prompt-label").find(".wcsatt-options-prompt-action");return e.find(".wcsatt-sub-discount").length>0?e:null},_=function(t,e,i){return"fixed_discount"===t.data.subscription_scheme.pricing_mode?i(e,!0):t.data.subscription_scheme.discount+"%"},r=function(e){var i=this,s=e.$bundle_form.data("satt_script");this.initialize_ui=function(){s.schemes_view.$el_content.length>0&&(!1!==e.$addons_totals?e.$addons_totals.after(s.schemes_view.$el_content):e.$bundle_price.after(s.schemes_view.$el_content))},this.initialize_schemes=function(){e.satt_schemes=[],e.satt_scheme_one_time=!1;var i=s.schemes_view.$el_option_items.filter(".one-time-option");i.length&&(e.satt_scheme_one_time={$el:i,data:i.find("input").data("custom_data")}),s.schemes_view.$el_option_items.filter(".subscription-option").each(function(){var i=t(this),s=i.find("input").data("custom_data");e.satt_schemes.push({$el:i,data:s})})},this.integrate=function(){s.schemes_view.has_schemes()&&(i.initialize_ui(),i.initialize_schemes(),e.satt_schemes.length>0&&(e.$bundle_data.on("woocommerce-product-bundle-updated-totals",i.update_subscription_totals),"no"!==e.price_data.hide_total_on_validation_fail&&e.$bundle_data.on("woocommerce-product-bundle-validation-status-changed",i.maybe_hide_subscription_options)))},this.has_single_forced_susbcription=function(){return 1===e.satt_schemes.length&&!1===e.satt_scheme_one_time},this.maybe_hide_subscription_options=function(){e.passes_validation()?i.has_single_forced_susbcription()||s.schemes_view.$el_content.slideDown(200):s.schemes_view.$el_content.slideUp(200)},this.update_subscription_totals=function(e,o){if(o.passes_validation()||"no"===o.price_data.hide_total_on_validation_fail){var a=o.get_price_html(),n=t(a).html();if(!1!==o.satt_scheme_one_time){var r=o.satt_scheme_one_time.$el.find(".price.one-time-price"),d=o.satt_scheme_one_time.data.option_details_html.replace(/%p/g,n);if(r.length&&r.html(d).find("span.total").remove(),s.schemes_view.has_prompt("radio")||s.schemes_view.has_prompt("checkbox")){var p=s.schemes_view.$el_prompt.find('.wcsatt-options-prompt-action-input[value="no"]').closest(".wcsatt-options-prompt-label").find(".wcsatt-options-prompt-action");p.find(".price").length>0&&p.html(o.satt_scheme_one_time.data.prompt_details_html.replace(/%p/g,n)).find("span.total").remove()}}if(i.has_single_forced_susbcription())o.$bundle_price.find(".price").html(o.satt_schemes[0].data.option_details_html.replace(/%p/g,n));else{var h=c(s),l=0,u=null;t.each(o.satt_schemes,function(e,c){if(c.data.option_has_price||s.schemes_view.has_prompt("radio")||s.schemes_view.has_prompt("checkbox")){var r=t.extend(!0,{},o.price_data),d=a,p=n;if(c.data.subscription_scheme.has_price_filter){if("inherit"===c.data.subscription_scheme.pricing_mode&&c.data.subscription_scheme.discount>0){t.each(o.bundled_items,function(t,e){var i=e.bundled_item_id;c.data.discount_from_regular?r.prices[i]=r.regular_prices[i]*(1-c.data.subscription_scheme.discount/100):(r.regular_prices[i]=r.prices[i],r.prices[i]=r.prices[i]*(1-c.data.subscription_scheme.discount/100)),r.addons_prices[i]=r.addons_prices[i]*(1-c.data.subscription_scheme.discount/100)}),c.data.discount_from_regular?r.base_price=r.base_regular_price*(1-c.data.subscription_scheme.discount/100):r.base_price=r.base_price*(1-c.data.subscription_scheme.discount/100);var m=o.get_addons_raw_price();r.addons_regular_price=o.has_addons()&&"yes"===s.pao.$discount_addons_data.data("discount_addons")?m:0,r.addons_price=o.has_addons()&&"yes"===s.pao.$discount_addons_data.data("discount_addons")?m*(1-c.data.subscription_scheme.discount/100):0}else"override"===c.data.subscription_scheme.pricing_mode&&(r.base_regular_price=Number(c.data.subscription_scheme.regular_price),r.base_price=Number(c.data.subscription_scheme.price));if(r=o.calculate_subtotals(!1,r),r=o.calculate_totals(r),"fixed_discount"===c.data.subscription_scheme.pricing_mode&&c.data.subscription_scheme.discount>0&&(r.totals.regular_price=r.totals.price,r.totals.price=Math.max(0,r.totals.price-c.data.subscription_scheme.discount)),d=o.get_price_html(r),p=t(d).html(),h){var f=Math.max(0,r.totals.regular_price-r.totals.price);f>l&&(l=f,u=_(c,f,wc_pb_price_format))}}var v=c.$el.find(".subscription-price"),g=c.data.option_details_html.replace(/%p/g,p);if(c.data.subscription_scheme.is_base&&(s.schemes_view.has_prompt("radio")||s.schemes_view.has_prompt("checkbox"))){var b=s.schemes_view.$el_prompt.find('.wcsatt-options-prompt-action-input[value="yes"]').closest(".wcsatt-options-prompt-label").find(".wcsatt-options-prompt-action");b.find(".subscription-price").length>0&&b.html(c.data.prompt_details_html.replace(/%p/g,p)).find("span.total").remove()}if(c.data.option_has_price&&(v.html(g).find("span.total").remove(),s.schemes_view.has_dropdown())){var w=wc_pb_price_format(r.totals.price,!0),$="";if(w=c.data.dropdown_format.replace("%p",w),c.data.subscription_scheme.has_price_filter)if("inherit"===c.data.subscription_scheme.pricing_mode&&c.data.subscription_scheme.discount>0)$=s.round_number(c.data.subscription_scheme.discount,c.data.dropdown_discount_decimals),w=c.data.dropdown_discounted_format.replace("%d",$).replace("%p",w);else if("fixed_discount"===c.data.subscription_scheme.pricing_mode&&c.data.dropdown_fixed_discounted_format)w=c.data.dropdown_fixed_discounted_format.replace("%p",w);else if(r.totals.regular_price>r.totals.price){var k=wc_pb_price_format(r.totals.regular_price,!0);w=c.data.dropdown_sale_format.replace("%r",k).replace("%p",w)}s.schemes_view.$el_dropdown.find("option[value="+c.data.subscription_scheme.key+"]").text(w)}v.trigger("wcsatt-updated-bundle-price",[d,c,o,i])}}),h&&u&&h.find(".wcsatt-sub-discount").html(u)}}},s&&this.integrate()},d=function(e){var i=this,s=e.$composite_form.data("satt_script");this.initialize_ui=function(){s.schemes_view.$el_content.length>0&&(!1!==e.composite_price_view.$addons_totals?e.composite_price_view.$addons_totals.after(s.schemes_view.$el_content):e.$composite_price.after(s.schemes_view.$el_content))},this.initialize_schemes=function(){e.satt_schemes=[],e.satt_scheme_one_time=!1;var i=s.schemes_view.$el_option_items.filter(".one-time-option");i.length&&(e.satt_scheme_one_time={$el:i,data:i.find("input").data("custom_data")}),s.schemes_view.$el_option_items.filter(".subscription-option").each(function(){var i=t(this),s=i.find("input").data("custom_data");e.satt_schemes.push({$el:i,data:s})})},this.integrate=function(){s.schemes_view.has_schemes()&&(i.initialize_schemes(),e.actions.add_action("initialize_composite",function(){i.initialize_ui(),e.satt_schemes.length>0&&(i.has_single_forced_susbcription()?e.filters.add_filter("composite_price_html",i.filter_price_html,10,i):(e.actions.add_action("composite_totals_changed",i.update_subscription_totals,101,i),"no"!==e.settings.hide_total_on_validation_fail&&(e.actions.add_action("composite_validation_status_changed",i.maybe_hide_subscription_options,101,i),e.actions.add_action("composite_initialized",i.maybe_hide_subscription_options,101,i))))},51,this))},this.has_single_forced_susbcription=function(){return 1===e.satt_schemes.length&&!1===e.satt_scheme_one_time},this.maybe_hide_subscription_options=function(){"pass"===e.api.get_composite_validation_status()?i.has_single_forced_susbcription()||s.schemes_view.$el_content.slideDown(200):s.schemes_view.$el_content.slideUp(200)},this.filter_price_html=function(i,s,o){var a=t(i).html();return'<p class="price">'+e.satt_schemes[0].data.option_details_html.replace(/%p/g,a)+"</p>"},this.update_subscription_totals=function(){if("pass"===e.api.get_composite_validation_status()||"no"===e.settings.hide_total_on_validation_fail){var o=e.composite_price_view.get_price_html(),a=e.data_model.calculate_totals(),n=t(o).html();if(!1!==e.satt_scheme_one_time){var r=e.satt_scheme_one_time.$el.find(".price.one-time-price"),d=e.satt_scheme_one_time.data.option_details_html.replace(/%p/g,n);if(r.length&&r.html(d).find("span.total").remove(),s.schemes_view.has_prompt("radio")||s.schemes_view.has_prompt("checkbox")){var p=s.schemes_view.$el_prompt.find('.wcsatt-options-prompt-action-input[value="no"]').closest(".wcsatt-options-prompt-label").find(".wcsatt-options-prompt-action");p.find(".price").length>0&&p.html(e.satt_scheme_one_time.data.prompt_details_html.replace(/%p/g,n)).find("span.total").remove()}}var h=c(s),l=0,u=null;t.each(e.satt_schemes,function(c,r){if(r.data.option_has_price||s.schemes_view.has_prompt("radio")||s.schemes_view.has_prompt("checkbox")){var d=t.extend(!0,{},e.data_model.price_data),p=o,m=n,f=a;if(r.data.subscription_scheme.has_price_filter){if(i.maybe_add_bundle_totals_filters(r),"inherit"===r.data.subscription_scheme.pricing_mode&&r.data.subscription_scheme.discount>0){t.each(e.get_components(),function(t,e){var i=e.component_id;r.data.discount_from_regular?d.prices[i]=d.regular_prices[i]*(1-r.data.subscription_scheme.discount/100):(d.regular_prices[i]=d.prices[i],d.prices[i]=d.prices[i]*(1-r.data.subscription_scheme.discount/100)),d.addons_prices[i]=d.addons_prices[i]*(1-r.data.subscription_scheme.discount/100)}),r.data.discount_from_regular?d.base_price=d.base_regular_price*(1-r.data.subscription_scheme.discount/100):d.base_price=d.base_price*(1-r.data.subscription_scheme.discount/100);var v=e.composite_price_view.get_addons_raw_price();d.addons_regular_price=e.composite_price_view.has_addons()&&"yes"===s.pao.$discount_addons_data.data("discount_addons")?v:0,d.addons_price=e.composite_price_view.has_addons()&&"yes"===s.pao.$discount_addons_data.data("discount_addons")?v*(1-r.data.subscription_scheme.discount/100):0}else"override"===r.data.subscription_scheme.pricing_mode&&(d.base_regular_price=Number(r.data.subscription_scheme.regular_price),d.base_price=Number(r.data.subscription_scheme.price));if(d=e.data_model.calculate_subtotals(!1,d),i.maybe_remove_bundle_totals_filters(r),f=e.data_model.calculate_totals(d),d.totals=f,"fixed_discount"===r.data.subscription_scheme.pricing_mode&&r.data.subscription_scheme.discount>0&&(d.totals.regular_price=d.totals.price,d.totals.price=Math.max(0,d.totals.price-r.data.subscription_scheme.discount)),p=e.composite_price_view.get_price_html(d),m=t(p).html(),h){var g=Math.max(0,d.totals.regular_price-d.totals.price);g>l&&(l=g,u=_(r,g,wc_cp_price_format))}}var b=r.$el.find(".subscription-price"),w=r.data.option_details_html.replace(/%p/g,m);if(r.data.subscription_scheme.is_base&&(s.schemes_view.has_prompt("radio")||s.schemes_view.has_prompt("checkbox"))){var $=s.schemes_view.$el_prompt.find('.wcsatt-options-prompt-action-input[value="yes"]').closest(".wcsatt-options-prompt-label").find(".wcsatt-options-prompt-action");$.find(".subscription-price").length>0&&$.html(r.data.prompt_details_html.replace(/%p/g,m)).find("span.total").remove()}if(r.data.option_has_price&&(b.html(w).find("span.total").remove(),s.schemes_view.has_dropdown())){var k=wc_cp_price_format(f.price,!0),y="";if(k=r.data.dropdown_format.replace("%p",k),r.data.subscription_scheme.has_price_filter)if("inherit"===r.data.subscription_scheme.pricing_mode&&r.data.subscription_scheme.discount>0)y=s.round_number(r.data.subscription_scheme.discount,r.data.dropdown_discount_decimals),k=r.data.dropdown_discounted_format.replace("%d",y).replace("%p",k);else if("fixed_discount"===r.data.subscription_scheme.pricing_mode&&r.data.dropdown_fixed_discounted_format)k=r.data.dropdown_fixed_discounted_format.replace("%p",k);else if(d.totals.regular_price>d.totals.price){var x=wc_cp_price_format(d.totals.regular_price,!0);k=r.data.dropdown_sale_format.replace("%r",x).replace("%p",k)}s.schemes_view.$el_dropdown.find("option[value="+r.data.subscription_scheme.key+"]").text(k)}b.trigger("wcsatt-updated-composite-price",[p,r,e,i])}}),h&&u&&h.find(".wcsatt-sub-discount").html(u)}},this.maybe_add_bundle_totals_filters=function(s){"inherit"===s.data.subscription_scheme.pricing_mode&&s.data.subscription_scheme.discount>0&&t.each(e.get_components(),function(t,e){if("bundle"===e.get_selected_product_type()){var o=e.get_bundle_script();o&&(o.satt_scheme=s,o.filters.add_filter("bundle_totals",i.filter_bundle_totals,10,i))}})},this.maybe_remove_bundle_totals_filters=function(s){"inherit"===s.data.subscription_scheme.pricing_mode&&s.data.subscription_scheme.discount>0&&t.each(e.get_components(),function(t,e){if("bundle"===e.get_selected_product_type()){var s=e.get_bundle_script();s&&(s.satt_scheme=!1,s.filters.remove_filter("bundle_totals",i.filter_bundle_totals))}})},this.filter_bundle_totals=function(e,i,s,o){if(!s.satt_scheme)return e;var a=s.satt_scheme.data,n=a.subscription_scheme.discount,c=t.extend(!0,{},i);return o=void 0===o?s.composite_data.component.get_selected_quantity():o,t.each(s.bundled_items,function(t,e){a.discount_from_regular?c.prices[e.bundled_item_id]=c.regular_prices[e.bundled_item_id]*(1-n/100):c.prices[e.bundled_item_id]=c.prices[e.bundled_item_id]*(1-n/100)}),c.base_price&&(a.discount_from_regular?c.base_price=Number(c.base_regular_price)*(1-n/100):c.base_price=Number(c.base_price)*(1-n/100)),s.satt_scheme=!1,c=s.calculate_subtotals(!1,c,o),(c=s.calculate_totals(c)).totals},this.integrate()};function p(){t(".product form.cart").each(function(){h(t(this))})}function h(t){var e;t.data("satt_script")||((e=new a(t)).initialize(),t.data("satt_script",e))}p(),t(".bundle_form .bundle_data").each(function(){t(this).on("woocommerce-product-bundle-initializing",function(t,e){e.is_composited()||new r(e)})}),t(".composite_form .composite_data").each(function(){t(this).on("wc-composite-initializing",function(t,e){new d(e)})}),t(document.body).on("wcsatt-initialize",function(){p()}),t.fn.wcsatt_initialize=function(){t(this).find(".product form.cart").each(function(){h(t(this))})}}(t),window.wcsatt_cart_params&&function(t){var e=t(document),i=t(document.body);e.on("change",".wcsatt-add-cart-to-subscription-action-input",function(){t("div.cart_totals");var e=t(this),i=e.closest(".wcsatt-add-cart-to-subscription-wrapper"),s=i.find(".wcsatt-add-cart-to-subscription-options");if(e.is(":checked")){i.block({message:null,overlayCSS:{background:"#fff",opacity:.6}});var o={add_to_subscription_checked:e.is(":checked")?"yes":"no",action:"wcsatt_load_subscriptions_matching_cart"};t.post(wcsatt_cart_params.wc_ajax_url.toString().replace("%%endpoint%%",o.action),o,function(t){"success"===t.result?(s.html(t.html),i.removeClass("closed"),i.addClass("open"),s.slideDown(200)):window.alert(wcsatt_cart_params.i18n_subs_load_error),i.unblock()})}else i.removeClass("open"),i.addClass("closed"),s.slideUp(200)}),e.on("click",".woocommerce-checkout .wcsatt-add-to-subscription-button",function(e){e.preventDefault();var s=t(this),o=s.closest(".wcsatt-add-cart-to-subscription-options"),a=t(".woocommerce-checkout form");a.block({message:null,overlayCSS:{background:"#fff",opacity:.6}});var n={"add-cart-to-subscription":parseInt(s.val(),10),"add-to-subscription-checked":"yes",action:"wcsatt_add_cart_to_subscription_from_checkout",wcsatt_nonce:o.find("#wcsatt_nonce").val()};t.post(wcsatt_cart_params.wc_ajax_url.toString().replace("%%endpoint%%",n.action),n,function(t){"success"===t.result?c(t.url)&&(location.href=t.url):i.trigger("update_checkout"),a.unblock()});var c=function(t){try{return new URL(t),!0}catch(t){return!1}}})}(t)})})();