import{d as D,o as n,i as l,j as v,w as g,k as c,e as t,F,t as M}from"./index.9838a17e.js";import{aC as I,r as p,aa as o,k as j,n as b,ac as V,aM as B}from"./index.02c939b6.js";import{_ as L}from"./ElModal.vue_vue_type_script_setup_true_lang.96ee1a0e.js";import{_ as P}from"./ElButton.vue_vue_type_script_setup_true_lang.1b461236.js";import{_ as G}from"./ElSpinner.vue_vue_type_style_index_0_lang.786c1ff1.js";const N=t("div",{class:"i-carbon-image text-theme-400 mr-2 text-lg"},null,-1),U=t("span",null,"Add Media",-1),A={class:"media-gallery grid grid-cols-12 py-2 px-4 text-sm"},E={class:"nav col-span-12"},O={class:"grid grid-cols-3 items-center justify-center text-xs"},S=["onClick"],q={key:0,class:"p-12"},z={class:"space-y-1 text-center"},J=t("div",{class:"text-center"},[t("div",{class:"i-carbon-upload inline-block text-3xl"})],-1),R={class:"flex text-sm text-slate-500"},T={class:"text-theme-700 hover:text-primary-400 relative cursor-pointer rounded-md bg-white font-medium"},H=t("span",null,"Upload a file",-1),K=t("p",{class:"pl-1"},"or drag and drop",-1),Q=t("p",{class:"text-xs text-slate-400"},"PNG, JPG, GIF up to 10MB",-1),W={key:2},ae=D({__name:"InputMediaLibrary",props:{modelValue:{type:[String],default:""},factorMedia:{type:Object,required:!0}},emits:["update:modelValue"],setup(y,{emit:h}){const k=y,u=`file-upload-${I()}`,f=p(),r=p(),_=["upload","stockPhotos","library"],m=p(_[0]),i=p(!1),w=(a="")=>{h("update:modelValue",a)},x=async a=>{var s,d;if(!a)return;i.value=!0;const e=await k.factorMedia.uploadFiles({files:a});((s=e[0])==null?void 0:s.status)=="success"&&w((d=e[0].data)==null?void 0:d.url),i.value=!1},C=async a=>{a.stopPropagation();const e=a.target;await x(e.files)},$=async a=>{var s;await x((s=a.dataTransfer)==null?void 0:s.files)};return(a,e)=>(n(),l("div",null,[v(P,{btn:"theme",loading:o(i),onClick:e[0]||(e[0]=c(s=>r.value=!0,["stop","prevent"]))},{default:g(()=>[N,U]),_:1},8,["loading"]),v(L,{vis:o(r),"onUpdate:vis":e[6]||(e[6]=s=>j(r)?r.value=s:null),"modal-class":"max-w-xl"},{default:g(()=>[t("div",A,[t("div",E,[t("div",O,[(n(),l(F,null,M(_,(s,d)=>t("div",{key:d,class:b(["border-b-2 py-2 px-3 text-center",s==o(m)?"text-theme-700 border-theme-400 font-semibold":"text-slate-400 cursor-pointer border-slate-300 hover:text-slate-700"]),onClick:X=>m.value=s},V(o(B)(s)),11,S)),64))])])]),t("div",{class:"media-body p-4",onDragover:e[3]||(e[3]=c(()=>{},["prevent"])),onDrop:e[4]||(e[4]=c(()=>{},["prevent"])),onClick:e[5]||(e[5]=c(()=>{},["stop"]))},[o(i)?(n(),l("div",q,[v(G,{class:"m-auto h-12 w-12 text-slate-200"})])):o(m)=="upload"?(n(),l("label",{key:1,for:u,class:b(["mt-1 flex cursor-pointer justify-center rounded-md border-2 border-dashed border-slate-200 px-6 pt-8 pb-10 hover:border-slate-300",[]]),onDrop:$,onDragover:e[1]||(e[1]=s=>f.value=!0),onDragleave:e[2]||(e[2]=s=>f.value=!1)},[t("div",z,[J,t("div",R,[t("div",T,[H,t("input",{id:u,name:u,type:"file",class:"sr-only",accept:"image/*",multiple:"",onChange:C},null,32)]),K]),Q])],32)):(n(),l("div",W,"Library"))],32)]),_:1},8,["vis"])]))}});export{ae as default};
