forge-terminal 0.6.0 → 0.7.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 (121) hide show
  1. package/README.md +38 -7
  2. package/dist/chunks/{about-credits-XL2AIGQ7.js → about-credits-PWTKZG3Y.js} +1 -1
  3. package/dist/chunks/args-RHIBM3R3.js +3 -0
  4. package/dist/chunks/{available-TNMISSBA.js → available-FPBRQ3LS.js} +1 -1
  5. package/dist/chunks/{boot-QRKC4QBA.js → boot-PHDTJAFT.js} +1 -1
  6. package/dist/chunks/{catalog-FMHWWMUX.js → catalog-G44MXIAF.js} +1 -1
  7. package/dist/chunks/{check-HOITNMJX.js → check-BFHBPCGW.js} +1 -1
  8. package/dist/chunks/{chunk-EIPMQFIF.js → chunk-2YU4EI24.js} +1 -1
  9. package/dist/chunks/chunk-3IAJTXYM.js +3 -0
  10. package/dist/chunks/{chunk-ECA4PW5T.js → chunk-3OCPO5V6.js} +1 -1
  11. package/dist/chunks/chunk-42IEPG2K.js +3 -0
  12. package/dist/chunks/{chunk-BYUOU2Q2.js → chunk-4AL5QJLM.js} +1 -1
  13. package/dist/chunks/{chunk-UUTBDIFR.js → chunk-56B3VZCM.js} +1 -1
  14. package/dist/chunks/{chunk-QIMSNTKL.js → chunk-56QHX7QR.js} +1 -1
  15. package/dist/chunks/{chunk-HXKLYK3M.js → chunk-6NCN7OJ5.js} +1 -1
  16. package/dist/chunks/{chunk-YBA6DJQ4.js → chunk-6PUV4HSU.js} +1 -1
  17. package/dist/chunks/{chunk-2OSM4W4D.js → chunk-72UR37EG.js} +1 -1
  18. package/dist/chunks/{chunk-3IX3QA76.js → chunk-7NP76V4U.js} +1 -1
  19. package/dist/chunks/{chunk-5FJT4BNY.js → chunk-AETM2PCZ.js} +1 -1
  20. package/dist/chunks/{chunk-GIG4I2IC.js → chunk-BQV3DSUZ.js} +2 -2
  21. package/dist/chunks/chunk-DC2DHMXO.js +3 -0
  22. package/dist/chunks/{chunk-6HUYBVQA.js → chunk-DKHBJ52G.js} +1 -1
  23. package/dist/chunks/chunk-E5VPEBUQ.js +3 -0
  24. package/dist/chunks/chunk-F4TUCI6D.js +3 -0
  25. package/dist/chunks/{chunk-MF3KKEFB.js → chunk-FEJSM3E4.js} +1 -1
  26. package/dist/chunks/{chunk-JUA63KQK.js → chunk-G2V33TMN.js} +1 -1
  27. package/dist/chunks/{chunk-FXA45V4B.js → chunk-G4M2XYFJ.js} +1 -1
  28. package/dist/chunks/{chunk-WID72ZII.js → chunk-H332YFSO.js} +1 -1
  29. package/dist/chunks/chunk-HAOKWLD3.js +4 -0
  30. package/dist/chunks/{chunk-S7BZPV5T.js → chunk-I3C3SRF2.js} +1 -1
  31. package/dist/chunks/{chunk-NUTTDNTG.js → chunk-ID4GJZJ6.js} +1 -1
  32. package/dist/chunks/{chunk-X4QI2EYV.js → chunk-ID75X37Z.js} +1 -1
  33. package/dist/chunks/{chunk-FWVE3GNA.js → chunk-JPASVE56.js} +1 -1
  34. package/dist/chunks/{chunk-UN5DSJE2.js → chunk-JZM37DG2.js} +1 -1
  35. package/dist/chunks/{chunk-G6L5NIJ5.js → chunk-KPUKMAYK.js} +1 -1
  36. package/dist/chunks/{chunk-UEAZTRTL.js → chunk-M7HB4L6L.js} +1 -1
  37. package/dist/chunks/{chunk-NLM2SP3F.js → chunk-OK56WDPA.js} +1 -1
  38. package/dist/chunks/{chunk-I25E2XDH.js → chunk-OLKPV4WO.js} +1 -1
  39. package/dist/chunks/chunk-OPDC577C.js +3 -0
  40. package/dist/chunks/chunk-OQ6DTE56.js +3 -0
  41. package/dist/chunks/chunk-PNPAHKJR.js +3 -0
  42. package/dist/chunks/{chunk-3HG7RXC2.js → chunk-PXCEMDOY.js} +2 -2
  43. package/dist/chunks/{chunk-YJZEHJ6U.js → chunk-QMNERJL2.js} +1 -1
  44. package/dist/chunks/{chunk-TNIPRV6K.js → chunk-R6QVLPGC.js} +1 -1
  45. package/dist/chunks/{chunk-65Y7YCZZ.js → chunk-S44LAUHZ.js} +1 -1
  46. package/dist/chunks/{chunk-YYZYZWF5.js → chunk-SCJ2QXZF.js} +22 -22
  47. package/dist/chunks/{chunk-QO4JUY6B.js → chunk-SJIDFYPT.js} +1 -1
  48. package/dist/chunks/{chunk-PISCJKIG.js → chunk-TQEGSODD.js} +1 -1
  49. package/dist/chunks/chunk-ULX4ZD2Y.js +3 -0
  50. package/dist/chunks/{chunk-BWJNZT75.js → chunk-W6QOV4RP.js} +1 -1
  51. package/dist/chunks/chunk-WWWWXOM4.js +3 -0
  52. package/dist/chunks/{chunk-2JU3YZQU.js → chunk-XIR3VWQY.js} +1 -1
  53. package/dist/chunks/chunk-XUJLUOGD.js +6 -0
  54. package/dist/chunks/chunk-Y3DMALHT.js +66 -0
  55. package/dist/chunks/chunk-YXV3PYVI.js +3 -0
  56. package/dist/chunks/{chunk-QPUKPSPZ.js → chunk-Z3PQ5TMU.js} +1 -1
  57. package/dist/chunks/chunk-ZL7E7PZN.js +4 -0
  58. package/dist/chunks/clip-command-6Q7BTXR5.js +3 -0
  59. package/dist/chunks/{clipboard-W67Q22JG.js → clipboard-QWNPA3GM.js} +1 -1
  60. package/dist/chunks/colour-7HPH6KTY.js +3 -0
  61. package/dist/chunks/{command-ZX3L5VFO.js → command-JTK4IOS7.js} +1 -1
  62. package/dist/chunks/{config-command-VEGQPXVB.js → config-command-DIQTU7DM.js} +1 -1
  63. package/dist/chunks/{continue-editing-LTMIEFRD.js → continue-editing-FTUY6UFG.js} +1 -1
  64. package/dist/chunks/{decoded-SK6W44WW.js → decoded-IXLPWTGZ.js} +1 -1
  65. package/dist/chunks/{entry-3R2GK3IW.js → entry-ZF7D32ZI.js} +2 -2
  66. package/dist/chunks/execute-RP7ZMWLZ.js +3 -0
  67. package/dist/chunks/extensions-YOZ4IF4E.js +3 -0
  68. package/dist/chunks/{extensions-command-RNAPQYWV.js → extensions-command-O7UHUJ3Y.js} +1 -1
  69. package/dist/chunks/{ffmpeg-G4TRWUTV.js → ffmpeg-2ZP3GXJX.js} +1 -1
  70. package/dist/chunks/{image-67XO45NW.js → image-6A7FXKIR.js} +1 -1
  71. package/dist/chunks/{install-X7EEH5CQ.js → install-4L7JGP3X.js} +1 -1
  72. package/dist/chunks/{install-UN3YGSJW.js → install-XJAPLIH2.js} +1 -1
  73. package/dist/chunks/launch-2KSJ4GGN.js +18 -0
  74. package/dist/chunks/link-inputs-GTEW6ZH4.js +3 -0
  75. package/dist/chunks/{lock-5ZO5PCZP.js → lock-KNR7XS7Q.js} +1 -1
  76. package/dist/chunks/manager-YH5XAMZA.js +4 -0
  77. package/dist/chunks/{needed-7IUPDEJB.js → needed-TB3OC76N.js} +1 -1
  78. package/dist/chunks/{own-5BD5BVE7.js → own-KUGTZ3BV.js} +1 -1
  79. package/dist/chunks/{paths-6OENILJ4.js → paths-BBUKTDDP.js} +1 -1
  80. package/dist/chunks/pdfium-MJ65YOXW.js +3 -0
  81. package/dist/chunks/{preferences-E2CH2YSG.js → preferences-7S7YZOFK.js} +1 -1
  82. package/dist/chunks/preset-command-KMKR6KMG.js +3 -0
  83. package/dist/chunks/registry-657JRJR5.js +3 -0
  84. package/dist/chunks/{run-3DX3SROY.js → run-VJDF5WRF.js} +1 -1
  85. package/dist/chunks/{server-TF32DQEO.js → server-6PH2DSFW.js} +20 -20
  86. package/dist/chunks/{signals-QSXY3F2A.js → signals-VY2XE3LV.js} +1 -1
  87. package/dist/chunks/{theme-4Y66DDAO.js → theme-FVQOSLPB.js} +1 -1
  88. package/dist/chunks/{transcribe-HH5P3PV4.js → transcribe-FUN2SKRN.js} +1 -1
  89. package/dist/chunks/transcribe-command-KNSUHROE.js +3 -0
  90. package/dist/chunks/{update-command-6VVDG75Y.js → update-command-X4OSYETA.js} +1 -1
  91. package/dist/chunks/{update-note-XV2T2NNG.js → update-note-LV7G4CHE.js} +1 -1
  92. package/dist/chunks/video-link-CF7GUA6V.js +3 -0
  93. package/dist/chunks/watch-command-3C4AWM7A.js +3 -0
  94. package/dist/index.js +7 -7
  95. package/package.json +9 -13
  96. package/skills/forge/SKILL.md +7 -3
  97. package/dist/chunks/args-PS5SVBZY.js +0 -3
  98. package/dist/chunks/chunk-2L66A2X6.js +0 -3
  99. package/dist/chunks/chunk-3SVHRKQH.js +0 -6
  100. package/dist/chunks/chunk-4MZV4SRU.js +0 -4
  101. package/dist/chunks/chunk-4NDZTK22.js +0 -3
  102. package/dist/chunks/chunk-5XJCMMCM.js +0 -3
  103. package/dist/chunks/chunk-CCNRNCRU.js +0 -3
  104. package/dist/chunks/chunk-EEQSUBBL.js +0 -3
  105. package/dist/chunks/chunk-EJWTYDBJ.js +0 -3
  106. package/dist/chunks/chunk-JD3RB6IV.js +0 -66
  107. package/dist/chunks/chunk-NMGQGYVM.js +0 -3
  108. package/dist/chunks/chunk-SFN3LBB6.js +0 -3
  109. package/dist/chunks/chunk-UI4EUC3S.js +0 -3
  110. package/dist/chunks/chunk-X2YUHPOU.js +0 -4
  111. package/dist/chunks/clip-command-4ON3Q57W.js +0 -3
  112. package/dist/chunks/colour-2BGK2BFR.js +0 -3
  113. package/dist/chunks/execute-TC3QZ6GL.js +0 -3
  114. package/dist/chunks/extensions-3SG2LW7R.js +0 -3
  115. package/dist/chunks/launch-EGFNGHLN.js +0 -18
  116. package/dist/chunks/manager-272REVNF.js +0 -4
  117. package/dist/chunks/pdfium-MHPBLZY5.js +0 -3
  118. package/dist/chunks/preset-command-5I3NZ2OP.js +0 -3
  119. package/dist/chunks/registry-DWFV4GBG.js +0 -3
  120. package/dist/chunks/transcribe-command-VY5HYNXV.js +0 -3
  121. package/dist/chunks/watch-command-BMSMGIHK.js +0 -3
@@ -1,3 +1,3 @@
1
1
  import { createRequire as __forgeCreateRequire } from 'node:module';
2
2
  const require = __forgeCreateRequire(import.meta.url);
3
- import{a,b,c,d}from"./chunk-EIPMQFIF.js";import"./chunk-65Y7YCZZ.js";import"./chunk-PON65UTS.js";import"./chunk-UN5DSJE2.js";import"./chunk-CCNRNCRU.js";import"./chunk-FGR6QCG5.js";import"./chunk-VLVNA4T3.js";import"./chunk-TMUK2DD3.js";export{a as SIGNAL_EXIT,b as dieBy,d as endLeftoverWork,c as stopOnSignals};
3
+ import{a,b,c,d}from"./chunk-2YU4EI24.js";import"./chunk-S44LAUHZ.js";import"./chunk-PON65UTS.js";import"./chunk-JZM37DG2.js";import"./chunk-PNPAHKJR.js";import"./chunk-FGR6QCG5.js";import"./chunk-VLVNA4T3.js";import"./chunk-TMUK2DD3.js";export{a as SIGNAL_EXIT,b as dieBy,d as endLeftoverWork,c as stopOnSignals};
@@ -1,3 +1,3 @@
1
1
  import { createRequire as __forgeCreateRequire } from 'node:module';
2
2
  const require = __forgeCreateRequire(import.meta.url);
3
- import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w}from"./chunk-WID72ZII.js";import"./chunk-TMUK2DD3.js";export{u as BAR,c as DARK,f as FIRST_RUN,d as LIGHT,h as MODE_KEYS,k as MODE_MARKERS,g as MODE_ORDER,e as NEUTRAL,b as SYMBOLS,a as VERSION,w as applyColourPreference,v as colourEnabled,t as colourProp,o as dotGradient,p as menuPalette,l as modeColours,j as modeForKey,m as modeGradient,q as modePalette,n as modeWash,r as paintsCanvas,s as paletteFor,i as tabStep};
3
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w}from"./chunk-H332YFSO.js";import"./chunk-TMUK2DD3.js";export{u as BAR,c as DARK,f as FIRST_RUN,d as LIGHT,h as MODE_KEYS,k as MODE_MARKERS,g as MODE_ORDER,e as NEUTRAL,b as SYMBOLS,a as VERSION,w as applyColourPreference,v as colourEnabled,t as colourProp,o as dotGradient,p as menuPalette,l as modeColours,j as modeForKey,m as modeGradient,q as modePalette,n as modeWash,r as paintsCanvas,s as paletteFor,i as tabStep};
@@ -1,3 +1,3 @@
1
1
  import { createRequire as __forgeCreateRequire } from 'node:module';
2
2
  const require = __forgeCreateRequire(import.meta.url);
