(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,15161,e=>{"use strict";var t=e.i(43476),s=e.i(71645),a=e.i(38149),l=e.i(23975);e.i(89308);var r=e.i(75954);async function i(e){let t=await e.arrayBuffer(),s=await r.PDFDocument.load(t),a=s.getPageCount(),l=[];for(let e=0;et.addPage(e));let s=await t.save();l.push({name:`${e.label}.pdf`,bytes:s})}return l}async function d(e){let t=await e.arrayBuffer();return(await r.PDFDocument.load(t)).getPageCount()}var o=e.i(43682),c=e.i(11110);function x(){let[e,r]=(0,s.useState)(null),[x,m]=(0,s.useState)(0),[h,u]=(0,s.useState)("all"),[b,g]=(0,s.useState)(""),[j,f]=(0,s.useState)(!1),[k,v]=(0,s.useState)(!1),{tl:N}=(0,c.useLanguage)(),w=N.split.content,y=(0,s.useCallback)(async e=>{let t=e[0];r(t),v(!1),m(await d(t))},[]),P=async()=>{if(e){f(!0);try{if("all"===h){let t=await i(e);1===t.length?(0,o.downloadBytes)(t[0].bytes,t[0].name):await (0,o.downloadZip)(t,"split_pages.zip")}else{let t=b.split(",").map(e=>e.trim()).filter(Boolean).map((e,t)=>{let s=[];if(e.includes("-")){let[t,a]=e.split("-").map(e=>parseInt(e.trim(),10));for(let e=t;e<=Math.min(a,x);e++)s.push(e-1)}else{let t=parseInt(e,10);!isNaN(t)&&t>=1&&t<=x&&s.push(t-1)}return{label:`part_${t+1}`,pages:s}}).filter(e=>e.pages.length>0);if(0===t.length)return void alert(N.split.invalidRange);let s=await n(e,t);1===s.length?(0,o.downloadBytes)(s[0].bytes,s[0].name):await (0,o.downloadZip)(s,"split_ranges.zip")}v(!0)}catch(e){console.error(e),alert(N.split.error)}finally{f(!1)}}};return(0,t.jsxs)(a.default,{title:N.split.title,description:N.split.desc,color:"violet",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 12h16M12 4v8M12 12v8"})}),children:[e?(0,t.jsxs)("div",{className:"space-y-5",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 bg-violet-50 dark:bg-violet-900/20 border border-violet-200 dark:border-violet-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:[x," ",N.common.pages]})]}),(0,t.jsx)("button",{onClick:()=>{r(null),m(0),v(!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-5 space-y-4",children:[(0,t.jsx)("p",{className:"font-medium text-slate-700 dark:text-slate-200",children:N.split.splitMethod}),(0,t.jsxs)("label",{className:"flex items-start gap-3 cursor-pointer",children:[(0,t.jsx)("input",{type:"radio",checked:"all"===h,onChange:()=>u("all"),className:"mt-0.5 accent-violet-600"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm font-medium text-slate-700 dark:text-slate-200",children:N.split.allPages}),(0,t.jsx)("p",{className:"text-xs text-slate-400 dark:text-slate-500",children:N.split.allPagesDesc})]})]}),(0,t.jsxs)("label",{className:"flex items-start gap-3 cursor-pointer",children:[(0,t.jsx)("input",{type:"radio",checked:"range"===h,onChange:()=>u("range"),className:"mt-0.5 accent-violet-600"}),(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsx)("p",{className:"text-sm font-medium text-slate-700 dark:text-slate-200",children:N.split.byRange}),(0,t.jsx)("p",{className:"text-xs text-slate-400 dark:text-slate-500",children:N.split.byRangeDesc}),"range"===h&&(0,t.jsx)("input",{type:"text",value:b,onChange:e=>g(e.target.value),placeholder:`e.g. 1-3, 4, 5-${x}`,className:"mt-2 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-violet-500 bg-white dark:bg-slate-700 text-slate-700 dark:text-slate-200"})]})]})]}),(0,t.jsxs)("div",{className:"flex gap-3",children:[(0,t.jsx)("button",{onClick:P,disabled:j||"range"===h&&!b.trim(),className:"flex-1 py-3 bg-violet-600 text-white font-semibold rounded-xl hover:bg-violet-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.split.splitting]}):k?N.split.doneSplit:N.split.splitBtn}),(0,t.jsx)("button",{onClick:()=>{r(null),m(0),v(!1),g("")},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.split.reset})]})]}):(0,t.jsx)(l.default,{onFiles:y,label:N.split.dropLabel}),(0,t.jsxs)("div",{className:"space-y-12 mt-12",children:[(0,t.jsx)(p,{title:w.howTo.title,children:(0,t.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-5",children:w.howTo.steps.map((e,s)=>(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",s+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})]},s))})}),(0,t.jsxs)(p,{title:w.about.title,children:[(0,t.jsx)("p",{className:"text-slate-500 dark:text-slate-400 mb-6",children:w.about.description}),(0,t.jsx)("div",{className:"space-y-5",children:w.about.methods.map((e,s)=>(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})]},s))})]}),(0,t.jsx)(p,{title:w.faq.title,children:(0,t.jsx)("div",{className:"space-y-4",children:w.faq.items.map((e,s)=>(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})]},s))})})]})]})}function p({title:e,children:s}){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}),s]})}e.s(["default",()=>x],15161)},95004,e=>{e.v(t=>Promise.all(["static/chunks/46b334ca3410349e.js","static/chunks/b383336e3942b8bd.js"].map(t=>e.l(t))).then(()=>t(71315)))}]);