2 lines
3.7 KiB
JavaScript
2 lines
3.7 KiB
JavaScript
import{d as D,u as A,H as B,r as k,a2 as I,o as M,y as r,z as i,A as o,I as s,ak as x,B as p,T as w,bY as V,a3 as b,a4 as $,C as v,D as _,E as y,R as O}from"./CYzE2ijA.js";import{_ as T}from"./CscEAC8U.js";import{C as q,a as z}from"./7leyeuG9.js";import{m as a,e as u,r as H,c as Y}from"./DtjP-fro.js";import{a as G,_ as J}from"./BVqkG0IS.js";import"./Bp0GhCjq.js";const K={class:"w-full h-screen bg-black text-white"},Q={class:"flex w-full p-4 gap-8 justify-between items-center"},W={class:"flex gap-8 items-center"},X=["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"}),H()}I(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"),R=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)}},U=e=>{const t=e.target.files;t.length&&(Array.from(t).forEach(n=>{a.value.length<f&&(a.value.push(URL.createObjectURL(n)),Y.value.push(n),u.value=URL.createObjectURL(n))}),h.value.value="")},L=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 M(()=>{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=G,N=J;return i(),r(b,null,[o("div",K,[o("div",Q,[o("div",W,[o("img",{src:T,alt:s(x),class:"w-4",onClick:C},null,8,X),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]=V(()=>{},["prevent"])),onDrop:L},[o("div",oe,[(i(!0),r(b,null,$(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:R},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:U},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 _};
|