3
- import{f as a,g as b,h as c,i as d,j as e,k as f,l as g,m as h,n as i,o as j,p as k,q as l,r as m,s as n}from"./chunk-GIG4I2IC.js";import"./chunk-MF3KKEFB.js";import"./chunk-I25E2XDH.js";import"./chunk-HZDYZ5RD.js";import"./chunk-BSFBZBAI.js";import"./chunk-BWJNZT75.js";import"./chunk-PON65UTS.js";import"./chunk-KXKQDFHX.js";import"./chunk-NUCGWLOY.js";import"./chunk-I2LPGKUU.js";import"./chunk-HON4OV7M.js";import"./chunk-CCNRNCRU.js";import"./chunk-FGR6QCG5.js";import"./chunk-VLVNA4T3.js";import"./chunk-TMUK2DD3.js";export{h as appleDoes,e as chooseHearing,c as helperPaths,d as helpers,b as notesNeed,i as probeSound,l as readRefusal,m as renderPages,n as renderTranscript,k as runRead,j as runTranscribe,a as transcribeNeeds,f as transcribeStatus,g as whisperUseful};
3
+ import{f as a,g as b,h as c,i as d,j as e,k as f,l as g,m as h,n as i,o as j,p as k,q as l,r as m,s as n}from"./chunk-BQV3DSUZ.js";import"./chunk-FEJSM3E4.js";import"./chunk-OLKPV4WO.js";import"./chunk-HZDYZ5RD.js";import"./chunk-BSFBZBAI.js";import"./chunk-W6QOV4RP.js";import"./chunk-PON65UTS.js";import"./chunk-KXKQDFHX.js";import"./chunk-NUCGWLOY.js";import"./chunk-I2LPGKUU.js";import"./chunk-HON4OV7M.js";import"./chunk-PNPAHKJR.js";import"./chunk-FGR6QCG5.js";import"./chunk-VLVNA4T3.js";import"./chunk-TMUK2DD3.js";export{h as appleDoes,e as chooseHearing,c as helperPaths,d as helpers,b as notesNeed,i as probeSound,l as readRefusal,m as renderPages,n as renderTranscript,k as runRead,j as runTranscribe,a as transcribeNeeds,f as transcribeStatus,g as whisperUseful};
@@ -0,0 +1,3 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ import{a as U,b as at}from"./chunk-F4TUCI6D.js";import{a as S,b as st,c as L}from"./chunk-XUJLUOGD.js";import{c as ot}from"./chunk-6PUV4HSU.js";import"./chunk-3OCPO5V6.js";import{a as H,b as J,c as Q,d as V,f as X,g as Y,k as R,o as Z,p as tt,q as et,r as rt,s as nt}from"./chunk-BQV3DSUZ.js";import{b as z}from"./chunk-3IAJTXYM.js";import"./chunk-PXCEMDOY.js";import"./chunk-FEJSM3E4.js";import"./chunk-OLKPV4WO.js";import"./chunk-TQEGSODD.js";import"./chunk-O7DK3GJT.js";import"./chunk-S44LAUHZ.js";import"./chunk-ULX4ZD2Y.js";import"./chunk-HZDYZ5RD.js";import{c as N}from"./chunk-BSFBZBAI.js";import"./chunk-W6QOV4RP.js";import"./chunk-7NP76V4U.js";import{b as I,c as q}from"./chunk-DC2DHMXO.js";import"./chunk-PON65UTS.js";import"./chunk-JPASVE56.js";import"./chunk-SJIDFYPT.js";import{a as x,w as F}from"./chunk-JZM37DG2.js";import"./chunk-DKHBJ52G.js";import"./chunk-KXKQDFHX.js";import{a as W,d as _}from"./chunk-NUCGWLOY.js";import"./chunk-I2LPGKUU.js";import"./chunk-HON4OV7M.js";import{Ga as B,H as k,Ja as P,La as D,Na as G,Oa as K,Q as C,i as O,j}from"./chunk-PNPAHKJR.js";import"./chunk-FGR6QCG5.js";import{c as E}from"./chunk-VLVNA4T3.js";import"./chunk-TMUK2DD3.js";import{existsSync as A}from"node:fs";import{stat as pt}from"node:fs/promises";import{basename as h,dirname as dt,extname as y,join as it,resolve as w}from"node:path";function lt(t){if(t.format)return t.format;let e=t.output;if(e===void 0||x(e))return"md";let r=y(e).toLowerCase();return W.find(s=>s.ext===r)?.id??"md"}function v(t,e,r,s){let a=`${t}${_(s)}`;return r===void 0?it(e,a):x(r)?it(w(r),a):w(r)}function At(t){return t.kind==="model"?`downloading speech model, ${Math.round(t.fraction*100)}%`:t.kind==="heard"?`heard ${S(t.seconds)} of ${S(t.of)}`:t.kind==="notes"?`writing notes, part ${t.part} of ${t.of}`:`page ${t.page} of ${t.of}`}var ct=t=>t.split(/\s+/).filter(Boolean).length,gt=t=>t.segments.reduce((e,r)=>e+ct(r.text),0);async function mt(t){let{probe:e}=await import("./registry-657JRJR5.js"),r=await e(t).catch(()=>{throw B(t)});return at(r)}async function ht(t,e,r,s){if(e.to!==void 0)throw C(h(t.path));if(!(await R())?.read)throw await et();let n=v(h(t.path,y(t.path)),dt(t.path),e.output,s);if(A(n)&&!e.force)throw k(n);r.onStart?.("read");let u=await tt(t.path,{language:e.language,signal:r.signal,onEvent:r.onProgress}),o=H(u);if(!J(o))throw D(t.path);let c=[];await F(n,await rt(o,s,h(t.path),{signal:r.signal,lang:e.language,onMissing:i=>{c=i}})),r.document?.({path:n,markdown:Q(o)});let p=t.what==="pdf"?`${t.pages} ${t.pages===1?"page":"pages"}`:y(t.path).slice(1).toUpperCase()||"picture";return r.out(`\u2713 ${E(n)} ${p} \u2192 ${ct(V(o)).toLocaleString("en-US")} words`),c.length>0&&r.err(`\u26A0 ${N(c).message}`),r.finished?.({made:[{from:[t.path],to:[n]}],failed:[]}),0}async function Mt(t,e){try{let r=I(t.input),s=q(r);if(s)throw s;let a=r?.kind==="video"?r:void 0,n,u,o,c,p=lt(t);if(a===void 0){if(n=w(t.input),!(await pt(n).catch(()=>{}))?.isFile())throw j(n);let f=await ot(n);if(f!=="video"&&f!=="audio"){let m=await mt(n);if(m)return await ht(m,t,e,p)}}let i=await R(t.language?{locale:t.language}:{});if(i===void 0||!i.speech)throw P(X(process.platform,i?.missing));let ft=U(i.locale),b=t.notes&&i.notes==="available"&&ft,g=!t.notes||b?void 0:i.notes!=="available"?i.notes:"language";if(t.notes&&!b&&g!=="language"){if(!t.transcript)throw P(Y(process.platform,i.notes));i.notes==="off"&&e.err("\u26A0 Apple Intelligence is off, so this is the transcript only.")}if(a===void 0){if(n=w(t.input),u={title:h(n,y(n)),from:h(n)},o=v(u.title,dt(n),t.output,p),A(o)&&!t.force)throw k(o)}else{let l=new AbortController;e.signal?.addEventListener("abort",()=>l.abort(e.signal?.reason),{once:!0});let f;c=await z(a.url,{signal:l.signal,onEvent:m=>{m.kind==="facts"&&(f=v(L(m.facts.title),process.cwd(),t.output,p),A(f)&&!t.force&&l.abort(k(f)))}}),n=c.path,u={title:c.facts.title,from:a.url},o=f??v(L(c.facts.title),process.cwd(),t.output,p)}let d;try{e.onStart?.("transcribe"),d=await Z(n,{notes:b,detail:t.detail,locale:t.language,signal:e.signal,onEvent:e.onProgress})}finally{await c?.dispose()}if(d.notes&&!U(d.locale)){let{notes:l,...f}=d;d=f,g="language"}b&&!d.notes&&g===void 0&&(g="too-short");let M=st(d,u,{transcript:t.transcript}),T=[];await F(o,await nt(M,p,{signal:e.signal,lang:d.locale,onMissing:l=>{T=l}})),e.document?.({path:o,markdown:M,...g?{notesSkipped:g}:{}});let $=d.notes?.parts.length,ut=$===void 0?"":` \xB7 ${$} ${$===1?"part":"parts"}`;return e.out(`\u2713 ${E(o)} ${S(d.seconds)} \u2192 ${gt(d).toLocaleString("en-US")} words${ut}`),T.length>0&&e.err(`\u26A0 ${N(T).message}`),e.finished?.({made:[{from:[a===void 0?n:u.title],to:[o]}],failed:[]}),0}catch(r){let s=O(r)?r:G(r);for(let n of K(s,{debug:t.debug}))e.err(n);let a=I(t.input)===void 0?w(t.input):"";return e.finished?.({made:[],failed:[{path:a,message:s.message}]}),1}}export{Mt as runTranscribeCommand,At as transcribeFact};
@@ -1,3 +1,3 @@
1
1
  import { createRequire as __forgeCreateRequire } from 'node:module';
2
2
  const require = __forgeCreateRequire(import.meta.url);
3
- import{da as a}from"./chunk-CCNRNCRU.js";import"./chunk-FGR6QCG5.js";import"./chunk-VLVNA4T3.js";import"./chunk-TMUK2DD3.js";async function d(i,n={}){let e=n.check??(async()=>(await import("./check-HOITNMJX.js")).checkNow()),s=n.install??(async r=>(await import("./install-UN3YGSJW.js")).installUpdate(r)),t=await e();if(t===void 0)throw a();let{isNewer:o}=await import("./check-HOITNMJX.js");return o(t,i)?(n.onInstalling?.(t),await s(t),{stdout:[`\u2713 Forge ${t} is installed. It runs from your next forge.`],data:{current:i,latest:t,installed:!0}}):{stdout:[`\u2713 Forge ${i} is the latest.`],data:{current:i,latest:t,installed:!1}}}export{d as runUpdate};
3
+ import{ga as a}from"./chunk-PNPAHKJR.js";import"./chunk-FGR6QCG5.js";import"./chunk-VLVNA4T3.js";import"./chunk-TMUK2DD3.js";async function d(i,n={}){let e=n.check??(async()=>(await import("./check-BFHBPCGW.js")).checkNow()),s=n.install??(async r=>(await import("./install-XJAPLIH2.js")).installUpdate(r)),t=await e();if(t===void 0)throw a();let{isNewer:o}=await import("./check-BFHBPCGW.js");return o(t,i)?(n.onInstalling?.(t),await s(t),{stdout:[`\u2713 Forge ${t} is installed. It runs from your next forge.`],data:{current:i,latest:t,installed:!0}}):{stdout:[`\u2713 Forge ${i} is the latest.`],data:{current:i,latest:t,installed:!1}}}export{d as runUpdate};
@@ -1,3 +1,3 @@
1
1
  import { createRequire as __forgeCreateRequire } from 'node:module';
2
2
  const require = __forgeCreateRequire(import.meta.url);
