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