1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[956,1966],{26497:function(e,t,r){"use strict";r.d(t,{l:function(){return s.l}});var a=r(57437),n=r(33145),o=r(2265),s=r(13274);let l=r(25566).env.IMAGE_CDN_DOMAIN,i=(0,o.forwardRef)((e,t)=>{let{src:r,...o}=e,i=l&&r&&"string"==typeof r&&(r.startsWith("http://")||r.startsWith("https://"));return(0,a.jsx)(n.default,{...o,src:r,ref:t,loader:i?s.l:void 0})});i.displayName="Image",t.Z=i},69880:function(e,t,r){"use strict";r.d(t,{l:function(){return h}});var a=r(57437),n=r(2265),o=r(86815),s=r(7761),l=r(62590),i=r(29827),c=r(58962),d=r(64067);let u=e=>{let{file:t,isSelected:r,onToggleSelection:n,onFolderClick:s,isDeleteMode:l=!1,isSelectedForDeletion:i=!1,onToggleDeleteSelection:c}=e,d=t.isFolder;return(0,a.jsxs)("div",{className:"relative flex flex-col items-center cursor-pointer rounded-lg p-2 transition-all group ".concat(l?i?"bg-[--destructive] bg-opacity-15":"hover:bg-[--muted]":d?"hover:bg-[--muted]":r?"bg-[rgba(var(--primary-rgb),0.1)]":"hover:bg-[--muted]"),onClick:()=>{l&&c?c(t.id):d&&s?s(t):l||d||n(t)},onDoubleClick:()=>{d&&s&&s(t)},title:t.originalName,children:[l&&(0,a.jsx)("div",{className:"absolute top-1 left-1 z-10",children:(0,a.jsx)("div",{className:"w-5 h-5 border-2 rounded flex items-center justify-center ".concat(i?"bg-[--destructive] border-[--destructive] text-white":"border-gray-400 bg-white"),children:i&&(0,a.jsx)("span",{className:"text-xs",children:"â"})})}),r&&!l&&!d&&(0,a.jsx)("div",{className:"absolute top-1 right-1 z-10",children:(0,a.jsx)("div",{className:"w-5 h-5 bg-[--primary] text-[--primary-foreground] rounded-full flex items-center justify-center text-xs",children:"â"})}),(0,a.jsx)("div",{className:"w-20 h-20 flex items-center justify-center mb-1",children:d?(0,a.jsxs)("svg",{width:"64",height:"56",viewBox:"0 0 64 56",fill:"none",className:"drop-shadow-sm",children:[(0,a.jsx)("path",{d:"M2 8C2 5.79086 3.79086 4 6 4H22L28 12H58C60.2091 12 62 13.7909 62 16V48C62 50.2091 60.2091 52 58 52H6C3.79086 52 2 50.2091 2 48V8Z",fill:"#60A5FA"}),(0,a.jsx)("path",{d:"M2 16C2 13.7909 3.79086 12 6 12H58C60.2091 12 62 13.7909 62 16V48C62 50.2091 60.2091 52 58 52H6C3.79086 52 2 50.2091 2 48V16Z",fill:"#93C5FD"})]}):t.fileType===o.Tv.IMAGE?(0,a.jsx)("img",{src:t.thumbnailUrl||t.fileUrl,alt:t.originalName,className:"max-w-full max-h-full object-contain rounded shadow-sm"}):(0,a.jsx)("span",{className:"text-5xl",children:(e=>{switch(e){case o.Tv.IMAGE:return"\uD83D\uDDBCï¸";case o.Tv.VIDEO:return"\uD83C\uDFA5";case o.Tv.AUDIO:return"\uD83C\uDFB5";case o.Tv.DOCUMENT:return"\uD83D\uDCC4";default:return"\uD83D\uDCC1"}})(t.fileType)})}),(0,a.jsx)("p",{className:"text-xs text-center leading-tight w-full px-1 rounded ".concat(!r||l||d?"text-[--foreground]":"bg-[--primary] text-[--primary-foreground]"),style:{display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",wordBreak:"break-all"},children:t.originalName})]})},m=["image/jpeg","image/png","image/gif","image/webp","image/svg+xml","application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-powerpoint","application/vnd.openxmlformats-officedocument.presentationml.presentation","text/plain","text/csv","video/mp4","video/mpeg","video/quicktime","video/x-msvideo","video/webm","audio/mpeg","audio/wav","audio/ogg","audio/mp4","audio/webm"],h=e=>{var t;let{isActive:h,onInsert:p,onClose:x,hideUpload:g=!1,hideDelete:f=!1,columns:b=6}=e,[v,w]=(0,n.useState)([]),[y,j]=(0,n.useState)(!1),[N,k]=(0,n.useState)(0),[C,E]=(0,n.useState)(!1),[M,S]=(0,n.useState)(""),[I,L]=(0,n.useState)(""),[T,U]=(0,n.useState)("ALL"),[D,O]=(0,n.useState)(!1),[R,F]=(0,n.useState)(!1),[A,P]=(0,n.useState)(new Set),[z,W]=(0,n.useState)(null),[B,_]=(0,n.use
1State)([{id:null,name:"ì ì²´"}]),K=(0,n.useRef)(null),{showAlert:q}=(0,s.V)(),{showConfirm:H}=(0,l.N)(),G=(0,i.NL)();(0,n.useEffect)(()=>{let e=setTimeout(()=>L(M),300);return()=>clearTimeout(e)},[M]);let J="IMAGE"===T?o.Tv.IMAGE:void 0,{data:V,isLoading:X,error:Q,fetchNextPage:Y,hasNextPage:Z,isFetchingNextPage:$}=(0,c.N)({queryKey:["files",I,T,z],queryFn:e=>{let{pageParam:t=1}=e;return o.Ju.getFileUploads({page:t,limit:20,search:I||void 0,fileType:J,...!I&&{parentFolderId:z}})},initialPageParam:1,getNextPageParam:e=>{let{page:t,totalPages:r}=e.data.pagination;return t<r?t+1:void 0},enabled:h}),ee=async e=>{try{let t;j(!0),k(0);let a=null,n=function(e,t){var r;let a=(null===(r=e.split(".").pop())||void 0===r?void 0:r.toLowerCase())||"";if("hwp"===a)return"application/x-hwp";if(!t||"application/octet-stream"===t||""===t.trim()){let e={doc:"application/msword",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",pdf:"application/pdf",xls:"application/vnd.ms-excel",xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",ppt:"application/vnd.ms-powerpoint",pptx:"application/vnd.openxmlformats-officedocument.presentationml.presentation",jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",mp4:"video/mp4",mp3:"audio/mpeg",wav:"audio/wav",txt:"text/plain",csv:"text/csv"};if(e[a])return e[a]}return t||"application/octet-stream"}(e.name,e.type);if("application/pdf"===n){k(5);let{createPdfThumbnail:t}=await r.e(441).then(r.bind(r,50441));a=await t(e)}let o=await fetch("/api/upload/presigned-url",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fileName:e.name,fileSize:e.size,fileType:n})});if(!o.ok)throw Error((await o.json()).error||"presigned URL ìì± ì¤í¨");let{presignedUrl:s,fileId:l,fileName:i,fileUrl:c,s3Key:d}=await o.json();if(a)try{let e=await fetch("/api/upload/presigned-url",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fileName:a.name,fileSize:a.size,fileType:a.type,folder:d.split("/").slice(0,-1).join("/")})});if(e.ok){let r=await e.json();await fetch(r.presignedUrl,{method:"PUT",body:a,headers:{"Content-Type":a.type}}),t=r.fileUrl}}catch(e){}await new Promise((t,r)=>{let o=new XMLHttpRequest;o.upload.addEventListener("progress",e=>{e.lengthComputable&&k(Math.round(e.loaded/e.total*80+(a?10:0)))}),o.addEventListener("load",()=>{200===o.status?(k(90),t()):r(Error("íì¼ ì
ë¡ë ì¤í¨"))}),o.addEventListener("error",()=>r(Error("ë¤í¸ìí¬ ì¤ë¥"))),o.open("PUT",s),o.setRequestHeader("Content-Type",n),o.send(e)}),k(95);let u=await fetch("/api/upload/confirm",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fileId:l,fileName:i,fileUrl:c,s3Key:d,originalFileName:e.name,fileSize:e.size,fileType:n,thumbnailUrl:t,parentFolderId:z})});if(!u.ok)throw Error((await u.json()).error||"íì¼ ì ë³´ ì ì¥ ì¤í¨");k(100),G.invalidateQueries({queryKey:["files"]}),q("success","íì¼ì´ ì±ê³µì ì¼ë¡ ì
ë¡ëëììµëë¤.")}catch(e){q("error",e instanceof Error?e.message:"íì¼ ì
ë¡ë ì¤í¨")}finally{j(!1),setTimeout(()=>k(0),2e3)}},et=e=>{if(e.size>524288e3){q("error","íì¼ í¬ê¸°ë 500MB를 ì´ê³¼í ì ììµëë¤.");return}if(!m.includes(e.type)){q("error","ì§ìíì§ ìë íì¼ íìì
ëë¤.");return}ee(e)},er=()=>{w([]),S(""),L(""),U("ALL"),W(null),_([{id:null,name:"ì ì²´"}]),O(!1),P(new Set)},ea=e=>{w(t=>t.some(t=>t.id===e.id)?t.filter(t=>t.id!==e.id):[...t,e])},en=e=>{W(e.id),_(t=>[...t,{id:e.id,name:e.originalName}])},eo=e=>{W(B[e].id),_(B.slice(0,e+1))},es=e=>"IMAGE"===T?!e.isFolder&&e.fileType===o.Tv.IMAGE:"FILE"===T?!e.isFolder&&e.fileType!==o.Tv.IMAGE:"FOLDER"!==T||e.isFolder;return(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[(0,a.jsxs)("div",{className:"space-y-3 flex-1 flex flex-col min-h-0",children:[!g&&!D&&(0,a.jsxs)("div",{className:"border-2 border-dashed rounded-lg p-4 text-center transition-colors shrink-0 ".concat(C?"border-[--primary] bg-[rgba(var(--primary-rgb),0.05)]":"border-[--border] hover:border-[--muted-foreground]"),onDragOver:e=>{e.preventDefault(),E(!0)},onDragLeave:e=>{e.preventDefault(),E(!1)},onDrop:e=>{e.preventDefault(),E(!1);let t=e.dataTransfer.files[0];t&&et(t)},children:[(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)("p",{className:"text-sm text-[--muted-foreground]",children:"íì¼ì
1 ëëê·¸íê±°ë í´ë¦íì¬ ì
ë¡ë"}),(0,a.jsx)("button",{type:"button",onClick:()=>{var e;return null===(e=K.current)||void 0===e?void 0:e.click()},className:"px-3 py-1.5 text-sm bg-[--primary] text-[--primary-foreground] rounded hover:bg-[--primary-hover] disabled:opacity-50",disabled:y,children:y?"ì
ë¡ë ì¤...":"íì¼ ì í"}),(0,a.jsx)("input",{ref:K,type:"file",onChange:e=>{var t;let r=null===(t=e.target.files)||void 0===t?void 0:t[0];r&&et(r)},className:"hidden",accept:"image/*,video/*,audio/*,.pdf,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.txt,.csv,.webm",disabled:y})]}),y&&(0,a.jsxs)("div",{className:"mt-2 space-y-1",children:[(0,a.jsxs)("div",{className:"flex justify-between text-xs",children:[(0,a.jsx)("span",{children:"ì
ë¡ë ì¤..."}),(0,a.jsxs)("span",{children:[N,"%"]})]}),(0,a.jsx)("div",{className:"w-full bg-[--muted] rounded-full h-1.5",children:(0,a.jsx)("div",{className:"bg-[--primary] h-1.5 rounded-full transition-all",style:{width:"".concat(N,"%")}})})]})]}),(0,a.jsxs)("div",{className:"flex gap-2 shrink-0",children:[(0,a.jsx)("input",{type:"text",placeholder:"íì¼ëª
ì¼ë¡ ê²ì...",value:M,onChange:e=>S(e.target.value),className:"flex-1 px-3 py-2 text-sm border border-[--border] rounded-lg focus:outline-none focus:ring-2 focus:ring-[--primary] bg-[--card-background] text-[--foreground]",disabled:D}),(0,a.jsxs)("select",{value:T,onChange:e=>{U(e.target.value),"FOLDER"===e.target.value&&(W(null),_([{id:null,name:"ì ì²´"}]))},className:"px-3 py-2 text-sm border border-[--border] rounded-lg bg-[--card-background] text-[--foreground] min-w-[90px]",disabled:D,children:[(0,a.jsx)("option",{value:"ALL",children:"ì ì²´"}),(0,a.jsx)("option",{value:"IMAGE",children:"ì´ë¯¸ì§"}),(0,a.jsx)("option",{value:"FILE",children:"íì¼"}),(0,a.jsx)("option",{value:"FOLDER",children:"í´ë"})]}),!f&&(0,a.jsx)("button",{type:"button",onClick:()=>
1{O(!D),w([]),P(new Set)},className:"px-3 py-2 text-xs rounded-lg ".concat(D?"bg-[--destructive] text-white":"bg-[--muted] text-[--foreground]"),disabled:y||R,children:D?"â ì¢
ë£":"\uD83D\uDDD1ï¸ ìì "}),D&&(0,a.jsxs)("button",{onClick:()=>{H({title:"íì¼ ìì ",message:"ì íí ".concat(A.size,"ê°ì íì¼ì ìì íìê² ìµëê¹?"),onConfirm:async()=>{try{F(!0);let e=await o.Ju.deleteFiles(Array.from(A));e.deletedCount>0&&(q("success","".concat(e.deletedCount,"ê° ìì ìë£")),G.invalidateQueries({queryKey:["files"]}),P(new Set))}catch(e){q("error",e instanceof Error?e.message:"ìì ì¤ë¥")}finally{F(!1)}}})},className:"px-3 py-2 text-xs bg-[--destructive] text-white rounded-lg",type:"button",disabled:0===A.size||R,children:["\uD83D\uDDD1ï¸ (",A.size,")"]})]}),B.length>1&&(0,a.jsx)("div",{className:"flex items-center gap-1 text-sm text-[--muted-foreground] shrink-0",children:B.map((e,t)=>(0,a.jsxs)(n.Fragment,{children:[t>0&&(0,a.jsx)("span",{className:"mx-1",children:"/"}),(0,a.jsx)("button",{type:"button",onClick:()=>eo(t),className:"hover:text-[--primary] ".concat(t===B.length-1?"text-[--foreground] font-medium":""),children:e.name})]},t))}),(0,a.jsxs)("div",{className:"flex-1 overflow-y-auto min-h-0",children:[X&&!V?(0,a.jsx)("div",{className:"flex items-center justify-center h-40",children:(0,a.jsx)(d.a,{})}):Q?(0,a.jsx)("div",{className:"text-center text-red-600 py-8",children:"íì¼ì ë¶ë¬ì¤ë ì¤ ì¤ë¥ê° ë°ìíìµëë¤."}):V&&(null===(t=V.pages[0])||void 0===t?void 0:t.data.items.filter(es).length)!==0?(0,a.jsx)("div",{className:"grid gap-1",style:{gridTemplateColumns:"repeat(".concat(b,", minmax(0, 1fr))")},children:V.pages.map(e=>e.data.items.filter(es).map(e=>(0,a.jsx)(u,{file:e,isSelected:v.some(t=>t.id===e.id),onToggleSelection:ea,onFolderClick:en,isDeleteMode:D,isSelectedForDeletion:A.has(e.id),onToggleDeleteSelection:e=>P(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},e.id)))}):(0,a.jsx)("div",{className:"text-center text-[--muted-foreground] py-8",children:I?'"'.concat(I,'" ê²ì ê²°ê³¼ê° ììµëë¤'):"FOLDER"===T?"ì´ ìì¹ì í´ëê° ììµëë¤":"ì
ë¡ëë íì¼ì´ ììµëë¤"}),$&&(0,a.jsx)("div",{className:"flex justify-center py-4",children:(0,a.jsx)(d.a,{})}),Z&&!$&&(0,a.jsx)("div",{className:"flex justify-center py-4",children:(0,a.jsx)("button",{onClick:()=>Y(),className:"px-4 py-2 text-sm bg-[--primary] text-[--primary-foreground] rounded hover:bg-[--primary-hover]",children:"ë 보기"})})]})]}),!D&&v.length>0&&(0,a.jsxs)("div",{className:"flex justify-end gap-2 pt-3 border-t border-[--border] shrink-0",children:[(0,a.jsx)("button",{onClick:()=>w([]),className:"px-4 py-2 text-sm text-[--muted-foreground] hover:text-[--foreground]",type:"button",children:"ì í í´ì "}),(0,a.jsxs)("button",{onClick:()=>{v.forEach(e=>p(e.fileUrl,e.originalName,e.fileType)),er(),null==x||x()},className:"px-4 py-2 text-sm bg-[--primary] text-[--primary-foreground] rounded hover:bg-[--primary-hover]",type:"button",children:["ì íí기 (",v.length,")"]})]})]})}},51883:function(e,t,r){"use strict";r.d(t,{i:function(){return m}});var a=r(39526),n=r(29827),o=r(21770),s=r(2265),l=r(18676),i=r(21966);let c=/^image\/jpe?g$/i,d=async e=>{if(!c.test(e.type))return null;let t=new DataView(await e.slice(0,65536).arrayBuffer());if(t.byteLength<4||65496!==t.getUint16(0,!1))return null;let r=2;for(;r+4<=t.byteLength&&255===t.getUint8(r);){let e=t.getUint16(r,!1);if(r+=2,65498===e||65497===e||r+2>t.byteLength)break;let a=t.getUint16(r,!1);if(a<2||r+a>t.byteLength)break;if(65505===e){let e=r+2;if(e+6>t.byteLength)return null;if(!(1165519206===t.getUint32(e,!1)&&0===t.getUint16(e+4,!1))){r+=a;continue}let n=e+6;if(n+8>t.byteLength)return null;let o=t.getUint16(n,!1),s=18761===o;if(!s&&19789!==o||42!==t.getUint16(n+2,s))return null;let l=n+t.getUint32(n+4,s);if(l+2>t.byteLength)return null;let i=t.getUint16(l,s);for(let e=0;e<i;e+=1){let r=l+2+12*e;if(r+12>t.byteLength)break;if(274===t.getUint16(r,s))return t.getUint16(r+8,s)}break}r+=a}return null},u=async e=>{let t;if("function"==typeof createImageBitmap)try{t=await createImageBitmap(e)}catch(r){console.warn("createImageBitmap ê¸°ë° JPEG ì ê·í ì¤í¨, Image ë¡ëë¡ ì¬ìë:",r),t=await (0,i.po)(e)}else t=await (0,i.po)(e);
1try{let r=(0,i.fg)(t)?t.width:t.naturalWidth||t.width,a=(0,i.fg)(t)?t.height:t.naturalHeight||t.height,n=document.createElement("canvas");n.width=r,n.height=a;let o=n.getContext("2d");if(!o)throw Error("Canvas context를 ê°ì ¸ì¬ ì ììµëë¤.");o.drawImage(t,0,0,r,a);let s=await new Promise((e,t)=>{n.toBlob(r=>{if(r){e(r);return}t(Error("JPEG ì ê·í ë³íì ì¤í¨íìµëë¤."))},"image/jpeg",.95)});return new File([s],e.name,{type:"image/jpeg",lastModified:e.lastModified||Date.now()})}finally{(0,i.fg)(t)&&t.close()}},m=(e,t)=>{let[r,c]=(0,s.useState)(null),m=(0,n.NL)(),h=(0,o.D)({mutationFn:a.g.uploadImage});return{handleUpload:async r=>{try{if(0===r.length)return{success:!1,error:"ì
ë¡ëí ì´ë¯¸ì§ê° ììµëë¤."};let l=[];for(let t of r){let r=t.file,c=null;try{(c=await d(r))&&1!==c&&!t.addWatermark&&(r=await u(r))}catch(e){console.warn("EXIF ë°©í¥ê° ì ê·í ì¤í¨, ì본ì¼ë¡ ì§í:",e)}let m=null!==c&&1!==c;if(t.addWatermark){let l=!1;try{var a,n,o,s;r=await (0,i.addWatermarkInBrowser)(r,e,{position:t.watermarkPosition||"bottom-right",opacity:null!==(a=t.watermarkOpacity)&&void 0!==a?a:.7,scale:null!==(n=t.watermarkScale)&&void 0!==n?n:.3,margin:null!==(o=t.watermarkMargin)&&void 0!==o?o:20,rotation:null!==(s=t.watermarkRotation)&&void 0!==s?s:0}),l=!0}catch(e){console.error("â ï¸ ìí°ë§í¬ ì¶ê° ì¤í¨, ì본 ì
ë¡ë:",e)}if(m&&!l)try{r=await u(r)}catch(e){console.warn("ìí°ë§í¬ ì¤í¨ í EXIF ë°©í¥ê° ì ê·íë ì¤í¨, ì본ì¼ë¡ ì§í:",e)}}/^image\/(jpe?g|png|webp)$/i.test(r.type)&&(r=await (0,i.resizeImageInBrowser)(r,{maxWidth:1920}));let p=await h.mutateAsync({file:r,caption:t.caption||void 0,addWatermark:!1});l.push({url:p.photoUrl,caption:p.caption,id:Number(p.id)})}return m.invalidateQueries({queryKey:["articleImages"]}),t(l),c(null),{success:!0,uploadedImages:l}}catch(t){console.error("[ERROR] ì´ë¯¸ì§ ì
ë¡ë ì¤í¨:",t);let e="ì´ë¯¸ì§ ì
ë¡ëì ì¤í¨íìµëë¤. ê´ë¦¬ììê² ë¬¸ìí´ì£¼ì¸ì.";return t instanceof l.s&&403===t.statusCode&&(e="ê¸°ì¬ ìì± ê¶íì´ ììµëë¤."),c(e),{success:!1,error:e}}},uploadError:r,setUploadError:c,isUploading:h.isPending}}},20956:function(e,t,r){"use strict";r.r(t),r.d(t,{ImageUploadDialog:function(){return eu}});var a=r(57437),n=r(2265),o=r(98702),s=r(51599);let l=e=>{let{isOpen:t,title:r,message:l,warningMessage:i,confirmText:c,itemCount:d,onConfirm:u,onCancel:m,isDeleting:h=!1}=e,[p,x]=(0,n.useState)(!1),g=()=>{x(!1),m()}
1,f=p&&!h;return(0,a.jsxs)(o.u_,{isOpen:t,onClose:g,size:"lg",children:[(0,a.jsx)(o.xB,{onClose:g,children:r}),(0,a.jsx)(o.hz,{children:(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsx)("p",{className:"text-[--foreground] whitespace-pre-line",children:l}),i&&(0,a.jsxs)("div",{className:"flex gap-3 p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg",children:[(0,a.jsx)(s.L8,{className:"w-5 h-5 text-red-600 dark:text-red-400 flex-shrink-0 mt-0.5"}),(0,a.jsx)("p",{className:"text-sm text-red-700 dark:text-red-300 whitespace-pre-line",children:i})]}),(0,a.jsxs)("label",{className:"flex items-center gap-2.5 cursor-pointer select-none ml-2",htmlFor:"delete-confirm-checkbox",children:[(0,a.jsx)("input",{id:"delete-confirm-checkbox",type:"checkbox",checked:p,onChange:e=>x(e.target.checked),disabled:h,className:"w-4 h-4 rounded border-gray-300 text-red-600 focus:ring-red-500 cursor-pointer accent-red-600"}),(0,a.jsxs)("span",{className:"text-sm text-[--foreground]",children:[c,"ì ëìí©ëë¤."]})]})]})}),(0,a.jsx)(o.mz,{children:(0,a.jsxs)("div",{className:"flex justify-end space-x-3",children:[(0,a.jsx)("button",{onClick:g,className:"px-4 py-2 bg-[--border] text-[--foreground] rounded-lg hover:opacity-90 transition-opacity",disabled:h,children:"ì·¨ì"}),(0,a.jsx)("button",{onClick:()=>{p&&u()},disabled:!f,className:"px-4 py-2 bg-red-600 text-white rounded-lg hover:bg-red-700 disabled:opacity-50 disabled:cursor-not-allowed transition-all",children:h?"ìì ì¤...":"ìì "})]})})]})};var i=r(7761),c=r(39174),d=r(71632);let u=e=>{let[t,r]=(0,n.useState)(!1),[a,o]=(0,n.useState)({x:0,y:0,width:0,height:0}
1),[s,l]=(0,n.useState)(!1),[i,c]=(0,n.useState)(!1),[d,u]=(0,n.useState)(""),[m,h]=(0,n.useState)({x:0,y:0}),[p,x]=(0,n.useState)({x:0,y:0,width:0,height:0}),g=(0,n.useRef)(null),f=(0,n.useRef)(null);(0,n.useEffect)(()=>{r(!1),o({x:0,y:0,width:0,height:0})},[e]);let b=(0,n.useCallback)(()=>{if(!g.current||!f.current)return null;let e=g.current,t=f.current,r=e.getBoundingClientRect(),a=t.getBoundingClientRect();return{actualWidth:r.width,actualHeight:r.height,offsetX:r.left-a.left,offsetY:r.top-a.top,containerWidth:a.width,containerHeight:a.height}},[]),v=(0,n.useCallback)(()=>{let e=b();if(!e)return;let{actualWidth:t,actualHeight:a,offsetX:n,offsetY:s}=e,l=.8*t,i=.8*a;o({x:n+(t-l)/2,y:s+(a-i)/2,width:l,height:i}),r(!0)},[b]),w=(0,n.useCallback)(()=>{r(!1),o({x:0,y:0,width:0,height:0})},[]),y=(0,n.useCallback)(t=>{if(!t)return;let n=b();if(!n)return;let{actualWidth:o,actualHeight:s,offsetX:l,offsetY:i}=n;t(e,{x:(a.x-l)/o,y:(a.y-i)/s,width:a.width/o,height:a.height/s}),r(!1)},[a,e,b]),j=(0,n.useCallback)(e=>{if(!t)return;e.preventDefault(),e.stopPropagation();let r="touches"in e?e.touches[0].clientX:e.clientX,n="touches"in e?e.touches[0].clientY:e.clientY;l(!0),h({x:r,y:n}),x({...a})},[t,a]),N=(0,n.useCallback)((e,r)=>{if(!t)return;e.preventDefault(),e.stopPropagation();let n="touches"in e?e.touches[0].clientX:e.clientX,o="touches"in e?e.touches[0].clientY:e.clientY;c(!0),u(r),h({x:n,y:o}),x({...a})},[t,a]),k=(0,n.useCallback)(e=>{if(!s&&!i||!t)return;let r=b();if(!r)return;let{actualWidth:n,actualHeight:l,offsetX:c,offsetY:u}=r,h="touches"in e?e.touches[0].clientX:e.clientX,x="touches"in e?e.touches[0].clientY:e.clientY,g=h-m.x,f=x-m.y,v=c+n,w=u+l;if(s)o({...a,x:Math.max(c,Math.min(p.x+g,v-a.width)),y:Math.max(u,Math.min(p.y+f,w-a.height))});else if(i){let e={...p};if(d.includes("n")){let t=Math.max(u,p.y+f),r=p.height-(t-p.y);r>20&&(e.y=t,e.height=r)}if(d.includes("s")){let t=Math.min(w-p.y,p.height+f);t>20&&(e.height=t)}if(d.includes("w")){let t=Math.max(c,p.x+g),r=p.width-(t-p.x);r>20&&(e.x=t,e.width=r)}if(d.includes("e")){let t=Math.min(v-p.x,p.width+g);t>20&&(e.width=t)}o(e)}},[s,i,t,m,p,a,d,b]);return{isCropMode:t,cropArea:a,cropImageRef:g,cropContainerRef:f,handleStartCrop:v,handleCancelCrop:w,handleApplyCrop:y,handleCropMouseDown:j,handleResizeMouseDown:N,handleMouseMove:k,handleMouseUp:(0,n.useCallback)(()=>{l(!1),c(!1),u("")},[])}};var m=r(21966);let h=(e,t,r)=>{let[a,o]=(0,n.useState)(null);return(0,n.useEffect)(()=>{let a=!0,n=setTimeout(async()=>{if(!e||r||!t||!e.addWatermark){o(null);return}try{var n;let r=await (0,m.eK)(e.preview,t,{position:e.watermarkPosition,scale:e.watermarkScale,margin:e.watermarkMargin,rotation:e.watermarkRotation,opacity:null!==(n=e.watermarkOpacity)&&void 0!==n?n:.7});a&&o(r)}catch(e){console.error("Preview generation failed",e)}},50);return()=>{a=!1,clearTimeout(n)}},[null==e?void 0:e.preview,null==e?void 0:e.addWatermark,null==e?void 0:e.watermarkPosition,null==e?void 0:e.watermarkScale,null==e?void 0:e.watermarkMargin,null==e?void 0:e.watermarkRotation,null==e?void 0:e.watermarkOpacity,t,r]),{previewWithWatermark:a}},p=e=>{let{imageSrc:t,onClose:r}=e;return(0,n.useEffect)(()=>{let e=e=>{"Escape"===e.key&&r()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[r]),(0,a.jsxs)("div",{className:"fixed inset-0 z-[100001] bg-black/95 flex items-center justify-center",onClick:r,role:"dialog","aria-modal":"true",children:[(0,a.jsx)("button",{type:"button",className:"absolute top-4 right-4 text-white/80 hover:text-white bg-black/50 hover:bg-black/70 rounded-full w-12 h-12 flex items-center justify-center transition-all z-10",onClick:e=>{e.stopPropagation(),r()},children:(0,a.jsx)("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M6 18L18 6M6 6l12 12"})})}),(0,a.jsx)("div",{className:"absolute bottom-4 left-1/2 transform -translate-x-1/2 text-white/60 text-sm",children:"í´ë¦íê±°ë ESC를 ëë¬ ë«ê¸°"}),(0,a.jsx)("div",{className:"relative max-w-[95vw] max-h-[95vh] cursor-zoom-out",onClick:e=>{e.stopPropagation(),r()},children:(0,a.jsx)("img",{src:t,alt:"íë 보기",className:"max-w-[95vw] max-h-[95vh] object-contain"})})]})},x=e=>{let{pendingUploads:t,selectedIndex:r,onSelectIndex:n,onExcludeToggle:o,isMobile:s}=e;return(0,a.jsxs)("div",{className:"flex flex-col bg-[--muted]/20 ".concat(s?"border-b flex-shrink-0":"w-72 border-r"," border-[--border]"),
1children:[(0,a.jsx)("div",{className:"border-b border-[--border] ".concat(s?"p-3":"p-4"),children:(0,a.jsxs)("h3",{className:"font-semibold text-[--foreground] ".concat(s?"text-xs":"text-sm"),children:["ì´ë¯¸ì§ ëª©ë¡ (",t.length,"ê°)"]})}),(0,a.jsx)("div",{className:"overflow-y-auto overscroll-contain space-y-2 ".concat(s?"flex-shrink-0 p-2 max-h-[160px]":"flex-1 p-3"),children:t.map((e,t)=>(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>n(t),className:"w-full flex items-center rounded-xl border-2 transition-all duration-200 ".concat(s?"gap-2 p-2":"gap-3 p-3"," ").concat(r===t?"border-[--primary] border-opacity-20 bg-[rgba(var(--primary-rgb),0.05)] hover:bg-[rgba(var(--primary-rgb),0.08)]":"border-[--border] border-opacity-50 bg-[--card-background] hover:border-[--primary] hover:border-opacity-20 hover:bg-[rgba(var(--primary-rgb),0.03)]"," ").concat(e.excluded?"opacity-50":""),children:[(0,a.jsxs)("div",{className:"relative flex-shrink-0",children:[(0,a.jsx)("div",{className:"rounded-lg overflow-hidden border border-[--border] bg-[--muted] flex items-center justify-center ".concat(s?"w-12 h-12":"w-16 h-16"),children:(0,a.jsx)("img",{src:e.preview,alt:"",className:"max-w-full max-h-full object-contain"})}),(0,a.jsx)("div",{className:"absolute -bottom-1.5 -left-1.5 bg-[--primary] text-[--primary-foreground] font-bold rounded-full flex items-center justify-center shadow-md ".concat(s?"w-5 h-5 text-[10px]":"w-6 h-6 text-xs"),children:t+1})]}),(0,a.jsxs)("div",{className:"flex-1 min-w-0 text-left",children:[(0,a.jsx)("div",{className:"font-medium text-[--foreground] truncate ".concat(s?"text-[10px]":"text-xs"),children:e.file.name}),(0,a.jsxs)("div",{className:"text-[--muted-foreground] mt-1 ".concat(s?"text-[9px]":"text-[10px]"),children:[(e.file.size/1024).toFixed(1)," KB"]})]})]}),(0,a.jsx)("button",{type:"button",onClick:t=>{t.stopPropagation(),o(e.file.name,!e.excluded)},className:"absolute -top-2 -right-2 rounded-full border-2 flex items-center justify-center transition-all duration-200 shadow-md ".concat(s?"w-5 h-5":"w-6 h-6"," ").concat(e.excluded?"bg-gray-300 dark:bg-gray-700 border-gray-300 dark:border-gray-700 hover:bg-gray-400 dark:hover:bg-gray-600":"bg-[--primary] border-[--primary] hover:bg-[--primary-hover]"),children:!e.excluded&&(0,a.jsx)("svg",{className:"text-white ".concat(s?"w-3 h-3":"w-3.5 h-3.5"),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"3",d:"M5 13l4 4L19 7"})})})]},e.id))})]})};var g=r(45168);let f=e=>{let{cropArea:t,isMobile:r,onCropMouseDown:n,onResizeMouseDown:o,onCancelCrop:s,onApplyCrop:l}=e,i=r?"w-5 h-5":"w-4 h-4";return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"absolute border-2 border-blue-500 bg-transparent cursor-move select-none",style:{left:"".concat(t.x,"px"),top:"".concat(t.y,"px"),width:"".concat(t.width,"px"),height:"".concat(t.height,"px"),boxShadow:"0 0 0 9999px rgba(0, 0, 0, 0.5)"},onMouseDown:n,onTouchStart:n,children:[(0,a.jsx)("div",{className:"absolute inset-0 grid grid-cols-3 grid-rows-3 pointer-events-none",children:Array.from({length:9}).map((e,t)=>(0,a.jsx)("div",{className:"border border-white/30"},t))}),[{pos:"-top-2 -left-2",cursor:"cursor-nwse-resize",handle:"nw"},{pos:"-top-2 -right-2",cursor:"cursor-nesw-resize",handle:"ne"},{pos:"-bottom-2 -left-2",cursor:"cursor-nesw-resize",handle:"sw"},{pos:"-bottom-2 -right-2",cursor:"cursor-nwse-resize",handle:"se"},{pos:"-top-2 left-1/2 transform -translate-x-1/2",cursor:"cursor-ns-resize",handle:"n"},{pos:"-bottom-2 left-1/2 transform -translate-x-1/2",cursor:"cursor-ns-resize",handle:"s"},{pos:"-left-2 top-1/2 transform -translate-y-1/2",cursor:"cursor-ew-resize",handle:"w"},{pos:"-right-2 top-1/2 transform -translate-y-1/2",cursor:"cursor-ew-resize",handle:"e"}].map(e=>{let{pos:t,cursor:r,handle:n}=e;return(0,a.jsx)("div",{className:"absolute ".concat(t," bg-blue-500 border-2 border-white rounded-full ").concat(r," ").concat(i),onMouseDown:e=>o(e,n),onTouchStart:e=>o(e,n)},n)})]}),(0,a.jsxs)("div",{className:"absolute left-1/2 transform -translate-x-1/2 flex bg-black/90 rounded-lg z-20 ".concat(r?"bottom-2 gap-1.5 p-2":"bottom-4 gap-2 p-3"),children:[(0,a.jsx)("button",{type:"button",onClick:s,className:"bg-gray-600 hover:bg-gray-700 text-white rounded font-medium transition-colors ".concat(r?"px-3 py-1.5 text-xs":"px-4 py-2 text-sm"),children:"ì·¨ì"}),(0,a.jsx)("button",{type:"button",onClick:l,className:"bg-blue-600 hover:bg-blue-700 text-white rounded font-medium transition-colors ".concat(r?"px-3 py-1.5 text-xs":"px-4 py-2 text-sm"),children:"ì르기 ì ì©"})]})]})},b=e=>{let{icon:t,label:r,onClick:n,isMobile:o,title:s}=e;return(0,a.jsxs)("button",{type:"button",onClick:n,className:"group bg-white/95 dar
1k:bg-gray-800/95 hover:bg-white dark:hover:bg-gray-800 rounded-lg shadow-lg hover:shadow-xl transition-all duration-200 border border-gray-200 dark:border-gray-700 flex flex-col items-center justify-center gap-0.5 ".concat(o?"p-1.5 min-w-[3rem]":"p-2 min-w-[3.5rem]"),title:s,children:[t,(0,a.jsx)("span",{className:"font-medium text-gray-600 dark:text-gray-400 ".concat(o?"text-[10px]":"text-[11px]"),children:r})]})},v=e=>{let{selectedUpload:t,selectedIndex:r,isMobile:n,isCropMode:o,cropArea:s,cropImageRef:l,cropContainerRef:i,previewWithWatermark:c,onMouseMove:d,onMouseUp:u,onCropMouseDown:m,onResizeMouseDown:h,onStartCrop:p,onCancelCrop:x,onApplyCrop:v,onRotate:w,onFlip:y,hasCrop:j,onShowLightbox:N,onImageLoad:k}=e,C=!o&&t.addWatermark&&c||t.preview,E="text-gray-700 dark:text-gray-300 ".concat(n?"w-4 h-4":"w-5 h-5");return(0,a.jsxs)("div",{className:"group flex items-center justify-center bg-[--muted]/10 overflow-hidden relative ".concat(n?"h-[250px] flex-shrink-0":"flex-1 min-h-[300px]"),onMouseMove:d,onMouseUp:u,onMouseLeave:u,onTouchMove:d,onTouchEnd:u,style:{padding:n?"12px":"24px",maxHeight:n?void 0:t.addWatermark?"300px":"500px"},children:[(0,a.jsxs)("div",{ref:i,className:"relative w-full h-full flex items-center justify-center",children:[(0,a.jsx)("img",{ref:l,src:C,alt:"미리보기",className:"max-w-full max-h-full object-contain rounded-lg shadow-2xl select-none ".concat(o?"":"cursor-zoom-in"),draggable:!1,onLoad:k,onClick:()=>{o||N()},title:o?void 0:"í´ë¦íì¬ í¬ê² 보기"}),!o&&(0,a.jsx)("div",{className:"absolute bottom-2 left-1/2 transform -translate-x-1/2 bg-black/50 text-white text-[10px] px-2 py-1 rounded-full opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none whitespace-nowrap z-10",children:"ì´ë¯¸ì§ë¥¼ í´ë¦íì¬ ì본 í¬ê¸°ë¡ 보기"}),0!==t.rotation&&void 0!==t.rotation&&!o&&(0,a.jsxs)("div",{className:"absolute bg-black/80 text-white rounded-lg font-semibold z-10 ".concat(n?"top-2 left-2 px-2 py-1 text-xs":"top-4 left-4 px-3 py-1.5 text-sm"),children:[t.rotation,"\xb0 íì ë¨"]}),o&&l.current&&(0,a.jsx)(f,{cropArea:s,isMobile:n,onCropMouseDown:m,onResizeMouseDown:h,onCancelCrop:x,onApplyCrop:v})]}),!o&&(0,a.jsxs)("div",{className:"absolute right-4 flex ".concat(n?"top-2 gap-1.5":"top-4 gap-2"),children:[j&&(0,a.jsx)(b,{icon:(0,a.jsx)(g.QeJ,{className:E}),label:"ì르기",onClick:p,isMobile:n,title:"ì´ë¯¸ì§ ì르기"}),w&&(0,a.jsx)(b,{icon:(0,a.jsx)(g.L6Y,{className:E}),label:"íì ",onClick:()=>w(r,"clockwise"),isMobile:n,title:"ìê³ë°©í¥ 90ë íì "}),y&&(0,a.jsx)(b,{icon:(0,a.jsx)(g.ewL,{className:E,style:{transform:"rotate(-90deg)"}}),label:"ë°ì ",onClick:()=>y(r),isMobile:n,title:"ì¢ì° ë°ì "})]})]})},w=e=>{let{value:t,onChange:r,min:o=-180,max:s=180,size:l=200}
1=e,[i,c]=(0,n.useState)(!1),[d,u]=(0,n.useState)(t),m=(0,n.useRef)(null);(0,n.useEffect)(()=>{i||u(t)},[t,i]);let h=l/2+20,p=l/2,x=l/2,f=l/2-20,b=e=>Math.round((Math.max(-90,Math.min(90,e))+90)/180*(s-o)+o),v=(e,t,r,a)=>{let n=a*Math.PI/180;return{x:e+r*Math.cos(n),y:t+r*Math.sin(n)}},w=e=>{if(!m.current)return;let t=m.current.getBoundingClientRect(),a="touches"in e?e.touches[0].clientX:e.clientX,n="touches"in e?e.touches[0].clientY:e.clientY,o=a-t.left-p,s=180*Math.atan2(n-t.top-x,o)/Math.PI;s<0&&(s+=360);let l=s;l>=0&&l<90?l=360:l>=90&&l<180&&(l=180);let i=b(l-270);u(i),r(i)},y=e=>{c(!0),w(e)};(0,n.useEffect)(()=>{let e=e=>{i&&(e.preventDefault(),w(e))},t=()=>c(!1);return i&&(window.addEventListener("mousemove",e,{passive:!1}),window.addEventListener("touchmove",e,{passive:!1}),window.addEventListener("mouseup",t),window.addEventListener("touchend",t)),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("touchmove",e),window.removeEventListener("mouseup",t),window.removeEventListener("touchend",t)}},[i]);let j=i?d:t,N=(Math.max(o,Math.min(s,j))-o)/(s-o)*180-90+270,k=v(p,x,f,N),C=v(p,x,f,180),E=v(p,x,f,360),M="M ".concat(C.x," ").concat(C.y," A ").concat(f," ").concat(f," 0 0 1 ").concat(E.x," ").concat(E.y),S=v(p,x,f,270),I="M ".concat(S.x," ").concat(S.y," A ").concat(f," ").concat(f," 0 0 ").concat(N>=270?1:0," ").concat(k.x," ").concat(k.y);return(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center select-none",children:[(0,a.jsx)("div",{className:"relative cursor-pointer",onMouseDown:y,onTouchStart:y,style:{width:l,height:h},children:(0,a.jsxs)("svg",{ref:m,width:l,height:h,className:"overflow-visible",children:[(0,a.jsx)("path",{d:M,fill:"none",stroke:"currentColor",strokeWidth:"4",strokeLinecap:"round",className:"text-[--border]"}),0!==j&&(0,a.jsx)("path",{d:I,fill:"none",stroke:"currentColor",strokeWidth:"4",strokeLinecap:"round",className:"text-[--primary]"}),(0,a.jsx)("circle",{cx:S.x,cy:S.y,r:"2",fill:"currentColor",className:"text-[--muted-foreground]"}),(0,a.jsx)("text",{x:C.x-10,y:C.y,className:"text-[10px] fill-[--muted-foreground]",textAnchor:"end",alignmentBaseline:"middle",children:"-180\xb0"}),(0,a.jsx)("text",{x:E.x+10,y:E.y,className:"text-[10px] fill-[--muted-foreground]",textAnchor:"start",alignmentBaseline:"middle",children:"180\xb0"}),!i&&(0,a.jsx)("circle",{cx:k.x,cy:k.y,r:8,fill:"white",stroke:"currentColor",strokeWidth:"3",className:"text-[--primary] drop-shadow-md transition-all duration-75 cursor-grab active:cursor-grabbing"})]})}),(0,a.jsxs)("div",{className:"flex flex-col items-center gap-1 -mt-4",children:[(0,a.jsxs)("span",{className:"font-mono font-bold text-[--primary] ".concat(l<150?"text-xs":"text-sm"),children:[j,"\xb0"]}),(0,a.jsxs)("button",{type:"button",onClick:()=>r(0),className:"text-[10px] text-[--muted-foreground] hover:text-[--primary] transition-colors flex items-center gap-1",title:"0ëë¡ ì´ê¸°í",children:[(0,a.jsx)(g.L6Y,{className:"w-3 h-3"}),(0,a.jsx)("span",{children:"0\xb0 ì´ê¸°í"})]})]})]})},y=[{value:"top-left",label:"ì¢ì",icon:"â"},{value:"top",label:"ìë¨",icon:"â"},{value:"top-right",label:"ì°ì",icon:"â"},{value:"left",label:"ì¢ì¸¡",icon:"â"},{value:"center",label:"ì¤ì",icon:"â"},{value:"right",label:"ì°ì¸¡",icon:"â"},{value:"bottom-left",label:"ì¢í",icon:"â"},{value:"bottom",label:"íë¨",icon:"â"},{value:"bottom-right",label:"ì°í",icon:"â"}],j=e=>{let{label:t,value:r,display:n,min:o,max:s,step:l,onChange:i,isMobile:c}=e;return(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex justify-between mb-1",children:[(0,a.jsx)("label",{className:"font-semibold text-[--foreground] ".concat(c?"text-[10px]":"text-xs"),children:t}),(0,a.jsx)("span",{className:"text-[--muted-foreground] ".concat(c?"text-[10px]":"text-xs"),children:n})]}),(0,a.jsx)("input",{type:"range",min:o,max:s,step:l,value:r,onChange:e=>i(Number(e.target.value)),className:"w-full h-1.5 bg-gray-200 rounded-lg appearance-none cursor-pointer dark:bg-gray-700 accent-[--primary]"})]})},N=e=>{var t,r,n,o,s,l;let{selectedUpload:i,isMobile:c,isFetchingWatermark:d,logoUrl:u,onWatermarkToggle:m,onPositionChange:h,onRotationChange:p,onMarginChange:x,onScaleChange:g,onOpacityChange:f}=e;return i.excluded?null:(0,a.jsxs)("div",{className:"pt-3 border-t border-[--border] ".concat(c?"space-y-2":"space-y-3"),children:[d?(0,a.jsxs)("div",{className:"flex items-center gap-2 py-1",children:[(0,a.jsx)("div",{className:"w-4 h-4 rounded-full border-2 border-[--muted] border-t-[--primary] animate-spin"}),(0,a.jsx)("span",{className:"text-xs text-[--muted-foreground]",children:"ìí°ë§í¬ ì¤ì íì¸ ì¤..."})]}):(0,a.jsxs)(a.Fragment,{children:[!u&&(0,a.jsxs)("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 text-yellow-800 dark:text-yellow-200 p-3 rounded-lg text-xs mb-2 border border-yellow-200 dark:border-yellow-800/30",children:[(0,a.jsx)("span",{className:"mr-1",children:"â ï¸"})," ìí°ë§í¬ ì´ë¯¸ì§ê° ì¤ì ëì§ ìììµëë¤.",(0,a.jsxs)("a",{href:"/admin/settings/general",target:"_blank",rel:"noopener noreferrer",className:"underline ml-1 font-semibold hover:text-yellow-900 dark:hover:text-yellow-100",children:["íê²½ì¤ì ",">"," ì¼ë°ì¤ì ",">"," ì¬ì´í¸ì¤ì "]}),"ìì ìí°ë§í¬ ì´ë¯¸ì§ë¥¼ ì¤ì í ì ììµëë¤."]}),(0,a.jsxs)("label",{className:"flex items-center ".concat(u?"cursor-pointer":"cursor-not-allowed opacity-50"," ").concat(c?"gap-1.5":"gap-2"),children:[(0,a.jsx)("input",{type:"checkbox",checked:i.addWatermark||!1,disabled:!u,onChange:e=>m(e.target.checked),className:"rounded border-2 border-[--border] text-[--primary] focus:ring-2 focus:ring-[--primary] focus:ring-offset-0 ".concat(u?"cursor-pointer":"cursor-not-allowed"," ").concat(c?"w-4 h-4":"w-5 h-5")}),(0,a.jsx)("span",{className:"font-semibold text-[--foreground] ".concat(c?"text-xs":"text-sm"),children:"ìí°ë§í¬ ì¶ê°"}),(0,a.jsx)("span",{className:"text-[--muted-foreground] ".concat(c?"text-[10px]":"text-xs"),children:"(ìí°ë§í¬ê° ì´ë¯¸ì§ì íìë©ëë¤)"})]})]}),i.addWatermark&&(0,a.jsxs)("div",{className:"pt-2 ".concat(c?"flex flex-col gap-3":"grid grid-cols-12 gap-2"),children:[h&&(0,a.jsx)("div",{className:c?"w-full":"col-span-3 min-w-[120px]",children:(0,a.jsxs)("div",{className:"h-full border border-[--border] rounded-lg p-2 bg-[--muted]/10 flex flex-col",children:[(0,a.jsx)("label",{className:"font-semibold text-[--foreground] block mb-2 text-center ".concat(c?"text-[10px]":"text-xs"),children:"ìì¹"}),(0,a.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,a.jsx)("div",{className:"bg-[--muted]/30 p-1.5 rounded-lg grid grid-cols-3 gap-1 w-full aspect-square max-w-[140px]",children:y.map(e=>(0,a.jsx)("button",{type:"button",title:e.label,onClick:()=>h(e.value),className:"w-full h-full flex items-center justify-center rounded transition-all aspect-square ".concat(c?"text-sm":"text-base"," ").concat((i.watermarkPosition||"bottom-right")===e.value?"bg-[--primary] text-[--primary-foreground] shadow-sm font-bold":"hover:bg-[--bg] text-[--muted-foreground] hover:text-[--foreground]"),children:e.icon},e.value))})})]})}),(0,a.jsx)("div",{className:c?"w-full":"col-span-5 flex flex-col",children:(0,a.jsxs)("div",{className:"h-full border border-[--border] rounded-lg p-3 bg-[--muted]/10 flex flex-col justify-center gap-3",children:[x&&(0,a.jsx)(j,{label:"ê°ì¥ì리 ê°ê²©",value:null!==(t=i.watermarkMargin)&&void 0!==t?t:20,display:"".concat(null!==(r=i.watermarkMargin)&&void 0!==r?r:20,"px"),min:0,max:100,step:5,onChange:x,isMobile:c}),g&&(0,a.jsx)(j,{label:"ìí°ë§í¬ í¬ê¸°",value:null!==(n=i.watermarkScale)&&void 0!==n?n:.3,display:"".concat(Math.round((null!==(o=i.watermarkScale)&&void 0!==o?o:.3)*100),"%"),min:.1,max:1,step:.
105,onChange:g,isMobile:c}),f&&(0,a.jsx)(j,{label:"ìí°ë§í¬ í¬ëª
ë",value:null!==(s=i.watermarkOpacity)&&void 0!==s?s:.7,display:"".concat(Math.round((null!==(l=i.watermarkOpacity)&&void 0!==l?l:.7)*100),"%"),min:0,max:1,step:.05,onChange:f,isMobile:c})]})}),p&&(0,a.jsx)("div",{className:c?"w-full":"col-span-4 flex flex-col",children:(0,a.jsxs)("div",{className:"h-full border border-[--border] rounded-lg p-2 bg-[--muted]/10 flex flex-col",children:[(0,a.jsx)("label",{className:"font-semibold text-[--foreground] block mb-2 text-center ".concat(c?"text-[10px]":"text-xs"),children:"íì "}),(0,a.jsx)("div",{className:"flex-1 flex items-center justify-center pb-2",children:(0,a.jsx)(w,{value:i.watermarkRotation||0,onChange:p,size:c?140:180})})]})})]})]})},k=e=>{let{includedCount:t,isMobile:r,isUploading:n,onClose:o,onSubmit:s}=e;return(0,a.jsxs)("div",{className:"flex justify-between items-center border-t border-[--border] bg-[--muted]/20 ".concat(r?"px-4 py-3 flex-col gap-3":"px-6 py-4"),children:[!r&&(0,a.jsx)("div",{className:"flex items-center gap-4",children:(0,a.jsx)("div",{className:"text-sm text-[--muted-foreground]",children:t>0?(0,a.jsxs)("span",{children:[(0,a.jsxs)("span",{className:"text-[--primary] font-bold text-lg",children:[t,"ê°"]})," ","ì´ë¯¸ì§ ì
ë¡ë ì¤ë¹ë¨"]}):(0,a.jsx)("span",{className:"text-[--destructive] font-semibold",children:"ì
ë¡ëí ì´ë¯¸ì§ ìì"})})}),(0,a.jsxs)("div",{className:"flex gap-3 ".concat(r?"w-full":""),children:[(0,a.jsx)("button",{onClick:o,type:"button",className:"text-[--muted-foreground] hover:text-[--foreground] hover:bg-[--muted] rounded-lg transition-all font-medium ".concat(r?"flex-1 px-4 py-2 text-sm":"px-5 py-2.5"),children:"ì·¨ì"}),(0,a.jsxs)("button",{onClick:s,type:"button",disabled:0===t||n,className:"rounded-lg font-semibold transition-all duration-200 flex items-center justify-center gap-2 ".concat(r?"flex-1 px-4 py-2 text-sm":"px-8 py-2.5"," ").concat(0===t||n?"bg-[--muted] text-[--muted-foreground] cursor-not-allowed":"bg-[--primary] text-[--primary-foreground] hover:bg-[--primary-hover] hover:scale-105 shadow-lg hover:shadow-xl"),children:[n&&(0,a.jsx)("div",{className:"border-2 border-current border-t-transparent rounded-full animate-spin ".concat(r?"w-3 h-3":"w-4 h-4")}),n?"ì
ë¡ë ì¤...":t>0?"".concat(t,"ê° ì´ë¯¸ì§ ì
ë¡ë"):"ì
ë¡ëí ì´ë¯¸ì§ ìì"]})]})]})};var C=r(91701),E=e=>{let{isOpen:t,onClose:r,pendingUploads:s,onCaptionChange:l,onExcludeToggle:i,onWatermarkToggle:m,onWatermarkPositionChange:g,onWatermarkRotationChange:f,onWatermarkMarginChange:b,onWatermarkScaleChange:w,onWatermarkOpacityChange:y,onRotate:j,onFlip:E,onCrop:M,onSubmit:S,errorMessage:I}
1=e,[L,T]=(0,n.useState)(!1),[U,D]=(0,n.useState)(0),O=(0,C.h)(),[R,F]=(0,n.useState)(!1),[,A]=(0,n.useState)(0),P=(0,n.useRef)(null),{data:z}=(0,d.a)({queryKey:["configs","value","DEFAULT_CAPTION_SUFFIX"],queryFn:async()=>{let e=await fetch("/api/configs?key=DEFAULT_CAPTION_SUFFIX");return e.ok&&(await e.json()).value||""},staleTime:3e5}),[W,B]=(0,n.useState)(!1);(0,n.useEffect)(()=>{z&&s[U]&&B((s[U].caption||"").endsWith(z))},[U,z,s]);let{data:_,isLoading:K}=(0,d.a)({queryKey:["configs","value","WATERMARK_IMAGE"],queryFn:async()=>{let e=await fetch("/api/configs?key=WATERMARK_IMAGE");return e.ok&&(await e.json()).value||null},staleTime:3e5}),q=(0,n.useMemo)(()=>_?(0,c.zg)(_,{transformToCloudFront:!0,width:1024}):null,[_]),{isCropMode:H,cropArea:G,cropImageRef:J,cropContainerRef:V,handleStartCrop:X,handleCancelCrop:Q,handleApplyCrop:Y,handleCropMouseDown:Z,handleResizeMouseDown:$,handleMouseMove:ee,handleMouseUp:et}=u(U),er=s[U],{previewWithWatermark:ea}=h(er,q,H);(0,n.useEffect)(()=>{U>=s.length&&s.length>0&&D(s.length-1)},[s.length,U]),(0,n.useEffect)(()=>{(null==er?void 0:er.addWatermark)&&setTimeout(()=>A(e=>e+1),10)},[null==er?void 0:er.addWatermark,U]);let en=(0,n.useCallback)(async()=>{T(!0);try{await S()}finally{T(!1)}},[S]),eo=(0,n.useCallback)(()=>Y(M),[Y,M]);if(!t)return null;let es=s.filter(e=>!e.excluded).length,el=s.length,ei=null==er?void 0:er.file.name;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.u_,{isOpen:t,onClose:r,size:"auto",closeOnOverlayClick:!1,children:(0,a.jsxs)("div",{className:"bg-[--card-background] rounded-lg flex flex-col shadow-xl ".concat(O?"w-[95vw] h-auto min-h-full":"w-[1100px] max-w-[95vw] h-auto"),children:[(0,a.jsxs)("div",{className:"flex justify-between items-center border-b border-[--border] ".concat(O?"px-4 py-3":"px-6 py-4"),children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h2",{className:"font-bold text-[--foreground] ".concat(O?"text-base":"text-xl"),children:"ì´ë¯¸ì§ ì
ë¡ë ë° ì¤ì "}),(0,a.jsxs)("p",{className:"text-[--muted-foreground] mt-1 ".concat(O?"text-xs":"text-sm"),children:[(0,a.jsx)("span",{className:"text-[--primary] font-semibold",children:es}),"/",el,"ê° ì´ë¯¸ì§ê° ì
ë¡ëë©ëë¤"]})]}),(0,a.jsx)("button",{onClick:r,className:"text-[--muted-foreground] hover:text-[--foreground] transition-colors font-light flex items-center justify-center hover:bg-[--muted] rounded-lg ".concat(O?"text-xl w-7 h-7":"text-2xl w-8 h-8"),type:"button",children:"â"})]}),I&&(0,a.jsxs)("div",{className:"mt-4 bg-red-50 dark:bg-red-950/90 border-2 border-red-500 rounded-xl flex items-center gap-3 ".concat(O?"mx-4 p-3":"mx-6 p-4"),children:[(0,a.jsx)("div",{className:"flex-shrink-0 bg-red-500 rounded-full flex items-center justify-center ".concat(O?"w-6 h-6":"w-8 h-8"),children:(0,a.jsx)("svg",{className:O?"w-4 h-4 text-white":"w-5 h-5 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2.5",d:"M6 18L18 6M6 6l12 12"})})}),(0,a.jsx)("div",{className:"text-red-800 dark:text-red-200 font-semibold ".concat(O?"text-xs":"text-sm"),children:I})]}),(0,a.jsxs)("div",{className:"flex-1 min-h-0 ".concat(O?"flex flex-col overflow-y-auto":"flex overflow-hidden"),children:[(0,a.jsx)(x,{pendingUploads:s,selectedIndex:U,onSelectIndex:D,onExcludeToggle:i,isMobile:O}),er&&(0,a.jsxs)("div",{className:"flex-1 flex flex-col",children:[(0,a.jsx)(v,{selectedUpload:er,selectedIndex:U,isMobile:O,isCropMode:H,cropArea:G,cropImageRef:J,cropContainerRef:V,previewWithWatermark:ea,onMouseMove:ee,onMouseUp:et,onCropMouseDown:Z,onResizeMouseDown:$,onStartCrop:X,onCancelCrop:Q,onApplyCrop:eo,onRotate:j,onFlip:E,hasCrop:!!M,onShowLightbox:()=>F(!0),onImageLoad:()=>A(e=>e+1)}),(0,a.jsxs)("div",{className:"border-t border-[--border] bg-[--card-background] space-y-4 flex-shrink-0 ".concat(O?"p-4 pb-6":"p-6"),children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"font-semibold text-[--foreground] block mb-2 ".concat(O?"text-xs":"text-sm"),children:"ì´ë¯¸ì§ 캡ì
"}),(0,a.jsx)("textarea",{ref:P,value:er.caption,onChange:e=>l(ei,e.target.value),disabled:er.excluded,rows:O?2:3,className:"w-full border-2 border-[--border] rounded-lg focus:outline-none focus:ring-2 focus:ring-[--primary] focus:border-transparent bg-[--card-background] text-[--foreground] disabled:opacity-50 disabled:cursor-not-allowed disabled:bg-[--muted] resize-none transition-all duration-200 ".concat(O?"px-3 py-2 text-xs":"px-4 py-3 text-sm"),placeholder:"ì´ë¯¸ì§ì ëí ì¤ëª
ì ì
ë ¥íì¸ì..."}),z&&(0,a.jsxs)("label",{className:"flex items-center gap-2 mt-2 cursor-pointer select-none ".concat(er.excluded?"opacity-50 pointer-events-none":""),children:[(0,a.jsx)("input",{type:"checkbox",checked:W,onChange:e=>{let t=e.target.checked;if(B(t),t){let e=er.caption||"";e.endsWith(z)||l(ei,e+z)}else{let e=er.caption||"";e.endsWith(z)&&l(ei,e.slice(0,-z.length))}},disabled:er.excluded,className:"w-4 h-4 rounded border-[--border] text-[--primary] focus:ring-[--primary]"}),(0,a.jsxs)("span",{className:"text-[--muted-foreground] ".concat(O?"text-xs":"text-sm"),children:["ì¤ì ë 캡ì
ì¶ê° ",(0,a.jsxs)("span",{className:"text-[--foreground] font-medium",children:["(",z,")"]})]})]})]}),m&&(0,a.jsx)(N,{selectedUpload:er,isMobile:O,isFetchingWatermark:K,logoUrl:q,onWatermarkToggle:e=>m(ei,e),onPositionChange:g?e=>g(ei,e):void 0,onRotationChange:f?e=>f(ei,e):void 0,onMarginChange:b?e=>b(ei,e):void 0,onScaleChange:w?e=>w(ei,e):void 0,onOpacityChange:y?e=>y(ei,e):void 0})]})]})]}),(0,a.jsx)(k,{includedCount:es,isMobile:O,isUploading:L,onClose:r,onSubmit:en})]})}),R&&er&&(0,a.jsx)(p,{imageSrc:er.addWatermark&&ea||er.preview,onClose:()=>F(!1)})]})},M=r(51883),S=r(39526),I=r(29827),L=r(58962),T=r(21770);let U=()=>{let{data:e}=(0,d.a)({queryKey:["configs","value","WATERMARK_IMAGE"],queryFn:async()=>{try{let e=await fetch("/api/configs?key=WATERMARK_IMAGE");if(e.ok)return(await e.json()).value;return null}
1catch(e){return console.error("ìí°ë§í¬ ì¤ì ê°ì ¸ì¤ê¸° ì¤í¨:",e),null}},staleTime:3e5}),{data:t}=(0,d.a)({queryKey:["configs","value","LOGO"],queryFn:async()=>{try{let e=await fetch("/api/configs?key=LOGO");if(e.ok)return(await e.json()).value;return null}catch(e){return console.error("ë¡ê³ ì¤ì ê°ì ¸ì¤ê¸° ì¤í¨:",e),null}},enabled:!e,staleTime:3e5});return{watermarkUrl:e||t||"/pangolingo_logo_dark.png"}},D=function(e,t){var r;let a=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=(0,I.NL)(),s=(0,n.useRef)(null),l=(0,n.useRef)(null),{data:i,isLoading:c,error:d,fetchNextPage:u,hasNextPage:m,isFetchingNextPage:h,isFetching:p}=(0,L.N)({queryKey:["articleImages",t,a],queryFn:e=>{let{pageParam:r=1}=e;return S.g.getImages(r,10,t||void 0,a)},getNextPageParam:e=>{if(e.page<e.totalPages)return e.page+1},initialPageParam:1,enabled:e}),x=(0,n.useRef)([t,a]);(0,n.useEffect)(()=>{let[r,n]=x.current;e&&(t!==r||a!==n)&&o.removeQueries({queryKey:["articleImages",r,n]}),x.current=[t,a]},[t,a,e,o]);let[g,f]=(0,n.useState)(!1);(0,n.useEffect)(()=>{e&&!g&&o.invalidateQueries({queryKey:["articleImages","",a]}),f(e)},[e,g,a,o]),(0,n.useEffect)(()=>(e&&(s.current=new IntersectionObserver(e=>{e[0].isIntersecting&&m&&!h&&u()},{threshold:.01,rootMargin:"100px"}),l.current&&s.current.observe(l.current)),()=>{s.current&&s.current.disconnect()}),[u,m,h,e]);let b=(null==d?void 0:null===(r=d.response)||void 0===r?void 0:r.status)===403||(null==d?void 0:d.status)===403||(null==d?void 0:d.statusCode)===403;return{imageData:i,isLoading:c,imageLoadError:d,is403Error:b,hasNextPage:m,isFetchingNextPage:h,isFetching:p,loadMoreRef:l}},O=(e,t,r)=>{let a=(0,I.NL)(),{showAlert:n}=(0,i.V)(),o=(0,T.D)({mutationFn:e=>{let{imageId:t,caption:r}=e;return S.g.updateImageCaption(t,r)},onSuccess:(o,s)=>{a.invalidateQueries({queryKey:["articleImages"]});let l=null==e?void 0:e.pages.flatMap(e=>e.items).find(e=>e.id===s.imageId);l&&t.has(l.photoUrl)&&r(e=>{let t=new Map(e);return t.set(l.photoUrl,s.caption),t}),n("success","캡ì
ì´ ìì ëììµëë¤.")},onError:e=>{n("error","캡ì
ìì ì¤í¨: ".concat(e.message))}});return{handleCaptionUpdate:async(e,t)=>{await o.mutateAsync({imageId:e,caption:t})},deleteImagesMutation:(0,T.D)({mutationFn:async e=>{await Promise.all(e.map(e=>S.g.deleteImage(e)))},onSuccess:()=>{a.invalidateQueries({queryKey:["articleImages"]}),n("success","ì íí ì´ë¯¸ì§ê° ìì ëììµëë¤.")},onError:e=>{n("error","ì´ë¯¸ì§ ìì ì¤í¨: ".concat(e.message))}})}},R=()=>{let[e,t]=(0,n.useState)(new Set),[r,a]=(0,n.useState)(new Map),[o,s]=(0,n.useState)(new Map),l=(0,n.useCallback)((e,r)=>{t(t=>{let n=new Set(t);return n.has(e)?(n.delete(e),a(t=>{let r=new Map(t),a=r.get(e);return r.delete(e),r.forEach((e,t)=>{e>a&&r.set(t,e-1)}),r}),s(t=>{let r=new Map(t);return r.delete(e),r})):(n.add(e),a(t=>{let r=new Map(t);return r.set(e,n.size),r}),s(t=>{let a=new Map(t);return a.set(e,r),a})),n})},[]),i=(0,n.useCallback)(()=>{t(new Set),a(new Map),s(new Map)},[]),c=(0,n.useCallback)(e=>{t(t=>{let r=new Set(t);return e.forEach(e=>r.add(e.url)),r}),a(t=>{let r=new Map(t);return e.forEach((e,a)=>{r.set(e.url,t.size+a+1)}),r}),s(t=>{let r=new Map(t);return e.forEach(e=>{r.set(e.url,e.caption)}),r})},[]);return{selectedImages:e,selectedOrder:r,selectedImagesCaptions:o,setSelectedImagesCaptions:s,toggleImageSelection:l,resetSelection:i,addUploadedImages:c}},F="watermark_settings",A=/^image\/(heic|heif|heic-sequence|heif-sequence)$/i,P=/\.(heic|heif)$/i,z=e=>A.test(e.type)||P.test(e.name),W={position:"bottom-right",rotation:0,margin:20,scale:.3,opacity:.7},B=()=>{try{let e=localStorage.getItem(F);if(e)return{...W,...JSON.parse(e)}}catch(e){console.error("ìí°ë§í¬ ì¤ì ë¶ë¬ì¤ê¸° ì¤í¨:",e)}return W},_=e=>{try{let t={...B(),...e};localStorage.setItem(F,JSON.stringify(t))}catch(e){console.error("ìí°ë§í¬ ì¤ì ì ì¥ ì¤í¨:",e)}};async function K(e,t){let r=null;try{r=URL.createObjectURL(e);let a=await G(r),n=document.createElement("canvas"),o=n.getContext("2d");if(!o)throw Error("Canvas context를 ê°ì ¸ì¬ ì ììµëë¤.");90===t||270===t?(n.width=a.height,n.height=a.width):(n.width=a.width,n.height=a.height),o.translate(n.width/2,n.height/2),o.rotate(t*Math.PI/180),o.drawImage(a,-a.width/2,-a.height/2);let s=await J(n,e.type);return new File([s],e.name,{type:e.type,lastModified:Date.now()})}finally{r&&URL.revokeObjectURL(r)}}async function q(e){let t=null;try{t=URL.createObjectURL(e);let r=await G(t),a=document.createElement("canvas"),n=a.getContext("2d");if(!n)throw Error("Canvas context를 ê°ì ¸ì¬ ì ììµëë¤.");a.width=r.width,a.height=r.height,n.translate(a.width,0),n.scale(-1,1),n.drawImage(r,0,0);
1let o=await J(a,e.type);return new File([o],e.name,{type:e.type,lastModified:Date.now()})}finally{t&&URL.revokeObjectURL(t)}}async function H(e,t){let r=null;try{r=URL.createObjectURL(e);let a=await G(r),n=document.createElement("canvas"),o=n.getContext("2d");if(!o)throw Error("Canvas context를 ê°ì ¸ì¬ ì ììµëë¤.");let s=a.width*t.x,l=a.height*t.y,i=a.width*t.width,c=a.height*t.height;n.width=i,n.height=c,o.drawImage(a,s,l,i,c,0,0,i,c);let d=await J(n,e.type);return new File([d],e.name,{type:e.type,lastModified:Date.now()})}finally{r&&URL.revokeObjectURL(r)}}function G(e){return new Promise((t,r)=>{let a=new Image;a.onload=()=>t(a),a.onerror=()=>r(Error("ì´ë¯¸ì§ ë¡ë ì¤í¨")),a.src=e})}function J(e,t){return new Promise((r,a)=>{e.toBlob(e=>{e?r(e):a(Error("ì´ë¯¸ì§ ë³í ì¤í¨"))},t,.95)})}let V=()=>{let[e,t]=(0,n.useState)([]),[r,a]=(0,n.useState)(!1),{showAlert:o}=(0,i.V)(),s=(0,n.useRef)(e);(0,n.useEffect)(()=>{s.current=e},[e]),(0,n.useEffect)(()=>()=>{s.current.forEach(e=>{URL.revokeObjectURL(e.preview)})},[]);let l=(0,n.useCallback)(e=>{let t=B(),r=e.filter(z),a=e.filter(e=>!z(e));return{blockedHeicNames:r.map(e=>e.name),uploads:a.map(e=>({id:crypto.randomUUID(),file:e,preview:URL.createObjectURL(e),caption:"",addWatermark:!1,watermarkPosition:t.position,watermarkRotation:t.rotation,watermarkMargin:t.margin,watermarkScale:t.scale,watermarkOpacity:t.opacity,rotation:0}))}},[]),c=(0,n.useCallback)((e,r,a)=>{t(t=>t.map(t=>t.id===e?{...t,[r]:a}:t))},[]),d=(0,n.useCallback)((e,t,r,a,n)=>{c(e,t,r),a&&_({[a]:null!=n?n:r})},[c]),u=(0,n.useCallback)(async(r,a)=>{let n=e[r];if(!n)return;let s=((n.rotation||0)+90)%360;try{let e=await K(n.file,90),a=URL.createObjectURL(e),o=n.preview;t(t=>{let o=[...t];return o[r]={...n,file:e,preview:a,rotation:s},o}),setTimeout(()=>URL.revokeObjectURL(o),100)}catch(e){console.error("ì´ë¯¸ì§ íì ì¤í¨:",e),o("error","ì´ë¯¸ì§ íì ì¤ ì¤ë¥ê° ë°ìíìµëë¤.")}},[e,o]),m=(0,n.useCallback)(async r=>{let a=e[r];if(a)try{let e=await q(a.file),n=URL.createObjectURL(e),o=a.preview;t(t=>{let o=[...t];return o[r]={...a,file:e,preview:n},o}),setTimeout(()=>URL.revokeObjectURL(o),100)}catch(e){console.error("ì´ë¯¸ì§ ì¢ì°ë°ì ì¤í¨:",e),o("error","ì´ë¯¸ì§ ì¢ì°ë°ì ì¤ ì¤ë¥ê° ë°ìíìµëë¤.")}},[e,o]),h=(0,n.useCallback)(async(r,a)=>{let n=e[r];if(n)try{let e=await H(n.file,a),o=URL.createObjectURL(e),s=n.preview;t(t=>{let a=[...t];return a[r]={...n,file:e,preview:o},a}),setTimeout(()=>URL.revokeObjectURL(s),100)}catch(e){console.error("ì´ë¯¸ì§ ì르기 ì¤í¨:",e),o("error","ì´ë¯¸ì§ ì르기 ì¤ ì¤ë¥ê° ë°ìíìµëë¤.")}},[e,o]);return{pendingUploads:e,setPendingUploads:t,showCaptionModal:r,setShowCaptionModal:a,createPendingUploadsFromFiles:l,updatePendingItem:c,updateWatermarkSetting:d,handleRotate:u,handleFlip:m,handleCrop:h}};var X=r(84154),Q=r(26497);let Y=e=>{let{selectedImages:t,selectedOrder:r,selectedImagesCaptions:n,onToggleSelection:o,containerRef:s}=e;return(0,a.jsxs)("div",{ref:s,className:"w-[300px] overflow-y-auto p-4 bg-gradient-to-b from-[--muted]/50 to-[--muted]/30 border-l border-[--border]",children:[(0,a.jsxs)("h3",{className:"text-sm font-semibold text-[--foreground] mb-4 flex items-center gap-2",children:[(0,a.jsx)(X.GH$,{className:"w-5 h-5 text-green-500"}),"ì íë ì´ë¯¸ì§",t.size>0&&(0,a.jsxs)("span",{className:"text-xs font-normal text-white bg-[--primary] px-2 py-0.5 rounded-full",children:[t.size,"ê°"]})]}),0===t.size?(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center h-48 text-[--muted-foreground] text-center",children:[(0,a.jsx)(X.Vpw,{className:"w-12 h-12 mb-3 text-[--muted-foreground]"}),(0,a.jsx)("p",{className:"text-sm",children:"ì¼ìª½ìì ì´ë¯¸ì§ë¥¼ í´ë¦íì¬"}),(0,a.jsx)("p",{className:"text-sm",children:"ì ííì¸ì"})]}):(0,a.jsx)("div",{className:"grid grid-cols-2 gap-3",children:Array.from(t).sort((e,t)=>(r.get(e)||0)-(r.get(t)||0)).map(e=>{let t=n.get(e),s=r.get(e);return(0,a.jsxs)("div",{className:"relative bg-[--card-background] rounded-xl overflow-hidden border border-[--border] group flex flex-col shadow-sm hover:shadow-md transition-shadow",children:[(0,a.jsx)("div",{className:"absolute top-1.5 left-1.5 z-10 w-6 h-6 flex items-center justify-center bg-[--primary] text-[--primary-foreground] rounded-full font-bold text-xs shadow-lg",children:s}),(0,a.jsx)("button",{onClick:()=>o(e,t),className:"absolute top-1.5 right-1.5 z-10 w-6 h-6 flex items-center justify-center bg-red-500 text-white rounded-full opacity-0 group-hover:opacity-100 transition-all duration-200 shadow-lg text-xs hover:bg-red-600 hover:scale-110",title:"ì í í´ì ",children:"â"}),(0,a.jsx)("div",{className:"aspect-square w-full bg-gradient-to-br from-[--muted] to-[--muted]/50 relative",children:(0,a.jsx)(Q.Z,{fill:!0,sizes:"140px",src:(0,c.zg)(e),alt:t||"",className:"object-contain p-2"})}),(0,a.jsx)("div",{className:"p-2 bg-[--card-background] min-h-[36px]",children:(0,a.jsx)("p",{className:"text-[11px] text-[--muted-foreground] line-clamp-2 leading-relaxed",children:t||"캡ì
ìì"})})]},e)})})]})},Z=e=>{let{searchKeyword:t,onSearchKeywordChange:r,onSearchSubmit:o,isLoading:s,isFetching:l,compact:i=!1,aiOnly:c,onAiOnlyChange:d}=e,u=(0,n.useRef)(null);return(0,a.jsxs)("div",{className:i?"space-y-2":"space-y-3",children:[(0,a.jsxs)("div",{className:i?"flex items-center gap-2":"flex items-center gap-3",children:[(0,a.jsx)("div",{className:i?"flex-1":"relative flex-1",children:(0,a.jsx)("input",{ref:u,type:"text",placeholder:i?"ì´ë¯¸ì§ ê²ì":"ì´ë¯¸ì§ ê²ì (캡ì
ì¼ë¡ ê²ì)",value:t,onChange:e=>r(e.target.value),onKeyDown:e=>{"Enter"!==e.key||s||l||(e.preventDefault(),o())},autoFocus:!0,className:i?"flex-1 py-2 px-3 border rounded-lg focus:outline-none focus:ring-2 focus:ring-[--primary] bg-[--card-background] text-[--foreground] text-sm":"w-full py-3 px-4 border-0 rounded-xl focus:outline-none focus:ring-2 focus:ring-[--primary] bg-[--card-background] text-[--foreground] shadow-md placeholder:text-[--muted-foreground]"})}),(0,a.jsx)("button",{type:"button",onClick:o,disabled:s||l,className:i?"px-4 py-2 bg-[--primary] text-white rounded-lg hover:bg-[--primary-hover] disabled:opacity-50 text-sm font-medium":"px-6 py-3 bg-[--primary] text-[--primary-foreground] rounded-xl hover:bg-[--primary-hover] disabled:opacity-50 disabled:cursor-not-allowed font-medium shadow-md hover:shadow-lg transition-all duration-200",children:"ê²ì"})]}),"function"==typeof d&&(0,a.jsxs)("label",{className:"inline-flex items-center gap-2 text-sm text-[--muted-foreground] cursor-pointer select-none",children:[(0,a.jsx)("input",{type:"checkbox",checked:!!c,onChange:e=>null==d?void 0:d(e.target.checked),className:"w-4 h-4 rounded border-[--border] text-[--primary] focus:ring-[--primary]"}),"AI ìì± ì´ë¯¸ì§ë§ 보기"]})]})},$=e=>{let{image:t,isSelected:r,selectionOrder:o,onToggleSelection:s,onCaptionUpdate:l}
1=e,[i,d]=(0,n.useState)(!1),[u,m]=(0,n.useState)(t.caption||""),[h,p]=(0,n.useState)(!1),x=async e=>{if(e.stopPropagation(),!h){p(!0);try{l&&await l(t.id,u),d(!1)}catch(e){console.error("캡ì
ì ì¥ ì¤í¨:",e)}finally{p(!1)}}},g=e=>{e.stopPropagation(),d(!1),m(t.caption||"")};return(0,a.jsxs)("div",{className:"relative flex flex-col cursor-pointer rounded-xl overflow-hidden transition-all duration-200 group hover:shadow-lg hover:-translate-y-1 ".concat(r?"ring-2 ring-[--primary] ring-offset-2 ring-offset-[--card-background] shadow-md":"border border-[--border] hover:border-[--primary]/50"),onClick:()=>s(t.photoUrl,t.caption),children:[(0,a.jsxs)("div",{className:"aspect-square w-full bg-gradient-to-br from-[--muted] to-[--muted]/50 relative overflow-hidden",children:[(0,a.jsx)("div",{className:"absolute inset-0 flex items-center justify-center p-2",children:(0,a.jsx)(Q.Z,{fill:!0,sizes:"200px",quality:100,src:(0,c.zg)(t.photoUrl),alt:t.caption||"",className:"max-w-full max-h-full object-contain select-none transition-transform duration-300 group-hover:scale-105",draggable:!1,onDragStart:e=>e.preventDefault()})}),r&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"absolute inset-0 bg-gradient-to-t from-[--primary]/30 to-transparent"}),(0,a.jsx)("div",{className:"absolute top-2 left-2",children:(0,a.jsx)("span",{className:"w-7 h-7 flex items-center justify-center bg-[--primary] text-[--primary-foreground] rounded-full font-bold text-sm shadow-lg",children:o})}),(0,a.jsx)("div",{className:"absolute bottom-2 right-2",children:(0,a.jsxs)("span",{className:"px-2 py-1 bg-[--primary] text-[--primary-foreground] rounded-full text-xs font-medium shadow-lg flex items-center gap-1",children:[(0,a.jsx)(X.ffJ,{className:"w-3 h-3"})," ì íë¨"]})})]}),!r&&(0,a.jsx)("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/10 transition-colors duration-200"}),t.isAiGenerated&&(0,a.jsx)("span",{className:"absolute top-2 right-2 px-1.5 py-0.5 bg-black/60 text-white rounded text-[10px] font-semibold tracking-wide shadow",children:"AI"})]}),(0,a.jsx)("div",{className:"p-2.5 text-xs text-[--muted-foreground] bg-[--card-background] relative group/caption transition-colors ".concat(i?"min-h-[70px]":"min-h-[44px]"),onClick:e=>e.stopPropagation(),children:i?(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("input",{type:"text",value:u,onChange:e=>m(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey?"Escape"===e.key&&(e.preventDefault(),g(e)):(e.preventDefault(),x(e))},className:"w-full text-xs bg-[--background] border border-[--border] rounded-lg px-2.5 py-1.5 focus:outline-none focus:ring-2 focus:ring-[--primary] focus:border-transparent",placeholder:"캡ì
ì ì
ë ¥íì¸ì",autoFocus:!0,onClick:e=>e.stopPropagation()}),(0,a.jsxs)("div",{className:"flex gap-1.5 justify-end",children:[(0,a.jsxs)("button",{type:"button",onClick:x,disabled:h,className:"px-2.5 py-1 text-xs bg-[--primary] text-white rounded-lg hover:bg-[--primary-hover] disabled:opacity-50 flex items-center gap-1 transition-colors",children:[h&&(0,a.jsx)("div",{className:"w-3 h-3 border border-white border-t-transparent rounded-full animate-spin"}),h?"ì ì¥ì¤":"ì ì¥"]}),(0,a.jsx)("button",{type:"button",onClick:g,className:"px-2.5 py-1 text-xs bg-[--muted] text-[--foreground] rounded-lg hover:bg-[--muted]/80 transition-colors",children:"ì·¨ì"})]})]}):(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("span",{className:"flex-1 pr-2 line-clamp-2 leading-relaxed",children:t.caption||"캡ì
ìì"}),(0,a.jsx)("button",{onClick:e=>{e.stopPropagation(),d(!0),m(t.caption||"")},className:"text-[--muted-foreground] hover:text-[--primary] md:opacity-0 md:group-hover/caption:opacity-100 transition-all duration-200 flex-shrink-0 hover:scale-110",title:"캡ì
í¸ì§",children:(0,a.jsx)(X.HuK,{className:"w-4 h-4"})})]})})]})},ee=e=>{let{imageData:t,selectedImages:r,selectedOrder:n,onToggleSelection:o,onCaptionUpdate:s,loadMoreRef:l,isFetchingNextPage:i,hasNextPage:c,columns:d=5}=e,u=2===d?"grid-cols-2":"grid-cols-5";return(0,a.jsxs)("div",{className:2===d?"":"min-h-[calc(85vh-280px)]",children:[(0,a.jsx)("div",{className:"grid ".concat(u," gap-3"),children:null==t?void 0:t.pages.map(e=>e.items.map(e=>(0,a.jsx)($,{image:e,isSelected:r.has(e.photoUrl),selectionOrder:n.get(e.photoUrl),onToggleSelection:o,onCaptionUpdate:s},e.id)))}),(0,a.jsx)("div",{ref:l,className:i?2===d?"my-2":"my-4":2===d?"h-16 flex items-center justify-center my-2":"h-20 flex items-center justify-center my-4",children:i?(0,a.jsx)("div",{className:"grid ".concat(u," ").concat(2===d?"gap-2":"gap-3"),children:Array.from({length:2===d?2:5}).map((e,t)=>(0,a.jsxs)("div",{className:"flex flex-col rounded-xl overflow-hidden border border-[--border]",children:[(0,a.jsx)("div",{className:"aspect-square w-full bg-[--muted] animate-pulse"}),(0,a.jsx)("div",{className:"p-2.5 bg-[--card-background] min-h-[44px] flex items-center",children:(0,a.jsx)("div",{className:"h-3 w-3/4 bg-[--muted] rounded animate-pulse"})})]},t))}):c?(0,a.jsx)("div",{className:"text-center py-4 text-[--muted-foreground] ".concat(2===d?"text-sm":""),children:2===d?"ì¤í¬ë¡¤íì¬ ë 보기":"ì¤í¬ë¡¤íì¬ ë ë¶ë¬ì¤ê¸°"}):(0,a.jsx)("div",{className:"text-center py-4 text-[--muted-foreground] ".concat(2===d?"text-sm":""),children:2===d?"ë§ì§ë§ ì´ë¯¸ì§ì
ëë¤":"ë ì´ì ì´ë¯¸ì§ê° ììµëë¤"})})]})},et=e=>{let{selectedCount:t,isDeleting:r,onDeleteSelected:n,onInsertAsCollage:o,onInsert:s,compact:l=!1}=e;return l?(0,a.jsxs)("div",{className:"flex-shrink-0 px-4 py-3 border-t border-[--border] bg-[--card-background]",children:[t>0&&(0,a.jsxs)("div",{className:"mb-2 text-sm text-[--muted-foreground] text-center",children:[t,"ê° ì íë¨"]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[t>0&&(0,a.jsxs)("button",{onClick:n,className:"flex-1 px-4 py-2.5 bg-red-500 text-white rounded-lg hover:bg-red-600 flex items-center justify-center gap-2 shadow-md font-medium text-sm",type:"button",disabled:r,children:[(0,a.jsx)(X.GnT,{className:"w-4 h-4"}),"ìì "]}),t>=2&&(0,a.jsxs)("button",{onClick:o,className:"flex-1 px-4 py-2.5 bg-blue-500 text-white rounded-lg hover:bg-blue-600 flex items-center justify-center gap-2 shadow-md font-medium text-sm",type:"button",children:[(0,a.jsx)(X._f$,{className:"w-4 h-4"}),"ì½ë¼ì£¼"]}),(0,a.jsxs)("button",{onClick:s,className:"flex-1 px-4 py-2.5 bg-[--primary] text-white rounded-lg hover:bg-[--primary-hover] disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-2 shadow-md font-medium text-sm",disabled:0===t,type:"button",children:[(0,a.jsx)(X.ffJ,{className:"w-4 h-4"}),"ì½ì
(",t,")"]})]})]}):(0,a.jsxs)("div",{className:"flex justify-between items-center px-6 py-4 border-t border-[--border] bg-[--card-background]",children:[(0,a.jsx)("div",{className:"text-sm text-[--muted-foreground]",children:t>0&&(0,a.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,a.jsx)(X.dc7,{className:"w-4 h-4 text-yellow-500"})," í: 2ê° ì´ì ì í ì ì½ë¼ì£¼ë¡ ì½ì
í ì ììµëë¤"]})}),(0,a.jsxs)("div",{className:"flex gap-3",children:[t>0&&(0,a.jsxs)("button",{onClick:n,className:"px-5 py-2.5 bg-gradient-to-r from-red-500 to-red-600 text-white rounded-xl hover:from-red-600 hover:to-red-700 flex items-center gap-2 shadow-md hover:shadow-lg transition-all duration-200 font-medium",type:"button",disabled:r,children:[(0,a.jsx)(X.GnT,{className:"w-5 h-5"}),"ìì (",t,"ê°)"]}),t>=2&&(0,a.jsxs)("button",{onClick:o,className:"px-5 py-2.5 bg-gradient-to-r from-blue-500 to-blue-600 text-white rounded-xl hover:from-blue-600 hover:to-blue-700 flex items-center gap-2 shadow-md hover:shadow-lg transition-all duration-200 font-medium",type:"button",children:[(0,a.jsx)(X._f$,{className:"w-5 h-5"}),"ì½ë¼ì£¼ë¡ ì½ì
(",t,"ê°)"]}),(0,a.jsxs)("button",{onClick:s,className:"px-5 py-2.5 bg-gradient-to-r from-[--primary] to-[--primary-hover] text-white rounded-xl hover:from-[--primary-hover] hover:to-[--primary] disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2 shadow-md hover:shadow-lg transition-all duration-200 font-medium",disabled:0===t,type:"button",children:[(0,a.jsx)(X.ffJ,{className:"w-5 h-5"}),"ì½ì
í기 (",t,"ê°)"]})]})]})},er=e=>{let{columns:t=5}=e;return(0,a.jsx)("div",{className:5===t?"min-h-[calc(85vh-280px)]":"",children:(0,a.jsx)("div",{className:"grid ".concat(2===t?"grid-cols-2":"grid-cols-5"," gap-").concat(2===t?"2":"3"," ").concat(2===t?"mb-4":""),children:Array.from({length:2===t?6:15}).map((e,t)=>(0,a.jsxs)("div",{className:"flex flex-col rounded-xl overflow-hidden border border-[--border]",children:[(0,a.jsx)("div",{className:"aspect-square w-full bg-[--muted] animate-pulse"}),(0,a.jsx)("div",{className:"p-2.5 bg-[--card-background] min-h-[44px] flex items-center",children:(0,a.jsx)("div",{className:"h-3 w-3/4 bg-[--muted] rounded animate-pulse"})})]},t))})})},ea=e=>{let{searchQuery:t,compact:r=!1}=e;return(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center h-64 text-[--muted-foreground]",children:[(0,a.jsx)(X.PBv,{className:"w-16 h-16 mb-4 text-[--muted-foreground]"}),(0,a.jsx)("p",{className:r?"text-base font-medium":"text-lg font-medium",children:t?'"'.concat(t,'" ê²ì ê²°ê
1³¼ê° ììµëë¤'):"ì´ë¯¸ì§ê° ììµëë¤"}),(0,a.jsx)("p",{className:"text-sm mt-2",children:"ì ì´ë¯¸ì§ë¥¼ ì
ë¡ëí´ë³´ì¸ì"})]})},en=e=>{let{is403:t,compact:r=!1}=e;return(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center h-64",children:[(0,a.jsx)("svg",{className:"w-16 h-16 mb-4 text-[--destructive]",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),(0,a.jsx)("h3",{className:"font-semibold text-[--foreground] mb-2 ".concat(r?"text-base":"text-lg"),children:t?"ê¶íì´ ììµëë¤":"ì¤ë¥ê° ë°ìíìµëë¤"}),(0,a.jsx)("p",{className:"text-sm text-[--muted-foreground] ".concat(r?"text-center px-4":""),children:t?"ì´ë¯¸ì§ë¥¼ ë¶ë¬ì¬ ì ìë ê¶íì´ ììµëë¤.":"ì´ë¯¸ì§ë¥¼ ë¶ë¬ì¤ë ì¤ ì¤ë¥ê° ë°ìíìµëë¤."})]})};var eo=r(69880);let es=e=>{var t,r,s;let{isOpen:l,onClose:i,searchKeyword:c,onSearchKeywordChange:d,onSearchSubmit:u,aiOnly:m,onAiOnlyChange:h,imageData:p,isLoading:x,imageLoadError:g,is403Error:f,searchQuery:b,hasNextPage:v,isFetchingNextPage:w,isFetching:y,loadMoreRef:j,selectedImages:N,selectedOrder:k,selectedImagesCaptions:C,onToggleSelection:E,onCaptionUpdate:M,onFileSelect:S,isDeleting:I,onDeleteSelected:L,onInsertAsCollage:T,onInsert:U,selectedImagesContainerRef:D,onFileInsert:O}
1=e,R=(0,n.useRef)(null),[F,A]=(0,n.useState)("images");return(0,a.jsx)(o.u_,{isOpen:l,onClose:i,width:1280,closeOnOverlayClick:!1,children:(0,a.jsxs)("div",{className:"bg-[--card-background] rounded-2xl w-full max-w-[1280px] h-[85vh] flex flex-col shadow-2xl overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex justify-between items-center px-6 py-4 bg-gradient-to-r from-[--primary]/10 via-[--primary]/5 to-transparent border-b border-[--border]",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"w-10 h-10 rounded-xl bg-[--primary] flex items-center justify-center shadow-lg",children:(0,a.jsx)(X.PBv,{className:"w-5 h-5 text-white"})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("h2",{className:"text-xl font-bold text-[--foreground]",children:"ì´ë¯¸ì§ ë¼ì´ë¸ë¬ë¦¬"}),(0,a.jsx)("p",{className:"text-xs text-[--muted-foreground]",children:"ì´ë¯¸ì§ë¥¼ ì ííê±°ë ìë¡ ì
ë¡ëíì¸ì"})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("input",{ref:R,type:"file",accept:"image/*,.svg",multiple:!0,onChange:S,className:"hidden"}),(0,a.jsxs)("button",{onClick:()=>{var e;return null===(e=R.current)||void 0===e?void 0:e.click()},className:"px-4 py-2.5 text-sm bg-gradient-to-r from-[--primary] to-[--primary-hover] hover:from-[--primary-hover] hover:to-[--primary] text-white rounded-xl flex items-center gap-2 shadow-md hover:shadow-lg transition-all duration-200 font-medium",type:"button",children:[(0,a.jsx)(X.KpO,{className:"w-5 h-5"}),"ì´ë¯¸ì§ ì
ë¡ë"]}),(0,a.jsx)("button",{onClick:i,className:"w-10 h-10 rounded-xl bg-[--muted] hover:bg-[--muted]/80 text-[--muted-foreground] hover:text-[--foreground] flex items-center justify-center transition-all duration-200 hover:shadow-md",type:"button",children:(0,a.jsx)(X.eSQ,{className:"w-5 h-5"})})]})]}),(0,a.jsxs)("div",{className:"flex border-b border-[--border] px-6 shrink-0",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>A("images"),className:"flex items-center gap-2 px-4 py-3 text-sm font-medium border-b-2 transition-colors ".concat("images"===F?"border-[--primary] text-[--primary]":"border-transparent text-[--muted-foreground] hover:text-[--foreground]"),children:[(0,a.jsx)(X.PBv,{className:"w-4 h-4"}),"ì´ë¯¸ì§ ë¼ì´ë¸ë¬ë¦¬"]}),(0,a.jsxs)("button",{type:"button",onClick:()=>A("files"),className:"flex items-center gap-2 px-4 py-3 text-sm font-medium border-b-2 transition-colors ".concat("files"===F?"border-[--primary] text-[--primary]":"border-transparent text-[--muted-foreground] hover:text-[--foreground]"),children:[(0,a.jsx)(X.Klk,{className:"w-4 h-4"}),"íì¼ ê´ë¦¬"]})]}),"images"===F?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"px-6 py-4 bg-[--muted]/30",children:(0,a.jsx)(Z,{searchKeyword:c,onSearchKeywordChange:d,onSearchSubmit:u,isLoading:x,isFetching:y})}),(0,a.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex-1 overflow-y-auto p-6",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,a.jsxs)("h3",{className:"text-sm font-semibold text-[--foreground] flex items-center gap-2",children:[(0,a.jsx)(X.NX3,{className:"w-5 h-5 text-[--primary]"}),"ì ì²´ ì´ë¯¸ì§",(null==p?void 0:null===(t=p.pages[0])||void 0===t?void 0:t.total)!=null&&(0,a.jsxs)("span",{className:"text-xs font-normal text-[--muted-foreground] bg-[--muted] px-2 py-0.5 rounded-full",children:[p.pages[0].total,"ê°"]})]}),(0,a.jsxs)("label",{className:"flex items-center gap-2 text-sm text-[--muted-foreground] cursor-pointer select-none",children:[(0,a.jsx)("input",{type:"checkbox",checked:m,onChange:e=>h(e.target.checked),className:"w-4 h-4 rounded border-[--border] text-[--primary] focus:ring-[--primary]"}),"AI ìì± ì´ë¯¸ì§ë§ 보기"]})]}),x?(0,a.jsx)(er,{columns:5}):g?(0,a.jsx)(en,{is403:f}):(null==p?void 0:null===(s=p.pages[0])||void 0===s?void 0:null===(r=s.items)||void 0===r?void 0:r.length)===0?(0,a.jsx)(ea,{searchQuery:b}):(0,a.jsx)(ee,{imageData:p,selectedImages:N,selectedOrder:k,onToggleSelection:E,onCaptionUpdate:M,loadMoreRef:j,isFetchingNextPage:w,hasNextPage:v,columns:5})]}),(0,a.jsx)(Y,{selectedImages:N,selectedOrder:k,selectedImagesCaptions:C,onToggleSelection:E,containerRef:D})]}),(0,a.jsx)(et,{selectedCount:N.size,isDeleting:I,onDeleteSelected:L,onInsertAsCollage:T,onInsert:U})]}):(0,a.jsx)("div",{className:"flex-1 overflow-hidden p-6",children:(0,a.jsx)(eo.l,{isActive:"files"===F,onInsert:(e,t,r)=>{null==O||O(e,t,r)},onClose:i,hideUpload:!1,hideDelete:!1,columns:7})})]})})};var el=r(77734),ei=r.n(el);let ec=e=>{var t,r;let{isClosing:o,onClose:s,searchKeyword:l,onSearchKeywordChange:i,onSearchSubmit:c,aiOnly:d,onAiOnlyChange:u,imageData:m,isLoading:h,imageLoadError:p,is403Error:x,searchQuery:g,hasNextPage:f,isFetchingNextPage:b,isFetching:v,loadMoreRef:w,selectedImages:y,selectedOrder:j,onToggleSelection:N,onCaptionUpdate:k,onFileSelect:C,isDeleting:E,onDeleteSelected:M,onInsertAsCollage:S,onInsert:I}=e,L=(0,n.useRef)(null),T=o?"".concat(ei().exit," ").concat(ei().exitActive):"".concat(ei().enter," ").concat(ei().enterActive);return(0,a.jsx)("div",{className:"fixed inset-0 z-[3000] bg-black/50",onClick:s,children:(0,a.jsxs)("div",{className:"bg-[--card-background] shadow-xl flex flex-col text-[--card-foreground] fixed inset-x-0 bottom-0 top-16 mx-0 rounded-t-lg ".concat(T),onClick:e=>e.stopPropagation(),children:[(0,a.jsxs)("div",{className:"flex-shrink-0 px-4 py-4 border-b border-[--border]",children:[(0,a.jsxs)("div",{className:"flex justify-between items-center mb-3",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold text-[--card-foreground]",children:"ì´ë¯¸ì§ ë¼ì´ë¸ë¬ë¦¬"}),(0,a.jsx)("button",{type:"button",onClick:s,className:"text-[--muted-foreground] hover:text-[--foreground] p-2",children:(0,a.jsx)(X.eSQ,{className:"w-6 h-6"})})]}
1),(0,a.jsx)("input",{ref:L,type:"file",accept:"image/*,.svg",multiple:!0,onChange:C,className:"hidden"}),(0,a.jsxs)("button",{onClick:()=>{var e;return null===(e=L.current)||void 0===e?void 0:e.click()},className:"w-full px-4 py-2.5 text-sm bg-gradient-to-r from-[--primary] to-[--primary-hover] text-white rounded-lg flex items-center justify-center gap-2 shadow-md font-medium",type:"button",children:[(0,a.jsx)(X.KpO,{className:"w-5 h-5"}),"ì´ë¯¸ì§ ì
ë¡ë"]})]}),(0,a.jsx)("div",{className:"flex-shrink-0 px-4 py-3 border-b border-[--border]",children:(0,a.jsx)(Z,{searchKeyword:l,onSearchKeywordChange:i,onSearchSubmit:c,isLoading:h,isFetching:v,aiOnly:d,onAiOnlyChange:u,compact:!0})}),(0,a.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:h?(0,a.jsx)(er,{columns:2}):p?(0,a.jsx)(en,{is403:x,compact:!0}):(null==m?void 0:null===(r=m.pages[0])||void 0===r?void 0:null===(t=r.items)||void 0===t?void 0:t.length)===0?(0,a.jsx)(ea,{searchQuery:g,compact:!0}):(0,a.jsx)(ee,{imageData:m,selectedImages:y,selectedOrder:j,onToggleSelection:N,onCaptionUpdate:k,loadMoreRef:w,isFetchingNextPage:b,hasNextPage:f,columns:2})}),(0,a.jsx)(et,{selectedCount:y.size,isDeleting:E,onDeleteSelected:M,onInsertAsCollage:S,onInsert:I,compact:!0})]})})},ed=e=>{(0,n.useEffect)(()=>{if(!e)return;let t=document.getElementById("main-scroll-container");if(!t)return;let r=t.style.overflow;return t.style.overflow="hidden",()=>{t.style.overflow=r}},[e])},eu=e=>{let{isOpen:t,onClose:r,onSelect:o,initialFiles:s=[],onFileInsert:c}=e,d=(0,C.h)(),[u,m]=(0,n.useState)(!1),[h,p]=(0,n.useState)(""),[x,g]=(0,n.useState)(""),[f,b]=(0,n.useState)(!1),[v,w]=(0,n.useState)(!1),y=(0,n.useRef)(null),j=(0,n.useRef)(null),{showAlert:N}=(0,i.V)();ed(t);let{watermarkUrl:k}=U(),{selectedImages:S,selectedOrder:I,selectedImagesCaptions:L,setSelectedImagesCaptions:T,toggleImageSelection:F,resetSelection:A,addUploadedImages:P}=R(),{pendingUploads:z,setPendingUploads:W,showCaptionModal:B,setShowCaptionModal:_,createPendingUploadsFromFiles:K,updatePendingItem:q,updateWatermarkSetting:H,handleRotate:G,handleFlip:J,handleCrop:X}=V(),{imageData:Q,isLoading:Y,imageLoadError:Z,is403Error:$,hasNextPage:ee,isFetchingNextPage:et,isFetching:er,loadMoreRef:ea}=D(t,x,f),{handleCaptionUpdate:en,deleteImagesMutation:eo}=O(Q,S,T),{handleUpload:el,uploadError:ei,setUploadError:eu,isUploading:em}=(0,M.i)(k,e=>{P(e),p(""),g(""),setTimeout(()=>{y.current&&(y.current.scrollTop=y.current.scrollHeight)},100)});(0,n.useEffect)(()=>{t&&m(!1)},[t]),(0,n.useEffect)(()=>{if(!t){j.current=null;return}if(!s||0===s.length)return;let e=s.map(e=>"".concat(e.name,":").concat(e.size,":").concat(e.lastModified)).join("|");if(j.current===e)return;j.current=e;let{uploads:r,blockedHeicNames:a}=K(s);a.length>0&&N("warning","HEIC/HEIF íìì ì§ìëì§ ìì ì
ë¡ëí ì ììµëë¤: ".concat(a.join(", "))),0!==r.length&&(W(e=>[...e,...r]),_(!0))},[t,s,K,N,W,_]);let eh=(0,n.useCallback)(e=>{let t=e.target.files?Array.from(e.target.files):[];if(e.target.value="",0===t.length)return;let{uploads:r,blockedHeicNames:a}=K(t);a.length>0&&N("warning","HEIC/HEIF íìì ì§ìëì§ ìì ì
ë¡ëí ì ììµëë¤: ".concat(a.join(", "))),0!==r.length&&(W(r),_(!0))},[K,N,W,_]),ep=(0,n.useCallback)(async()=>{let e=z.filter(e=>!e.excluded);if(0===e.length){N("warning","ì
ë¡ëí ì´ë¯¸ì§ê° ììµëë¤.");return}let t=await el(e);t.success&&(s&&s.length>0&&t.uploadedImages?(o(t.uploadedImages,!1),eb()):(W([]),_(!1)))},[z,el,s,o,N,W,_]),ex=(0,n.useCallback)(function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(S.size>0){let t=(null==Q?void 0:Q.pages.flatMap(e=>e.items))||[];o(Array.from(S).map(e=>{let r=t.find(t=>t.photoUrl===e);return{url:e,caption:L.get(e),id:(null==r?void 0:r.id)?Number(r.id):void 0}}),e),eb()}},[S,Q,L,o]),eg=(0,n.useCallback)(()=>{0!==S.size&&w(!0)},[S.size]),ef=(0,n.useCallback)(async()=>{let e=Array.from(S),t=(null==Q?void 0:Q.pages.flatMap(e=>e.items).filter(t=>e.includes(t.photoUrl)).map(e=>e.id))||[];if(0===t.length){N("error","ìì í ì´ë¯¸ì§ë¥¼ ì°¾ì ì ììµëë¤."),w(!1);return}try{await eo.mutateAsync(t),A(),w(!1)}
1catch(e){console.error("ì´ë¯¸ì§ ìì ì¤ ì¤ë¥:",e)}},[S,Q,eo,A,N]),eb=(0,n.useCallback)(()=>{let e=()=>{A(),W([]),_(!1),p(""),g(""),r()};d?(m(!0),setTimeout(e,300)):e()},[d,A,W,_,r]),ev=(0,n.useCallback)(()=>{g(h)},[h]),ew=(0,n.useCallback)(e=>{var t,r;return null!==(r=null===(t=z.find(t=>t.file.name===e))||void 0===t?void 0:t.id)&&void 0!==r?r:e},[z]),ey=s&&s.length>0;return t?(0,a.jsxs)(a.Fragment,{children:[!ey&&(d?(0,a.jsx)(ec,{isClosing:u,onClose:eb,searchKeyword:h,onSearchKeywordChange:p,onSearchSubmit:ev,aiOnly:f,onAiOnlyChange:b,imageData:Q,isLoading:Y,imageLoadError:Z,is403Error:$,searchQuery:x,hasNextPage:ee,isFetchingNextPage:et,isFetching:er,loadMoreRef:ea,selectedImages:S,selectedOrder:I,onToggleSelection:F,onCaptionUpdate:en,onFileSelect:eh,isDeleting:eo.isPending,onDeleteSelected:eg,onInsertAsCollage:()=>ex(!0),onInsert:()=>ex(!1)}):(0,a.jsx)(es,{isOpen:t,onClose:eb,searchKeyword:h,onSearchKeywordChange:p,onSearchSubmit:ev,aiOnly:f,onAiOnlyChange:b,imageData:Q,isLoading:Y,imageLoadError:Z,is403Error:$,searchQuery:x,hasNextPage:ee,isFetchingNextPage:et,isFetching:er,loadMoreRef:ea,selectedImages:S,selectedOrder:I,selectedImagesCaptions:L,onToggleSelection:F,onCaptionUpdate:en,onFileSelect:eh,isDeleting:eo.isPending,onDeleteSelected:eg,onInsertAsCollage:()=>ex(!0),onInsert:()=>ex(!1),selectedImagesContainerRef:y,onFileInsert:c})),B&&(0,a.jsx)(E,{isOpen:B,onClose:()=>{_(!1),W([]),eu(null),ey&&r()},pendingUploads:z,onCaptionChange:(e,t)=>
1q(ew(e),"caption",t),onExcludeToggle:(e,t)=>q(ew(e),"excluded",t),onWatermarkToggle:(e,t)=>q(ew(e),"addWatermark",t),onWatermarkPositionChange:(e,t)=>H(ew(e),"watermarkPosition",t,"position",t),onWatermarkRotationChange:(e,t)=>H(ew(e),"watermarkRotation",t,"rotation",t),onWatermarkMarginChange:(e,t)=>H(ew(e),"watermarkMargin",t,"margin",t),onWatermarkScaleChange:(e,t)=>H(ew(e),"watermarkScale",t,"scale",t),onWatermarkOpacityChange:(e,t)=>H(ew(e),"watermarkOpacity",t,"opacity",t),onRotate:G,onFlip:J,onCrop:X,onSubmit:ep,errorMessage:null!=ei?ei:void 0}),(0,a.jsx)(l,{isOpen:v,title:"ì´ë¯¸ì§ ìì íì¸",message:"ì íí ".concat(S.size,"ê°ì ì´ë¯¸ì§ë¥¼ ìì íìê² ìµëê¹?"),warningMessage:"ì본 ì´ë¯¸ì§ê° ìì ëë ê²½ì° ê¸°ì¬ ë´ìì ì´ë¯¸ì§ê° ë
¸ì¶ëì§ ììµëë¤.",confirmText:"ì´ë¯¸ì§ ìì ",itemCount:S.size,onConfirm:ef,onCancel:()=>w(!1),isDeleting:eo.isPending})]}):null}},91701:function(e,t,r){"use strict";r.d(t,{h:function(){return n}});var a=r(2265);let n=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:768,[t,r]=(0,a.useState)(!1);return(0,a.useEffect)(()=>{let t=()=>r(window.innerWidth<e);return t(),window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[e]),t}},51599:function(e,t,r){"use strict";r.d(t,{Cg:function(){return o},L8:function(){return s}});var a=r(57437);let n=(e,t)=>{let{size:r,className:a,color:n,style:o}=e;return{xmlns:"http://www.w3.org/2000/svg",width:null!=r?r:"1em",height:null!=r?r:"1em",viewBox:t,fill:null!=n?n:"currentColor",className:a,style:o}},o=e=>{var t,r,n;return(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:null!==(t=e.size)&&void 0!==t?t:"1em",height:null!==(r=e.size)&&void 0!==r?r:"1em",viewBox:"0 0 512 512",fill:"none",className:e.className,style:e.style,children:(0,a.jsx)("path",{stroke:null!==(n=e.color)&&void 0!==n?n:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"48",d:"m112 184 144 144 144-144"})})},s=e=>(0,a.jsx)("svg",{...n(e,"0 0 24 24"),children:(0,a.jsx)("path",{d:"M12.8659 3.00017L22.3922 19.5002C22.6684 19.9785 22.5045 20.5901 22.0262 20.8662C21.8742 20.954 21.7017 21.0002 21.5262 21.0002H2.47363C1.92135 21.0002 1.47363 20.5525 1.47363 20.0002C1.47363 19.8246 1.51984 19.6522 1.60761 19.5002L11.1339 3.00017C11.41 2.52187 12.0216 2.358 12.4999 2.63414C12.6519 2.72191 12.7782 2.84815 12.8659 3.00017ZM4.20568 19.0002H19.7941L11.9999 5.50017L4.20568 19.0002ZM10.9999 16.0002H12.9999V18.0002H10.9999V16.0002ZM10.9999 9.00017H12.9999V14.0002H10.9999V9.00017Z"})})},62590:function(e,t,r){"use strict";r.d(t,{N:function(){return o}});var a=r(1204),n=r(2265);let o=()=>{let e=(0,n.useContext)(a.s6);if(!e)throw Error("useConfirm must be used within an AdminProvider");return e}},39526:function(e,t,r){"use strict";r.d(t,{g:function(){return s}});var a=r(18676),n=r(39566),o=r(59578);let s={getImages:async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,r=arguments.length>2?arguments[2]:void 0,a=arguments.length>3?arguments[3]:void 0;return await (0,o.R1)("/api/upload/article-image",{params:{page:e,limit:t,keyword:r,...a?{aiOnly:!0}:{}}})},uploadImage:async e=>{let{file:t,caption:r,description:o,addWatermark:s=!1,watermarkPosition:l="bottom-right",watermarkOpacity:i=.7,watermarkRotation:c=0}=e;try{let e=await fetch("/api/upload/article-image/presigned",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:t.name,contentType:t.type})});if(!e.ok)throw new a.s(await (0,n.Ev)(e,"ì´ë¯¸ì§ ì
ë¡ë URL ë°ê¸ì ì¤í¨íìµëë¤."),e.status);let{presignedUrl:s,key:l,fullUrl:i}=await e.json(),c=await fetch(s,{method:"PUT",body:t,headers:{"Content-Type":t.type}});if(!c.ok)throw new a.s("S3 ì
ë¡ë ì¤í¨: ".concat(c.statusText),c.status);let d=await fetch("/api/upload/article-image",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({photoUrl:i,caption:r,description:o})});if(!d.ok)throw new a.s("DB ì ì¥ ì¤í¨: ".concat(d.statusText),d.status);return await d.json()}
1catch(e){throw console.error("ì´ë¯¸ì§ ì
ë¡ë ì¤ ì¤ë¥ ë°ì:",e),e}},deleteImage:async e=>{let t=(0,o.U0)("/api/upload/article-image/".concat(e)),r=await fetch(t,{method:"DELETE"});if(!r.ok)throw Error("ì´ë¯¸ì§ ìì ì¤í¨: ".concat(r.status," ").concat(r.statusText))},updateImageCaption:async(e,t,r)=>{let a=(0,o.U0)("/api/upload/article-image/".concat(e)),n=await fetch(a,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({caption:t,description:r})});if(!n.ok)throw Error("ì´ë¯¸ì§ 캡ì
ìì ì¤í¨: ".concat(n.status," ").concat(n.statusText));return n.json()},getArticleImages:async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10;try{let n=await (0,o.R1)((0,o.U0)("api/article/".concat(e,"/image"),{page:t.toString(),limit:r.toString()}));if(!n.ok)throw new a.s("ì´ë¯¸ì§ë¥¼ ë¶ë¬ì¤ëë° ì¤í¨íìµëë¤: ".concat(n.statusText),n.status);return n.json()}catch(e){if(e instanceof a.s)throw e;throw new a.s("ì´ë¯¸ì§ë¥¼ ë¶ë¬ì¤ë ì¤ ì¤ë¥ê° ë°ìíìµëë¤.",500)}},uploadArticleImage:async(e,t)=>{try{let r=new FormData;r.append("file",t);let n=await fetch((0,o.U0)("api/article/".concat(e,"/image")),{method:"POST",body:r});if(!n.ok)throw new a.s("ì´ë¯¸ì§ ì
ë¡ëì ì¤í¨íìµëë¤: ".concat(n.statusText),n.status);return n.json()}catch(e){if(e instanceof a.s)throw e;throw new a.s("ì´ë¯¸ì§ë¥¼ ì
ë¡ëíë ì¤ ì¤ë¥ê° ë°ìíìµëë¤.",500)}},deleteArticleImage:async(e,t)=>{try{let r=await fetch((0,o.U0)("api/article/".concat(e,"/image/").concat(t)),{method:"DELETE"});if(!r.ok)throw new a.s("ì´ë¯¸ì§ ìì ì ì¤í¨íìµëë¤: ".concat(r.statusText),r.status)}catch(e){if(e instanceof a.s)throw e;throw new a.s("ì´ë¯¸ì§ë¥¼ ìì íë ì¤ ì¤ë¥ê° ë°ìíìµëë¤.",500)}}}},86815:function(e,t,r){"use strict";var a,n,o,s;r.d(t,{Ju:function(){return l},Tv:function(){return a}}),(o=a||(a={})).IMAGE="IMAGE",o.VIDEO="VIDEO",o.AUDIO="AUDIO",o.DOCUMENT="DOCUMENT",o.OTHER="OTHER",(s=n||(n={})).ACTIVE="ACTIVE",s.DELETED="DELETED",s.PROCESSING="PROCESSING";class l{static async getPresignedUrl(e){let t=await fetch("/api/upload/presigned-url",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw Error((await t.json()).error||"presigned URL ìì±ì ì¤í¨íìµëë¤.");return t.json()}static async confirmUpload(e){let t=await fetch("/api/upload/confirm",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw Error((await t.json()).error||"íì¼ ì ë³´ ì ì¥ì ì¤í¨íìµëë¤.");return(await t.json()).file}static async uploadFile(e,t){let r=new FormData;r.append("file",e),(null==t?void 0:t.description)&&r.append("description",t.description),(null==t?void 0:t.tags)&&t.tags.length>0&&r.append("tags",t.tags.join(","));let a=await fetch("/api/upload",{method:"POST",body:r});if(!a.ok)throw Error((await a.json()).error||"íì¼ ì
ë¡ëì ì¤í¨íìµëë¤.");return a.json()}static async getFileUploads(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=new URLSearchParams;e.page&&t.set("page",e.page.toString()),e.limit&&t.set("limit",e.limit.toString()),e.fileType&&t.set("fileType",e.fileType),e.status&&t.set("status",e.status),e.uploaderId&&t.set("uploaderId",e.uploaderId.toString()),e.search&&t.set("search",e.search),void 0!==e.parentFolderId&&t.set("parentFolderId",null===e.parentFolderId?"null":e.parentFolderId);let r=await fetch("/api/upload/files?".concat(t.toString()));if(!r.ok)throw Error((await r.json()).error||"íì¼ ëª©ë¡ ì¡°íì ì¤í¨íìµëë¤.");return r.json()}static async getFolders(e){let t=new URLSearchParams;t.set("isFolder","true"),t.set("limit","100"),void 0!==e&&t.set("parentFolderId",null===e?"null":e);let r=await fetch("/api/upload/files?".concat(t.toString()));return r.ok?(await r.json()).data.items:[]}static async getFileUploadById(e){let t=await fetch("/api/upload/".concat(e));if(!t.ok)throw Error((await t.json()).error||"íì¼ ì¡°íì ì¤í¨íìµëë¤.");return t.json()}static async updateFileUpload(e,t){let r=await fetch("/api/upload/".concat(e),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok)throw Error((await r.json()).error||"íì¼ ìì ì ì¤í¨íìµëë¤.");return r.json()}static async deleteFileUpload(e){let t=await fetch("/api/upload/".concat(e),{method:"DELETE"});if(!t.ok)throw Error((await t.json()).error||"íì¼ ìì ì ì¤í¨íìµëë¤.");return t.json()}static getDownloadUrl(e){return"/api/upload/".concat(e,"?action=download")}static getFileTypeFromMimeType(e){return e.startsWith("image/")?"IMAGE":e.startsWith("video/")?"VIDEO":e.startsWith("audio/")?"AUDIO":e.includes("pdf")||e.includes("document")||e.includes("text")||e.includes("spreadsheet")||e.includes("presentation")?"DOCUMENT":"OTHER"}static async deleteFiles(e){let t=await fetch("/api/upload/delete",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({fileIds:e})});if(!t.ok)throw Error((await t.json()).error||"íì¼ ìì ì ì¤í¨íìµëë¤.");return await t.json()}static validateFile(e){return e.size>524288e3?{valid:!1,error:"íì¼ í¬ê¸°ë 500MB를 ì´ê³¼í ì ììµëë¤."}
1:["image/jpeg","image/png","image/gif","image/webp","image/svg+xml","application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-powerpoint","application/vnd.openxmlformats-officedocument.presentationml.presentation","text/plain","text/csv","video/mp4","video/mpeg","video/quicktime","video/x-msvideo","audio/mpeg","audio/wav","audio/ogg","audio/mp4"].includes(e.type)?{valid:!0}:{valid:!1,error:"ì§ìíì§ ìë íì¼ íìì
ëë¤."}}static formatFileSize(e){if(0===e)return"0 Bytes";let t=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,t)).toFixed(2))+" "+["Bytes","KB","MB","GB"][t]}}},39566:function(e,t,r){"use strict";function a(e){var t,r;return!!e&&((null==e?void 0:null===(t=e.response)||void 0===t?void 0:t.status)===403||(null==e?void 0:e.status)===403||(null==e?void 0:e.statusCode)===403||(null==e?void 0:null===(r=e.response)||void 0===r?void 0:r.status)===401||(null==e?void 0:e.status)===401||(null==e?void 0:e.statusCode)===401)}function n(e,t){let r=Error(e);return r.statusCode=t,r}async function o(e,t){try{let t=await e.json();if(t&&"string"==typeof t.error&&t.error.trim())return t.error}catch(e){}return t}r.d(t,{Ev:function(){return o},lx:function(){return a},zm:function(){return n}})},21966:function(e,t,r){"use strict";r.d(t,{addWatermarkInBrowser:function(){return n},eK:function(){return i},fg:function(){return a},po:function(){return o},resizeImageInBrowser:function(){return l}});let a=e=>"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap;async function n(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},{position:n="bottom-right",opacity:l=.7,scale:i=.3,margin:c=20,rotation:d=0}=r,u=null;try{if("function"==typeof createImageBitmap)try{u=await createImageBitmap(e)}catch(t){console.warn("createImageBitmap ë¡ë ì¤í¨, Image ë¡ëë¡ í´ë°±í©ëë¤:",t),u=await o(e)}else u=await o(e);let r=a(u)?u.width:u.naturalWidth||u.width,m=a(u)?u.height:u.naturalHeight||u.height;if(r<100||m<100)return e;let h=await s(t),p=document.createElement("canvas");p.width=r,p.height=m;let x=p.getContext("2d");if(!x)throw Error("Canvas context를 ê°ì ¸ì¬ ì ììµëë¤.");x.drawImage(u,0,0,r,m);let g=Math.max(50,Math.floor(r*i)),f=Math.floor(h.height*(g/h.width)),b=0,v=0;switch(n){case"top-left":b=c,v=c;break;case"top":b=Math.floor((r-g)/2),v=c;break;case"top-right":b=r-g-c,v=c;break;case"left":b=c,v=Math.floor((m-f)/2);break;case"center":b=Math.floor((r-g)/2),v=Math.floor((m-f)/2);break;case"right":b=r-g-c,v=Math.floor((m-f)/2);break;case"bottom-left":b=c,v=m-f-c;break;case"bottom":b=Math.floor((r-g)/2),v=m-f-c;break;case"bottom-right":b=r-g-c,v=m-f-c}b=Math.max(0,Math.min(b,r-g)),v=Math.max(0,Math.min(v,m-f));let w=document.createElement("canvas");w.width=g,w.height=f;let y=w.getContext("2d");if(!y)throw Error("ìì Canvas context를 ê°ì ¸ì¬ ì ììµëë¤.");y.drawImage(h,0,0,g,f);let j=y.getImageData(0,0,g,f),N=j.data;for(let e=0;e<N.length;e+=4){let t=.299*N[e]+.587*N[e+1]+.114*N[e+2];N[e]=t,N[e+1]=t,N[e+2]=t}y.putImageData(j,0,0),x.save(),x.globalAlpha=l;let k=b+g/2,C=v+f/2;x.translate(k,C),x.rotate(d*Math.PI/180),x.drawImage(w,-g/2,-f/2),x.restore();let E=await new Promise((t,r)=>{p.toBlob(e=>{e?t(e):r(Error("Blob ë³í ì¤í¨"))},e.type||"image/png",.95)}),M=e.name.replace(/\.[^/.]+$/,"")+"_watermark"+function(e){let t=e.match(/\.[^/.]+$/);return t?t[0]:".png"}(e.name);return new File([E],M,{type:e.type||"image/png"})}catch(t){return console.error("â ìí°ë§í¬ ì¶ê° ì¤í¨:",t),e}finally{u&&a(u)&&u.close()}}function o(e){return new Promise((t,r)=>{let a=new Image,n=URL.createObjectURL(e);a.onload=()=>{URL.revokeObjectURL(n),t(a)},a.onerror=e=>{URL.revokeObjectURL(n),r(e)},a.src=n})}function s(e){return new Promise((t,r)=>{let a=new Image;if(a.crossOrigin="anonymous",a.onload=()=>t(a),a.onerror=t=>{console.error("ì´ë¯¸ì§ ë¡ë ì¤í¨ (URL: ".concat(e,")"),t),r(t)},e.startsWith("data:")||e.startsWith("blob:")){a.src=e;return}let n=e.includes("?")?"&":"?";a.src="".concat(e).concat(n,"t=").concat(new Date().getTime())})}async function l(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{maxWidth:r=1200,maxHeight:n,quality:s=.92}=t,l=null;try{if("function"==typeof createImageBitmap)try{l=await createImageBitmap(e)}catch(t){l=await o(e)}else l=await o(e);
1let t=a(l)?l.width:l.naturalWidth||l.width,i=a(l)?l.height:l.naturalHeight||l.height,c=t>r,d=!!n&&i>n;if(!c&&!d)return e;let u=t,m=i;c&&(u=r,m=Math.round(r/t*i)),n&&m>n&&(u=Math.round(n/m*u),m=n);let h=document.createElement("canvas");h.width=u,h.height=m;let p=h.getContext("2d");if(!p)throw Error("Canvas context를 ê°ì ¸ì¬ ì ììµëë¤.");p.drawImage(l,0,0,u,m);let x=e.type||"image/jpeg",g=/jpe?g|webp/.test(x),f=await new Promise((e,t)=>{h.toBlob(r=>r?e(r):t(Error("리ì¬ì´ì¦ Blob ë³í ì¤í¨")),x,g?s:void 0)});return new File([f],e.name,{type:x,lastModified:e.lastModified||Date.now()})}catch(t){return console.error("â 리ì¬ì´ì¦ ì¤í¨:",t),e}finally{l&&a(l)&&l.close()}}async function i(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},{position:a="bottom-right",opacity:n=.7,scale:o=.3,margin:l=20,rotation:i=0}=r;try{let r=await s(e),c=await s(t),d=document.createElement("canvas");d.width=r.width,d.height=r.height;let u=d.getContext("2d");if(!u)throw Error("Canvas context를 ê°ì ¸ì¬ ì ììµëë¤.");u.drawImage(r,0,0);let m=Math.max(50,Math.floor(r.width*o)),h=Math.floor(c.height*(m/c.width)),p=0,x=0;switch(a){case"top-left":p=l,x=l;break;case"top":p=Math.floor((r.width-m)/2),x=l;break;case"top-right":p=r.width-m-l,x=l;break;case"left":p=l,x=Math.floor((r.height-h)/2);break;case"center":p=Math.floor((r.width-m)/2),x=Math.floor((r.height-h)/2);break;case"right":p=r.width-m-l,x=Math.floor((r.height-h)/2);break;case"bottom-left":p=l,x=r.height-h-l;break;case"bottom":p=Math.floor((r.width-m)/2),x=r.height-h-l;break;case"bottom-right":p=r.width-m-l,x=r.height-h-l}p=Math.max(0,Math.min(p,r.width-m)),x=Math.max(0,Math.min(x,r.height-h));let g=document.createElement("canvas");g.width=m,g.height=h;let f=g.getContext("2d");if(!f)throw Error("ìì Canvas context를 ê°ì ¸ì¬ ì ììµëë¤.");f.drawImage(c,0,0,m,h);let b=f.getImageData(0,0,m,h),v=b.data;for(let e=0;e<v.length;e+=4){let t=.299*v[e]+.587*v[e+1]+.114*v[e+2];v[e]=t,v[e+1]=t,v[e+2]=t}f.putImageData(b,0,0),u.save(),u.globalAlpha=n;let w=p+m/2,y=x+h/2;return u.translate(w,y),u.rotate(i*Math.PI/180),u.drawImage(g,-m/2,-h/2),u.restore(),d.toDataURL("image/png")}catch(t){return console.error("미리보기 ìí°ë§í¬ ìì± ì¤í¨:",t),e}}},77734:function(e){e.exports={enter:"mobileAnimations_enter__qNliW",enterActive:"mobileAnimations_enterActive__xe_wH",exit:"mobileAnimations_exit__hR9Fc",exitActive:"mobileAnimations_exitActive__KyX4_"}}}]);
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.