1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4186],{19524:(e,s,t)=>{t.r(s),t.d(s,{default:()=>d});var r=t(98914),l=t(59626),a=t(95898),i=t(2945),n=t(76801);function d(){let[e,s]=(0,l.useState)(null),[t,d]=(0,l.useState)(0),[o,c]=(0,l.useState)(null),[m,h]=(0,l.useState)(0),[x,u]=(0,l.useState)(75),[p,f]=(0,l.useState)(!1),[g,b]=(0,l.useState)(!1),[w,j]=(0,l.useState)(null),[v,N]=(0,l.useState)(null),[y,P]=(0,l.useState)(!1),[k,C]=(0,l.useState)(0),F=(0,l.useRef)(null),R=(0,l.useRef)(null);(0,l.useEffect)(()=>{let e=R.current;if(!e)return;let s=e=>{e.preventDefault(),b(!0)},t=e=>{e.preventDefault()},r=()=>b(!1),l=e=>{e.preventDefault(),b(!1),e.dataTransfer.files.length&&D({target:{files:e.dataTransfer.files}})};return e.addEventListener("dragenter",s),e.addEventListener("dragover",t),e.addEventListener("dragleave",r),e.addEventListener("drop",l),()=>{e.removeEventListener("dragenter",s),e.removeEventListener("dragover",t),e.removeEventListener("dragleave",r),e.removeEventListener("drop",l)}},[]);let D=e=>{let t=e.target.files[0];if(t){if("application/pdf"!==t.type)return void i.oR.error("Please select a PDF file");s(t),d(t.size),c(null),h(0),N(null),j(URL.createObjectURL(t)),i.oR.success("PDF file loaded successfully")}},L=async()=>{if(!e)return void i.oR.error("Please select a PDF file first");f(!0),C(0);let s=i.oR.loading("Compressing PDF...");try{let t=await S(e);C(20);let r=await n.U.load(t);C(40);let l=r.getPages(),a=await n.U.create();C(50);let d=await a.embedPages(l);for(let e=0;e<d.length;e++){let s=d[e];C(50+Math.round(e/d.length*30));let{width:t,height:r}=s;a.addPage([t,r]).drawPage(s,{x:0,y:0,width:t,height:r}),await new Promise(e=>setTimeout(e,10))}C(80);let o=await a.save({useObjectStreams:!0,addDefaultPage:!1,compress:!0,updateFieldAppearances:!1,objectsPerTick:100});C(90);let m=new Blob([o],{type:"application/pdf"});h(m.size),c(m),N(URL.createObjectURL(m));let x=U();i.oR.update(s,{render:x>0?"PDF compressed successfully! Reduced by ".concat(x,"%"):"PDF processed. File size already optimized.",type:"success",isLoading:!1,autoClose:3e3})}catch(t){console.error("Compression error",t);try{let t=await S(e),r=await n.U.load(t),l=await n.U.create(),a=r.getPages(),d=x>70?.95:.9,o=await l.embedPages(a);for(let e=0;e<o.length;e++){let s=o[e],t=s.width*d,r=s.height*d;l.addPage([t,r]).drawPage(s,{x:0,y:0,width:t,height:r})}let m=await l.save({useObjectStreams:!0,compress:!0,updateFieldAppearances:!1}),u=new Blob([m],{type:"application/pdf"});h(u.size),c(u),N(URL.createObjectURL(u));let p=U();i.oR.update(s,{render:"PDF compressed with size reduction! Reduced by ".concat(p,"%"),type:"success",isLoading:!1,autoClose:3e3})}catch(e){i.oR.update(s,{render:"Failed to compress PDF: "+t.message,type:"error",isLoading:!1,autoClose:3e3})}}finally{f(!1),C(100)}},S=e=>new Promise((s,t)=>{let r=new FileReader;r.onload=()=>s(r.result),r.onerror=t,r.readAsArrayBuffer(e)}),U=()=>m&&t?Math.round((1-m/t)*100):0,E=e=>{if(0===e)return"0 Bytes";let s=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,s)).toFixed(2))+" "+["Bytes","KB","MB","GB"][s]};return(0,r.jsx)("div",{className:"min-h-screen bg-gradient-to-br from-purple-900 via-blue-900 to-indigo-900 text-white rounded-full",children:(0,r.jsx)("div",{className:" mx-auto px-4 pb-12",children:(0,r.jsxs)("div",{className:"bg-white/5 backdrop-blur-lg rounded-xl shadow-2xl overflow-hidden border border-white/10",children:[(0,r.jsxs)("div",{className:"text-center mb-8 pt-12",children:[(0,r.jsxs)("div",{className:"flex items-center justify-center gap-3",children:[(0,r.jsx)(a._V,{className:"text-cyan-400",size:28}),(0,r.jsx)("h1",{className:"text-3xl font-bold text-white",children:"PDF Compressor"})]}),(0,r.jsx)("p",{className:"text-white/80 mt-2",children:"Reduce PDF file size while maintaining quality"})]}),(0,r.jsxs)("div",{className:"p-6",children:[e?(0,r.jsxs)("div",{className:"space-y-6",children:[p&&k>0&&k<100&&(0,r.jsxs)("div",{className:"w-full bg-white/10 rounded-full h-2.5",children:[(0,r.jsx)("div",{className:"bg-cyan-400 h-2.5 rounded-full transition-all duration-300",style:{width:"".concat(k,"%")}}),(0,r.jsxs)("div",{className:"text-xs text-white/80 mt-1 text-center",children:[k,"% Complete"]})]}),(0,r.jsxs)("div",{className:"flex flex-col lg:flex-row gap-6",children:[(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsxs)("div",{className:"flex justify-between items-center mb-2",children:[(0,r.jsx)("h3",{className:"text-lg font-bold text-white",children:"Original PDF"}),(0,r.jsx)("span",{className:"text-xs bg-blue-900/50 text-cyan-200 px-2 py-1 rounded",children:E(t)})]}),(0,r.jsxs)("div",{className:"relative aspect-[4/3] bg-gray-800/30 rounded-lg overflow-hidden border border-white/10 flex items-center justify-center",children:[(0,r.jsx)(a.ZH,{className:"h-16 w-16 text-cyan-400"}),(0,r.jsx)("div",{className:"absolute bottom-2 left-2 bg-black/70 px-2 py-1 rounded text-sm",children:e.name})]}),(0,r.jsxs)("div",{className:"text-sm text-white/80 mt-2 space-y-1",children:[(0,r.jsx)("p",{children:e.name}),(0,r.jsx)("p",{children:E(t)})]})]}),(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsxs)("div",{className:"flex justify-between items-center mb-2",children:[(0,r.jsx)("h3",{className:"text-lg font-bold text-white",children:"Compressed PDF"}),o&&(0,r.jsxs)("span",{className:"text-xs px-2 py-1 rounded ".concat(U()>0?"bg-green-900/50 text-green-200":"bg-yellow-900/50 text-yellow-200"),children:[U(),"% smaller"]})]}),(0,r.jsx)("div",{className:"relative aspect-[4/3] bg-gray-800/30 rounded-lg overflow-hidden border border-white/10 flex items-center justify-center",children:o?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(a.ZH,{className:"h-16 w-16 text-cyan-400"}),(0,r.jsxs)("div",{className:"absolute bottom-2 left-2 bg-black/70 px-2 py-1 rounded text-sm",children:["compressed_",e.name]})]}):(0,r.jsx)("div",{className:"flex items-center justify-center h-full text-white/50",children:p?(0,r.jsxs)("div",{className:"flex flex-col items-center",children:[(0,r.jsx)(a.kr,{className:"animate-spin h-8 w-8 text-cyan-400 mb-2"}),(0,r.jsx)("span",{children:"Compressing PDF..."})]}):"Compressed version will appear here"})}),o&&(0,r.jsxs)("div",{className:"text-sm text-white/80 mt-2 space-y-1",children:[(0,r.jsxs)("p",{children:["compressed_",e.name]}),(0,r.jsx)("p",{children:E(m)}),(0,r.jsxs)("p",{children:[U(),"% size reduction"]})]})]})]}),(0,r.jsxs)("div",{className:"mt-6 space-y-6",children:[(0,r.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[(0,r.jsxs)("div",{children:[(0,r.jsxs)("label",{htmlFor:"compression",className:"block text-sm font-medium text-white/80 mb-1",children:["Compression Level: ",(0,r.jsxs)("span",{className:"text-cyan-300",children:[x,"%"]})]}),(0,r.jsx)("input",{type:"range",id:"compression",min:"10",max:"90",value:x,onChange:e=>u(parseInt(e.target.value)),className:"w-full h-2 bg-white/10 rounded-lg appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:h-4 [&::-webkit-slider-thumb]:w-4 [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-cyan-400"}),(0,r.jsxs)("div",{className:"flex justify-between text-xs text-white/60 mt-1",children:[(0,r.jsx)("span",{children:"Less compression"}),(0,r.jsx)("span",{children:"More compression"})]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-sm font-medium text-white/80 mb-1",children:"Compression Presets"}),(0,r.jsx)("div",{className:"grid grid-cols-3 gap-2",children:[{id:"low",label:"Low",level:40},{id:"medium",label:"Medium",level:65},{id:"high",label:"High",level:85}].map(e=>(0,r.jsx)("button",{onClick:()=>u(e.level),className:"py-2 text-sm rounded-lg transition-colors ".concat(x===e.level?"bg-gradient-to-r from-cyan-500 to-purple-500 text-white":"bg-white/5 hover:bg-white/10 text-white/80"),children:e.label},e.id))})]})]}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-3 pt-4",children:[(0,r.jsx)("button",{onClick:L,disabled:p||!e,className:"px-5 py-2.5 border border-transparent roun
1ded-lg text-sm font-medium text-white bg-gradient-to-r from-cyan-500 to-purple-500 hover:from-cyan-600 hover:to-purple-600 focus:outline-none focus:ring-2 focus:ring-cyan-400 focus:ring-offset-2 focus:ring-offset-purple-900/50 shadow-lg shadow-cyan-500/20 disabled:opacity-50 disabled:cursor-not-allowed transition-all cursor-pointer",children:p?(0,r.jsxs)("span",{className:"flex items-center",children:[(0,r.jsx)(a.kr,{className:"animate-spin -ml-1 mr-2 h-4 w-4 text-white"}),"Compressing..."]}):(0,r.jsxs)("span",{className:"flex items-center",children:[(0,r.jsx)(a._I,{className:"w-4 h-4 mr-2"}),"Compress PDF"]})}),o&&(0,r.jsx)("button",{onClick:()=>{if(!o)return;let s=URL.createObjectURL(o),t=document.createElement("a");t.href=s,t.download="compressed_".concat(e.name),document.body.appendChild(t),t.click(),document.body.removeChild(t),URL.revokeObjectURL(s),i.oR.success("Download started")},className:"px-5 py-2.5 border border-transparent rounded-lg text-sm font-medium text-white bg-gradient-to-r from-green-500 to-teal-500 hover:from-green-600 hover:to-teal-600 focus:outline-none focus:ring-2 focus:ring-green-400 focus:ring-offset-2 focus:ring-offset-purple-900/50 shadow-lg shadow-green-500/20 transition-all cursor-pointer",children:(0,r.jsxs)("span",{className:"flex items-center",children:[(0,r.jsx)(a.f5,{className:"w-4 h-4 mr-2"}),"Download"]})}),(0,r.jsx)("button",{onClick:()=>{s(null),d(0),c(null),h(0),j(null),N(null),P(!1),C(0),F.current&&(F.current.value=""),i.oR.info("Reset complete")},className:"px-5 py-2.5 cursor-pointer border border-white/10 rounded-lg text-sm font-medium text-white bg-white/5 hover:bg-white/10 focus:outline-none focus:ring-2 focus:ring-cyan-400 focus:ring-offset-2 focus:ring-offset-purple-900/50 transition-colors",children:(0,r.jsxs)("span",{className:"flex items-center",children:[(0,r.jsx)(a.X,{className:"w-4 h-4 mr-2"}),"Reset All"]})}),w&&(0,r.jsx)("button",{onClick:()=>P(!y),className:"px-5 py-2.5 cursor-pointer border border-white/10 rounded-lg text-sm font-medium text-white bg-white/5 hover:bg-white/10 focus:outline-none focus:ring-2 focus:ring-cyan-400 focus:ring-offset-2 focus:ring-offset-purple-900/50 transition-colors",children:(0,r.jsxs)("span",{className:"flex items-center",children:[(0,r.jsx)(a.kU,{className:"w-4 h-4 mr-2"}),y?"Hide Preview":"Show Preview"]})})]})]}),y&&w&&(0,r.jsxs)("div",{className:"mt-6 border-t border-white/10 pt-6",children:[(0,r.jsx)("h3",{className:"text-lg font-bold text-white mb-4",children:"PDF Preview"}),(0,r.jsx)("div",{className:"bg-black/30 rounded-lg p-4",children:(0,r.jsx)("iframe",{src:w,className:"w-full h-96 rounded border border-white/10",title:"PDF preview"})})]})]}):(0,r.jsxs)("div",{ref:R,onClick:()=>{var e;return null==(e=F.current)?void 0:e.click()},className:"border-2 border-dashed rounded-xl p-8 text-center cursor-pointer transition-all duration-300 ".concat(g?"border-cyan-400 bg-white/10":"border-cyan-400/50 bg-purple-900/10 hover:bg-purple-900/20"),children:[(0,r.jsx)(a._O,{className:"mx-auto h-12 w-12 text-cyan-400"}),(0,r.jsx)("p",{className:"mt-4 text-lg font-medium text-white",children:"Drag & drop a PDF or click to browse"}),(0,r.jsx)("p",{className:"text-sm text-white/60 mt-1",children:"Compress PDF files to reduce their size"}),(0,r.jsx)("input",{ref:F,type:"file",accept:"application/pdf",className:"hidden",onChange:D})]}),(0,r.jsx)("div",{className:"mt-12 border-t border-white/10 pt-8",children:(0,r.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 text-center",children:[(0,r.jsxs)("div",{className:"p-4 bg-white/5 rounded-lg border border-white/10",children:[(0,r.jsx)("p",{className:"text-sm text-white mb-1",children:"Privacy Focused"}),(0,r.jsx)("p",{className:"text-xs text-white/60",children:"All processing happens in your browser"})]}),(0,r.jsxs)("div",{className:"p-4 bg-white/5 rounded-lg border border-white/10",children:[(0,r.jsx)("p",{className:"text-sm text-white mb-1",children:"Quality Control"}),(0,r.jsx)("p",{className:"text-xs text-white/60",children:"Adjustable compression levels"})]}),(0,r.jsxs)("div",{className:"p-4 bg-white/5 rounded-lg border border-white/10",children:[(0,r.jsx)("p",{className:"text-sm text-white mb-1",children:"Instant Results"}),(0,r.jsx)("p",{className:"text-xs text-white/60",children:"See size reduction immediately"})]})]})})]})]})})})}}}]);
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.