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

2 lines
7.0 KiB
JavaScript

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(()=>{switch(f.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=ce,u=ve,K=pe,F=ae("lazy");return c(),d($,null,[k(n,{spinning:t(re)},{default:b(()=>{var h,A;return[s("div",me,[s("div",ge,[s("div",fe,[s("img",{src:ne,alt:t(O),class:"w-4",onClick:z},null,8,he),s("div",_e,p(t(T)(t(P).name)?t(r).useString("editProduct"):t(r).useString("newProduct")),1)]),s("div",{class:"text-primary text-sm",onClick:q},p(t(r).useString("next")),1)]),s("div",ke,[t(g)?(c(),d("div",xe,[E(s("img",{alt:t(O),class:"w-full object-scale-down aspect-square"},null,8,ye),[[F,{src:t(g),loading:t(x),error:t(x)}]]),s("div",be,[s("div",{onClick:H,class:"flex bg-primary rounded-full py-1 gap-2 px-2"},[k(de,{icon:"vuesax-linear:gallery-edit"}),s("span",null,p(t(r).useString("edit")),1)])])])):((h=t(a))==null?void 0:h.length)===0?(c(),d("p",we,p(t(r).useString("tapPlusToAdd")),1)):U("",!0)]),s("div",Ce,[s("div",{class:"drop-area",onDragover:e[2]||(e[2]=se(()=>{},["prevent"])),onDrop:Q},[s("div",Se,[t(i).url?(c(),d("div",{key:0,class:"media-container border-1 border-solid border-primary",onClick:e[0]||(e[0]=v=>j(-1))},[E(s("img",Pe,null,512),[[F,{src:t(i).url,loading:t(x),error:t(x)}]]),s("button",{onClick:J,class:"remove-btn"},"✖")])):(c(),d("div",{key:1,class:"add-media text-black",onClick:D},[s("div",null,p(t(i).url),1),e[9]||(e[9]=s("span",null,"+",-1)),s("div",Fe,p(t(r).useString("mainImage")),1)])),(c(!0),d($,null,oe(t(a),(v,L)=>(c(),d("div",{key:L,class:"media-container",onClick:W=>j(L)},[G(v.url)?(c(),d("video",{key:0,src:v.url,class:"media-preview",controls:""},null,8,Ue)):E((c(),d("img",{key:1,src:v.url,class:"media-preview"},null,8,Ee)),[[F,{src:v.url,loading:t(x),error:t(x)}]]),s("button",{onClick:W=>Z(L,v.index),class:"remove-btn"},"✖",8,Ie)],8,Le))),128)),((A=t(a))==null?void 0:A.length)<C?(c(),d("div",{key:2,class:"add-media text-black",onClick:e[1]||(e[1]=()=>{o.value=-2,M()})},[e[10]||(e[10]=s("span",null,"+",-1)),s("div",Re,p(t(r).useString("subImage")),1)])):U("",!0)])],32),s("input",{ref_key:"fileInput",ref:S,type:"file",accept:"image/*,video/*",multiple:"",hidden:"",onChange:e[3]||(e[3]=v=>N(v))},null,544),s("input",{ref_key:"fileInputLimited",ref:_,type:"file",accept:"image/*,video/*",hidden:"",onChange:e[4]||(e[4]=v=>N(v))},null,544)])])]}),_:1},8,["spinning"]),t(T)(t(P).name)?U("",!0):(c(),d("div",je,[k(K,{value:y.value,"onUpdate:value":e[8]||(e[8]=h=>y.value=h),"button-style":"solid"},{default:b(()=>[k(u,{onClick:e[5]||(e[5]=h=>t(f).push({name:"add-product-excel-inputProductExcel"})),value:"productExcel"},{default:b(()=>[I(p(t(r).useString("productExcel")),1)]),_:1}),k(u,{onClick:e[6]||(e[6]=h=>t(f).push({name:"add-product-inputProduct"})),value:"product"},{default:b(()=>[I(p(t(r).useString("product2")),1)]),_:1}),k(u,{onClick:e[7]||(e[7]=h=>t(f).push({name:"add-story-inputStory"})),value:"story"},{default:b(()=>[I(p(t(r).useString("story2")),1)]),_:1})]),_:1},8,["value"])]))],64)}}});export{qe as _};