3
- import{b as m,c as w,d as h,i as l,j as p,k as b}from"./chunk-UEAZTRTL.js";import{c as $,d as g}from"./chunk-WID72ZII.js";import{e as u}from"./chunk-4MZV4SRU.js";import"./chunk-BYUOU2Q2.js";import"./chunk-NUCGWLOY.js";import"./chunk-I2LPGKUU.js";import"./chunk-HON4OV7M.js";import"./chunk-CCNRNCRU.js";import"./chunk-FGR6QCG5.js";import"./chunk-VLVNA4T3.js";import"./chunk-TMUK2DD3.js";import{spawn as x}from"node:child_process";var P=60;function v(t,n){let e=Number.parseInt(t.slice(1),16);return`\x1B[${n};2;${e>>16&255};${e>>8&255};${e&255}m`}function C(t,n,e){let i=[" \u2191 ",`Forge ${t} is available`,` \xB7 your version ${n}`],r=[" In terminal: ","forge update"];if(e===void 0)return[i.join(""),r.join("")];let s=v(e.newTagBg,48),o=f=>v(f,38),c="\x1B[1m",a="\x1B[0m",d=f=>" ".repeat(Math.max(0,P-f.join("").length));return[`${s}${o(e.newTag)}${c}${i[0]}${o(e.fg)}${i[1]}${a}${s}${o(e.dim)}${i[2]}${d(i)}${a}`,`${s}${o(e.dim)}${r[0]}${o(e.fg)}${c}${r[1]}${a}${s}${d(r)}${a}`]}async function I(t,n){let e=n.now??Date.now(),{prefs:i}=await u();if(!h(i,n.env??process.env))return[];let r=await l();b(r,e)&&n.refresh();let s=r?.latest;if(r===void 0||s===void 0||!w(s,t))return[];let o=r.notifiedAt;if(o!==void 0&&o<=e&&e-o<=m)return[];await p({...r,notifiedAt:e}).catch(()=>{});let c=n.colour?i.theme==="light"?g:$:void 0;return C(s,t,c)}function N(t,n=process.platform,e=x){if(t!==void 0)try{e(process.execPath,[...process.execArgv,t,"__update-check"],{detached:!0,stdio:"ignore",...n==="win32"?{windowsHide:!0}:{}}).unref()}catch{}}export{I as afterCommand,C as noteLines,N as spawnRefresh};
3
+ import{b as m,c as w,d as h,i as l,j as p,k as b}from"./chunk-M7HB4L6L.js";import{c as $,d as g}from"./chunk-H332YFSO.js";import{e as u}from"./chunk-ZL7E7PZN.js";import"./chunk-4AL5QJLM.js";import"./chunk-NUCGWLOY.js";import"./chunk-I2LPGKUU.js";import"./chunk-HON4OV7M.js";import"./chunk-PNPAHKJR.js";import"./chunk-FGR6QCG5.js";import"./chunk-VLVNA4T3.js";import"./chunk-TMUK2DD3.js";import{spawn as x}from"node:child_process";var P=60;function v(t,n){let e=Number.parseInt(t.slice(1),16);return`\x1B[${n};2;${e>>16&255};${e>>8&255};${e&255}m`}function C(t,n,e){let i=[" \u2191 ",`Forge ${t} is available`,` \xB7 your version ${n}`],r=[" In terminal: ","forge update"];if(e===void 0)return[i.join(""),r.join("")];let s=v(e.newTagBg,48),o=f=>v(f,38),c="\x1B[1m",a="\x1B[0m",d=f=>" ".repeat(Math.max(0,P-f.join("").length));return[`${s}${o(e.newTag)}${c}${i[0]}${o(e.fg)}${i[1]}${a}${s}${o(e.dim)}${i[2]}${d(i)}${a}`,`${s}${o(e.dim)}${r[0]}${o(e.fg)}${c}${r[1]}${a}${s}${d(r)}${a}`]}async function I(t,n){let e=n.now??Date.now(),{prefs:i}=await u();if(!h(i,n.env??process.env))return[];let r=await l();b(r,e)&&n.refresh();let s=r?.latest;if(r===void 0||s===void 0||!w(s,t))return[];let o=r.notifiedAt;if(o!==void 0&&o<=e&&e-o<=m)return[];await p({...r,notifiedAt:e}).catch(()=>{});let c=n.colour?i.theme==="light"?g:$:void 0;return C(s,t,c)}function N(t,n=process.platform,e=x){if(t!==void 0)try{e(process.execPath,[...process.execArgv,t,"__update-check"],{detached:!0,stdio:"ignore",...n==="win32"?{windowsHide:!0}:{}}).unref()}catch{}}export{I as afterCommand,C as noteLines,N as spawnRefresh};
@@ -0,0 +1,3 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ import{a,b,c,d,e,f}from"./chunk-3IAJTXYM.js";import"./chunk-PXCEMDOY.js";import"./chunk-FEJSM3E4.js";import"./chunk-OLKPV4WO.js";import"./chunk-DC2DHMXO.js";import"./chunk-PON65UTS.js";import"./chunk-HON4OV7M.js";import"./chunk-PNPAHKJR.js";import"./chunk-FGR6QCG5.js";import"./chunk-VLVNA4T3.js";import"./chunk-TMUK2DD3.js";export{f as byteCounter,b as fetchSound,c as fetchVideo,d as linkArgs,e as readFacts,a as ytDlpMissing};
@@ -0,0 +1,3 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ import{c as R,d as k}from"./chunk-OPDC577C.js";import{a as W,d as N}from"./chunk-6PUV4HSU.js";import"./chunk-42IEPG2K.js";import"./chunk-YXV3PYVI.js";import"./chunk-56QHX7QR.js";import"./chunk-3OCPO5V6.js";import"./chunk-Z3PQ5TMU.js";import{d as w,e as h}from"./chunk-YJ6XLDRA.js";import"./chunk-63XCSYHM.js";import"./chunk-TQEGSODD.js";import"./chunk-O7DK3GJT.js";import"./chunk-S44LAUHZ.js";import"./chunk-ULX4ZD2Y.js";import"./chunk-BSFBZBAI.js";import"./chunk-W6QOV4RP.js";import{a as S}from"./chunk-H332YFSO.js";import"./chunk-7NP76V4U.js";import"./chunk-PON65UTS.js";import"./chunk-JPASVE56.js";import"./chunk-SJIDFYPT.js";import"./chunk-JZM37DG2.js";import"./chunk-DKHBJ52G.js";import"./chunk-KXKQDFHX.js";import"./chunk-ZL7E7PZN.js";import"./chunk-4AL5QJLM.js";import"./chunk-NUCGWLOY.js";import"./chunk-I2LPGKUU.js";import"./chunk-HON4OV7M.js";import{Oa as E,S as L,d as F,i as M,j as I}from"./chunk-PNPAHKJR.js";import{a as A}from"./chunk-FGR6QCG5.js";import{c as a}from"./chunk-VLVNA4T3.js";import"./chunk-TMUK2DD3.js";import{readdir as T,stat as B}from"node:fs/promises";import{join as C,resolve as y}from"node:path";function K(r,t,s,n){return[`\u2713 ${r} converted${n?` to ${n}`:""}`,...t?[`${t} failed`]:[],...s?[`${s} left alone`]:[]].join(" \xB7 ")}var P=r=>{let[t,...s]=r.job.outputs,n=`${a(t??"")}${s.length?` + ${s.length} more`:""}`;return`\u2713 ${a(r.job.sources[0].path)} \u2192 ${n} ${A(r.outputBytes)}`},O=(r,t)=>`\u2715 ${a(r)} ${t.title.toLowerCase()}`,D=r=>`\u2013 ${a(r.path)} ${r.reason}`;async function _(r,t){let s=y(r.folder),n=(e,o)=>t.out(JSON.stringify({forge:S,event:e,...o}));try{let e=await B(s).catch(()=>{});if(!e)throw I(s);if(!e.isDirectory())throw L(`${a(s)} is not a folder.`,`forge watch watches a folder. Try: forge watch ${a(y(s,".."))} --to ${r.target}`)}catch(e){if(!M(e))throw e;if(t.json)n("error",{ok:!1,failures:[h({error:e})]});else for(let o of E(e,{debug:r.debug}))(t.err??t.out)(o);return e.code==="invalid-arguments"?2:1}let m={target:r.target,...r.quality===void 0?{}:{quality:r.quality},dpi:r.dpi??150},$={images:m,pdfs:m,documents:m},c=r.output===void 0?void 0:y(r.output),q=F[r.target].label,p=0,i=[],u=[],b=new Set,g;if(r.newOnly)g=(await T(s,{withFileTypes:!0})).filter(o=>o.isFile()&&!W(o.name)).map(o=>C(s,o.name));else{let e=await N(s);g=e.paths;let o=await R(e,$,{destination:c});b=o.claimed;let f=[...e.failures,...o.outcome.refusals,...o.outcome.failures],j=e.kinds.flatMap(l=>l.why?[{count:l.count,why:l.why}]:[]),J=o.left.length+j.reduce((l,d)=>l+d.count,0);if(p+=o.outcome.results.length,i.push(...f),u.push(...o.left),t.json)n("converted-existing",{ok:f.length===0,results:o.outcome.results.map(w),failures:f.map(h),leftAlone:o.left});else if(e.paths.length>0){t.out(K(o.outcome.results.length,f.length,J,q));for(let l of f)t.out(O(l.path,l.error))}for(let l of j)for(let d=0;d<l.count;d++)u.push({path:"",reason:l.why})}t.json?n("watching",{folder:s,...c?{output:c}:{}}):t.out(`Watching ${a(s)} \xB7 any new files you add will be converted \xB7 ctrl-c to stop`);let x=k({dir:s,answers:$,known:g,claimed:b,destination:c,...t.settleMs===void 0?{}:{settleMs:t.settleMs},...t.pollMs===void 0?{}:{pollMs:t.pollMs},onEvent:e=>{e.type==="converted"?(p++,t.json?n("converted",{result:w(e.result)}):t.out(P(e.result))):e.type==="failed"?(i.push({path:e.path,error:e.error}),t.json?n("failed",{failure:h({path:e.path,error:e.error})}):t.out(O(e.path,e.error))):e.type==="left"&&(u.push({path:e.path,reason:e.reason}),t.json?n("left-alone",{path:e.path,reason:e.reason}):t.out(D({path:e.path,reason:e.reason})))}});return await new Promise(e=>{t.signal.aborted?e():t.signal.addEventListener("abort",()=>e(),{once:!0})}),await x.stop(),t.json?n("stopped",{converted:p,failed:i.length,leftAlone:u.length}):t.out(K(p,i.length,u.length)),i.length>0?1:0}export{_ as runWatch};
package/dist/index.js CHANGED
@@ -1,19 +1,19 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __forgeCreateRequire } from 'node:module';
3
3
  const require = __forgeCreateRequire(import.meta.url);
