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