2025-07-27 10:51:22 +03:30
|
|
|
import{d as X,u as Y,G as ee,r as w,d2 as le,a1 as B,o as te,ak as ae,y as d,z as c,C as k,S as U,D as b,A as s,H as t,aj as O,B as p,a7 as E,bZ as se,a2 as $,a3 as oe,E as I,Q as ie}from"./vNwORUzZ.js";import{_ as ne}from"./CscEAC8U.js";import{C as V,a as R}from"./ppZ4gnC7.js";import{m as a,e as g,o as i,b as T,l as re,d as ue}from"./CAZokKdz.js";import{u as m}from"./1RfmGlEz.js";import{i as x}from"./hIAbPA16.js";import{B as de}from"./DSh6TMV1.js";import{S as ce}from"./I3pYu3kF.js";import{a as ve,_ as pe}from"./BwFejD95.js";const me={class:"w-full h-screen bg-black text-white"},ge={class:"flex w-full p-4 gap-8 justify-between items-center"},fe={class:"flex gap-8 items-center"},he=["alt"],_e={class:"font-semibold text-lg"},ke={class:"aspect-square flex items-center justify-center"},xe={key:0,class:"relative w-full"},ye=["alt"],be={class:"flex absolute shadow-black shadow-sm rounded-full bottom-2 mx-3"},we={key:1,class:"empty-state"},Ce={class:"media-picker"},Se={class:"media-grid"},Pe={class:"media-preview"},Fe={class:"text-sm"},Le=["onClick"],Ue=["src"],Ee=["src"],Ie=["onClick"],Re={class:"text-sm"},je={key:0,class:"absolute bottom-5 right-5 addStyle"},C=10,qe=X({__name:"index",setup(Me){const f=Y(),r=ee(),y=w(""),S=w(null),_=w(null),o=w(-2),P=le();function z(){a.value=[],i.value={},f.push({name:"home"})}B(a,l=>{var e,n,u;((e=a.value)==null?void 0:e.length)===0?g.value="":((n=a.value)==null?void 0:n.length)===1?g.value=a.value[0].url:l&&(g.value=(u=l[(l==null?void 0:l.length)-1])==null?void 0:u.url)},{deep:!0}),B(i,l=>{g.value=l.url,o.value=-1},{deep:!0});function q(){i.value.url?P.name=="edit-product-id-inputProduct"?f.push({name:"edit-product-id-infProduct"}):f.push({name:"add-product-infProduct"}):(console.log(m().originalFile),ie.warn(r.useString("addAtLeastOneMedia")))}function j(l){o.value=l,l===-1?g.value=i.value.url:g.value=a.value[l].url}const G=l=>l.includes(".mp4")||l.includes(".mov")||l.includes("video"),H=async()=>{o.value==-1?await D():await M()},M=async()=>{console.log(o.value,"Media");try{if(V.isNativePlatform())if(o.value==-2)(await R.pickImages({limit:C-a.value.length})).photos.forEach(e=>{m().mediaFiles.push({file:e,index:a.value.length}),a.value.push({url:e.webPath,index:a.value.length})}),o.value=a.value.length-1;else{const l=await R.pickImages({limit:1});l.photos.length>0&&(a.value[o.value].url=l.photos[0].webPath,m().mediaFiles[o.value].file=l.photos[0])}else console.log(o.value,"MediaA"),o.value==-2?S.value.click():_.value.click()}catch(l){console.error("Error selecting media:",l)}},D=async()=>{try{if(V.isNativePlatform()){const l=await R.pickImages({limit:1});l.photos.length>0&&(i.value.url=l.photos[0].webPath,m().originalFile={file:l.photos[0],index:0})}else console.log(o.value,"main"),await _.value.click(),console.log(o.value,"mainA"),_.value.onchange=l=>{const e=l.target.files;console.log(e,8888),e.length>0&&(i.value.url=URL.createObjectURL(e[0]),console.log(e,9999)),setTimeout(()=>{_.value.value=null},10)};console.log("dsacbnkjsdkmc,loskock,sdds",i.value)}catch(l){console.error("Error selecting main media:",l)}},N=l=>{console.log(o.value,4555);const e=l.target.files;e.length!=0&&(console.log(l,45),!i.value.url&&e.length>0||o.value==-1&&e.length>0?(i.value.url=URL.createObjectURL(e[0]),m().originalFile={file:e[0],index:0},console.log(i.value)):o.value==-2?Array.from(e).forEach(n=>{let u=a.value.length;a.value.length<C&&(a.value.push({url:URL.createObjectURL(n),index:u+1}),m().mediaFiles.push({file:n,index:u+1}),o.value=a.value.length-1)}):(a.value[o.value].url=URL.createObjectURL(e[0]),m().mediaFiles.push({file:e[0],index:a.value[o.value].index}),o.value=a.value.length-1),S.value.value="",_.value.value="")},Q=l=>{l.preventDefault();const e=l.dataTransfer.files;Array.from(e).forEach(n=>{a.value.length<C&&(m().mediaFiles.push({file:n,index:a.value.length}),a.value.push({url:URL.createObjectURL(n),index:a.value.length}))})},Z=(l,e)=>{const n=m().mediaFiles.findIndex(u=>u.index==e);a.value.splice(l,1),n>=0&&m().mediaFiles.splice(n,1)},J=()=>{i.value.url=void 0,ue.value=void 0};return te(()=>{swi
|