import{j as e,cI as u,aa as h,af as g}from"./vendor-laZsiqLO.js";import{B as m}from"./button-B8f8jW4H.js";import{I as v}from"./input-CT5MkJwj.js";import{L as b}from"./label-BDbCc0wv.js";import"./utils-RgT4yCq8.js";function C({existingImages:i,newImages:n,onAddImages:r,onDeleteExisting:o,onDeleteNew:c,onSetPrimary:l,onCaptionChange:d}){const s=i.length+n.length;return e.jsxs("div",{className:"border rounded-lg p-4 bg-muted/10 space-y-4",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs(b,{className:"text-base font-semibold",children:["Gallery & Covers (",s,"/5)"]}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:"file",id:"admin-img-upload",className:"hidden",multiple:!0,accept:"image/*",onChange:r,disabled:s>=5}),e.jsxs(m,{type:"button",variant:"outline",size:"sm",onClick:()=>document.getElementById("admin-img-upload").click(),disabled:s>=5,children:[e.jsx(u,{className:"w-4 h-4 mr-2"})," Add Images"]})]})]}),e.jsxs("div",{className:"space-y-3",children:[s===0&&e.jsx("div",{className:"text-center py-6 text-muted-foreground text-sm border-2 border-dashed rounded-md bg-background",children:"No images uploaded. Add images to set a cover."}),i.map(t=>e.jsx(p,{src:t.image_path,caption:t.caption||"",isPrimary:t.is_primary,type:"existing",onCaptionChange:a=>d("existing",t.id,a),onSetPrimary:()=>l("existing",t.id),onDelete:()=>o(t.id)},`existing-${t.id}`)),n.map((t,a)=>e.jsx(p,{src:t.preview,caption:t.caption,isPrimary:t.isPrimary,isNew:!0,type:"new",onCaptionChange:x=>d("new",a,x),onSetPrimary:()=>l("new",a),onDelete:()=>c(a)},`new-${a}`))]})]})}function p({src:i,caption:n,isPrimary:r,isNew:o,onCaptionChange:c,onSetPrimary:l,onDelete:d}){return e.jsxs("div",{className:`flex gap-3 p-2 border bg-card rounded-md items-center transition-all ${r?"border-primary ring-1 ring-primary/20 bg-primary/5":""}`,children:[e.jsxs("div",{className:"relative w-16 h-16 shrink-0 rounded overflow-hidden bg-muted",children:[e.jsx("img",{src:i,className:"w-full h-full object-cover"}),o&&e.jsx("span",{className:"absolute top-0 right-0 bg-green-500 text-[8px] text-white px-1 font-bold",children:"NEW"})]}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx(v,{value:n,onChange:s=>c(s.target.value),placeholder:"Enter image caption...",className:"h-8 text-xs bg-background"})}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(m,{type:"button",size:"icon",variant:r?"default":"ghost",onClick:l,title:"Set as Primary Cover",className:"h-8 w-8",children:e.jsx(h,{className:`w-4 h-4 ${r?"fill-current":""}`})}),e.jsx(m,{type:"button",size:"icon",variant:"ghost",className:"h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:d,title:"Remove Image",children:e.jsx(g,{className:"w-4 h-4"})})]})]})}export{C as default};
