import{d as rt,f as I,x as mt,w as k,i as y,y as _t,h as u,G as F,L as D,I as wt,l as B,k as x,O as Ct,s as xt,r as c,z as Dt,a as Vt,B as M,g as b,F as R,j as r,K as St,m as w,S as q,T as K,V as At,C as j,t as m,W as $,J as at,a9 as nt,aa as ut,A as W,b as Ot,_ as $t}from"./index-N7CMQwFv.js";import{_ as Nt,P as Et}from"./myImg-B3XMH9SK.js";import{R as Rt}from"./replenishInventory-DC09iOKe.js";import{c as Ft}from"./product-C59H-sk9.js";import{N as Bt}from"./noData-IsWEUHkL.js";const ct={3:"Greeting Cards",4:"Jewelry Box",5:"Thank You Letter",6:"Brand Packaging Bags",7:"Jewelry Care Cloth",8:"Logo Sealing Sticker",9:"Inventory",10:"Certificate"},Ut={class:"d-flex justify-end"},zt={class:"d-flex justify-center align-center mt-10"},Jt={class:"btn-cancel"},Tt={class:"btn-save ml-5"},jt=rt({__name:"toAddAccessories",props:["toAddDialogVisible"],emits:["change:confirmJump","update:toAddDialogVisible"],setup(L,{emit:Y}){const h=L,V=Y,_=()=>{V("update:toAddDialogVisible",!1)},C=()=>{V("update:toAddDialogVisible",!1),V("change:confirmJump",!0)};return(p,g)=>(I(),mt(Ct,{modelValue:h.toAddDialogVisible,"onUpdate:modelValue":g[0]||(g[0]=S=>h.toAddDialogVisible=S),width:p.$vuetify.display.smAndDown?"auto":500,persistent:""},{default:k(()=>[y(_t,{class:"pa-6 pa-2 add-product-dialog"},{default:k(()=>[u("div",Ut,[y(F,{icon:"custom-close-line",onClick:D(_,["prevent"])})]),y(wt,{class:"pa-0"},{default:k(()=>[g[3]||(g[3]=u("h4",{class:"text-h4 text-center mb-5"}," Page redirection prompt ",-1)),g[4]||(g[4]=u("div",null," Do you want to leave this page and go to the attachments menu? ",-1)),u("div",zt,[u("div",Jt,[y(B,{variant:"outlined",color:"#6D788D",height:"42px",onClick:D(_,["prevent"])},{default:k(()=>g[1]||(g[1]=[x(" No,Cancel ")])),_:1,__:[1]})]),u("div",Tt,[y(B,{class:"text-none text-subtitle-1",color:"#7367f1",height:"42px",variant:"flat",onClick:D(C,["prevent"])},{default:k(()=>g[2]||(g[2]=[x(" Yes, Confirm ")])),_:1,__:[2]})])])]),_:1,__:[3,4]})]),_:1})]),_:1},8,["modelValue","width"]))}}),Yt={key:0,class:"d-flex justify-center"},Gt={key:0,class:"text-center pa-10 d-flex align-center justify-center flex-column"},Mt={key:0,class:"personalize-box mt-5"},qt={class:"personalize-title pa-2 pl-3 pr-3 d-flex justify-space-between align-center"},Kt=["onClick"],Wt={class:"d-flex justify-space-between align-center flex-wrap"},Ht={class:"d-flex align-center"},Qt={class:"position-relative my-img-box d-flex align-center justify-center flex-wrap"},Xt=["onClick"],Zt={class:"personalize-text ml-5"},te={class:""},ee={key:0,style:{"font-weight":"500"}},ie=["onClick"],oe={key:0,class:"personalize-box mt-5"},se={class:"personalize-title pa-2 pl-3 pr-3 d-flex justify-space-between align-center"},ae=["onClick"],ne={class:"d-flex justify-space-between align-center flex-wrap"},ue={class:"d-flex align-center"},ce={class:"my-img-box position-relative d-flex align-center justify-center"},re=["onClick"],le={class:"personalize-text ml-5"},de={class:""},ve={key:0,style:{"font-weight":"500"}},ge=["onClick"],fe={key:3,class:"d-flex align-center justify-space-between mt-5"},ye=rt({__name:"orderAndItemFittings",props:["productDetailId","isObject","type","onlyItem","onlyOrder","chooseItem","isCart"],emits:["change:addonData","change:previous","change:objectData","change:cartAccessories"],setup(L,{emit:Y}){const h=L,V=xt(),_=c({}),C=c({}),p=c([]),g=c([]),S=c(!0),H=async()=>{S.value=!0;const n={records:h.productDetailId},e=await Ft(n);await lt(e.data.skuLevelItemList),await dt(e.data.orderLevelItemList),vt(),await Pt(),S.value=!1};H();const lt=async n=>{const e=c(null),i=c(null),v=c(null),l=c(null),f=c(null),o=c(null),d=c(null),a=c(null);n.forEach(t=>{t.fittingsList.forEach(s=>{s.category2===3&&(e.value||(e.value={blankProductId:t.blankProductId,customProductId:t.customProductId,category2:s.category2,fittingsList:[]}),e.value.fittingsList.push(s)),s.category2===4&&(i.value||(i.value={blankProductId:t.blankProductId,customProductId:t.customProductId,category2:s.category2,fittingsList:[]}),i.value.fittingsList.push(s)),s.category2===5&&(v.value||(v.value={blankProductId:t.blankProductId,customProductId:t.customProductId,category2:s.category2,fittingsList:[]}),v.value.fittingsList.push(s)),s.category2===6&&(l.value||(l.value={blankProductId:t.blankProductId,customProductId:t.customProductId,category2:s.category2,fittingsList:[]}),l.value.fittingsList.push(s)),s.category2===7&&(f.value||(f.value={blankProductId:t.blankProductId,customProductId:t.customProductId,category2:s.category2,fittingsList:[]}),f.value.fittingsList.push(s)),s.category2===8&&(o.value||(o.value={blankProductId:t.blankProductId,customProductId:t.customProductId,category2:s.category2,fittingsList:[]}),o.value.fittingsList.push(s)),s.category2===9&&(d.value||(d.value={blankProductId:t.blankProductId,customProductId:t.customProductId,category2:s.category2,fittingsList:[]}),d.value.fittingsList.push(s)),s.category2===10&&(a.value||(a.value={blankProductId:t.blankProductId,customProductId:t.customProductId,category2:s.category2,fittingsList:[]}),a.value.fittingsList.push(s))})}),e.value&&(e.value.fittingsList=P(e.value.fittingsList),g.value.push(e.value)),i.value&&(i.value.fittingsList=P(i.value.fittingsList),g.value.push(i.value)),v.value&&(v.value.fittingsList=P(v.value.fittingsList),g.value.push(v.value)),l.value&&(l.value.fittingsList=P(l.value.fittingsList),g.value.push(l.value)),f.value&&(f.value.fittingsList=P(f.value.fittingsList),g.value.push(f.value)),o.value&&(o.value.fittingsList=P(o.value.fittingsList),g.value.push(o.value)),d.value&&(d.value.fittingsList=P(d.value.fittingsList),g.value.push(d.value)),a.value&&(a.value.fittingsList=P(a.value.fittingsList),g.value.push(a.value)),g.value.forEach((t,s)=>{A.value[s]=!0})},dt=async n=>{const e=c(null),i=c(null),v=c(null),l=c(null),f=c(null),o=c(null),d=c(null),a=c(null);n.forEach((t,s)=>{t.category2===3&&(e.value||(e.value={blankProductId:t.blankProductId,customProductId:t.customProductId,category2:t.category2,fittingsList:[]}),e.value.fittingsList.push(t)),t.category2===4&&(i.value||(i.value={blankProductId:t.blankProductId,customProductId:t.customProductId,category2:t.category2,fittingsList:[]}),i.value.fittingsList.push(t)),t.category2===5&&(v.value||(v.value={blankProductId:t.blankProductId,customProductId:t.customProductId,category2:t.category2,fittingsList:[]}),v.value.fittingsList.push(t)),t.category2===6&&(l.value||(l.value={blankProductId:t.blankProductId,customProductId:t.customProductId,category2:t.category2,fittingsList:[]}),l.value.fittingsList.push(t)),t.category2===7&&(f.value||(f.value={blankProductId:t.blankProductId,customProductId:t.customProductId,category2:t.category2,fittingsList:[]}),f.value.fittingsList.push(t)),t.category2===8&&(o.value||(o.value={blankProductId:t.blankProductId,customProductId:t.customProductId,category2:t.category2,fittingsList:[]}),o.value.fittingsList.push(t)),t.category2===9&&(d.value||(d.value={blankProductId:t.blankProductId,customProductId:t.customProductId,category2:t.category2,fittingsList:[]}),d.value.fittingsList.push(t)),t.category2===10&&(a.value||(a.value={blankProductId:t.blankProductId,customProductId:t.customProductId,category2:t.category2,fittingsList:[]}),a.value.fittingsList.push(t))}),e.value&&(e.value.fittingsList=P(e.value.fittingsList),p.value.push(e.value)),i.value&&(i.value.fittingsList=P(i.value.fittingsList),p.value.push(i.value)),v.value&&(v.value.fittingsList=P(v.value.fittingsList),p.value.push(v.value)),l.value&&(l.value.fittingsList=P(l.value.fittingsList),p.value.push(l.value)),f.value&&(f.value.fittingsList=P(f.value.fittingsList),p.value.push(f.value)),o.value&&(o.value.fittingsList=P(o.value.fittingsList),p.value.push(o.value)),d.value&&(d.value.fittingsList=P(d.value.fittingsList),p.value.push(d.value)),a.value&&(a.value.fittingsList=P(a.value.fittingsList),p.value.push(a.value)),p.value.forEach((t,s)=>{O.value[s]=!0})},vt=()=>{h.chooseItem&&(h.chooseItem.forEach(n=>{g.value.forEach(e=>{n.category2===e.category2&&e.fittingsList.forEach(i=>{n.customProductId===i.customProductId&&(_.value[n.category2]=i.customProductId)})})}),h.chooseItem.forEach(n=>{p.value.forEach(e=>{n.category2===e.category2&&e.fittingsList.forEach(i=>{n.customProductId===i.customProductId&&(C.value[n.category2]=i.customProductId)})})}))};function P(n){return n.filter((e,i,v)=>i===v.findIndex(l=>l.blankProductId===e.blankProductId&&l.category2===e.category2&&l.customProductId===e.customProductId))}const A=c([]),O=c([]),Q=c([]),X=c([]),N=c([]),G=async()=>{if(N.value=[],g.value.length){const n=g.value.reduce((e,i)=>{const v=i.fittingsList.find(l=>_.value[i.category2]===l.customProductId);return v&&e.push({blankProductId:v.blankProductId,customProductId:v.customProductId}),e},[]);Q.value=n,n.forEach(e=>{N.value.push(e.customProductId)})}if(p.value.length){const n=p.value.reduce((e,i)=>{const v=i.fittingsList.find(l=>C.value[i.category2]===l.customProductId);return v&&e.push({blankProductId:v.blankProductId,customProductId:v.customProductId}),e},[]);X.value=n,n.forEach(e=>{N.value.push(e.customProductId)})}if(h.isObject){It();return}},U=c(!1),Z=c({}),tt=c(0),et=n=>{Z.value=JSON.parse(JSON.stringify(n)),tt.value=n.customProductId,U.value=!0},gt=()=>{H()},ft=[n=>{p.value.forEach(e=>{e.fittingsList.forEach(i=>{if(i.customProductId===n){if(i.stockingStrategy===1)return;i.inventory<=0&&(delete C.value[e.category2],V.changeSnackbar({color:"#ff4c51",location:"top end",variant:"elevated",text:"Inventory is not enough !",visible:!0}))}})})}],yt=[n=>{g.value.forEach(e=>{e.fittingsList.forEach(i=>{if(i.customProductId===n){if(i.stockingStrategy===1)return;i.inventory<=0&&(delete _.value[e.category2],V.changeSnackbar({color:"#ff4c51",location:"top end",variant:"elevated",text:"Inventory is not enough !",visible:!0}))}})})}],E=Y,pt=async()=>{await G(),E("change:addonData",{fittingsSelect:N.value})},ht=()=>{E("change:previous")},It=()=>{h.type===2&&E("change:objectData",{itemAddonSelect:Q.value,orderAddonSelect:X.value,id:h.productDetailId}),h.type===3&&E("change:addonData",{fittingsSelect:N.value})},z=c(!1),it=c({}),ot=n=>{const e={productName:n.title,picturePreview:n.imageUrls};z.value=!0,it.value=JSON.parse(JSON.stringify(e))},J=c(!1),Pt=async()=>{h.onlyItem&&h.onlyOrder&&(!g.value||!g.value.length)&&(J.value=!0),h.onlyItem&&!h.onlyOrder&&(!g.value||!g.value.length)&&(!p.value||!p.value.length)&&(J.value=!0),!h.onlyItem&&!h.onlyOrder&&(!p.value||!p.value.length)&&(J.value=!0)},bt=Ot(),T=c(!1),Lt=()=>{if(h.isCart){E("change:cartAccessories");return}else T.value=!0},kt=()=>{bt.push({name:"brand-services"})},st=Dt(()=>n=>{const e=localStorage.getItem("ChooseCurrency"),i=JSON.parse(e),l=Vt().$state.currentData,f=c(0),o=n||0;return l.currencyRate?(f.value=new M(o).times(l.currencyRate).toNumber(),`${l.name} ${f.value}`):i&&i.currencyRate?(f.value=new M(o).times(i.currencyRate).toNumber(),`${i.name} ${f.value}`):(f.value=new M(o).times(1).toNumber(),`$ ${f.value}`)});return(n,e)=>{const i=Nt,v=Rt,l=Et,f=jt;return I(),b(R,null,[r(S)?(I(),b("div",Yt,[y(St,{class:"mr-3",indeterminate:"",size:20,width:2})])):w("",!0),q(u("div",null,[r(J)?(I(),b("div",Gt,[y(At,{class:"nodata-img",src:r(Bt)},null,8,["src"]),y(B,{variant:"text",onClick:Lt,"append-icon":"custom-arrow-right-s-line"},{default:k(()=>e[3]||(e[3]=[x(" To Add Attachment ")])),_:1,__:[3]})])):w("",!0),L.onlyItem&&L.onlyOrder||L.onlyItem&&!L.onlyOrder?(I(!0),b(R,{key:1},j(r(g),(o,d)=>(I(),b("div",{key:d},[o.fittingsList.length?(I(),b("div",Mt,[u("div",qt,[u("div",null,m(o.fittingsList.length?("category2"in n?n.category2:r(ct))[o.category2]:""),1),u("div",{class:"cursor-pointer",onClick:a=>r(A)[d]=!r(A)[d]},[x(m(r(_)[o.category2]?"Checked":"Unchecked")+" ",1),y(F,{class:"cursor-pointer ml-2",icon:"tabler-chevron-down",color:"#000000",style:$({transform:r(A)[d]?"rotate(-180deg)":void 0})},null,8,["style"])],8,Kt)]),u("div",{class:at(["overflow-y-auto",r(A)[d]?"pa-5":""])},[y(nt,null,{default:k(()=>[q(u("div",{style:$(o.fittingsList.length>4?"height: 300px;":`'height: ${o.fittingsList.length*80}px;'`)},[(I(!0),b(R,null,j(o.fittingsList,(a,t)=>(I(),b("div",{class:"d-flex justify-space-between align-center mb-5 flex-wrap",key:t},[y(ut,{modelValue:r(_)[o.category2],"onUpdate:modelValue":[s=>r(_)[o.category2]=s,G],"true-icon":"custom-radio-button-fill","false-icon":"custom-checkbox-blank-circle-line",value:a.customProductId,rules:yt},{label:k(()=>[u("div",Wt,[u("div",Ht,[u("div",Qt,[y(i,{src:a.mainImageUrl,height:60,width:60},null,8,["src"]),u("div",{class:"pointer-img position-absolute cursor-pointer",onClick:D(s=>ot(a),["prevent"])},[y(F,{icon:"custom-zoom-in-line",color:"#ffffff",width:20})],8,Xt)]),u("div",Zt,[u("div",te,m(a.title),1),u("div",null,"( "+m(a.price&&a.price!==0?r(st)(a.price):"Free")+" ) ",1)])])])]),_:2},1032,["modelValue","onUpdate:modelValue","value"]),a.stockingStrategy===2?(I(),b("div",ee,[u("div",null,"Your Inventory "+m(a.inventory)+" Pic",1),u("div",{class:"cursor-pointer text-decoration-underline",style:$(a.inventory>0?"":"color: #F44336;"),onClick:D(s=>et(a),["stop"])}," To Replenish Inventory ",12,ie)])):w("",!0)]))),128))],4),[[K,r(A)[d]]])]),_:2},1024)],2)])):w("",!0)]))),128)):w("",!0),L.onlyItem&&!L.onlyOrder||!L.onlyItem&&!L.onlyOrder?(I(!0),b(R,{key:2},j(r(p),(o,d)=>(I(),b("div",{key:d},[o.fittingsList.length?(I(),b("div",oe,[u("div",se,[u("div",null,m(("category2"in n?n.category2:r(ct))[o.category2]),1),u("div",{class:"cursor-pointer",onClick:a=>r(O)[d]=!r(O)[d]},[x(m(r(C)[o.category2]?"Checked":"Unchecked")+" ",1),y(F,{class:"cursor-pointer ml-2",icon:"tabler-chevron-down",color:"#000000",style:$({transform:r(O)[d]?"rotate(-180deg)":void 0})},null,8,["style"])],8,ae)]),u("div",{class:at(["overflow-y-auto",r(O)[d]?"pa-5":""])},[y(nt,null,{default:k(()=>[q(u("div",{style:$(o.fittingsList.length>4?"height: 300px;":`'height: ${o.fittingsList.length*80}px;'`)},[(I(!0),b(R,null,j(o.fittingsList,(a,t)=>(I(),b("div",{class:"d-flex justify-space-between align-center mb-5 flex-wrap",key:t},[y(ut,{modelValue:r(C)[o.category2],"onUpdate:modelValue":[s=>r(C)[o.category2]=s,G],"true-icon":"custom-radio-button-fill","false-icon":"custom-checkbox-blank-circle-line",value:a.customProductId,rules:ft},{label:k(()=>[u("div",ne,[u("div",ue,[u("div",ce,[y(i,{src:a.mainImageUrl,height:60,width:60},null,8,["src"]),u("div",{class:"pointer-img position-absolute cursor-pointer",onClick:D(s=>ot(a),["prevent"])},[y(F,{icon:"custom-zoom-in-line",color:"#ffffff",width:20})],8,re)]),u("div",le,[u("div",de,m(a.title),1),u("div",null,"( "+m(a.price&&a.price!==0?r(st)(a.price):"Free")+" ) ",1)])])])]),_:2},1032,["modelValue","onUpdate:modelValue","value"]),a.stockingStrategy===2?(I(),b("div",ve,[u("div",null,"Your Inventory "+m(a.inventory)+" Pic",1),u("div",{class:"cursor-pointer text-decoration-underline",style:$(a.inventory>0?"":"color: #F44336;"),onClick:D(s=>et(a),["stop"])}," To Replenish Inventory ",12,ge)])):w("",!0)]))),128))],4),[[K,r(O)[d]]])]),_:2},1024)],2)])):w("",!0)]))),128)):w("",!0),L.isObject?w("",!0):(I(),b("div",fe,[y(B,{variant:"outlined",color:"#6D788D",height:"42px",onClick:ht},{default:k(()=>e[4]||(e[4]=[x(" Previous ")])),_:1,__:[4]}),y(B,{variant:"flat",color:"#000000",height:"42px",onClick:pt},{default:k(()=>e[5]||(e[5]=[x(" Next ")])),_:1,__:[5]})]))],512),[[K,!r(S)]]),y(v,{"open-or-close-replenish-inventory-dialog-visible":r(U),"onUpdate:openOrCloseReplenishInventoryDialogVisible":e[0]||(e[0]=o=>W(U)?U.value=o:null),"item-inventory-data":r(Z),"is-fittings":!0,"item-inventory-id":r(tt),"onChange:confirmReplenishInventory":gt},null,8,["open-or-close-replenish-inventory-dialog-visible","item-inventory-data","item-inventory-id"]),y(l,{"picture-preview-dialog-visible":r(z),"onUpdate:picturePreviewDialogVisible":e[1]||(e[1]=o=>W(z)?z.value=o:null),"picture-data":r(it)},null,8,["picture-preview-dialog-visible","picture-data"]),y(f,{"to-add-dialog-visible":r(T),"onUpdate:toAddDialogVisible":e[2]||(e[2]=o=>W(T)?T.value=o:null),"onChange:confirmJump":kt},null,8,["to-add-dialog-visible"])],64)}}}),Le=$t(ye,[["__scopeId","data-v-7c470cbe"]]);export{Le as O};