forge-terminal 0.5.1 → 0.5.2

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 (116) hide show
  1. package/README.md +7 -6
  2. package/dist/chunks/{about-credits-FZ35HUFP.js → about-credits-VZQJAWG3.js} +1 -1
  3. package/dist/chunks/args-FZXEZBPA.js +3 -0
  4. package/dist/chunks/{boot-PCZBPNFR.js → boot-NYKO3NLR.js} +1 -1
  5. package/dist/chunks/chunk-2AFHW44W.js +36 -0
  6. package/dist/chunks/{chunk-S2M4XESA.js → chunk-63ZZRDSV.js} +1 -1
  7. package/dist/chunks/{chunk-63ZK5SRQ.js → chunk-7I2OSTBX.js} +1 -1
  8. package/dist/chunks/chunk-7KYO62XK.js +3 -0
  9. package/dist/chunks/{chunk-DZOBIUV6.js → chunk-BIBDLXCG.js} +1 -1
  10. package/dist/chunks/{chunk-G46QQBT3.js → chunk-BROTSQXG.js} +1 -1
  11. package/dist/chunks/chunk-CVNYUROW.js +3 -0
  12. package/dist/chunks/chunk-CW2Y2KDQ.js +3 -0
  13. package/dist/chunks/chunk-DYIATUFE.js +3 -0
  14. package/dist/chunks/{chunk-SK2UZ25Y.js → chunk-EITGK5OI.js} +1 -1
  15. package/dist/chunks/chunk-GRWOJKQB.js +3 -0
  16. package/dist/chunks/{chunk-X26WUHWB.js → chunk-GT6U6HV3.js} +1 -1
  17. package/dist/chunks/{chunk-JMBEZPYC.js → chunk-HWCXNKIN.js} +1 -1
  18. package/dist/chunks/chunk-IED6VBE6.js +3 -0
  19. package/dist/chunks/{chunk-2CX33C6H.js → chunk-ITW5FG4K.js} +1 -1
  20. package/dist/chunks/{chunk-MTDCDKPU.js → chunk-IVBSXPNS.js} +2 -2
  21. package/dist/chunks/chunk-J2UQI544.js +4 -0
  22. package/dist/chunks/{chunk-THDAQBQ3.js → chunk-J6AZTW62.js} +1 -1
  23. package/dist/chunks/chunk-JGJU3AW5.js +3 -0
  24. package/dist/chunks/{chunk-XURW53YK.js → chunk-K6ERQTUQ.js} +1 -1
  25. package/dist/chunks/chunk-KMLT45OJ.js +66 -0
  26. package/dist/chunks/{chunk-QXNB5DQ2.js → chunk-LA5JVBFP.js} +1 -1
  27. package/dist/chunks/chunk-M6LYLTFH.js +3 -0
  28. package/dist/chunks/chunk-O7DK3GJT.js +3 -0
  29. package/dist/chunks/chunk-Q7ERPAG3.js +7 -0
  30. package/dist/chunks/{chunk-HCLEHCAR.js → chunk-R24JCIZ5.js} +1 -1
  31. package/dist/chunks/{chunk-3KWAO2N2.js → chunk-RK3WGALB.js} +1 -1
  32. package/dist/chunks/chunk-RXI6QLNY.js +82 -0
  33. package/dist/chunks/chunk-SNFUGJ3M.js +3 -0
  34. package/dist/chunks/chunk-T37DEXUI.js +3 -0
  35. package/dist/chunks/chunk-TARDT6LZ.js +55 -0
  36. package/dist/chunks/{chunk-EKTUUKDP.js → chunk-TYWGB767.js} +1 -1
  37. package/dist/chunks/chunk-VLVNA4T3.js +3 -0
  38. package/dist/chunks/{chunk-YINYF6C7.js → chunk-VTA6Z45X.js} +1 -1
  39. package/dist/chunks/{chunk-JOIHR724.js → chunk-W2QJA73Q.js} +1 -1
  40. package/dist/chunks/{chunk-BD3OLIVT.js → chunk-XPATZLEH.js} +1 -1
  41. package/dist/chunks/chunk-XUKYIVJC.js +3 -0
  42. package/dist/chunks/{chunk-GLAD7GP2.js → chunk-YK26E3OX.js} +1 -1
  43. package/dist/chunks/{chunk-YNZIN42P.js → chunk-ZFLFBNIK.js} +1 -1
  44. package/dist/chunks/{chunk-655UG277.js → chunk-ZHNPBRCX.js} +1 -1
  45. package/dist/chunks/{chunk-C4UCCBCX.js → chunk-ZOQA3JAR.js} +1 -1
  46. package/dist/chunks/clip-command-SLSAWJF4.js +3 -0
  47. package/dist/chunks/clipboard-7KSZNWWT.js +3 -0
  48. package/dist/chunks/colour-LMZO2EE6.js +3 -0
  49. package/dist/chunks/command-DMGGGAPS.js +3 -0
  50. package/dist/chunks/config-command-6GXRV627.js +3 -0
  51. package/dist/chunks/continue-editing-4W3XWWCE.js +3 -0
  52. package/dist/chunks/decoded-SMEHAVCH.js +3 -0
  53. package/dist/chunks/{entry-2XJD7UCY.js → entry-TV4FJQDR.js} +2 -2
  54. package/dist/chunks/execute-NEDE4JM6.js +3 -0
  55. package/dist/chunks/extensions-4UJRQ32J.js +3 -0
  56. package/dist/chunks/{extensions-command-MGPRISPH.js → extensions-command-VROVGVD4.js} +1 -1
  57. package/dist/chunks/{ffmpeg-2UZXAB3C.js → ffmpeg-OIVMTPY7.js} +1 -1
  58. package/dist/chunks/image-J5WDYORX.js +3 -0
  59. package/dist/chunks/install-5XLVERRR.js +3 -0
  60. package/dist/chunks/install-C6XNONFF.js +3 -0
  61. package/dist/chunks/launch-5JMWS5CI.js +17 -0
  62. package/dist/chunks/lock-AFVXUDOM.js +3 -0
  63. package/dist/chunks/manager-T3WDLUKR.js +4 -0
  64. package/dist/chunks/{needed-YEXRZMZX.js → needed-YU5BPYD6.js} +1 -1
  65. package/dist/chunks/notify-LTV7F634.js +3 -0
  66. package/dist/chunks/{own-WOK6H277.js → own-OJAQ5FRQ.js} +1 -1
  67. package/dist/chunks/pdfium-7HNCQ3K3.js +3 -0
  68. package/dist/chunks/preset-command-VP5RAXBG.js +3 -0
  69. package/dist/chunks/registry-E5PNQWOZ.js +3 -0
  70. package/dist/chunks/run-WSETTQXP.js +3 -0
  71. package/dist/chunks/{server-QNWPC2CC.js → server-EFNTD7ZW.js} +3 -3
  72. package/dist/chunks/{theme-EHFY7DT6.js → theme-NF3LQHPV.js} +1 -1
  73. package/dist/chunks/transcribe-CQFHXBTV.js +3 -0
  74. package/dist/chunks/transcribe-command-ZXB3JJFZ.js +3 -0
  75. package/dist/chunks/update-command-DJLYU6AB.js +3 -0
  76. package/dist/chunks/{update-note-GYJWUDFS.js → update-note-CJ5XYKYH.js} +1 -1
  77. package/dist/chunks/watch-command-ZNMO4SF7.js +3 -0
  78. package/dist/index.js +13 -13
  79. package/package.json +9 -9
  80. package/dist/chunks/args-FSQFXDIX.js +0 -3
  81. package/dist/chunks/chunk-2J2PTA5O.js +0 -3
  82. package/dist/chunks/chunk-2MLASXG5.js +0 -3
  83. package/dist/chunks/chunk-5TEAR5XH.js +0 -3
  84. package/dist/chunks/chunk-63BBFKT2.js +0 -4
  85. package/dist/chunks/chunk-72TNSFL5.js +0 -36
  86. package/dist/chunks/chunk-AYB5AJ4E.js +0 -3
  87. package/dist/chunks/chunk-C32KGH4S.js +0 -3
  88. package/dist/chunks/chunk-LBDSFSYP.js +0 -3
  89. package/dist/chunks/chunk-OY4EGSPE.js +0 -3
  90. package/dist/chunks/chunk-UXRQ4UBQ.js +0 -66
  91. package/dist/chunks/chunk-WIPP5TWQ.js +0 -3
  92. package/dist/chunks/chunk-WZWK3PEZ.js +0 -3
  93. package/dist/chunks/chunk-ZRHYGR2L.js +0 -134
  94. package/dist/chunks/clip-command-NZNC46H2.js +0 -3
  95. package/dist/chunks/clipboard-GICOXMMN.js +0 -3
  96. package/dist/chunks/colour-GSDOHCFK.js +0 -3
  97. package/dist/chunks/command-GYCYLUHN.js +0 -3
  98. package/dist/chunks/config-command-6YUMMZF3.js +0 -3
  99. package/dist/chunks/continue-editing-QE5RRIMG.js +0 -3
  100. package/dist/chunks/decoded-NBZ335RZ.js +0 -3
  101. package/dist/chunks/execute-FYEXZ7EY.js +0 -3
  102. package/dist/chunks/extensions-V5O4NIHI.js +0 -3
  103. package/dist/chunks/image-3CMUB2P4.js +0 -3
  104. package/dist/chunks/install-IDUHZTTS.js +0 -3
  105. package/dist/chunks/install-L5C2UT6M.js +0 -3
  106. package/dist/chunks/launch-GUHDBMSJ.js +0 -17
  107. package/dist/chunks/lock-UQJ66TZ3.js +0 -3
  108. package/dist/chunks/manager-UKTMRXKE.js +0 -4
  109. package/dist/chunks/pdfium-LYHOU6WV.js +0 -3
  110. package/dist/chunks/preset-command-6A2C6VPQ.js +0 -3
  111. package/dist/chunks/registry-2YU7NW4P.js +0 -3
  112. package/dist/chunks/run-U2CU6VGE.js +0 -5
  113. package/dist/chunks/transcribe-SCL3LFZU.js +0 -3
  114. package/dist/chunks/transcribe-command-BX2VVUI3.js +0 -3
  115. package/dist/chunks/update-command-JCTCRPCS.js +0 -3
  116. package/dist/chunks/watch-command-ZLZAWTNJ.js +0 -3
