Files
appco_dist/.output/public/_nuxt/C9Denr28.js
T
2025-08-09 21:39:49 +03:30

2 lines
7.5 KiB
JavaScript

import{d as Z,u as ee,G as le,r as C,d3 as te,a1 as O,o as ie,al as ae,y as c,z as v,C as x,S as E,D as w,A as a,H as t,ak as $,B as g,a7 as I,b_ as se,a2 as V,a3 as oe,E as R,Q as ne}from"./Cr0Hk_pZ.js";import{_ as re}from"./CscEAC8U.js";import{C as T,a as M}from"./ppZ4gnC7.js";import{m as i,e as f,o as u,b as z,l as ue,r as q,i as de,d as ce}from"./CTqxhVoZ.js";import{u as o}from"./CwYiSFBC.js";import{i as k}from"./Cpj_3H7O.js";import{B as ve}from"./cbEt2zZD.js";import{S as me}from"./aCe-A9au.js";import{a as pe,_ as ge}from"./BBz81bf1.js";const fe={class:"w-full h-screen bg-black text-white"},he={class:"flex w-full p-4 gap-8 justify-between items-center"},_e={class:"flex gap-8 items-center"},xe=["alt"],ke={class:"font-semibold text-lg"},ye={class:"aspect-square flex items-center justify-center"},be={key:0,class:"relative w-full"},we=["alt"],Fe={class:"flex absolute shadow-black shadow-sm rounded-full bottom-2 mx-3"},Ce={key:1,class:"empty-state"},Se={class:"media-picker"},Pe={class:"media-grid"},Le={class:"media-preview"},Ue={class:"text-sm"},Ee=["onClick"],Ie=["src"],Re=["src"],Me=["onClick"],je={class:"text-sm"},De={key:0,class:"absolute bottom-5 right-5 addStyle"},S=10,He=Z({__name:"index",setup(Ne){const h=ee(),d=le(),y=C(""),P=C(null),_=C(null),s=C(-2),L=te();function G(){h.push({name:"home"}),q(),o().mediaFiles=[],de.value=[]}O(i,l=>{var e,n,r;((e=i.value)==null?void 0:e.length)===0?f.value="":((n=i.value)==null?void 0:n.length)===1?f.value=i.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 H(){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),ne.warn(d.useString("addAtLeastOneMedia"))),console.log(o().originalFile,o().mediaFiles)}function j(l){s.value=l,l===-1?f.value=u.value.url:f.value=i.value[l].url}const Q=l=>l.includes(".mp4")||l.includes(".mov")||l.includes("video"),J=async()=>{s.value==-1?await N():await D()},D=async()=>{console.log(s.value,"Media");try{if(T.isNativePlatform())if(s.value==-2)(await M.pickImages({limit:S-i.value.length})).photos.forEach(e=>{o().mediaFiles.push({file:e,index:i.value.length}),i.value.push({url:e.webPath,index:i.value.length})}),s.value=i.value.length-1;else{const l=await M.pickImages({limit:1});l.photos.length>0&&(i.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 M.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=i.value.at(-1))==null?void 0:F.index)??0;i.value.length<S&&(i.value.push({url:URL.createObjectURL(n),index:r+1}),o().mediaFiles.push({file:n,index:r+1}),o().mediaFiles.sort((b,m)=>b.index-m.index),s.value=i.value.length-1)}):(i.value[s.value].url=URL.createObjectURL(e[0]),o().mediaFiles.length>0?o().mediaFiles.some((n,r)=>{if(n.index==i.value[s.value].index)return n.file=e[0],!0})||(o().mediaFiles.push({file:e[0],index:i.value[s.value].index}),console.log(o().mediaFiles)):o().mediaFiles.push({file:e[0],index:i.value[s.value].index}),o().mediaFiles.sort((n,r)=>n.index-r.index),s.value=i.value.length-1),P.value.value="",_.value.value="",console.log(o().mediaFiles))},K=l=>{l.preventDefault();const e=l.dataTransfer.files;Array.from(e).forEach(n=>{i.value.length<S&&(o().mediaFiles.push({file:n,index:i.value.length}),i.value.push({url:URL.createObjectURL(n),index:i.value.length}))})},W=(l,e)=>{const n=o().mediaFiles.findIndex(r=>r.index==e);i.value.splice(l,1),n>=0&&o().mediaFiles.splice(n,1),console.log(o().mediaFiles,i.value)},X=()=>{u.value.url=void 0,ce.value=void 0};return ie(()=>{switch(h.currentRoute.value.name){case"add-product-inputProduct":y.value="product";break;case"add-story-inputStory":y.value="story";break;case"add-product-excel-inputProductExcel":y.value="productExcel";break}}),(l,e)=>{const n=me,r=pe,F=ge,b=ae("lazy");return v(),c(V,null,[x(n,{spinning:t(ue)},{default:w(()=>{var m,B;return[a("div",fe,[a("div",he,[a("div",_e,[a("img",{src:re,alt:t($),class:"w-4",onClick:G},null,8,xe),a("div",ke,g(t(z)(t(L).name)?t(d).useString("editProduct"):t(d).useString("newProduct")),1)]),a("div",{class:"text-primary text-sm",onClick:H},g(t(d).useString("next")),1)]),a("div",ye,[t(f)?(v(),c("div",be,[I(a("img",{alt:t($),class:"w-full object-scale-down aspect-square"},null,8,we),[[b,{src:t(f),loading:t(k),error:t(k)}]]),a("div",Fe,[a("div",{onClick:J,class:"flex bg-primary items-center rounded-full py-1 gap-2 px-2"},[x(ve,{icon:"vuesax-linear:gallery-edit"}),a("span",null,g(t(d).useString("edit")),1)])])])):((m=t(i))==null?void 0:m.length)===0?(v(),c("p",Ce,g(t(d).useString("tapPlusToAdd")),1)):E("",!0)]),a("div",Se,[a("div",{class:"drop-area",onDragover:e[2]||(e[2]=se(()=>{},["prevent"])),onDrop:K},[a("div",Pe,[t(u).url?(v(),c("div",{key:0,class:"media-container border-1 border-solid border-primary",onClick:e[0]||(e[0]=p=>j(-1))},[I(a("img",Le,null,512),[[b,{src:t(u).url,loading:t(k),error:t(k)}]]),a("button",{onClick:X,class:"remove-btn"},"✖")])):(v(),c("div",{key:1,class:"add-media text-black",onClick:N},[a("div",null,g(t(u).url),1),e[10]||(e[10]=a("span",null,"+",-1)),a("div",Ue,g(t(d).useString("mainImage")),1)])),(v(!0),c(V,null,oe(t(i),(p,U)=>(v(),c("div",{key:U,class:"media-container",onClick:Y=>j(U)},[Q(p.url)?(v(),c("video",{key:0,src:p.url,class:"media-preview",controls:""},null,8,Ie)):I((v(),c("img",{key:1,src:p.url,class:"media-preview"},null,8,Re)),[[b,{src:p.url,loading:t(k),error:t(k)}]]),a("button",{onClick:Y=>W(U,p.index),class:"remove-btn"},"✖",8,Me)],8,Ee))),128)),((B=t(i))==null?void 0:B.length)<S?(v(),c("div",{key:2,class:"add-media text-black",onClick:e[1]||(e[1]=()=>{s.value=-2,D()})},[e[11]||(e[11]=a("span",null,"+",-1)),a("div",je,g(t(d).useString("subImage")),1)])):E("",!0)])],32),a("input",{ref_key:"fileInput",ref:P,type:"file",accept:"image/*,video/*",multiple:"",hidden:"",onChange:e[3]||(e[3]=p=>A(p))},null,544),a("input",{ref_key:"fileInputLimited",ref:_,type:"file",accept:"image/*,video/*",hidden:"",onChange:e[4]||(e[4]=p=>A(p))},null,544)])])]}),_:1},8,["spinning"]),t(z)(t(L).name)?E("",!0):(v(),c("div",De,[x(F,{value:y.value,"onUpdate:value":e[8]||(e[8]=m=>y.value=m),onChange:e[9]||(e[9]=m=>t(q)()),"button-style":"solid"},{default:w(()=>[x(r,{onClick:e[5]||(e[5]=m=>t(h).push({name:"add-product-excel-inputProductExcel"})),value:"productExcel"},{default:w(()=>[R(g(t(d).useString("productExcel")),1)]),_:1}),x(r,{onClick:e[6]||(e[6]=m=>t(h).push({name:"add-product-inputProduct"})),value:"product"},{default:w(()=>[R(g(t(d).useString("product2")),1)]),_:1}),x(r,{onClick:e[7]||(e[7]=m=>t(h).push({name:"add-story-inputStory"})),value:"story"},{default:w(()=>[R(g(t(d).useString("story2")),1)]),_:1})]),_:1},8,["value"])]))],64)}}});export{He as _};