4
- import{e as N,f as v,g as E}from"./chunks/chunk-YYZYZWF5.js";import{b as f,d as S}from"./chunks/chunk-IBPGC4N2.js";import"./chunks/chunk-QPUKPSPZ.js";import"./chunks/chunk-PISCJKIG.js";import"./chunks/chunk-HZDYZ5RD.js";import"./chunks/chunk-EYOO35US.js";import{g as C}from"./chunks/chunk-YJ6XLDRA.js";import"./chunks/chunk-63XCSYHM.js";import{a as d}from"./chunks/chunk-WID72ZII.js";import{b as P}from"./chunks/chunk-O7DK3GJT.js";import{c as F}from"./chunks/chunk-65Y7YCZZ.js";import"./chunks/chunk-NMGQGYVM.js";import"./chunks/chunk-EEQSUBBL.js";import"./chunks/chunk-BSFBZBAI.js";import"./chunks/chunk-BWJNZT75.js";import"./chunks/chunk-3IX3QA76.js";import"./chunks/chunk-2OSM4W4D.js";import"./chunks/chunk-PON65UTS.js";import"./chunks/chunk-FWVE3GNA.js";import"./chunks/chunk-QO4JUY6B.js";import"./chunks/chunk-UN5DSJE2.js";import"./chunks/chunk-6HUYBVQA.js";import"./chunks/chunk-KXKQDFHX.js";import"./chunks/chunk-4MZV4SRU.js";import"./chunks/chunk-BYUOU2Q2.js";import"./chunks/chunk-NUCGWLOY.js";import"./chunks/chunk-I2LPGKUU.js";import"./chunks/chunk-HON4OV7M.js";import{Ka as $,La as h,Q as k,f as g}from"./chunks/chunk-CCNRNCRU.js";import"./chunks/chunk-FGR6QCG5.js";import"./chunks/chunk-VLVNA4T3.js";import"./chunks/chunk-TMUK2DD3.js";import*as M from"node:module";function y(r){return g(r)?r:$(r)}function I(r,n){return h(y(r),{debug:n})}function j(r,n){process.once("beforeExit",()=>{r()||(n(new Error("Forge stopped before it finished: it was waiting for input that never came.")),process.exitCode=1)})}P();M.enableCompileCache?.();function R({completed:r,total:n}){r===0?process.stderr.write(`Converting ${n} files
4
+ import{b as f,d as S}from"./chunks/chunk-IBPGC4N2.js";import{e as N,f as v,g as E}from"./chunks/chunk-SCJ2QXZF.js";import"./chunks/chunk-EYOO35US.js";import"./chunks/chunk-72UR37EG.js";import"./chunks/chunk-Z3PQ5TMU.js";import{g as C}from"./chunks/chunk-YJ6XLDRA.js";import"./chunks/chunk-63XCSYHM.js";import"./chunks/chunk-TQEGSODD.js";import{b as P}from"./chunks/chunk-O7DK3GJT.js";import{c as F}from"./chunks/chunk-S44LAUHZ.js";import"./chunks/chunk-ULX4ZD2Y.js";import"./chunks/chunk-HZDYZ5RD.js";import"./chunks/chunk-BSFBZBAI.js";import"./chunks/chunk-W6QOV4RP.js";import{a as d}from"./chunks/chunk-H332YFSO.js";import"./chunks/chunk-7NP76V4U.js";import"./chunks/chunk-OQ6DTE56.js";import"./chunks/chunk-DC2DHMXO.js";import"./chunks/chunk-PON65UTS.js";import"./chunks/chunk-JPASVE56.js";import"./chunks/chunk-SJIDFYPT.js";import"./chunks/chunk-JZM37DG2.js";import"./chunks/chunk-DKHBJ52G.js";import"./chunks/chunk-KXKQDFHX.js";import"./chunks/chunk-ZL7E7PZN.js";import"./chunks/chunk-4AL5QJLM.js";import"./chunks/chunk-NUCGWLOY.js";import"./chunks/chunk-I2LPGKUU.js";import"./chunks/chunk-HON4OV7M.js";import{Na as $,Oa as h,T,i as g}from"./chunks/chunk-PNPAHKJR.js";import"./chunks/chunk-FGR6QCG5.js";import"./chunks/chunk-VLVNA4T3.js";import"./chunks/chunk-TMUK2DD3.js";import*as M from"node:module";function y(r){return g(r)?r:$(r)}function I(r,n){return h(y(r),{debug:n})}function j(r,n){process.once("beforeExit",()=>{r()||(n(new Error("Forge stopped before it finished: it was waiting for input that never came.")),process.exitCode=1)})}P();M.enableCompileCache?.();function R({completed:r,total:n}){r===0?process.stderr.write(`Converting ${n} files
5
5
  `):process.stderr.write(` ${r}/${n}
6
- `)}async function U(){let r=process.argv.slice(2),n=r.includes("--debug"),u=v(r);try{if(r[0]==="__update-check"){let{checkNow:e}=await import("./chunks/check-HOITNMJX.js");await e();return}if(r[0]==="menu"||r[0]==="mcp"){let e=N(r);if(e!==void 0){process.stdout.write(e);return}}if(r[0]==="menu"){let{openedForClick:e,parseMenuArgs:o}=await import("./chunks/command-ZX3L5VFO.js"),s=o(r.slice(1));if(s.kind==="open"){let{applyColourPreference:p}=await import("./chunks/theme-4Y66DDAO.js");p();let{bootShell:_}=await import("./chunks/boot-QRKC4QBA.js");await _(void 0,{opened:await e(s.action,s.paths)});return}let{runMenuCommand:a}=await import("./chunks/entry-3R2GK3IW.js");process.exitCode=await a(s,d);return}if(r[0]==="mcp"){let{runMcpServer:e}=await import("./chunks/server-TF32DQEO.js");await e(r.slice(1));return}let t=E(r);if(t.kind==="shell"){if(u)throw k("Pass a file, for example: forge photo.jpg --to webp --json");if(!process.stdout.isTTY||!process.stdin.isTTY){process.stderr.write(`Forge needs a file and a target format.
6
+ `)}async function U(){let r=process.argv.slice(2),n=r.includes("--debug"),u=v(r);try{if(r[0]==="__update-check"){let{checkNow:e}=await import("./chunks/check-BFHBPCGW.js");await e();return}if(r[0]==="menu"||r[0]==="mcp"){let e=N(r);if(e!==void 0){process.stdout.write(e);return}}if(r[0]==="menu"){let{openedForClick:e,parseMenuArgs:o}=await import("./chunks/command-JTK4IOS7.js"),i=o(r.slice(1));if(i.kind==="open"){let{applyColourPreference:p}=await import("./chunks/theme-FVQOSLPB.js");p();let{bootShell:_}=await import("./chunks/boot-PHDTJAFT.js");await _(void 0,{opened:await e(i.action,i.paths)});return}let{runMenuCommand:a}=await import("./chunks/entry-ZF7D32ZI.js");process.exitCode=await a(i,d);return}if(r[0]==="mcp"){let{runMcpServer:e}=await import("./chunks/server-6PH2DSFW.js");await e(r.slice(1));return}let t=E(r);if(t.kind==="shell"){if(u)throw T("Pass a file, for example: forge photo.jpg --to webp --json");if(!process.stdout.isTTY||!process.stdin.isTTY){process.stderr.write(`Forge needs a file and a target format.
7
7
  Try: forge photo.jpg --to webp
8
- `),process.exitCode=2;return}if(process.env.TERM==="dumb"){E(["--help"]);return}let{applyColourPreference:e}=await import("./chunks/theme-4Y66DDAO.js");e();let{bootShell:o}=await import("./chunks/boot-QRKC4QBA.js");await o(void 0,{menuNote:async()=>(await import("./chunks/entry-3R2GK3IW.js")).menuAtStart(d)});return}if(t.kind==="watch"){let{runWatch:e}=await import("./chunks/watch-command-BMSMGIHK.js"),{stopOnSignals:o}=await import("./chunks/signals-QSXY3F2A.js"),s=new AbortController,a=o(()=>s.abort(),{graceful:["SIGINT"]});process.exitCode=await e(t,{out:p=>process.stdout.write(`${p}
8
+ `),process.exitCode=2;return}if(process.env.TERM==="dumb"){E(["--help"]);return}let{applyColourPreference:e}=await import("./chunks/theme-FVQOSLPB.js");e();let{bootShell:o}=await import("./chunks/boot-PHDTJAFT.js");await o(void 0,{menuNote:async()=>(await import("./chunks/entry-ZF7D32ZI.js")).menuAtStart(d)});return}if(t.kind==="watch"){let{runWatch:e}=await import("./chunks/watch-command-3C4AWM7A.js"),{stopOnSignals:o}=await import("./chunks/signals-VY2XE3LV.js"),i=new AbortController,a=o(()=>i.abort(),{graceful:["SIGINT"]});process.exitCode=await e(t,{out:p=>process.stdout.write(`${p}
9
9
  `),err:p=>process.stderr.write(`${p}
10
- `),json:u,signal:s.signal}),a();return}if(t.kind==="uninstall"){let{runUninstall:e}=await import("./chunks/entry-3R2GK3IW.js");process.exitCode=await e(d,o=>process.stdout.write(`${o}
11
- `));return}let{execute:m}=await import("./chunks/execute-TC3QZ6GL.js"),i,b,T=0,O=(e,o)=>{let s=Date.now();if(e<o&&s-T<100)return;T=s;let a=p=>(p/1e6).toFixed(1);process.stderr.write(`\r downloading ${a(e)} / ${a(o)} MB${e>=o?`
12
- `:""}`)},l=!!process.stderr.isTTY&&!u,w=new AbortController,{stopOnSignals:D,SIGNAL_EXIT:Y}=await import("./chunks/signals-QSXY3F2A.js"),x,G=D(e=>{x=e,w.abort()},{graceMs:1e3}),L=Date.now(),c=await m(t,{json:u,...l?{onInstalling:e=>{i=f(process.stderr,`installing Forge ${e}`)}}:{},signal:w.signal,...l?{onDownload:O}:{},colour:!!process.stdout.isTTY&&!u&&S(),onProgress:l?e=>{e.completed>0&&i?.stop(),R(e)}:void 0,...l?{onSearch:e=>{i??=f(process.stderr,"finding the smallest that fits"),i.update(e)},onEncode:e=>{i??=f(process.stderr,"encoding"),i.update(e)},onTranscribe:(e,o)=>{i??=f(process.stderr,e),i.update(o),b??=setInterval(()=>i?.tick(),1e3),b.unref()}}:{}});if(clearInterval(b),G(),i?.stop(),c.stdout.length>0&&process.stdout.write(`${c.stdout.join(`
10
+ `),json:u,signal:i.signal}),a();return}if(t.kind==="uninstall"){let{runUninstall:e}=await import("./chunks/entry-ZF7D32ZI.js");process.exitCode=await e(d,o=>process.stdout.write(`${o}
11
+ `));return}let{execute:m}=await import("./chunks/execute-RP7ZMWLZ.js"),s,b,k=0,D=(e,o)=>{let i=Date.now();if(e<o&&i-k<100)return;k=i;let a=p=>(p/1e6).toFixed(1);process.stderr.write(`\r downloading ${a(e)} / ${a(o)} MB${e>=o?`
12
+ `:""}`)},l=!!process.stderr.isTTY&&!u,w=new AbortController,{stopOnSignals:O,SIGNAL_EXIT:L}=await import("./chunks/signals-VY2XE3LV.js"),x,Y=O(e=>{x=e,w.abort()},{graceMs:1e3}),G=Date.now(),c=await m(t,{json:u,...l?{onInstalling:e=>{s=f(process.stderr,`installing Forge ${e}`)}}:{},signal:w.signal,...l?{onDownload:D}:{},colour:!!process.stdout.isTTY&&!u&&S(),onProgress:l?e=>{e.completed>0&&s?.stop(),R(e)}:void 0,...l?{onSearch:e=>{s??=f(process.stderr,"finding the smallest that fits"),s.update(e)},onEncode:e=>{s??=f(process.stderr,"encoding"),s.update(e)},onLinkDownload:e=>{if(e===void 0){s?.stop(),s=void 0;return}s??=f(process.stderr,"downloading"),s.update(e)},onTranscribe:(e,o)=>{s??=f(process.stderr,e),s.update(o),b??=setInterval(()=>s?.tick(),1e3),b.unref()}}:{}});if(clearInterval(b),Y(),s?.stop(),c.stdout.length>0&&process.stdout.write(`${c.stdout.join(`
13
13
  `)}
14
14
  `),c.stderr.length>0&&process.stderr.write(`${c.stderr.join(`
15
15
  `)}
16
- `),process.exitCode=x?Y[x]:c.exitCode,l&&c.notice&&!w.signal.aborted){let{postFinishNotice:e}=await import("./chunks/notify-UD7FQAWX.js");await e(c.notice,Date.now()-L)}if(l&&process.stdout.isTTY&&t.kind!=="update"&&!w.signal.aborted)try{let{afterCommand:e,spawnRefresh:o}=await import("./chunks/update-note-XV2T2NNG.js"),{runningScript:s}=await import("./chunks/install-UN3YGSJW.js"),a=await e(d,{refresh:()=>o(s(process.argv[1])),colour:S()});a.length>0&&process.stderr.write(`
16
+ `),process.exitCode=x?L[x]:c.exitCode,l&&c.notice&&!w.signal.aborted){let{postFinishNotice:e}=await import("./chunks/notify-UD7FQAWX.js");await e(c.notice,Date.now()-G)}if(l&&process.stdout.isTTY&&t.kind!=="update"&&!w.signal.aborted)try{let{afterCommand:e,spawnRefresh:o}=await import("./chunks/update-note-LV7G4CHE.js"),{runningScript:i}=await import("./chunks/install-XJAPLIH2.js"),a=await e(d,{refresh:()=>o(i(process.argv[1])),colour:S()});a.length>0&&process.stderr.write(`
17
17
  ${a.join(`
18
18
  `)}
19
19
  `)}catch{}}catch(t){if(g(t)){u?process.stdout.write(`${JSON.stringify(C(d,t))}
package/package.json CHANGED
@@ -1,27 +1,23 @@
1
1
  {
2
2
  "name": "forge-terminal",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "A terminal-native file converter for macOS, Windows and Linux",
5
5
  "whatsNew": [
6
6
  {
7
- "title": "Pick the language",
8
- "text": "Transcribe lets you choose the spoken language, so French, Japanese and 40 more come out right. Notes are written for English speech."
7
+ "title": "Videos from links",
8
+ "text": "Paste a link from YouTube, Instagram, TikTok, X and more, and it works like a dropped video: convert it, shrink it, trim it or transcribe it."
9
9
  },
10
10
  {
11
- "title": "Better with PDFs",
12
- "text": "Locked PDFs ask for their password first. PDFs that already hold text are read from it: much faster, and right for Hebrew, Thai and Korean."
11
+ "title": "Download in Edit",
12
+ "text": "Edit → Download saves a link's video as the site sent it, named after its title. On the command line, forge <link> does the same."
13
13
  },
14
14
  {
15
- "title": "Stop means stop",
16
- "text": "ctrl-c stops a conversion at once, and nothing half-made is left behind."
15
+ "title": "Signed-in sites",
16
+ "text": "Sites that want you signed in, like Instagram, can borrow your browser's sign-in. Forge asks once and remembers it for that site."
17
17
  },
18
18
  {
19
- "title": "Quiet when idle",
20
- "text": "Left open, Forge uses almost no power: the home animation rests after 10 seconds, or as soon as you switch to another window."
21
- },
22
- {
23
- "title": "Fewer surprises",
24
- "text": "Word files in any language become PDFs, Compress makes the size it promises, and errors say what went wrong instead of \"Conversion failed\"."
19
+ "title": "Smoother colours",
20
+ "text": "On a scale, type a new colour without #. ⇧→ starts a gradient, and the bar no longer fills up with every colour you tried."
25
21
  }
26
22
  ],
27
23
  "keywords": [
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: forge
3
- description: Convert, compress and edit local files with the Forge CLI (`forge`) — images (HEIC, camera RAW, JPEG, PNG, WebP, AVIF, GIF, TIFF), PDFs, Word documents, video and sound — and hear or read what an agent cannot. Use when the user wants a file in another format, smaller or under a size limit, or cropped to a shape; a PDF merged, split, trimmed or rotated; what a recording, meeting or YouTube video says; the text in a picture, scan or PDF; or a colour palette, tonal scale or named colours as a card to paste into Figma — and `forge` is installed (`npm i -g forge-terminal`).
3
+ description: Convert, compress and edit local files with the Forge CLI (`forge`) — images (HEIC, camera RAW, JPEG, PNG, WebP, AVIF, GIF, TIFF), PDFs, Word documents, video and sound — and hear or read what an agent cannot. Use when the user wants a file in another format, smaller or under a size limit, or cropped to a shape; a PDF merged, split, trimmed or rotated; what a recording, meeting or online video says; a video saved from a link (YouTube, Instagram, TikTok, X…); the text in a picture, scan or PDF; or a colour palette, tonal scale or named colours as a card to paste into Figma — and `forge` is installed (`npm i -g forge-terminal`).
4
4
  ---
5
5
 
6
6
  # Forge
@@ -13,8 +13,12 @@ Forge converts files on this computer. Nothing is uploaded.
13
13
  `--max-size 5mb`. A set width: `--width 1200`.
14
14
  - **A format you cannot open** (HEIC, camera RAW, Word): convert it to PNG,
15
15
  JPEG or PDF and read that.
16
- - **What a recording, meeting or YouTube video says:** `forge transcribe`,
16
+ - **What a recording, meeting or online video says:** `forge transcribe`,
17
17
  then read the Markdown file it writes.
18
+ - **A video from a link** (YouTube, Instagram, TikTok, X…): `forge '<link>'`
19
+ saves it in the current folder; a link also goes anywhere a file goes
20
+ (`--to gif`, `compress --max-size 25mb`). A site that wants a sign-in:
21
+ `--cookies-from-browser chrome` (or safari, firefox, brave, edge).
18
22
  - **The text in a picture, screenshot, scan or PDF:** `forge transcribe` on
19
23
  it reads the text instead.
20
24
  - **Colours for Figma:** `forge card`, `forge scale` or `forge palette` with
@@ -98,7 +102,7 @@ never edit the original.
98
102
  ```bash
99
103
  forge transcribe meeting.m4a # summary, notes and transcript -> meeting.md
100
104
  forge transcribe talk.mp4 --to transcript # no notes; --to notes: no transcript
101
- forge transcribe 'https://youtu.be/…' # a YouTube link, into this folder
105
+ forge transcribe 'https://youtu.be/…' # a video link, into this folder
102
106
  forge transcribe talk.mp4 --detail brief --format pdf -o ~/Notes/
103
107
  forge transcribe whiteboard.jpg # the text in a picture -> whiteboard.md
104
108
  ```
@@ -1,3 +0,0 @@
1
- import { createRequire as __forgeCreateRequire } from 'node:module';
2
- const require = __forgeCreateRequire(import.meta.url);
3
- import{a,b,c,d,e,f,g}from"./chunk-YYZYZWF5.js";import"./chunk-QPUKPSPZ.js";import"./chunk-PISCJKIG.js";import"./chunk-HZDYZ5RD.js";import"./chunk-EYOO35US.js";import"./chunk-WID72ZII.js";import"./chunk-NMGQGYVM.js";import"./chunk-EEQSUBBL.js";import"./chunk-BSFBZBAI.js";import"./chunk-BWJNZT75.js";import"./chunk-3IX3QA76.js";import"./chunk-2OSM4W4D.js";import"./chunk-PON65UTS.js";import"./chunk-FWVE3GNA.js";import"./chunk-QO4JUY6B.js";import"./chunk-UN5DSJE2.js";import"./chunk-6HUYBVQA.js";import"./chunk-KXKQDFHX.js";import"./chunk-4MZV4SRU.js";import"./chunk-BYUOU2Q2.js";import"./chunk-NUCGWLOY.js";import"./chunk-I2LPGKUU.js";import"./chunk-HON4OV7M.js";import"./chunk-CCNRNCRU.js";import"./chunk-FGR6QCG5.js";import"./chunk-VLVNA4T3.js";import"./chunk-TMUK2DD3.js";export{b as COMMANDS_HELP,a as EXIT_CODES_HELP,d as colourUsage,c as commandsHelp,g as parseArgs,e as subcommandHelp,f as wantsJson};
@@ -1,3 +0,0 @@
1
- import { createRequire as __forgeCreateRequire } from 'node:module';
2
- const require = __forgeCreateRequire(import.meta.url);
3
- import{d as s,h as a}from"./chunk-EEQSUBBL.js";import{a as i}from"./chunk-CCNRNCRU.js";import{a as r}from"./chunk-FGR6QCG5.js";import{win32 as d}from"node:path";function l(n,e=process.platform){return e==="win32"?d.basename(n):n.split("/").pop()}function f(n){return n.facts?n.facts.video!==void 0:i[n.format].media==="video"}function v(n){return n==="mp3"?"mp3":n==="opus"?"opus":"m4a"}var u=n=>n===1?"mono":n===2?"stereo":`${n} channels`,m=n=>`${Math.round(n/100)/10} kHz`;function F(n){let e=r(n.bytes),o=n.facts;if(!o)return`${f(n)?"video":"sound"} \xB7 ${e}`;let t=[s(o.duration)];return o.video?(t.push(`${o.video.width}\xD7${o.video.height}`,`${o.video.fps} fps`),o.video.hdr&&t.push("HDR")):o.audio&&t.push(u(o.audio.channels),m(o.audio.sampleRate)),t.push(e),t.join(" \xB7 ")}function p(n){return n.facts?a(n.facts):void 0}function $(n){let e=p(n)??0;return[...e<1e6?["kb"]:[],...n.bytes>=1e6||e>=1e6?["mb"]:[],...n.bytes>1e9?["gb"]:[]]}var c=n=>n==="opus"?96:128;function k(n,e){let o=n.facts;if(!(!o?.audio||i[e].media!=="sound")){if(i[e].lossy)return Math.round(c(e)*1e3*o.duration/8);if(e==="wav"||e==="aiff")return Math.round(o.audio.sampleRate*o.audio.channels*2*o.duration)}}export{l as a,f as b,v as c,F as d,p as e,$ as f,k as g};
@@ -1,6 +0,0 @@
1
- import { createRequire as __forgeCreateRequire } from 'node:module';
2
- const require = __forgeCreateRequire(import.meta.url);
3
- import{l as k}from"./chunk-3HG7RXC2.js";import{c as I,e as $,f as P}from"./chunk-I25E2XDH.js";import{a as w}from"./chunk-PON65UTS.js";import{D as v,Da as E,Fa as m,X as S}from"./chunk-CCNRNCRU.js";var M="Summary and notes by Apple Intelligence. They may contain mistakes.";function L(t){let r=Math.floor(t),e=s=>String(s).padStart(2,"0"),n=Math.floor(r/3600),o=Math.floor(r/60)%60;return n>0?`${n}:${e(o)}:${e(r%60)}`:`${o}:${e(r%60)}`}var N=t=>t.split(/\s+/).filter(Boolean).length,D=60,j=140,R=1,V=10;function Y(t){let r=[],e;for(let n of t){if(e){let o=n.start-e.end;if(!(o>V||o>R&&e.words>=D||e.words>=j)){e.text+=` ${n.text}`,e.end=n.end,e.words+=N(n.text);continue}r.push({start:e.start,text:e.text})}e={start:n.start,end:n.end,text:n.text,words:N(n.text)}}return e&&r.push({start:e.start,text:e.text}),r}var T=t=>Y(t).flatMap(r=>[`**${L(r.start)}** ${r.text}`,""]),W=t=>/^https?:\/\/\S+$/.test(t)?`<${t}>`:t;function q(t,r,{transcript:e=!0}={}){let n=[`# ${r.title}`,"",W(r.from),""],o=t.notes;if(!o)return[...n,...T(t.segments)].join(`
4
- `);let s=o.parts,p=a=>{let d=s[a];return d?`### ${d.refused?`Part ${a+1}`:d.heading} \xB7 ${L(d.start)}`:""};n.push(o.summary,"","## Notes",""),s.forEach((a,d)=>{n.push(p(d),""),a.points.length>0&&n.push(...a.points.map(l=>`- ${l}`),"")});let c=[`_${M}_`,""];return e?(n.push("## Transcript",""),s.forEach((a,d)=>{let l=s[d+1]?.start??Number.POSITIVE_INFINITY,b=t.segments.filter(h=>h.start>=a.start&&h.start<l);n.push(p(d),"",...T(b))}),[...n,...c].join(`
5
- `)):[...n,...c].join(`
6
- `)}function z(t){let r=[...t].map(e=>(e.codePointAt(0)??0)<32?" ":e).join("").replace(/[/\\:*?"<>|]/g,"-").replace(/\s+/g," ").trim().slice(0,120).replace(/^\.+/,"");return r===""?"transcript":r}var C=["en"];function Z(t){let r=t?.split(/[-_]/)[0]?.toLowerCase();return r!==void 0&&C.includes(r)}function rt(t){if(t.kind!=="media"){if(t.kind==="image"){let{path:r,format:e,bytes:n,width:o,height:s}=t;return{what:"image",path:r,format:e,bytes:n,width:o,height:s}}if(t.format!=="pdf")throw E(t.path);if(t.encrypted)throw v(t.path);return{what:"pdf",path:t.path,bytes:t.bytes,pages:t.pages}}}import{spawn as F}from"node:child_process";import{mkdtemp as G,rm as H}from"node:fs/promises";import{tmpdir as K}from"node:os";import{join as _}from"node:path";import{createInterface as B}from"node:readline";var U=[[/private video/i,"This video is private."],[/confirm your age/i,"This video is age-restricted."],[/members-only|join this channel/i,"This video is for channel members only."],[/live event will begin|premieres in/i,"This video has not started yet."],[/unavailable|has been removed|does not exist/i,"This video is unavailable."]],g=class extends Error{};function J(t=process.platform,r=process.arch){let e=$("yt-dlp");return e!==void 0&&P(e,t,r)!==void 0?S("yt-dlp"):m(`YouTube links on ${I(t)} need yt-dlp on your PATH.`,void 0,{hint:"Install yt-dlp (https://github.com/yt-dlp/yt-dlp) and put it on your PATH.",shellHint:"Install yt-dlp and put it on your PATH."})}async function ft(t,r={}){let e=await k();if(e===void 0)throw J();let n=await G(_(K(),"forge-yt-"));r.onDir?.(n);let o=()=>H(n,{recursive:!0,force:!0});try{let s;try{s=await A(e.entry,t,n,r)}catch(p){if(!(p instanceof g))throw p;if(e.own)throw m(`yt-dlp could not fetch this video: ${p.message}`,p);await X(e.entry,r.signal);try{s=await A(e.entry,t,n,r)}catch(c){throw c instanceof g?m(`yt-dlp could not fetch this video: ${c.message}`,c):c}}return{...s,dispose:o}}catch(s){throw await o(),s}}function A(t,r,e,n){let{signal:o}=n;if(o?.aborted)return Promise.reject(o.reason??new Error("aborted"));let s=["--js-runtimes",`node:${process.execPath}`,"--no-playlist","--no-warnings","--newline","--progress","-f","bestaudio[ext=m4a]/bestaudio","--print","before_dl:forge-facts %(.{title,uploader,duration,is_live})j","--progress-template","download:forge-bytes %(progress.downloaded_bytes)s %(progress.total_bytes,progress.total_bytes_estimate)s","--print","after_move:forge-file %(filepath)s","--no-simulate","-o",_(e,"sound.%(ext)s"),r];return new Promise((p,c)=>{let a=w(F(t,s,{stdio:["ignore","pipe","pipe"]})),d,l,b="",h=!1,y=i=>{h||(h=!0,o?.removeEventListener("abort",x),i())},x=()=>{a.kill("SIGKILL"),y(()=>c(o?.reason??new Error("aborted")))};o?.addEventListener("abort",x,{once:!0}),B({input:a.stdout}).on("line",i=>{if(i.startsWith("forge-facts ")){let u=JSON.parse(i.slice(12));if(u.is_live===!0){a.kill("SIGKILL"),y(()=>c(m("Live streams cannot be transcribed.")));return}d={title:String(u.title??""),uploader:String(u.uploader??""),seconds:Number(u.duration??0)},n.onEvent?.({kind:"facts",facts:d})}else if(i.startsWith("forge-bytes ")){let[u,f]=i.slice(12).split(" ").map(Number);Number.isFinite(u)&&Number.isFinite(f)&&(f??0)>0&&n.onEvent?.({kind:"bytes",done:u,total:f})}else i.startsWith("forge-file ")&&(l=i.slice(11))}),a.stderr.on("data",i=>{b+=i.toString()}),a.on("error",i=>y(()=>c(new g(i.message)))),a.on("close",i=>y(()=>{if(i===0&&d!==void 0&&l!==void 0)return p({path:l,facts:d});let u=b.match(/ERROR: (?:\[[^\]]*\] )?(?:[\w-]+: )?(.*)/)?.[1]?.trim()??"",f=U.find(([O])=>O.test(u));c(f?m(f[1]):new g(u||`yt-dlp exited ${i}`))}))})}function X(t,r){return new Promise((e,n)=>{let o=w(F(t,["--update"],{stdio:"ignore"})),s=()=>o.kill("SIGKILL");r?.addEventListener("abort",s,{once:!0}),o.on("error",()=>e()),o.on("close",()=>{r?.removeEventListener("abort",s),r?.aborted?n(r.reason??new Error("aborted")):e()})})}export{L as a,q as b,z as c,Z as d,rt as e,J as f,ft as g};
@@ -1,4 +0,0 @@
1
- import { createRequire as __forgeCreateRequire } from 'node:module';
2
- const require = __forgeCreateRequire(import.meta.url);
3
- import{b as l}from"./chunk-BYUOU2Q2.js";import{c as g}from"./chunk-NUCGWLOY.js";import{a as h}from"./chunk-HON4OV7M.js";import{O as u}from"./chunk-CCNRNCRU.js";import{copyFile as M,mkdir as N,readFile as b,rename as S,unlink as D,writeFile as j}from"node:fs/promises";import{homedir as F}from"node:os";import{dirname as c,join as O}from"node:path";import{execFileSync as x}from"node:child_process";import{homedir as m}from"node:os";import{join as k}from"node:path";var E={Desktop:"[Environment]::GetFolderPath('Desktop')",Downloads:"(Get-ItemProperty 'HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders').'{374DE290-123F-4565-9164-39C4925E467B}'"};function v(e){try{let n=x("powershell.exe",["-NoProfile","-NonInteractive","-Command",`[Console]::OutputEncoding=[Text.Encoding]::UTF8; ${E[e]}`],{encoding:"buffer",timeout:5e3,stdio:["ignore","pipe","ignore"]}).toString("utf8").trim();return n.length>0?n:void 0}catch{return}}var y=new Map;function a(e,t=process.platform,n=v){if(t!=="win32")return k(m(),e);let r=y.get(e);if(r!==void 0)return r;let o=n(e)?.replace(/%([^%]+)%/g,(w,C)=>process.env[C]??w),p=(o!==void 0&&!o.includes("%")?o:void 0)??k(m(),e);return y.set(e,p),p}var s={defaultOutput:"~/Desktop"};function d(){return O(h(),"forge","config.json")}function Q(e,t=process.platform){if(t==="win32"){if(e==="~/Desktop")return a("Desktop",t);if(e==="~/Downloads")return a("Downloads",t)}return e==="~"?F():e.startsWith("~/")?O(F(),e.slice(2)):e}function P(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function R(e){let t={...s},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 r=e.quality;typeof r=="number"&&Number.isInteger(r)&&r>=1&&r<=100?t.quality=r: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.transcribeFormat!==void 0&&(g(e.transcribeFormat)?t.transcribeFormat=e.transcribeFormat:n.push("transcribeFormat")),e.presets!==void 0)if(Array.isArray(e.presets)){let r=e.presets.map(l);t.presets=r.filter(i=>i!==void 0),t.presets.length<r.length&&n.push("presets")}else n.push("presets");return{prefs:t,rejected:n}}async function $(){let e;try{e=await b(d(),"utf8")}catch{return"missing"}try{let t=JSON.parse(e);return P(t)?t:"broken"}catch{return"broken"}}async function V(){let e=d(),t;try{t=await b(e,"utf8")}catch(o){return o.code==="ENOENT"?{prefs:s}:{prefs:s,warning:`Could not read the config at ${e} \u2014 using defaults.`}}let n;try{n=JSON.parse(t)}catch{return{prefs:s,warning:`The config at ${e} is not valid JSON \u2014 using defaults.`}}if(!P(n))return{prefs:s,warning:`The config at ${e} is not an object \u2014 using defaults.`};let{prefs:r,rejected:i}=R(n);return i.length===0?{prefs:r}:{prefs:r,warning:`Ignored invalid config ${i.length===1?"setting":"settings"}: ${i.join(", ")}.`}}async function _(e){let t=d();try{await N(c(t),{recursive:!0})}catch(o){throw u(c(t),o)}let n=await $();n==="broken"&&await M(t,`${t}.bak`).catch(o=>{throw u(c(t),o)});let r=typeof n=="object"?{...n}:{};for(let[o,f]of Object.entries(e))f!==void 0&&(r[o]=f);let i=`${t}.${process.pid}.tmp`;try{await j(i,`${JSON.stringify(r,null,2)}
4
- `,"utf8"),await S(i,t)}catch(o){throw await D(i).catch(()=>{}),u(c(t),o)}}export{a,s as b,d as c,Q as d,V as e,_ as f};
@@ -1,3 +0,0 @@
1
- import { createRequire as __forgeCreateRequire } from 'node:module';
2
- const require = __forgeCreateRequire(import.meta.url);
3
- import{j as h}from"./chunk-NMGQGYVM.js";import{g as l}from"./chunk-6HUYBVQA.js";import{b as c}from"./chunk-KXKQDFHX.js";import{B as p,a as s,f as m,n,p as f}from"./chunk-CCNRNCRU.js";async function x(r,i=192){let t=await h(r);if(t.kind!=="image")throw f(r,n(s[t.format].label));let u=await l(r,t.format);try{let e=await c(),{data:o,info:a}=await e(u,{animated:!1}).rotate().resize(i,i,{fit:"inside",withoutEnlargement:!0}).ensureAlpha().raw().toBuffer({resolveWithObject:!0});return{source:t,pixels:{width:a.width,height:a.height,rgba:new Uint8Array(o.buffer,o.byteOffset,o.length)}}}catch(e){throw m(e)?e:p(r,e)}}export{x 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 Q,b as X,f as Y}from"./chunk-YBA6DJQ4.js";import{b as J,c as W,m as A,n as O,o as $,q,r as N,t as C,u as _,w as H,x as U,y as V}from"./chunk-UI4EUC3S.js";import{b as j}from"./chunk-QIMSNTKL.js";import{b as G}from"./chunk-ECA4PW5T.js";import{d as S}from"./chunk-QPUKPSPZ.js";import{a as L}from"./chunk-PISCJKIG.js";import{f as K,g as T,h as D}from"./chunk-FWVE3GNA.js";import{b as P}from"./chunk-UN5DSJE2.js";import{a as R}from"./chunk-CCNRNCRU.js";import{a as z}from"./chunk-FGR6QCG5.js";import{existsSync as ye}from"node:fs";import{existsSync as M}from"node:fs";import{basename as re,dirname as se,extname as ie,join as ae}from"node:path";var le={images:"an image",pdfs:"a PDF",documents:"a document",videos:"a video",audio:"audio",other:"a file Forge reads"};function ce(e){let t=Object.keys(e).filter(s=>e[s]);if(t.length===0)return"not supported";let o=t.map(s=>le[s]);return`not ${o.length===1?o[0]:`${o.slice(0,-1).join(", ")} or ${o.at(-1)}`}`}function fe(e){return e.kind==="document"?e.format==="pdf"?"no images to shrink":"nothing to compress":`${R[e.format].label} is lossless`}function de(e,t,o){if(e.kind!=="image")return{left:"images only"};let s=e,r=o===void 0?{}:{output:o};if(t.tool==="sharpen"||t.tool==="boost"){let l=t.tool==="sharpen"?1:t.scale??2;if(K(s.width,s.height,l))return{left:l===1?"too large":`too large for ${l}\xD7`};let[c]=J.plan([s],{scale:String(l),target:S(s),...r});return c?{job:c}:{left:"not supported"}}if(t.tool==="cutout"){let[l]=W.plan([s],{target:"png",...r});return l?{job:l}:{left:"not supported"}}if(t.tool==="rotate"){if(s.frames>1)return{left:"animated"};let[l]=H.plan([s],{turn:t.turn??90,...r});return l?{job:l}:{left:"not supported"}}if(t.tool==="deband"){if(s.frames>1)return{left:"animated"};let[l]=V.plan([s],{deband:t.level??T[D].id,target:S(s),...r});return l?{job:l}:{left:"not supported"}}if(t.tool==="dither"){if(!N(s))return{left:"animated"};let[l]=U.plan([s],{dither:t.colours??$[0],target:q(s),...r});return l?{job:l}:{left:"not supported"}}if(t.tool==="trim"&&s.frames>1)return{left:"animated"};let n=t.tool==="trim"?C:_,[i]=n.plan([s],{target:S(s),...t.resize?{resize:t.resize}:{},...r});return i?{job:i}:{left:"not supported"}}function ue(e,t,o){if(t.op==="edit")return de(e,t,o);if(e.kind==="media")return{left:"one at a time"};let s=o===void 0?{}:{destination:o};if(t.op==="compress"){if(!A.appliesTo([e]))return{left:fe(e)};if(t.targetBytes!==void 0&&e.bytes<=t.targetBytes)return{left:"already under that size"};let[i]=A.plan([e],{mode:t.targetBytes===void 0?"quality":"size",...t.quality===void 0?{}:{quality:t.quality},...s});return i?{job:i}:{left:"not supported"}}let r=t.answers[X(e)];if(!r)return{left:ce(t.answers)};if(e.format===r.target)return{left:`already ${R[r.target].label}`};if(!L(e).includes(r.target))return{left:`can\u2019t become ${R[r.target].label}`};let[n]=O.plan([e],{target:r.target,...r.quality===void 0?{}:{quality:r.quality},...r.dpi===void 0?{}:{dpi:String(r.dpi)},pages:"all",...s});return n?.op==="convert"?{job:n}:{left:"not supported"}}function pe(e,t){if(!t(e))return e;let o=ie(e),s=re(e,o);for(let r=1;;r++){let n=ae(se(e),P(s,` (${r})${o}`));if(!t(n)&&!M(n))return n}}function me(e,t,o,s={}){let r=s.existing??"leave",n=ue(e,t,s.destination);if(!("job"in n))return n;let{job:i}=n,l=i.outputs.some(f=>M(f)&&!o.has(f));if(l&&r==="leave")return{left:t.op==="compress"?"already compressed":t.op==="edit"?"already edited":"already converted"};let c=r==="number"?f=>o.has(f)||M(f):f=>o.has(f);i.outputs=i.outputs.map(f=>pe(f,c));for(let f of i.outputs)o.add(f);return l&&r==="ask"?{job:i,taken:!0}:{job:i}}function F(e,t,o,s={}){let r=[],n=[],i=[];for(let l of e){let c=me(l,t,o,s);"job"in c?(r.push(c.job),c.taken&&i.push(c.job)):n.push({path:l.path,reason:c.left})}return{jobs:r,left:n,taken:i}}async function Z(e,t,o={}){let s=new Set,r=o.existing??"leave",{jobs:n,left:i}=F(e,t,s,{destination:o.destination,existing:r});return{outcome:await j(n,{force:r==="replace",...t.op==="compress"&&t.targetBytes!==void 0?{targetBytes:t.targetBytes}:{},...o.concurrency===void 0?{}:{concurrency:o.concurrency},...o.onEvent?{onEvent:o.onEvent}:{},...o.signal?{signal:o.signal}:{}}),left:i,claimed:s,jobs:n}}function ee(e,t){let{outcome:o,left:s}=t,r=new Map;for(let n of o.results){let i=n.job.sources[0].path;r.set(i,{path:i,state:"done",result:n})}for(let n of[...o.refusals,...o.failures])if(n.error.code==="cannot-compress-more"){let i=n.error.short==="nothing written"?"can\u2019t get smaller":"already under that size";r.set(n.path,{path:n.path,state:"left",reason:i})}else n.error.code==="nothing-to-trim"?r.set(n.path,{path:n.path,state:"left",reason:"no empty edges"}):n.error.code==="no-sound"?r.set(n.path,{path:n.path,state:"left",reason:"no sound"}):r.set(n.path,{path:n.path,state:"failed",reason:n.error.title.toLowerCase()});for(let n of o.unreachable){let i=n.job.sources[0].path;r.set(i,{path:i,state:"left",reason:`can\u2019t get below ${z(n.smallest)}`})}for(let n of s)r.set(n.path,{path:n.path,state:"left",reason:n.reason});return e.map(n=>r.get(n.path)??{path:n.path,state:"left",reason:o.cancelled?"stopped":"not run"})}import{watch as ge}from"node:fs";import{readdir as he,stat as te}from"node:fs/promises";import{join as be,resolve as k}from"node:path";function ne(e,t,o){let s=k(e),r=o.settleMs??1e3,n=o.pollMs??500,i=new Set([...t].map(u=>k(u))),l=new Map,c=new Map,f=!1,v=!1,x=!1,y=async()=>{if(!f){if(v){x=!0;return}v=!0;try{let u=await he(s,{withFileTypes:!0}).catch(()=>[]),d=new Set;for(let p of u){if(!p.isFile()||Q(p.name))continue;let g=be(s,p.name);if(d.add(g),i.has(g)||o.ignore?.(g))continue;let h=await te(g).catch(()=>{});if(!h||f)continue;let w=Date.now(),b=c.get(g);if(b){if(b.size===h.size&&b.mtimeMs===h.mtimeMs)continue;c.delete(g)}let m=l.get(g);if(!m||m.size!==h.size||m.mtimeMs!==h.mtimeMs){l.set(g,{size:h.size,mtimeMs:h.mtimeMs,since:w});continue}w-m.since<r||(l.delete(g),i.add(g),o.onFile(g))}for(let p of[...i,...l.keys(),...c.keys()])d.has(p)||(i.delete(p),l.delete(p),c.delete(p))}finally{v=!1,x&&!f&&(x=!1,y())}}},E=setInterval(()=>{y()},n),a;try{a=ge(s,{persistent:!1},()=>{y()}),a.on("error",()=>{})}catch{}return y(),{again(u){let d=k(u);f||!i.has(d)||te(d).then(p=>{f||!i.has(d)||(i.delete(d),c.set(d,{size:p.size,mtimeMs:p.mtimeMs}))}).catch(()=>{})},close(){f=!0,clearInterval(E),a?.close()}}}var I=e=>"op"in e&&(e.op==="convert"||e.op==="compress"||e.op==="edit")?e:{op:"convert",answers:e};function ve(e,t,o,s){let{jobs:r,left:n}=F(e,I(t),o,{destination:s});return{jobs:r,left:n}}async function Ge(e,t,o={}){return Z(e.sources,I(t),o)}var we=(e,t)=>e==="other"?t==="text"?"a text file":"not supported":"not yet supported";function Qe(e){let t=G(e.concurrency),o=I(e.answers),s=[],r=new Set,n=!1,i=e.holdMs??4e3,l=new Map,c=new Map,f=a=>{let u=c.get(a);u&&(clearTimeout(u.timer),c.delete(a),e.onEvent({type:"failed",path:a,error:u.error}))},v=(a,u)=>{E.again(a);let d=Math.max(0,(l.get(a)??0)+i-Date.now());c.set(a,{error:u,timer:setTimeout(()=>f(a),d)})},x=async a=>{let u=c.get(a);u?(clearTimeout(u.timer),c.delete(a)):e.onEvent({type:"arrived",path:a}),e.onEvent({type:"phase",path:a,phase:"reading"});let d=await Y(a);if(d.kind==="failed"){v(a,d.failure.error);return}if(d.kind!=="source"){e.onEvent({type:"left",path:a,reason:we(d.kind,d.sniffed)});return}let{jobs:p,left:g}=ve([d.source],o,e.claimed,e.destination),[h]=g;if(h){e.onEvent({type:"left",path:a,reason:h.reason});return}let w=await j(p,{force:!1,concurrency:1,...o.op==="compress"&&o.targetBytes!==void 0?{targetBytes:o.targetBytes}:{},onEvent:m=>{m.type==="job:phase"&&"phase"in m.progress&&m.progress.phase!=="page"&&m.progress.phase!=="time"&&m.progress.phase!=="tiles"&&e.onEvent({type:"phase",path:a,phase:m.progress.phase,job:m.job})}}),[b]=ee([d.source],{outcome:w,left:[],claimed:e.claimed,jobs:p});if(b?.result)e.onEvent({type:"converted",path:a,result:b.result});else if(b?.state==="left")e.onEvent({type:"left",path:a,reason:b.reason??""});else{let m=[...w.refusals,...w.failures][0];if(m){for(let B of p.flatMap(oe=>oe.outputs))ye(B)||e.claimed.delete(B);v(a,m.error)}}},y=()=>{for(;!n&&r.size<t&&s.length>0;){let a=s.shift(),u=x(a).catch(()=>{}).finally(()=>{r.delete(u),y()});r.add(u)}},E=ne(e.dir,e.known,{...e.settleMs===void 0?{}:{settleMs:e.settleMs},...e.pollMs===void 0?{}:{pollMs:e.pollMs},ignore:a=>e.claimed.has(a),onFile:a=>{l.set(a,Date.now()),s.push(a),y()}});return{async stop(){n=!0,E.close(),s.length=0,await Promise.all([...r]);for(let a of[...c.keys()])f(a)}}}export{F as a,ee as b,Ge as c,Qe as d};
@@ -1,3 +0,0 @@
1
- import { createRequire as __forgeCreateRequire } from 'node:module';
2
- const require = __forgeCreateRequire(import.meta.url);
3
- import{a as u}from"./chunk-FGR6QCG5.js";import{c as r}from"./chunk-VLVNA4T3.js";var s={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:!1,lossy:!0,hint:"smallest",defaultQuality:50},heic:{id:"heic",label:"HEIC",extensions:[".heic",".heif"],hasAlpha:!0,animatable:!1,lossy:!0,hint:"Apple photos"},raw:{id:"raw",label:"RAW",extensions:[".dng",".cr2",".cr3",".nef",".nrw",".arw",".srf",".sr2",".raf",".orf",".rw2",".rwl",".pef",".srw",".3fr",".fff",".erf",".dcr",".kdc",".mos"],hasAlpha:!1,animatable:!1,lossy:!1,hint:"camera 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}},P=Object.keys(s);function H(e){return s[e.toLowerCase()]}function R(e){let t=e.toLowerCase();return Object.values(s).filter(n=>n.extensions.includes(t))}function W(e){let t=s[e].extensions[0];if(!t)throw new Error(`format ${e} declares no extensions`);return t}var $=80;function M(e,t){return t??(e?s[e].defaultQuality:void 0)??$}import{dirname as F}from"node:path";var o=class extends Error{code;title;detail;short;hint;shellHint;constructor(t){super(t.detail===""?t.title:`${t.title}: ${t.detail}`,t.cause===void 0?void 0:{cause:t.cause}),this.name="ForgeError",this.code=t.code,this.title=t.title,this.detail=t.detail,this.short=t.short,this.hint=t.hint,this.shellHint=t.shellHint}};function y(e){return e instanceof o}function z(e){return new o({code:"file-not-found",title:"File not found",detail:`${r(e)} could not be found.`,short:`${r(e)} could not be found.`,hint:"Check the filename and try again."})}function V(e){return new o({code:"not-a-file",title:"Not a file",detail:`${r(e)} is not a file.`,short:`${r(e)} is not a file.`,hint:"Point Forge at an image, or at a directory of images."})}function q(e){return new o({code:"permission-denied",title:"Permission denied",detail:`${r(e)} could not be read.`,short:`${r(e)} could not be read.`,hint:"Check the file permissions and try again."})}function G(e){return new o({code:"not-a-directory",title:"Invalid path",detail:`${r(e)} could not be found: part of its path is not a directory.`,short:`part of ${r(e)}'s path is not a folder.`,hint:"Check the path and try again."})}function Q(e){return new o({code:"symlink-loop",title:"Too many symbolic links",detail:`${r(e)} could not be resolved: its path contains a symbolic-link loop.`,short:`${r(e)}'s path loops back on itself.`,hint:"Check for a circular symlink somewhere in the path."})}function _(e){return new o({code:"path-too-long",title:"Path too long",detail:`${r(e)}'s path is too long for the filesystem to resolve.`,short:`${r(e)}'s path is too long.`,hint:"Use a shorter path and try again."})}function B(e,t){return new o({code:"unreadable-path",title:"Could not read path",detail:`${r(e)} could not be checked.`,short:`${r(e)} could not be checked.`,hint:"Check the path and try again.",cause:t})}var v=new Set(["HEIC","HEVC","FLAC","RAW"]);function g(e){return`${(/^[A-Z0-9]+$/.test(e)&&!v.has(e)?/^[AEFILMNORSX8]/.test(e):/^[aeiou]/i.test(e))?"an":"a"} ${e}`}function E(e){return e.kind==="image"?"image":e.kind==="document"?"document":(e.facts?!e.facts.video:s[e.format].media==="sound")?"sound file":"video"}function Y(e,t){return new o({code:"unsupported-source",title:"Unsupported file type",detail:`${r(e)} is ${t}, which Forge cannot read.`,short:`${r(e)} is ${t}, which Forge cannot read.`})}function K(e,t){return new o({code:"unsupported-source",title:"Not an image",detail:`${r(e)} is ${t}, not an image.`,hint:"A palette is taken from a photo, a screenshot or artwork."})}function X(e){return new o({code:"unsupported-source",title:"Nothing to take colours from",detail:`${r(e)} has no visible pixels.`})}function Z(e){return new o({code:"unsupported-source",title:"No colours",detail:`There are no colours in ${e} that Forge can read.`,hint:"Write one a line, a name and a colour (bg #F8F1E6), or use a CSV with name and hex columns, CSS variables or design tokens."})}function ee(e,t){let n=t.slice(0,8).join("; "),i=t.length>8?`; and ${t.length-8} more`:"";return new o({code:"unsupported-source",title:"Not colours",detail:`${t.length===1?"One line":`${t.length} lines`} of ${e} could not be read as a colour: ${n}${i}.`,hint:"Write each as a name and a colour, such as bg #F8F1E6, or take the line out."})}function te(e,t=process.platform){if(t!=="darwin"){let n=t==="win32"?"Windows":t==="linux"?"Linux":"this system";return new o({code:"heic-decoder-unavailable",title:"Cannot read HEIC here",detail:`${r(e,t)} is a HEIC photo, which needs Forge's free HEIC extension on ${n}.`,short:"HEIC needs the heic extension.",hint:"Install it with: forge extensions add heic",shellHint:"Open /extensions to install it."})}return new o({code:"heic-decoder-unavailable",title:"Cannot read HEIC here",detail:`${r(e)} is a HEIC photo, which Forge decodes with the macOS sips tool.`,short:"HEIC needs sips, which could not be run.",hint:"sips could not be run. It ships with macOS at /usr/bin/sips."})}function ne(e,t=process.platform){if(t!=="darwin"){let n=t==="win32"?"Windows":t==="linux"?"Linux":"this system";return new o({code:"raw-decoder-unavailable",title:"Cannot read RAW here",detail:`${r(e,t)} is a camera RAW photo, which needs Forge's free RAW extension on ${n}.`,short:"RAW needs the raw extension.",hint:"Install it with: forge extensions add raw",shellHint:"Open /extensions to install it."})}return new o({code:"raw-decoder-unavailable",title:"Cannot read RAW here",detail:`${r(e,t)} is a camera RAW photo, which Forge reads with macOS's own RAW support.`,short:"RAW needs sips, which could not be run.",hint:"sips could not be run. It ships with macOS at /usr/bin/sips."})}function oe(e){return new o({code:"raw-decoder-unavailable",title:"Cannot read this RAW",detail:`${r(e)} is a camera RAW photo that this Mac cannot read.`,short:"macOS cannot read RAW photos from this camera.",hint:"A newer camera usually needs a newer macOS."})}function re(e,t){let n=r(e.path);if(t!==void 0&&t!==e.format){let i=s[t].label;return s[t].lossy?new o({code:"unsupported-compress",title:"Cannot fit that to a size",detail:`Forge cannot search ${n} \u2192 ${i} toward a size yet.`,hint:"Convert it first, then compress the result with --max-size.",shellHint:"Convert it first, then /compress the result to a size."}):new o({code:"unsupported-compress",title:"Cannot fit that to a size",detail:`${i} is lossless \u2014 there is no quality to trade away, so ${n} cannot be made to fit as ${i}.`,hint:"Drop --max-size, or choose a lossy target. forge --formats lists them.",shellHint:"Choose a lossy target to aim for a size."})}if(e.kind==="document"&&e.format==="pdf"){let i=e.images?.skipped??0;return new o({code:"unsupported-compress",title:"Nothing to compress",detail:i>0?`${n}'s images are a kind Forge cannot re-encode, so there is nothing to make smaller.`:`${n} has no images \u2014 it is text and layout, which compression cannot shrink.`,hint:"Try a page operation such as --extract to keep fewer pages, or --to <format> to turn its pages into images.",shellHint:"Try /pdf to keep fewer pages, or /convert to turn its pages into images."})}return e.kind==="document"?new o({code:"unsupported-compress",title:"Nothing to compress",detail:`${n} is ${s[e.format].label}, which has no images Forge can re-encode.`,hint:`Use --to pdf to change it to PDF instead: forge ${n} --to pdf`,shellHint:"Use /convert to change it to PDF instead."}):new o({code:"unsupported-compress",title:"Nothing to compress",detail:`${n} is ${s[e.format].label}, which is lossless \u2014 there is no quality to trade away.`,hint:"Use --to to change it to a smaller format instead. forge --formats lists them.",shellHint:"Use /convert to change it to a smaller format instead."})}function ie(e){let t=r(e.path);return new o({code:"unsupported-pdf",title:"/pdf needs a PDF",detail:`${t} is ${s[e.format].label}, not a PDF.`,hint:"Converting it instead."})}function ae(e,t,n){return new o({code:"unsupported-operation",title:`Cannot ${e} these files`,detail:`Not available for these files: ${t}.`,hint:n??"Page operations work on PDFs: --merge takes two or more, the others take one.",shellHint:n??"Use /pdf with a PDF staged \u2014 two or more for merge."})}function se(e,t,n){let i=e.kind==="media"?`The smallest ${r(e.path)} can get is ${u(n)}, which is still over ${u(t)}.`:`${r(e.path)} is ${u(n)} even at the lowest quality, which is still over ${u(t)}.`;return new o({code:"target-unreachable",title:"Cannot get that small",detail:i,hint:"Try a larger --max-size, or --to a smaller format.",shellHint:"Try a larger target, or /convert to a smaller format."})}function le(e,t,n){return new o({code:"unsupported-target",title:`Cannot convert ${r(e.path)} to ${t}`,detail:`${r(e.path)} is ${g(s[e.format].label)} ${E(e)}.`,hint:`Available: ${n.join(", ")}`})}function k(e,t){return new o({code:"corrupt-source",title:"Damaged file",detail:`${r(e)} could not be read. It may be damaged, or not a format Forge recognises.`,short:`${r(e)} could not be read.`,hint:"The file may be incomplete or corrupted.",cause:t})}function C(e,t,n){return new o({code:"corrupt-source",title:`Damaged ${s[t].label}`,detail:`${r(e)} is ${g(s[t].label)} file, but its content could not be read.`,short:`${r(e)} could not be read.`,hint:"The file may be incomplete or corrupted.",cause:n})}function de(e,t={}){let n=r(e);return new o({code:"encrypted-source",title:"This PDF is password-protected",detail:`${n} is password-protected.`,short:`${n} is password-protected.`,hint:t.attempted?"That password didn't open it. Check it and try again.":`Convert it to images instead: forge ${n} --to jpeg --password-stdin`})}var c=e=>e==="convert"||e==="boost"||e==="remove-background";function ue(e,t="convert"){return new o({code:"output-exists",title:"File already exists",detail:`${r(e)} is already there.`,hint:c(t)?"Pass --force to replace it, or choose a different --output.":"Pass --force to replace it, or move the existing file out of the way.",shellHint:"Run it again and Forge will ask before replacing it."})}function ce(e,t){return new o({code:"output-collision",title:"Two files want the same output",detail:`${r(e[0])} and ${r(e[1])} would both become ${r(t)}.`,hint:"Convert them separately, or use --output to send them to different folders.",shellHint:"Convert them one at a time."})}function pe(e,t){return new o({code:"output-collision",title:"One output, written twice",detail:`${r(e)} would write ${r(t)} twice, and only the second would survive.`,hint:"Every output has to be its own file. Check the selection for a repeated page."})}function he(e,t="convert"){return new o({code:"output-is-input",title:"Output would replace the original",detail:`${r(e)} is both the input and the output.`,hint:c(t)?"Choose a different --output, or pass --force to overwrite in place.":"Move or rename that file first, or pass --force to overwrite it in place.",shellHint:c(t)?"Choose a different folder to save it in.":"Move or rename that file first."})}function f(e,t){return new o({code:"permission-denied",title:"Permission denied",detail:`${r(F(e))} is not a folder you can write to.`,hint:"Choose a different --output, or check the folder permissions.",shellHint:"Choose a different folder, or check its permissions.",cause:t})}var h=new Set(["EACCES","EPERM","EROFS"]);function ge(e,t){if(y(t))return t;let n=t?.code;return n!==void 0&&h.has(n)?f(e,t):n==="ENOSPC"||n==="EDQUOT"?m(e,t,e):n==="ENAMETOOLONG"?w(e,t):t}function S(e,t){return new o({code:"output-invalid",title:"Cannot write there",detail:`${e} could not be written to.`,hint:"Check that the path is valid and that you have permission to write to it.",cause:t})}function fe(e){return new o({code:"empty-directory",title:"No images found",detail:`${r(e)} contains no images Forge can convert.`,hint:"Try --recursive to look inside subfolders.",shellHint:"Only files directly inside a folder are read \u2014 drop the files themselves, or the folder that holds them."})}function me(e,t){return new o({code:"invalid-cut",title:"Cut past the end",detail:`The cut keeps nothing of ${r(e)}: it starts at or after its end.`,hint:`It is ${t} long.`})}function we(e){return new o({code:"unsupported-operation",title:"Cannot use --to here",detail:"--to is for video and sound: a picture or PDF gives its text as it is.",hint:`Try: forge transcribe ${e}`})}function be(e,t){let n=t?.code;return new o({code:n!==void 0&&h.has(n)?"permission-denied":"output-invalid",title:"Settings not saved",detail:`${e} is not a folder Forge can write to.`,cause:t})}function A(e,t){return new o({code:"invalid-arguments",title:"Invalid arguments",detail:e,hint:t})}function xe(e){return new o({code:"invalid-arguments",title:"No files given",detail:"",hint:e})}function $e(e,t="--background"){return A(`${t} takes a colour, not '${e}'.`,"Try a hex code (#ffffff), rgb(), hsl(), oklch() or a colour name.")}function Fe(e,t,n){let i=Math.max(n-1,0);return new o({code:"invalid-page-range",title:"Page range not understood",detail:`'${e}' is outside 1 and ${i}.`,hint:`${t} has ${n} pages, so it can be cut after page 1 to ${i}.`})}function ye(e,t,n){return new o({code:"invalid-page-range",title:"Page range not understood",detail:t,hint:`This document has ${n} pages. Use numbers and spans, like '3-7, 12, 20-'.`})}function ve(e){return new o({code:"empty-selection",title:"Nothing to write",detail:e,hint:"Select at least one page to keep."})}function Ee(e,t,n){return new o({code:"invalid-arguments",title:"Nothing to split",detail:`${r(e)} has ${t} pages; splitting every ${n} makes only one file.`,hint:`Use every=N with N below ${t}.`})}function ke(e){return new o({code:"invalid-dpi",title:"Invalid resolution",detail:`${String(e)} is not a resolution Forge can use.`,hint:"Give a number between 36 and 600. The default is 150."})}function Ce(e){return new o({code:"extension-missing",title:"Extension not installed",detail:`${e} is an optional extension and is not installed.`,hint:`Install it with: forge extensions add ${e}`,shellHint:"Open /extensions to install it."})}function Se(e,t,n,i){return new o({code:"extension-outdated",title:"Extension out of date",detail:`${e} ${n} cannot ${t}; that needs ${i} or later.`,hint:`Update it with: forge extensions add ${e}`,shellHint:"Open /extensions to update it."})}function Ae(e,t){return new o({code:"extension-corrupt",title:"Extension failed verification",detail:`${e}: ${t}`,hint:`Nothing was installed. Try again with: forge extensions add ${e}`,shellHint:"Nothing was installed. Try again from /extensions."})}function Ne(e,t,n=process.platform){let i=n==="win32"?"PC":n==="darwin"?"Mac":"computer";return new o({code:"extension-unsupported",title:"Extension not available here",detail:`${e} cannot be installed on this ${i}: ${t}`,hint:"See what is available with: forge extensions",shellHint:"See what is available in /extensions."})}function Te(e,t=process.platform){let n=t==="win32"?"Windows":t==="darwin"?"macOS":t==="linux"?"Linux":"this system";return new o({code:"extension-unsupported",title:"Extension not available here",detail:`${e} is not available on ${n}.`,hint:"See what is available with: forge extensions",shellHint:"See what is available in /extensions."})}function Ie(e){return new o({code:"update-unavailable",title:"Cannot update this Forge",detail:`This copy of Forge was not installed with npm i -g, so ${e} cannot be installed over it.`,hint:"npm i -g forge-terminal"})}function Oe(e,t=process.platform){return t==="win32"?new o({code:"update-denied",title:"Forge is in use",detail:`npm could not replace Forge's files to update it to ${e}. Windows keeps them locked while Forge runs: close every Forge window, then run the command below. If Node is installed for every user, run it in a terminal opened as administrator.`,short:"Windows locks Forge while it runs: close it, then run this",hint:`npm i -g forge-terminal@${e}`}):new o({code:"update-denied",title:"npm needs permission",detail:`npm needs permission to update Forge to ${e}.`,short:"npm needs permission to update Forge",hint:`sudo npm i -g forge-terminal@${e}`})}function Pe(e,t){return new o({code:"update-failed",title:"Update failed",detail:`npm could not install Forge ${e}: ${t}`,short:"npm could not install the update",hint:`npm i -g forge-terminal@${e}`})}function He(){return new o({code:"update-unreachable",title:"Could not check for updates",detail:"The npm registry could not be reached.",short:"could not reach npm",hint:"Check your connection, then run: forge update",shellHint:"Check your connection, then try again."})}function Re(e,t){return new o({code:"extension-download-failed",title:"Download failed",detail:`${e}: ${t}`,hint:`Check your connection, then run: forge extensions add ${e}`,shellHint:"Check your connection, then try again from /extensions."})}function We(e,t){return new o({code:"extension-download-failed",title:"Not enough disk space",detail:`${e}: ${t}`,hint:`Free some disk space, then run: forge extensions add ${e}`,shellHint:"Free some disk space, then try again from /extensions."})}function Me(e,t,n){let i=t?t.what?`${t.what} (forge, pid ${t.pid})`:`another forge (pid ${t.pid}) is using it`:"another forge is using it";return new o({code:"extension-in-use",title:"Extension in use",detail:`${e} is in use: ${i}.`,hint:n==="remove"?`Wait for that job to finish, then run: forge extensions remove ${e}`:"Wait for that job to finish, then try again.",shellHint:n==="remove"?"It can be removed when that job finishes.":"Try again when that job finishes."})}function De(e){return new o({code:"no-subject",title:"No subject found",detail:`${r(e)} has no clear subject to cut out.`,hint:"Try a photo where the subject stands apart from the background."})}function Ue(e,t,n){return n===1?new o({code:"boost-too-large",title:"Too large to sharpen",detail:`${r(e)} is too large to sharpen.`,hint:"Sharpen works on images up to 16,384 px a side and 100 megapixels."}):new o({code:"boost-too-large",title:"Too large to boost",detail:t>=2?`${r(e)} is too large to boost that far; ${t}x is the most it can take.`:`${r(e)} is already too large to boost.`,hint:t>=2?`Try --boost ${t}.`:"Boost works on images up to 100 megapixels.",shellHint:t>=2?`Choose ${t}x instead.`:void 0})}function je(e,t,n,i=process.platform){let a=n===1?"sharpen":"boost",l=i==="win32"?"PC":i==="darwin"?"Mac":"computer",d=Math.max(1,Math.round(t/60));return new o({code:"boost-too-slow",title:`Too slow to ${a}`,detail:`${r(e)} would take about ${d} ${d===1?"minute":"minutes"} to ${a} on this ${l}.`,hint:"Try a smaller photo."})}function Je(e,t){return new o({code:"resize-too-large",title:"Too large to resize to",detail:`${r(e)} would be ${t.width} \xD7 ${t.height}.`,hint:"Resize works up to 16,384 px a side and 100 megapixels."})}var N={darwin:"\u2303\u21E7\u23184",win32:"Win+Shift+S"};function Le(e,t=process.platform){let n=N[t];return new o({code:"no-clipboard-image",title:"No image",detail:e==="text"?"The clipboard holds text, not a picture.":"The clipboard is empty.",hint:n===void 0?"Copy a picture or a screenshot, then run forge clip again.":`Copy a picture, or take a screenshot with ${n}, then run forge clip again.`})}function ze(e=process.platform){return new o({code:"clipboard-unavailable",title:"No clipboard",detail:e==="linux"?"Forge reads the clipboard of a Wayland or X11 desktop, and not over SSH.":"Forge reads the clipboard on macOS, Windows and Linux, and not over SSH."})}function Ve(e){return new o({code:"clipboard-tool-missing",title:`Clipboard needs ${e}`,detail:`Forge reaches the clipboard through ${e}, and it is not on this computer.`,short:`${e} is not on this computer`,hint:`Install it with sudo apt install ${e} (or your distribution's package manager), then try again.`})}function qe(){return new o({code:"nothing-to-undo",title:"Nothing to undo",detail:"No copied image has been changed yet."})}function Ge(e,t,n,i=!1){let a=r(e);if(i)return new o({code:"cannot-compress-more",title:"Cannot compress more",detail:`${a} is no smaller even at the lowest quality, so nothing was written.`,short:"nothing written"});let l=n>t?`would grow from ${u(t)} to ${u(n)}`:`would stay at ${u(t)}`;return new o({code:"cannot-compress-more",title:"Cannot compress more",detail:`${a} ${l}, so nothing was written.`,short:"nothing written",hint:"Try a lower --quality.",shellHint:"Try a lower quality."})}function Qe(e,t,n){return new o({code:"cannot-compress-more",title:"Already small enough",detail:`${r(e)} is ${u(t)}, already under ${u(n)}, so nothing was written.`,short:"already under that size"})}function _e(e){return new o({code:"nothing-to-trim",title:"Nothing to trim",detail:`${r(e)} has no empty edges.`,short:"no empty edges"})}function Be(e){return new o({code:"animated-trim",title:"Cannot trim an animation",detail:`${r(e)} is animated; trimming works on still images.`})}function Ye(e,t){return new o({code:"nothing-to-crop",title:"Nothing to crop",detail:`${r(e)} is already ${t}.`,short:`already ${t}`})}function Ke(e){return new o({code:"animated-crop",title:"Cannot crop an animation",detail:`${r(e)} is animated; cropping works on still images.`})}function Xe(e){return new o({code:"animated-rotate",title:"Cannot rotate an animation",detail:`${r(e)} is animated; rotating works on still images.`})}function Ze(e,t=process.platform,n=!1){let i=p(t),a=n?`forge extensions add video (or ${i})`:t==="linux"?`${i} (or your distribution's package manager)`:i;return new o({code:"ffmpeg-missing",title:"Video and audio need ffmpeg",detail:`${r(e)} is a video or audio file, and ffmpeg is not on this computer.`,short:"ffmpeg is not on this computer",hint:`Install it with ${a}, then run Forge again.`})}function et(e,t,n=process.platform){let i=s[e].label,a=/^[AEFHILMNORSX]/.test(t.codec)?"an":"a",l=t.encoders,d=l.length>1?`${l.slice(0,-1).join(", ")} or ${l.at(-1)}`:l[0]??"",b=l.length>1?"any of them":"it",x=n==="linux"?"Install a full build of ffmpeg, then run Forge again. On Fedora, RPM Fusion's ffmpeg replaces ffmpeg-free.":n==="win32"?`Install a full build of ffmpeg, such as gyan.dev's (${p(n)}), then run Forge again.`:`Install a full build of ffmpeg (${p(n)}), then run Forge again.`;return new o({code:"encoder-missing",title:`Your ffmpeg cannot write ${i}`,detail:`${i} needs ${a} ${t.codec} encoder${t.sound?" for its sound":""}: ${d}. Your ffmpeg was built without ${b}.`,short:`Your ffmpeg has no ${t.codec} encoder`,hint:x})}function p(e=process.platform){return e==="win32"?"winget install ffmpeg":e==="linux"?"sudo apt install ffmpeg":"brew install ffmpeg"}function tt(e,t,n){return O(e,t,n)??T(e,t)}function T(e,t){return new o({code:"conversion-failed",title:"Conversion failed",detail:`${r(e)} could not be converted.`,hint:"Run again with --debug for the underlying error.",shellHint:"Run the same conversion with forge --debug from the command line to see why.",cause:t})}var I=/premature end|truncated|unexpected end of|libpng read error|corrupt/i;function O(e,t,n){let i=t?.code,a=t instanceof Error?t.message:typeof t=="string"?t:"",l=t?.path,d=typeof l=="string"?l:void 0;if(i==="ENOSPC"||i==="EDQUOT"||/no space left on device|quota exceeded/i.test(a))return m(e,t,d);if(i==="ENAMETOOLONG"||/file name too long/i.test(a))return w(d??e,t,d===void 0);if(d!==void 0&&i!==void 0&&h.has(i))return f(d,t);if(d!==void 0&&i==="ENOTDIR")return S(d,t);if(I.test(a))return n?C(e,n,t):k(e,t)}function m(e,t,n){return new o({code:"disk-full",title:"Disk full",detail:n!==void 0?`There is no space left to write ${r(n)}.`:`${r(e)} could not be converted: no disk space left.`,short:"The disk is full.",hint:"Free up disk space, or choose a different --output.",shellHint:"Free up disk space, or choose a different folder.",cause:t})}function w(e,t,n=!1){let i=n?`${r(e)} could not be converted: the name to write it under is too long.`:`${r(e)} is too long to write.`;return new o({code:"path-too-long",title:"Name too long",detail:i,short:n?"The name to write is too long.":`${r(e)} is too long to write.`,hint:"Choose a shorter name with --output.",shellHint:"Choose a shorter name.",cause:t})}function nt(e){return new o({code:"no-sound",title:"Nothing to transcribe",detail:`${r(e)} has no sound.`})}function ot(e){return new o({code:"no-sound",title:"No sound",detail:`${r(e)} has no sound.`,short:"no sound"})}function rt(e){return new o({code:"source-changed",title:"File changed",detail:`${r(e)} changed while converting, so nothing was written.`,short:"changed while converting"})}function it(e,t=process.platform,n=t==="darwin"?"apple":"whisper"){return n==="whisper"?new o({code:"unsupported-source",title:"Cannot transcribe this file",detail:`${r(e,t)} cannot be read by whisper.`,hint:"Video and sound files can be transcribed."}):new o({code:"unsupported-source",title:"Cannot transcribe this file",detail:`${r(e)} cannot be read by Apple's speech recogniser.`,hint:"MP4, MOV, M4A, MP3, WAV and AIFF can be transcribed; with ffmpeg (brew install ffmpeg), any video or sound file."})}function at(e,t=process.platform,n=t==="darwin"?"apple":"whisper"){let i=n==="apple"?"Apple's speech recogniser":"The whisper extension";return new o({code:"language-unsupported",title:"Language not supported",detail:`${i} does not support ${e}.`,hint:"Pass another with --language, for example --language en-US."})}function st(e,t,n={}){return new o({code:"link-unavailable",title:"Cannot transcribe this link",detail:e,...n,...t===void 0?{}:{cause:t}})}function lt(e){return new o({code:"transcribe-unavailable",title:"Transcribe is not available",detail:e})}function dt(e=!1){return e?new o({code:"read-unavailable",title:"Reading text is not available",detail:"Reading text needs Forge's free read-text extension.",short:"Needs the read-text extension.",hint:"Install it with: forge extensions add read-text",shellHint:"Open /extensions to install it."}):new o({code:"read-unavailable",title:"Reading text is not available",detail:"Reading text needs macOS 26 or later.",short:"Reading text needs macOS 26 or later."})}function ut(e){let t=r(e);return new o({code:"no-text",title:"No text found",detail:`No text found in ${t}.`,short:`No text found in ${t}.`})}function ct(e){let t=r(e);return new o({code:"no-speech",title:"No speech found",detail:`No speech found in ${t}.`,short:`No speech found in ${t}.`})}function pt(e){return new o({code:"unexpected",title:"Something went wrong",detail:e instanceof Error?e.message:String(e),hint:"This was not expected. Try again \u2014 if it keeps happening, it may be worth reporting.",cause:e})}function ht(e,t={}){let n=[`\u2715 ${e.title}`];e.detail!==""&&n.push("",` ${e.detail}`);let i=e.cause instanceof Error?e.cause.stack??e.cause.message:typeof e.cause=="string"?e.cause:void 0,a=t.debug===!0&&i!==void 0;return e.hint&&!(a&&e.hint.includes("--debug"))&&n.push("",` ${e.hint}`),a&&n.push("",` ${i}`),n}export{s as a,H as b,R as c,W as d,M as e,y as f,z as g,V as h,q as i,G as j,Q as k,_ as l,B as m,g as n,Y as o,K as p,X as q,Z as r,ee as s,te as t,ne as u,oe as v,re as w,ie as x,ae as y,se as z,le as A,k as B,C,de as D,ue as E,ce as F,pe as G,he as H,f as I,ge as J,S as K,fe as L,me as M,we as N,be as O,A as P,xe as Q,$e as R,Fe as S,ye as T,ve as U,Ee as V,ke as W,Ce as X,Se as Y,Ae as Z,Ne as _,Te as $,Ie as aa,Oe as ba,Pe as ca,He as da,Re as ea,We as fa,Me as ga,De as ha,Ue as ia,je as ja,Je as ka,Le as la,ze as ma,Ve as na,qe as oa,Ge as pa,Qe as qa,_e as ra,Be as sa,Ye as ta,Ke as ua,Xe as va,Ze as wa,et as xa,p as ya,tt as za,nt as Aa,ot as Ba,rt as Ca,it as Da,at as Ea,st as Fa,lt as Ga,dt as Ha,ut as Ia,ct as Ja,pt as Ka,ht as La};
@@ -1,3 +0,0 @@
1
- import { createRequire as __forgeCreateRequire } from 'node:module';
2
- const require = __forgeCreateRequire(import.meta.url);
3
- function f(n){let t=n.trim().split(":");if(t.length===0||t.length>3)return;let e=0;for(let[o,i]of t.entries()){if(!(o===t.length-1?/^\d+(\.\d+)?$/:/^\d+$/).test(i))return;let u=Number(i);if(o>0&&u>=60)return;e=e*60+u}return e}function R(n){let t=n.indexOf("-");if(t<0)return;let e=f(n.slice(0,t)),o=n.slice(t+1).trim(),i=o===""?void 0:f(o);if(!(e===void 0||o!==""&&i===void 0)&&!(i!==void 0&&i<=e))return{start:e,end:i}}var s=n=>String(n).padStart(2,"0");function A(n){let t=Math.round(n*10),e=t%600/10,o=Math.floor(t/600)%60,i=Math.floor(t/36e3),d=e.toFixed(1).padStart(4,"0");return i>0?`${i}:${s(o)}:${d}`:`${o}:${d}`}function _(n){let t=Math.round(n),e=t%60,o=Math.floor(t/60)%60,i=Math.floor(t/3600);return i>0?`${i}:${s(o)}:${s(e)}`:`${o}:${s(e)}`}var S=[1,5,10,30,60,300,600,1800];function K(n){return S.filter((t,e)=>e===0||t<=n/4)}function P(n){return n<60?`${n} s`:`${n/60} min`}var w=[1920,1280,854],O=[30,24],E=15,M=64,$=32,x=32,r=n=>Math.max(2,Math.round(n/2)*2);function a(n,t){let e=n.width>=n.height,o=e?n.width:n.height;if(t>=o)return{width:r(n.width-1),height:r(n.height-1)};let i=t/o;return e?{width:r(t),height:r(n.height*i)}:{width:r(n.width*i),height:r(t)}}function c(n){let t=Math.max(n.width,n.height),e=[t,...w.filter(u=>u<t)],o=n.hasAudio?M:0,i=[];for(let u of e){let{width:p,height:l}=a(n,u),g=[...new Set([n.fps,...O].filter(h=>h<=n.fps))];for(let h of g)i.push({width:p,height:l,fps:h,audioKbps:o})}let d=a(n,e[e.length-1]??t);return i.push({...d,fps:Math.min(E,n.fps),audioKbps:n.hasAudio?x:0}),i}var m=n=>n.width*n.height*n.fps*.02/1e3;function b(n){let t=c(n),e=t[t.length-1];return e?Math.ceil((m(e)+e.audioKbps)*1e3/8/.98*n.duration):0}function v(n){let t=n.targetBytes*8/n.duration/1e3*.98;for(let e of c(n)){let o=t-e.audioKbps;if(o>=m(e))return{...e,videoKbps:Math.floor(o)}}return{floor:b(n)}}function z(n,t={}){let e=n.audio!==void 0&&t.mute!==!0;return n.video&&!t.soundOnly?b({duration:n.duration,width:n.video.width,height:n.video.height,fps:n.video.fps,hasAudio:e}):Math.ceil($*1e3/8/.98*n.duration)}export{f as a,R as b,A as c,_ as d,K as e,P as f,v as g,z as h};
@@ -1,3 +0,0 @@
1
- import { createRequire as __forgeCreateRequire } from 'node:module';
2
- const require = __forgeCreateRequire(import.meta.url);
3
- import{b as A,c as y,g as o,m as x,n as v,t as O,u as P,v as k}from"./chunk-UI4EUC3S.js";import{a as S,b as m,d as I}from"./chunk-NMGQGYVM.js";import{g as c,h as g,j as b,k as h,l,m as a}from"./chunk-UN5DSJE2.js";import{P as d}from"./chunk-CCNRNCRU.js";var f=e=>e.filter(t=>t.kind==="document"&&t.format==="pdf"),D={id:"merge",label:"Merge",verb:"Merging",hint:"several files into one",appliesTo:e=>f(e).length>=2&&f(e).length===e.length,unavailable:e=>f(e).length!==e.length?"PDFs only":"needs 2+ files",options:()=>[],plan(e,t){let n=a(h(e.map(r=>r.path)),o(t.destination),o(t.name));return[{op:"merge",sources:e,outputs:[n]}]}},z=e=>e.length>=2&&e.every(t=>t.kind==="image"||t.kind==="document"&&t.format==="pdf");function i(e){return e.filter(n=>n.kind==="document"&&n.format==="pdf").length===0?"PDFs only":"one PDF at a time"}var u=e=>e.length===1&&e[0]?.kind==="document"&&e[0].format==="pdf"?e[0]:void 0,T={id:"split",label:"Split",verb:"Splitting",hint:"into several files",appliesTo:e=>(u(e)?.pages??0)>1,unavailable:e=>u(e)===void 0?i(e):"only one page",options(e){let t=u(e);return t?[{kind:"select",id:"mode",label:"How",default:"every-page",choices:[{value:"every-page",label:"Every page",hint:`${t.pages} files`},{value:"every-n",label:"Every N pages",hint:"ask how many"},{value:"points",label:"At points I choose",hint:"grid"}]}]:[]},plan(e,t){let n=u(e);if(!n)return[];let r=Array.isArray(t.cuts)?t.cuts:[],p=I(r,n.pages).length,q=l(g(n.path,p),o(t.destination),o(t.name));return[{op:"split",sources:[n],outputs:q,cuts:r}]}};function Q(e){return Array.from({length:Math.max(0,e-1)},(t,n)=>n)}function U(e,t){if(!Number.isInteger(t)||t<1)throw d("Splitting every N pages needs N to be a whole number, at least 1.");let n=[];for(let r=t;r<e;r+=t)n.push(r-1);return n}var s=e=>e.length===1&&e[0]?.kind==="document"&&e[0].format==="pdf"?e[0]:void 0;function w(e,t){return Array.isArray(t.pages)?m(t.pages):typeof t.pages=="string"?m(S(t.pages,e.pages)):[]}var R=e=>({kind:"text",id:"pages",label:"Pages",placeholder:`1-${e.pages}`}),j={id:"extract",label:"Extract",verb:"Extracting",hint:"keep only some pages",appliesTo:e=>s(e)!==void 0,unavailable:i,options:e=>{let t=s(e);return t?[R(t),{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(e,t){let n=s(e);if(!n)return[];let r=w(n,t),p=t.separate==="many";return[{op:"extract",sources:[n],outputs:l(b(n.path,r,p),o(t.destination),o(t.name)),pages:r,separate:p}]}},J={id:"delete",label:"Delete",verb:"Deleting",hint:"drop some pages",appliesTo:e=>s(e)!==void 0,unavailable:i,options:e=>{let t=s(e);return t?[R(t)]:[]},plan(e,t){let n=s(e);return n?[{op:"delete",sources:[n],outputs:[a(c(n.path,"trimmed"),o(t.destination),o(t.name))],pages:w(n,t)}]:[]}};var N=e=>e.length===1&&e[0]?.kind==="document"&&e[0].format==="pdf"?e[0]:void 0,E={id:"rotate",label:"Rotate",verb:"Rotating",hint:"turn pages",appliesTo:e=>N(e)!==void 0,unavailable:i,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(e,t){let n=N(e);if(!n)return[];let p=Number(t.degrees??90)/90%4||1;return[{op:"rotate",sources:[n],outputs:[a(c(n.path,"rotated"),o(t.destination),o(t.name))],turns:p}]}};var C=[v,x,D,T,j,J,E,O,P,k],de=C.filter(e=>!["convert","compress","trim","resize","crop"].includes(e.id)),F=[A,y];function ge(e,t=new Set){return[...C,...F.filter(n=>n.requires&&t.has(n.requires))].filter(n=>n.appliesTo(e))}function be(e,t){return e.appliesTo(t)?void 0:e.unavailable?.(t)}export{D as a,z as b,E as c,T as d,Q as e,U as f,C as g,de as h,ge as i,be as j};