1import{u as R,r as n,j as e}from"./vendor-react-ff_kKGjF.js";import{SortableImageGrid as Y}from"./SortableImageGrid-dcRL9fGW.js";import{useAdEntry as V}from"./AdEntryContext-BKUG1EDF.js";import{c as j}from"./app--xwA6v7e.js";import{e as k,g as C}from"./youtube-DSd9f1Vi.js";import{I as U}from"./input-Bhxw-LNq.js";import{L}from"./label-B3U1sF3p.js";const y=10;function B(t){if(!t)return y;const i=t.sub_category??t.category;return i?.max_images!==void 0&&i.max_images!==null?i.max_images:y}const h=1,N=250;function F(){const{translations:t}=R().props,{draft:i,images:d,videos:c,isUploadingImage:E,isUploadingVideo:m,videoUploadProgress:u,uploadImage:p,deleteImage:D,reorderImages:w,uploadVideo:b,deleteVideo:A,errors:r,setFieldError:v,adFormat:I,videosEnabled:_,step2Data:x,updateStep2Data:S}=V(),f=I==="video",l=n.useMemo(()=>B(i),[i]),g=n.useMemo(()=>k(x.youtube_video_url),[x.youtube_video_url]),T=n.useCallback(async s=>{const a=Array.from(s);for(let o=0;o<a.length&&!(d.length+o>=l);o++)await p(a[o])},[d.length,l,p]),M=n.useCallback(async s=>{if(s.target.files&&s.target.files.length>0){const a=s.target.files[0];s.target.value="";const o=a.size/(1024*1024);if(o>N){v("video",t.AD_ENTRY_VIDEO_TOO_LARGE.replace(":max",String(N)).replace(":size",String(Math.round(o))));return}await b(a)}},[b,v,t]),O=c.length<h;return e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{children:[l>1&&e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-base font-medium text-gray-900 mb-1",children:t.AD_ENTRY_PHOTOS}),e.jsx("p",{className:"text-sm text-gray-500 mb-4",children:t.AD_ENTRY_ADD_PHOTOS_DESC.replace(":count",String(l))})]}),e.jsx(Y,{images:d,onReorder:w,onDelete:D,onUpload:T,isUploading:E,maxImages:l,showPendingBadge:!1}),(r.image||r.pending_images)&&e.jsx("p",{className:"mt-2 text-sm text-red-600",children:r.image||r.pending_images})]}),!f&&_&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-medium text-gray-900 mb-1",children:t.AD_ENTRY_VIDEOS}),e.jsx("p",{className:"text-sm text-gray-500 mb-4",children:t.AD_ENTRY_VIDEOS_DESC.replace(":count",String(h))}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-4",children:[c.map((s,a)=>e.jsxs("div",{className:j("relative aspect-square rounded-lg overflow-hidden border-2 group",a===0?"ring-2 ring-primary ring-offset-2 border-gray-200":"border-gray-200"),children:[e.jsx("video",{src:s.url,className:"w-full h-full object-cover",controls:!1}),a===0&&e.jsx("div",{className:"absolute top-2 left-2 bg-primary text-white text-xs px-2 py-1 rounded",children:t.AD_ENTRY_PRIMARY}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:e.jsx("div",{className:"w-12 h-12 bg-black/50 rounded-full flex items-center justify-center",children:e.jsx("svg",{className:"w-6 h-6 text-white ml-1",fill:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M8 5v14l11-7z"})})})}),e.jsx("button",{type:"button",onClick:()=>A(s.id),className:"absolute bottom-2 right-2 bg-red-600 hover:bg-red-700 text-white rounded-full p-1.5 opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]},s.id)),O&&e.jsxs("label",{className:j("aspect-square rounded-lg border-2 border-dashed border-gray-300 flex flex-col items-center justify-center cursor-pointer hover:border-primary hover:bg-gray-50 transition-colors",m&&"opacity-50 cursor-not-allowed"),children:[e.jsx("input",{type:"file",accept:"video/mp4,video/quicktime,video/x-msvideo,video/webm",onChange:M,disabled:m,className:"hidden"}),m?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-3/4",children:e.jsx("div",{className:"h-1.5 bg-gray-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-primary rounded-full transition-all duration-300",style:{width:`${u}%`}})})}),e.jsx("span",{className:"text-xs text-gray-500 mt-1",children:u>=90?t.AD_ENTRY_PROCESSING:`${u}%`})]}):e.jsxs(e.Fragment,{children:[e.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z"})}),e.jsx("span",{className:"text-sm text-gray-500 mt-2",children:t.AD_ENTRY_ADD_VIDEO})]})]})]}),r.video&&e.jsx("p",{className:"mt-2 text-sm text-red-600",children:r.video}),e.jsx("p",{className:"text-sm text-gray-500 mt-2",children:t.AD_ENTRY_VIDEOS_COUNT.replace(":current",String(c.length)).replace(":max",String(h))})]}),!f&&_&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-medium text-gray-900 mb-1",children:t.AD_ENTRY_YOUTUBE_VIDEO}),e.jsx("p",{className:"text-sm text-gray-500 mb-2",children:t.AD_ENTRY_YOUTUBE_VIDEO_DESC}),e.jsx(L,{htmlFor:"youtube_video_url",className:"text-sm font-medium text-gray-700 mb-1 block",children:"YouTube URL"}),e.jsx(U,{id:"youtube_video_url",type:"url",placeholder:"https://www.youtube.com/watch?v=...",value:x.youtube_video_url,onChange:s=>S({youtube_video_url:s.target.value})}),g&&e.jsxs("div",{className:"mt-3 flex items-center gap-3",children:[e.jsxs("div",{className:"w-32 aspect-video rounded-lg overflow-hidden border border-gray-200 relative",children:[e.jsx("img",{src:C(g),alt:"YouTube video thumbnail",className:"w-full h-full object-cover"}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx("div",{className:"w-8 h-5 bg-red-600 rounded-sm flex items-center justify-center",children:e.jsx("svg",{className:"w-3 h-3 text-white",f
1ill:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M8 5v14l11-7z"})})})})]}),e.jsxs("span",{className:"text-sm text-gray-500",children:["ID: ",g]})]}),r.youtube_video_url&&e.jsx("p",{className:"mt-1 text-sm text-red-600",children:r.youtube_video_url})]})]})}const W=Object.freeze(Object.defineProperty({__proto__:null,MediaUploadSection:F},Symbol.toStringTag,{value:"Module"}));export{F as M,W as a,B as m};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.