2 lines
3.7 KiB
JavaScript
2 lines
3.7 KiB
JavaScript
import{d as D,u as A,G as B,r as k,a1 as M,o as V,y as r,z as i,A as o,H as s,ak as x,B as p,S as w,b_ as $,a2 as b,a3 as I,C as v,D as _,E as y,Q as O}from"./B3Hm6diO.js";import{_ as T}from"./CscEAC8U.js";import{C as q,a as z}from"./ppZ4gnC7.js";import{m as a,e as u,r as G,c as H}from"./D94lvKi3.js";import{a as Q,_ as J}from"./BrW_ACFg.js";import"./1KdgQ08W.js";const K={class:"w-full h-screen bg-black text-white"},W={class:"flex w-full p-4 gap-8 justify-between items-center"},X={class:"flex gap-8 items-center"},Y=["alt"],Z={class:"font-semibold text-lg"},ee={class:"w-full flex items-center justify-center"},te=["src","alt"],se={key:1,class:"empty-state"},ae={class:"media-picker"},oe={class:"media-grid"},ne=["onClick"],le=["src"],re=["src"],ie=["onClick"],ce={class:"absolute bottom-5 right-5 addStyle"},f=10,he=D({__name:"index",setup(ue){const d=A(),c=B(),h=k(null),m=k("");function C(){d.push({name:"home"}),G()}M(a,e=>{a.value.length===0?u.value="":a.value.length===1?u.value=a.value[0]:u.value=e[e.length-1]});function S(){a.value.length!==0?d.push({name:"add-story-infStory"}):O.warn(c.useString("addAtLeastOneMedia"))}function E(e){u.value=a.value[e]}const P=e=>e.includes(".mp4")||e.includes(".mov")||e.includes("video"),U=async()=>{try{q.isNativePlatform()?(await z.pickImages({limit:f-a.value.length})).photos.forEach(t=>a.value.push(t.webPath)):h.value.click()}catch(e){console.error("Error selecting media:",e)}},L=e=>{const t=e.target.files;t.length&&(Array.from(t).forEach(n=>{a.value.length<f&&(a.value.push(URL.createObjectURL(n)),H.value.push(n),u.value=URL.createObjectURL(n))}),h.value.value="")},R=e=>{e.preventDefault();const t=e.dataTransfer.files;Array.from(t).forEach(n=>{a.value.length<f&&a.value.push(URL.createObjectURL(n))})},F=e=>{a.value.splice(e,1)};return V(()=>{switch(d.currentRoute.value.name){case"add-product-inputProduct":m.value="product";break;case"add-story-inputStory":m.value="story";break;case"add-product-excel-inputProductExcel":m.value="productExcel";break}}),(e,t)=>{const n=Q,N=J;return i(),r(b,null,[o("div",K,[o("div",W,[o("div",X,[o("img",{src:T,alt:s(x),class:"w-4",onClick:C},null,8,Y),o("div",Z,p(s(c).useString("newStory")),1)]),o("div",{class:"text-primary text-sm",onClick:S},p(s(c).useString("next")),1)]),o("div",ee,[s(u)?(i(),r("img",{key:0,src:s(u),alt:s(x),class:"w-full aspect-square"},null,8,te)):s(a).length===0?(i(),r("p",se,p(s(c).useString("tapPlusToAdd")),1)):w("",!0)]),o("div",ae,[o("div",{class:"drop-area",onDragover:t[0]||(t[0]=$(()=>{},["prevent"])),onDrop:R},[o("div",oe,[(i(!0),r(b,null,I(s(a),(l,g)=>(i(),r("div",{key:g,class:"media-container",onClick:j=>E(g)},[P(l)?(i(),r("video",{key:0,src:l,class:"media-preview",controls:""},null,8,le)):(i(),r("img",{key:1,src:l,class:"media-preview"},null,8,re)),o("button",{onClick:j=>F(g),class:"remove-btn"},"✖",8,ie)],8,ne))),128)),s(a).length<f?(i(),r("div",{key:0,class:"add-media text-black",onClick:U},t[5]||(t[5]=[o("span",null,"+",-1)]))):w("",!0)])],32),o("input",{ref_key:"fileInput",ref:h,type:"file",accept:"image/*,video/*",multiple:"",hidden:"",onChange:L},null,544)])]),o("div",ce,[v(N,{value:m.value,"onUpdate:value":t[4]||(t[4]=l=>m.value=l),"button-style":"solid"},{default:_(()=>[v(n,{onClick:t[1]||(t[1]=l=>s(d).push({name:"add-product-excel-inputProductExcel"})),value:"productExcel"},{default:_(()=>[y(p(s(c).useString("productExcel")),1)]),_:1}),v(n,{onClick:t[2]||(t[2]=l=>s(d).push({name:"add-product-inputProduct"})),value:"product"},{default:_(()=>[y(p(s(c).useString("product2")),1)]),_:1}),v(n,{onClick:t[3]||(t[3]=l=>s(d).push({name:"add-story-inputStory"})),value:"story"},{default:_(()=>[y(p(s(c).useString("story2")),1)]),_:1})]),_:1},8,["value"])])],64)}}});export{he as _};
|