import{c as C,j as l,r as B}from"./app-BiexncSX.js";import{c as E}from"./utils-DvRnx1Xn.js";import{l as D,z as _,t as L}from"./lucide-react-C-jOYeYF.js";import{C as A}from"./shield-check-BcGX3gbR.js";import{L as F}from"./loader-circle-C36m3ppM.js";import{I as G}from"./ImagePicker-DNMwSTP_.js";import{L as M}from"./label-BACPLsln.js";import{I as R}from"./input-C7geQw3H.js";import{X as U}from"./x-Cp4MPESs.js";function J(f){const e=C.c(10),{status:o,className:a}=f;let r;e[0]!==a?(r=E("absolute bottom-1 left-1 w-6 h-6 p-1 rounded-full bg-white/80 dark:bg-black/80 backdrop-blur shadow",a),e[0]=a,e[1]=r):r=e[1];const c=r;switch(o){case"uploading":{const s=`${c} animate-spin text-blue-600`;let t;return e[2]!==s?(t=l.jsx(F,{className:s}),e[2]=s,e[3]=t):t=e[3],t}case"uploaded":{const s=`${c} text-green-600`;let t;return e[4]!==s?(t=l.jsx(_,{className:s}),e[4]=s,e[5]=t):t=e[5],t}case"failed":{const s=`${c} text-red-600`;let t;return e[6]!==s?(t=l.jsx(A,{className:s}),e[6]=s,e[7]=t):t=e[7],t}case"local":{const s=`${c} text-yellow-500`;let t;return e[8]!==s?(t=l.jsx(D,{className:s}),e[8]=s,e[9]=t):t=e[9],t}default:return null}}const T=f=>{const e=C.c(10),{image:o,disabled:a,onDelete:r,className:c}=f,{url:s}=o,t=`relative border h-full  p-1 ${a?"":"border-blue-300 border-dashed bg-blue-50"} dark:bg-secondary dark:border-blue-800 flex justify-center items-center rounded-sm overflow-hidden group`;let i;e[0]!==c||e[1]!==t?(i=E(t,c),e[0]=c,e[1]=t,e[2]=i):i=e[2];let n;e[3]!==a||e[4]!==r||e[5]!==s?(n=s?l.jsxs(l.Fragment,{children:[l.jsx("img",{src:s??"",width:460,height:300,className:"object-cover w-full h-full rounded-sm",alt:"Desktop Banner"}),l.jsx(J,{status:"loading",className:"bottom-1.5 left-1.5"}),l.jsx("button",{type:"button",className:`absolute top-2 right-2 bg-white/40 text-red-600 border cursor-pointer border-red-600 p-0.5 rounded-full hover:bg-red-600 hover:text-white  z-2 opacity-100 group-hover:opacity-100 transition-opacity ${a&&"hidden"}`,onClick:r,disabled:a,children:l.jsx(U,{className:"w-3 h-3"})})]}):l.jsxs(M,{className:`text-blue-400 h-full dark:text-blue-700 ${!a&&"cursor-pointer"} w-full h-full flex flex-col gap-2 items-center justify-center`,children:[l.jsx(L,{className:"w-6 h-6"}),l.jsx("span",{className:"text-sm",children:"Upload Banner"}),l.jsx(R,{className:"hidden",type:"file",disabled:a,accept:"image/png, image/jpeg, image/webp"})]}),e[3]=a,e[4]=r,e[5]=s,e[6]=n):n=e[6];let d;return e[7]!==i||e[8]!==n?(d=l.jsx("div",{className:i,children:n}),e[7]=i,e[8]=n,e[9]=d):d=e[9],d};function te(f){const e=C.c(30),{data:o,edit:a,processing:r,max:c,onChange:s,uploadFolderType:t,itemName:i,itemId:n}=f,d=c===void 0?1:c;let N;e[0]!==o?(N=o||[],e[0]=o,e[1]=N):N=e[1];const[p,$]=B.useState(N);let w;e[2]!==s?(w=u=>{const h=u.map(W);s(h)},e[2]=s,e[3]=w):w=e[3];const m=w;let y,I;e[4]!==o?(y=()=>{$(o||[])},I=[o],e[4]=o,e[5]=y,e[6]=I):(y=e[5],I=e[6]),B.useEffect(y,I);const v=`space-y-4  ${a&&"p-2 rounded-sm  border-2  border-dashed bg-card"}`;let x;if(e[7]!==a||e[8]!==p||e[9]!==r||e[10]!==m){let u;e[12]!==a||e[13]!==r||e[14]!==m?(u=(h,j)=>l.jsx(T,{disabled:!a||r,image:h,onDelete:()=>$(S=>{const P=S.filter((X,z)=>z!==j);return m(P),P}),className:"bg-white h-34"},j),e[12]=a,e[13]=r,e[14]=m,e[15]=u):u=e[15],x=p.map(u),e[7]=a,e[8]=p,e[9]=r,e[10]=m,e[11]=x}else x=e[11];let g;e[16]!==a||e[17]!==p||e[18]!==n||e[19]!==i||e[20]!==d||e[21]!==m||e[22]!==t?(g=p.length<d&&a&&l.jsxs(G,{selected:p,onSelect:u=>$(h=>{const j=[...h,...u];return m(j),j}),max:d,uploadFolderType:t,itemName:i,itemId:n,className:"text-blue-400 border rounded-sm dark:text-blue-700 w-full  flex flex-col gap-2 items-center justify-center py-6  bg-background h-34",children:[l.jsx(L,{className:"w-10 h-10"}),l.jsx("span",{className:"text-sm text-muted-foreground font-medium",children:"Add new image"}),l.jsx("span",{className:"text-xs text-muted-foreground",children:"JPG, PNG, WebP | Max size: 2MB"})]}),e[16]=a,e[17]=p,e[18]=n,e[19]=i,e[20]=d,e[21]=m,e[22]=t,e[23]=g):g=e[23];let b;e[24]!==x||e[25]!==g?(b=l.jsxs("div",{className:"grid grid-cols-4 gap-2 w-full  ",children:[x,g]}),e[24]=x,e[25]=g,e[26]=b):b=e[26];let k;return e[27]!==v||e[28]!==b?(k=l.jsx("div",{className:v,children:b}),e[27]=v,e[28]=b,e[29]=k):k=e[29],k}function W(f,e){return{id:f.id,role:e===0?"thumbnail":"gallery",sort_order:e}}export{te as I};
