forge-terminal 0.4.4 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/README.md +104 -19
  2. package/dist/chunks/{about-credits-QMC5GQU2.js → about-credits-5UQU5WHE.js} +2 -2
  3. package/dist/chunks/args-QKAIL3E4.js +3 -0
  4. package/dist/chunks/{available-GYIHVSRX.js → available-M6Z62OWE.js} +1 -1
  5. package/dist/chunks/boot-MGR26CBU.js +3 -0
  6. package/dist/chunks/catalog-VPSTQTFD.js +3 -0
  7. package/dist/chunks/check-B6NP7BEM.js +3 -0
  8. package/dist/chunks/chunk-37P6QZ5Q.js +3 -0
  9. package/dist/chunks/chunk-3GJ7GV3V.js +19 -0
  10. package/dist/chunks/{chunk-EHARO6IS.js → chunk-57M4J2BR.js} +1 -1
  11. package/dist/chunks/chunk-63XCSYHM.js +3 -0
  12. package/dist/chunks/{chunk-JFJ3ZJQL.js → chunk-63ZK5SRQ.js} +1 -1
  13. package/dist/chunks/chunk-C4UCCBCX.js +3 -0
  14. package/dist/chunks/{chunk-DERIWZAT.js → chunk-CKZBBDAW.js} +1 -1
  15. package/dist/chunks/chunk-DZOBIUV6.js +3 -0
  16. package/dist/chunks/chunk-EKTUUKDP.js +80 -0
  17. package/dist/chunks/chunk-F34DPQFQ.js +63 -0
  18. package/dist/chunks/chunk-G46QQBT3.js +3 -0
  19. package/dist/chunks/chunk-GSK2A3TN.js +3 -0
  20. package/dist/chunks/chunk-H3DIRJFE.js +3 -0
  21. package/dist/chunks/chunk-HKINXTUW.js +3 -0
  22. package/dist/chunks/chunk-HOZ6XGQQ.js +6 -0
  23. package/dist/chunks/chunk-I6754KTB.js +36 -0
  24. package/dist/chunks/{chunk-YYB3TTGT.js → chunk-JMBEZPYC.js} +1 -1
  25. package/dist/chunks/chunk-K7KKCR7V.js +6 -0
  26. package/dist/chunks/chunk-KH5DHZ2U.js +8 -0
  27. package/dist/chunks/chunk-KXKQDFHX.js +3 -0
  28. package/dist/chunks/chunk-LVYQVJOF.js +3 -0
  29. package/dist/chunks/chunk-N6RCLJE6.js +4 -0
  30. package/dist/chunks/chunk-N72E43Z3.js +3 -0
  31. package/dist/chunks/chunk-NDECMPOM.js +3 -0
  32. package/dist/chunks/chunk-NXJGO66P.js +3 -0
  33. package/dist/chunks/chunk-OK7XOZFO.js +3 -0
  34. package/dist/chunks/chunk-P4RAYEM7.js +6 -0
  35. package/dist/chunks/{chunk-EX7KZBI6.js → chunk-PE5LAYGF.js} +1 -1
  36. package/dist/chunks/chunk-PPR7B5AR.js +3 -0
  37. package/dist/chunks/chunk-Q6KQWJ4J.js +3 -0
  38. package/dist/chunks/{chunk-GJ2GZHRI.js → chunk-RMD7F3QX.js} +1 -1
  39. package/dist/chunks/chunk-SK2UZ25Y.js +3 -0
  40. package/dist/chunks/chunk-SNDFMJIX.js +3 -0
  41. package/dist/chunks/{chunk-IGF6ZFTM.js → chunk-SZRSAL64.js} +1 -1
  42. package/dist/chunks/chunk-THDAQBQ3.js +3 -0
  43. package/dist/chunks/chunk-TL5MACSF.js +3 -0
  44. package/dist/chunks/chunk-V3I6DSF4.js +3 -0
  45. package/dist/chunks/{chunk-M7A55JKD.js → chunk-W6SY5PPG.js} +2 -2
  46. package/dist/chunks/chunk-WC6SJN5Y.js +3 -0
  47. package/dist/chunks/chunk-WE6KP4FR.js +3 -0
  48. package/dist/chunks/chunk-WIPP5TWQ.js +3 -0
  49. package/dist/chunks/{chunk-I2IATJNL.js → chunk-XBOMWF34.js} +1 -1
  50. package/dist/chunks/chunk-XRI5XKEB.js +66 -0
  51. package/dist/chunks/chunk-Y7LOIHFU.js +3 -0
  52. package/dist/chunks/chunk-YINYF6C7.js +3 -0
  53. package/dist/chunks/chunk-ZRHYGR2L.js +134 -0
  54. package/dist/chunks/chunk-ZZZAPVKM.js +3 -0
  55. package/dist/chunks/clip-command-R2NKW4TI.js +3 -0
  56. package/dist/chunks/clipboard-GICOXMMN.js +3 -0
  57. package/dist/chunks/colour-APVBMEJQ.js +3 -0
  58. package/dist/chunks/command-GYCYLUHN.js +3 -0
  59. package/dist/chunks/config-command-6YUMMZF3.js +3 -0
  60. package/dist/chunks/continue-editing-QE5RRIMG.js +3 -0
  61. package/dist/chunks/decoded-UNCEUPNW.js +3 -0
  62. package/dist/chunks/entry-TSLQHDP7.js +6 -0
  63. package/dist/chunks/execute-S5WN34PS.js +3 -0
  64. package/dist/chunks/extensions-XI5R74TS.js +3 -0
  65. package/dist/chunks/{extensions-command-L2AT6OVR.js → extensions-command-25JOL47P.js} +1 -1
  66. package/dist/chunks/ffmpeg-3CJ6C37W.js +3 -0
  67. package/dist/chunks/image-QSTDWHJ4.js +3 -0
  68. package/dist/chunks/install-IDUHZTTS.js +3 -0
  69. package/dist/chunks/{install-V62EEK54.js → install-L5C2UT6M.js} +1 -1
  70. package/dist/chunks/install-size-PZUFEDGI.js +3 -0
  71. package/dist/chunks/launch-LFFWVTFE.js +17 -0
  72. package/dist/chunks/libs-EK64ACG3.js +3 -0
  73. package/dist/chunks/lock-PTQUMNYX.js +3 -0
  74. package/dist/chunks/manager-CQ6NNQY4.js +4 -0
  75. package/dist/chunks/needed-MYXIUZI4.js +3 -0
  76. package/dist/chunks/own-WNA6BFYL.js +3 -0
  77. package/dist/chunks/{paths-5XI5L4KW.js → paths-EOYKOUBC.js} +1 -1
  78. package/dist/chunks/pdfium-WFGSET5S.js +3 -0
  79. package/dist/chunks/preferences-3P4V2EDX.js +3 -0
  80. package/dist/chunks/preset-command-HMOFTZSG.js +3 -0
  81. package/dist/chunks/registry-4IOXO6DT.js +3 -0
  82. package/dist/chunks/{reveal-L6TBFOMV.js → reveal-D5FCZYOA.js} +1 -1
  83. package/dist/chunks/run-HGZVOXRW.js +5 -0
  84. package/dist/chunks/{server-7PMVIYWQ.js → server-KKF3XBQG.js} +8 -8
  85. package/dist/chunks/text-layer-LHZNDMPZ.js +3 -0
  86. package/dist/chunks/{theme-Z6X54JY4.js → theme-NAWQ77WF.js} +1 -1
  87. package/dist/chunks/transcribe-Q5NLWSSR.js +3 -0
  88. package/dist/chunks/transcribe-command-2L7F7MCG.js +3 -0
  89. package/dist/chunks/{update-command-GMBG7BK6.js → update-command-JCTCRPCS.js} +1 -1
  90. package/dist/chunks/update-note-FRMHMUMD.js +3 -0
  91. package/dist/chunks/watch-command-XCCMIQIM.js +3 -0
  92. package/dist/fonts/NotoSans-Bold.ttf.gz +0 -0
  93. package/dist/fonts/NotoSans-Regular.ttf.gz +0 -0
  94. package/dist/fonts/OFL.txt +93 -0
  95. package/dist/helpers/forge-transcribe +0 -0
  96. package/dist/helpers/forge-transcribe-whisper.mjs +525 -0
  97. package/dist/index.js +8 -8
  98. package/dist/third-party-licenses.txt +98 -0
  99. package/package.json +45 -10
  100. package/dist/chunks/args-VPUOIDWE.js +0 -3
  101. package/dist/chunks/boot-FOKV7OHT.js +0 -3
  102. package/dist/chunks/catalog-YSMT3PXT.js +0 -3
  103. package/dist/chunks/check-KAR72Y4X.js +0 -3
  104. package/dist/chunks/chunk-3UEQ2OX6.js +0 -3
  105. package/dist/chunks/chunk-5B5XXH22.js +0 -3
  106. package/dist/chunks/chunk-5IS7O673.js +0 -6
  107. package/dist/chunks/chunk-5SMYDPVX.js +0 -63
  108. package/dist/chunks/chunk-6FUVEO3A.js +0 -78
  109. package/dist/chunks/chunk-6L6C3GJU.js +0 -3
  110. package/dist/chunks/chunk-AAXBN572.js +0 -4
  111. package/dist/chunks/chunk-BZXDNDPG.js +0 -3
  112. package/dist/chunks/chunk-DOWMSJ6R.js +0 -3
  113. package/dist/chunks/chunk-EXLXSKRH.js +0 -3
  114. package/dist/chunks/chunk-FH3R2YYD.js +0 -19
  115. package/dist/chunks/chunk-I63TO22X.js +0 -3
  116. package/dist/chunks/chunk-IWFVEMDN.js +0 -3
  117. package/dist/chunks/chunk-JSMGNA55.js +0 -3
  118. package/dist/chunks/chunk-KAHWYWNT.js +0 -3
  119. package/dist/chunks/chunk-LDKF7KIZ.js +0 -6
  120. package/dist/chunks/chunk-LNB5D67B.js +0 -3
  121. package/dist/chunks/chunk-M66BUNYO.js +0 -3
  122. package/dist/chunks/chunk-NWREILRP.js +0 -66
  123. package/dist/chunks/chunk-PSEIJXGT.js +0 -3
  124. package/dist/chunks/chunk-QR6QHTC3.js +0 -3
  125. package/dist/chunks/chunk-QXTXBMTM.js +0 -3
  126. package/dist/chunks/chunk-SMBK6BTC.js +0 -3
  127. package/dist/chunks/chunk-TDW6KQH6.js +0 -3
  128. package/dist/chunks/chunk-TMQDQLY7.js +0 -21
  129. package/dist/chunks/chunk-XEQVXPPY.js +0 -3
  130. package/dist/chunks/chunk-XSOCV3F2.js +0 -3
  131. package/dist/chunks/chunk-YWKMG5WO.js +0 -3
  132. package/dist/chunks/clip-command-SGB3B4OJ.js +0 -3
  133. package/dist/chunks/clipboard-CPHPA4FH.js +0 -3
  134. package/dist/chunks/colour-QMGYV6WQ.js +0 -3
  135. package/dist/chunks/command-I5M275ZV.js +0 -3
  136. package/dist/chunks/config-command-TYNYVUMP.js +0 -3
  137. package/dist/chunks/entry-3PEVSH2X.js +0 -6
  138. package/dist/chunks/execute-WQJ37VKD.js +0 -3
  139. package/dist/chunks/extensions-ZKOWPSLD.js +0 -3
  140. package/dist/chunks/ffmpeg-PF3VLTHK.js +0 -3
  141. package/dist/chunks/image-J4FT4ACZ.js +0 -3
  142. package/dist/chunks/install-2A5BGKQU.js +0 -3
  143. package/dist/chunks/launch-L5DKAUA3.js +0 -15
  144. package/dist/chunks/lock-KN7CF4YN.js +0 -3
  145. package/dist/chunks/manager-TEZ3V4L4.js +0 -4
  146. package/dist/chunks/preferences-4VETUGMN.js +0 -3
  147. package/dist/chunks/preset-command-HORY7KZQ.js +0 -3
  148. package/dist/chunks/run-6BK4REXK.js +0 -4
  149. package/dist/chunks/transcribe-command-YUSBCQEQ.js +0 -3
  150. package/dist/chunks/update-note-RQG2RZNR.js +0 -3
  151. package/dist/chunks/watch-command-DUHMTXQL.js +0 -3
