Files
appco_dist/.output/public/_nuxt/CAZokKdz.js
T
2025-07-27 10:51:22 +03:30

2 lines
4.0 KiB
JavaScript

import{g as I,a as F}from"./wregT3CP.js";import{r as u,k as w,K,aH as g}from"./vNwORUzZ.js";const z=u(),p=u(!1),m=u(1);let c=[];const _=u(),v=u([]),b=u([]),N=u([]),T=u({url:void 0,index:0}),B=u(),C=u(),E=u([]),d=u([]),G=u([]),k=u([]),A=K({code:void 0,title_fa:"",title:"",brand_id:void 0,collection_id:void 0,price:0,body:"",discount:void 0,discount_type:void 0,is_show:!0,is_active:!0,box_size:0,sell_type:"numeric",original_image:"",count:void 0,display_price:void 0,product_attributes:[],meta:void 0,seo_title:void 0,description:void 0,files:[],variants:[],product_type:void 0,weight:void 0,rial_fee:void 0,percent_fee:void 0,price_type:"manual",auto_calculate:!1}),L=w(()=>{let e=g(N.value);return e==null||e.splice(0,0,T.value),e=e==null?void 0:e.map((t,a)=>t),console.log(e),e});function j(){var a,i;let e=[],t=[];(a=v.value)==null||a.forEach(r=>{r.valueId,e.push(r.valueId),t.push(r.valueName)}),console.log(e,v.value),(i=A.variants)==null||i.push({id:void 0,attribute_values:[],attribute_values_name:[],price:0,weight:0,stock:0,auto_calculate:!1,discount_type:void 0,discount:void 0,is_default:!1,sku:""})}function R(e,t){if(t==1)return;let a=e;m.value=1,b.value=[],v.value=[],console.log(e),console.log("why");let i=0,r=[];e==null||e.forEach((o,l)=>{var f,n,h;console.log(o,l),o.show_in_variable?(m.value=2,A.variants.length===0&&j(),b.value.push({attributeId:o.id,name:o.name,values:o.new_feature,show:o.show_in_variable,valueKey:l}),(f=o.new_feature)==null||f.forEach((s,H)=>{v.value.push({attributeName:o.name,attributeId:o.id,valueId:s.id,valueName:s.value,valueKey:i})})):(n=d.value)==null||n.forEach(s=>{console.log("val.attribute_values>",l),console.log(s.attribute_values),console.log("myAttributes.value.length "+a.length),console.log("val.attribute_values.length "+s.attribute_values.length),a.length>s.attribute_values.length&&s.attribute_values[l]!=null&&(s.attribute_values.length!=l?(s.attribute_values.splice(l,0,null),s.attribute_values_name.splice(l,0,null)):(s.attribute_values=[...s.attribute_values,null],s.attribute_values_name=[...s.attribute_values_name,null])),console.log("val.attribute_values After slice>"+l),console.log(s.attribute_values)}),i++,(h=d.value)==null||h.forEach(s=>{a.length>s.attribute_values.length&&s.attribute_values[l]!=null&&(s.attribute_values=[...s.attribute_values,null],s.attribute_values_name=[...s.attribute_values_name,null])}),r.push(l),console.log("variants+++")}),console.log("tempIndexArray"),console.log(r),D(d.value)}function D(e){console.log("444444",e),e==null||e.forEach((t,a)=>{c=g(t.attribute_values),b.value.length<=c.length&&(c==null||c.forEach((i,r)=>{var o;(o=v.value)==null||o.forEach((l,f)=>{c.find(n=>n==(l==null?void 0:l.valueId))&&t.attribute_values[l.valueKey]!=c.find(n=>n==l.valueId)&&(t.attribute_values[l.valueKey]=c.find(n=>n==l.valueId),t.attribute_values_name[l.valueKey]=l.valueName),console.log((t==null?void 0:t.attribute_values)+"AFTER CHANGE ITEM"+a)})})),a==0&&(_.value=y(t.attribute_values_name)),t.is_default&&(console.log("val.attribute_values",t.attribute_values_name),_.value=y(t.attribute_values_name),console.log("defaultVariant",_.value))})}function y(e){console.log(e,_.value);let t="";return e.forEach((a,i)=>{if(a)return t+=(i!==0?" - ":"")+a}),t}async function U(){try{p.value=!0,k.value=await F()}catch(e){console.log(e)}finally{p.value=!1}}async function J(e){let t;e[e.length-1]!=null&&(t=await I(e[e.length-1]));let a;a=t[0],Object.assign(a,{new_feature:[],show_in_product:!1,show_in_variable:!1}),E.value.push(a)}async function P(e){var i,r;const t=await I(e),a=E.value.find(o=>o.id===e);a&&(console.log(a.attribute_values,t[0].attribute_values),a.attribute_values=[],a.attribute_values=(i=t[0])!=null&&i.attribute_values?g((r=t[0])==null?void 0:r.attribute_values):[],console.log(a.attribute_values))}const Q=e=>(console.log("fsdfuygiuhguighuisdf",e),e.split("-")[0]==="edit"),S=u([]),W=u([]);export{S as a,Q as b,W as c,B as d,z as e,L as f,k as g,U as h,E as i,P as j,J as k,p as l,N as m,A as n,T as o,C as p,m as q,j as r,G as s,b as t,R as u,d as v,_ as w,y as x,v as y};