"use strict";const e=require("../../../common/vendor.js"),r=require("../../index.js"),o=require("../../hooks/useGoods.js");if(require("../../url/index.js"),require("../../store/index.js"),require("../../store/app.js"),require("../../api/promotion/diy.js"),require("../../request/index.js"),require("../../config/index.js"),require("../../platform/index.js"),require("../../platform/provider/wechat/index.js"),require("../../platform/provider/wechat/miniProgram.js"),require("../../api/member/auth.js"),require("../../api/member/social.js"),require("../../api/member/user.js"),require("../../platform/provider/apple/index.js"),require("../../platform/share.js"),require("../../router/index.js"),require("../../hooks/useModal.js"),require("../../helper/index.js"),require("../../helper/test.js"),require("../../helper/digit.js"),require("../../api/member/signin.js"),require("../../helper/throttle.js"),require("../../platform/pay.js"),require("../../api/pay/order.js"),require("../../store/user.js"),require("../../store/cart.js"),require("../../api/trade/cart.js"),require("../../api/pay/wallet.js"),require("../../api/trade/order.js"),require("../../api/promotion/coupon.js"),require("../../store/sys.js"),require("../../store/modal.js"),require("../../config/zIndex.js"),require("../../util/index.js"),!Array){(e.resolveComponent("su-number-box")+e.resolveComponent("su-popup"))()}Math||((()=>"../../ui/su-number-box/su-number-box.js")+(()=>"../../ui/su-popup/su-popup.js"))();const t={__name:"s-select-groupon-sku",props:{show:{type:Boolean,default:!1},goodsInfo:{type:Object,default(){}},grouponAction:{type:String,default:"create"},grouponNum:{type:[Number,String],default:0}},emits:["change","addCart","buy","close","ladder"],setup(t,{emit:u}){e.useCssVars((r=>({"7fc47f57":e.unref(s)})));const s=r.sheep.$url.css("/static/images/groupon-btn-long.png"),i=u,n=t,a=e.reactive({selectedSku:{},currentPropertyArray:[],grouponNum:n.grouponNum}),p=o.convertProductPropertyList(n.goodsInfo.skus),c=e.computed((()=>{let e=n.goodsInfo.skus;for(let r of e)r.value_id_array=r.properties.map((e=>e.valueId));return e}));function d(){!a.selectedSku.id||a.selectedSku.id<=0?r.sheep.$helper.toast("请选择规格"):a.selectedSku.stock<=0?r.sheep.$helper.toast("库存不足"):i("buy",a.selectedSku)}function l(e=!1,r=0,o=0){let t=[];if(e)for(let i of c.value)i.stock<=0||i.value_id_array.indexOf(o)>=0&&t.push(i);else t=f();let u=[];for(let i of t)u=u.concat(i.value_id_array);if(u=Array.from(new Set(u)),e){let e=u.indexOf(o);u.splice(e,1)}else a.currentPropertyArray.forEach((e=>{if(""!==e.toString())return;let r=u.indexOf(e);r>=0&&u.splice(r,1)}));let s=[];e?s=[r]:a.currentPropertyArray.forEach(((e,r)=>{""!==e&&s.push(r)}));for(let i in p)if(!(s.indexOf(p[i].id)>=0))for(let e in p[i].values)p[i].values[e].disabled=u.indexOf(p[i].values[e].id)<0}function f(){let e=[];for(let r of c.value){if(r.stock<=0)continue;let o=!0;a.currentPropertyArray.forEach((e=>{""!==e.toString()&&r.value_id_array.indexOf(e)<0&&(o=!1)})),o&&e.push(r)}return e}return e.watch((()=>a.selectedSku),(e=>{i("change",e)}),{immediate:!0,deep:!0}),l(!1),(u,s)=>e.e({a:e.unref(r.sheep).$url.cdn(a.selectedSku.picUrl||t.goodsInfo.picUrl),b:e.unref(r.sheep).$url.static("/static/images/groupon-tag-white.png"),c:e.t(t.goodsInfo.name),d:e.t(e.unref(o.fen2yuan)(t.goodsInfo.price)),e:e.t(a.selectedSku.stock||t.goodsInfo.stock),f:e.f(e.unref(p),((r,o,t)=>({a:e.t(r.name),b:e.f(r.values,((o,t,u)=>({a:e.t(o.name),b:e.n({"checked-btn":a.currentPropertyArray[r.id]===o.id}),c:e.n({"disabled-btn":!0===o.disabled}),d:o.id,e:!0===o.disabled,f:e.o((e=>function(e,r){let o=!0;void 0!==a.currentPropertyArray[e]&&a.currentPropertyArray[e]===r?(o=!1,a.currentPropertyArray.splice(e,1,"")):a.currentPropertyArray[e]=r;let t=[];a.currentPropertyArray.forEach((e=>{""!==e&&t.push(e)}));let u=f();t.length===p.length&&u.length?(u[0].count=a.selectedSku.count||1,a.selectedSku=u[0]):a.selectedSku={},l(o,e,r)}(r.id,o.id)),o.id)}))),c:r.id}))),g:e.o((e=>{var r;0!==(r=e)&&a.selectedSku.count!==r&&(a.selectedSku.count=r)})),h:e.o((e=>a.selectedSku.count=e)),i:e.p({min:1,max:a.selectedSku.stock,step:1,activity:"groupon",modelValue:a.selectedSku.count}),j:e.t(t.grouponNum+"人团"),k:e.t(e.unref(o.fen2yuan)(t.goodsInfo.price)),l:"create"===t.grouponAction},("create"===t.grouponAction||t.grouponAction,{}),{m:"join"===t.grouponAction,n:e.o(d),o:e.o((e=>i("close"))),p:e.s(u.__cssVars()),q:e.p({show:t.show,round:"10"})})}},u=e._export_sfc(t,[["__scopeId","data-v-02f85066"]]);wx.createComponent(u);
