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