/******/ (function() { // webpackBootstrap
/******/ 	"use strict";
/******/ 	var __webpack_modules__ = ({

/***/ 583:
/***/ (function(__unused_webpack_module, __unused_webpack___webpack_exports__, __webpack_require__) {


// EXTERNAL MODULE: ./node_modules/@vue/runtime-dom/dist/runtime-dom.esm-bundler.js
var runtime_dom_esm_bundler = __webpack_require__(751);
// EXTERNAL MODULE: ./node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js
var runtime_core_esm_bundler = __webpack_require__(641);
;// ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[3]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/App.vue?vue&type=template&id=aac48e26

function render(_ctx, _cache, $props, $setup, $data, $options) {
  const _component_Reminder = (0,runtime_core_esm_bundler/* resolveComponent */.g2)("Reminder");
  return (0,runtime_core_esm_bundler/* openBlock */.uX)(), (0,runtime_core_esm_bundler/* createBlock */.Wv)(_component_Reminder);
}
// EXTERNAL MODULE: ./node_modules/@vue/shared/dist/shared.esm-bundler.js
var shared_esm_bundler = __webpack_require__(33);
;// ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[3]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/components/Reminder.vue?vue&type=template&id=3d00452a&scoped=true

const _withScopeId = n => ((0,runtime_core_esm_bundler/* pushScopeId */.Qi)("data-v-3d00452a"), n = n(), (0,runtime_core_esm_bundler/* popScopeId */.jt)(), n);
const _hoisted_1 = {
  key: 0,
  class: "ss-banner-wrapper"
};
const _hoisted_2 = {
  id: "reminder"
};
const _hoisted_3 = {
  "test-id": "reminder-wraper"
};
const _hoisted_4 = {
  key: 0,
  class: "ss-banner"
};
const _hoisted_5 = {
  class: "ss-banner-top"
};
const _hoisted_6 = {
  class: "ss-logo-title"
};
const _hoisted_7 = ["src"];
const _hoisted_8 = /*#__PURE__*/_withScopeId(() => /*#__PURE__*/(0,runtime_core_esm_bundler/* createElementVNode */.Lk)("div", null, [/*#__PURE__*/(0,runtime_core_esm_bundler/* createElementVNode */.Lk)("span", {
  class: "ss-title"
}, "Shipping Protection"), /*#__PURE__*/(0,runtime_core_esm_bundler/* createElementVNode */.Lk)("span", {
  class: "ss-subtitle"
}, "by Ship-Safely")], -1));
const _hoisted_9 = {
  class: "ss-toggle-area"
};
const _hoisted_10 = {
  key: 0,
  class: "ss-toggle-wrap"
};
const _hoisted_11 = /*#__PURE__*/_withScopeId(() => /*#__PURE__*/(0,runtime_core_esm_bundler/* createElementVNode */.Lk)("label", {
  class: "shipsafe_tgl-btn",
  for: "shipsafe_checkbox"
}, null, -1));
const _hoisted_12 = ["src"];
const _hoisted_13 = {
  class: "ss-price-row"
};
const _hoisted_14 = {
  key: 0,
  class: "ss-price-label"
};
const _hoisted_15 = /*#__PURE__*/_withScopeId(() => /*#__PURE__*/(0,runtime_core_esm_bundler/* createElementVNode */.Lk)("span", {
  class: "ss-price-label"
}, "Protection for", -1));
const _hoisted_16 = {
  class: "ss-price"
};
const _hoisted_17 = {
  key: 2,
  class: "ss-price-label"
};
const _hoisted_18 = /*#__PURE__*/_withScopeId(() => /*#__PURE__*/(0,runtime_core_esm_bundler/* createElementVNode */.Lk)("div", {
  class: "ss-desc"
}, " Covers items that are lost, stolen or damaged during shipping. ", -1));
const _hoisted_19 = {
  key: 0,
  class: "ss-error"
};
const _hoisted_20 = {
  class: "ss-links"
};
const _hoisted_21 = /*#__PURE__*/_withScopeId(() => /*#__PURE__*/(0,runtime_core_esm_bundler/* createElementVNode */.Lk)("span", {
  class: "ss-link-dot"
}, "•", -1));
const _hoisted_22 = /*#__PURE__*/_withScopeId(() => /*#__PURE__*/(0,runtime_core_esm_bundler/* createElementVNode */.Lk)("a", {
  href: "https://ship-safely.com/terms",
  target: "_blank",
  class: "ss-link"
}, "Terms & Conditions", -1));
const _hoisted_23 = {
  key: 1,
  class: "ss-banner ss-limit-msg"
};
const _hoisted_24 = /*#__PURE__*/_withScopeId(() => /*#__PURE__*/(0,runtime_core_esm_bundler/* createElementVNode */.Lk)("span", null, "Apologies, we are unable to insure cart amounts larger than $5,000.", -1));
const _hoisted_25 = [_hoisted_24];
const _hoisted_26 = {
  class: "ss-popup"
};
const _hoisted_27 = ["src"];
const _hoisted_28 = /*#__PURE__*/_withScopeId(() => /*#__PURE__*/(0,runtime_core_esm_bundler/* createElementVNode */.Lk)("div", {
  class: "ss-popup-text"
}, " Ship-Safely is a policy designed for you and covers you in the event of your delivery being lost, stolen or damaged whilst in transit. Giving you an added level of comfort and security that your purchase is protected. ", -1));
function Remindervue_type_template_id_3d00452a_scoped_true_render(_ctx, _cache, $props, $setup, $data, $options) {
  return _ctx.isPluginEnabled === 'Active' && !_ctx.priceFailed ? ((0,runtime_core_esm_bundler/* openBlock */.uX)(), (0,runtime_core_esm_bundler/* createElementBlock */.CE)("div", _hoisted_1, [(0,runtime_core_esm_bundler/* createElementVNode */.Lk)("div", _hoisted_2, [(0,runtime_core_esm_bundler/* createElementVNode */.Lk)("div", _hoisted_3, [!_ctx.hitPriceLimitation ? ((0,runtime_core_esm_bundler/* openBlock */.uX)(), (0,runtime_core_esm_bundler/* createElementBlock */.CE)("div", _hoisted_4, [(0,runtime_core_esm_bundler/* createElementVNode */.Lk)("div", _hoisted_5, [(0,runtime_core_esm_bundler/* createElementVNode */.Lk)("div", _hoisted_6, [(0,runtime_core_esm_bundler/* createElementVNode */.Lk)("img", {
    src: $data.logoUrl,
    alt: "Ship-Safely",
    class: "ss-logo"
  }, null, 8, _hoisted_7), _hoisted_8]), (0,runtime_core_esm_bundler/* createElementVNode */.Lk)("div", _hoisted_9, [!_ctx.showSpinner ? ((0,runtime_core_esm_bundler/* openBlock */.uX)(), (0,runtime_core_esm_bundler/* createElementBlock */.CE)("div", _hoisted_10, [(0,runtime_core_esm_bundler/* withDirectives */.bo)((0,runtime_core_esm_bundler/* createElementVNode */.Lk)("input", {
    class: "shipsafe_tgl shipsafe_tgl-ios",
    id: "shipsafe_checkbox",
    type: "checkbox",
    onChange: _cache[0] || (_cache[0] = $event => $options.onInsuranceStatusChange(_ctx.event)),
    "onUpdate:modelValue": _cache[1] || (_cache[1] = $event => _ctx.isCartHasInsurance = $event)
  }, null, 544), [[runtime_dom_esm_bundler/* vModelCheckbox */.lH, _ctx.isCartHasInsurance]]), _hoisted_11])) : ((0,runtime_core_esm_bundler/* openBlock */.uX)(), (0,runtime_core_esm_bundler/* createElementBlock */.CE)("img", {
    key: 1,
    src: $data.loadingUrl,
    class: "ss-spinner",
    alt: "Loading"
  }, null, 8, _hoisted_12))])]), (0,runtime_core_esm_bundler/* createElementVNode */.Lk)("div", _hoisted_13, [(0,runtime_core_esm_bundler/* createElementVNode */.Lk)("div", {
    class: (0,shared_esm_bundler/* normalizeClass */.C4)(["ss-price-box", {
      'ss-price-box--loading': _ctx.isUpdatingPrice || _ctx.insurancePrice <= 0
    }])
  }, [_ctx.isUpdatingPrice ? ((0,runtime_core_esm_bundler/* openBlock */.uX)(), (0,runtime_core_esm_bundler/* createElementBlock */.CE)("span", _hoisted_14, "Updating price...")) : _ctx.insurancePrice > 0 ? ((0,runtime_core_esm_bundler/* openBlock */.uX)(), (0,runtime_core_esm_bundler/* createElementBlock */.CE)(runtime_core_esm_bundler/* Fragment */.FK, {
    key: 1
  }, [_hoisted_15, (0,runtime_core_esm_bundler/* createElementVNode */.Lk)("span", _hoisted_16, (0,shared_esm_bundler/* toDisplayString */.v_)(_ctx.insuranceCurrency) + " " + (0,shared_esm_bundler/* toDisplayString */.v_)(_ctx.insurancePrice), 1)], 64)) : ((0,runtime_core_esm_bundler/* openBlock */.uX)(), (0,runtime_core_esm_bundler/* createElementBlock */.CE)("span", _hoisted_17, "Calculating price..."))], 2)]), _hoisted_18, _ctx.cartError ? ((0,runtime_core_esm_bundler/* openBlock */.uX)(), (0,runtime_core_esm_bundler/* createElementBlock */.CE)("div", _hoisted_19, " ⚠️ " + (0,shared_esm_bundler/* toDisplayString */.v_)(_ctx.cartError), 1)) : (0,runtime_core_esm_bundler/* createCommentVNode */.Q3)("", true), (0,runtime_core_esm_bundler/* createElementVNode */.Lk)("div", _hoisted_20, [(0,runtime_core_esm_bundler/* createElementVNode */.Lk)("a", {
    onClick: _cache[2] || (_cache[2] = (...args) => $options.openPopup && $options.openPopup(...args)),
    class: "ss-link"
  }, "What's this?"), _hoisted_21, _hoisted_22])])) : ((0,runtime_core_esm_bundler/* openBlock */.uX)(), (0,runtime_core_esm_bundler/* createElementBlock */.CE)("div", _hoisted_23, _hoisted_25))])]), $data.showPopup ? ((0,runtime_core_esm_bundler/* openBlock */.uX)(), (0,runtime_core_esm_bundler/* createElementBlock */.CE)("div", {
    key: 0,
    class: "ss-popup-overlay",
    onClick: _cache[4] || (_cache[4] = (0,runtime_dom_esm_bundler/* withModifiers */.D$)((...args) => $options.closePopup && $options.closePopup(...args), ["self"]))
  }, [(0,runtime_core_esm_bundler/* createElementVNode */.Lk)("div", _hoisted_26, [(0,runtime_core_esm_bundler/* createElementVNode */.Lk)("img", {
    src: $data.minLogoUrl,
    class: "ss-popup-logo"
  }, null, 8, _hoisted_27), _hoisted_28, (0,runtime_core_esm_bundler/* createElementVNode */.Lk)("div", {
    class: "ss-popup-close",
    onClick: _cache[3] || (_cache[3] = (...args) => $options.closePopup && $options.closePopup(...args))
  }, " Got it. Thanks! ")])])) : (0,runtime_core_esm_bundler/* createCommentVNode */.Q3)("", true)])) : (0,runtime_core_esm_bundler/* createCommentVNode */.Q3)("", true);
}
;// ./src/components/Reminder.vue?vue&type=template&id=3d00452a&scoped=true

// EXTERNAL MODULE: ./node_modules/vuex/dist/vuex.esm-bundler.js + 4 modules
var vuex_esm_bundler = __webpack_require__(543);
;// ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/components/Reminder.vue?vue&type=script&lang=js

/* harmony default export */ var Remindervue_type_script_lang_js = ({
  name: "Reminder",
  computed: {
    ...(0,vuex_esm_bundler/* mapState */.aH)(["isCartHasInsurance", "isPluginEnabled", "insuranceId", "cartPrice", "insuranceCurrency", "insurancePrice", "cartInsurancePrice", "hitPriceLimitation", "showSpinner", "autoAddInsuranceToCart", "isUpdatingPrice", "priceFailed", "cartError"])
  },
  watch: {
    "$store.state.isUpdatingPrice": function (updating) {
      // Block the WooCommerce Place Order button while the insurance price is being recalculated
      const btn = document.getElementById('place_order');
      if (!btn) return;
      if (updating) {
        btn.disabled = true;
        btn.dataset.ssBlocked = 'true';
        btn.style.opacity = '0.5';
        btn.style.pointerEvents = 'none';
      } else if (btn.dataset.ssBlocked === 'true') {
        btn.disabled = false;
        delete btn.dataset.ssBlocked;
        btn.style.opacity = '';
        btn.style.pointerEvents = '';
      }
    },
    "$store.state.insuranceId": async function (val) {
      try {
        // Check cart state first before fetching new price
        let cartInsurancePrice = await this.getCartInsurance(val);
        let insuranceAlreadyInCart = cartInsurancePrice > 0;

        // If insurance is in cart, show loading immediately so user
        // never sees a mismatch between banner price and cart price
        if (insuranceAlreadyInCart) {
          this.$store.commit("cartHasInsurance", {
            has: true
          });
          this.$store.commit("setUpdatingPrice", {
            updating: true
          });
        }
        let insurancePrice = await this.getInsurancePrice({
          insuranceId: val,
          currency: this.insuranceCurrency
        });
        if (insuranceAlreadyInCart) {
          // Insurance is in the cart — remember this so we can detect external removal
          sessionStorage.setItem('shipsafely_was_in_cart', 'true');
          let diff = Math.abs(insurancePrice - cartInsurancePrice);
          if (diff > 0.02) {
            // Price changed by more than 2 cents - silently swap without toggling
            await this.updateInsuranceInCart({
              insuranceId: val
            });
            this.refreshForm();
          }
        } else if (this.autoAddInsuranceToCart && !this.$store.state.userOptedOut) {
          // Insurance is NOT in the cart — check if it was previously added
          if (sessionStorage.getItem('shipsafely_was_in_cart') === 'true') {
            // It was in the cart before but now it's gone — user removed it externally
            this.$store.commit("setUserOptedOut", {
              optedOut: true
            });
          } else if (insurancePrice && insurancePrice > 0) {
            // Never been in cart this session and we have a valid price — auto-add
            await this.addInsuranceToCart({
              insuranceId: val
            });
            sessionStorage.setItem('shipsafely_was_in_cart', 'true');
            this.refreshForm();
          }
          // If insurancePrice is 0/false (no price returned), skip auto-add silently
        }
      } catch (e) {
        console.error("Ship-Safely: insuranceId watcher failed", e);
      } finally {
        // Always release the button lock, no matter what went wrong
        this.$store.commit("setUpdatingPrice", {
          updating: false
        });
      }
    }
  },
  data() {
    return {
      storeMode: null,
      showPopup: false,
      logoUrl: window.url.plugin + "/ship-safely/public/dist/glyph-c.png",
      loadingUrl: window.url.plugin + "/ship-safely/public/dist/loading.gif",
      minLogoUrl: window.url.plugin + "/ship-safely/public/dist/logo-min-c.png"
    };
  },
  methods: {
    ...(0,vuex_esm_bundler/* mapActions */.i0)(["addInsuranceToCart", "removeInsuranceFromCart", "updateInsuranceInCart", "getCartInsurance", "getInsurancePrice", "getStoreData"]),
    async refreshForm() {
      if (window.jQuery) {
        window.jQuery('body').trigger('update_checkout');
      }
    },
    async onInsuranceStatusChange() {
      this.$store.commit("setCartError", {
        message: ''
      });
      if (this.isCartHasInsurance) {
        // User manually toggled off - remember this choice
        this.$store.commit("setUserOptedOut", {
          optedOut: true
        });
        await this.removeInsuranceFromCart();
        this.$store.commit("cartHasInsurance", {
          has: false
        });
        this.refreshForm();
      } else {
        // Before adding, check if insurance already exists in cart
        let existingPrice = await this.getCartInsurance(this.insuranceId);
        if (existingPrice > 0) {
          // Insurance exists but toggle was wrong - get current price and check if update needed
          let currentPrice = await this.getInsurancePrice({
            insuranceId: this.insuranceId,
            currency: this.insuranceCurrency
          });
          let diff = Math.abs(currentPrice - existingPrice);
          if (diff > 0.02) {
            // Price difference more than 2 cents - update
            await this.removeInsuranceFromCart();
            await this.addInsuranceToCart({
              insuranceId: this.insuranceId
            });
            this.refreshForm();
            // Wait for checkout to update before fetching price again
            await new Promise(res => setTimeout(res, 400));
          }
          // Set correct toggle state
          this.$store.commit("cartHasInsurance", {
            has: true
          });
        } else {
          // No existing insurance - add it
          this.$store.commit("setUserOptedOut", {
            optedOut: false
          });
          await this.addInsuranceToCart({
            insuranceId: this.insuranceId
          });
          this.refreshForm();
          // Wait for checkout to update before fetching price again
          await new Promise(res => setTimeout(res, 400));
          this.$store.commit("cartHasInsurance", {
            has: true
          });
        }
      }
    },
    isDevMode() {
      return this.storeMode === "dev";
    },
    openPopup() {
      this.showPopup = true;
    },
    closePopup() {
      this.showPopup = false;
    }
  },
  async mounted() {
    await this.getStoreData();
    // The insuranceId watcher handles cart state, pricing, and auto-add
  }
});
;// ./src/components/Reminder.vue?vue&type=script&lang=js
 
;// ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-12.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-12.use[1]!./node_modules/vue-loader/dist/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-12.use[2]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/components/Reminder.vue?vue&type=style&index=0&id=3d00452a&scoped=true&lang=css
// extracted by mini-css-extract-plugin

;// ./src/components/Reminder.vue?vue&type=style&index=0&id=3d00452a&scoped=true&lang=css

// EXTERNAL MODULE: ./node_modules/vue-loader/dist/exportHelper.js
var exportHelper = __webpack_require__(262);
;// ./src/components/Reminder.vue




;


const __exports__ = /*#__PURE__*/(0,exportHelper/* default */.A)(Remindervue_type_script_lang_js, [['render',Remindervue_type_template_id_3d00452a_scoped_true_render],['__scopeId',"data-v-3d00452a"]])

/* harmony default export */ var Reminder = (__exports__);
;// ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/App.vue?vue&type=script&lang=js

/* harmony default export */ var Appvue_type_script_lang_js = ({
  name: "App",
  components: {
    Reminder: Reminder
  }
});
;// ./src/App.vue?vue&type=script&lang=js
 
;// ./src/App.vue




;
const App_exports_ = /*#__PURE__*/(0,exportHelper/* default */.A)(Appvue_type_script_lang_js, [['render',render]])

/* harmony default export */ var App = (App_exports_);
;// ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[3]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/components/OrderSender.vue?vue&type=template&id=1036cd97

function OrderSendervue_type_template_id_1036cd97_render(_ctx, _cache, $props, $setup, $data, $options) {
  return (0,runtime_core_esm_bundler/* openBlock */.uX)(), (0,runtime_core_esm_bundler/* createElementBlock */.CE)("div");
}
;// ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/components/OrderSender.vue?vue&type=script&lang=js

/* harmony default export */ var OrderSendervue_type_script_lang_js = ({
  name: "OrderSender",
  components: {},
  props: {
    orderid: String
  },
  methods: {
    ...(0,vuex_esm_bundler/* mapActions */.i0)(["saveOrder"])
  },
  async mounted() {
    await this.saveOrder(this.orderid);
  }
});
;// ./src/components/OrderSender.vue?vue&type=script&lang=js
 
;// ./src/components/OrderSender.vue




;
const OrderSender_exports_ = /*#__PURE__*/(0,exportHelper/* default */.A)(OrderSendervue_type_script_lang_js, [['render',OrderSendervue_type_template_id_1036cd97_render]])

/* harmony default export */ var OrderSender = (OrderSender_exports_);
// EXTERNAL MODULE: ./node_modules/axios/lib/axios.js + 48 modules
var axios = __webpack_require__(335);
;// ./src/store/index.js


let API = axios/* default */.A.create({
  baseURL: window.url.API
});
let Plugin = axios/* default */.A.create({
  baseURL: `${window.url.context}/index.php/wp-json/shipsafely/v1`
});

// Credential is set in class-ship-safely-public.php
API.defaults.headers.common["Content-Type"] = "application/json";
API.defaults.headers.common["Authorization"] = "Bearer " + window.credential.token;
API.defaults.headers.common["Context"] = window.credential.context;
API.defaults.headers.common["ngrok-skip-browser-warning"] = "true";
Plugin.defaults.headers.post["Content-Type"] = "application/json";
Plugin.defaults.headers.common['X-WP-Nonce'] = window.credential.nonce; // this will make "global $current_user" valid in function 'wp_set_current_user', so REST API can work with logged in user's authentication.
Plugin.defaults.headers.common["ngrok-skip-browser-warning"] = "true";
if (false) // removed by dead control flow
{}
/* harmony default export */ var store = ((0,vuex_esm_bundler/* createStore */.y$)({
  state() {
    return {
      isShowSpinner: false,
      isCartHasInsurance: false,
      cartInsurancePrice: 0,
      isPluginEnabled: false,
      insuranceId: 0,
      cartPrice: 0,
      insurancePrice: 0,
      insuranceCurrency: 0,
      hitPriceLimitation: false,
      errors: {},
      storeMode: "prod",
      variation: "",
      testingUrl: null,
      autoAddInsuranceToCart: false,
      isUpdatingPrice: false,
      priceFailed: false,
      cartError: '',
      userOptedOut: sessionStorage.getItem('shipsafely_opted_out') === 'true'
    };
  },
  mutations: {
    showSpinner(state, {
      show = true
    }) {
      state.showSpinner = show;
    },
    setUpdatingPrice(state, {
      updating = false
    }) {
      state.isUpdatingPrice = updating;
    },
    setPriceFailed(state, {
      failed = false
    }) {
      state.priceFailed = failed;
    },
    setCartError(state, {
      message = ''
    }) {
      state.cartError = message;
    },
    setUserOptedOut(state, {
      optedOut = false
    }) {
      state.userOptedOut = optedOut;
      if (optedOut) {
        sessionStorage.setItem('shipsafely_opted_out', 'true');
      } else {
        sessionStorage.removeItem('shipsafely_opted_out');
      }
    },
    setVariation(state, {
      variation = null
    }) {
      state.variation = variation;
    },
    cartHasInsurance(state, {
      has = true
    }) {
      state.isCartHasInsurance = has;
    },
    setCartInsurancePrice(state, {
      price = 0
    }) {
      state.cartInsurancePrice = price;
    },
    setCartPrice(state, {
      price = 0
    }) {
      state.cartPrice = price;
    },
    setPriceLimitation(state, {
      hit = false
    }) {
      state.hitPriceLimitation = hit;
    },
    setInsurancePrice(state, {
      price = 0
    }) {
      state.insurancePrice = price;
    },
    setInsuranceCurrency(state, {
      currency = 0
    }) {
      state.insuranceCurrency = currency;
    },
    setInsuranceId(state, {
      insuranceId = 0
    }) {
      state.insuranceId = insuranceId;
    },
    setErrors(state, {
      errors
    }) {
      state.errors = errors;
    },
    setPluginStatus(state, {
      status = "Disabled"
    }) {
      state.isPluginEnabled = status;
    },
    setAppMode(state, {
      mode = "prod"
    }) {
      state.storeMode = mode;
    },
    setAutoAddInsuranceToCart(state, {
      auto = false
    }) {
      state.autoAddInsuranceToCart = auto;
    },
    setTestingUrl(state, {
      url = null
    }) {
      if (url) {
        console.log("/woocommerce/public/vue/src/store/index.js:102", url);
        window.url.API = url + '/api';
        API.defaults.baseURL = window.url.API;
        window.url.callback = url;
        state.testingUrl = url;
      }
    }
  },
  actions: {
    async getStoreData({
      commit
    }) {
      commit("setErrors", {
        errors: {}
      });
      try {
        commit("showSpinner", {
          show: true
        });
        let res = await API.get(`/v3/store/${encodeURIComponent(window.location.hostname)}`);
        if (res && res.data) {
          commit("setInsuranceId", {
            insuranceId: res.data.insurance_id
          });
          commit("setInsuranceCurrency", {
            currency: res.data.currency
          });
          commit("setAutoAddInsuranceToCart", {
            auto: res.data.auto_enable
          });
          return commit("setPluginStatus", {
            status: res.data.status
          });
        }
        commit("setPluginStatus", {
          status: false
        });
      } catch (e) {
        console.log("/woocommerce_plugin/public/vue/src/store/index.js:72", e.response.data);
        commit("setErrors", {
          errors: e.response.data
        });
        // alert(e.response.data ? (e.response.data.message ? e.response.data.message : e.response.data) : "Unknown error.");
      } finally {
        commit("showSpinner", {
          show: false
        });
      }
      return false;
    },
    async getCartInsurance({
      commit
    }, insuranceId) {
      if (insuranceId <= 0) {
        return false;
      }
      try {
        let res = await Plugin.post(`/cart/insurance/current`, {
          id: insuranceId
        });
        if (res && res.data !== "" && res.data > 0) {
          commit("setCartInsurancePrice", {
            price: res.data
          });
          return res.data;
        }
        return 0;
      } catch (e) {
        console.error("/woocommerce_plugin/public/vue/src/store/index.js", e.response.data);
        return 0;
      }
    },
    async getInsurancePrice({
      commit
    }, {
      insuranceId = 0,
      currency = "USD"
    }) {
      if (insuranceId <= 0) {
        return false;
      }
      commit("setErrors", {
        errors: {}
      });
      commit("setPriceLimitation", {
        hit: false
      });
      commit("setPriceFailed", {
        failed: false
      });
      try {
        commit("showSpinner", {
          show: true
        });
        let res = await Plugin.post(`/cart/price`, {
          id: insuranceId
        });
        if (res && res.data !== "") {
          commit("setCartPrice", {
            price: res.data
          });
          let price = await API.post("/v3/price", {
            amount: res.data,
            currency: currency
          });
          if (price && price.data && price.data.price != null && price.data.currency != null) {
            commit("setInsuranceCurrency", {
              currency: price.data.currency
            });
            commit("setInsurancePrice", {
              price: price.data.price
            });
            return price.data.price;
          }

          // Response missing price or currency — hide widget
          commit("setPriceFailed", {
            failed: true
          });
          return 0;
        }
        commit("setCartPrice", {
          price: 0
        });
        commit("setInsurancePrice", {
          price: 0
        });
        commit("setInsuranceCurrency", {
          currency: ""
        });
      } catch (e) {
        console.error("/woocommerce_plugin/public/vue/src/store/index.js", e.response ? e.response.data : e);
        if (e.response && e.response.status === 404) {
          commit("setPriceLimitation", {
            hit: true
          });
        }
        commit("setPriceFailed", {
          failed: true
        });
        commit("setErrors", {
          errors: e.response ? e.response.data : {}
        });
        // alert(e.response.data ? (e.response.data.message ? e.response.data.message : e.response.data) : "Unknown error.");
      } finally {
        commit("showSpinner", {
          show: false
        });
      }
      return false;
    },
    async removeInsuranceFromCart({
      commit,
      state
    }) {
      commit("setErrors", {
        errors: {}
      });
      try {
        commit("showSpinner", {
          show: true
        });
        await Plugin.delete(`/cart/insurance/${state.insuranceId}`);
        return true;
      } catch (e) {
        console.error("/woocommerce_plugin/public/vue/src/store/index.js", e.response.data);
        commit("setErrors", {
          errors: e.response.data
        });
        commit("cartHasInsurance", {
          has: true
        });
        // alert(e.response.data ? (e.response.data.message ? e.response.data.message : e.response.data) : "Unknown error.");
      } finally {
        commit("showSpinner", {
          show: false
        });
        commit("cartHasInsurance", {
          has: false
        });
      }
      return false;
    },
    async updateInsuranceInCart({
      commit,
      state
    }, {
      insuranceId
    }) {
      // Silently swap insurance (remove old + add new) without toggling the switch
      commit("setUpdatingPrice", {
        updating: true
      });
      try {
        // Remove the old one
        await Plugin.delete(`/cart/insurance/${insuranceId}`);

        // Add the new one with exact price from state
        await Plugin.put("/cart/insurance", {
          id: insuranceId,
          price: state.insurancePrice
        });
        return true;
      } catch (e) {
        console.error("/woocommerce_plugin/public/vue/src/store/index.js updateInsuranceInCart", e);
        return false;
      } finally {
        commit("setUpdatingPrice", {
          updating: false
        });
      }
    },
    async addInsuranceToCart({
      commit,
      dispatch,
      state
    }, {
      insuranceId
    }) {
      commit("setErrors", {
        errors: {}
      });

      // Never add a 0-price insurance product to the cart
      if (!state.insurancePrice || state.insurancePrice <= 0) {
        commit("cartHasInsurance", {
          has: false
        });
        return false;
      }
      try {
        commit("showSpinner", {
          show: true
        });

        // Check if insurance already exists in cart
        let existingPrice = await dispatch("getCartInsurance", insuranceId);
        if (existingPrice > 0) {
          // Insurance already exists, just update the state
          commit("cartHasInsurance", {
            has: true
          });
          commit("setCartInsurancePrice", {
            price: existingPrice
          });
          return true;
        }
        await Plugin.put("/cart/insurance", {
          id: insuranceId,
          price: state.insurancePrice
        });
        commit("setCartError", {
          message: ''
        });
        commit("cartHasInsurance", {
          has: true
        });
        return true;
      } catch (e) {
        console.error("/woocommerce_plugin/public/vue/src/store/index.js", e.response ? e.response.data : e);
        commit("setErrors", {
          errors: e.response ? e.response.data : {}
        });
        commit("cartHasInsurance", {
          has: false
        });

        // alert(e.response.data ? (e.response.data.message ? e.response.data.message : e.response.data) : "Unknown error.");
      } finally {
        commit("showSpinner", {
          show: false
        });
      }
      return false;
    },
    async saveOrder({
      commit
    }, orderId) {
      commit("setErrors", {
        errors: {}
      });
      try {
        commit("showSpinner", {
          show: true
        });
        await API.post(`/v3/order`, {
          context: window.location.hostname,
          id: orderId
        });
      } catch (e) {
        console.error("/woocommerce_plugin/public/vue/src/store/index.js", e.response.data);
        commit("setErrors", {
          errors: e.response.data
        });
        // alert(e.response.data ? (e.response.data.message ? e.response.data.message : e.response.data) : "Unknown error.");
      } finally {
        commit("showSpinner", {
          show: false
        });
      }
      return false;
    }
  },
  modules: {}
}));
;// ./src/main.js




(0,runtime_dom_esm_bundler/* createApp */.Ef)(App).use(store).mount("#nano_reminder");
const mountEl = document.querySelector("#nano_order_completed");
mountEl && (0,runtime_dom_esm_bundler/* createApp */.Ef)(OrderSender, {
  ...mountEl.dataset
}) // pass order id from dom to OrderSender component
.use(store).mount("#nano_order_completed");

/***/ })

/******/ 	});
/************************************************************************/
/******/ 	// The module cache
/******/ 	var __webpack_module_cache__ = {};
/******/ 	
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/ 		// Check if module is in cache
/******/ 		var cachedModule = __webpack_module_cache__[moduleId];
/******/ 		if (cachedModule !== undefined) {
/******/ 			return cachedModule.exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = __webpack_module_cache__[moduleId] = {
/******/ 			// no module.id needed
/******/ 			// no module.loaded needed
/******/ 			exports: {}
/******/ 		};
/******/ 	
/******/ 		// Execute the module function
/******/ 		__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/ 	
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/ 	
/******/ 	// expose the modules object (__webpack_modules__)
/******/ 	__webpack_require__.m = __webpack_modules__;
/******/ 	
/************************************************************************/
/******/ 	/* webpack/runtime/chunk loaded */
/******/ 	!function() {
/******/ 		var deferred = [];
/******/ 		__webpack_require__.O = function(result, chunkIds, fn, priority) {
/******/ 			if(chunkIds) {
/******/ 				priority = priority || 0;
/******/ 				for(var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) deferred[i] = deferred[i - 1];
/******/ 				deferred[i] = [chunkIds, fn, priority];
/******/ 				return;
/******/ 			}
/******/ 			var notFulfilled = Infinity;
/******/ 			for (var i = 0; i < deferred.length; i++) {
/******/ 				var chunkIds = deferred[i][0];
/******/ 				var fn = deferred[i][1];
/******/ 				var priority = deferred[i][2];
/******/ 				var fulfilled = true;
/******/ 				for (var j = 0; j < chunkIds.length; j++) {
/******/ 					if ((priority & 1 === 0 || notFulfilled >= priority) && Object.keys(__webpack_require__.O).every(function(key) { return __webpack_require__.O[key](chunkIds[j]); })) {
/******/ 						chunkIds.splice(j--, 1);
/******/ 					} else {
/******/ 						fulfilled = false;
/******/ 						if(priority < notFulfilled) notFulfilled = priority;
/******/ 					}
/******/ 				}
/******/ 				if(fulfilled) {
/******/ 					deferred.splice(i--, 1)
/******/ 					var r = fn();
/******/ 					if (r !== undefined) result = r;
/******/ 				}
/******/ 			}
/******/ 			return result;
/******/ 		};
/******/ 	}();
/******/ 	
/******/ 	/* webpack/runtime/define property getters */
/******/ 	!function() {
/******/ 		// define getter functions for harmony exports
/******/ 		__webpack_require__.d = function(exports, definition) {
/******/ 			for(var key in definition) {
/******/ 				if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ 					Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ 				}
/******/ 			}
/******/ 		};
/******/ 	}();
/******/ 	
/******/ 	/* webpack/runtime/global */
/******/ 	!function() {
/******/ 		__webpack_require__.g = (function() {
/******/ 			if (typeof globalThis === 'object') return globalThis;
/******/ 			try {
/******/ 				return this || new Function('return this')();
/******/ 			} catch (e) {
/******/ 				if (typeof window === 'object') return window;
/******/ 			}
/******/ 		})();
/******/ 	}();
/******/ 	
/******/ 	/* webpack/runtime/hasOwnProperty shorthand */
/******/ 	!function() {
/******/ 		__webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
/******/ 	}();
/******/ 	
/******/ 	/* webpack/runtime/make namespace object */
/******/ 	!function() {
/******/ 		// define __esModule on exports
/******/ 		__webpack_require__.r = function(exports) {
/******/ 			if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ 				Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ 			}
/******/ 			Object.defineProperty(exports, '__esModule', { value: true });
/******/ 		};
/******/ 	}();
/******/ 	
/******/ 	/* webpack/runtime/jsonp chunk loading */
/******/ 	!function() {
/******/ 		// no baseURI
/******/ 		
/******/ 		// object to store loaded and loading chunks
/******/ 		// undefined = chunk not loaded, null = chunk preloaded/prefetched
/******/ 		// [resolve, reject, Promise] = chunk loading, 0 = chunk loaded
/******/ 		var installedChunks = {
/******/ 			524: 0
/******/ 		};
/******/ 		
/******/ 		// no chunk on demand loading
/******/ 		
/******/ 		// no prefetching
/******/ 		
/******/ 		// no preloaded
/******/ 		
/******/ 		// no HMR
/******/ 		
/******/ 		// no HMR manifest
/******/ 		
/******/ 		__webpack_require__.O.j = function(chunkId) { return installedChunks[chunkId] === 0; };
/******/ 		
/******/ 		// install a JSONP callback for chunk loading
/******/ 		var webpackJsonpCallback = function(parentChunkLoadingFunction, data) {
/******/ 			var chunkIds = data[0];
/******/ 			var moreModules = data[1];
/******/ 			var runtime = data[2];
/******/ 			// add "moreModules" to the modules object,
/******/ 			// then flag all "chunkIds" as loaded and fire callback
/******/ 			var moduleId, chunkId, i = 0;
/******/ 			if(chunkIds.some(function(id) { return installedChunks[id] !== 0; })) {
/******/ 				for(moduleId in moreModules) {
/******/ 					if(__webpack_require__.o(moreModules, moduleId)) {
/******/ 						__webpack_require__.m[moduleId] = moreModules[moduleId];
/******/ 					}
/******/ 				}
/******/ 				if(runtime) var result = runtime(__webpack_require__);
/******/ 			}
/******/ 			if(parentChunkLoadingFunction) parentChunkLoadingFunction(data);
/******/ 			for(;i < chunkIds.length; i++) {
/******/ 				chunkId = chunkIds[i];
/******/ 				if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {
/******/ 					installedChunks[chunkId][0]();
/******/ 				}
/******/ 				installedChunks[chunkId] = 0;
/******/ 			}
/******/ 			return __webpack_require__.O(result);
/******/ 		}
/******/ 		
/******/ 		var chunkLoadingGlobal = self["webpackChunkvue"] = self["webpackChunkvue"] || [];
/******/ 		chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));
/******/ 		chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));
/******/ 	}();
/******/ 	
/************************************************************************/
/******/ 	
/******/ 	// startup
/******/ 	// Load entry module and return exports
/******/ 	// This entry module depends on other loaded chunks and execution need to be delayed
/******/ 	var __webpack_exports__ = __webpack_require__.O(undefined, [504], function() { return __webpack_require__(583); })
/******/ 	__webpack_exports__ = __webpack_require__.O(__webpack_exports__);
/******/ 	
/******/ })()
;