@@ -1,3 +0,0 @@
1
- import { createRequire as __forgeCreateRequire } from 'node:module';
2
- const require = __forgeCreateRequire(import.meta.url);
3
- import{c as Q,g as je,h as et}from"./chunk-EEQSUBBL.js";import{A as Ge,B as Ve,C as He,G as X,H as Ke,I as Ye,N as Ze,o as Te,p as Be,r as Le,u as ze,v as N,w as D,x as Ue,y as Ce,z as qe}from"./chunk-KAHWYWNT.js";import{a as Ne,b as Je,d as We,e as E}from"./chunk-SMBK6BTC.js";import{$ as Z,F as ke,G as C,H as ae,J as Ae,N as _e,W as Me,c as k,d as T,fa as Oe,ga as L,s as De,u as Y,w as B}from"./chunk-3UEQ2OX6.js";import{a as Re}from"./chunk-J7FLFHQJ.js";import{c as ce,e as pe,f as Xe,j as Qe}from"./chunk-LDKF7KIZ.js";import{a as I}from"./chunk-M66BUNYO.js";import{readFile as Rt,rm as Dt}from"node:fs/promises";var kt=new Set(["pdf"]),At=new Set(["jpeg","png"]),_t=new Set(["convert"]),tt;function Mt(){return tt??=Ue().then(e=>e.PDFiumLibrary.init()),tt}async function ot(e,t){return await(await Mt()).loadDocument(e,t)}async function nt(e){let t=await ot(e);try{let o=[];for(let n=0;n<t.getPageCount();n++)o.push(t.getPage(n).getText());return o}finally{t.destroy()}}var rt={id:"pdfium",reads:kt,writes:At,ops:_t,probe(){throw new Error("pdfium does not probe; engines/pdf.ts classifies PDFs")},async run(e,t){if(e.op!=="convert")throw new Error(`pdfium cannot ${e.op}`);let o=e.sources[0];if(o.kind!=="document")throw new Error("the pdfium engine can only rasterise a document source");if(o.encrypted&&e.options.password===void 0)throw B(o.path);let n=e.options.dpi??150,s=e.options.pages??Array.from({length:o.pages},(a,p)=>p);if(s.length!==e.outputs.length)throw new Error(`pdfium was given ${s.length} pages but ${e.outputs.length} outputs`);for(let a of s)if(a<0||a>=o.pages)throw new Error(`pdfium was asked for page ${a}, but ${o.path} has ${o.pages} pages`);let r=await N(),i=await ot(await Rt(o.path),e.options.password);try{let a=[],p=0;try{for(let[c,d]of s.entries()){let l=await i.getPage(d).render({scale:n/72,render:"bitmap",transparent:!0}),h=r(l.data,{raw:{width:l.width,height:l.height,channels:4}}).flatten({background:e.options.background}),g=await X(h,e.target,e.options.quality).toBuffer(),m=e.outputs[c];p+=await E(m,g),a.push(m),t({phase:"page",done:c+1,total:s.length})}}catch(c){throw await Promise.all(a.map(d=>Dt(d,{force:!0}))),c}return{job:e,outputBytes:p,warnings:[]}}finally{i.destroy()}}};import{mkdtemp as Ot,rm as Tt}from"node:fs/promises";import{tmpdir as Bt}from"node:os";import{join as j}from"node:path";var it=(e,t,o)=>Le(e,t,o)===void 0;function st(e,t,o=Number.POSITIVE_INFINITY,n=[2,4]){return[...n].reverse().find(s=>s<o&&it(e,t,s))??0}async function Lt(e,t,o){if(e.op!=="boost"&&e.op!=="remove-background")throw new Error(`the extension engine cannot ${e.op}`);if(o?.aborted)throw o.reason??new Error("aborted");let n=e.sources[0],s=e.outputs[0],r=e.op,{assetFor:i,catalogEntry:a,offeredHere:p}=await import("./catalog-YSMT3PXT.js");if(!p(r))throw _e(a(r)?.title??r);let{installed:c,extensionsRoot:d}=await import("./paths-5XI5L4KW.js"),l=await c(r);if(!l)throw Ae(r);let h=Te(l.version);if(e.op==="boost"){let w=a(r),P=Be(e.scale,l.version,w&&i(w)?.version);if(P)throw P}if(e.op==="boost"&&!it(n.width,n.height,e.scale))throw Me(n.path,st(n.width,n.height,Number.POSITIVE_INFINITY,h),e.scale);let{runExtension:g}=await import("./run-6BK4REXK.js"),m=[];n.frames>1&&m.push({code:"animation-flattened",message:`${k(n.path)} has ${n.frames} frames. Only the first frame was used.`});let x=await Ot(j(Bt(),"forge-ext-"));try{t({phase:"decoding"});let w=j(x,"in.png"),P=j(x,"out.png");await Ye(n,w);let u=e.op==="boost"?["--in",w,"--out",P,"--scale",String(e.scale),"--cache",j(d(),"boost","cache")]:[w,P];await g(l,u,{subject:n.path,what:`${Nt(e)} is running on ${k(n.path)}`,onWait:()=>t({phase:"waiting"}),onStart:()=>t({phase:"encoding"}),...e.op==="boost"?{maxScale:st(n.width,n.height,e.scale,h)}:{},...o===void 0?{}:{signal:o}});let y=(await N())(P);I[e.target].hasAlpha||(y=y.flatten({background:e.options.background}));let S=await X(y,e.target,e.options.quality).toBuffer();t({phase:"writing"});let F=await Ke(S,s);return{job:e,outputBytes:F,warnings:m}}catch(w){throw T(w)?w:L(n.path,w)}finally{await Tt(x,{recursive:!0,force:!0}).catch(()=>{})}}function Nt(e){return e.op!=="boost"?"Remove background":e.scale===1?"Sharpen":`Boost resolution ${e.scale}\xD7`}var at={id:"extension",reads:new Set,writes:new Set,ops:new Set(["boost","remove-background"]),probe:()=>Promise.reject(new Error("the extension engine reads no files")),run:Lt};import{randomBytes as to}from"node:crypto";import{open as oo,rm as no,stat as ee}from"node:fs/promises";import{dirname as ro,join as so}from"node:path";var fe="%LOUDNORM_MEASURED%",Jt={mp4:"mp4",hevc:"mp4",mov:"mov",webm:"webm",mkv:"matroska",avi:"avi",gif:"gif",mp3:"mp3",m4a:"ipod",opus:"opus",flac:"flac",wav:"wav",aiff:"aiff",ogg:"ogg"},Wt={mp4:["h264","hevc","mpeg4","av1"],mov:["h264","hevc","mpeg4","prores","av1"],mkv:["h264","hevc","mpeg4","vp8","vp9","av1"],hevc:["hevc"],webm:["vp8","vp9","av1"],avi:["mpeg4","h264","mjpeg","msmpeg4v3"]},zt={mp4:["aac","alac","mp3"],hevc:["aac","alac","mp3"],mov:["aac","alac","mp3","pcm_s16le","pcm_s16be","pcm_s24le"],m4a:["aac","alac"],mkv:["aac","mp3","opus","vorbis","flac","ac3","eac3"],webm:["opus","vorbis"],opus:["opus"],mp3:["mp3"],flac:["flac"],wav:["pcm_s16le"],aiff:["pcm_s16be"],ogg:["vorbis","opus","flac"],avi:["mp3","ac3","aac","pcm_s16le"]};function Ut(e,t,o){switch(e){case"webm":case"opus":return{encoder:"libopus",kbps:96};case"mp3":return{encoder:"libmp3lame",kbps:128};case"flac":return{encoder:"flac"};case"wav":return{encoder:"pcm_s16le"};case"aiff":return{encoder:"pcm_s16be"};case"ogg":return{encoder:"libvorbis",kbps:128};default:return{encoder:t==="darwin"&&o("aac_at")?"aac_at":"aac",kbps:128}}}var q=e=>Math.max(2,Math.floor(e/2)*2),Ct=e=>String(Math.round(e*1e3)/1e3),qt=e=>String(Math.ceil(e*1e3)/1e3),Gt=e=>Math.round(38-(e-1)*20/99),Vt=e=>Math.round(50-(e-1)*30/99),Ht=e=>Math.round(40-(e-1)*18/99),Kt="zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,format=yuv420p";function ct(e){let t=[],o=e;for(;o>2;)t.push("atempo=2"),o/=2;for(;o<.5;)t.push("atempo=0.5"),o/=.5;return t.push(`atempo=${Math.round(o*1e3)/1e3}`),t}var Yt=800,Zt=15,pt=32;function ft(e){let{facts:t,options:o,target:n,platform:s}=e,r=o.media??{},i=t.video,a=t.audio,p=I[n].media==="sound",c=n==="gif",d=o.compress!==void 0,l=s==="darwin",h=f=>e.has===void 0||e.has.has(f),g=r.cut?.start??0,m=Math.min(r.cut?.end??t.duration,t.duration),x=Math.max(0,m-g),w=r.speed??1,P=x/w,u=i!==void 0&&!p,b=a!==void 0&&!r.mute&&!c,y,S,F,_;if(r.targetBytes!==void 0&&P>0){if(u&&i){let f=je({duration:P,width:i.width,height:i.height,fps:i.fps,hasAudio:b,targetBytes:r.targetBytes});"videoKbps"in f&&(y={width:f.width,height:f.height,fps:f.fps},F=f.videoKbps,S=f.audioKbps)}else if(b){let f=Math.floor(r.targetBytes*8/P/1e3*.98);_=Math.max(pt,Math.min(320,f))}}let $=[];if(u&&i){if(i.hdr&&n!=="hevc"&&h("zscale")&&$.push(Kt),o.crop?.box){let f=o.crop.box;$.push(`crop=${q(f.width)}:${q(f.height)}:${f.left}:${f.top}`)}if(y)$.push(`scale=${y.width}:${y.height}`);else if(o.resize){let f=o.resize;"width"in f?$.push(`scale=trunc(min(${q(f.width)}\\,iw)/2)*2:-2`):"height"in f?$.push(`scale=-2:trunc(min(${q(f.height)}\\,ih)/2)*2`):$.push(`scale=trunc(iw*${f.percent/100}/2)*2:-2`)}if(w!==1&&$.push(`setpts=PTS/${w}`),c){let f=Math.min(Yt,q(i.width));$.push(`fps=${Math.min(Zt,i.fps)},scale=${f}:-2:flags=lanczos,split[s0][s1];[s0]palettegen=stats_mode=diff[p];[s1][p]paletteuse=dither=bayer:bayer_scale=4`)}}let re=y?.fps??r.fps,xe=u&&i!==void 0&&$.length===0&&re===void 0&&!d&&r.targetBytes===void 0&&(Wt[n]??[]).includes(i.codec),v=[];if(!u)v.push("-vn");else if(xe)v.push("-c:v","copy");else{if($.length&&v.push("-vf",$.join(",")),c)v.push("-c:v","gif","-loop","0");else if(n==="webm")if(v.push("-c:v","libvpx-vp9","-row-mt","1","-deadline","good","-cpu-used","4"),F!==void 0)v.push("-b:v",`${F}k`);else{let f=d?Vt(o.quality??60):33;v.push("-crf",String(f),"-b:v","0")}else if(n==="hevc"){let f=h("libx265")||!l;if(F!==void 0)f?v.push("-c:v","libx265","-preset","fast","-b:v",`${F}k`):v.push("-c:v","hevc_videotoolbox","-b:v",`${F}k`);else if(l&&(!d||!f)){let O=d?Math.round(20+(o.quality??60)*60/100):60;v.push("-c:v","hevc_videotoolbox","-q:v",String(O))}else{let O=d?Ht(o.quality??60):26;v.push("-c:v","libx265","-crf",String(O),"-preset","fast")}v.push("-tag:v","hvc1","-pix_fmt",i?.hdr?"p010le":"yuv420p")}else F!==void 0?v.push("-c:v","libx264","-preset","medium","-b:v",`${F}k`):d?v.push("-c:v","libx264","-preset","medium","-crf",String(Gt(o.quality??60))):l?v.push("-c:v","h264_videotoolbox","-q:v","65"):v.push("-c:v","libx264","-preset","veryfast","-crf","21"),v.push("-pix_fmt","yuv420p");re!==void 0?v.push("-r",String(re)):c||v.push("-fps_mode","passthrough")}let V=w!==1?ct(w):[],M=r.loudness;M!==void 0&&V.push(`loudnorm=I=${M}:TP=-1.5:LRA=11:${fe}:linear=true`);let Pe=r.bitrate??S??_,Fe=b&&a!==void 0&&V.length===0&&Pe===void 0&&!(d&&p)&&(zt[n]??[]).includes(a.codec),R=[];if(!b)R.push("-an");else if(Fe)R.push("-c:a","copy");else{V.length&&R.push("-af",V.join(","));let f=Ut(n,s,h);R.push("-c:a",f.encoder);let O=Pe??f.kbps;O!==void 0&&f.kbps!==void 0&&R.push("-b:a",`${O}k`),S!==void 0&&S<=pt&&R.push("-ac","1"),M!==void 0&&a&&R.push("-ar",String(a.sampleRate))}let se=[];g>0&&se.push("-ss",qt(g)),r.cut&&se.push("-t",Ct(x));let H=[...se,"-i",e.input],K=[],ie=[...u?["-map","0:v:0"]:[],...b?["-map","0:a:0"]:[]],Ee=o.keepMetadata?[]:["-map_metadata","-1"],$t=Jt[n]??n,Se=["mp4","hevc","mov","m4a"].includes(n)?["-movflags","+faststart"]:[],Ie=["-f",$t,"-y",e.output],$e=s==="win32"?"NUL":"/dev/null",U=[];return M!==void 0&&U.push({args:[...H,...K,"-vn","-af",`${w!==1?`${ct(w).join(",")},`:""}loudnorm=I=${M}:TP=-1.5:LRA=11:print_format=json`,"-f","null",$e],measures:"loudness",pass:{at:1,of:2}}),F!==void 0&&n!=="hevc"&&!c?(U.push({args:[...H,...K,...ie.slice(0,2),...v,"-pass","1","-passlogfile",e.passlog,"-an","-f","null",$e],pass:{at:1,of:2}}),U.push({args:[...H,...K,...ie,...v,"-pass","2","-passlogfile",e.passlog,...R,...Ee,...Se,...Ie],pass:{at:2,of:2}})):U.push({args:[...H,...K,...ie,...v,...R,...Ee,...Se,...Ie],...M!==void 0?{pass:{at:2,of:2}}:{}}),{steps:U,duration:P,copies:{video:xe,audio:Fe},...y?{fitted:y}:{}}}var J=(e,t,o)=>e.subarray(t,t+o).toString("latin1"),Xt=new Set(["heic","heix","hevc","hevx","heim","heis","mif1","msf1","avif","avis","crx "]),Qt=new Set(["M4A ","M4B ","M4P ","F4A ","F4B "]);function jt(e){let t=J(e,8,4);if(!Xt.has(t))return t==="qt "?"mov":Qt.has(t)?"m4a":"mp4"}function dt(e){if(e.length<4)return;if(J(e,4,4)==="ftyp")return jt(e);if(e[0]===26&&e[1]===69&&e[2]===223&&e[3]===163)return e.includes("webm",0,"latin1")?"webm":"mkv";let t=J(e,0,4);if(t==="RIFF"){let o=J(e,8,4);return o==="WAVE"?"wav":o==="AVI "?"avi":void 0}if(t==="FORM"){let o=J(e,8,4);return o==="AIFF"||o==="AIFC"?"aiff":void 0}if(t==="fLaC")return"flac";if(t==="OggS")return e.includes("OpusHead",0,"latin1")?"opus":"ogg";if(J(e,0,3)==="ID3"||e[0]===255&&((e[1]??0)&224)===224&&((e[1]??0)&6)===2)return"mp3"}var io=["mp4","mov","webm","mkv","avi","gif"],mt=["mp4","mov","hevc","webm","mkv","avi","gif","mp3","m4a","wav"],ao=["mp3","m4a","wav","aiff","flac","opus","ogg"],co=["mp3","m4a","opus","flac","aiff","wav"];async function po(e){let t=await oo(e,"r");try{let o=Buffer.alloc(64),{bytesRead:n}=await t.read(o,0,o.length,0);return o.subarray(0,n)}finally{await t.close()}}function fo(e,t){return t&&!t.video&&(e==="mp4"||e==="mov")?"m4a":e}async function lt(e,t){let o=dt(await po(e));if(!o)throw new Error("not video or sound");if(o!=="mp4"&&o!=="mov"&&I[o].media!==t)throw new Error(`not ${t}`);let n=(await ee(e)).size,s=await ce(),r;if(s){try{r=await pe(e,s)}catch(a){throw Y(e,a)}if(r.duration<=0||!r.video&&!r.audio)throw Y(e,r)}let i=fo(o,r);if(I[i].media!==t)throw new Error(`not ${t}`);return{kind:"media",path:e,format:i,bytes:n,...r?{facts:r}:{}}}async function uo(){let{assetFor:e,catalogEntry:t}=await import("./catalog-YSMT3PXT.js"),o=t("video");return o!==void 0&&e(o)!==void 0}async function mo(e,t){if(e.kind==="media"&&e.facts)return e.facts;try{return await pe(e.path,t)}catch(o){throw Y(e.path,o)}}function lo(e,t){let o=e.options.media??{},n=o.cut?.start??0,s=Math.min(o.cut?.end??t,t);return Math.max(0,s-n)/(o.speed??1)}function gt(e,t){if(e.op!=="convert")return;let o=e.sources[0],n=o.kind==="media"?o.facts:void 0;if(!n)return;let s=e.options.media??{},r=et({...n,duration:lo(e,n.duration)},{soundOnly:I[e.target].media==="sound",mute:s.mute===!0||e.target==="gif"});return t<r?{floor:r}:void 0}function go(e){let t=e.slice(e.lastIndexOf("{"),e.lastIndexOf("}")+1),o=JSON.parse(t);return[`measured_I=${o.input_i}`,`measured_TP=${o.input_tp}`,`measured_LRA=${o.input_lra}`,`measured_thresh=${o.input_thresh}`,`offset=${o.target_offset}`].join(":")}async function ut(e){await Promise.all(e.map(t=>no(t,{force:!0}).catch(()=>{})))}async function ht(e,t,o){if(e.op!=="convert")throw new Error(`media engines only convert, not ${e.op}`);if(o?.aborted)throw o.reason??new Error("aborted");let n=e.sources[0],s=e.outputs[0],r=await ce();if(!r)throw Oe(n.path,process.platform,await uo());let i=await mo(n,r);await Je(s);let a=to(6).toString("hex"),p=Ne(s,a),c=so(ro(s),`.forge-pass-${a}`),d=[p,`${c}-0.log`,`${c}-0.log.temp`,`${c}-0.log.mbtree`,`${c}-0.log.mbtree.temp`],l=[],h=(u,b=e.options)=>ft({input:n.path,output:p,target:e.target,facts:i,options:b,platform:u,passlog:c,...r.has?{has:r.has}:{}}),g=e.options,m=h(process.platform);if(m.duration<=0)throw ke(`The cut keeps nothing of ${k(n.path)}: it starts at or after its end.`,`It is ${Q(i.duration)} long.`);let x=g.media?.cut;if(m.copies.video&&x&&x.start>0){let u=await Xe(n.path,x.start,r);u!==void 0&&x.start-u>.05&&(g={...g,media:{...g.media,cut:{...x,start:u}}},m=h(process.platform,g),l.push({code:"media-cut-keyframe",message:`It starts at ${Q(u)}, the keyframe just before ${Q(x.start)}.`}))}let w=async u=>{let b="";for(let y of u.steps){let S=y.args.map(_=>_.replace(fe,b)),F=await Qe(S,{tools:r,signal:o,report:y.measures==="loudness",onTime:_=>t({phase:"time",done:Math.min(_,u.duration),total:u.duration,...y.pass?{pass:y.pass}:{}})});y.measures==="loudness"&&(b=go(F))}};try{try{await w(m)}catch(y){if(o?.aborted||!m.steps.some(S=>S.args.some(F=>F.endsWith("_videotoolbox"))))throw y;m=h("linux",g),await w(m)}let u=g.media?.targetBytes;for(let y of[.95,.9]){if(u===void 0||(await ee(p)).size<=u)break;g={...g,media:{...g.media,targetBytes:Math.floor(u*y)}},m=h(m.steps.some(S=>S.args.includes("libx264"))?"linux":process.platform,g),await w(m)}let b=(await ee(p)).size;if(u!==void 0&&b>u)throw De(n,e.options.media?.targetBytes??u,b);if(e.options.compress!==void 0&&b>=n.bytes)throw Z(n.path,n.bytes,b);await We(p,s)}catch(u){throw await ut(d),o?.aborted||T(u)?u:L(n.path,u)}await ut(d.slice(1));let P=i.video;if(m.fitted&&P&&(m.fitted.width<P.width-2||m.fitted.fps<P.fps)){let u=Re(e.options.media?.targetBytes??0);l.push({code:"media-fitted",message:`To fit ${u} it is now ${m.fitted.width}\xD7${m.fitted.height} at ${m.fitted.fps} fps.`})}return{job:e,outputBytes:(await ee(s)).size,warnings:l}}var G=e=>new Set(e);function ho(e){let t=e.kind==="media"?e.facts:void 0,o=e.kind==="image"||t!==void 0&&t.audio===void 0;return G(mt.filter(n=>!(o&&I[n].media==="sound"||n==="hevc"&&t?.video?.codec==="hevc")))}var wt={id:"video",reads:G(io),writes:G(mt),ops:new Set(["convert"]),probe:e=>lt(e,"video"),run:ht,sizeTo:gt,writesFor:ho},yt={id:"sound",reads:G(ao),writes:G(co),ops:new Set(["convert"]),probe:e=>lt(e,"sound"),run:ht,sizeTo:gt};import{readFile as te,rm as xt,stat as wo}from"node:fs/promises";function zn(e,t){let o=e.split(",").map(r=>r.trim()).filter(r=>r!=="");if(o.length===0)throw C(e,"That selects no pages.",t);let n=new Set,s=(r,i)=>{if(!Number.isInteger(r)||r<1||r>t)throw C(i,`"${i}" is outside 1 and ${t}.`,t);return r};for(let r of o){let i=r.match(/^(\d+)\s*-\s*(\d*)$/);if(i?.[1]!==void 0){let a=s(Number(i[1]),r),p=i[2]===""?t:s(Number(i[2]),r);if(p<a)throw C(r,`"${r}" ends before it starts.`,t);for(let c=a;c<=p;c++)n.add(c-1);continue}if(!/^\d+$/.test(r))throw C(r,`"${r}" is not a page number.`,t);n.add(s(Number(r),r)-1)}return[...n].sort((r,i)=>r-i)}function vt(e){return[...new Set(e)].sort((t,o)=>t-o)}function Un(e){if(e.length===0)return"";let t=[...new Set(e)].sort((r,i)=>r-i),o=[],n=t[0],s=n;for(let r of t.slice(1)){if(r===s+1){s=r;continue}o.push(n===s?`${n+1}`:`${n+1}-${s+1}`),n=r,s=r}return o.push(n===s?`${n+1}`:`${n+1}-${s+1}`),o.join(", ")}function bt(e,t){let o=[...new Set(e)].sort((r,i)=>r-i).filter(r=>r>=0&&r<t-1),n=[],s=0;for(let r of o)n.push({from:s,to:r}),s=r+1;return n.push({from:s,to:t-1}),n}var ue=ze(()=>import("./pdf-compress-U2E3CNXG.js")),yo=new Set(["pdf","jpeg","png","webp","avif","gif","tiff"]),vo=new Set(["pdf"]);async function W(e){return(await D()).PDFDocument.load(await te(e),{ignoreEncryption:!0})}async function bo(e){let{surveyDocument:t}=await ue(),o=await W(e),{size:n}=await wo(e);return{kind:"document",path:e,format:"pdf",bytes:n,pages:o.getPageCount(),encrypted:o.isEncrypted,images:t(o)}}function z(e){for(let t of e)if(t.encrypted)throw B(t.path)}async function xo(e,t,o){let n=await N(),s=t.format==="jpeg"||t.format==="png",r=s?(await n(o).metadata()).orientation:void 0;if(s&&(r===void 0||r===1))return t.format==="jpeg"?e.embedJpg(o):e.embedPng(o);if(t.format==="jpeg"){let i=await n(o).rotate().jpeg({quality:I.jpeg.defaultQuality,mozjpeg:!0}).toBuffer();return e.embedJpg(i)}return e.embedPng(await n(o).rotate().png().toBuffer())}async function Po(e,t){let o=e.sources[0];if(o.kind!=="image")throw new Error("the pdf engine cannot embed a document source");let n=[];o.frames>1&&n.push({code:"animation-flattened",message:`${k(o.path)} has ${o.frames} frames, and ${I.pdf.label} cannot animate. Only the first frame was converted.`}),t({phase:"reading"});let s=await te(o.path);t({phase:"encoding"});let i=await(await D()).PDFDocument.create(),a=await xo(i,o,s);i.addPage([a.width,a.height]).drawImage(a,{x:0,y:0,width:a.width,height:a.height}),t({phase:"writing"});let c=await E(e.outputs[0],await i.save());return{job:e,outputBytes:c,warnings:n}}async function Fo(e,t){z(e.sources.filter(i=>i.kind==="document"));let n=await(await D()).PDFDocument.create();for(let i of e.sources){t({phase:"reading"});let a=await W(i.path),p=await n.copyPages(a,a.getPageIndices());for(let c of p)n.addPage(c)}t({phase:"writing"});let s=await n.save(),r=await E(e.outputs[0],s);return{job:e,outputBytes:r,warnings:[]}}async function Eo(e,t){let o=e.sources[0];z([o]);let n=await D();t({phase:"reading"});let s=await W(o.path),r=bt(e.cuts,s.getPageCount()),i=[],a=0;try{for(let[p,c]of r.entries()){let d=await n.PDFDocument.create(),l=Array.from({length:c.to-c.from+1},(m,x)=>c.from+x),h=await d.copyPages(s,l);for(let m of h)d.addPage(m);let g=e.outputs[p];if(g===void 0)throw new Error(`split produced ${r.length} parts but was given ${e.outputs.length} outputs`);a+=await E(g,await d.save()),i.push(g),t({phase:"page",done:p+1,total:r.length})}}catch(p){throw await Promise.all(i.map(c=>xt(c,{force:!0}))),p}return{job:e,outputBytes:a,warnings:[]}}async function de(e,t){let n=await(await D()).PDFDocument.create(),s=await n.copyPages(e,t);for(let r of s)n.addPage(r);return n.save()}async function So(e,t){let o=e.sources[0];if(z([o]),e.pages.length===0)throw ae("That extract selects no pages.");t({phase:"reading"});let n=await W(o.path),s=vt(e.pages),r=[],i=0;try{if(e.separate)for(let[a,p]of s.entries()){let c=e.outputs[a];i+=await E(c,await de(n,[p])),r.push(c),t({phase:"page",done:a+1,total:s.length})}else{t({phase:"writing"});let a=e.outputs[0];i=await E(a,await de(n,s)),r.push(a)}}catch(a){throw await Promise.all(r.map(p=>xt(p,{force:!0}))),a}return{job:e,outputBytes:i,warnings:[]}}async function Io(e,t){let o=e.sources[0];z([o]),t({phase:"reading"});let n=await W(o.path),s=new Set(e.pages),r=n.getPageIndices().filter(a=>!s.has(a));if(r.length===0)throw ae("That would delete every page.");t({phase:"writing"});let i=await E(e.outputs[0],await de(n,r));return{job:e,outputBytes:i,warnings:[]}}async function $o(e,t){let o=e.sources[0];z([o]);let n=await D();t({phase:"reading"});let s=await W(o.path);for(let i of s.getPages()){let p=((i.getRotation().angle+e.turns*90)%360+360)%360;i.setRotation(n.degrees(p))}t({phase:"writing"});let r=await E(e.outputs[0],await s.save());return{job:e,outputBytes:r,warnings:[]}}async function Ro(e,t){let o=e.sources[0];z([o]);let{compressPdf:n}=await ue();t({phase:"reading"});let s=await te(o.path);t({phase:"encoding"});let{bytes:r,recompressed:i,skipped:a,fromDpi:p,toDpi:c}=await n(s,{quality:e.options.quality??60,dpi:e.options.dpi??150});if(e.options.compress&&r.length>=o.bytes)throw Z(o.path,o.bytes,r.length);t({phase:"writing"});let d=await E(e.outputs[0],r),l=g=>g===1?"":"s",h=[];return i===0&&a===0?h.push({code:"pdf-no-images",message:"This PDF has no images to re-encode, so its size is almost unchanged."}):i===0?h.push({code:"pdf-no-images",message:`None of its ${a} image${l(a)} could be re-encoded \u2014 they are not JPEG data.`}):a>0&&h.push({code:"pdf-images-skipped",message:`${i} image${l(i)} recompressed, ${a} skipped (not JPEG).`}),p!==void 0&&c!==void 0&&h.push({code:"pdf-downsampled",message:`Images reduced from ${p} to ${c} dpi. Pass --dpi ${p} to keep them.`}),{job:e,outputBytes:d,warnings:h}}async function Do(e){if(e.op!=="convert")return;let t=e.sources[0];if(t.kind!=="document")return;let{compressPdf:o}=await ue(),n=await te(t.path);return{ladder:[e.options.dpi??150,120,96,72].map(s=>({dpi:s})),measure:async s=>(await o(n,{quality:s.quality??60,...s.dpi===void 0?{}:{dpi:s.dpi}})).bytes.byteLength}}var Pt={id:"pdf",measurer:Do,reads:yo,writes:vo,ops:new Set(["convert","merge","split","extract","delete","rotate"]),probe:bo,async run(e,t){switch(e.op){case"convert":if(e.target!=="pdf")throw new Error("the pdf engine only converts to pdf");return e.sources[0].kind==="document"?Ro(e,t):Po(e,t);case"merge":return Fo(e,t);case"split":return Eo(e,t);case"extract":return So(e,t);case"delete":return Io(e,t);case"rotate":return $o(e,t);default:throw new Error(`the pdf engine cannot ${e.op}`)}}};import{execFile as ko}from"node:child_process";import{mkdtemp as Ao,readFile as ye,rm as _o}from"node:fs/promises";import{tmpdir as Mo}from"node:os";import{basename as Oo,extname as To,join as Ft,win32 as he}from"node:path";import{pathToFileURL as Bo}from"node:url";import{promisify as Lo}from"node:util";var we=Lo(ko),me=Buffer.from([208,207,17,224,161,177,26,225]);async function No(e){if(e.length<me.length||!e.subarray(0,me.length).equals(me))return!1;let t=await Ve();try{return t.find(t.parse(e),"WordDocument")!==null}catch{return!1}}async function Jo(e){let t=await Ge();try{let o=new t(e);if(!o.getEntry("word/document.xml"))return;let n=0,s=o.getEntry("docProps/app.xml");if(s){let r=/<Pages>(\d+)<\/Pages>/.exec(o.readAsText(s));r?.[1]&&(n=Number(r[1]))}return{pages:n}}catch{return}}async function Wo(e){let t=await ye(e),o=await Jo(t);if(o)return{kind:"document",path:e,format:"docx",bytes:t.byteLength,pages:o.pages,encrypted:!1};if(await No(t))return{kind:"document",path:e,format:"doc",bytes:t.byteLength,pages:0,encrypted:!1};throw new Error(`${e} is not a Word document`)}function zo(e,t){return e==="win32"?[he.join(t.ProgramFiles??"C:\\Program Files","LibreOffice","program","soffice.exe"),he.join(t["ProgramFiles(x86)"]??"C:\\Program Files (x86)","LibreOffice","program","soffice.exe")]:["/Applications/LibreOffice.app/Contents/MacOS/soffice"]}var Uo=0;async function Co(){Uo++;try{return await we("soffice",["--version"],{timeout:5e3}),"soffice"}catch{}for(let e of zo(process.platform,process.env))try{return await we(e,["--version"],{timeout:5e3}),e}catch{}}var Et,qo=!1,Go;async function Vo(){return qo?Go:(Et??=Co(),Et)}var ve="\f";function oe(e){return e.split(/\r?\n/).map(t=>t.trim()).filter(t=>t.length>0)}async function Ho(e){if(e.format==="docx"){let o=await Ce(),{value:n}=await o.extractRawText({path:e.path});return oe(n)}if(e.format==="doc"){let o=await qe(),s=await new o().extract(e.path);return oe(s.getBody())}return(await nt(await ye(e.path))).flatMap((o,n)=>n===0?oe(o):[ve,...oe(o)])}var le=612,ne=792,A=54,ge=11,St=14;async function Ko(e){let{PDFDocument:t,StandardFonts:o}=await D(),n=await t.create(),s=await n.embedFont(o.Helvetica),r=le-A*2,i=n.addPage([le,ne]),a=ne-A,p=()=>{i=n.addPage([le,ne]),a=ne-A};for(let c of e){if(c===ve){p();continue}let d="";for(let l of c.split(/\s+/).filter(Boolean)){let h=d?`${d} ${l}`:l;d&&s.widthOfTextAtSize(h,ge)>r?(a<A&&p(),i.drawText(d,{x:A,y:a,size:ge,font:s}),a-=St,d=l):d=h}d&&(a<A&&p(),i.drawText(d,{x:A,y:a,size:ge,font:s}),a-=St)}return n.save()}async function Yo(e){let{Document:t,Packer:o,PageBreak:n,Paragraph:s}=await He(),r=e.map(a=>a===ve?new s({children:[new n]}):new s(a)),i=new t({sections:[{children:r}]});return o.toBuffer(i)}var Zo=new Set(["docx","doc","pdf"]),Xo=new Set(["docx","pdf"]),Qo=new Set(["convert"]),jo={code:"word-basic-fidelity",message:"Converted with basic formatting only \u2014 tables, images, and complex layouts weren't preserved. Install LibreOffice for full-fidelity conversion: brew install --cask libreoffice"};function en(e=process.platform){return e!=="win32"?jo:{code:"word-basic-fidelity",message:"Converted with basic formatting only \u2014 tables, images, and complex layouts weren't preserved. Install LibreOffice from libreoffice.org for full-fidelity conversion."}}function tn(e,t,o,n=process.platform){return[`-env:UserInstallation=${n==="win32"?Bo(he.join(e,"profile"),{windows:!0}).href:`file://${e}/profile`}`,"--headless","--convert-to",o,"--outdir",e,t]}async function on(e,t,o){let n=await Ao(Ft(Mo(),"forge-word-"));try{await we(e,tn(n,t,o),{timeout:12e4});let s=Oo(t,To(t));return await ye(Ft(n,`${s}.${o}`))}finally{await _o(n,{recursive:!0,force:!0})}}async function nn(e,t){if(e.op!=="convert")throw new Error(`the word engine cannot ${e.op}`);let o=e.sources[0];if(o.kind!=="document")throw new Error("the word engine can only convert a document source");if(o.encrypted)throw B(o.path);t({phase:"reading"});let n=await Vo();t({phase:"encoding"});let s=[],r;try{if(n!==void 0)r=await on(n,o.path,e.target);else{let a=await Ho(o);r=e.target==="pdf"?await Ko(a):await Yo(a),s.push(en())}}catch(a){throw L(o.path,a)}t({phase:"writing"});let i=await E(e.outputs[0],r);return{job:e,outputBytes:i,warnings:s}}var It={id:"word",reads:Zo,writes:Xo,ops:Qo,probe:Wo,run:nn};var be=[Ze,wt,yt,Pt,It,at,rt];function hr(e){if(e.op==="convert"){let t=e.sources[0].format;return be.find(o=>o.reads.has(t)&&o.writes.has(e.target))}return be.find(t=>t.ops.has(e.op))}async function wr(e){let t;for(let o of be)try{return await o.probe(e)}catch(n){T(t)||(t=n)}throw t}export{zn as a,vt as b,Un as c,bt as d,ot as e,rt as f,be as g,hr as h,wr as i};
@@ -1,4 +0,0 @@
1
- import { createRequire as __forgeCreateRequire } from 'node:module';
2
- const require = __forgeCreateRequire(import.meta.url);
3
- import{a as k}from"./chunk-HON4OV7M.js";import{b as p}from"./chunk-M66BUNYO.js";import{mkdir as A,readFile as O,rename as M,unlink as T,writeFile as D}from"node:fs/promises";import{homedir as F}from"node:os";import{dirname as I,join as S}from"node:path";var C=e=>/^[A-Za-z0-9][A-Za-z0-9-]*$/.test(e),a=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),u=e=>typeof e=="number"&&Number.isInteger(e)&&e>0;function B(e){if(!(!a(e)||Object.keys(e).length!==1)){if(u(e.width))return{width:e.width};if(u(e.height))return{height:e.height};if(u(e.percent))return{percent:e.percent}}}function R(e){if(!a(e))return;let t={};if(e.to!==void 0){if(typeof e.to!="string"||!p(e.to))return;t.to=e.to}if(e.quality!==void 0){if(!u(e.quality)||e.quality>100)return;t.quality=e.quality}if(e.maxBytes!==void 0){if(!u(e.maxBytes))return;t.maxBytes=e.maxBytes}if(e.resize!==void 0){let n=B(e.resize);if(!n)return;t.resize=n}for(let n of["trim","sharpen","removeBackground"])if(e[n]!==void 0){if(typeof e[n]!="boolean")return;t[n]=e[n]}if(e.crop!==void 0){if(!a(e.crop)||!u(e.crop.w)||!u(e.crop.h))return;t.crop={w:e.crop.w,h:e.crop.h}}if(e.boost!==void 0){if(e.boost!==2&&e.boost!==3&&e.boost!==4)return;t.boost=e.boost}if(e.behind!==void 0){if(e.behind!=="white"&&e.behind!=="black")return;t.behind=e.behind}return t}function b(e){if(!a(e)||typeof e.name!="string"||!C(e.name)||typeof e.saveTo!="string"||e.saveTo.trim()==="")return;let t=R(e.steps);if(t)return{name:e.name,steps:t,saveTo:e.saveTo}}var q={white:"#ffffff",black:"#000000"};function U(e,t){let n=[];e.removeBackground&&n.push({kind:"cutout"}),e.boost?n.push({kind:"boost",scale:e.boost}):e.sharpen&&n.push({kind:"boost",scale:1});let i=[];e.trim&&i.push({kind:"cut",trim:!0}),e.crop&&i.push({kind:"cut",crop:e.crop});let s=e.to??t,r={kind:"encode",target:s};if(e.quality!==void 0&&!e.maxBytes&&(r.quality=e.quality),e.maxBytes&&(r.maxBytes=e.maxBytes),e.resize&&(r.resize=e.resize),n.length===0){let o=i.pop();o?.kind==="cut"&&(o.trim&&(r.trim=!0),o.crop&&(r.crop=o.crop))}if(r.maxBytes&&(r.trim||r.crop||r.resize)){let{trim:o,crop:m,resize:y}=r;i.push({kind:"cut",...o?{trim:o}:{},...m?{crop:m}:{},...y?{resize:y}:{}}),delete r.trim,delete r.crop,delete r.resize}if(e.removeBackground&&!p(s)?.hasAlpha&&(r.background=q[e.behind??"white"]),i.length===0&&n.length===0&&Object.keys(r).length===2&&e.to===void 0)return[];let d=i.filter(o=>o.kind==="cut"&&o.resize);return[...i.filter(o=>!d.includes(o)),...n,...d,r]}import{execFileSync as E}from"node:child_process";import{homedir as x}from"node:os";import{join as P}from"node:path";var N={Desktop:"[Environment]::GetFolderPath('Desktop')",Downloads:"(Get-ItemProperty 'HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders').'{374DE290-123F-4565-9164-39C4925E467B}'"};function j(e){try{let n=E("powershell.exe",["-NoProfile","-NonInteractive","-Command",`[Console]::OutputEncoding=[Text.Encoding]::UTF8; ${N[e]}`],{encoding:"buffer",timeout:5e3,stdio:["ignore","pipe","ignore"]}).toString("utf8").trim();return n.length>0?n:void 0}catch{return}}var w=new Map;function l(e,t=process.platform,n=j){if(t!=="win32")return P(x(),e);let i=w.get(e);if(i!==void 0)return i;let r=n(e)?.replace(/%([^%]+)%/g,(g,o)=>process.env[o]??g),d=(r!==void 0&&!r.includes("%")?r:void 0)??P(x(),e);return w.set(e,d),d}var f={defaultOutput:"~/Desktop",quality:80};function h(){return S(k(),"forge","config.json")}function ee(e,t=process.platform){if(t==="win32"){if(e==="~/Desktop")return l("Desktop",t);if(e==="~/Downloads")return l("Downloads",t)}return e==="~"?F():e.startsWith("~/")?S(F(),e.slice(2)):e}function z(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function $(e){let t={...f},n=[];if(e.theme!==void 0&&(e.theme==="dark"||e.theme==="light"?t.theme=e.theme:n.push("theme")),e.defaultOutput!==void 0&&(typeof e.defaultOutput=="string"&&e.defaultOutput.trim().length>0?t.defaultOutput=e.defaultOutput:n.push("defaultOutput")),e.quality!==void 0){let i=e.quality;typeof i=="number"&&Number.isInteger(i)&&i>=1&&i<=100?t.quality=i:n.push("quality")}if(e.updateCheck!==void 0&&(typeof e.updateCheck=="boolean"?t.updateCheck=e.updateCheck:n.push("updateCheck")),e.rightClickMenu!==void 0&&(typeof e.rightClickMenu=="boolean"?t.rightClickMenu=e.rightClickMenu:n.push("rightClickMenu")),e.searchMac!==void 0&&(typeof e.searchMac=="boolean"?t.searchMac=e.searchMac:n.push("searchMac")),e.lastOutput!==void 0&&(typeof e.lastOutput=="string"&&e.lastOutput.trim().length>0?t.lastOutput=e.lastOutput:n.push("lastOutput")),e.presets!==void 0)if(Array.isArray(e.presets)){let i=e.presets.map(b);t.presets=i.filter(s=>s!==void 0),t.presets.length<i.length&&n.push("presets")}else n.push("presets");return{prefs:t,rejected:n}}async function K(){let e;try{e=await O(h(),"utf8")}catch{return}try{let t=JSON.parse(e);return z(t)?t:void 0}catch{return}}async function te(){let e=h(),t;try{t=await O(e,"utf8")}catch(r){return r.code==="ENOENT"?{prefs:f}:{prefs:f,warning:`Could not read the config at ${e} \u2014 using defaults.`}}let n;try{n=JSON.parse(t)}catch{return{prefs:f,warning:`The config at ${e} is not valid JSON \u2014 using defaults.`}}if(!z(n))return{prefs:f,warning:`The config at ${e} is not an object \u2014 using defaults.`};let{prefs:i,rejected:s}=$(n);return s.length===0?{prefs:i}:{prefs:i,warning:`Ignored invalid config ${s.length===1?"setting":"settings"}: ${s.join(", ")}.`}}async function ne(e){let t=h();await A(I(t),{recursive:!0});let i={...await K()??{}};for(let[r,c]of Object.entries(e))c!==void 0&&(i[r]=c);let s=`${t}.${process.pid}.tmp`;try{await D(s,`${JSON.stringify(i,null,2)}
4
- `,"utf8"),await M(s,t)}catch(r){throw await T(s).catch(()=>{}),r}}export{U as a,l as b,f as c,h as d,ee as e,te as f,ne as g};
@@ -1,3 +0,0 @@
1
- import { createRequire as __forgeCreateRequire } from 'node:module';
2
- const require = __forgeCreateRequire(import.meta.url);
3
- import{win32 as r}from"node:path";function o(n,e=process.platform){return e==="win32"?r.basename(n):n.split("/").pop()}export{o as a};
@@ -1,3 +0,0 @@
1
- import { createRequire as __forgeCreateRequire } from 'node:module';
2
- const require = __forgeCreateRequire(import.meta.url);
3
- import{i as F}from"./chunk-LNB5D67B.js";import{a as y}from"./chunk-QR6QHTC3.js";import{i as h}from"./chunk-6L6C3GJU.js";import{b as g}from"./chunk-EXLXSKRH.js";import{d as b}from"./chunk-3UEQ2OX6.js";import{a as u}from"./chunk-M66BUNYO.js";import{existsSync as I}from"node:fs";import{open as k,readdir as w,stat as K}from"node:fs/promises";import{basename as A,dirname as j,extname as S,join as v,resolve as R}from"node:path";function M(e){return e.startsWith(".")||/\.(crdownload|part|download|tmp)$/i.test(e)}function O(e){return e.kind==="image"?"images":e.format==="pdf"?"pdfs":"documents"}var $=new Set(Object.values(u).flatMap(e=>e.extensions));async function E(e){let r=await k(e,"r"),n=Buffer.alloc(4096),i=0;try{i=(await r.read(n,0,n.length,0)).bytesRead}finally{await r.close()}let t=n.subarray(0,i),o=(c,a)=>t.subarray(c,c+a).toString("latin1");return o(4,4)==="ftyp"?/^(M4A |M4B |M4P )$/.test(o(8,4))?"audio":"video":t[0]===26&&t[1]===69&&t[2]===223&&t[3]===163?"video":o(0,4)==="RIFF"?o(8,4)==="WAVE"?"audio":o(8,3)==="AVI"?"video":"other":t[0]===0&&t[1]===0&&t[2]===1&&(t[3]===186||t[3]===179)?"video":o(0,3)==="ID3"||o(0,4)==="fLaC"||o(0,4)==="OggS"||o(0,4)==="FORM"&&/^AIF[FC]$/.test(o(8,4))||t[0]===255&&t[1]!==void 0&&(t[1]&224)===224?"audio":i>0&&!t.includes(0)&&N(t)?"text":"other"}function N(e){try{return new TextDecoder("utf-8",{fatal:!0}).decode(e,{stream:!0}),!0}catch{return!1}}var x=["images","pdfs","documents","videos","audio","other"];function q(e,r){if(e==="videos"||e==="audio")return"not yet supported";if(e==="other")return r.every(n=>n==="text")?r.length===1?"a text file":"text files":"not supported"}async function G(e){let r=R(e),n=await w(r,{withFileTypes:!0}),i=[],t=[],o=new Map,c=[],a=0;for(let f of n.sort((d,s)=>d.name.localeCompare(s.name))){if(!f.isFile()||M(f.name))continue;let d=v(r,f.name);c.push(d);let s=await D(d);if(s.kind==="source")i.push(s.source),a+=s.source.bytes;else if(s.kind==="failed")t.push(s.failure),a+=s.bytes;else{let p=s.kind,m=o.get(p)??{bytes:0,sniffed:[]};m.bytes+=s.bytes,m.sniffed.push(s.sniffed),o.set(p,m),a+=s.bytes}}let l=[];for(let f of x){let d=i.filter(s=>O(s)===f);d.length>0&&l.push({id:f,count:d.length,bytes:d.reduce((s,p)=>s+p.bytes,0),sources:d})}l.sort((f,d)=>d.count-f.count);for(let f of x){let d=o.get(f);if(!d)continue;let s=q(f,d.sniffed);l.push({id:f,count:d.sniffed.length,bytes:d.bytes,sources:[],...s===void 0?{}:{why:s}})}return{dir:r,sources:i,failures:t,kinds:l,bytes:a,paths:c}}async function D(e){let r=()=>K(e).then(n=>n.size,()=>0);try{let n=await h(e);if(n.kind==="media"){let i=u[n.format].media==="video";return{kind:i?"videos":"audio",sniffed:i?"video":"audio",bytes:n.bytes}}return{kind:"source",source:n}}catch(n){let i=await r(),t=await E(e).catch(()=>"other");if(t==="video"||t==="audio")return{kind:t==="video"?"videos":"audio",sniffed:t,bytes:i};if($.has(S(e).toLowerCase())){let o=b(n)?n:void 0;if(o)return{kind:"failed",failure:{path:e,error:o},bytes:i}}return{kind:"other",sniffed:t,bytes:i}}}function T(e){let r=new Set(e.flatMap(n=>y(n).filter(i=>i!==n.format)));return Object.keys(u).filter(n=>r.has(n))}function H(e,r){let n=T(e),i=e[0],t=i?.kind==="image"?"webp":i?.format==="pdf"?"png":void 0,o=t&&n.includes(t)?t:n[0];if(o)return B(e,o,r)}function B(e,r,n){let i={target:r};return u[r].lossy&&(i.quality=n),e.some(t=>t.kind==="document"&&t.format==="pdf")&&(r==="png"||r==="jpeg")&&(i.dpi=150),i}function Q(e,r,n,i){if(e.format===r.target)return{left:`already ${u[r.target].label}`};if(!y(e).includes(r.target))return{left:`can\u2019t become ${u[r.target].label}`};let[t]=F.plan([e],{target:r.target,...r.quality===void 0?{}:{quality:r.quality},...r.dpi===void 0?{}:{dpi:String(r.dpi)},pages:"all",...i===void 0?{}:{destination:i}});if(t?.op!=="convert")return{left:"not supported"};if(t.outputs.some(o=>I(o)&&!n.has(o)))return{left:"already converted"};t.outputs=t.outputs.map(o=>C(o,n));for(let o of t.outputs)n.add(o);return{job:t}}function C(e,r){if(!r.has(e))return e;let n=S(e),i=A(e,n);for(let t=1;;t++){let o=v(j(e),g(i,` (${t})${n}`));if(!r.has(o)&&!I(o))return o}}export{M as a,O as b,E as c,G as d,D as e,T as f,H as g,B as h,Q as i};
@@ -1,3 +0,0 @@
1
- import { createRequire as __forgeCreateRequire } from 'node:module';
2
- const require = __forgeCreateRequire(import.meta.url);
3
- import{c as x}from"./chunk-M66BUNYO.js";import{existsSync as l,statSync as h}from"node:fs";import{basename as f,dirname as E,extname as a,isAbsolute as F,join as o,relative as R,resolve as s,sep as k}from"node:path";function y(t){return t.endsWith("/")||t.endsWith(k)||l(t)&&h(t).isDirectory()?!0:a(t)===""}var O=255;function b(t,r){return r==="darwin"||r==="win32"?t.length:Buffer.byteLength(t)}function c(t,r,e=process.platform){if(b(t+r,e)<=O)return t+r;let n="";for(let i of t){if(b(n+i+r,e)>O)break;n+=i}return n+r}function j(t,r){if(s(t)===s(r))return!0;try{let e=h(t),n=h(r);return e.dev===n.dev&&e.ino===n.ino}catch{return!1}}function A(t,r){let e=f(t),n=a(e),i=n?e.slice(0,-n.length):e;return c(i,x(r))}function S(t,r,e){if(!e)return t;let n=R(s(e),r);return!n||n.startsWith("..")?t:o(t,n)}function L(t){let r=s(t.sourcePath),e=A(r,t.target);if(!t.output)return o(s(r,".."),e);let n=F(t.output)?t.output:s(t.output);return y(t.output)?o(S(n,s(r,".."),t.sourceRoot),e):s(n)}function D(t){let r=L(t);if(t.output&&!y(t.output))return r;let e=a(r);return o(s(r,".."),c(f(r,e),`-${t.suffix}${e}`))}function J(t){if(!l(t))return t;let r=s(t,".."),e=f(t),n=a(e),i=n?e.slice(0,-n.length):e;for(let u=1;u<1e4;u++){let g=o(r,c(i,` (${u})${n}`));if(!l(g))return g}throw new Error(`no free name beside ${e}`)}function p(t){let r=s(t,".."),e=f(t),n=a(e);return{dir:r,stem:n?e.slice(0,-n.length):e,ext:n||".pdf"}}function w(t,r){let{dir:e,stem:n,ext:i}=p(s(t));return o(e,c(n,`-${r}${i}`))}function T(t,r){let{dir:e,stem:n,ext:i}=p(s(t)),u=String(r).length;return Array.from({length:r},(g,m)=>o(e,c(n,`-${String(m+1).padStart(u,"0")}${i}`)))}function z(t,r,e,n,i){let{stem:u}=p(s(t)),g=n?S(s(n),s(t,".."),i):s(t,".."),m=x(e),P=String(Math.max(1,...r.map(d=>d+1))).length,I=r.map(d=>o(g,c(u,`-${String(d+1).padStart(P,"0")}${m}`))),[$,...v]=I;if($===void 0)throw new Error("rasterOutputPaths requires at least one selected page");return[$,...v]}function B(t,r,e){if(!e)return[w(t,"extract")];let{dir:n,stem:i,ext:u}=p(s(t));return r.map(g=>o(n,c(i,`-p${g+1}${u}`)))}function C(t){let r=s(t[0]??"merged.pdf");if(new Set(t.map(n=>s(n,".."))).size===1){let n=s(r,"..");return o(n,c(f(n),"-merged.pdf"))}return w(r,"merged")}function N(t,r,e){let n=r?t.map(u=>o(r,f(u))):t,[i]=n;return!e||n.length!==1||i===void 0?n:[o(E(i),`${e}${a(i)}`)]}function G(t,r,e){return N([t],r,e)[0]??t}export{y as a,c as b,j as c,L as d,D as e,J as f,w as g,T as h,z as i,B as j,C as k,N as l,G as m};
@@ -1,19 +0,0 @@
1
- import { createRequire as __forgeCreateRequire } from 'node:module';
2
- const require = __forgeCreateRequire(import.meta.url);
3
- import{a as $,h as lt,i as D}from"./chunk-IWFVEMDN.js";import{b as x,c as R,d as H,f as v,g as P,h as X}from"./chunk-QVACE4IE.js";import{i as it}from"./chunk-6L6C3GJU.js";import{D as at,E as st,v as ot}from"./chunk-KAHWYWNT.js";import{d as tt,m as et,o as nt,u as rt}from"./chunk-3UEQ2OX6.js";import{a as Z}from"./chunk-M66BUNYO.js";var xt=[[15,"rose"],[45,"red"],[70,"orange"],[95,"amber"],[120,"yellow"],[140,"lime"],[165,"green"],[185,"teal"],[215,"cyan"],[250,"sky"],[280,"blue"],[295,"indigo"],[315,"violet"],[340,"purple"],[355,"pink"],[360,"rose"]];function w(t){let{C:e,h:n}=v(R(t));return e<.03?"grey":_(n)}function _(t){let e=(t%360+360)%360;return(xt.find(([n])=>e<n)??[360,"rose"])[1]}var Tt=["full","mono","analogous","opposite","split","triad","pastel"],ct={full:"Full set",mono:"Monochromatic",analogous:"Analogous",opposite:"Complementary",split:"Split complementary",triad:"Triadic",pastel:"Pastel"},B={brightness:0,saturation:0,hue:0,contrast:0},At=t=>!!(t.brightness||t.saturation||t.hue||t.contrast),G=[{name:"red",hex:{r:251,g:44,b:54},role:"danger"},{name:"orange",hex:{r:255,g:105,b:0}},{name:"yellow",hex:{r:239,g:177,b:0},role:"warning"},{name:"green",hex:{r:0,g:201,b:80},role:"success"},{name:"teal",hex:{r:0,g:187,b:167}},{name:"blue",hex:{r:43,g:127,b:255},role:"info"},{name:"purple",hex:{r:173,g:70,b:255}},{name:"pink",hex:{r:246,g:51,b:154}}],$t={analogous:[-30,0,30],opposite:[0,180],split:[0,150,210],triad:[0,120,240]},wt=.553,yt=.024,b=t=>v(R(t)),C=(t,e,n)=>H(P({L:t,C:Math.max(0,e),h:(n+360)%360})),K=(t,e)=>(t-e+540)%360-180;function ht(t,e,n){let r=P({L:t,C:e,h:n}),a=R(H(r));return Math.hypot(a.L-r.L,a.a-r.a,a.b-r.b)<.003}function L(t,e){let n=0,r=.4;for(let a=0;a<30;a++){let o=(n+r)/2;ht(t,o,e)?n=o:r=o}return n}function W({L:t,C:e,h:n}){let r=L(t,n);return r>0?Math.min(1,e/r):0}var A=(t,e)=>e>=0?t+(.98-t)*(e/100):t+(t-.05)*(e/100),q=(t,e,n)=>n>=0?t+(Math.max(t,e)-t)*(n/100):t*(1+n/100);function T(t,e){if(!(e.brightness||e.saturation||e.hue))return t;let{L:n,C:r,h:a}=b(t),o=A(n,e.brightness),i=(a+e.hue+360)%360,l=q(r,L(o,i),e.saturation);for(let s=0;s<40&&l>0&&!ht(o,l,i);s++)l-=.005;return C(o,l,i)}function k(t,e,n,r){let a=A(t,r.brightness),o=(n+r.hue+360)%360,i=L(a,o);return C(a,Math.min(i,q(e,i,r.saturation)),o)}function Y(t,e,n){if(!e)return t;let r=b(t[n].rgb).L;return t.map((a,o)=>{if(o===n)return a;let i=b(a.rgb),l=Math.max(.02,Math.min(.995,r+(i.L-r)*(1+e/100))),s=C(l,Math.min(i.C,L(l,i.h)),i.h);return{...a,rgb:s,hex:x(s)}})}function Et(t,e,n,r){return Y(t(T(e,n)),n.contrast,r)}function ut(t,e){let n=b(t),r=G.map(s=>b(s.hex)),a=0;r.forEach((s,c)=>{Math.abs(K(n.h,s.h))<Math.abs(K(n.h,r[a].h))&&(a=c)});let o=r[a],i=Math.max(-10,Math.min(10,K(n.h,o.h)/2)),l=W(n);return G.map((s,c)=>{if(c===a)return{name:s.name,role:s.role,rgb:T(t,e),yours:!0};let h=r[c],p=n.L>=o.L?h.L+(n.L-o.L)*(1-h.L)/(1-o.L):h.L*n.L/o.L,f=A(p,e.brightness),g=(h.h+i+e.hue+360)%360,d=L(f,g),u=Math.min(1,W(h)),S=Math.min(d,q(l*u*d,d,e.saturation));return{name:s.name,role:s.role,rgb:C(f,S,g),yours:!1}})}function St(t,e,n){let r=b(t),a=w(t);if(e==="mono")return[{name:a,rgb:T(t,n),yours:!0},{name:`${a} soft`,rgb:k(r.L,r.C*.5,r.h,n),yours:!1},{name:`${a} dusty`,rgb:k(r.L,r.C*.22,r.h,n),yours:!1}];if(e==="pastel")return ut(t,B).map((l,s)=>{let c=b(l.rgb),h=c.C<.01?b(G[s].hex).h:c.h;return{...l,rgb:k(.86,Math.min(.1,L(.86,h))*.85,h,n)}});let o=W(r);return($t[e]??[0]).map(l=>{if(l===0)return{name:a,rgb:T(t,n),yours:!0};let s=(r.h+l+360)%360,c=o*L(r.L,s);return{name:o>0?_(s):w(k(r.L,c,s,B)),rgb:k(r.L,c,s,n),yours:!1}}).sort((l,s)=>Number(s.yours)-Number(l.yours))}function Lt(t,e,n){let r=b(t).h+e.hue,a=Math.max(0,yt*(1+e.saturation/100));return D(C(A(wt,e.brightness),a,r),n)}function Ot(t,e,n=B,r=$){let a=lt(r);return{rows:(e==="full"?ut(t,n):St(t,e,n)).map(({name:l,role:s,rgb:c,yours:h})=>({name:l,...s?{role:s}:{},steps:Y(D(c,r),n.contrast,a),yours:h})),neutral:Y(Lt(t,n,r),n.contrast,a)}}var M=t=>t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),E=t=>t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"colour",y='font-family="Inter"',O=t=>`${t[0]?.toUpperCase()??""}${t.slice(1)}`;function mt(t){let e=t==="dark";return{ink:e?"#FAFAFA":"#111111",grey:e?"#A1A1AA":"#71717A",edge:e?"#FFFFFF":"#000000",paper:e?"#18181B":"#FFFFFF"}}var Mt=`<defs><pattern id="checker" width="16" height="16" patternUnits="userSpaceOnUse"><rect width="16" height="16" fill="#FFFFFF"/><rect width="8" height="8" fill="#E5E5E5"/><rect x="8" y="8" width="8" height="8" fill="#E5E5E5"/></pattern></defs>
4
- `;function I(t,e,n,r="light"){let{ink:a,grey:o,edge:i,paper:l}=mt(r),s=n.length>8?64:104,c=10,h=48+n.length*s+Math.max(0,n.length-1)*c,p=84+s+56,f=s>80?12:10,g=`<text id="title" x="24" y="38" ${y} font-size="15" font-weight="600" fill="${a}">${M(t)}</text><text id="subtitle" x="24" y="58" ${y} font-size="12" fill="${o}">${M(e)}</text>`,d=n.map((u,S)=>`<g id="${E(u.id)}" transform="translate(${24+S*(s+c)} 80)">`+(u.alpha===void 0?"":`<rect id="checker" width="${s}" height="${s}" rx="${f}" fill="url(#checker)"/>`)+`<rect id="swatch" width="${s}" height="${s}" rx="${f}" fill="${u.hex}"`+(u.alpha===void 0?"":` fill-opacity="${u.alpha.toFixed(3)}"`)+` stroke="${i}" stroke-opacity="0.08"/><text id="name" x="1" y="${s+22}" ${y} font-size="13" font-weight="600" fill="${a}">${M(u.name)}</text><text id="value" x="1" y="${s+40}" ${y} font-size="11" fill="${o}">${M(u.value)}</text></g>`).join(`
5
- `);return`<svg xmlns="http://www.w3.org/2000/svg" width="${h}" height="${p}" viewBox="0 0 ${h} ${p}">
6
- `+(n.some(u=>u.alpha!==void 0)?Mt:"")+`<g id="${E(t)}">
7
- <rect id="card" width="${h}" height="${p}" rx="0" fill="${l}"/>
8
- ${g}
9
- ${d}
10
- </g>
11
- </svg>`}function Ht(t,e,n="light",r){let a=t.replace(/\.[^.]+$/,""),o=e.length;return I(t,r?`${o} shade${o===1?"":"s"} of ${r}`:`${o} colour${o===1?"":"s"}, most of the image first`,e.map((i,l)=>({id:`${a}-${l+1}`,name:i.hex,value:X(i.rgb),hex:i.hex})),n)}function N(t){if(t.set==="radix")return"Radix 1\u201312";if(t.set==="even")return`${t.start}\u2013${t.end}, ${t.count} even steps`;let e=$;return t.start===e.start&&t.end===e.end?"50\u2013950":`Tailwind ${t.start}\u2013${t.end}`}function Pt(t,e,n="light",r=$){let a=w(t);return I(O(a),`from ${x(t)} \xB7 ${N(r)} in OKLCH`,e.map(o=>({id:`${a}-${o.step}`,name:String(o.step),value:o.hex,hex:o.hex})),n)}function Dt(t,e,n,r=$,a="light"){let{ink:o,grey:i,edge:l,paper:s}=mt(a),c=`${O(w(t))} palette`,h=`from ${x(t)} \xB7 ${ct[n]} \xB7 ${N(r)} in OKLCH`,p=[...e.rows.map(m=>({name:m.name,steps:m.steps})),{name:"neutral",steps:e.neutral}],f=p[0]?.steps.map(m=>m.step)??[],g=44,d=6,u=g+10,S=92,z=24+Math.max(92,...p.map(m=>m.name.length*8+12)),gt=z+f.length*g+Math.max(0,f.length-1)*d+24,U=Math.max(gt,48+Math.ceil(h.length*6.5)),j=S+p.length*u+24+10,pt=`<text id="title" x="24" y="38" ${y} font-size="15" font-weight="600" fill="${o}">${M(c)}</text><text id="subtitle" x="24" y="58" ${y} font-size="12" fill="${i}">${M(h)}</text>`,ft=f.map((m,F)=>`<text id="step-${m}" x="${z+F*(g+d)+1}" y="${S-10}" ${y} font-size="11" font-weight="600" fill="${i}">${m}</text>`).join(""),dt=p.map((m,F)=>{let J=S+F*u+(F===p.length-1?10:0),Q=E(m.name);return`<g id="${Q}"><text id="name" x="24" y="${J+g/2+4}" ${y} font-size="13" font-weight="600" fill="${o}">${M(m.name)}</text>`+m.steps.map((V,bt)=>`<g id="${Q}-${V.step}"><rect id="swatch" x="${z+bt*(g+d)}" y="${J}" width="${g}" height="${g}" rx="8" fill="${V.hex}" stroke="${l}" stroke-opacity="0.08"/></g>`).join("")+"</g>"}).join(`
12
- `);return`<svg xmlns="http://www.w3.org/2000/svg" width="${U}" height="${j}" viewBox="0 0 ${U} ${j}">
13
- <g id="${E(c)}">
14
- <rect id="card" width="${U}" height="${j}" rx="0" fill="${s}"/>
15
- ${pt}
16
- <g id="steps">${ft}</g>
17
- ${dt}
18
- </g>
19
- </svg>`}function _t(t,e,n,r="light",a=$){return I(`${O(w(t))} neutral`,`from ${x(t)} \xB7 ${n} tint \xB7 ${N(a)} in OKLCH`,e.map(o=>({id:`neutral-${o.step}`,name:String(o.step),value:o.hex,hex:o.hex})),r)}function Kt(t,e,n,r="light",a=$){let o=w(t);return I(`${O(o)} alpha`,`from ${x(t)} \xB7 over ${n} \xB7 ${N(a)}`,e.map(i=>({id:`${o}-alpha-${i.step}`,name:String(i.step),value:i.hex8,hex:x(i.rgb),alpha:i.a})),r)}async function Qt(t,e=192){let n=await it(t);if(n.kind!=="image")throw et(t,`a ${Z[n.format].label}`);let r=n.format==="heic";if(r&&!await at())throw nt(t);let a=r?await st(t):void 0;try{let i=(await ot())(a?.path??t,{animated:!1}),{data:l,info:s}=await(r?i:i.rotate()).resize(e,e,{fit:"inside",withoutEnlargement:!0}).ensureAlpha().raw().toBuffer({resolveWithObject:!0});return{source:n,pixels:{width:s.width,height:s.height,rgba:new Uint8Array(l.buffer,l.byteOffset,l.length)}}}catch(o){throw tt(o)?o:rt(t,o)}finally{await a?.cleanup()}}export{Tt as a,ct as b,B as c,At as d,Et as e,Ot as f,I as g,Ht as h,Pt as i,Dt as j,_t as k,Kt as l,Qt as m};
@@ -1,3 +0,0 @@
1
- import { createRequire as __forgeCreateRequire } from 'node:module';
2
- const require = __forgeCreateRequire(import.meta.url);
3
- import{b as v,d as a,e as $,g as B,i as Q}from"./chunk-LNB5D67B.js";import{a as S}from"./chunk-BZXDNDPG.js";import{a as J,j as E,l as I,m as N}from"./chunk-QR6QHTC3.js";import{a as q,b as k,d as C}from"./chunk-6L6C3GJU.js";import{d as M,k as T,s as y}from"./chunk-KAHWYWNT.js";import{b as R,e as d,g as f,h as F,j,k as D,l as g,m as s}from"./chunk-EXLXSKRH.js";import{F as l,t as w}from"./chunk-3UEQ2OX6.js";import{a as u,c as P}from"./chunk-M66BUNYO.js";var b=t=>t.length>0&&t.every(e=>e.kind==="image")?t:void 0;function Pt(t,e){let n=J(t);return n.includes(e)?void 0:w(t,e,n)}function _(t){return{target:t.target??"png",background:typeof t.background=="string"?t.background:"#ffffff",keepMetadata:t.keepMetadata===!0,...typeof t.output=="string"?{output:t.output}:{},...t.roots instanceof Map?{roots:t.roots}:{},...typeof t.quality=="number"?{quality:t.quality}:{}}}var G=()=>({kind:"select",id:"target",label:"Save as",default:"png",choices:[{value:"png",label:"PNG",hint:u.png.hint}]}),pt=t=>t===1?"sharp":`${t}x`,ut=t=>t===1||t===3||t===4?t:2,X={id:"boost",label:"Boost resolution",verb:"Boosting",hint:"sharper, at its size or at 2\xD7, 3\xD7 or 4\xD7",requires:"boost",appliesTo:t=>b(t)!==void 0,unavailable:()=>"images only",options:()=>[{kind:"select",id:"scale",label:"Scale",default:"2",choices:[{value:"1",label:"Sharpen",hint:"the same size, sharper"},{value:"2",label:"2\xD7",hint:"twice the width and height"},{value:"3",label:"3\xD7",hint:"three times the width and height"},{value:"4",label:"4\xD7",hint:"four times the width and height"}]},G()],plan(t,e){let n=b(t);if(!n)return[];let o=_(e),r=ut(Number(e.scale??2));return n.map(i=>({op:"boost",sources:[i],outputs:[d({sourcePath:i.path,target:o.target,suffix:pt(r),...o.output===void 0?{}:{output:o.output},...o.roots?.get(i.path)===void 0?{}:{sourceRoot:o.roots.get(i.path)}})],scale:r,target:o.target,options:{background:o.background,keepMetadata:o.keepMetadata,...o.quality===void 0?{}:{quality:o.quality}}}))}},H={id:"remove-background",label:"Remove background",verb:"Removing",hint:"cut out the subject",requires:"remove-background",appliesTo:t=>b(t)!==void 0,unavailable:()=>"images only",options:()=>[G()],plan(t,e){let n=b(t);if(!n)return[];let o=_(e);return n.map(r=>({op:"remove-background",sources:[r],outputs:[d({sourcePath:r.path,target:o.target,suffix:"cutout",...o.output===void 0?{}:{output:o.output},...o.roots?.get(r.path)===void 0?{}:{sourceRoot:o.roots.get(r.path)}})],target:o.target,options:{background:o.background,keepMetadata:o.keepMetadata,...o.quality===void 0?{}:{quality:o.quality}}}))}};import{dirname as ct}from"node:path";var mt=t=>u[t.format].media==="video",dt=t=>t.length===1&&t[0]?.kind==="image"?t[0]:void 0,lt=t=>t.length===1&&t[0]?.kind==="document"?t[0]:void 0,ft="-small",c={min:30,max:100,step:35},gt=t=>{let e=Math.ceil((t-c.min)/c.step);return Math.min(c.max,c.min+Math.max(0,e)*c.step)},U={id:"compress",label:"Compress",verb:"Compressing",hint:"make it smaller",appliesTo:t=>{if(t.length===1&&t[0]?.kind==="media")return!0;let e=dt(t);if(e!==void 0){let o=u[e.format];return o.lossy||o.quantisable===!0}return(lt(t)?.images?.compressible??0)>0},options(t,e,n){let o=t[0];if(!o)return[];let r=[{kind:"select",id:"mode",label:`Compress ${S(o.path)??"this file"}`,choices:[o.kind==="media"?{value:"quality",label:"By quality"}:{value:"quality",label:"By quality",hint:"pick a level, see the result"},{value:"size",label:"To a target size",hint:"smallest quality that fits"}],default:"quality"}];if(e.mode==="quality"&&o.kind==="media"&&!mt(o))r.push({kind:"slider",id:"bitrate",label:"Quality",min:32,max:320,step:32,default:96});else if(e.mode==="quality"){let i=o.kind==="image"&&u[o.format].quantisable===!0;r.push(i?{kind:"slider",id:"quality",label:"Quality",...c,default:gt(n.quality),points:!0}:{kind:"slider",id:"quality",label:"Quality",min:1,max:100,step:5,default:n.quality})}else if(e.mode==="size")r.push({kind:"text",id:"size",label:"Target size",placeholder:"e.g. 500kb or 2mb"});else return r;return r.push(v(o,n)),r},plan(t,e){let n=e.mode;if(n!=="quality"&&n!=="size")throw l(`compressAction.plan() needs a mode of "quality" or "size", got ${JSON.stringify(n)}.`,"This is a caller bug, not a user-facing condition: walk options() before calling plan().");let o=t[0];if(!o)return[];let r=(S(o.path)??"file").replace(/\.[^.]+$/,""),i=typeof e.destination=="string"?e.destination:ct(o.path),p=o.kind==="media"?$(o.format):o.format,st=`${i}/${R(r,`${ft}${P(p)}`)}`,z=o.kind==="media"?B(e):void 0;return[{op:"convert",sources:[o],target:p,outputs:[st],options:{background:"#ffffff",keepMetadata:!1,...n==="quality"&&typeof e.quality=="number"?{quality:e.quality}:{},compress:{dither:e.dither===!0},...z?{media:z}:{}}}]}};function bt(t,e){if(e.crop){let n=T(e.crop.aspect);if(!e.resize)return n;let o=e.crop.box??M(t,e.crop.aspect);return`${n}-${I(y(o,e.resize))}`}return e.trim&&e.resize?`trimmed-${N(e.resize)}`:e.resize?I(y(t,e.resize)):"trimmed"}function ht(t,e){if(e.trim&&e.crop)throw new Error("planEdit cannot trim and crop the same image");return t.map(n=>{let o=e.target??E(n),r={background:e.background,keepMetadata:e.keepMetadata,...e.quality===void 0?{}:{quality:e.quality},...e.trim?{trim:!0}:{},...e.resize?{resize:e.resize}:{},...e.crop?{crop:e.crop}:{}},i=e.roots?.get(n.path),p=d({sourcePath:n.path,target:o,suffix:bt(n,e),...e.output===void 0?{}:{output:e.output},...i===void 0?{}:{sourceRoot:i}});return{op:"convert",sources:[n],outputs:[s(p,a(e.destination),a(e.name))],target:o,options:r}})}var x=t=>t.length>0&&t.every(e=>e.kind==="image")?t:void 0,yt=t=>typeof t=="object"&&t!==null&&("percent"in t||"width"in t||"height"in t),K=t=>typeof t=="object"&&t!==null&&"aspect"in t&&typeof t.aspect=="object"&&t.aspect!==null&&"w"in t.aspect&&"h"in t.aspect;function A(t,e,n,o){return{id:t,label:e,verb:n,hint:o,appliesTo:r=>x(r)?.every(i=>t==="resize"||i.frames<=1)===!0,unavailable:r=>x(r)?"animated":"images only",options:()=>[],plan(r,i){let p=x(r);return p?t==="crop"&&!K(i.crop)?[]:ht(p,{trim:t==="trim"||i.trim===!0,...yt(i.resize)?{resize:i.resize}:{},...K(i.crop)?{crop:i.crop}:{},...typeof i.target=="string"?{target:i.target}:{},...typeof i.output=="string"?{output:i.output}:{},...i.roots instanceof Map?{roots:i.roots}:{},destination:i.destination,name:i.name,background:typeof i.background=="string"?i.background:"#ffffff",keepMetadata:i.keepMetadata===!0,...typeof i.quality=="number"?{quality:i.quality}:{}}):[]}}}var L=A("trim","Trim edges","Trimming edges","cut empty borders"),V=A("resize","Resize","Resizing","smaller or larger"),W=A("crop","Crop to shape","Cropping","change the shape");var h=t=>t.length===1&&t[0]?.kind==="document"&&t[0].format==="pdf"?t[0]:void 0,Y={id:"split",label:"Split",verb:"Splitting",hint:"into several files",appliesTo:t=>(h(t)?.pages??0)>1,unavailable:t=>h(t)===void 0?"one PDF at a time":"only one page",options(t){let e=h(t);return e?[{kind:"select",id:"mode",label:"How",default:"every-page",choices:[{value:"every-page",label:"Every page",hint:`${e.pages} files`},{value:"every-n",label:"Every N pages",hint:"ask how many"},{value:"points",label:"At points I choose",hint:"grid"}]}]:[]},plan(t,e){let n=h(t);if(!n)return[];let o=Array.isArray(e.cuts)?e.cuts:[],r=C(o,n.pages).length,i=g(F(n.path,r),a(e.destination),a(e.name));return[{op:"split",sources:[n],outputs:i,cuts:o}]}};function Xt(t){return Array.from({length:Math.max(0,t-1)},(e,n)=>n)}function Ht(t,e){if(!Number.isInteger(e)||e<1)throw l("Splitting every N pages needs N to be a whole number, at least 1.");let n=[];for(let o=e;o<t;o+=e)n.push(o-1);return n}var m=t=>t.length===1&&t[0]?.kind==="document"&&t[0].format==="pdf"?t[0]:void 0;function Z(t,e){return Array.isArray(e.pages)?k(e.pages):typeof e.pages=="string"?k(q(e.pages,t.pages)):[]}var tt=t=>({kind:"text",id:"pages",label:"Pages",placeholder:`1-${t.pages}`}),et={id:"extract",label:"Extract",verb:"Extracting",hint:"keep only some pages",appliesTo:t=>m(t)!==void 0,unavailable:()=>"one PDF at a time",options:t=>{let e=m(t);return e?[tt(e),{kind:"select",id:"separate",label:"Output",default:"one",choices:[{value:"one",label:"One file",hint:"all selected pages together"},{value:"many",label:"Separate files",hint:"one per page"}]}]:[]},plan(t,e){let n=m(t);if(!n)return[];let o=Z(n,e),r=e.separate==="many";return[{op:"extract",sources:[n],outputs:g(j(n.path,o,r),a(e.destination),a(e.name)),pages:o,separate:r}]}},ot={id:"delete",label:"Delete",verb:"Deleting",hint:"drop some pages",appliesTo:t=>m(t)!==void 0,unavailable:()=>"one PDF at a time",options:t=>{let e=m(t);return e?[tt(e)]:[]},plan(t,e){let n=m(t);return n?[{op:"delete",sources:[n],outputs:[s(f(n.path,"trimmed"),a(e.destination),a(e.name))],pages:Z(n,e)}]:[]}};var O=t=>t.filter(e=>e.kind==="document"&&e.format==="pdf"),nt={id:"merge",label:"Merge",verb:"Merging",hint:"several files into one",appliesTo:t=>O(t).length>=2&&O(t).length===t.length,unavailable:t=>O(t).length!==t.length?"PDFs only":"needs 2+ files",options:()=>[],plan(t,e){let n=s(D(t.map(o=>o.path)),a(e.destination),a(e.name));return[{op:"merge",sources:t,outputs:[n]}]}};var it=t=>t.length===1&&t[0]?.kind==="document"&&t[0].format==="pdf"?t[0]:void 0,rt={id:"rotate",label:"Rotate",verb:"Rotating",hint:"turn pages",appliesTo:t=>it(t)!==void 0,unavailable:()=>"one PDF at a time",options:()=>[{kind:"select",id:"degrees",label:"Turn",default:"90",choices:[{value:"90",label:"90\xB0 right",hint:"a quarter turn"},{value:"180",label:"180\xB0",hint:"upside down"},{value:"270",label:"90\xB0 left",hint:"a quarter turn back"}]}],plan(t,e){let n=it(t);if(!n)return[];let r=Number(e.degrees??90)/90%4||1;return[{op:"rotate",sources:[n],outputs:[s(f(n.path,"rotated"),a(e.destination),a(e.name))],turns:r}]}};var at=[Q,U,nt,Y,et,ot,rt,L,V,W],de=at.filter(t=>!["convert","compress","trim","resize","crop"].includes(t.id)),kt=[X,H];function le(t,e=new Set){return[...at,...kt.filter(n=>n.requires&&e.has(n.requires))].filter(n=>n.appliesTo(t))}function fe(t,e){return t.appliesTo(e)?void 0:t.unavailable?.(e)}export{Pt as a,X as b,H as c,U as d,ht as e,L as f,V as g,W as h,rt as i,Y as j,Xt as k,Ht as l,at as m,de as n,le as o,fe as p};
@@ -1,3 +0,0 @@
1
- import { createRequire as __forgeCreateRequire } from 'node:module';
2
- const require = __forgeCreateRequire(import.meta.url);
3
- import{b as h,c as S,d as A,e as R,f as T,g}from"./chunk-QVACE4IE.js";import{F as E}from"./chunk-3UEQ2OX6.js";var y={set:"tailwind",start:50,end:950,count:11},O=["tailwind","even","radix"],v=[0,50,100,150,200,250,300,350,400,450],D=[550,600,650,700,750,800,850,900,950,1e3],I=Array.from({length:19},(e,n)=>n+3),$=[20,50,100,150,200,260,330,420,500,560,750,920],N=8;function P({set:e,start:n,end:r,count:o}){if(!O.includes(e))return`The set must be tailwind, even or radix; got ${e}.`;if(e!=="radix"){if(!v.includes(n))return n%50===0?`The start must be from 0 to 450, so the colour (500) stays in the scale; got ${n}.`:`The start must be a multiple of 50; got ${n}.`;if(!D.includes(r))return r%50===0?`The end must be from 550 to 1000, so the colour (500) stays in the scale; got ${r}.`:`The end must be a multiple of 50; got ${r}.`;if(e==="even"&&!I.includes(o))return`An even set has 3 to 21 steps; got ${o}.`}}function d(e){let{set:n,start:r,end:o,count:a}=e;if(n==="radix")return $.map((t,s)=>({step:s+1,at:t}));if(n==="tailwind"){let t=new Set([r,o,500]);for(let s=Math.ceil((r+1)/100)*100;s<o;s+=100)t.add(s);return[...t].sort((s,u)=>s-u).map(s=>({step:s,at:s}))}let i=a-1,f=Math.round(i*(500-r)/(o-r)),c=Math.max(1,Math.min(i-1,f)),p=i-c,b=[];for(let t=0;t<=c;t++)b.push(r+(500-r)*t/c);for(let t=1;t<=p;t++)b.push(500+(o-500)*t/p);for(let t of[10,5,1]){let s=b.map(u=>Math.round(u/t)*t);if(new Set(s).size===s.length)return b.map((u,l)=>({step:s[l],at:u}))}return b.map(t=>({step:t,at:t}))}function _(e){return d(e).map(n=>n.step)}var z=_(y);function K(e){return e.set==="radix"?N:d(e).findIndex(n=>n.at===500)}var W=[[50,1],[100,.86],[200,.68],[300,.46],[400,.22],[500,0]],F=[[500,0],[600,.2],[700,.4],[800,.6],[900,.8],[950,1]];function w(e,n){for(let r=1;r<e.length;r++){let[o,a]=e[r-1],[i,f]=e[r];if(n<=i)return a+(f-a)*(n-o)/(i-o)}return e[e.length-1][1]}var H=.995,U=.35,j=5e-4;function Y(e,n=y){let r=P(n);if(r)throw E(r,"Try: Tailwind, from 50 to 950.");let{L:o,C:a,h:i}=T(S(e)),f=a<j,c=Math.max(.975,o),p=o<.16?.42*o:Math.max(.16,.42*o);return d(n).map(({step:b,at:t})=>{if(t===500)return{step:b,at:t,rgb:{...e},hex:h(e),reference:!0};let s,u;if(t>=50&&t<500){let m=w(W,t);s=o+(c-o)*m,u=a*(1-.88*m)}else if(t<50){let m=(50-t)/50;s=c+(Math.max(H,c)-c)*m,u=a*.12*(1-m)}else if(t<=950){let m=w(F,t);s=o-(o-p)*m,u=a*(1-.45*m)}else{let m=(t-950)/50;s=p*(1-U*m),u=a*.55*(1-.4*m)}for(f&&(u=0);u>0&&!R(g({L:s,C:u,h:i}));)u-=.002;let l=A(g({L:s,C:Math.max(0,u),h:i}));return{step:b,at:t,rgb:l,hex:h(l),reference:!1}})}var x=e=>{let n=e/255;return n<=.04045?n/12.92:((n+.055)/1.055)**2.4},M=({r:e,g:n,b:r})=>.2126*x(e)+.7152*x(n)+.0722*x(r);function L(e,n){let[r,o]=[M(e),M(n)].sort((a,i)=>i-a);return(r+.05)/(o+.05)}function J(e){return e>=7?"AAA":e>=4.5?"AA":e>=3?"large":"fails"}var k={r:255,g:255,b:255},B={r:0,g:0,b:0},C=e=>Math.floor(e*10)/10;function Q(e){return{white:C(L(e,k)),black:C(L(e,B))}}export{y as a,O as b,v as c,D as d,I as e,d as f,_ as g,K as h,Y as i,L as j,J as k,Q as l};
@@ -1,3 +0,0 @@
1
- import { createRequire as __forgeCreateRequire } from 'node:module';
2
- const require = __forgeCreateRequire(import.meta.url);
3
- import{c as h}from"./chunk-YWKMG5WO.js";import{i as P}from"./chunk-6L6C3GJU.js";import{d as y,ga as s}from"./chunk-3UEQ2OX6.js";import{mkdtemp as F,rm as x}from"node:fs/promises";import{tmpdir as z}from"node:os";import{join as v}from"node:path";var f={background:"#ffffff",keepMetadata:!1};function w(e,r,o){switch(e.kind){case"cut":return{op:"convert",sources:[r],outputs:[o],target:"png",options:{...f,...e.trim?{trim:!0}:{},...e.crop?{crop:{aspect:e.crop}}:{},...e.resize?{resize:e.resize}:{}}};case"cutout":return{op:"remove-background",sources:[r],outputs:[o],target:"png",options:f};case"boost":return{op:"boost",sources:[r],outputs:[o],scale:e.scale,target:"png",options:f};case"encode":return{op:"convert",sources:[r],outputs:[o],target:e.target,options:{...f,...e.background?{background:e.background}:{},...e.quality!==void 0?{quality:e.quality}:{},...e.trim?{trim:!0}:{},...e.crop?{crop:{aspect:e.crop}}:{},...e.resize?{resize:e.resize}:{}}}}}async function C(e,r,o,n){let E=n.probe??P,l=await F(v(z(),"forge-preset-")),I={force:n.force,...n.signal?{signal:n.signal}:{},...n.onEvent?{onEvent:n.onEvent}:{}};try{let i=e;for(let[d,t]of r.entries()){let u=d===r.length-1,g=u?o:v(l,`${d}.png`),a=await h([w(t,i,g)],{...I,...u?{}:{force:!0},...u&&t.kind==="encode"&&t.maxBytes?{targetBytes:t.maxBytes}:{}});if(a.cancelled)return{kind:"cancelled"};let m=a.refusals[0];if(m)return{kind:"refused",error:m.error};let p=a.unreachable[0];if(p)return{kind:"unreachable",entry:p};let b=a.failures[0];if(b)return{kind:"failed",pass:t,error:b.error};let c=a.results[0];if(!c)return{kind:"failed",pass:t,error:s(e.path,"no result")};if(u){let j=c.job.op==="convert"?{...c.job,sources:[e]}:c.job;return{kind:"done",result:{...c,job:j}}}let k=await E(g);if(k.kind!=="image")return{kind:"failed",pass:t,error:s(e.path,"not an image")};i=k}return{kind:"failed",pass:{kind:"encode",target:e.format},error:s(e.path,"nothing to run")}}catch(i){return{kind:"failed",pass:r[r.length-1]??{kind:"encode",target:e.format},error:y(i)?i:s(e.path,i)}}finally{await x(l,{recursive:!0,force:!0})}}export{C as a};
@@ -1,3 +0,0 @@
1
- import { createRequire as __forgeCreateRequire } from 'node:module';
2
- const require = __forgeCreateRequire(import.meta.url);
3
- import{a as gt,b as q,d as yt}from"./chunk-SMBK6BTC.js";import{$ as pt,C as ct,F as B,K as ft,X as dt,ba as ut,c as k,ca as mt,d as C,da as lt,e as et,ea as wt,f as rt,g as W,ga as U,h as it,i as nt,j as ot,k as at,l as st,o as I,u as ht,v as j}from"./chunk-3UEQ2OX6.js";import{a as w}from"./chunk-M66BUNYO.js";import{constants as Jt}from"node:fs";import{access as Vt,readFile as Bt,rm as Xt,stat as Zt,writeFile as Gt}from"node:fs/promises";import{dirname as Kt}from"node:path";var Ft=[{w:1,h:1,label:"1:1"},{w:4,h:5,label:"4:5"},{w:16,h:9,label:"16:9"},{w:9,h:16,label:"9:16"}],ue=20,me=10,E=t=>Math.max(1,Math.round(t)),N=(t,e,r)=>Math.min(Math.max(t,e),r);function A(t,e){let r=E(t.width*e.h/e.w),[i,n]=r<=t.height?[t.width,r]:[Math.min(t.width,E(t.height*e.w/e.h)),t.height];return{left:Math.floor((t.width-i)/2),top:Math.floor((t.height-n)/2),width:i,height:n}}var zt=(t,e)=>e.width===t.width&&e.height===t.height;function le(t){return Ft.filter(e=>!zt(t,A(t,e)))}function we(t,e,r,i){let n=A(t,e),o,a;return e.w>=e.h?(o=E(n.width*i/100),a=Math.min(t.height,E(o*e.h/e.w))):(a=E(n.height*i/100),o=Math.min(t.width,E(a*e.w/e.h))),{left:N(Math.round(r.x-o/2),0,t.width-o),top:N(Math.round(r.y-a/2),0,t.height-a),width:o,height:a}}function ge(t,e,r,i){return{...e,left:N(e.left+r,0,t.width-e.width),top:N(e.top+i,0,t.height-e.height)}}function ye(t,e){return{x:e.width<t.width,y:e.height<t.height}}function xe(t){return{x:t.left+t.width/2,y:t.top+t.height/2}}function be(t,e){return Math.round(e.width*e.height*100/(t.width*t.height))}var J=t=>`${t.w}:${t.h}`,Se=t=>`cropped-${t.w}x${t.h}`;function Ie(t){let e=/^(\d{1,3}):(\d{1,3})$/.exec(t.trim()),r=Number(e?.[1]),i=Number(e?.[2]);if(!e||r<1||r>100||i<1||i>100)throw B(`"${t}" is not a shape; it takes two whole numbers from 1 to 100, as W:H.`,"Try --crop 1:1 or --crop 16:9.");return{w:r,h:i}}function Me(t,e,r){let i=r*2,n=new Uint8Array(e*i*3),o=t.alpha?new Uint8Array(e*i):void 0,a=t.width/e,d=t.height/i;for(let s=0;s<i;s++){let h=s*d,l=h+d;for(let p=0;p<e;p++){let f=p*a,u=f+a,x=0,m=0,g=0,c=0,y=0;for(let b=Math.floor(h);b<Math.min(Math.ceil(l),t.height);b++){let L=Math.min(b+1,l)-Math.max(b,h);for(let O=Math.floor(f);O<Math.min(Math.ceil(u),t.width);O++){let Y=b*t.width+O,tt=(Math.min(O+1,u)-Math.max(O,f))*L,R=tt*(t.alpha?(t.alpha[Y]??0)/255:1),H=Y*3;x+=(t.rgb[H]??0)*R,m+=(t.rgb[H+1]??0)*R,g+=(t.rgb[H+2]??0)*R,c+=R,y+=tt}}let z=s*e+p;c>0&&n.set([x/c,m/c,g/c].map(Math.round),z*3),o&&y>0&&(o[z]=Math.round(c*255/y))}}return{cols:e,dotRows:i,rgb:n,...o?{alpha:o}:{}}}function Oe(t){if(w[t].hasAlpha)return;let e=Object.keys(w).filter(r=>w[r].hasAlpha&&r!=="heic").join(", ");return B(`${w[t].label} cannot hold transparency, so a cutout cannot be saved as one.`,`Choose a format that can: ${e}.`)}var xt="1.1.0";function Rt(t,e){let r=t.split(".").map(n=>Number.parseInt(n,10)||0),i=e.split(".").map(n=>Number.parseInt(n,10)||0);for(let n=0;n<Math.max(r.length,i.length);n++){let o=(r[n]??0)-(i[n]??0);if(o!==0)return o>0}return!0}function V(t){return t!==void 0&&Rt(t,xt)?[2,3,4]:[2,4]}function Be(t,e,r){if(t===1||V(e).some(n=>n===t))return;if(r!==void 0&&V(r).some(n=>n===t))return ft("boost",`boost ${t}\xD7`,e,xt);let i=V(e).map(n=>`--boost ${n}`);return B(`No released boost makes ${t}\xD7 yet.`,`Try ${i.slice(0,-1).join(", ")} or ${i.at(-1)}.`)}var kt=16384,Ct=1e8;function bt(t,e,r){let i=Math.max(t,e)*r;if(i>kt)return{side:i};let n=t*r*e*r;if(n>Ct)return{megapixels:Math.round(n/1e6)}}var v=t=>Math.max(1,Math.round(t));function X(t,e){return"percent"in e?{width:v(t.width*e.percent/100),height:v(t.height*e.percent/100)}:"width"in e?{width:v(e.width),height:v(t.height*e.width/t.width)}:{width:v(t.width*e.height/t.height),height:v(e.height)}}function St(t){return bt(t.width,t.height,1)}import{execFile as Nt}from"node:child_process";import{randomBytes as Dt}from"node:crypto";import{mkdtemp as _t,open as It,readFile as $t,rm as Z}from"node:fs/promises";import{tmpdir as Mt}from"node:os";import{join as _}from"node:path";import{promisify as Lt}from"node:util";function S(t){let e;return()=>(e??=t(),e)}var M=S(async()=>(await import("sharp")).default),ze=S(()=>import("./es-T2U7NBLD.js")),Re=S(()=>import("@hyzyla/pdfium")),ke=S(async()=>(await import("./lib-TPEJ5CJJ.js")).default),Ce=S(async()=>(await import("./word-OGQ2KZAJ.js")).default),Ue=S(async()=>(await import("./adm-zip-SQKLKBDP.js")).default),Ne=S(async()=>(await import("./cfb-V6M2PYOD.js")).default);async function Ut(){let t=Object.getOwnPropertyDescriptor(globalThis,"localStorage");if(!t?.configurable)return import("./dist-J2V6ITHG.js");Object.defineProperty(globalThis,"localStorage",{value:void 0,configurable:!0,enumerable:t.enumerable??!1,writable:!0});try{return await import("./dist-J2V6ITHG.js")}finally{Object.defineProperty(globalThis,"localStorage",t)}}var De=S(Ut);var G=Lt(Nt),Et=async()=>({...await import("./paths-5XI5L4KW.js"),...await import("./run-6BK4REXK.js")}),T;async function P(t=process.platform){if(t==="win32")return await(await Et()).installed("heic")!==void 0;if(T!==void 0)return T;try{await G("/usr/bin/sips",["--help"],{timeout:5e3}),T=!0}catch{T=!1}return T}async function $(t,e=process.platform){if(e==="win32")return Ht(t);let r=_(Mt(),`forge-heic-${Dt(8).toString("hex")}.png`),i=async()=>{await Z(r,{force:!0}).catch(()=>{})};try{return await G("/usr/bin/sips",["-s","format","png",t,"--out",r],{timeout:12e4}),{path:r,cleanup:i}}catch(n){throw await i(),n}}async function At(t){let{installed:e,runExtension:r}=await Et(),i=await e("heic");if(i===void 0)throw I(t,"win32");return{ext:i,runExtension:r}}async function Ht(t){let e=await _t(_(Mt(),"forge-heic-")),r=async()=>{await Z(e,{recursive:!0,force:!0}).catch(()=>{})};try{let{ext:i,runExtension:n}=await At(t),o=_(e,"decoded.rgba"),a=_(e,"decoded.png"),{width:d,height:s}=await n(i,["--in",t,"--out",o],{subject:t});return await(await M())(await $t(o),{raw:{width:d,height:s,channels:4}}).png().toFile(a),await Z(o,{force:!0}),{path:a,cleanup:r}}catch(i){throw await r(),i}}var Wt=new Set(["heic","heix","hevc","hevx","heim","heis","mif1","msf1"]),jt=new Set(["avif","avis"]);async function vt(t){let e;try{e=await It(t,"r")}catch{return!1}try{let r=Buffer.alloc(64),{bytesRead:i}=await e.read(r,0,64,0);if(i<12||r.toString("latin1",4,8)!=="ftyp")return!1;let n=Math.min(r.readUInt32BE(0),i),o=[];for(let a=8;a+4<=n;a+=4)o.push(r.toString("latin1",a,a+4));return o.some(a=>jt.has(a))?!1:o.some(a=>Wt.has(a))}catch{return!1}finally{await e.close().catch(()=>{})}}async function Ot(t,e=process.platform){if(e==="win32"){let{ext:a,runExtension:d}=await At(t),s=await d(a,["--info","--in",t],{subject:t});return{width:s.width,height:s.height,hasAlpha:s.hasAlpha??!0}}let{stdout:r}=await G("/usr/bin/sips",["-g","pixelWidth","-g","pixelHeight","-g","hasAlpha",t],{timeout:3e4}),i=Number(/pixelWidth:\s*(\d+)/.exec(r)?.[1]??0),n=Number(/pixelHeight:\s*(\d+)/.exec(r)?.[1]??0),o=await qt(t);return{width:o?n:i,height:o?i:n,hasAlpha:/hasAlpha:\s*yes/i.test(r)}}function*D(t,e,r){let i=e;for(;i+8<=r;){let n=t.readUInt32BE(i),o=8;if(n===1&&i+16<=r?(n=Number(t.readBigUInt64BE(i+8)),o=16):n===0&&(n=r-i),n<o)return;yield{type:t.toString("latin1",i+4,i+8),start:i+o,end:Math.min(i+n,r)},i+=n}}async function qt(t){let e=await It(t,"r");try{let r=Buffer.alloc(262144),{bytesRead:i}=await e.read(r,0,r.length,0),n=[...D(r,0,i)].find(c=>c.type==="meta");if(!n)return!1;let o=[...D(r,n.start+4,n.end)],a=o.find(c=>c.type==="pitm"),d=o.find(c=>c.type==="iprp");if(!a||!d)return!1;let s=r.readUInt8(a.start)===0?r.readUInt16BE(a.start+4):r.readUInt32BE(a.start+4),h=[...D(r,d.start,d.end)],l=h.find(c=>c.type==="ipco"),p=h.find(c=>c.type==="ipma");if(!l||!p)return!1;let f=new Map;if([...D(r,l.start,l.end)].forEach((c,y)=>{c.type==="irot"&&f.set(y+1,r.readUInt8(c.start)&3)}),f.size===0)return!1;let u=r.readUInt8(p.start),x=(r.readUInt8(p.start+3)&1)===1,m=p.start+4,g=r.readUInt32BE(m);m+=4;for(let c=0;c<g&&m<p.end;c++){let y=u<1?r.readUInt16BE(m):r.readUInt32BE(m);m+=u<1?2:4;let z=r.readUInt8(m);m+=1;for(let b=0;b<z;b++){let L=x?r.readUInt16BE(m)&32767:r.readUInt8(m)&127;if(m+=x?2:1,y===s&&(f.get(L)??0)%2===1)return!0}}return!1}catch{return!1}finally{await e.close().catch(()=>{})}}var Qt=new Set(["jpeg","png","webp","avif","heic","gif","tiff"]),Yt=new Set(["jpeg","png","webp","avif","gif","tiff"]),te={jpeg:"jpeg",png:"png",webp:"webp",gif:"gif",tiff:"tiff"};function ee(t,e){if(e.format==="heif")return e.compression==="av1"?"avif":"heic";let r=te[e.format??""];if(!r)throw st(t,e.format??"an unknown format");return r}async function re(t){let e;try{e=await Zt(t)}catch(n){let o=n.code;throw o==="ENOENT"?et(t):o==="EACCES"||o==="EPERM"?W(t):o==="ENOTDIR"?it(t):o==="ELOOP"?nt(t):o==="ENAMETOOLONG"?ot(t):at(t,n)}if(!e.isFile())throw rt(t);try{await Vt(t,Jt.R_OK)}catch{throw W(t)}if(await vt(t)){if(!await P())throw I(t);let n;try{n=await Ot(t)}catch(o){throw j(t,"heic",o)}if(n.width===0||n.height===0)throw j(t,"heic",void 0);return{kind:"image",path:t,format:"heic",width:n.width,height:n.height,bytes:e.size,hasAlpha:n.hasAlpha,frames:1}}let r=await M(),i;try{i=await r(t).metadata()}catch(n){throw ht(t,n)}return{kind:"image",path:t,format:ee(t,i),width:i.autoOrient?.width??i.width??0,height:i.autoOrient?.height??i.height??0,bytes:e.size,hasAlpha:i.hasAlpha??!1,frames:i.pages??1}}function K(t,e,r,i){let n=r??w[e].defaultQuality;if(i&&w[e].quantisable)return ie(t,e,r,i);switch(e){case"jpeg":return t.jpeg({quality:n,mozjpeg:!0});case"webp":return t.webp({quality:n});case"avif":return t.avif({quality:n});case"png":return t.png({compressionLevel:9});case"gif":return t.gif();case"tiff":return t.tiff({compression:"deflate"});case"heic":throw new Error("heic is not writable; the capability graph should have prevented this");case"pdf":throw new Error("pdf is not an image target; the capability graph should have prevented this");case"docx":throw new Error("docx is not an image target; the capability graph should have prevented this");case"doc":throw new Error("doc is not an image target; the capability graph should have prevented this");default:throw new Error(`${e} is not an image target; the capability graph should have prevented this`)}}function ie(t,e,r,{dither:i}){let n=r??100,o=i?1:0;return e==="gif"?t.gif({interFrameMaxError:Math.round(32*(100-n)/100),dither:o}):t.png({palette:!0,quality:n,dither:o,compressionLevel:9,effort:10})}var Q=(t,e)=>t.kind==="image"&&t.frames>1&&w[e].animatable;async function ne(t,e){let r=Kt(e);await q(e);let i=gt(e);try{return await Gt(i,t),await yt(i,e),t.length}catch(n){throw await Xt(i,{force:!0}).catch(()=>{}),ct(e,n)}}async function F(t,e,r,i,n,o){if(t.kind!=="image")throw new Error("pipelineFor received a non-image source");if(n===void 0&&t.format==="heic"&&!await P())throw I(t.path);let a=n===void 0&&t.format==="heic"?await $(t.path):void 0,d=async()=>{await a?.cleanup()},h=(await M())(n??a?.path??t.path,i?{animated:!0}:{});if(h=h.rotate(),r.trim&&(h=h.trim()),r.crop){if(!r.crop.box)throw new Error("pipelineFor needs the crop placed (run does it)");h=h.extract(r.crop.box)}if(r.resize){if(!o&&(r.trim||r.crop))throw new Error("pipelineFor needs the resolved size to resize a cut image");let l=o??X(t,r.resize);h=h.resize(l.width,l.height,{fit:"fill"})}return t.hasAlpha&&!w[e].hasAlpha&&(h=h.flatten({background:r.background})),h=r.keepMetadata?h.keepMetadata():h.keepIccProfile(),{pipeline:h,cleanup:d}}async function ar(t,e){let r={background:"#ffffff",keepMetadata:!1},{pipeline:i,cleanup:n}=await F(t,"png",r,!1);try{await i.png({compressionLevel:1}).toFile(e)}finally{await n()}}async function sr(t,e,r){let{pipeline:i,cleanup:n}=await F(t,e,r,Q(t,e));try{return await K(i,e,r.quality,r.compress).toBuffer()}finally{await n()}}async function oe(t){let e={width:t.width,height:t.height};if(t.frames>1)return{upright:e,trimmed:"animated"};if(t.format==="heic"&&!await P())throw I(t.path);let r=t.format==="heic"?await $(t.path):void 0;try{let i=await M(),{info:n}=await i(r?.path??t.path).rotate().trim().jpeg({quality:1}).toBuffer({resolveWithObject:!0});return n.width===e.width&&n.height===e.height?{upright:e,trimmed:"nothing"}:{upright:e,trimmed:{width:n.width,height:n.height}}}catch(i){throw C(i)?i:U(t.path,i)}finally{await r?.cleanup()}}var Tt=1024;async function ae(t){let e={background:"#ffffff",keepMetadata:!1},{pipeline:r,cleanup:i}=await F(t,"png",e,!1);try{let{data:n,info:o}=await r.resize(Tt,Tt,{fit:"inside",withoutEnlargement:!0}).ensureAlpha().raw().toBuffer({resolveWithObject:!0}),a=o.width*o.height,d=o.channels,s=new Uint8Array(a*3),h=new Uint8Array(a),l=!1;for(let p=0;p<a;p++){for(let f=0;f<3;f++)s[p*3+f]=n[p*d+(d>=4?f:0)]??0;h[p]=n[p*d+d-1]??255,h[p]!==255&&(l=!0)}return{size:{width:t.width,height:t.height},thumb:{width:o.width,height:o.height,rgb:s,...l?{alpha:h}:{}}}}catch(n){throw C(n)?n:U(t.path,n)}finally{await i()}}var Pt=128;async function se(t,e){let{thumb:r,size:i}=t,n=A(r,e),o=await M(),{info:a}=await o(he(r),{raw:{width:r.width,height:r.height,channels:3}}).resize(n.width,n.height,{fit:"cover",position:o.strategy.attention}).raw().toBuffer({resolveWithObject:!0}),d=A(i,e),s=Math.round(-(a.cropOffsetLeft??0)*i.width/r.width),h=Math.round(-(a.cropOffsetTop??0)*i.height/r.height);return{...d,left:Math.min(Math.max(s,0),i.width-d.width),top:Math.min(Math.max(h,0),i.height-d.height)}}function he(t){let{alpha:e}=t;if(!e)return t.rgb;let r=new Uint8Array(t.rgb.length);for(let i=0;i<r.length;i++){let n=(e[Math.floor(i/3)]??255)/255;r[i]=Math.round(Pt+((t.rgb[i]??0)-Pt)*n)}return r}async function ce(t,e){if(t.op!=="convert")throw new Error(`image engine cannot ${t.op}`);let r=t.sources[0],i=t.outputs[0];if(r.kind!=="image")throw new Error("the image engine cannot convert a document source");let n=w[t.target],o=[];e({phase:"reading"});let a=r.frames>1,d=Q(r,t.target);a&&!n.animatable&&o.push({code:"animation-flattened",message:`${k(r.path)} has ${r.frames} frames, and ${n.label} cannot animate. Only the first frame was converted.`});let s=t.options,h;if(s.trim||s.crop||s.resize){let f={width:r.width,height:r.height};if(s.trim&&s.crop)throw new Error("a job cannot both trim and crop");if(s.crop){if(a)throw wt(r.path);let{aspect:u}=s.crop,x=c=>c.width===r.width&&c.height===r.height,m=A(f,u),g=s.crop.box??(x(m)?m:await se(await ae(r),u));if(x(g)){if(!s.resize)throw lt(r.path,J(u));o.push({code:"nothing-cropped",message:`${k(r.path)} is already ${J(u)}; resized only.`});let{crop:c,...y}=s;s=y}else s={...s,crop:{aspect:u,box:g}},f={width:g.width,height:g.height}}if(s.trim){if(a)throw mt(r.path);let{trimmed:u}=await oe(r);if(u==="nothing"){if(!s.resize)throw ut(r.path);o.push({code:"nothing-trimmed",message:`${k(r.path)} has no empty edges; resized only.`})}else u!=="animated"&&(f=u)}if(s.resize&&(h=X(f,s.resize),St(h)))throw dt(r.path,h)}e({phase:"decoding"});let{pipeline:l,cleanup:p}=await F(r,t.target,s,d,void 0,h);try{await q(i),e({phase:"encoding"});let f=await K(l,t.target,s.quality,s.compress).toBuffer();if(s.compress&&f.length>=r.bytes)throw pt(r.path,r.bytes,f.length);e({phase:"writing"});let u=await ne(f,i);return{job:t,outputBytes:u,warnings:o}}catch(f){throw C(f)?f:U(r.path,f)}finally{await p()}}async function fe(t){if(t.format!=="heic")return Bt(t.path);if(!await P())throw I(t.path);let e=await $(t.path);try{return await Bt(e.path)}finally{await e.cleanup()}}async function de(t){if(t.op!=="convert")return;let e=w[t.target];if(!e.lossy&&!(e.quantisable&&t.options.compress))return;let r=t.sources[0];if(r.kind!=="image")return;let i=await fe(r);return{ladder:[{}],measure:async n=>{let{pipeline:o}=await F(r,t.target,n,Q(r,t.target),i);return(await K(o,t.target,n.quality,n.compress).toBuffer()).length}}}var hr={id:"image",reads:Qt,writes:Yt,ops:new Set(["convert"]),probe:re,run:ce,measurer:de};export{Ft as a,ue as b,me as c,A as d,le as e,we as f,ge as g,ye as h,xe as i,be as j,Se as k,Ie as l,Me as m,Oe as n,V as o,Be as p,kt as q,bt as r,X as s,St as t,S as u,M as v,ze as w,Re as x,ke as y,Ce as z,Ue as A,Ne as B,De as C,P as D,$ as E,vt as F,K as G,ne as H,ar as I,sr as J,oe as K,ae as L,se as M,hr as N};
@@ -1,6 +0,0 @@
1
- import { createRequire as __forgeCreateRequire } from 'node:module';
2
- const require = __forgeCreateRequire(import.meta.url);
3
- import{execFile as O,spawn as B}from"node:child_process";import{access as I,constants as T}from"node:fs/promises";import{join as A}from"node:path";import{promisify as K}from"node:util";function E(e){let[n,r]=(e??"").split("/").map(Number);return!n||!r?0:Math.round(n/r*100)/100}function R(e){let n=e.side_data_list?.find(t=>typeof t.rotation=="number")?.rotation,r=n!==void 0?-n:Number(e.tags?.rotate??0);return(Math.round(r/90)*90%360+360)%360}function S(e){let n=e,r=n.streams??[],t=r.find(o=>o.codec_type==="video"&&o.disposition?.attached_pic!==1),i=r.find(o=>o.codec_type==="audio"),a={duration:Number(n.format?.duration)||Math.max(0,...r.map(o=>Number(o.duration)||0))};if(t){let o=R(t),f=o===90||o===270,s=t.width??0,u=t.height??0;a.video={codec:t.codec_name??"",width:f?u:s,height:f?s:u,fps:E(t.avg_frame_rate)||E(t.r_frame_rate),rotation:o,hdr:t.color_transfer==="arib-std-b67"||t.color_transfer==="smpte2084"}}return i&&(a.audio={codec:i.codec_name??"",channels:i.channels??0,sampleRate:Number(i.sample_rate)||0}),a}var _=K(O);function $(e,n){let r=n.PATH??n.Path??"",t=e==="win32"?";":":",i=r.split(t).filter(Boolean);return e==="darwin"&&i.push("/opt/homebrew/bin","/usr/local/bin"),[...new Set(i)]}var L=e=>process.platform==="win32"?`${e}.exe`:e;async function N(e){try{return await I(e,T.X_OK),!0}catch{return!1}}function D(e){let n=new Set;for(let r of e.split(`
4
- `)){let t=r.match(/^\s*[A-Z.|]{3,6}\s+(\S+)\s/);t?.[1]&&t[1]!=="="&&n.add(t[1])}return n}async function G(){try{let{installed:e}=await import("./paths-5XI5L4KW.js");return(await e("video"))?.dir}catch{return}}async function J(){let e=await G(),n=[...$(process.platform,process.env),...e?[e]:[]];for(let r of n){let t=A(r,L("ffmpeg")),i=A(r,L("ffprobe"));if(!await N(t)||!await N(i))continue;try{await _(t,["-hide_banner","-version"],{timeout:5e3})}catch{continue}let[m,a]=await Promise.all(["-encoders","-filters"].map(f=>_(t,["-hide_banner",f],{timeout:5e3,maxBuffer:4<<20}).then(({stdout:s})=>D(s)).catch(()=>{}))),o=m&&a?new Set([...m,...a]):void 0;return{ffmpeg:t,ffprobe:i,...o?{has:o}:{}}}}var h,y=null;function v(){return y?Promise.resolve(y.value):(h=(h??J()).then(n=>(n||(h=void 0),n)),h)}function U(e){y=e===null?null:{value:e},h=void 0}async function W(e,n){let r=n??await v();if(!r)throw new Error("ffmpeg is not installed");let{stdout:t}=await _(r.ffprobe,["-v","error","-print_format","json","-show_format","-show_streams",e],{timeout:3e4,maxBuffer:16*1024*1024});return S(JSON.parse(t))}async function Y(e,n,r){let t=r??await v();if(!t)return;let i=Math.max(0,n-15),{stdout:m}=await _(t.ffprobe,["-v","error","-select_streams","v:0","-skip_frame","nokey","-show_entries","frame=pts_time","-of","csv=p=0","-read_intervals",`${i}%${n+.01}`,e],{timeout:3e4,maxBuffer:4*1024*1024}),a=m.split(`
5
- `).map(o=>Number.parseFloat(o)).filter(o=>Number.isFinite(o)&&o<=n+.001);return a.length?Math.max(...a):void 0}var k=4e3;async function ee(e,n,r,t={}){let i=t.tools??await v();if(!i)return null;let m=Math.max(1,Math.round(n*k)),a=Math.max(1,Math.ceil(m/r)),o=new Array(r).fill(0),f=0,s=Buffer.alloc(0);if(!await new Promise((p,d)=>{let c=B(i.ffmpeg,["-hide_banner","-nostdin","-loglevel","error","-i",e,"-map","0:a:0","-ac","1","-ar",String(k),"-f","s16le","-"],{stdio:["ignore","pipe","pipe"]}),b=()=>c.kill("SIGKILL");t.signal?.addEventListener("abort",b,{once:!0}),c.stdout.on("data",l=>{let w=s.length?Buffer.concat([s,l]):l,F=w.length-w.length%2;for(let x=0;x<F;x+=2){let P=Math.abs(w.readInt16LE(x)),M=Math.min(r-1,Math.floor(f/a));P>(o[M]??0)&&(o[M]=P),f++}s=w.subarray(F)}),c.stderr.resume(),c.on("error",d),c.on("close",l=>{t.signal?.removeEventListener("abort",b),t.signal?.aborted?d(t.signal.reason??new Error("aborted")):p(l===0&&f>0)})}))return null;let g=Math.max(1,...o);return o.map(p=>Math.sqrt(p/g))}async function te(e,n,r,t){await C(["-ss",String(Math.max(0,n)),"-i",e,"-frames:v","1","-y",r],{tools:t})}function j(e){let n;for(let r of e.matchAll(/out_time_us=(\d+)/g))n=Number(r[1])/1e6;return n}var q=4e3;async function C(e,n={}){let{signal:r,onTime:t}=n;if(r?.aborted)throw r.reason??new Error("aborted");let i=n.tools??await v();if(!i)throw new Error("ffmpeg is not installed");let a=["-hide_banner","-nostdin","-loglevel",n.report?"info":"error","-progress","pipe:1","-nostats",...e];return new Promise((o,f)=>{let s=B(i.ffmpeg,a,{stdio:["ignore","pipe","pipe"]}),u="",g=()=>s.kill("SIGKILL");r?.addEventListener("abort",g,{once:!0}),s.stdout.setEncoding("utf8");let p="";s.stdout.on("data",d=>{let c=p+d,b=c.lastIndexOf(`
6
- `);p=c.slice(b+1);let l=j(c.slice(0,b+1));l!==void 0&&t?.(l)}),s.stderr.setEncoding("utf8"),s.stderr.on("data",d=>{u=(u+d).slice(-q)}),s.on("error",d=>{r?.removeEventListener("abort",g),f(d)}),s.on("close",d=>{r?.removeEventListener("abort",g),r?.aborted?f(r.reason??new Error("aborted")):d===0?o(u):f(new Error(u.trim()||`ffmpeg exited with ${d}`))})})}export{$ as a,D as b,v as c,U as d,W as e,Y as f,ee as g,te as h,j as i,C as j};
@@ -1,3 +0,0 @@
1
- import { createRequire as __forgeCreateRequire } from 'node:module';
2
- const require = __forgeCreateRequire(import.meta.url);
3
- import{a as A}from"./chunk-BZXDNDPG.js";import{b as w,e as m,l as R}from"./chunk-QR6QHTC3.js";import{a as P,b as l}from"./chunk-6L6C3GJU.js";import{d as k,k as O,s as M}from"./chunk-KAHWYWNT.js";import{c as x,d as I,e as c,i as z,m as F}from"./chunk-EXLXSKRH.js";import{F as S}from"./chunk-3UEQ2OX6.js";import{b as u,e as g}from"./chunk-AAXBN572.js";import{a as f,b as y}from"./chunk-M66BUNYO.js";import{dirname as J,join as E}from"node:path";var C="Same location",j="New subfolder";function L(e,t){return e===t?C:e===u("Desktop")?"Desktop":e===u("Downloads")?"Downloads":t!==void 0&&e===E(t,"converted")?j:A(e)||e}function T(e,t,n={}){return _(J(e.path),t,n)}function _(e,t,{subfolder:n=!1}={}){let i=g(t.defaultOutput),o=t.lastOutput?g(t.lastOutput):void 0,r=p=>({label:L(p,e),path:p}),s=[r(i),...o?[r(o)]:[],r(u("Desktop")),...e===void 0?[]:[{label:C,path:e}],r(u("Downloads")),...n&&e!==void 0?[{label:j,path:E(e,"converted")}]:[]],a=new Set,d=s.filter(p=>a.has(p.path)?!1:(a.add(p.path),!0));return{kind:"path",id:"destination",label:"Save to",default:i,presets:d,...o&&o!==i?{last:o}:{}}}var b=e=>typeof e=="string"&&e!==""?e:void 0;var B=-16;function dt(e){return{wav:"m4a",aiff:"m4a",flac:"m4a",avi:"mp4",ogg:"opus"}[e]??e}var D=e=>e.length===1&&e[0]?.kind==="media"?e[0]:void 0,U=e=>e==="cut"||e==="mute"||e==="resize"||e==="crop"||e==="loudness";function Q(e,t){let n=t.media??{},i=e.facts?.video,o=[];return n.cut&&o.push("trimmed"),n.mute&&o.push("muted"),n.loudness!==void 0&&o.push("levelled"),n.speed!==void 0&&o.push(`${n.speed}x`),n.fps!==void 0&&o.push(`${n.fps}fps`),n.bitrate!==void 0&&o.push(`${n.bitrate}k`),t.crop&&o.push(O(t.crop.aspect)),t.resize&&o.push(i?R(M(i,t.resize)):"resized"),o.length===1?o[0]:"edited"}function W(e,t){return e.map(n=>{let i=t.target??n.format,o={background:"#ffffff",keepMetadata:!1};t.media&&Object.keys(t.media).length&&(o.media=t.media),t.resize&&(o.resize=t.resize);let r=n.facts?.video;t.crop&&r&&(o.crop={aspect:t.crop.aspect,box:t.crop.box??k(r,t.crop.aspect)});let s=t.roots?.get(n.path),a=c({sourcePath:n.path,target:i,suffix:Q(n,t),...t.output===void 0?{}:{output:t.output},...s===void 0?{}:{sourceRoot:s}});return{op:"convert",sources:[n],outputs:[F(a,b(t.destination),b(t.name))],target:i,options:o}})}function h(e){let t={},n=e.cut;return n&&typeof n.start=="number"&&(t.cut={start:n.start,...typeof n.end=="number"?{end:n.end}:{}}),e.mute===!0&&(t.mute=!0),typeof e.speed=="number"&&(t.speed=e.speed),typeof e.fps=="number"&&(t.fps=e.fps),typeof e.bitrate=="number"&&(t.bitrate=e.bitrate),typeof e.loudness=="number"&&(t.loudness=e.loudness),Object.keys(t).length?t:void 0}var pt={id:"media-edit",label:"Edit",verb:"Editing",hint:"trim, mute, resize, crop",appliesTo:e=>D(e)!==void 0,unavailable:()=>"one video or audio file",options:()=>[],plan(e,t){let n=D(e);if(!n||!U(t.tool))return[];let i=t.tool,o={...typeof t.output=="string"?{output:t.output}:{},destination:t.destination,name:t.name};if(i==="cut"){let r=h(t)?.cut;if(!r)return[];o.media={cut:r}}if(i==="mute"&&(o.media={mute:!0}),i==="loudness"&&(o.media={loudness:typeof t.loudness=="number"?t.loudness:B}),i==="resize"){if(typeof t.resize!="object"||t.resize===null)return[];o.resize=t.resize}if(i==="crop"){let r=t.crop;if(!r?.aspect||!n.facts?.video)return[];o.crop=r}return W([n],o)}};function G(e){return{kind:"select",id:"pages",label:"Pages",default:"all",choices:[{value:"all",label:"All pages",hint:`${e.pages} pages`},{value:"first",label:"First page only"},{value:"choose",label:"Choose pages",hint:"pick which ones"}]}}function H(){return{kind:"select",id:"dpi",label:"Resolution",default:"150",choices:[{value:"72",label:"72 dpi",hint:"screen"},{value:"150",label:"150 dpi",badge:"default"},{value:"300",label:"300 dpi",hint:"print"}]}}function K(e,t){return Array.isArray(t)?l(t):t==="first"?[0]:typeof t=="string"&&t!=="all"&&t!==""?l(P(t,e.pages)):Array.from({length:e.pages},(n,i)=>i)}function V(e,t){let n=f[e.format].lossy,i=f[t].lossy;if(n&&!i)return{hint:"likely bigger",tone:"warn"};if(!n&&i)return{hint:"likely smaller",tone:"ok"}}function X(e){let t=w(e).filter(i=>i.id!==e.format),n=t[0];return{kind:"select",id:"target",label:`Convert ${f[e.format].label} to`,choices:t.map(i=>{let o=V(e,i.id);return{value:i.id,label:i.label,hint:o?.hint??i.hint,...o===void 0?{}:{tone:o.tone}}}),default:n?n.id:""}}function Y(e){return{kind:"slider",id:"bitrate",label:"Quality",min:64,max:320,step:32,default:e==="opus"?96:128}}var Z=e=>typeof e=="object"&&e!==null&&("percent"in e||"width"in e||"height"in e);function v(e){let t=e.target,n=typeof t=="string"?y(t):void 0;if(!n)throw S(`convertAction.plan() requires a valid target format, got ${JSON.stringify(t)}.`,"This is a caller bug, not a user-facing condition: call options() and pass one of the target select choices before calling plan().");return n}var yt={id:"convert",label:"Convert",verb:"Converting",hint:"to another format",appliesTo:e=>e.length>=1,options(e,t,n){let i=e[0];if(!i)return[];let o=[X(i)],r=t.target;if(typeof r!="string")return o;i.kind==="document"&&m(r)&&o.push(G(i),H());let s=f[r];return i.kind==="media"?s?.media==="sound"&&s.lossy&&o.push(Y(r)):s?.lossy&&s.media===void 0&&o.push({kind:"slider",id:"quality",label:"Quality",min:1,max:100,step:5,default:n.quality}),o.push(T(i,n,{subfolder:!0})),o},plan(e,t){let n=e[0];if(!n)return[];let i=v(t),o=i.id,r={background:typeof t.background=="string"?t.background:"#ffffff",keepMetadata:t.keepMetadata===!0};if(i.lossy&&typeof t.quality=="number"&&(r.quality=t.quality),n.kind==="media"){let d=h(t);d&&(r.media=d),Z(t.resize)&&(r.resize=t.resize)}let s=typeof t.destination=="string"?t.destination:void 0;if(n.kind==="document"&&m(o)){let d=Number(t.dpi);r.dpi=Number.isFinite(d)&&d>0?d:150;let p=K(n,t.pages);r.pages=p;let N=typeof t.sourceRoot=="string"?t.sourceRoot:void 0,$=z(n.path,p,o,s,N);return[{op:"convert",sources:[n],outputs:$,target:o,options:r}]}let a=I({sourcePath:n.path,target:o,...s===void 0?{}:{output:`${s}/`}});return x(a,n.path)&&(a=c({sourcePath:n.path,target:o,suffix:o,...s===void 0?{}:{output:`${s}/`}})),[{op:"convert",sources:[n],outputs:[a],target:o,options:r}]}};export{j as a,T as b,_ as c,b as d,dt as e,W as f,h as g,pt as h,yt as i};
@@ -1,3 +0,0 @@
1
- import { createRequire as __forgeCreateRequire } from 'node:module';
2
- const require = __forgeCreateRequire(import.meta.url);
3
- var a={jpeg:{id:"jpeg",label:"JPEG",extensions:[".jpg",".jpeg"],hasAlpha:!1,animatable:!1,lossy:!0,hint:"universal",defaultQuality:82},png:{id:"png",label:"PNG",extensions:[".png"],hasAlpha:!0,animatable:!1,lossy:!1,hint:"lossless",quantisable:!0},webp:{id:"webp",label:"WebP",extensions:[".webp"],hasAlpha:!0,animatable:!0,lossy:!0,hint:"smaller, modern",defaultQuality:80},avif:{id:"avif",label:"AVIF",extensions:[".avif"],hasAlpha:!0,animatable:!0,lossy:!0,hint:"smallest",defaultQuality:50},heic:{id:"heic",label:"HEIC",extensions:[".heic",".heif"],hasAlpha:!0,animatable:!1,lossy:!0,hint:"Apple photos"},mp4:{id:"mp4",label:"MP4",extensions:[".mp4",".m4v"],hasAlpha:!1,animatable:!0,lossy:!0,hint:"H.264 \xB7 AAC",media:"video"},mov:{id:"mov",label:"MOV",extensions:[".mov",".qt"],hasAlpha:!1,animatable:!0,lossy:!0,hint:"QuickTime",media:"video",keepsOnly:!0},hevc:{id:"hevc",label:"HEVC",extensions:[".mp4"],hasAlpha:!1,animatable:!0,lossy:!0,hint:"H.265 \xB7 AAC",media:"video"},webm:{id:"webm",label:"WebM",extensions:[".webm"],hasAlpha:!1,animatable:!0,lossy:!0,hint:"VP9 \xB7 Opus",media:"video"},gif:{id:"gif",label:"GIF",extensions:[".gif"],hasAlpha:!0,animatable:!0,lossy:!1,hint:"animation",quantisable:!0,media:"video"},tiff:{id:"tiff",label:"TIFF",extensions:[".tif",".tiff"],hasAlpha:!0,animatable:!1,lossy:!1,hint:"archival"},pdf:{id:"pdf",label:"PDF",extensions:[".pdf"],hasAlpha:!1,animatable:!1,lossy:!1,hint:"document"},docx:{id:"docx",label:"DOCX",extensions:[".docx"],hasAlpha:!1,animatable:!1,lossy:!1,hint:"Word document"},doc:{id:"doc",label:"DOC",extensions:[".doc"],hasAlpha:!1,animatable:!1,lossy:!1,hint:"legacy Word"},mkv:{id:"mkv",label:"MKV",extensions:[".mkv"],hasAlpha:!1,animatable:!0,lossy:!0,hint:"Matroska",media:"video",keepsOnly:!0},avi:{id:"avi",label:"AVI",extensions:[".avi"],hasAlpha:!1,animatable:!0,lossy:!0,hint:"legacy video",media:"video",keepsOnly:!0},mp3:{id:"mp3",label:"MP3",extensions:[".mp3"],hasAlpha:!1,animatable:!1,lossy:!0,hint:"plays anywhere",media:"sound"},m4a:{id:"m4a",label:"M4A",extensions:[".m4a",".m4b"],hasAlpha:!1,animatable:!1,lossy:!0,hint:"AAC",media:"sound"},opus:{id:"opus",label:"Opus",extensions:[".opus"],hasAlpha:!1,animatable:!1,lossy:!0,hint:"smallest",media:"sound"},flac:{id:"flac",label:"FLAC",extensions:[".flac"],hasAlpha:!1,animatable:!1,lossy:!1,hint:"lossless",media:"sound"},aiff:{id:"aiff",label:"AIFF",extensions:[".aiff",".aif",".aifc"],hasAlpha:!1,animatable:!1,lossy:!1,hint:"uncompressed",media:"sound"},wav:{id:"wav",label:"WAV",extensions:[".wav"],hasAlpha:!1,animatable:!1,lossy:!1,hint:"uncompressed",media:"sound"},ogg:{id:"ogg",label:"OGG",extensions:[".ogg",".oga"],hasAlpha:!1,animatable:!1,lossy:!0,hint:"Vorbis",media:"sound",keepsOnly:!0}},l=Object.keys(a);function i(e){return a[e.toLowerCase()]}function t(e){let s=a[e].extensions[0];if(!s)throw new Error(`format ${e} declares no extensions`);return s}export{a,i as b,t as c};