@@ -2,5 +2,5 @@ import { createRequire as __forgeCreateRequire } from 'node:module';
2
2
  const require = __forgeCreateRequire(import.meta.url);
3
3
  import{a as l,c}from"./chunk-MF3KKEFB.js";import{e as p,f as u}from"./chunk-I25E2XDH.js";import{execFile as P}from"node:child_process";import{access as N,constants as A,mkdir as I,readFile as E,realpath as _,writeFile as F}from"node:fs/promises";import{homedir as B}from"node:os";import{dirname as C,join as f,posix as R,sep as m,win32 as S}from"node:path";import{promisify as T}from"node:util";var w=T(P),H=["yt-dlp","video"],X=e=>H.includes(e),a={"yt-dlp":{binary:"yt-dlp",name:"yt-dlp",formula:"yt-dlp",versionArgs:["--version"],version:e=>e.trim().split(`
4
4
  `)[0]?.match(/^\d+(\.\d+)+$/)?.[0]},video:{binary:"ffmpeg",name:"ffmpeg",formula:"ffmpeg",versionArgs:["-hide_banner","-version"],version:e=>e.match(/ffmpeg version (\S+)/)?.[1],beside:["ffprobe"]}},Y=e=>a[e].name,q=e=>a[e].formula;function $(e,n){let r=e.split(".").map(Number),i=n.split(".").map(Number);for(let t=0;t<Math.max(r.length,i.length);t++){let o=r[t]??0,s=i[t]??0;if(Number.isNaN(o)||Number.isNaN(s))return e>n;if(o!==s)return o>s}return!1}function g(e){let n=p(e);return n&&(u(n)?.version??u(n,"darwin","universal")?.version)}function y({platform:e=process.platform,env:n=process.env,deep:r=!1}={}){let t=(n.PATH??n.Path??"").split(e==="win32"?";":":").filter(Boolean);if(e==="darwin"&&t.push("/opt/homebrew/bin","/usr/local/bin"),r){let o=n.HOME??B(),{join:s}=e==="win32"?S:R;t.push(s(o,".local","bin"),s(o,"bin"),"/opt/local/bin","/usr/bin")}return[...new Set(t)]}var O=(e,n=process.platform)=>n==="win32"?`${e}.exe`:e;async function d(e){try{return await N(e,A.X_OK),!0}catch{return!1}}async function b(e,n){let r=a[e];if(await d(n)){for(let i of r.beside??[])if(!await d(f(C(n),O(i))))return;try{let{stdout:i}=await w(n,r.versionArgs,{timeout:5e3}),t=r.version(i);if(t===void 0)return;let o=await _(n).catch(()=>n),s=g(e);return{id:e,path:n,version:t,homebrew:o.includes(`${m}Cellar${m}`),tooOld:e==="yt-dlp"&&s!==void 0&&$(s,t)}}catch{return}}}var h=()=>f(l(),"own.json");async function v(){try{let e=JSON.parse(await E(h(),"utf8"));return typeof e=="object"&&e!==null?e:{}}catch{return{}}}async function j(e){let n=(await v())[e];return typeof n=="string"&&n!==""?n:void 0}async function z(e,n){let r=await v();n===void 0?delete r[e]:r[e]=n,await I(l(),{recursive:!0}),await F(h(),`${JSON.stringify(r,null,2)}
5
- `)}async function J(e,n={}){let r=await j(e);if(r!==void 0){let o=await b(e,r);if(o)return o}let t=process.env.FORGE_NO_OWN_TOOLS==="1"&&n.dirs===void 0?[]:n.dirs??y({deep:n.deep??!1});for(let o of t){let s=await b(e,f(o,O(a[e].binary)));if(s)return s}}async function k(e){if(await c(e)===void 0)return 0;try{let{removeExtension:n,extensionBytes:r}=await import("./manager-UKTMRXKE.js"),i=await r(e);return await n(e)?i:0}catch{return 0}}async function Q(e={}){let n=await J("yt-dlp",e);if(n&&!n.tooOld)return await k("yt-dlp"),{entry:n.path,own:!0};let r=await c("yt-dlp");return r?{entry:r.entry,own:!1}:void 0}async function x(e){if(e.brew!==void 0)return await d(e.brew)?e.brew:void 0;for(let n of y({env:{PATH:process.env.PATH??""}})){let r=f(n,"brew");if(await d(r))return r}}async function V(e,n={}){if(e.tooOld)return g(e.id);if(!e.homebrew)return;let r=await x(n);if(r!==void 0)try{let{stdout:i}=await w(r,["outdated","--json=v2","--formula",a[e.id].formula],{timeout:15e3,env:{...process.env,HOMEBREW_NO_AUTO_UPDATE:"1"}}),t=JSON.parse(i);if(!Array.isArray(t.formulae))return;let o=t.formulae[0]?.current_version;return typeof o=="string"?o:null}catch{return}}var Z=e=>e.homebrew?"Homebrew":e.id==="yt-dlp"?"yt-dlp":void 0;async function ee(e,n={}){let r,i;if(e.homebrew){let t=await x(n);if(t===void 0)throw new Error("Homebrew was not found");r=t,i=["upgrade",a[e.id].formula]}else if(e.id==="yt-dlp")r=e.path,i=["--update"];else throw new Error(`${a[e.id].name} cannot update itself`);try{await w(r,i,{timeout:10*6e4,maxBuffer:8<<20,...n.signal?{signal:n.signal}:{}})}catch(t){if(n.signal?.aborted)throw n.signal.reason??t;let o=t,s=(o.stderr??"").trim().split(`
5
+ `)}async function J(e,n={}){let r=await j(e);if(r!==void 0){let o=await b(e,r);if(o)return o}let t=process.env.FORGE_NO_OWN_TOOLS==="1"&&n.dirs===void 0?[]:n.dirs??y({deep:n.deep??!1});for(let o of t){let s=await b(e,f(o,O(a[e].binary)));if(s)return s}}async function k(e){if(await c(e)===void 0)return 0;try{let{removeExtension:n,extensionBytes:r}=await import("./manager-T3WDLUKR.js"),i=await r(e);return await n(e)?i:0}catch{return 0}}async function Q(e={}){let n=await J("yt-dlp",e);if(n&&!n.tooOld)return await k("yt-dlp"),{entry:n.path,own:!0};let r=await c("yt-dlp");return r?{entry:r.entry,own:!1}:void 0}async function x(e){if(e.brew!==void 0)return await d(e.brew)?e.brew:void 0;for(let n of y({env:{PATH:process.env.PATH??""}})){let r=f(n,"brew");if(await d(r))return r}}async function V(e,n={}){if(e.tooOld)return g(e.id);if(!e.homebrew)return;let r=await x(n);if(r!==void 0)try{let{stdout:i}=await w(r,["outdated","--json=v2","--formula",a[e.id].formula],{timeout:15e3,env:{...process.env,HOMEBREW_NO_AUTO_UPDATE:"1"}}),t=JSON.parse(i);if(!Array.isArray(t.formulae))return;let o=t.formulae[0]?.current_version;return typeof o=="string"?o:null}catch{return}}var Z=e=>e.homebrew?"Homebrew":e.id==="yt-dlp"?"yt-dlp":void 0;async function ee(e,n={}){let r,i;if(e.homebrew){let t=await x(n);if(t===void 0)throw new Error("Homebrew was not found");r=t,i=["upgrade",a[e.id].formula]}else if(e.id==="yt-dlp")r=e.path,i=["--update"];else throw new Error(`${a[e.id].name} cannot update itself`);try{await w(r,i,{timeout:10*6e4,maxBuffer:8<<20,...n.signal?{signal:n.signal}:{}})}catch(t){if(n.signal?.aborted)throw n.signal.reason??t;let o=t,s=(o.stderr??"").trim().split(`
6
6
  `).filter(Boolean).at(-1)?.replace(/^Error:\s*/,"");throw new Error(s||o.message||"the update failed")}}export{H as a,X as b,Y as c,q as d,$ as e,y as f,b as g,j as h,z as i,J as j,k,Q as l,V as m,Z as n,ee as o};
@@ -1,3 +1,3 @@
1
1
  import { createRequire as __forgeCreateRequire } from 'node:module';
2
2
  const require = __forgeCreateRequire(import.meta.url);
3
- import{c as i,e as s,f as o}from"./chunk-N6RCLJE6.js";import{H as n}from"./chunk-WIPP5TWQ.js";var g=["output","theme","quality","update-check"];async function p(a){if(a.action==="path")return{stdout:[i()],exitCode:0,config:{path:i()},warnings:[]};if(a.action==="list"){let{prefs:e,warning:u}=await s(),f=[`output ${e.defaultOutput}`,`theme ${e.theme??"not set"}`,`quality ${e.quality}`,`update-check ${e.updateCheck===!1?"off":"on"}`,"",i()];return u!==void 0&&f.unshift(`\u26A0 ${u}`,""),{stdout:f,exitCode:0,config:{output:e.defaultOutput,theme:e.theme??null,quality:e.quality,"update-check":e.updateCheck===!1?"off":"on",path:i()},warnings:u===void 0?[]:[{code:"config-unreadable",message:u}]}}let{key:r,value:t}=a;if(r==="theme"){if(t!=="dark"&&t!=="light")throw n(`Theme must be dark or light, not ${t}.`);return await o({theme:t}),{stdout:[`theme is now ${t}`],exitCode:0,config:{theme:t},warnings:[]}}if(r==="quality"){let e=Number(t);if(!Number.isInteger(e)||e<1||e>100)throw n(`Quality must be a whole number between 1 and 100, not ${t}.`);return await o({quality:e}),{stdout:[`quality is now ${e}`],exitCode:0,config:{quality:e},warnings:[]}}if(r==="update-check"){if(t!=="on"&&t!=="off")throw n(`update-check must be on or off, not ${t}.`);return await o({updateCheck:t==="on"}),{stdout:[`update-check is now ${t}`],exitCode:0,config:{"update-check":t},warnings:[]}}if(t.trim().length===0)throw n("Output must be a folder path.");return await o({defaultOutput:t}),{stdout:[`output is now ${t}`],exitCode:0,config:{output:t},warnings:[]}}export{g as a,p as b};
3
+ import{c as i,e as s,f as o}from"./chunk-N6RCLJE6.js";import{E as n}from"./chunk-CVNYUROW.js";var g=["output","theme","quality","update-check"];async function p(a){if(a.action==="path")return{stdout:[i()],exitCode:0,config:{path:i()},warnings:[]};if(a.action==="list"){let{prefs:e,warning:u}=await s(),f=[`output ${e.defaultOutput}`,`theme ${e.theme??"not set"}`,`quality ${e.quality}`,`update-check ${e.updateCheck===!1?"off":"on"}`,"",i()];return u!==void 0&&f.unshift(`\u26A0 ${u}`,""),{stdout:f,exitCode:0,config:{output:e.defaultOutput,theme:e.theme??null,quality:e.quality,"update-check":e.updateCheck===!1?"off":"on",path:i()},warnings:u===void 0?[]:[{code:"config-unreadable",message:u}]}}let{key:r,value:t}=a;if(r==="theme"){if(t!=="dark"&&t!=="light")throw n(`Theme must be dark or light, not ${t}.`);return await o({theme:t}),{stdout:[`theme is now ${t}`],exitCode:0,config:{theme:t},warnings:[]}}if(r==="quality"){let e=Number(t);if(!Number.isInteger(e)||e<1||e>100)throw n(`Quality must be a whole number between 1 and 100, not ${t}.`);return await o({quality:e}),{stdout:[`quality is now ${e}`],exitCode:0,config:{quality:e},warnings:[]}}if(r==="update-check"){if(t!=="on"&&t!=="off")throw n(`update-check must be on or off, not ${t}.`);return await o({updateCheck:t==="on"}),{stdout:[`update-check is now ${t}`],exitCode:0,config:{"update-check":t},warnings:[]}}if(t.trim().length===0)throw n("Output must be a folder path.");return await o({defaultOutput:t}),{stdout:[`output is now ${t}`],exitCode:0,config:{output:t},warnings:[]}}export{g as a,p as b};
@@ -0,0 +1,3 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ import{a as E}from"./chunk-O7DK3GJT.js";import{i as R}from"./chunk-DYIATUFE.js";import{a as F,ka as y}from"./chunk-CVNYUROW.js";function P(n=process.env){let r=Number(n.UV_THREADPOOL_SIZE),o=E();return Number.isInteger(r)&&r>0?Math.min(o,r):o}function w(n){let r=n!==void 0&&Number.isFinite(n)?n:void 0;return Math.max(1,r??P())}async function x(n,r,o,f){let b=[],l=[];for(let[i,u]of n.entries())(f?.(u)?l:b).push(i);let p=0,m=0,t,g=async()=>{for(;;){let i=b[p],u=t?void 0:l[m];if(i!==void 0&&(u===void 0||i<u))p++,await o(n[i],i);else if(u!==void 0)m++,t=o(n[u],u).finally(()=>{t=void 0}),await t;else if(t)await t;else return}},d=Math.min(w(r),n.length);await Promise.all(Array.from({length:d},g))}async function T(n,r){let o=r.onEvent??(()=>{}),f=r.engineFor??R,b=w(r.concurrency),l=n.length,p=[],m=[],t=0;await x(n,b,async(e,a)=>{if(r.signal?.aborted)return;o({type:"job:start",job:e,index:a,total:l});let h=f(e);if(!h){t++;let s=e.sources[0].path,c={path:s,error:y(s,new Error(`no engine runs ${e.op}`))};m[a]=c,o({type:"job:error",job:e,failure:c,completed:t,total:l});return}try{let s=await h.run(e,c=>o({type:"job:phase",job:e,progress:c}),r.signal);p[a]=s,t++,o({type:"job:done",job:e,result:s,completed:t,total:l})}catch(s){t++;let c=e.sources[0].path,J=F(s)?s:y(c,s),v={path:c,error:J};m[a]=v,o({type:"job:error",job:e,failure:v,completed:t,total:l})}},e=>f(e)?.alone===!0);let d=p.filter(e=>e!==void 0),i=m.filter(e=>e!==void 0),u={results:d,failures:i,inputBytes:d.reduce((e,a)=>e+a.job.sources[0].bytes,0),outputBytes:d.reduce((e,a)=>e+a.outputBytes,0)};return o({type:"batch:done",summary:u}),u}export{P as a,w as b,x as c,T as d};
@@ -1,3 +1,3 @@
1
1
  import { createRequire as __forgeCreateRequire } from 'node:module';
2
2
  const require = __forgeCreateRequire(import.meta.url);
3
- import{c as P}from"./chunk-C32KGH4S.js";import{j as v}from"./chunk-WZWK3PEZ.js";import{d as y,na as s}from"./chunk-WIPP5TWQ.js";import{mkdtemp as x,rm as F}from"node:fs/promises";import{tmpdir as z}from"node:os";import{join as h}from"node:path";var f={background:"#ffffff",keepMetadata:!1};function q(e,r,n){switch(e.kind){case"cut":return{op:"convert",sources:[r],outputs:[n],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:[n],target:"png",options:f};case"boost":return{op:"boost",sources:[r],outputs:[n],scale:e.scale,target:"png",options:f};case"encode":return{op:"convert",sources:[r],outputs:[n],target:e.target,options:{...f,...e.background?{background:e.background}:{},...e.quality!==void 0?{quality:e.quality}:{},...e.compress?{compress:e.compress}:{},...e.trim?{trim:!0}:{},...e.crop?{crop:{aspect:e.crop}}:{},...e.resize?{resize:e.resize}:{}}}}}async function C(e,r,n,o){let E=o.probe??v,d=await x(h(z(),"forge-preset-")),I={force:o.force,...o.signal?{signal:o.signal}:{},...o.onEvent?{onEvent:o.onEvent}:{}};try{let i=e;for(let[l,t]of r.entries()){o.onPass?.(l);let u=l===r.length-1,m=u?n:h(d,`${l}.png`),a=await P([q(t,i,m)],{...I,...u?{}:{force:!0},...u&&t.kind==="encode"&&t.maxBytes?{targetBytes:t.maxBytes,...t.quality===void 0?{}:{maxQuality:t.quality}}:{}});if(a.cancelled)return{kind:"cancelled"};let g=a.refusals[0];if(g)return{kind:"refused",error:g.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(m);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 F(d,{recursive:!0,force:!0})}}export{C as a};
3
+ import{b as P}from"./chunk-GRWOJKQB.js";import{j as v}from"./chunk-DYIATUFE.js";import{a as y,ka as s}from"./chunk-CVNYUROW.js";import{mkdtemp as x,rm as F}from"node:fs/promises";import{tmpdir as z}from"node:os";import{join as h}from"node:path";var f={background:"#ffffff",keepMetadata:!1};function q(e,r,n){switch(e.kind){case"cut":return{op:"convert",sources:[r],outputs:[n],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:[n],target:"png",options:f};case"boost":return{op:"boost",sources:[r],outputs:[n],scale:e.scale,target:"png",options:f};case"encode":return{op:"convert",sources:[r],outputs:[n],target:e.target,options:{...f,...e.background?{background:e.background}:{},...e.quality!==void 0?{quality:e.quality}:{},...e.compress?{compress:e.compress}:{},...e.trim?{trim:!0}:{},...e.crop?{crop:{aspect:e.crop}}:{},...e.resize?{resize:e.resize}:{}}}}}async function C(e,r,n,o){let E=o.probe??v,d=await x(h(z(),"forge-preset-")),I={force:o.force,...o.signal?{signal:o.signal}:{},...o.onEvent?{onEvent:o.onEvent}:{}};try{let i=e;for(let[l,t]of r.entries()){o.onPass?.(l);let u=l===r.length-1,m=u?n:h(d,`${l}.png`),a=await P([q(t,i,m)],{...I,...u?{}:{force:!0},...u&&t.kind==="encode"&&t.maxBytes?{targetBytes:t.maxBytes,...t.quality===void 0?{}:{maxQuality:t.quality}}:{}});if(a.cancelled)return{kind:"cancelled"};let g=a.refusals[0];if(g)return{kind:"refused",error:g.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(m);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 F(d,{recursive:!0,force:!0})}}export{C as a};
@@ -1,6 +1,6 @@
1
1
  import { createRequire as __forgeCreateRequire } from 'node:module';
2
2
  const require = __forgeCreateRequire(import.meta.url);
3
- import{a as $,h as at,i as _}from"./chunk-YINYF6C7.js";import{b as d,c as R,d as P,f as v,g as H,h as X}from"./chunk-QVACE4IE.js";import{j as st}from"./chunk-WZWK3PEZ.js";import{g as ot}from"./chunk-5TEAR5XH.js";import{d as tt,m as et,w as nt}from"./chunk-WIPP5TWQ.js";import{a as Z}from"./chunk-H3DIRJFE.js";import{b as rt}from"./chunk-KXKQDFHX.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":D(n)}function D(t){let e=(t%360+360)%360;return(xt.find(([n])=>e<n)??[360,"rose"])[1]}var Ft=["full","mono","analogous","opposite","split","triad","pastel"],it={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},vt=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}}],bt={analogous:[-30,0,30],opposite:[0,180],split:[0,150,210],triad:[0,120,240]},dt=.553,$t=.024,b=t=>v(R(t)),C=(t,e,n)=>P(H({L:t,C:Math.max(0,e),h:(n+360)%360})),K=(t,e)=>(t-e+540)%360-180;function lt(t,e,n){let r=H({L:t,C:e,h:n}),o=R(P(r));return Math.hypot(o.L-r.L,o.a-r.a,o.b-r.b)<.003}function L(t,e){let n=0,r=.4;for(let o=0;o<30;o++){let a=(n+r)/2;lt(t,a,e)?n=a:r=a}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:o}=b(t),a=A(n,e.brightness),i=(o+e.hue+360)%360,l=q(r,L(a,i),e.saturation);for(let s=0;s<40&&l>0&&!lt(a,l,i);s++)l-=.005;return C(a,l,i)}function k(t,e,n,r){let o=A(t,r.brightness),a=(n+r.hue+360)%360,i=L(o,a);return C(o,Math.min(i,q(e,i,r.saturation)),a)}function Y(t,e,n){if(!e)return t;let r=b(t[n].rgb).L;return t.map((o,a)=>{if(a===n)return o;let i=b(o.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{...o,rgb:s,hex:d(s)}})}function Tt(t,e,n,r){return Y(t(T(e,n)),n.contrast,r)}function ct(t,e){let n=b(t),r=G.map(s=>b(s.hex)),o=0;r.forEach((s,c)=>{Math.abs(K(n.h,s.h))<Math.abs(K(n.h,r[o].h))&&(o=c)});let a=r[o],i=Math.max(-10,Math.min(10,K(n.h,a.h)/2)),l=W(n);return G.map((s,c)=>{if(c===o)return{name:s.name,role:s.role,rgb:T(t,e),yours:!0};let h=r[c],p=n.L>=a.L?h.L+(n.L-a.L)*(1-h.L)/(1-a.L):h.L*n.L/a.L,f=A(p,e.brightness),g=(h.h+i+e.hue+360)%360,x=L(f,g),u=Math.min(1,W(h)),S=Math.min(x,q(l*u*x,x,e.saturation));return{name:s.name,role:s.role,rgb:C(f,S,g),yours:!1}})}function wt(t,e,n){let r=b(t),o=w(t);if(e==="mono")return[{name:o,rgb:T(t,n),yours:!0},{name:`${o} soft`,rgb:k(r.L,r.C*.5,r.h,n),yours:!1},{name:`${o} dusty`,rgb:k(r.L,r.C*.22,r.h,n),yours:!1}];if(e==="pastel")return ct(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 a=W(r);return(bt[e]??[0]).map(l=>{if(l===0)return{name:o,rgb:T(t,n),yours:!0};let s=(r.h+l+360)%360,c=a*L(r.L,s);return{name:a>0?D(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 yt(t,e,n){let r=b(t).h+e.hue,o=Math.max(0,$t*(1+e.saturation/100));return _(C(A(dt,e.brightness),o,r),n)}function At(t,e,n=B,r=$){let o=at(r);return{rows:(e==="full"?ct(t,n):wt(t,e,n)).map(({name:l,role:s,rgb:c,yours:h})=>({name:l,...s?{role:s}:{},steps:Y(_(c,r),n.contrast,o),yours:h})),neutral:Y(yt(t,n,r),n.contrast,o)}}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 ht(t){let e=t==="dark";return{ink:e?"#FAFAFA":"#111111",grey:e?"#A1A1AA":"#71717A",edge:e?"#FFFFFF":"#000000",paper:e?"#18181B":"#FFFFFF"}}var St=`<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>
3
+ import{a as $,h as at,i as _}from"./chunk-VTA6Z45X.js";import{b as d,c as R,d as P,f as v,g as H,h as X}from"./chunk-QVACE4IE.js";import{j as st}from"./chunk-DYIATUFE.js";import{g as ot}from"./chunk-7KYO62XK.js";import{a as tt,j as et,t as nt}from"./chunk-CVNYUROW.js";import{a as Z}from"./chunk-H3DIRJFE.js";import{b as rt}from"./chunk-KXKQDFHX.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":D(n)}function D(t){let e=(t%360+360)%360;return(xt.find(([n])=>e<n)??[360,"rose"])[1]}var Ft=["full","mono","analogous","opposite","split","triad","pastel"],it={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},vt=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}}],bt={analogous:[-30,0,30],opposite:[0,180],split:[0,150,210],triad:[0,120,240]},dt=.553,$t=.024,b=t=>v(R(t)),C=(t,e,n)=>P(H({L:t,C:Math.max(0,e),h:(n+360)%360})),K=(t,e)=>(t-e+540)%360-180;function lt(t,e,n){let r=H({L:t,C:e,h:n}),o=R(P(r));return Math.hypot(o.L-r.L,o.a-r.a,o.b-r.b)<.003}function L(t,e){let n=0,r=.4;for(let o=0;o<30;o++){let a=(n+r)/2;lt(t,a,e)?n=a:r=a}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:o}=b(t),a=A(n,e.brightness),i=(o+e.hue+360)%360,l=q(r,L(a,i),e.saturation);for(let s=0;s<40&&l>0&&!lt(a,l,i);s++)l-=.005;return C(a,l,i)}function k(t,e,n,r){let o=A(t,r.brightness),a=(n+r.hue+360)%360,i=L(o,a);return C(o,Math.min(i,q(e,i,r.saturation)),a)}function Y(t,e,n){if(!e)return t;let r=b(t[n].rgb).L;return t.map((o,a)=>{if(a===n)return o;let i=b(o.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{...o,rgb:s,hex:d(s)}})}function Tt(t,e,n,r){return Y(t(T(e,n)),n.contrast,r)}function ct(t,e){let n=b(t),r=G.map(s=>b(s.hex)),o=0;r.forEach((s,c)=>{Math.abs(K(n.h,s.h))<Math.abs(K(n.h,r[o].h))&&(o=c)});let a=r[o],i=Math.max(-10,Math.min(10,K(n.h,a.h)/2)),l=W(n);return G.map((s,c)=>{if(c===o)return{name:s.name,role:s.role,rgb:T(t,e),yours:!0};let h=r[c],p=n.L>=a.L?h.L+(n.L-a.L)*(1-h.L)/(1-a.L):h.L*n.L/a.L,f=A(p,e.brightness),g=(h.h+i+e.hue+360)%360,x=L(f,g),u=Math.min(1,W(h)),S=Math.min(x,q(l*u*x,x,e.saturation));return{name:s.name,role:s.role,rgb:C(f,S,g),yours:!1}})}function wt(t,e,n){let r=b(t),o=w(t);if(e==="mono")return[{name:o,rgb:T(t,n),yours:!0},{name:`${o} soft`,rgb:k(r.L,r.C*.5,r.h,n),yours:!1},{name:`${o} dusty`,rgb:k(r.L,r.C*.22,r.h,n),yours:!1}];if(e==="pastel")return ct(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 a=W(r);return(bt[e]??[0]).map(l=>{if(l===0)return{name:o,rgb:T(t,n),yours:!0};let s=(r.h+l+360)%360,c=a*L(r.L,s);return{name:a>0?D(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 yt(t,e,n){let r=b(t).h+e.hue,o=Math.max(0,$t*(1+e.saturation/100));return _(C(A(dt,e.brightness),o,r),n)}function At(t,e,n=B,r=$){let o=at(r);return{rows:(e==="full"?ct(t,n):wt(t,e,n)).map(({name:l,role:s,rgb:c,yours:h})=>({name:l,...s?{role:s}:{},steps:Y(_(c,r),n.contrast,o),yours:h})),neutral:Y(yt(t,n,r),n.contrast,o)}}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 ht(t){let e=t==="dark";return{ink:e?"#FAFAFA":"#111111",grey:e?"#A1A1AA":"#71717A",edge:e?"#FFFFFF":"#000000",paper:e?"#18181B":"#FFFFFF"}}var St=`<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
4
  `;function I(t,e,n,r="light"){let{ink:o,grey:a,edge:i,paper:l}=ht(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="${o}">${M(t)}</text><text id="subtitle" x="24" y="58" ${y} font-size="12" fill="${a}">${M(e)}</text>`,x=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="${o}">${M(u.name)}</text><text id="value" x="1" y="${s+40}" ${y} font-size="11" fill="${a}">${M(u.value)}</text></g>`).join(`
5
5
  `);return`<svg xmlns="http://www.w3.org/2000/svg" width="${h}" height="${p}" viewBox="0 0 ${h} ${p}">
6
6
  `+(n.some(u=>u.alpha!==void 0)?St:"")+`<g id="${E(t)}">
@@ -16,4 +16,4 @@ ${mt}
16
16
  <g id="steps">${gt}</g>
17
17
  ${pt}
18
18
  </g>
19
- </svg>`}function Ht(t,e,n,r="light",o=$){return I(`${O(w(t))} neutral`,`from ${d(t)} \xB7 ${n} tint \xB7 ${N(o)} in OKLCH`,e.map(a=>({id:`neutral-${a.step}`,name:String(a.step),value:a.hex,hex:a.hex})),r)}function _t(t,e,n,r="light",o=$){let a=w(t);return I(`${O(a)} alpha`,`from ${d(t)} \xB7 over ${n} \xB7 ${N(o)}`,e.map(i=>({id:`${a}-alpha-${i.step}`,name:String(i.step),value:i.hex8,hex:d(i.rgb),alpha:i.a})),r)}async function qt(t,e=192){let n=await st(t);if(n.kind!=="image")throw et(t,`a ${Z[n.format].label}`);let r=await ot(t,n.format);try{let o=await rt(),{data:a,info:i}=await o(r.path,{animated:!1}).rotate().resize(e,e,{fit:"inside",withoutEnlargement:!0}).ensureAlpha().raw().toBuffer({resolveWithObject:!0});return{source:n,pixels:{width:i.width,height:i.height,rgba:new Uint8Array(a.buffer,a.byteOffset,a.length)}}}catch(o){throw tt(o)?o:nt(t,o)}finally{await r.cleanup()}}export{Ft as a,it as b,B as c,vt as d,Tt as e,At as f,I as g,Ut as h,jt as i,Pt as j,Ht as k,_t as l,qt as m};
19
+ </svg>`}function Ht(t,e,n,r="light",o=$){return I(`${O(w(t))} neutral`,`from ${d(t)} \xB7 ${n} tint \xB7 ${N(o)} in OKLCH`,e.map(a=>({id:`neutral-${a.step}`,name:String(a.step),value:a.hex,hex:a.hex})),r)}function _t(t,e,n,r="light",o=$){let a=w(t);return I(`${O(a)} alpha`,`from ${d(t)} \xB7 over ${n} \xB7 ${N(o)}`,e.map(i=>({id:`${a}-alpha-${i.step}`,name:String(i.step),value:i.hex8,hex:d(i.rgb),alpha:i.a})),r)}async function qt(t,e=192){let n=await st(t);if(n.kind!=="image")throw et(t,`a ${Z[n.format].label}`);let r=await ot(t,n.format);try{let o=await rt(),{data:a,info:i}=await o(r,{animated:!1}).rotate().resize(e,e,{fit:"inside",withoutEnlargement:!0}).ensureAlpha().raw().toBuffer({resolveWithObject:!0});return{source:n,pixels:{width:i.width,height:i.height,rgba:new Uint8Array(a.buffer,a.byteOffset,a.length)}}}catch(o){throw tt(o)?o:nt(t,o)}}export{Ft as a,it as b,B as c,vt as d,Tt as e,At as f,I as g,Ut as h,jt as i,Pt as j,Ht as k,_t as l,qt as m};
@@ -0,0 +1,4 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ import{c as ie,d as ue,e as pe,g as ce,h as de}from"./chunk-W2QJA73Q.js";import{a as re,b as oe,c as se,k as ne,m as M,n as O,o as ae}from"./chunk-ZHNPBRCX.js";import{b as X,c as T}from"./chunk-SNFUGJ3M.js";import{a as y}from"./chunk-XUKYIVJC.js";import{b as I}from"./chunk-GRWOJKQB.js";import{e as be}from"./chunk-R24JCIZ5.js";import{a as F,c as _,d as ee,e as C,f as te}from"./chunk-XPATZLEH.js";import{e as fe,f as le,g as me,h as ge,i as he,j as ye}from"./chunk-57M4J2BR.js";import{a as g}from"./chunk-RK3WGALB.js";import{d as $}from"./chunk-EEQSUBBL.js";import{a as Z}from"./chunk-K6ERQTUQ.js";import{a as L,d as U}from"./chunk-T37DEXUI.js";import{a as Y,c as K,d as E,e as Q}from"./chunk-BIBDLXCG.js";import{E as N,F as V,I as G,a as P,o as z,q as k,s as q,ta as H,v as J}from"./chunk-CVNYUROW.js";import{a as h,b as W}from"./chunk-J7FLFHQJ.js";import{b as x,c as w}from"./chunk-VLVNA4T3.js";import{a as R}from"./chunk-H3DIRJFE.js";import{readFile as Te}from"node:fs/promises";import{dirname as Oe,resolve as Me}from"node:path";async function we(e){let r=[],t=[...e.resolved.failures];for(let o of e.resolved.sources){let s=F(o);if(!s.includes(e.target)){t.push({path:o.path,error:q(o,e.target,s)});continue}let a={sourcePath:o.path,target:e.target,output:e.output,sourceRoot:e.resolved.roots.get(o.path)},n=E(a);K(n,o.path)&&e.target!==o.format&&(n=Q({...a,suffix:e.target})),r.push({op:"convert",sources:[o],outputs:[n],target:e.target,options:e.options})}return{jobs:r,failures:t}}import{resolve as je}from"node:path";function Be(e,r=new Set){let t={path:je(e.path),kind:e.kind,format:e.format,bytes:e.bytes},o=e.kind==="document"&&e.encrypted===!0,s={targets:F(e).filter(a=>!o||C(a)),actions:ce([e],r).filter(a=>!o||a.id===O.id).map(a=>a.id)};if(e.kind==="image")return{...t,width:e.width,height:e.height,...s};if(e.kind==="media"){let a=e.facts;return{...t,...a?{duration:a.duration}:{},...a?.video?{width:a.video.width,height:a.video.height,fps:a.video.fps}:{},...s}}return{...t,pages:e.pages,encrypted:e.encrypted,...s}}async function Ie(e){let r=await y(e,{recursive:!1}),{installedExtensionIds:t}=await import("./available-TNMISSBA.js"),o=await t();return{probes:r.sources.map(s=>Be(s,o)),failures:r.failures}}import{dirname as Se}from"node:path";var j=e=>({cwd:e.cwd??process.cwd(),...e.home===void 0?{}:{home:e.home}});function ve(e,r){let t=x(Se(e),j(r));return t==="."?"":` in ${t.endsWith("/")?t:`${t}/`}`}function xe(e,r){let{pct:t,direction:o}=W(e,r);return o==="same"?"same size":`${t}% ${o}`}function Pe(e,r={}){let t=e.results[0];if(!t)return[];let o=t.job.sources[0],s=t.job.outputs;if(s.length>1){let n=[`\u2713 ${w(o.path)} \u2192 ${s.length} files${ve(s[0],r)}`,` ${s.map(i=>w(i)).join(", ")}`,` ${h(o.bytes)} \u2192 ${h(t.outputBytes)} total`];for(let i of t.warnings)n.push("",`\u26A0 ${i.message}`);return n}let a=[`\u2713 ${w(o.path)} \u2192 ${x(s[0],j(r))}`,` ${h(o.bytes)} \u2192 ${h(t.outputBytes)} \xB7 ${xe(o.bytes,t.outputBytes)}`];for(let n of t.warnings)a.push("",`\u26A0 ${n.message}`);return a}function ke(e,r={}){let t=[`\u2713 ${e.results.length} converted`,` ${h(e.inputBytes)} \u2192 ${h(e.outputBytes)} \xB7 ${xe(e.inputBytes,e.outputBytes)}`];for(let s of e.results)for(let a of s.job.outputs)t.push(` ${x(a,j(r))}`);let o=e.results.flatMap(s=>s.warnings);if(o.length>0){t.push("");for(let s of o)t.push(`\u26A0 ${s.message}`)}return t}function $e(e,r={}){let t=e.results.flatMap(u=>u.job.outputs),o=t.map(u=>w(u)).join(", "),s=t.length===1?"file":"files",a=t[0]===void 0?"":ve(t[0],r),n=[`\u2713 ${t.length} ${s} \xB7 ${o}${a}`],i=e.results.flatMap(u=>u.warnings);for(let u of i)n.push("",`\u26A0 ${u.message}`);return n}function B(e,r){if(e.length===0)return[];let t=[];for(let o of e)t.push(...H(o.error,{debug:r.debug}),"");return t}function Re(){let e=new Set(_()),r=new Set(ee()),t=["Formats",""];for(let s of e){let a=R[s],n=r.has(s)?"read and write":"read only";t.push(` ${a.label.padEnd(6)} ${a.extensions.join(" ").padEnd(12)} ${n}`)}let o=[...e].filter(s=>!r.has(s)).map(s=>R[s].label);if(o.length>0){let s=o.join(", "),[a,n]=o.length===1?["is","it"]:["are","them"];t.push("",`${s} ${a} read only because Forge cannot yet write ${n}.`)}return t}function Ee(e,r={}){let t=[R[e.format].label,h(e.bytes)];return e.duration!==void 0&&t.push($(e.duration)),e.width!==void 0&&e.height!==void 0&&t.push(`${e.width}\xD7${e.height}`),e.fps!==void 0&&t.push(`${e.fps} fps`),e.pages!==void 0&&t.push(`${e.pages} ${e.pages===1?"page":"pages"}`),e.encrypted&&t.push("password-protected"),[`${x(e.path,j(r))} \xB7 ${t.join(" \xB7 ")}`,` converts to ${e.targets.join(", ")}`,` actions ${e.actions.join(", ")}`]}import{createInterface as Fe}from"node:readline";import{PassThrough as Je}from"node:stream";function Ne(e){return new Promise(r=>{let t=Fe({input:e,terminal:!1}),o=!1,s=a=>{if(o)return;o=!0,t.close(),e.pause(),e.unref?.(),r(a.replace(/\r$/,""))};t.once("line",s),t.once("close",()=>s(""))})}async function Ce(e){if(e.stdin)return Ne(process.stdin);if(!process.stdin.isTTY)return;let r=new Je,t=Fe({input:process.stdin,output:r,terminal:!0});try{return process.stderr.write("Password: "),await new Promise(o=>t.question("",o))}finally{process.stderr.write(`
4
+ `),t.close()}}function Ae(e){return e.kind==="preset"?e.name:e.kind==="pageop"?"PDF":e.kind==="compress"?"Compress":e.kind==="convert"?"Convert":"Edit"}function A(e){return e.length===0?0:e.some(r=>r.error.code==="invalid-arguments")?2:1}function De(e,r){if(e.action==="merge")return{};if(e.action==="rotate")return{degrees:e.rotate};if(e.action==="extract")return{pages:e.pages,separate:e.separate?"many":"one"};if(e.action==="delete")return{pages:e.pages};let t=r.find(n=>n.kind==="document"),o=t?.pages??0,s=e.split;if(!s)throw N("--split needs a mode: every-page, every=N or at=N,N.");if(s.mode==="every-page")return{cuts:ie(o)};if(s.mode==="every-n")return{cuts:ue(o,s.n)};let a=Math.max(o-1,0);for(let n of s.after)if(!Number.isInteger(n)||n<1||n>a)throw V(String(n),`"${n}" is outside 1 and ${a} \u2014 ${t?w(t.path):"the document"} has ${o} pages.`,o);return{cuts:s.after.map(n=>n-1)}}function We(e,r){let t;return()=>r?(t??=Ce({stdin:e}).then(o=>e&&o===""?void 0:o),t):Promise.resolve(void 0)}async function ze(e,r,t,o){let s;if(e.encrypted){if(s=r.password??await t(),s===void 0)return{failure:{path:e.path,error:J(e.path)}};let i;try{i=await Z(await Te(e.path),s)}catch{return{failure:{path:e.path,error:J(e.path,{attempted:!0})}}}i.destroy()}let a;try{a=O.plan([e],{target:r.target,background:r.options.background,keepMetadata:r.options.keepMetadata,dpi:String(r.dpi??150),...r.options.quality===void 0?{}:{quality:r.options.quality},...r.pages===void 0?{}:{pages:r.pages},...r.output===void 0?{}:{destination:r.output},...o===void 0?{}:{sourceRoot:o}})}catch(i){if(!P(i))throw i;return{failure:{path:e.path,error:i}}}let n=a[0];if(n?.op!=="convert")throw new Error(`convertAction.plan() did not return a convert job for ${e.path}`);return s!==void 0&&(n.options.password=s),{job:n}}function S(e,r){return t=>{if(t.type==="search:attempt"){r||e.onSearch?.(t.rung.dpi===void 0?`attempt ${t.attempt} of ${t.of}`:`${t.rung.dpi} dpi \xB7 attempt ${t.attempt} of ${t.of}`);return}if(t.type==="search:settled"){r&&e.onSearch?.(`${t.completed} of ${t.total} searched`);return}if(!r&&t.type==="job:phase"&&t.progress.phase==="time"){let o=t.progress,s=`${$(o.done)} of ${$(o.total)}`;e.onEncode?.(o.pass?`pass ${o.pass.at} of 2 \xB7 ${s}`:s);return}r&&(t.type==="job:done"||t.type==="job:error")&&e.onProgress?.({completed:t.completed,total:t.total})}}var b=(e,r)=>({kind:e,results:[],failures:r,inputBytes:0,outputBytes:0});async function qe(e){let r=await y(e.inputs,{recursive:!1});if(r.sources.length===0)return b("pageop",r.failures);let t=pe.find(n=>n.id===e.action);if(!t)throw new Error(`no action registered for "${e.action}"`);let o=r.sources[0]?.path??"";if(!t.appliesTo(r.sources)){let n=de(t,r.sources)??"not available for these files";return b("pageop",[...r.failures,{path:o,error:k(e.action,n)}])}let s;try{s=t.plan(r.sources,De(e,r.sources))}catch(n){if(!P(n))throw n;return b("pageop",[...r.failures,{path:o,error:n}])}let a=await I(s,{force:e.force});return{kind:"pageop",results:a.results,failures:[...r.failures,...a.refusals,...a.failures],inputBytes:a.inputBytes,outputBytes:a.outputBytes}}async function Ve(e,r){let t=await y(e.inputs,{recursive:e.recursive}),o=[],s=[];for(let i of t.sources){if(!M.appliesTo([i])){s.push({path:i.path,error:z(i)});continue}let u=e.output!==void 0&&!Y(e.output)?Me(e.output):void 0,f=e.output===void 0||u!==void 0?Oe(i.path):Oe(E({sourcePath:i.path,target:i.format,output:e.output,sourceRoot:t.roots.get(i.path)})),[d]=M.plan([i],{mode:e.maxBytes===void 0?"quality":"size",...e.quality===void 0?{}:{quality:e.quality},...e.options.media??{},destination:f});d?.op==="convert"&&(u!==void 0&&(d.outputs=[u]),e.dpi!==void 0&&(d.options.dpi=e.dpi),o.push(d))}let a=o.length>1;a&&r.onProgress?.({completed:0,total:o.length});let n=await I(o,{force:e.force,...e.concurrency===void 0?{}:{concurrency:e.concurrency},...e.maxBytes===void 0?{}:{targetBytes:e.maxBytes},onEvent:S(r,a)});return{kind:"compress",results:n.results,failures:[...t.failures,...s,...n.refusals,...n.unreachable.map(i=>({path:i.job.sources[0].path,error:i.error})),...n.failures],inputBytes:n.inputBytes,outputBytes:n.outputBytes}}async function Ge(e,r){let t=e.kind,o=e.op==="remove-background"?L(e.target):void 0;if(o)return b(t,[{path:"",error:o}]);let{installed:s}=await import("./paths-6OENILJ4.js"),a=await s(e.op);if(!a)return b(t,[{path:"",error:G(e.op)}]);if(e.op==="boost"&&e.scale!==void 0){let{assetFor:l,catalogEntry:p}=await import("./catalog-FMHWWMUX.js"),m=p("boost"),v=m&&l(m)?.version,D=U(e.scale,a.version,v);if(D)return b(t,[{path:"",error:D}])}let n=await y(e.inputs,{recursive:e.recursive}),i=e.op==="boost"?oe:se,u=[],f=[];for(let l of n.sources){if(!i.appliesTo([l])){f.push({path:l.path,error:k(e.op,"it works on images, not documents","Try an image such as a JPEG, PNG, WebP or HEIC file.")});continue}let p=re(l,e.target);if(p){f.push({path:l.path,error:p});continue}u.push(...i.plan([l],{target:e.target,background:e.options.background,keepMetadata:e.options.keepMetadata,...e.scale===void 0?{}:{scale:e.scale},...e.options.quality===void 0?{}:{quality:e.options.quality},...e.output===void 0?{}:{output:e.output},roots:n.roots}))}let d=u.length>1;d&&r.onProgress?.({completed:0,total:u.length});let c=await I(u,{force:e.force,concurrency:1,...r.signal===void 0?{}:{signal:r.signal},onEvent:S(r,d)});return{kind:t,results:c.results,failures:[...n.failures,...f,...c.refusals,...c.failures],inputBytes:c.inputBytes,outputBytes:c.outputBytes}}async function He(e,r){let t=e.crop!==void 0?"crop":e.resize!==void 0?"resize":"trim",o=e.target===void 0?void 0:be(e.target,t);if(o)return b(e.kind,[{path:"",error:o}]);let s=await y(e.inputs,{recursive:e.recursive}),a=[],n=[],i=[];for(let p of s.sources)p.kind==="image"&&e.media===void 0?a.push(p):p.kind==="media"&&!e.trim?n.push(p):p.kind==="image"?i.push({path:p.path,error:k("cut","it works on video and sound, not images","Try a video or sound file, such as a MOV, MP4 or WAV.")}):i.push({path:p.path,error:k(t,"it works on images, not documents","Try an image such as a JPEG, PNG, WebP or HEIC file.")});let u=ne(n,{...e.media===void 0?{}:{media:e.media},...e.crop===void 0?{}:{crop:e.crop},...e.resize===void 0?{}:{resize:e.resize},...e.target===void 0?{}:{target:e.target},...e.output===void 0?{}:{output:e.output},roots:s.roots}),d=[...ae(a,{trim:e.trim,...e.crop===void 0?{}:{crop:e.crop},...e.resize===void 0?{}:{resize:e.resize},...e.target===void 0?{}:{target:e.target},...e.output===void 0?{}:{output:e.output},roots:s.roots,background:e.options.background,keepMetadata:e.options.keepMetadata,...e.options.quality===void 0?{}:{quality:e.options.quality}}),...u],c=d.length>1;c&&r.onProgress?.({completed:0,total:d.length});let l=await I(d,{force:e.force,...e.concurrency===void 0?{}:{concurrency:e.concurrency},onEvent:S(r,c)});return{kind:e.kind,results:l.results,failures:[...s.failures,...i,...l.refusals,...l.failures],inputBytes:l.inputBytes,outputBytes:l.outputBytes}}async function Le(e,r){let t=await y(e.inputs,{recursive:e.recursive}),o=m=>m.kind==="document"&&m.format==="pdf",s=C(e.target),a=s?t.sources.filter(o):[],n=s?t.sources.filter(m=>!o(m)):t.sources,i=[],u=[],f=We(e.passwordStdin??!1,r.interactive??!0);for(let m of a){let v=await ze(m,e,f,t.roots.get(m.path));"failure"in v?u.push(v.failure):i.push(v.job)}let d=await we({resolved:{sources:n,failures:[],roots:t.roots},target:e.target,options:e.options,force:e.force,...e.output===void 0?{}:{output:e.output}}),c=[...d.jobs,...i],l=c.length>1;l&&r.onProgress?.({completed:0,total:c.length});let p=await I(c,{force:e.force,...e.concurrency===void 0?{}:{concurrency:e.concurrency},...e.maxBytes===void 0?{}:{targetBytes:e.maxBytes},onEvent:S(r,l)});return{kind:"convert",results:p.results,failures:[...t.failures,...u,...d.failures,...p.refusals,...p.unreachable.map(m=>({path:m.job.sources[0].path,error:m.error})),...p.failures],inputBytes:p.inputBytes,outputBytes:p.outputBytes}}async function Ue(e,r={}){try{if(e.kind==="pageop")return await qe(e);if(e.kind==="extension-op")return await Ge(e,r);if(e.kind==="edit")return await He(e,r);if(e.kind==="preset"){let{runPresetCommand:t}=await import("./preset-command-VP5RAXBG.js");return await t(e)}return e.kind==="compress"?await Ve(e,r):await Le(e,r)}catch(t){if(!P(t))throw t;return b(e.kind,[{path:"",error:t}])}}function Ye(e,r){let t=A(e.failures);if(r.json)return{exitCode:t,stdout:[JSON.stringify(fe(g,e))],stderr:[]};let o=e.results.length===0?[]:e.kind==="pageop"?$e(e):e.results.length===1?Pe(e):ke(e);return{exitCode:t,stdout:o,stderr:B(e.failures,{debug:r.debug})}}function Ke(e,r){let t=[{path:"",error:e}],o=A(t);return r.json?{exitCode:o,stdout:[JSON.stringify(le(g,e))],stderr:[]}:{exitCode:o,stdout:[],stderr:B(t,{debug:r.debug})}}async function Qe(e,r){let{runConfig:t}=await import("./config-command-6GXRV627.js"),o=await t(e);return r?{exitCode:0,stdout:[JSON.stringify(he(g,o.config,o.warnings))],stderr:[]}:{exitCode:0,stdout:o.stdout,stderr:[]}}async function zt(e,r={}){let t=r.json??!1,o="debug"in e?e.debug:!1;try{if(e.kind==="config")return await Qe(e,t);if(e.kind==="clip"){let{runClipCommand:n}=await import("./clip-command-SLSAWJF4.js");return await n(e,{...r,json:t,debug:o})}if(e.kind==="update"){let{runUpdate:n}=await import("./update-command-DJLYU6AB.js"),i=await n(g,{...r.onInstalling?{onInstalling:r.onInstalling}:{}});return{exitCode:0,stdout:t?[JSON.stringify({forge:g,ok:!0,...i.data})]:i.stdout,stderr:[]}}if(e.kind==="uninstall"){let{runUninstall:n}=await import("./entry-TV4FJQDR.js"),i=[];return{exitCode:await n(g,f=>i.push(f)),stdout:i,stderr:[]}}if(e.kind==="extensions"){let{runExtensions:n}=await import("./extensions-command-VROVGVD4.js"),i=await n(e,{onDownload:r.onDownload});return{exitCode:0,stdout:t?[JSON.stringify(ye(g,i.data))]:i.stdout,stderr:[]}}if(e.kind==="formats")return t?{exitCode:0,stdout:[JSON.stringify(me(g,te()))],stderr:[]}:{exitCode:0,stdout:Re(),stderr:[]};if(e.kind==="probe"){let{probes:n,failures:i}=await Ie(e.inputs),u=A(i);return t?{exitCode:u,stdout:[JSON.stringify(ge(g,{probes:n,failures:i}))],stderr:[]}:{exitCode:u,stdout:n.flatMap((f,d)=>[...d>0?[""]:[],...Ee(f)]),stderr:B(i,{debug:o})}}if(e.kind==="palette"||e.kind==="scale"){let{runPalette:n,runScale:i}=await import("./colour-LMZO2EE6.js"),u={json:t,colour:r.colour??!1};return e.kind==="palette"?await n(e,u):await i(e,u)}if(e.kind==="transcribe"){let{runTranscribeCommand:n}=await import("./transcribe-command-ZXB3JJFZ.js"),i=[],u=[],f;return{exitCode:await n(e,{out:c=>i.push(c),err:c=>u.push(c),finished:c=>{f=T("Transcribe",c)}}),stdout:i,stderr:u,...f?{notice:f}:{}}}if(e.kind==="shell")return{exitCode:0,stdout:[],stderr:[]};if(e.kind==="watch")throw N("forge watch runs in a terminal until ctrl-c.","Try: forge watch ./images --to webp");let s=await Ue(e,r),a=T(Ae(e),X(s.results,s.failures));return{...Ye(s,{json:t,debug:o}),...a?{notice:a}:{}}}catch(s){if(!P(s))throw s;return Ke(s,{json:t,debug:o})}}export{Ie as a,xe as b,A as c,Ue as d,Ye as e,zt as f};
@@ -1,3 +1,3 @@
1
1
  import { createRequire as __forgeCreateRequire } from 'node:module';
2
2
  const require = __forgeCreateRequire(import.meta.url);
3
- import{H as $}from"./chunk-WIPP5TWQ.js";var _=[{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"}],v=20,D=10,p=t=>Math.max(1,Math.round(t)),u=(t,e,n)=>Math.min(Math.max(t,e),n);function P(t,e){let n=p(t.width*e.h/e.w),[r,i]=n<=t.height?[t.width,n]:[Math.min(t.width,p(t.height*e.w/e.h)),t.height];return{left:Math.floor((t.width-r)/2),top:Math.floor((t.height-i)/2),width:r,height:i}}var T=(t,e)=>e.width===t.width&&e.height===t.height;function N(t){return _.filter(e=>!T(t,P(t,e)))}function W(t,e,n,r){let i=P(t,e),o,h;return e.w>=e.h?(o=p(i.width*r/100),h=Math.min(t.height,p(o*e.h/e.w))):(h=p(i.height*r/100),o=Math.min(t.width,p(h*e.w/e.h))),{left:u(Math.round(n.x-o/2),0,t.width-o),top:u(Math.round(n.y-h/2),0,t.height-h),width:o,height:h}}function k(t,e,n,r){return{...e,left:u(e.left+n,0,t.width-e.width),top:u(e.top+r,0,t.height-e.height)}}function E(t,e){return{x:e.width<t.width,y:e.height<t.height}}function H(t){return{x:t.left+t.width/2,y:t.top+t.height/2}}function Z(t,e){return Math.round(e.width*e.height*100/(t.width*t.height))}var F=t=>`${t.w}:${t.h}`,I=t=>`cropped-${t.w}x${t.h}`;function L(t){let e=/^(\d{1,3}):(\d{1,3})$/.exec(t.trim()),n=Number(e?.[1]),r=Number(e?.[2]);if(!e||n<1||n>100||r<1||r>100)throw $(`"${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:n,h:r}}function q(t,e,n){let r=n*2,i=new Uint8Array(e*r*3),o=t.alpha?new Uint8Array(e*r):void 0,h=t.width/e,M=t.height/r;for(let c=0;c<r;c++){let w=c*M,y=w+M;for(let s=0;s<e;s++){let f=s*h,b=f+h,A=0,S=0,B=0,a=0,x=0;for(let d=Math.floor(w);d<Math.min(Math.ceil(y),t.height);d++){let R=Math.min(d+1,y)-Math.max(d,w);for(let l=Math.floor(f);l<Math.min(Math.ceil(b),t.width);l++){let C=d*t.width+l,U=(Math.min(l+1,b)-Math.max(l,f))*R,m=U*(t.alpha?(t.alpha[C]??0)/255:1),g=C*3;A+=(t.rgb[g]??0)*m,S+=(t.rgb[g+1]??0)*m,B+=(t.rgb[g+2]??0)*m,a+=m,x+=U}}let O=c*e+s;a>0&&i.set([A/a,S/a,B/a].map(Math.round),O*3),o&&x>0&&(o[O]=Math.round(a*255/x))}}return{cols:e,dotRows:r,rgb:i,...o?{alpha:o}:{}}}export{_ as a,v as b,D as c,P as d,N as e,W as f,k as g,E as h,H as i,Z as j,F as k,I as l,L as m,q as n};
3
+ import{E as $}from"./chunk-CVNYUROW.js";var _=[{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"}],v=20,D=10,p=t=>Math.max(1,Math.round(t)),u=(t,e,n)=>Math.min(Math.max(t,e),n);function P(t,e){let n=p(t.width*e.h/e.w),[r,i]=n<=t.height?[t.width,n]:[Math.min(t.width,p(t.height*e.w/e.h)),t.height];return{left:Math.floor((t.width-r)/2),top:Math.floor((t.height-i)/2),width:r,height:i}}var T=(t,e)=>e.width===t.width&&e.height===t.height;function N(t){return _.filter(e=>!T(t,P(t,e)))}function W(t,e,n,r){let i=P(t,e),o,h;return e.w>=e.h?(o=p(i.width*r/100),h=Math.min(t.height,p(o*e.h/e.w))):(h=p(i.height*r/100),o=Math.min(t.width,p(h*e.w/e.h))),{left:u(Math.round(n.x-o/2),0,t.width-o),top:u(Math.round(n.y-h/2),0,t.height-h),width:o,height:h}}function k(t,e,n,r){return{...e,left:u(e.left+n,0,t.width-e.width),top:u(e.top+r,0,t.height-e.height)}}function E(t,e){return{x:e.width<t.width,y:e.height<t.height}}function H(t){return{x:t.left+t.width/2,y:t.top+t.height/2}}function Z(t,e){return Math.round(e.width*e.height*100/(t.width*t.height))}var F=t=>`${t.w}:${t.h}`,I=t=>`cropped-${t.w}x${t.h}`;function L(t){let e=/^(\d{1,3}):(\d{1,3})$/.exec(t.trim()),n=Number(e?.[1]),r=Number(e?.[2]);if(!e||n<1||n>100||r<1||r>100)throw $(`"${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:n,h:r}}function q(t,e,n){let r=n*2,i=new Uint8Array(e*r*3),o=t.alpha?new Uint8Array(e*r):void 0,h=t.width/e,M=t.height/r;for(let c=0;c<r;c++){let w=c*M,y=w+M;for(let s=0;s<e;s++){let f=s*h,b=f+h,A=0,S=0,B=0,a=0,x=0;for(let d=Math.floor(w);d<Math.min(Math.ceil(y),t.height);d++){let R=Math.min(d+1,y)-Math.max(d,w);for(let l=Math.floor(f);l<Math.min(Math.ceil(b),t.width);l++){let C=d*t.width+l,U=(Math.min(l+1,b)-Math.max(l,f))*R,m=U*(t.alpha?(t.alpha[C]??0)/255:1),g=C*3;A+=(t.rgb[g]??0)*m,S+=(t.rgb[g+1]??0)*m,B+=(t.rgb[g+2]??0)*m,a+=m,x+=U}}let O=c*e+s;a>0&&i.set([A/a,S/a,B/a].map(Math.round),O*3),o&&x>0&&(o[O]=Math.round(a*255/x))}}return{cols:e,dotRows:r,rgb:i,...o?{alpha:o}:{}}}export{_ as a,v as b,D as c,P as d,N as e,W as f,k as g,E as h,H as i,Z as j,F as k,I as l,L as m,q as n};
@@ -0,0 +1,3 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ import{a as y,c as b}from"./chunk-IED6VBE6.js";import{a as p}from"./chunk-XPATZLEH.js";import{j as h}from"./chunk-DYIATUFE.js";import{a as m}from"./chunk-CVNYUROW.js";import{a as c}from"./chunk-H3DIRJFE.js";import{open as g,readdir as w,stat as x}from"node:fs/promises";import{extname as S,join as k,resolve as v}from"node:path";function K(e){return e.startsWith(".")||/\.(crdownload|part|download|tmp)$/i.test(e)}function A(e){return e.kind==="image"?"images":e.format==="pdf"?"pdfs":"documents"}var R=new Set(Object.values(c).flatMap(e=>e.extensions));async function O(e){let i=await g(e,"r"),t=Buffer.alloc(4096),r=0;try{r=(await i.read(t,0,t.length,0)).bytesRead}finally{await i.close()}let n=t.subarray(0,r),o=(d,f)=>n.subarray(d,d+f).toString("latin1");return o(4,4)==="ftyp"?/^(M4A |M4B |M4P )$/.test(o(8,4))?"audio":"video":n[0]===26&&n[1]===69&&n[2]===223&&n[3]===163?"video":o(0,4)==="RIFF"?o(8,4)==="WAVE"?"audio":o(8,3)==="AVI"?"video":"other":n[0]===0&&n[1]===0&&n[2]===1&&(n[3]===186||n[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))||n[0]===255&&n[1]!==void 0&&(n[1]&224)===224?"audio":r>0&&!n.includes(0)&&M(n)?"text":"other"}function M(e){try{return new TextDecoder("utf-8",{fatal:!0}).decode(e,{stream:!0}),!0}catch{return!1}}var F=["images","pdfs","documents","videos","audio","other"];function j(e,i){if(e==="videos"||e==="audio")return"not yet supported";if(e==="other")return i.every(t=>t==="text")?i.length===1?"a text file":"text files":"not supported"}async function V(e){let i=v(e),t=await w(i,{withFileTypes:!0}),r=[],n=[],o=new Map,d=[],f=0;for(let s of t.sort((a,u)=>a.name.localeCompare(u.name)))!s.isFile()||K(s.name)||d.push(k(i,s.name));for(let s of await E(d))if(s.kind==="source")r.push(s.source),f+=s.source.bytes;else if(s.kind==="failed")n.push(s.failure),f+=s.bytes;else{let a=s.kind,u=o.get(a)??{bytes:0,sniffed:[]};u.bytes+=s.bytes,u.sniffed.push(s.sniffed),o.set(a,u),f+=s.bytes}let l=I(r);for(let s of F){let a=o.get(s);if(!a)continue;let u=j(s,a.sniffed);l.push({id:s,count:a.sniffed.length,bytes:a.bytes,sources:[],...u===void 0?{}:{why:u}})}return{dir:i,sources:r,failures:n,kinds:l,bytes:f,paths:d}}async function E(e){let i=[];return await b(e,y(),async(t,r)=>{try{i[r]={read:await C(t)}}catch(n){i[r]={error:n}}}),i.map(t=>{if("error"in t)throw t.error;return t.read})}function I(e){let i=[];for(let t of F){let r=e.filter(n=>A(n)===t);r.length>0&&i.push({id:t,count:r.length,bytes:r.reduce((n,o)=>n+o.bytes,0),sources:r})}return i.sort((t,r)=>r.count-t.count)}function W(e,i=[]){let t=e.filter(o=>o.kind==="media"),r=e.filter(o=>o.kind!=="media"),n=I(r);for(let o of["videos","audio"]){let d=t.filter(f=>c[f.format].media==="video"==(o==="videos"));if(d.length>0){let f=d.reduce((l,s)=>l+s.bytes,0);n.push({id:o,count:d.length,bytes:f,sources:[],why:"one at a time"})}}return{dir:"",sources:r,failures:i,kinds:n,bytes:e.reduce((o,d)=>o+d.bytes,0),paths:e.map(o=>o.path)}}async function C(e){let i=()=>x(e).then(t=>t.size,()=>0);try{let t=await h(e);if(t.kind==="media"){let r=c[t.format].media==="video";return{kind:r?"videos":"audio",sniffed:r?"video":"audio",bytes:t.bytes}}return{kind:"source",source:t}}catch(t){let r=await i(),n=await O(e).catch(()=>"other");if(n==="video"||n==="audio")return{kind:n==="video"?"videos":"audio",sniffed:n,bytes:r};if(R.has(S(e).toLowerCase())){let o=m(t)?t:void 0;if(o)return{kind:"failed",failure:{path:e,error:o},bytes:r}}return{kind:"other",sniffed:n,bytes:r}}}function D(e){let i=new Set(e.flatMap(t=>p(t).filter(r=>r!==t.format)));return Object.keys(c).filter(t=>i.has(t))}function _(e,i){let t=D(e),r=e[0],n=r?.kind==="image"?"webp":r?.format==="pdf"?"png":void 0,o=n&&t.includes(n)?n:t[0];if(o)return N(e,o,i)}function N(e,i,t){let r={target:i};return c[i].lossy&&(r.quality=t),e.some(n=>n.kind==="document"&&n.format==="pdf")&&(i==="png"||i==="jpeg")&&(r.dpi=150),r}export{K as a,A as b,O as c,V as d,W as e,C as f,D as g,_ as h,N as i};
@@ -1,3 +1,3 @@
1
1
  import { createRequire as __forgeCreateRequire } from 'node:module';
2
2
  const require = __forgeCreateRequire(import.meta.url);
3
- import{h as l}from"./chunk-2J2PTA5O.js";import{r as f}from"./chunk-DZOBIUV6.js";import{y as m}from"./chunk-WIPP5TWQ.js";import{b as g,d as w}from"./chunk-KXKQDFHX.js";import{readFile as D,rm as E}from"node:fs/promises";var b=new Set(["pdf"]),x=new Set(["jpeg","png"]),I=new Set(["convert"]),y;function R(){return y??=w().then(t=>t.PDFiumLibrary.init()),y}async function h(t,r){return await(await R()).loadDocument(t,r)}async function J(t){let r=await h(t);try{let e=[];for(let n=0;n<r.getPageCount();n++)e.push(r.getPage(n).getText());return e}finally{r.destroy()}}var T={id:"pdfium",reads:b,writes:x,ops:I,probe(){throw new Error("pdfium does not probe; engines/pdf.ts classifies PDFs")},async run(t,r){if(t.op!=="convert")throw new Error(`pdfium cannot ${t.op}`);let e=t.sources[0];if(e.kind!=="document")throw new Error("the pdfium engine can only rasterise a document source");if(e.encrypted&&t.options.password===void 0)throw m(e.path);let n=t.options.dpi??150,i=t.options.pages??Array.from({length:e.pages},(o,a)=>a);if(i.length!==t.outputs.length)throw new Error(`pdfium was given ${i.length} pages but ${t.outputs.length} outputs`);for(let o of i)if(o<0||o>=e.pages)throw new Error(`pdfium was asked for page ${o}, but ${e.path} has ${e.pages} pages`);let P=await g(),d=await h(await D(e.path),t.options.password);try{let o=[],a=0;try{for(let[s,p]of i.entries()){let u=await d.getPage(p).render({scale:n/72,render:"bitmap",transparent:!0}),F=P(u.data,{raw:{width:u.width,height:u.height,channels:4}}).flatten({background:t.options.background}),S=await l(F,t.target,t.options.quality).toBuffer(),c=t.outputs[s];a+=await f(c,S),o.push(c),r({phase:"page",done:s+1,total:i.length})}}catch(s){throw await Promise.all(o.map(p=>E(p,{force:!0}))),s}return{job:t,outputBytes:a,warnings:[]}}finally{d.destroy()}}};export{h as a,J as b,T as c};
3
+ import{i as l}from"./chunk-T37DEXUI.js";import{r as f}from"./chunk-BIBDLXCG.js";import{v as m}from"./chunk-CVNYUROW.js";import{b as g,d as w}from"./chunk-KXKQDFHX.js";import{readFile as D,rm as E}from"node:fs/promises";var b=new Set(["pdf"]),x=new Set(["jpeg","png"]),I=new Set(["convert"]),y;function R(){return y??=w().then(t=>t.PDFiumLibrary.init()),y}async function h(t,r){return await(await R()).loadDocument(t,r)}async function J(t){let r=await h(t);try{let e=[];for(let n=0;n<r.getPageCount();n++)e.push(r.getPage(n).getText());return e}finally{r.destroy()}}var T={id:"pdfium",reads:b,writes:x,ops:I,probe(){throw new Error("pdfium does not probe; engines/pdf.ts classifies PDFs")},async run(t,r){if(t.op!=="convert")throw new Error(`pdfium cannot ${t.op}`);let e=t.sources[0];if(e.kind!=="document")throw new Error("the pdfium engine can only rasterise a document source");if(e.encrypted&&t.options.password===void 0)throw m(e.path);let n=t.options.dpi??150,i=t.options.pages??Array.from({length:e.pages},(o,a)=>a);if(i.length!==t.outputs.length)throw new Error(`pdfium was given ${i.length} pages but ${t.outputs.length} outputs`);for(let o of i)if(o<0||o>=e.pages)throw new Error(`pdfium was asked for page ${o}, but ${e.path} has ${e.pages} pages`);let P=await g(),d=await h(await D(e.path),t.options.password);try{let o=[],a=0;try{for(let[s,p]of i.entries()){let u=await d.getPage(p).render({scale:n/72,render:"bitmap",transparent:!0}),F=P(u.data,{raw:{width:u.width,height:u.height,channels:4}}).flatten({background:t.options.background}),S=await l(F,t.target,t.options.quality).toBuffer(),c=t.outputs[s];a+=await f(c,S),o.push(c),r({phase:"page",done:s+1,total:i.length})}}catch(s){throw await Promise.all(o.map(p=>E(p,{force:!0}))),s}return{job:t,outputBytes:a,warnings:[]}}finally{d.destroy()}}};export{h as a,J as b,T as c};