(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,95392,e=>{"use strict";var t=e.i(43476),a=e.i(71645),s=e.i(38149),r=e.i(23975),l=e.i(21274),d=e.i(85665);e.i(89308);var o=e.i(75954);async function n(e){let t=await o.PDFDocument.create();for(let a of e){let e,s=await a.arrayBuffer(),r=a.type;if("image/jpeg"===r||"image/jpg"===r)e=await t.embedJpg(s);else{if("image/png"!==r)continue;e=await t.embedPng(s)}let{width:l,height:d}=e;t.addPage([l,d]).drawImage(e,{x:0,y:0,width:l,height:d})}return t.save()}async function i(t,a=1.5,s){let r=await e.A(25834);r.GlobalWorkerOptions.workerSrc="/pdf.worker.min.js";let l=await t.arrayBuffer(),d=r.getDocument({data:l}),o=await d.promise,n=o.numPages,c=[];for(let e=1;e<=n;e++){let t=await o.getPage(e),r=t.getViewport({scale:a}),l=document.createElement("canvas");l.width=r.width,l.height=r.height;let d=l.getContext("2d");await t.render({canvasContext:d,canvas:l,viewport:r}).promise,c.push(l.toDataURL("image/png")),s?.(e,n)}return c}var c=e.i(43682),m=e.i(11110);function x(){let[e,o]=(0,a.useState)("pdf-to-img"),[x,g]=(0,a.useState)([]),[p,u]=(0,a.useState)(!1),[h,b]=(0,a.useState)(null),[f,j]=(0,a.useState)([]),[v,k]=(0,a.useState)(!1),[w,N]=(0,a.useState)(null),{tl:y}=(0,m.useLanguage)(),P=y.convert.content,C=(0,a.useCallback)(e=>{g(e),j([]),k(!1),N(null)},[]),S=async()=>{if(0!==x.length){u(!0),b(null),j([]),k(!1),N(null);try{if("pdf-to-img"===e){let e=await i(x[0],2,(e,t)=>b({current:e,total:t}));j(e),k(!0)}else{let e=await n(x);(0,c.downloadBytes)(e,"images_to_pdf.pdf"),k(!0)}}catch(e){console.error(e),N(y.convert.error)}finally{u(!1),b(null)}}};return(0,t.jsxs)(s.default,{title:y.convert.title,description:y.convert.desc,color:"orange",icon:(0,t.jsx)("svg",{viewBox:"0 0 24 24",className:"w-7 h-7 text-white",fill:"none",stroke:"currentColor",strokeWidth:2,children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})}),children:[(0,t.jsx)("div",{className:"flex bg-white dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded-xl p-1 mb-6",children:["pdf-to-img","img-to-pdf"].map(a=>(0,t.jsx)("button",{onClick:()=>{o(a),g([]),j([]),k(!1),N(null)},className:`flex-1 py-2 text-sm font-medium rounded-lg transition-colors ${e===a?"bg-orange-500 text-white shadow-sm":"text-slate-500 dark:text-slate-400 hover:text-slate-700 dark:hover:text-slate-200"}`,children:"pdf-to-img"===a?y.convert.pdfToImg:y.convert.imgToPdf},a))}),0===x.length?(0,t.jsx)(r.default,{onFiles:C,accept:"pdf-to-img"===e?{"application/pdf":[".pdf"]}:{"image/jpeg":[".jpg",".jpeg"],"image/png":[".png"]},multiple:"img-to-pdf"===e,label:"pdf-to-img"===e?y.convert.dropPdf:y.convert.dropImg,sublabel:"pdf-to-img"===e?y.convert.sublabelPdf:y.convert.sublabelImg,color:"orange"}):(0,t.jsxs)("div",{className:"space-y-5",children:[(0,t.jsx)("div",{className:"bg-orange-50 dark:bg-orange-900/20 border border-orange-200 dark:border-orange-800 rounded-xl px-4 py-3 space-y-1",children:x.map((e,a)=>(0,t.jsx)("p",{className:"text-sm text-slate-700 dark:text-slate-200 truncate",children:e.name},a))}),p&&h&&(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex justify-between text-xs text-slate-500 dark:text-slate-400 mb-1",children:[(0,t.jsx)("span",{children:y.convert.converting}),(0,t.jsxs)("span",{children:[h.current," / ",h.total," ",y.common.pages]})]}),(0,t.jsx)("div",{className:"bg-slate-100 dark:bg-slate-700 rounded-full h-2 overflow-hidden",children:(0,t.jsx)("div",{className:"h-2 bg-orange-500 rounded-full transition-all",style:{width:`${h.current/h.total*100}%`}})})]}),f.length>0&&(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)("p",{className:"text-sm font-medium text-slate-600 dark:text-slate-300",children:y.convert.doneConvert.replace("{n}",String(f.length))}),(0,t.jsx)("div",{className:"grid grid-cols-2 gap-3 max-h-[400px] overflow-y-auto",children:f.map((e,a)=>(0,t.jsxs)("div",{className:"relative group",children:[(0,t.jsx)("img",{src:e,alt:`page ${a+1}`,className:"w-full border border-slate-200 dark:border-slate-700 rounded-lg"}),(0,t.jsx)("button",{onClick:()=>(0,c.downloadDataUrl)(e,`page_${a+1}.png`),className:"absolute inset-0 bg-black/40 text-white text-sm font-medium rounded-lg opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center",children:y.convert.download}),(0,t.jsx)("p",{className:"text-xs text-center text-slate-500 dark:text-slate-400 mt-1",children:y.convert.pageLabel.replace("{n}",String(a+1))})]},a))})]}),w&&(0,t.jsx)("p",{className:"text-sm text-red-600 dark:text-red-400 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg px-3 py-2",children:w}),(0,t.jsxs)("div",{className:"flex gap-3",children:[(0,t.jsx)("button",{onClick:S,disabled:p,className:"flex-1 py-3 bg-orange-500 text-white font-semibold rounded-xl hover:bg-orange-600 disabled:opacity-50 transition-colors flex items-center justify-center gap-2 whitespace-nowrap",children:p?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("svg",{className:"w-4 h-4 animate-spin flex-shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 12a8 8 0 018-8v8z"})}),y.convert.converting]}):"pdf-to-img"===e?y.convert.toImage:y.convert.toPdf}),(0,t.jsx)("button",{onClick:()=>{g([]),j([]),k(!1),N(null)},className:"px-4 py-3 border border-slate-200 dark:border-slate-700 text-slate-600 dark:text-slate-300 rounded-xl hover:bg-slate-50 dark:hover:bg-slate-800 transition-colors",children:y.convert.reset})]}),v&&(0,t.jsx)(l.default,{})]}),(0,t.jsxs)("div",{className:"space-y-12 mt-12",children:[(0,t.jsx)(d.default,{title:P.howTo.title,children:(0,t.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-5",children:P.howTo.steps.map((e,a)=>(0,t.jsxs)("div",{className:"bg-white dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded-xl p-5",children:[(0,t.jsxs)("div",{className:"font-bold text-lg text-slate-400 dark:text-slate-500 mb-2",children:["0",a+1]}),(0,t.jsx)("h3",{className:"font-semibold text-slate-800 dark:text-slate-100 mb-1",children:e.title}),(0,t.jsx)("p",{className:"text-sm text-slate-500 dark:text-slate-400",children:e.desc})]},a))})}),(0,t.jsxs)(d.default,{title:P.about.title,children:[(0,t.jsx)("p",{className:"text-slate-500 dark:text-slate-400 mb-6",children:P.about.description}),(0,t.jsx)("div",{className:"space-y-5",children:P.about.methods.map((e,a)=>(0,t.jsxs)("div",{className:"bg-slate-50 dark:bg-slate-800/50 border border-slate-200 dark:border-slate-700 rounded-xl p-5",children:[(0,t.jsx)("h3",{className:"font-semibold text-slate-800 dark:text-slate-100 mb-1",children:e.title}),(0,t.jsx)("p",{className:"text-sm text-slate-500 dark:text-slate-400",children:e.desc})]},a))})]}),(0,t.jsx)(d.default,{title:P.faq.title,children:(0,t.jsx)("div",{className:"space-y-4",children:P.faq.items.map((e,a)=>(0,t.jsxs)("details",{className:"bg-slate-50 dark:bg-slate-800/50 border border-slate-200 dark:border-slate-700 rounded-xl p-4 cursor-pointer",children:[(0,t.jsx)("summary",{className:"font-semibold text-slate-800 dark:text-slate-100",children:e.q}),(0,t.jsx)("p",{className:"text-sm text-slate-500 dark:text-slate-400 mt-2",children:e.a})]},a))})})]})]})}e.s(["default",()=>x],95392)},25834,e=>{e.v(t=>Promise.all(["static/chunks/46b334ca3410349e.js","static/chunks/d125a3694ba40e5d.js"].map(t=>e.l(t))).then(()=>t(18657)))},95004,e=>{e.v(t=>Promise.all(["static/chunks/46b334ca3410349e.js","static/chunks/b383336e3942b8bd.js"].map(t=>e.l(t))).then(()=>t(71315)))}]);