PageSourceSearch

https://toolbreezy.com/_next/static/chunks/7703-7fe41cd285f8efac.js

js toolbreezy.com collected 2026-09-24 14:56:40 UTC 40,769 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7703],{7703:(e,t,s)=>{s.r(t),s.d(t,{default:()=>X,parseRange:()=>T});var a=s(95155),r=s(12115),n=s(21786),l=s(35299),i=s(5917),o=s(52056),d=s(90368),c=s(27937),h=s(39867),u=s(65229),m=s(76907),g=s(97003),p=s(70134),f=s(27784),x=s(33789),b=s(90235),w=s(33534),k=s(25016),v=s(31258),y=s(14827),j=s(32319),M=s(2042);let N=72/25.4,$=25.4/72,S=e=>e*N,C=e=>e*$,P=e=>Math.round(10*e)/10,F={mode:"booklet",nup:4,order:"row",sides:"double",signature:0,sheetId:"a4",nupOrient:"auto",binding:"left",rtl:!1,reverse:!1,rangeText:"",blanksAt:"end",blanksAfter:1,marginMm:8,gutterMm:0,foldSafeMm:5,unprintableMm:4,scaleMode:"each",creaseLine:!0,cropMarks:!1,slotBorders:!1,slotNumbers:!1},A=[{id:"a4",label:"A4 (210 x 297 mm)",w:595.28,h:841.89},{id:"a3",label:"A3 (297 x 420 mm)",w:841.89,h:1190.55},{id:"a5",label:"A5 (148 x 210 mm)",w:419.53,h:595.28},{id:"letter",label:"US Letter (8.5 x 11 in)",w:612,h:792},{id:"legal",label:"US Legal (8.5 x 14 in)",w:612,h:1008},{id:"tabloid",label:"Tabloid (11 x 17 in)",w:792,h:1224}],z={2:{c:2,r:1},4:{c:2,r:2},6:{c:3,r:2},8:{c:4,r:2},9:{c:3,r:3},16:{c:4,r:4}},E=[2,4,6,8,9,16];function T(e,t){let s=[],a=new Set;for(let r of e.split(/[,\s]+/).map(e=>e.trim()).filter(e=>e.length>0)){let e=r.match(/^(\d+)\s*-\s*(\d*)$/);if(e){let r=Number.parseInt(e[1]??"",10),n=e[2]??"",l=""===n?null:Number.parseInt(n,10);if(!Number.isFinite(r)||null!==l&&!Number.isFinite(l))continue;let i=(0,j.H)(r,l,t);if(!i)continue;let o=Math.min(i.from,i.to),d=Math.max(i.from,i.to);for(let e=o;e<=d;e++)a.has(e)||(a.add(e),s.push(e));continue}if(/^\d+$/.test(r)){let e=Number.parseInt(r,10);e>=1&&e<=t&&!a.has(e)&&(a.add(e),s.push(e))}}return s}function L(e,t,s,a,r,n){let l=Math.max(1,e-2*r-(s-1)*n)/s,i=Math.max(1,t-2*r-(a-1)*n)/a,o=[];for(let e=0;e<a;e++)for(let a=0;a<s;a++)o.push({x:r+a*(l+n),y:t-r-(e+1)*i-e*n,w:l,h:i});return o}let R=(e,t,s,a)=>Math.min(e/Math.max(1,s),t/Math.max(1,a));function W(e,t,s,a){let r=e.cells[a];if(!r)return null;let n="largest"===t.scaleMode?e.minScale:R(r.w,r.h,s.visW,s.visH),l=s.visW*n,i=s.visH*n;return{rect:{x:r.x+(r.w-l)/2,y:r.y+(r.h-i)/2,w:l,h:i},scale:n}}function H(e){return new Promise((t,s)=>{let a=new FileReader;a.onload=()=>{let e=a.result;e instanceof ArrayBuffer?t(e):s(Error("Could not read that file."))},a.onerror=()=>s(a.error??Error("Could not read that file.")),a.readAsArrayBuffer(e)})}function O(e,t){let s=e.current;e.current=null,t.current=null,s&&s.destroy().catch(()=>void 0)}let D="tb-booklet-last",I="tb-booklet-presets",B=[["mode","mode"],["nup","nup"],["order","ord"],["sides","sides"],["signature","sig"],["sheetId","sheet"],["nupOrient","orient"],["binding","bind"],["rtl","rtl"],["reverse","rev"],["blanksAt","blanks"],["blanksAfter","after"],["marginMm","m"],["gutterMm","g"],["foldSafeMm","fold"],["unprintableMm","unp"],["scaleMode","sc"],["creaseLine","crease"],["cropMarks","marks"],["slotBorders","borders"],["slotNumbers","nums"]];function U(e){let t=new URLSearchParams;for(let[s,a]of B){let r=e[s];r!==F[s]&&t.set(a,"boolean"==typeof r?r?"1":"0":String(r))}return t}function J(e,t){let s=(t,s)=>e.get(t)??s,a=(t,s)=>{let a=e.get(t);return null===a?s:"1"===a||"true"===a},r=(t,s,a,r)=>{let n=e.get(t);if(null===n)return Math.max(a,Math.min(r,s));let l=Number(n);return Number.isFinite(l)?Math.max(a,Math.min(r,l)):Math.max(a,Math.min(r,s))},n=Math.round(r("nup",t.nup,2,16)),l=s("sheet",t.sheetId),i=s("orient",t.nupOrient);return{mode:"nup"===s("mode",t.mode)?"nup":"booklet",nup:E.includes(n)?n:F.nup,order:"column"===s("ord",t.order)?"column":"row",sides:"single"===s("sides",t.sides)?"single":"double",signature:Math.round(r("sig",t.signature,0,64)),sheetId:"double"===l||A.some(e=>e.id===l)?l:"a4",nupOrient:"portrait"===i||"landscape"===i?i:"auto",binding:"top"===s("bind",t.binding)?"top":"left",rtl:a("rtl",t.rtl),reverse:a("rev",t.reverse),rangeText:t.rangeText,blanksAt:"after"===s("blanks",t.blanksAt)?"after":"end",blanksAfter:Math.round(r("after",t.blanksAfter,1,1e4)),marginMm:r("m",t.marginMm,0,50),gutterMm:r("g",t.gutterMm,0,50),foldSafeMm
1:r("fold",t.foldSafeMm,0,50),unprintableMm:r("unp",t.unprintableMm,0,30),scaleMode:"largest"===s("sc",t.scaleMode)?"largest":"each",creaseLine:a("crease",t.creaseLine),cropMarks:a("marks",t.cropMarks),slotBorders:a("borders",t.slotBorders),slotNumbers:a("nums",t.slotNumbers)}}function X(){let[e,t]=(0,r.useState)(F),[j,N]=(0,r.useState)(null),[$,X]=(0,r.useState)(!1),[q,V]=(0,r.useState)(!1),[_,K]=(0,r.useState)(!1),[G,Q]=(0,r.useState)(""),[Z,ee]=(0,r.useState)(""),[et,es]=(0,r.useState)(0),[ea,er]=(0,r.useState)("front"),[en,el]=(0,r.useState)(null),[ei,eo]=(0,r.useState)(null),[ed,ec]=(0,r.useState)([]),[eh,eu]=(0,r.useState)(""),[em,eg]=(0,r.useState)(new Map),[ep,ef]=(0,r.useState)(!1),[ex,eb]=(0,r.useState)(""),[ew,ek]=(0,r.useState)(!1),[ev,ey]=(0,r.useState)(0),ej=(0,r.useRef)(null),eM=(0,r.useRef)(null),eN=(0,r.useRef)(null),e$=(0,r.useRef)(new Map),eS=(0,r.useRef)(new Set),eC=(0,r.useRef)(0),eP=(0,r.useRef)(new Set),eF=(0,r.useRef)(""),eA=(0,r.useRef)(new Set),ez=(0,r.useCallback)(e=>{eA.current.delete(e),URL.revokeObjectURL(e)},[]),eE=(0,r.useCallback)((e,s)=>{t(t=>({...t,[e]:s}))},[]);(0,r.useEffect)(()=>{let e=F;try{let t=window.localStorage.getItem(D);t&&(e=J(new URLSearchParams(t),F));let s=window.localStorage.getItem(I);if(s){let e=JSON.parse(s);if(Array.isArray(e)){let t=[];for(let s of e)if(s&&"object"==typeof s&&"name"in s&&"q"in s){let e=String(s.name).slice(0,40),a=String(s.q);t.push({name:e,cfg:J(new URLSearchParams(a),F)})}ec(t.slice(0,12))}}}catch{}let s=new URLSearchParams(window.location.search),a=!1;for(let[,e]of B)s.has(e)&&(a=!0);t(a?J(s,e):e)},[]),(0,f.Vd)(D,()=>U(e).toString(),[e]),(0,r.useEffect)(()=>{let e=e$.current,t=eA.current;return()=>{e.forEach(e=>URL.revokeObjectURL(e)),e.clear(),t.forEach(e=>URL.revokeObjectURL(e)),t.clear(),O(eN,eM)}},[]),(0,r.useEffect)(()=>{function e(e){let t=e.clipboardData?.files;t&&t.length>0&&eU(t)}return window.addEventListener("paste",e),()=>window.removeEventListener("paste",e)},[]);let eT=(0,r.useMemo)(()=>{if(!j)return null;let e=new Map;for(let t of j.geoms){let s=`${t.visW.toFixed(1)}x${t.visH.toFixed(1)}`,a=e.get(s);a?a.n++:e.set(s,{n:1,g:t})}let t=null;for(let s of e.values())(!t||s.n>t.n)&&(t=s);return t?t.g:null},[j]),eL=(0,r.useMemo)(()=>j?function(e,t,s){let a,r,n,l,i;if(0===t.length||!s)return null;let o=t.map(e=>e.page),d=e.rangeText.trim()?T(e.rangeText,t.length):o;if(0===d.length)return null;let c=e.reverse?[...d].reverse():d,h=S(Math.max(0,e.marginMm)),u=S(Math.max(0,e.gutterMm));if("booklet"===e.mode){if("double"===e.sheetId)a=2*s.visW,r=s.visH;else{let t=A.find(t=>t.id===e.sheetId)??A[0];if(!t)return null;a=Math.max(t.w,t.h),r=Math.min(t.w,t.h)}n=2,l=1,i=2}else{let t=z[e.nup]??{c:2,r:2},o=A.find(t=>t.id===e.sheetId)??A[0];if(!o)return null;let d=[];"landscape"!==e.nupOrient&&d.push({w:o.w,h:o.h,name:"portrait"}),"portrait"!==e.nupOrient&&d.push({w:o.h,h:o.w,name:"landscape"});let c=t.c===t.r?[t]:[t,{c:t.r,r:t.c}],m=null;for(let e of d)for(let t of c){let a=L(e.w,e.h,t.c,t.r,h,u)[0];if(!a)continue;let r=R(a.w,a.h,s.visW,s.visH);(!m||r>m.s)&&(m={w:e.w,h:e.h,c:t.c,r:t.r,s:r})}if(!m)return null;a=m.w,r=m.h,n=m.c,l=m.r,i=n*l}let m=L(a,r,n,l,h,u),g=m[0];if(!g)return null;let p="booklet"===e.mode?4:i*("double"===e.sides?2:1),f=Math.ceil(c.length/p)*p-c.length,x=c.slice();if(f>0){let t=x.length;if("after"===e.blanksAt){let s=x.indexOf(e.blanksAfter);s>=0&&(t=s+1)}x.splice(t,0,...Array.from({length:f},()=>null))}let b=[];if("booklet"===e.mode){let t=e.signature>0?4*e.signature:x.length,s=0,a=1;for(;s<x.length;){let r=Math.min(t,x.length-s);for(let t=0;t<r/4;t++){let n=e=>{let t=x[s+e-1];return void 0===t?null:t},l=n(r-2*t),i=n(2*t+1),o=n(2*t+2),d=n(r-2*t-1);b.push(e.rtl?{front:[i,l],back:[d,o],signature:a}:{front:[l,i],back:[o,d],signature:a})}s+=r,a++}}else{let t=t=>{let s=Array(i).fill(null);for(let a=0;a<i;a++){let r=x[t+a],o=void 0===r?null:r,d="row"===e.order?a:a%l*n+Math.floor(a/l);if(e.rtl){let e=Math.floor(d/n),t=d%n;d=e*n+(n-1-t)}d>=0&&d<i&&(s[d]=o)}return s};for(let s=0;s*p<x.length;s++){let a=s*p;b.push({front:t(a),back:"double"===e.sides?t(a+i):Array(i).fill(null),signature:1})}}let w=[];b.forEach((t,s)=>{["front","back"].forEach(a=>
1{("front"===a?t.front:t.back).forEach((t,r)=>{null===t&&("nup"!==e.mode||"single"!==e.sides||"back"!==a)&&w.push({sheet:s+1,side:a,slot:r})})})});let k=R(g.w,g.h,s.visW,s.visH),v=1/0,y=0,j=new Set(c);for(let e of t){if(!j.has(e.page))continue;let t=R(g.w,g.h,e.visW,e.visH);v=Math.min(v,t),y=Math.max(y,t)}Number.isFinite(v)||(v=k),0===y&&(y=k);let M="booklet"===e.mode||"left"===e.binding,N=M?r:a,{duplex:$,why:F}=function(e,t,s,a){if("single"===s)return{duplex:"single",why:"Only one side of each sheet is used, so there is no duplex setting to get wrong."};let r=e>=t,n=`${a} runs along the sheet's ${r?"long":"short"} edge (${P(C(e))} mm against ${P(C(t))} mm), and the flip has to turn about an axis parallel to it, so this print is ${r?"long":"short"} edge.`;return{duplex:r?"long":"short",why:n}}(N,M?a:r,"booklet"===e.mode?"double":e.sides,"booklet"===e.mode?"The fold":"The edge you staple"),E=m[1],W="booklet"===e.mode&&E?(g.x+g.w+E.x)/2:null;return{sheetW:a,sheetH:r,cols:n,rows:l,perSide:i,cells:m,sheets:b,seq:x,pad:f,blanks:w,signatures:"booklet"===e.mode?Math.max(...b.map(e=>e.signature),1):1,duplex:$,duplexWhy:F,bindingEdgeLen:N,refScale:k,minScale:v,maxScale:y,foldX:W,usedPages:c}}(e,j.geoms,eT):null,[e,j,eT]),eR=(0,r.useMemo)(()=>{let e=new Map;if(j)for(let t of j.geoms)e.set(t.page,t);return e},[j]),eW=(0,r.useMemo)(()=>{let e=new Map;return eL&&eL.sheets.forEach((t,s)=>{["front","back"].forEach(a=>{("front"===a?t.front:t.back).forEach((t,r)=>{"number"==typeof t&&e.set(t,{sheet:s+1,side:a,slot:r})})})}),e},[eL]),eH=(0,r.useMemo)(()=>{if(!eL||!j)return[];let t=[],s=S(e.foldSafeMm),a=S(e.unprintableMm);for(let[n,l]of em){var r;if(l.empty)continue;let i=eR.get(n),o=eW.get(n);if(!i||!o)continue;let d=W(eL,e,i,o.slot);if(!d)continue;let c=d.scale,h=(r=o.slot,null===eL.foldX?null:0===r?"right":"left");if(h){let e="left"===h?l.left:"right"===h?l.right:"top"===h?l.top:l.bottom,a=e*c;a<s&&t.push({kind:"fold",page:n,sheet:o.sheet,side:o.side,text:`Page ${n} has ink ${P(C(a))} mm from the fold on sheet ${o.sheet} (${P(C(e))} mm on the original, printed at ${Math.round(100*c)}%).`})}let u=d.rect.x+l.left*c,m=eL.sheetW-(d.rect.x+d.rect.w-l.right*c),g=Math.min(u,m,d.rect.y+l.bottom*c,eL.sheetH-(d.rect.y+d.rect.h-l.top*c));g<a&&t.push({kind:"edge",page:n,sheet:o.sheet,side:o.side,text:`Page ${n} puts ink ${P(C(g))} mm from the paper's edge on sheet ${o.sheet}, inside the ${e.unprintableMm} mm your printer cannot reach.`})}return t.sort((e,t)=>e.page-t.page),t},[eL,j,em,e,eR,eW]),eO=(0,r.useMemo)(()=>{if(!eL)return{checked:0,total:0,missed:0};let e=0;for(let t of eL.usedPages)em.has(t)&&e++;return{checked:e,total:eL.usedPages.length,missed:eL.usedPages.length-e}},[eL,em]),eD=eH.length>0?"flagged":0===eO.checked?"unmeasured":eO.missed>0?"partial":"clean",eI=(0,r.useMemo)(()=>{let{checked:e,total:t,missed:s}=eO;return"flagged"===eD?{tone:"bg-amber-500/15 text-amber-700 dark:text-amber-400",icon:"warn",text:`${eH.length} thing${1===eH.length?"":"s"} to look at before you print`+(s>0?`, out of the ${e} of ${t} pages measured so far`:"")}:"partial"===eD?{tone:"bg-muted text-muted-foreground",icon:"warn",text:`Nothing flagged on the ${e} page${1===e?"":"s"} measured, and ${s} of the ${t} in this layout ${1===s?"was":"were"} not measured at all`}:"clean"===eD?{tone:"bg-emerald-500/15 text-emerald-700 dark:text-emerald-400",icon:"ok",text:"Nothing flagged on this layout"}:{tone:"bg-muted text-muted-foreground",icon:"wait",text:ep?"Measuring your pages":"Your pages have not been measured, so nothing has been checked yet"}},[eD,eO,eH.length,ep]),eB=(0,r.useMemo)(()=>j?`${j.name}|${j.size}|${j.pageCount}|${U(e).toString()}|r=${e.rangeText}`:"none",[j,e]);async function eU(e){if(!e||0===e.length)return;let t=e.item(0);if(!t)return;if(!("application/pdf"===t.type||t.name.toLowerCase().endsWith(".pdf")))return void Q("That is not a PDF. Choose a file ending in .pdf.");if(t.size>0x6400000)return void Q(`That file is ${(0,v.z)(t.size)}, over the 100 MB limit. Imposition holds every page in memory at once, so a bigger file would run your browser out of room. Split it first and do it in parts.`);let a=++eC.current;Q(""),ee(""),V(!0),eg(new Map),ek(!1),eP.current.clear(),eF.current="",e$.current.forEach(e
1=>URL.revokeObjectURL(e)),e$.current.clear(),eS.current.clear(),O(eN,eM),N(null);try{let e,{PDFDocument:r,PDFName:n,PDFDict:l,PDFNumber:i}=await s.e(57814).then(s.bind(s,57814)),o=await H(t);try{e=await r.load(o)}catch(t){let e=t instanceof Error?t.message:"";if(/encrypt/i.test(e))throw Error("This PDF is password-protected, so its pages cannot be rearranged. Take the password off first with the PDF Password Remover, then impose the unlocked copy.");throw Error("Could not open this PDF. It may be damaged or not really a PDF.")}let d=e.getPages();if(0===d.length)throw Error("That PDF has no pages in it.");if(d.length>500)throw Error(`That PDF has ${d.length} pages and the limit here is 500. Split it into parts and impose each part as its own booklet.`);let c=0,h=[],u=d.map((e,t)=>{let s=e.getCropBox(),a=e.getMediaBox(),r=!!e.node.CropBox();r||h.push(t+1);let n=r?s:a,l=function(e){let t=(e%360+360)%360;return 90===t||180===t||270===t?t:0}(e.getRotation().angle),i=90===l||270===l,o=Math.max(1,n.width),d=Math.max(1,n.height),u=e.node.Annots();return u&&(c+=u.size()),{page:t+1,boxX:n.x,boxY:n.y,boxW:o,boxH:d,rot:l,visW:i?d:o,visH:i?o:d,hasCrop:r}}),m=0;try{m=e.getForm().getFields().length}catch{m=0}let g=0;try{let t=e.catalog.lookupMaybe(n.of("Outlines"),l),s=t?.lookupMaybe(n.of("Count"),i);g=s?Math.abs(s.asNumber()):+!!t}catch{g=0}let p=new Set(u.map(e=>`${e.visW.toFixed(1)}x${e.visH.toFixed(1)}`));if(eC.current!==a)return;N({file:t,name:t.name,size:t.size,pageCount:d.length,geoms:u,annots:c,fields:m,outline:g,mixed:p.size>1,noCrop:h});try{let e=await Promise.all([s.e(52084),s.e(15376)]).then(s.bind(s,20426));e.GlobalWorkerOptions.workerSrc=new s.U(s(15373)).toString();let r=e.getDocument({data:await t.arrayBuffer()}),n=await r.promise;if(eC.current!==a)return void r.destroy().catch(()=>void 0);eN.current=r,eM.current=n,ek(!0)}catch{eC.current===a&&ee("The page pictures could not be drawn in this browser, so the preview squares are empty and the ink measurement was skipped. The page order, the blanks and the duplex setting below are all still correct.")}}catch(e){if(eC.current!==a)return;N(null),Q((0,M.oh)(e,e instanceof Error?e.message:"Could not open this PDF."))}finally{eC.current===a&&V(!1)}}async function eJ(e,t){let s=eM.current;if(!s)return;let a=t.slice(0,80);if(0===a.length)return;ef(!0);let r=new Map;try{for(let t=0;t<a.length;t++){let n=a[t];if(void 0!==n){if(eC.current!==e)return;eb(`Measuring page ${n}, ${t+1} of ${a.length}`),eP.current.add(n);try{let e=await s.getPage(n),t=e.getViewport({scale:1}),a=Math.min(2,520/Math.max(1,t.width,t.height)),l=e.getViewport({scale:a}),i=(0,p.$t)(Math.max(1,Math.floor(l.width)),Math.max(1,Math.floor(l.height)),{willReadFrequently:!0});if(!i)break;let{canvas:o,ctx:d}=i;d.fillStyle="#ffffff",d.fillRect(0,0,o.width,o.height),await e.render({canvasContext:d,viewport:l,canvas:o}).promise;let c=d.getImageData(0,0,o.width,o.height).data,h=o.width,u=o.height,m=-1,g=-1;for(let e=0;e<o.height;e++){let t=e*o.width*4;for(let s=0;s<o.width;s++){let a=t+4*s,r=c[a]??255,n=c[a+1]??255,l=c[a+2]??255;(r<244||n<244||l<244)&&(s<h&&(h=s),s>m&&(m=s),e<u&&(u=e),e>g&&(g=e))}}m<0?r.set(n,{left:0,right:0,top:0,bottom:0,empty:!0}):r.set(n,{left:h/a,right:(o.width-1-m)/a,top:u/a,bottom:(o.height-1-g)/a,empty:!1})}catch{}}}if(eC.current!==e)return;eg(e=>{let t=new Map(e);return r.forEach((e,s)=>t.set(s,e)),t})}finally{eC.current===e&&(ef(!1),eb(""))}}(0,r.useEffect)(()=>{el(e=>(e&&ez(e.url),null)),eo(e=>(e&&ez(e.url),null))},[eB,ez]),(0,r.useEffect)(()=>{es(0),er("front")},[eB]),(0,r.useEffect)(()=>{if(!ew||!eL||ep)return;let t=`${eC.current}|${e.rangeText.trim()}|${eL.usedPages.length}`;if(eF.current===t)return;eF.current=t;let s=eL.usedPages.filter(e=>!eP.current.has(e));0!==s.length&&eJ(eC.current,s)},[ew,eL,ep,e.rangeText]);let eX=(0,r.useCallback)(e=>{let t=eM.current;if(!t||e$.current.has(e)||eS.current.has(e))return;eS.current.add(e);let s=eC.current;(async()=>{try{let a=await t.getPage(e),r=a.getViewport({scale:1}),n=Math.min(1.5,220/Math.max(1,r.width,r.height)),l=a.getViewport({scale:n}),i=(0,p.$t)(Math.max(1,Math.floor(l.width)),Math.max(1,Math.floor(l.height)));if(!i)return;let{canvas:o,ctx:d}=i;d.fillStyle="#ffffff",d.fillRect(0,0,o.width,o.height),await a.render({canvasContext:d,viewport:l,canvas:o}).promise;let c=await new Promise(e=>o.toBlob(t=>e(t),"image/jpeg",.7));if(!c||eC.current!==s)return;let h=URL.createObjectURL(c);e$.current.set(e,h),ey(e=>e+1)}catch{}finally{eS.current.delete(e)}})()},[]),eY=eL?eL.sheets[Math.min(et,eL.sheets.length-1)]:void 0,eq=(0,r.useMemo)(()=>eY?"front"===ea?eY.front:eY.back:[],[eY,ea]);async function eV(t){if(j&&eL){K(!0),Q("");try{let{PDFDocument:a,StandardFonts:r,degrees:n,rgb:l}=await s.e(57814).then(s.bind(s,57814)),i=await a.create(),o=t?eL.sheets.slice(0,1):eL.sheets,d="nup"===e.mode&&"single"===e.sides?["front"]:["front","back"];
1if(t){let e=await i.embedFont(r.Helvetica),t=await i.embedFont(r.HelveticaBold),s=o[0];if(!s)throw Error("There is nothing to build a test sheet from.");for(let a of d){let r=i.addPage([eL.sheetW,eL.sheetH]),n="front"===a?s.front:s.back;for(let s=0;s<eL.perSide;s++){let a=eL.cells[s],i=n[s];if(!a||void 0===i)continue;r.drawRectangle({x:a.x,y:a.y,width:a.w,height:a.h,borderColor:l(.75,.75,.75),borderWidth:.75});let o=null===i?"BLANK":String(i),d=Math.min(a.w,a.h)*(null===i?.16:.36),c=null===i?e:t,h=c.widthOfTextAtSize(o,d);r.drawText(o,{x:a.x+(a.w-h)/2,y:a.y+(a.h-.72*d)/2,size:d,font:c,color:null===i?l(.62,.62,.62):l(.1,.1,.1)})}null!==eL.foldX&&r.drawLine({start:{x:eL.foldX,y:6},end:{x:eL.foldX,y:eL.sheetH-6},thickness:.6,dashArray:[4,4],color:l(.6,.6,.6)});let o=`TEST SHEET, ${a} side. ${Y(eL.duplex)} `+(null!==eL.foldX?"Fold once down the dashed line. ":"")+"The numbers are your original pages. Made with ToolBreezy.";r.drawText(o,{x:12,y:8,size:7,font:e,color:l(.45,.45,.45)})}}else{let t,s=e.slotNumbers?await i.embedFont(r.Helvetica):null,c=await H(j.file),h=(await a.load(c)).getPages(),u=eL.usedPages,m=[],g=[];for(let e of u){let t=h[e-1],s=eR.get(e);if(!t||!s)throw Error(`Page ${e} could not be read out of this PDF.`);m.push(t),g.push({left:s.boxX,bottom:s.boxY,right:s.boxX+s.boxW,top:s.boxY+s.boxH})}try{t=await i.embedPages(m,g)}catch{throw Error("At least one page could not be copied across, so nothing was written. A page like that would have come out silently blank, which is worse than an error.")}let p=new Map;for(let a of(u.forEach((e,s)=>{let a=t[s];a&&p.set(e,a)}),o))for(let t of d){let r=i.addPage([eL.sheetW,eL.sheetH]),o="front"===t?a.front:a.back;for(let t=0;t<eL.perSide;t++){let a=eL.cells[t],i=o[t];if(!a||void 0===i||(e.slotBorders&&r.drawRectangle({x:a.x,y:a.y,width:a.w,height:a.h,borderColor:l(.8,.8,.8),borderWidth:.5}),null===i))continue;let d=eR.get(i),c=p.get(i);if(!d||!c)continue;let h=W(eL,e,d,t);if(!h)continue;let u=h.scale,m=h.rect.x,g=h.rect.y,f=90===d.rot?{x:m,y:g+d.boxW*u,rotate:n(-90)}:180===d.rot?{x:m+d.boxW*u,y:g+d.boxH*u,rotate:n(180)}:270===d.rot?{x:m+d.boxH*u,y:g,rotate:n(90)}:{x:m,y:g,rotate:n(0)};r.drawPage(c,{...f,xScale:u,yScale:u}),s&&r.drawText(String(i),{x:a.x+4,y:a.y+4,size:7,font:s,color:l(.55,.55,.55)})}if(e.creaseLine&&null!==eL.foldX&&r.drawLine({start:{x:eL.foldX,y:4},end:{x:eL.foldX,y:eL.sheetH-4},thickness:.4,dashArray:[3,5],color:l(.78,.78,.78)}),e.cropMarks){let t=S(Math.max(0,e.marginMm)),s=Math.min(14,Math.max(6,t));for(let[e,a,n,i]of[[0,eL.sheetH-t,s,eL.sheetH-t],[t,eL.sheetH,t,eL.sheetH-s],[eL.sheetW,eL.sheetH-t,eL.sheetW-s,eL.sheetH-t],[eL.sheetW-t,eL.sheetH,eL.sheetW-t,eL.sheetH-s],[0,t,s,t],[t,0,t,s],[eL.sheetW,t,eL.sheetW-s,t],[eL.sheetW-t,0,eL.sheetW-t,s]])r.drawLine({start:{x:e,y:a},end:{x:n,y:i},thickness:.4,color:l(.5,.5,.5)})}}}let c=await i.save({useObjectStreams:!0}),h=c.buffer.slice(c.byteOffset,c.byteOffset+c.byteLength),u=new Blob([h],{type:"application/pdf"}),m=URL.createObjectURL(u);eA.current.add(m);let g=j.name.replace(/\.pdf$/i,""),p={url:m,name:t?`${g}-test-sheet.pdf`:`${g}-${"booklet"===e.mode?"booklet":`${e.nup}up`}.pdf`,stamp:eB,sheets:o.length};t?eo(e=>(e&&ez(e.url),p)):el(e=>(e&&ez(e.url),p))}catch(e){Q(e instanceof Error?e.message:"Could not build the imposed PDF.")}finally{K(!1)}}}function e_(e){(0,y.Is)(e.url,e.name)}(0,r.useEffect)(()=>{for(let e of eq)"number"==typeof e&&eX(e)},[eq,eX]);let eK=(0,r.useCallback)(()=>U(e),[e]),eG="flex h-9 w-full rounded-md border border-input bg-background px-3 py-1 text-sm shadow-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50",eQ=eL&&j?function(e,t,s){let a=e.usedPages.length,r=[];return r.push(`${a} page${1===a?"":"s"}`),r.push(0===e.pad?"no padding needed":`${e.pad} blank${1===e.pad?"":"s"} added`),r.push(`${e.sheets.length} sheet${1===e.sheets.length?"":"s"}`),"booklet"===t.mode?r.push(e.signatures>1?`folded in ${e.signatures} signatures`:"folded once through the middle"):r.push(`${t.nup} pages on each side, ${e.cols} across and ${e.rows} down on a ${e.sheetW>e.sheetH?"landscape":"portrait"} sheet`),r.push(Y(e.duplex).replace(/\.$/,"").toLowerCase()),r.push(`text prints at ${Math.round(("largest"===t.scaleMode?e.minScale:e.refScale)*100)}%`),`${s.name}: ${r.join(", ")}.`}(eL,e,j):"";return(0,a.jsxs)("div",{className:"space-y-5",children:[(0,a.jsxs)("div",{role:"button",tabIndex:0,onClick:()=>ej.current?.click(),onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&ej.current?.click()},onDragOver:e=>{e.preventDefault(),X(!0)},onDragLeave:()=>X(!1),onDrop:e=>{e.preventDefault(),X(!1),eU(e.dataTransfer.files)},className:(0,k.cn)("flex cursor-pointer flex-col items-center justify-center gap-1.5 rounded-lg border-2 border-dashed p-8 text-center transition-colors",$?"border-primary bg-primary/5":"border-input hover:border-primary/50"),children:[(0,a.jsx)(n.A,{className:"size-6 text-muted-foreground"}),(0,a.jsx)("p",{className:"text-sm font-medium",children:j?j.name:"Click to choose a PDF, or drag one into the box"}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:j?`${j.pageCount} pages, ${(0,v.z)(j.size)}`:"You can paste one too. Up to 500 pages and 100 MB, and it never leaves your device."}),(0,a.jsx)("input",{ref:ej,type:"file",accept:"application/pdf,.pdf",className:"hidden",onChange:e=>{eU(e.target.files),ej.current&&(ej.current.value="")}})]}),q&&(0,a.jsxs)("p",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,a.jsx)(l.A,{className:"size-4 animate-spin"})," Reading the PDF"]}),G&&(0,a.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:G}),Z&&(0,a.jsx)("p",{role:"status",className:"text-sm text-amber-600 dar
1k:text-amber-400",children:Z}),j&&!eL&&(0,a.jsxs)("p",{role:"status",className:"text-sm text-amber-600 dark:text-amber-400",children:["None of the pages you typed exist in this file. Type at least one page between 1 and"," ",j.pageCount,", like 2, 4, 6-8, or clear the box to use every page."]}),j&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"rounded-lg border p-4",children:[(0,a.jsxs)("div",{className:"mb-3 flex flex-wrap gap-2",children:[(0,a.jsx)(g.$,{size:"sm",variant:"booklet"===e.mode?"default":"outline",onClick:()=>{t(e=>({...e,mode:"booklet"}))},children:"Fold into a booklet"}),(0,a.jsx)(g.$,{size:"sm",variant:"nup"===e.mode?"default":"outline",onClick:()=>t(e=>({...e,mode:"nup",sheetId:"double"===e.sheetId?"a4":e.sheetId})),children:"Several pages per sheet"})]}),(0,a.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:[(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)(b.J,{htmlFor:"bk-sheet",children:"Sheet you are printing on"}),(0,a.jsxs)("select",{id:"bk-sheet",className:eG,value:e.sheetId,onChange:e=>eE("sheetId",e.target.value),children:[A.map(e=>(0,a.jsx)("option",{value:e.id,children:e.label},e.id)),"booklet"===e.mode&&(0,a.jsx)("option",{value:"double",children:"Twice my page size (prints at 100%)"})]})]}),"booklet"===e.mode?(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)(b.J,{htmlFor:"bk-sig",children:"Sheets folded together"}),(0,a.jsxs)("select",{id:"bk-sig",className:eG,value:String(e.signature),onChange:e=>eE("signature",Number(e.target.value)),children:[(0,a.jsx)("option",{value:"0",children:"All of them, one fold"}),(0,a.jsx)("option",{value:"2",children:"2 sheets per signature"}),(0,a.jsx)("option",{value:"4",children:"4 sheets per signature"}),(0,a.jsx)("option",{value:"5",children:"5 sheets per signature"}),(0,a.jsx)("option",{value:"8",children:"8 sheets per signature"})]})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)(b.J,{htmlFor:"bk-nup",children:"Pages per sheet side"}),(0,a.jsx)("select",{id:"bk-nup",className:eG,value:String(e.nup),onChange:e=>eE("nup",Number(e.target.value)),children:E.map(e=>(0,a.jsxs)("option",{value:e,children:[e," up"]},e))})]}),(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)(b.J,{htmlFor:"bk-bind",children:"Edge you will staple"}),(0,a.jsxs)("select",{id:"bk-bind",className:eG,value:e.binding,onChange:e=>eE("binding","top"===e.target.value?"top":"left"),children:[(0,a.jsx)("option",{value:"left",children:"Left, read like a book"}),(0,a.jsx)("option",{value:"top",children:"Top, flip like a notepad"})]})]}),(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)(b.J,{htmlFor:"bk-sides",children:"Sides"}),(0,a.jsxs)("select",{id:"bk-sides",className:eG,value:e.sides,onChange:e=>eE("sides","single"===e.target.value?"single":"double"),children:[(0,a.jsx)("option",{value:"double",children:"Print both sides"}),(0,a.jsx)("option",{value:"single",children:"One side only"})]})]}),(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)(b.J,{htmlFor:"bk-orient",children:"Sheet orientation"}),(0,a.jsxs)("select",{id:"bk-orient",className:eG,value:e.nupOrient,onChange:e=>{let t=e.target.value;eE("nupOrient","portrait"===t||"landscape"===t?t:"auto")},children:[(0,a.jsx)("option",{value:"auto",children:"Whichever shrinks my pages least"}),(0,a.jsx)("option",{value:"portrait",children:"Portrait"}),(0,a.jsx)("option",{value:"landscape",children:"Landscape"})]})]}),(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)(b.J,{htmlFor:"bk-order",children:"Reading order"}),(0,a.jsxs)("select",{id:"bk-order",className:eG,value:e.order,onChange:e=>eE("order","column"===e.target.value?"column":"row"),children:[(0,a.jsx)("option",{value:"row",children:"Across, then down"}),(0,a.jsx)("option",{value:"column",children:"Down, then across"})]})]})]}),(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)(b.J,{htmlFor:"bk-margin",children:"Outer margin (mm)"}),(0,a.jsx)(x.p,{id:"bk-margin",type:"number",min:0,max:50,value:e.marginMm,onChange:e=>eE("marginMm",Math.max(0,Math.min(50,Number(e.target.value)||0)))})]}),(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)(b.J,{htmlFor:"bk-gutter",children:"booklet"===e.mode?"Extra space at the fold (mm)":"Space between slots (mm)"}),(0,a.jsx)(x.p,{id:"bk-gutter",type:"number",min:0,max:50,value:e.gutterMm,onChange:e=>eE("gutterMm",Math.max(0,Math.min(50,Number(e.target.value)||0)))})]}),(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)(b.J,{htmlFor:"bk-range",children:"Pages to use (blank means all)"}),(0,a.jsx)(x.p,{id:"bk-range",value:e.rangeText,placeholder:`1-${j.pageCount}`,onChange:e=>eE("rangeText",e.target.value)})]}),(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)(b.J,{htmlFor:"bk-blanks",children:"Padding blanks go"}),(0,a.jsxs)("select",{id:"bk-blanks",className:eG,value:e.blanksAt,onChange:e=>eE("blanksAt","after"===e.target.value?"after":"end"),children:[(0,a.jsx)("option",{value:"end",children:"At the end"}),(0,a.jsx)("option",{value:"after",children:"Straight after a page I pick"})]})]}),"after"===e.blanksAt&&(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)(b.J,{htmlFor:"bk-after",children:"Put them after page"}),(0,a.jsx)(x.p,{id:"bk-after",type:"number",min:1,max:j.pageCount,value:e.blanksAfter,onChange:e=>eE("blanksAfter",Math.max(1,Math.min(j.pageCount,Number(e.target.value)||1)))})]}),(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)(b.J,{htmlFor:"bk-fold",children:"Keep ink this far from the fold (mm)"}),(0,a.jsx)(x.p,{id:"bk-fold",type:"number",min:0,max:50,value:e.foldSafeMm,onChange:e=>eE("foldSafeMm",Math.max(0,Math.min(50,Number(e.target.value)||0)))})]}),(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)(b.J,{htmlFor:"bk-unp",children:"Your printer's unprintable edge (mm)"}),(0,a.jsx)(x.p,{id:"bk-unp",type:"number",min:0,max:30,value:e.unprintableMm,onChange:e=>eE("unprintableMm",Math.max(0,Math.min(30,Number(e.target.value)||0)))})]}),j.mixed&&(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)(b.J,{htmlFor:"bk-scale",children:"Mixed page sizes"}),(0,a.jsxs)("select",{id:"bk-scale",className:eG,value:e.scaleMode,onChange:e=>eE("scaleMode","largest"===e.target.value?"largest":"each"),children:[(0,a.jsx)("option",{value:"each",children:"Fit each page to its own slot"}),(0,a.jsx)("option",{value:"largest",children:"Scale everything by the biggest page"})]})]})]}),(0,a.jsxs)("p",{className:"mt-2 text-xs text-muted-foreground",children:["The fold clearance and the unprintable edge start at ",F.foldSafeMm," mm and"," ",F.unprintableMm," mm. Those are defaults we picked, not measurements of your printer or your paper, so change them to what you know."]}),(0,a.jsxs)("div",{className:"mt-3 flex flex-wrap gap-x-5 gap-y-2 text-sm",children:[(0,a.jsxs)("label",{className:"flex items-center gap-2",children:[(0,a.jsx)("input",{type:"checkbox",className:"size-4",checked:e.rtl,onChange:e=>eE("rtl",e.target.checked)}),"Right to left binding"]}),(0,a.jsxs)("label",{className:"flex items-center gap-2",children:[(0,a.jsx)("input",{type:"checkbox",className:"size-4",checked:e.reverse,onChange:e=>eE("reverse",e.target.checked)}),"Pages are in reverse order"]}
1),"booklet"===e.mode&&(0,a.jsxs)("label",{className:"flex items-center gap-2",children:[(0,a.jsx)("input",{type:"checkbox",className:"size-4",checked:e.creaseLine,onChange:e=>eE("creaseLine",e.target.checked)}),"Dotted fold line"]}),(0,a.jsxs)("label",{className:"flex items-center gap-2",children:[(0,a.jsx)("input",{type:"checkbox",className:"size-4",checked:e.cropMarks,onChange:e=>eE("cropMarks",e.target.checked)}),"Crop marks"]}),(0,a.jsxs)("label",{className:"flex items-center gap-2",children:[(0,a.jsx)("input",{type:"checkbox",className:"size-4",checked:e.slotBorders,onChange:e=>eE("slotBorders",e.target.checked)}),"Outline each slot"]}),(0,a.jsxs)("label",{className:"flex items-center gap-2",children:[(0,a.jsx)("input",{type:"checkbox",className:"size-4",checked:e.slotNumbers,onChange:e=>eE("slotNumbers",e.target.checked)}),"Print the original page number in each corner"]})]})]}),eL&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"space-y-3 rounded-lg border p-4",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,a.jsxs)("span",{className:(0,k.cn)("inline-flex items-center gap-1.5 rounded px-2 py-0.5 text-sm font-medium",eI.tone),children:["ok"===eI.icon?(0,a.jsx)(i.A,{className:"size-4"}):"warn"===eI.icon?(0,a.jsx)(o.A,{className:"size-4"}):(0,a.jsx)(l.A,{className:(0,k.cn)("size-4",ep&&"animate-spin")}),eI.text]}),ep&&(0,a.jsxs)("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,a.jsx)(l.A,{className:"size-3.5 animate-spin"}),ex]})]}),(0,a.jsx)("p",{className:"text-sm",children:eQ}),(0,a.jsxs)("ul",{className:"space-y-1 text-sm text-muted-foreground",children:[(0,a.jsxs)("li",{children:[(0,a.jsx)("strong",{className:"text-foreground",children:"Duplex:"})," ",Y(eL.duplex)," ",eL.duplexWhy]}),(0,a.jsxs)("li",{children:[(0,a.jsx)("strong",{className:"text-foreground",children:"Scale:"})," your text prints at"," ",Math.round(("largest"===e.scaleMode?eL.minScale:eL.refScale)*100),"% of its original size",j.mixed&&"each"===e.scaleMode?`, and because this file mixes page sizes the pages range from ${Math.round(100*eL.minScale)}% to ${Math.round(100*eL.maxScale)}%`:"","."]}),(0,a.jsxs)("li",{children:[(0,a.jsx)("strong",{className:"text-foreground",children:"Blanks:"})," ",0===eL.pad?"none needed, your page count already divides evenly.":`${eL.pad} added. `+eL.blanks.map(e=>`sheet ${e.sheet} ${e.side} ${function(e,t){if(null!==e.foldX)return 0===t?"left half":"right half";let s=t%e.cols,a=Math.floor(t/e.cols);return`row ${a+1} column ${s+1}`}(eL,e.slot)}`).join(", ")+"."]}),(0,a.jsxs)("li",{children:[(0,a.jsx)("strong",{className:"text-foreground",children:"Ink measured on:"})," ",0===eO.checked?`none of the ${eO.total} page${1===eO.total?"":"s"} in this layout yet, so nothing above is a check on them.`:`${eO.checked} of the ${eO.total} page${1===eO.total?"":"s"} in this layout, to about half a millimeter.`+(eO.missed>0?` The other ${eO.missed} went unmeasured${eO.total>80?", since one pass covers 80 pages":""}, so nothing above is a check on them.`:"")]}),j.annots+j.fields+j.outline>0&&(0,a.jsxs)("li",{className:"text-amber-700 dark:text-amber-400",children:[(0,a.jsx)("strong",{children:"Will be dropped:"})," this file carries ",j.annots," annotation",1===j.annots?"":"s"," and ",j.fields," form field",1===j.fields?"":"s",". Copying a page onto a sheet copies what is drawn on it, not the links, comments, highlights or fields sitting on top.",j.outline>0?` The bookmark outline goes too, and this file has ${j.outline} ${1===j.outline?"entry":"entries"} in it.`:""]}),j.noCrop.length>0&&j.noCrop.length<j.pageCount&&(0,a.jsxs)("li",{children:[(0,a.jsx)("strong",{className:"text-foreground",children:"Page boxes:"})," ",j.noCrop.length," page",1===j.noCrop.length?"":"s"," carry no crop box, so their full media box was used instead."]})]}),eH.length>0&&(0,a.jsxs)("ul",{className:"space-y-1 rounded border border-amber-500/40 bg-amber-500/5 p-3 text-sm",children:[eH.slice(0,12).map(e=>(0,a.jsx)("li",{children:e.text},`${e.kind}-${e.page}`)),eH.length>12&&(0,a.jsxs)("li",{className:"text-muted-foreground",children:["and ",eH.length-12," more like it."]})]})]}),(0,a.jsxs)("div",{className:"space-y-2 rounded-lg border p-4",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[(0,a.jsx)(g.$,{size:"sm",variant:"outline",onClick:()=>es(e=>Math.max(0,e-1)),disabled:et<=0,"aria-label":"Previous sheet",children:(0,a.jsx)(d.A,{className:"size-4"})}),(0,a.jsxs)("span",{className:"px-1 text-sm",children:["Sheet ",Math.min(et+1,eL.sheets.length)," of ",eL.sheets.length,eL.signatures>1&&eY?`, signature ${eY.signature} of ${eL.signatures}`:""]}),(0,a.jsx)(g.$,{size:"sm",variant:"outline",onClick:()=>es(e=>Math.min(eL.sheets.length-1,e+1)),disabled:et>=eL.sheets.length-1,"aria-label":"Next sheet",children:(0,a.jsx)(c.A,{className:"size-4"})})]}),(0,a.jsxs)("div",{className:"flex gap-1",children:[(0,a.jsx)(g.$,{size:"sm",variant:"front"===ea?"default":"outline",onClick:()=>er("front"),children:"Front"}),(0,a.jsx)(g.$,{size:"sm",variant:"back"===ea?"default":"outline",onClick:()=>er("back"),disabled:"nup"===e.mode&&"single"===e.sides,children:"Back"})]})]}),(0,a.jsxs)("div",{className:"relative mx-auto w-full max-w-2xl border bg-white shadow-sm",style:{aspectRatio:`${eL.sheetW} / ${eL.sheetH}`},"data-thumb-tick":ev,children:[eL.cells.map((t,s)=>{let r=eq[s],n="number"==typeof r?e$.current.get(r):void 0,l="number"==typeof r?eR.get(r):void 0,i=l?W(eL,e,l,s):null;return(0,a.jsx)("div",{className:"absolute flex items-center justify-center",style:{left:`${t.x/eL.sheetW*100}%`,bottom:`${t.y/eL.sheetH*100}%`,width:`${t.w/eL.sheetW*100}%`,height:`${t.h/eL.sheetH*100}%`},children:null==r?(0,a.jsx)("span",{className:"text-[10px] uppercase tracking-wide text-neutral-400",children:"blank"}):(0,a.jsxs)(a.Fragment,{children:[n&&i?(0,a.jsx)("img",{src:n,alt:`Page ${r}`,className:"border border-neutral-200 object-contain",style:{width:`${i.rect.w/t.w*100}%`,height:`${i.rect.h/t.h*100}%`}}):(0,a.jsxs)("span",{className:"text-xs text-neutral-400",children:["page ",r]}),(0,a.jsx)("span",{className:"absolute bottom-1 left-1 rounded bg-neutral-900/80 px-1 text-[10px] font-medium text-white",children:r})]})},s)}),null!==eL.foldX&&(0,a.jsx)("div",{className:"absolute top-0 h-full border-l border-dashed border-neutral-400",style:{left:`${eL.foldX/eL.sheetW*100}%`}})]}),(0,a.jsx)("p",{className:"text-center text-xs text-muted-foreground",children:"Numbers are your original page numbers, shown where they land on the paper."})]}),(0,a.jsxs)("div",{className:"space-y-3 rounded-lg border p-4",children:[(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,a.jsxs)(g.$,{onClick:()=>void eV(!0),variant:"outline",disabled:_,children:[_?(0,a.jsx)(l.A,{className:"mr-2 size-4 animate-spin"}):null,"Make the test sheet"]}),(0,a.jsxs)(g.$,{onClick:()=>void eV(!1),disabled:_,children:[_?(0,a.jsx)(l.A,{className:"mr-2 size-4 animate-spin"}):null,"Build all ",eL.sheets.length," sheets"]})]}),ei&&ei.stamp===eB&&(0,a.jsxs)("div",{className:"rounded border border-dashed p-3 text-sm",children:[(0,a.jsx)("p",{className:"mb-2",children:1===eL.sheets.length?"Your whole job is one sheet, so this test sheet is the job itself with the numbers printed large. Print it, fold it, and you are done checking.":"One sheet, numbered. Print it double sided, fold it, and see whether the numbers land where the preview says. Thirty seconds against twenty-odd wasted sheets."}),(0,a.jsxs)(g.$,{size:"sm",onClick:()=>e_(ei),children:[(0,a.jsx)(h.A,{className:"mr-2 size-4"})," Download the test sheet"]})]}),en&&en.stamp===eB&&(0,a.jsxs)("div",{className:"rounded border p-3 text-sm",children:[(0,a.jsxs)("p",{className:"mb-2",children:[en.sheets," sheet",1===en.sheets?"":"s"," ready. Print at 100% or actual size with any fit to page option switched off, or the print dialog will rescale a correctly imposed sheet at the last second."]}),(0,a.jsxs)(g.$,{size:"sm",onClick:()=>e_(en),children:[(0,a.jsx)(h.A,{className:"mr-2 size-4"})," Download the imposed PDF"]})]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-end gap-2",children:[(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)(b.J,{htmlFor:"bk-preset",children:"Save these settings as"}),(0,a.jsx)(x.p,{id:"bk-preset",className:"w-56",value:eh,placeholder:"Sunday programme",onCh
1ange:e=>eu(e.target.value)})]}),(0,a.jsx)(g.$,{size:"sm",variant:"outline",onClick:function(){let t=eh.trim().slice(0,40);if(!t)return;let s=[{name:t,cfg:e},...ed.filter(e=>e.name!==t)].slice(0,12);ec(s),eu("");try{window.localStorage.setItem(I,JSON.stringify(s.map(e=>({name:e.name,q:U(e.cfg).toString()}))))}catch{}},disabled:!eh.trim(),children:"Save"}),(0,a.jsx)(g.$,{size:"sm",variant:"outline",onClick:function(){eC.current++,e$.current.forEach(e=>URL.revokeObjectURL(e)),e$.current.clear(),eS.current.clear(),O(eN,eM),N(null),eg(new Map),ek(!1),eP.current.clear(),eF.current="",Q(""),ee(""),ej.current&&(ej.current.value="")},children:"Start over"})]}),ed.length>0&&(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:ed.map(e=>(0,a.jsxs)("span",{className:"inline-flex items-center gap-1 rounded border px-2 py-1 text-xs",children:[(0,a.jsx)("button",{type:"button",className:"hover:underline",onClick:()=>t(e.cfg),children:e.name}),(0,a.jsx)("button",{type:"button","aria-label":`Delete ${e.name}`,onClick:()=>(function(e){let t=ed.filter(t=>t.name!==e);ec(t);try{window.localStorage.setItem(I,JSON.stringify(t.map(e=>({name:e.name,q:U(e.cfg).toString()}))))}catch{}})(e.name),children:(0,a.jsx)(u.A,{className:"size-3 text-muted-foreground"})})]},e.name))})]})]})]}),(0,a.jsx)(w.ToolActions,{getParams:eK,title:"PDF Booklet Maker"}),(0,a.jsxs)("p",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,a.jsx)(m.A,{className:"size-3.5"}),"Your PDF is read and imposed on your own device. Nothing is uploaded, there is no account, and no page is stamped with a watermark."]})]})}function Y(e){return"single"===e?"Print single sided.":"short"===e?"Print double sided, flipping on the SHORT edge.":"Print double sided, flipping on the LONG edge."}}}]);

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.