"use strict";
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
  for (var prop in b || (b = {}))
    if (__hasOwnProp.call(b, prop))
      __defNormalProp(a, prop, b[prop]);
  if (__getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(b)) {
      if (__propIsEnum.call(b, prop))
        __defNormalProp(a, prop, b[prop]);
    }
  return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __async = (__this, __arguments, generator) => {
  return new Promise((resolve, reject) => {
    var fulfilled = (value) => {
      try {
        step(generator.next(value));
      } catch (e) {
        reject(e);
      }
    };
    var rejected = (value) => {
      try {
        step(generator.throw(value));
      } catch (e) {
        reject(e);
      }
    };
    var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
    step((generator = generator.apply(__this, __arguments)).next());
  });
};
const common_vendor = require("../../../common/vendor.js");
const modules_mall_sheep_index = require("../sheep/index.js");
const _sfc_main = {
  __name: "addressSelection",
  props: {
    modelValue: {
      type: Object,
      default() {
      }
    }
  },
  emits: ["update:modelValue"],
  setup(__props, { emit: __emit }) {
    const props = __props;
    const emits = __emit;
    const state = common_vendor.computed({
      get() {
        return new Proxy(props.modelValue, {
          set(obj, name, val) {
            emits("update:modelValue", __spreadProps(__spreadValues({}, obj), {
              [name]: val
            }));
            return true;
          }
        });
      },
      set(val) {
        emits("update:modelValue", val);
      }
    });
    function onSelectAddress() {
      let emitName = "SELECT_ADDRESS";
      let addressPage = "/modules/mall/user/address/list?type=select";
      if (state.value.deliveryType === 2) {
        emitName = "SELECT_PICK_UP_INFO";
        addressPage = "/modules/mall/user/goods_details_store/index";
      }
      common_vendor.index.$once(emitName, (e) => {
        changeConsignee(e.addressInfo);
      });
      modules_mall_sheep_index.sheep.$router.go(addressPage);
    }
    function changeConsignee() {
      return __async(this, arguments, function* (addressInfo = {}) {
        if (!common_vendor.isEmpty(addressInfo)) {
          if (state.value.deliveryType === 1) {
            state.value.addressInfo = addressInfo;
          }
          if (state.value.deliveryType === 2) {
            state.value.pickUpInfo = addressInfo;
          }
        }
      });
    }
    const switchDeliveryType = (type) => {
      state.value.deliveryType = type;
    };
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: state.value.isPickUp
      }, state.value.isPickUp ? {
        b: common_vendor.n(state.value.deliveryType === 1 ? "on" : "on2"),
        c: common_vendor.o(($event) => switchDeliveryType(1))
      } : {}, {
        d: state.value.isPickUp
      }, state.value.isPickUp ? {
        e: common_vendor.n(state.value.deliveryType === 2 ? "on" : "on2"),
        f: common_vendor.o(($event) => switchDeliveryType(2))
      } : {}, {
        g: state.value.deliveryType === 1
      }, state.value.deliveryType === 1 ? common_vendor.e({
        h: state.value.addressInfo.name
      }, state.value.addressInfo.name ? common_vendor.e({
        i: common_vendor.t(state.value.addressInfo.name),
        j: common_vendor.t(state.value.addressInfo.mobile),
        k: state.value.addressInfo.defaultStatus
      }, state.value.addressInfo.defaultStatus ? {} : {}, {
        l: common_vendor.t(state.value.addressInfo.areaName),
        m: common_vendor.t(state.value.addressInfo.detailAddress)
      }) : {}, {
        n: common_vendor.o(onSelectAddress),
        o: common_vendor.s(state.value.isPickUp ? "" : "border-top-left-radius: 14rpx;border-top-right-radius: 14rpx;")
      }) : common_vendor.e({
        p: state.value.pickUpInfo.name
      }, state.value.pickUpInfo.name ? {
        q: common_vendor.t(state.value.pickUpInfo.name),
        r: common_vendor.t(state.value.pickUpInfo.phone),
        s: common_vendor.t(state.value.pickUpInfo.areaName),
        t: common_vendor.t(", " + state.value.pickUpInfo.detailAddress)
      } : {}, {
        v: common_vendor.o(onSelectAddress)
      }), {
        w: common_vendor.unref(modules_mall_sheep_index.sheep).$url.static("/static/images/line.png", "local"),
        x: common_vendor.s(state.value.isPickUp ? "" : "padding-top:10rpx;")
      });
    };
  }
};
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-1ea29242"]]);
wx.createComponent(Component);