(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,5628,e=>{"use strict";var t=e.i(71645);function a(s,r,l=.28){let[i,n]=(0,t.useState)([]),[d,o]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{if(!s||0===r)return void n([]);let t=!1;return o(!0),n(Array(r).fill(null)),(async()=>{let a=await e.A(25834);a.GlobalWorkerOptions.workerSrc="/pdf.worker.min.js";let i=await s.arrayBuffer(),d=await a.getDocument({data:i}).promise;for(let e=1;e<=r&&!t;e++){let a=await d.getPage(e),s=a.getViewport({scale:l}),r=document.createElement("canvas");r.width=Math.round(s.width),r.height=Math.round(s.height);let i=r.getContext("2d");i.fillStyle="#ffffff",i.fillRect(0,0,r.width,r.height),await a.render({canvasContext:i,canvas:r,viewport:s}).promise;let o=r.toDataURL("image/jpeg",.75);t||n(t=>{let a=[...t];return a[e-1]=o,a})}t||o(!1)})(),()=>{t=!0}},[s,r,l]),{thumbnails:i,loading:d}}e.s(["usePdfThumbnails",()=>a])},80385,e=>{"use strict";var t=e.i(43476),a=e.i(71645),s=e.i(38149),r=e.i(23975);e.i(89308);var l=e.i(75954);async function i(e,t){let a=await e.arrayBuffer(),s=await l.PDFDocument.load(a),r=await l.PDFDocument.create();return(await r.copyPages(s,t)).forEach(e=>r.addPage(e)),r.save()}async function n(e){let t=await e.arrayBuffer();return(await l.PDFDocument.load(t)).getPageCount()}function d(e,t){let a=new Set;for(let s of e.split(",").map(e=>e.trim()).filter(Boolean))if(s.includes("-")){let[e,r]=s.split("-"),l=parseInt(e.trim(),10),i=parseInt(r.trim(),10);if(!isNaN(l)&&!isNaN(i))for(let e=Math.max(1,l);e<=Math.min(t,i);e++)a.add(e-1)}else{let e=parseInt(s,10);!isNaN(e)&&e>=1&&e<=t&&a.add(e-1)}return Array.from(a).sort((e,t)=>e-t)}var o=e.i(43682),c=e.i(5628),x=e.i(11110);function m(){let[e,l]=(0,a.useState)(null),[m,u]=(0,a.useState)(0),[b,f]=(0,a.useState)(""),[g,p]=(0,a.useState)(new Set),[j,k]=(0,a.useState)(!1),[v,w]=(0,a.useState)(!1),{tl:N}=(0,x.useLanguage)(),y=N.extract.content,{thumbnails:S,loading:C}=(0,c.usePdfThumbnails)(e,m),P=(0,a.useCallback)(async e=>{let t=e[0];l(t),w(!1),f(""),p(new Set),u(await n(t))},[]),B=async()=>{if(!e)return;let t=b.trim()?d(b,m):Array.from(g).sort((e,t)=>e-t);if(0===t.length)return void alert(N.extract.noPage);k(!0);try{let a=await i(e,t);(0,o.downloadBytes)(a,e.name.replace(/\.pdf$/i,"_extracted.pdf")),w(!0)}catch(e){console.error(e),alert(N.extract.error)}finally{k(!1)}},L=b.trim()?d(b,m).length:g.size;return(0,t.jsxs)(s.default,{title:N.extract.title,description:N.extract.desc,color:"rose",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:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"})}),children:[e?(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 bg-rose-50 dark:bg-rose-900/20 border border-rose-200 dark:border-rose-800 rounded-xl px-4 py-3",children:[(0,t.jsx)("svg",{viewBox:"0 0 24 24",className:"w-5 h-5 text-red-500 flex-shrink-0",fill:"currentColor",children:(0,t.jsx)("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8l-6-6z"})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("p",{className:"text-sm font-medium text-slate-700 dark:text-slate-200 truncate",children:e.name}),(0,t.jsxs)("p",{className:"text-xs text-slate-400 dark:text-slate-500",children:[m," ",N.common.pages]})]}),(0,t.jsx)("button",{onClick:()=>{l(null),u(0),w(!1)},className:"text-slate-400 hover:text-red-500",children:(0,t.jsx)("svg",{viewBox:"0 0 24 24",className:"w-4 h-4",fill:"none",stroke:"currentColor",strokeWidth:2,children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),(0,t.jsxs)("div",{className:"bg-white dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded-xl p-4",children:[(0,t.jsxs)("label",{className:"block text-sm font-medium text-slate-700 dark:text-slate-200 mb-2",children:[N.extract.rangeLabel," ",(0,t.jsx)("span",{className:"text-slate-400 dark:text-slate-500 font-normal",children:N.extract.rangeHint})]}),(0,t.jsx)("input",{type:"text",value:b,onChange:e=>{f(e.target.value),p(new Set),w(!1)},placeholder:N.extract.rangePlaceholder.replace("{n}",String(m)),className:"w-full border border-slate-300 dark:border-slate-600 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-rose-500 bg-white dark:bg-slate-700 text-slate-700 dark:text-slate-200"})]}),(0,t.jsxs)("div",{className:"bg-white dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded-xl p-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,t.jsx)("p",{className:"text-sm font-medium text-slate-700 dark:text-slate-200",children:C?(0,t.jsx)("span",{className:"text-slate-400 dark:text-slate-500",children:N.extract.loadingPreview}):N.extract.pageSelection.replace("{n}",String(L))}),(0,t.jsxs)("div",{className:"flex gap-3",children:[(0,t.jsx)("button",{onClick:()=>{p(new Set(Array.from({length:m},(e,t)=>t))),f("")},className:"text-xs text-rose-600 dark:text-rose-400 hover:underline",children:N.extract.selectAll}),(0,t.jsx)("button",{onClick:()=>{p(new Set),f("")},className:"text-xs text-slate-400 dark:text-slate-500 hover:underline",children:N.extract.clearAll})]})]}),(0,t.jsx)("div",{className:"grid grid-cols-4 sm:grid-cols-5 md:grid-cols-6 gap-2 max-h-[480px] overflow-y-auto pr-1",children:Array.from({length:m},(e,a)=>{let s=S[a],r=b.trim()?d(b,m).includes(a):g.has(a);return(0,t.jsxs)("button",{onClick:()=>!b.trim()&&void(p(e=>{let t=new Set(e);return t.has(a)?t.delete(a):t.add(a),t}),w(!1),f("")),disabled:!!b.trim(),className:`relative flex flex-col items-center gap-1 rounded-lg p-1 border-2 transition-all ${r?"border-rose-500 bg-rose-50 dark:bg-rose-900/30":"border-transparent hover:border-slate-300 dark:hover:border-slate-500 bg-slate-50 dark:bg-slate-700"} ${b.trim()?"cursor-default":"cursor-pointer"}`,children:[(0,t.jsxs)("div",{className:"w-full aspect-[3/4] rounded overflow-hidden bg-slate-200 dark:bg-slate-600 relative",children:[s?(0,t.jsx)("img",{src:s,alt:`${a+1}`,className:"w-full h-full object-contain bg-white"}):(0,t.jsx)("div",{className:"w-full h-full animate-pulse bg-slate-200 dark:bg-slate-600"}),r&&(0,t.jsx)("div",{className:"absolute top-1 right-1 w-5 h-5 bg-rose-500 rounded-full flex items-center justify-center shadow",children:(0,t.jsx)("svg",{viewBox:"0 0 24 24",className:"w-3 h-3 text-white",fill:"none",stroke:"currentColor",strokeWidth:3,children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})})]}),(0,t.jsx)("span",{className:`text-xs font-medium ${r?"text-rose-600 dark:text-rose-400":"text-slate-500 dark:text-slate-400"}`,children:a+1})]},a)})})]}),(0,t.jsxs)("div",{className:"flex gap-3",children:[(0,t.jsx)("button",{onClick:B,disabled:j||0===L,className:"flex-1 py-3 bg-rose-600 text-white font-semibold rounded-xl hover:bg-rose-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors flex items-center justify-center gap-2",children:j?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("svg",{className:"w-4 h-4 animate-spin",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"})}),N.extract.extracting]}):v?N.extract.doneExtract:L>0?N.extract.extractBtnN.replace("{n}",String(L)):N.extract.extractBtn}),(0,t.jsx)("button",{onClick:()=>{l(null),u(0),w(!1),f(""),p(new Set)},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:N.common.reset})]})]}):(0,t.jsx)(r.default,{onFiles:P,label:N.extract.dropLabel}),(0,t.jsxs)("div",{className:"space-y-12 mt-12",children:[(0,t.jsx)(h,{title:y.howTo.title,children:(0,t.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-5",children:y.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)(h,{title:y.about.title,children:[(0,t.jsx)("p",{className:"text-slate-500 dark:text-slate-400 mb-6",children:y.about.description}),(0,t.jsx)("div",{className:"space-y-5",children:y.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)(h,{title:y.faq.title,children:(0,t.jsx)("div",{className:"space-y-4",children:y.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))})})]})]})}function h({title:e,children:a}){return(0,t.jsxs)("section",{children:[(0,t.jsx)("h2",{className:"text-2xl font-bold text-slate-800 dark:text-slate-100 text-center mb-6",children:e}),a]})}e.s(["default",()=>m],80385)},95004,e=>{e.v(t=>Promise.all(["static/chunks/46b334ca3410349e.js","static/chunks/b383336e3942b8bd.js"].map(t=>e.l(t))).then(()=>t(71315)))},25834,e=>{e.v(t=>Promise.all(["static/chunks/46b334ca3410349e.js","static/chunks/d125a3694ba40e5d.js"].map(t=>e.l(t))).then(()=>t(18657)))}]);