forge-terminal 0.5.2 → 0.5.3

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 (62) hide show
  1. package/README.md +3 -3
  2. package/dist/chunks/{about-credits-VZQJAWG3.js → about-credits-DBQHH5HA.js} +1 -1
  3. package/dist/chunks/{args-FZXEZBPA.js → args-TZMA4ZR6.js} +1 -1
  4. package/dist/chunks/{boot-NYKO3NLR.js → boot-E57BKWEC.js} +1 -1
  5. package/dist/chunks/{chunk-TARDT6LZ.js → chunk-3CLPUPJT.js} +1 -1
  6. package/dist/chunks/chunk-3GHHQNR6.js +3 -0
  7. package/dist/chunks/{chunk-KMLT45OJ.js → chunk-4YFFT5CZ.js} +2 -2
  8. package/dist/chunks/{chunk-XPATZLEH.js → chunk-5IZBFF6Y.js} +1 -1
  9. package/dist/chunks/{chunk-63ZZRDSV.js → chunk-5YUOG3A5.js} +1 -1
  10. package/dist/chunks/{chunk-GT6U6HV3.js → chunk-6LMVOQQA.js} +1 -1
  11. package/dist/chunks/chunk-6RMRWBMB.js +3 -0
  12. package/dist/chunks/{chunk-R24JCIZ5.js → chunk-7VR6LODN.js} +1 -1
  13. package/dist/chunks/{chunk-RK3WGALB.js → chunk-AFEYLHDD.js} +1 -1
  14. package/dist/chunks/{chunk-ZFLFBNIK.js → chunk-AIINYKXW.js} +1 -1
  15. package/dist/chunks/{chunk-LA5JVBFP.js → chunk-E2BYNETT.js} +1 -1
  16. package/dist/chunks/{chunk-DYIATUFE.js → chunk-EPDF4NQI.js} +1 -1
  17. package/dist/chunks/{chunk-W2QJA73Q.js → chunk-EURVTBPH.js} +1 -1
  18. package/dist/chunks/{chunk-IVBSXPNS.js → chunk-FLMQ5VFR.js} +1 -1
  19. package/dist/chunks/{chunk-K6ERQTUQ.js → chunk-IE6NFN3N.js} +1 -1
  20. package/dist/chunks/{chunk-IED6VBE6.js → chunk-IJRLRAC5.js} +1 -1
  21. package/dist/chunks/{chunk-XUKYIVJC.js → chunk-IKZTH2RL.js} +1 -1
  22. package/dist/chunks/{chunk-J2UQI544.js → chunk-ITJZ7ODJ.js} +2 -2
  23. package/dist/chunks/chunk-MNI6IKIU.js +3 -0
  24. package/dist/chunks/{chunk-CW2Y2KDQ.js → chunk-N3X3H4IZ.js} +1 -1
  25. package/dist/chunks/{chunk-RXI6QLNY.js → chunk-NHMACTW3.js} +1 -1
  26. package/dist/chunks/{chunk-ITW5FG4K.js → chunk-QPJ2LNXB.js} +1 -1
  27. package/dist/chunks/{chunk-JGJU3AW5.js → chunk-TDYKRRZH.js} +1 -1
  28. package/dist/chunks/chunk-TFOEI5VF.js +3 -0
  29. package/dist/chunks/{chunk-2AFHW44W.js → chunk-Z2H2GT2X.js} +2 -2
  30. package/dist/chunks/{chunk-GRWOJKQB.js → chunk-ZYIW4MAG.js} +1 -1
  31. package/dist/chunks/clip-command-QPLYCGJ2.js +3 -0
  32. package/dist/chunks/{colour-LMZO2EE6.js → colour-PZOAKNTH.js} +1 -1
  33. package/dist/chunks/{entry-TV4FJQDR.js → entry-REXB6JNP.js} +2 -2
  34. package/dist/chunks/execute-GKO4THUK.js +3 -0
  35. package/dist/chunks/{extensions-4UJRQ32J.js → extensions-UV4X2UUA.js} +1 -1
  36. package/dist/chunks/{extensions-command-VROVGVD4.js → extensions-command-TLW53BUK.js} +1 -1
  37. package/dist/chunks/{ffmpeg-OIVMTPY7.js → ffmpeg-32EEMAZS.js} +1 -1
  38. package/dist/chunks/{image-J5WDYORX.js → image-YMCS4PTS.js} +1 -1
  39. package/dist/chunks/{install-5XLVERRR.js → install-7ZRVQKCF.js} +1 -1
  40. package/dist/chunks/launch-IVBMNYNY.js +17 -0
  41. package/dist/chunks/{manager-T3WDLUKR.js → manager-XPO4ZIRY.js} +1 -1
  42. package/dist/chunks/{needed-YU5BPYD6.js → needed-NOGBHTHE.js} +1 -1
  43. package/dist/chunks/{notify-LTV7F634.js → notify-YEBP67MP.js} +1 -1
  44. package/dist/chunks/{own-OJAQ5FRQ.js → own-G4G4MRGM.js} +1 -1
  45. package/dist/chunks/{pdfium-7HNCQ3K3.js → pdfium-BAMNBCNW.js} +1 -1
  46. package/dist/chunks/{preset-command-VP5RAXBG.js → preset-command-XXKLUJOS.js} +1 -1
  47. package/dist/chunks/{registry-E5PNQWOZ.js → registry-PKOPEG3Z.js} +1 -1
  48. package/dist/chunks/{server-EFNTD7ZW.js → server-AR73FWWG.js} +3 -3
  49. package/dist/chunks/{theme-NF3LQHPV.js → theme-D4AMWFFW.js} +1 -1
  50. package/dist/chunks/{transcribe-CQFHXBTV.js → transcribe-EFVJPBPG.js} +1 -1
  51. package/dist/chunks/{transcribe-command-ZXB3JJFZ.js → transcribe-command-Q4J3WTOB.js} +1 -1
  52. package/dist/chunks/{update-note-CJ5XYKYH.js → update-note-2YR3TLPK.js} +1 -1
  53. package/dist/chunks/{watch-command-ZNMO4SF7.js → watch-command-2D7NLDAM.js} +1 -1
  54. package/dist/index.js +6 -6
  55. package/package.json +7 -11
  56. package/dist/chunks/chunk-M6LYLTFH.js +0 -3
  57. package/dist/chunks/chunk-SNFUGJ3M.js +0 -3
  58. package/dist/chunks/chunk-T37DEXUI.js +0 -3
  59. package/dist/chunks/chunk-ZHNPBRCX.js +0 -3
  60. package/dist/chunks/clip-command-SLSAWJF4.js +0 -3
  61. package/dist/chunks/execute-NEDE4JM6.js +0 -3
  62. package/dist/chunks/launch-5JMWS5CI.js +0 -17
package/README.md CHANGED
@@ -50,7 +50,7 @@ That puts `forge` on your `PATH`, so it works from any directory. Verify:
50
50
 
51
51
  ```bash
52
52
  forge --version
53
- # 0.5.2
53
+ # 0.5.3
54
54
 
55
55
  forge photo.jpg --to webp
56
56
  ```
@@ -1117,7 +1117,7 @@ photo.png · PNG · 122 KB · 2756×774
1117
1117
  With `--json`:
1118
1118
 
1119
1119
  ```json
1120
- {"forge":"0.5.2","ok":true,"probes":[{"path":"/Users/me/photo.png","kind":"image","format":"png","bytes":122449,"width":2756,"height":774,"targets":["jpeg","png","webp","avif","gif","tiff","pdf"],"actions":["convert"]}],"failures":[]}
1120
+ {"forge":"0.5.3","ok":true,"probes":[{"path":"/Users/me/photo.png","kind":"image","format":"png","bytes":122449,"width":2756,"height":774,"targets":["jpeg","png","webp","avif","gif","tiff","pdf"],"actions":["convert"]}],"failures":[]}
1121
1121
  ```
1122
1122
 
1123
1123
  `targets` and `actions` come from the engines' own capabilities, so they are
@@ -1143,7 +1143,7 @@ succeeded) and `failures`. A conversion, compression or page operation adds
1143
1143
 
1144
1144
  ```jsonc
1145
1145
  {
1146
- "forge": "0.5.2",
1146
+ "forge": "0.5.3",
1147
1147
  "ok": false,
1148
1148
  "results": [
1149
1149
  {
@@ -1,4 +1,4 @@
1
1
  import { createRequire as __forgeCreateRequire } from 'node:module';
2
2
  const require = __forgeCreateRequire(import.meta.url);
3
3
  import"./chunk-TMUK2DD3.js";import{readFile as x}from"node:fs/promises";import{dirname as m,join as u}from"node:path";import{fileURLToPath as C}from"node:url";var c=[{name:"sharp \xB7 libvips",licence:"Apache-2.0 \xB7 LGPL-3.0",does:"images",packages:["sharp"]},{name:"PDFium",licence:"BSD-3-Clause",does:"PDF pages",packages:[]},{name:"pdf-lib",licence:"MIT",does:"writing PDFs",packages:["pdf-lib"]},{name:"mammoth \xB7 docx",licence:"BSD-2-Clause \xB7 MIT",does:"Word documents",packages:["mammoth","docx"]},{name:"Ink \xB7 React",licence:"MIT",does:"this screen",packages:["ink","react"]}],g=[{name:"@hyzyla/pdfium",licence:"MIT"}],h=[{name:"Noto Sans",licence:"OFL-1.1"},{name:"xkcd colour survey",licence:"CC0-1.0"}];function l(n){let t=[];for(let e of n.split(`
4
- `)){let i=/^((?:@[^/\s]+\/)?[^@\s]+)@\S+ — (.+)$/.exec(e);i&&t.push({name:i[1],licence:i[2].replace(/^\((.*)\)$/,"$1")})}return t}var d=n=>n.name.replace(/^@/,"");function p({bundled:n,extensions:t}){let e=new Set(c.flatMap(s=>s.packages)),i=[...n.filter(s=>!e.has(s.name)),...g,...h].sort((s,r)=>d(s).localeCompare(d(r)));return[{title:"App",credits:c.map(({packages:s,...r})=>r)},...t.length>0?[{title:"Extensions",credits:t}]:[],{title:"Others",credits:i}]}var f="third-party-licenses.txt";function y(n){let t=[],e=m(n);for(let i=0;i<4;i++)t.push(u(e,f),u(e,"dist",f)),e=m(e);return t}async function k(n){for(let t of y(C(n))){let e=await x(t,"utf8").catch(()=>{});if(e!==void 0)return{path:t,text:e}}}async function F({from:n=import.meta.url,list:t=async()=>(await import("./manager-T3WDLUKR.js")).listExtensions()}={}){let[e,i]=await Promise.all([k(n),t().catch(()=>[])]),{extensionCredits:s}=await import("./extensions-4UJRQ32J.js"),r=i.filter(o=>o.installed!==void 0).flatMap(o=>s(o.entry)),a=p({bundled:l(e?.text??""),extensions:r});return e?{sections:a,file:e.path}:{sections:a}}export{F as loadCredits};
4
+ `)){let i=/^((?:@[^/\s]+\/)?[^@\s]+)@\S+ — (.+)$/.exec(e);i&&t.push({name:i[1],licence:i[2].replace(/^\((.*)\)$/,"$1")})}return t}var d=n=>n.name.replace(/^@/,"");function p({bundled:n,extensions:t}){let e=new Set(c.flatMap(s=>s.packages)),i=[...n.filter(s=>!e.has(s.name)),...g,...h].sort((s,r)=>d(s).localeCompare(d(r)));return[{title:"App",credits:c.map(({packages:s,...r})=>r)},...t.length>0?[{title:"Extensions",credits:t}]:[],{title:"Others",credits:i}]}var f="third-party-licenses.txt";function y(n){let t=[],e=m(n);for(let i=0;i<4;i++)t.push(u(e,f),u(e,"dist",f)),e=m(e);return t}async function k(n){for(let t of y(C(n))){let e=await x(t,"utf8").catch(()=>{});if(e!==void 0)return{path:t,text:e}}}async function F({from:n=import.meta.url,list:t=async()=>(await import("./manager-XPO4ZIRY.js")).listExtensions()}={}){let[e,i]=await Promise.all([k(n),t().catch(()=>[])]),{extensionCredits:s}=await import("./extensions-UV4X2UUA.js"),r=i.filter(o=>o.installed!==void 0).flatMap(o=>s(o.entry)),a=p({bundled:l(e?.text??""),extensions:r});return e?{sections:a,file:e.path}:{sections:a}}export{F as loadCredits};
@@ -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}from"./chunk-ZFLFBNIK.js";import"./chunk-U5TEGDGH.js";import"./chunk-R24JCIZ5.js";import"./chunk-XPATZLEH.js";import"./chunk-HZDYZ5RD.js";import"./chunk-QVACE4IE.js";import"./chunk-RK3WGALB.js";import"./chunk-DYIATUFE.js";import"./chunk-EEQSUBBL.js";import"./chunk-LA5JVBFP.js";import"./chunk-K6ERQTUQ.js";import"./chunk-HWCXNKIN.js";import"./chunk-N6RCLJE6.js";import"./chunk-WE6KP4FR.js";import"./chunk-KH5DHZ2U.js";import"./chunk-HON4OV7M.js";import"./chunk-T37DEXUI.js";import"./chunk-J6AZTW62.js";import"./chunk-BIBDLXCG.js";import"./chunk-7KYO62XK.js";import"./chunk-CVNYUROW.js";import"./chunk-J7FLFHQJ.js";import"./chunk-VLVNA4T3.js";import"./chunk-H3DIRJFE.js";import"./chunk-KXKQDFHX.js";import"./chunk-TMUK2DD3.js";export{b as COMMANDS_HELP,a as EXIT_CODES_HELP,d as colourUsage,c as commandsHelp,f as parseArgs,e as wantsJson};
3
+ import{a,b,c,d,e,f}from"./chunk-AIINYKXW.js";import"./chunk-U5TEGDGH.js";import"./chunk-7VR6LODN.js";import"./chunk-5IZBFF6Y.js";import"./chunk-HZDYZ5RD.js";import"./chunk-QVACE4IE.js";import"./chunk-AFEYLHDD.js";import"./chunk-EPDF4NQI.js";import"./chunk-EEQSUBBL.js";import"./chunk-E2BYNETT.js";import"./chunk-IE6NFN3N.js";import"./chunk-HWCXNKIN.js";import"./chunk-N6RCLJE6.js";import"./chunk-WE6KP4FR.js";import"./chunk-KH5DHZ2U.js";import"./chunk-HON4OV7M.js";import"./chunk-TFOEI5VF.js";import"./chunk-J6AZTW62.js";import"./chunk-BIBDLXCG.js";import"./chunk-7KYO62XK.js";import"./chunk-CVNYUROW.js";import"./chunk-J7FLFHQJ.js";import"./chunk-VLVNA4T3.js";import"./chunk-H3DIRJFE.js";import"./chunk-KXKQDFHX.js";import"./chunk-TMUK2DD3.js";export{b as COMMANDS_HELP,a as EXIT_CODES_HELP,d as colourUsage,c as commandsHelp,f as parseArgs,e as wantsJson};
@@ -1,3 +1,3 @@
1
1
  import { createRequire as __forgeCreateRequire } from 'node:module';
2
2
  const require = __forgeCreateRequire(import.meta.url);
3
- import{r as a}from"./chunk-RK3WGALB.js";import{e as l}from"./chunk-N6RCLJE6.js";import"./chunk-WE6KP4FR.js";import"./chunk-KH5DHZ2U.js";import"./chunk-HON4OV7M.js";import"./chunk-H3DIRJFE.js";import"./chunk-TMUK2DD3.js";var c={loadPreferences:l,loadShell:()=>import("./launch-5JMWS5CI.js")};async function f(e=c,n={}){let t=e.loadShell();t.catch(()=>{});let{prefs:o,warning:r}=await e.loadPreferences(),s=a(o.theme),{launchShell:i}=await t;await i({prefs:o,palette:s,...r===void 0?{}:{warning:r},...n})}export{f as bootShell};
3
+ import{r as a}from"./chunk-AFEYLHDD.js";import{e as l}from"./chunk-N6RCLJE6.js";import"./chunk-WE6KP4FR.js";import"./chunk-KH5DHZ2U.js";import"./chunk-HON4OV7M.js";import"./chunk-H3DIRJFE.js";import"./chunk-TMUK2DD3.js";var c={loadPreferences:l,loadShell:()=>import("./launch-IVBMNYNY.js")};async function f(e=c,n={}){let t=e.loadShell();t.catch(()=>{});let{prefs:o,warning:r}=await e.loadPreferences(),s=a(o.theme),{launchShell:i}=await t;await i({prefs:o,palette:s,...r===void 0?{}:{warning:r},...n})}export{f as bootShell};
@@ -1,6 +1,6 @@
1
1
  import { createRequire as __forgeCreateRequire } from 'node:module';
2
2
  const require = __forgeCreateRequire(import.meta.url);
3
- import{a as y}from"./chunk-SNFUGJ3M.js";import{execFile as C}from"node:child_process";import{accessSync as v,constants as k}from"node:fs";import{isAbsolute as A,join as a}from"node:path";var S=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");function $(e,t){if(typeof e=="string")return`${t}<string>${S(e)}</string>`;if(typeof e=="number")return`${t}<integer>${e}</integer>`;if(typeof e=="boolean")return`${t}<${e}/>`;if(Array.isArray(e))return`${t}<array>
3
+ import{a as y}from"./chunk-6RMRWBMB.js";import{execFile as C}from"node:child_process";import{accessSync as v,constants as k}from"node:fs";import{isAbsolute as A,join as a}from"node:path";var S=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");function $(e,t){if(typeof e=="string")return`${t}<string>${S(e)}</string>`;if(typeof e=="number")return`${t}<integer>${e}</integer>`;if(typeof e=="boolean")return`${t}<${e}/>`;if(Array.isArray(e))return`${t}<array>
4
4
  ${e.map(o=>$(o,`${t} `)).join(`
5
5
  `)}
6
6
  ${t}</array>`;let n=Object.entries(e).map(([o,i])=>`${t} <key>${S(o)}</key>
@@ -0,0 +1,3 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ import{a as b,c as G}from"./chunk-Q6KQWJ4J.js";import{d as W,f as y,g as K}from"./chunk-7VR6LODN.js";import{a as Q,b as X,e as w}from"./chunk-5IZBFF6Y.js";import{a as H,b as P}from"./chunk-EPDF4NQI.js";import{a as h,d as R}from"./chunk-N6RCLJE6.js";import{i as F,j as U,k as g}from"./chunk-TFOEI5VF.js";import{d as I,l as z}from"./chunk-J6AZTW62.js";import{b as B,c as J,d as L,e as u,i as _,m as O}from"./chunk-BIBDLXCG.js";import{E as k,s as N}from"./chunk-CVNYUROW.js";import{a as s,b as D,c as $}from"./chunk-H3DIRJFE.js";var M=t=>t.length>0&&t.every(e=>e.kind==="image")?t:void 0;function Gt(t,e){let n=Q(t);return n.includes(e)?void 0:N(t,e,n)}function V(t){return{target:t.target??"png",background:typeof t.background=="string"?t.background:"#ffffff",keepMetadata:t.keepMetadata===!0,...typeof t.output=="string"?{output:t.output}:{},...t.roots instanceof Map?{roots:t.roots}:{},...typeof t.quality=="number"?{quality:t.quality}:{}}}var Y=()=>({kind:"select",id:"target",label:"Save as",default:"png",choices:[{value:"png",label:"PNG",hint:s.png.hint}]}),dt=t=>t===1?"sharp":`${t}x`,ut=t=>t===1||t===3||t===4?t:2,Ht={id:"boost",label:"Boost resolution",verb:"Boosting",hint:"sharper, at its size or at 2\xD7, 3\xD7 or 4\xD7",requires:"boost",appliesTo:t=>M(t)!==void 0,unavailable:()=>"images only",options:()=>[{kind:"select",id:"scale",label:"Scale",default:"2",choices:[{value:"1",label:"Sharpen",hint:"the same size, sharper"},{value:"2",label:"2\xD7",hint:"twice the width and height"},{value:"3",label:"3\xD7",hint:"three times the width and height"},{value:"4",label:"4\xD7",hint:"four times the width and height"}]},Y()],plan(t,e){let n=M(t);if(!n)return[];let o=V(e),i=ut(Number(e.scale??2));return n.map(r=>({op:"boost",sources:[r],outputs:[u({sourcePath:r.path,target:o.target,suffix:dt(i),...o.output===void 0?{}:{output:o.output},...o.roots?.get(r.path)===void 0?{}:{sourceRoot:o.roots.get(r.path)}})],scale:i,target:o.target,options:{background:o.background,keepMetadata:o.keepMetadata,...o.quality===void 0?{}:{quality:o.quality}}}))}},Wt={id:"remove-background",label:"Remove background",verb:"Removing",hint:"cut out the subject",requires:"remove-background",appliesTo:t=>M(t)!==void 0,unavailable:()=>"images only",options:()=>[Y()],plan(t,e){let n=M(t);if(!n)return[];let o=V(e);return n.map(i=>({op:"remove-background",sources:[i],outputs:[u({sourcePath:i.path,target:o.target,suffix:"cutout",...o.output===void 0?{}:{output:o.output},...o.roots?.get(i.path)===void 0?{}:{sourceRoot:o.roots.get(i.path)}})],target:o.target,options:{background:o.background,keepMetadata:o.keepMetadata,...o.quality===void 0?{}:{quality:o.quality}}}))}};var ft=[{degrees:90,label:"90\xB0 right",suffix:"rotated-right"},{degrees:180,label:"180\xB0",suffix:"rotated-180"},{degrees:270,label:"90\xB0 left",suffix:"rotated-left"}],S=t=>t===90||t===180||t===270,Vt=(t,e)=>e===180?{...t}:{width:t.height,height:t.width},T=t=>ft.find(e=>e.degrees===t).suffix;import{dirname as ct,join as Z}from"node:path";var q="Same location",v="New subfolder";function mt(t,e,n){return t===e?q:t===h("Desktop")?"Desktop":t===h("Downloads")?"Downloads":e!==void 0&&n!==void 0&&t===Z(e,n)?v:b(t)||t}function A(t,e,n={}){return lt(ct(t.path),e,n)}function lt(t,e,{subfolder:n}={}){let o=R(e.defaultOutput),i=e.lastOutput?R(e.lastOutput):void 0,r=f=>({label:mt(f,t,n),path:f}),a=[r(o),...i?[r(i)]:[],r(h("Desktop")),...t===void 0?[]:[{label:q,path:t}],r(h("Downloads")),...n!==void 0&&t!==void 0?[{label:v,path:Z(t,n)}]:[]],p=new Set,d=a.filter(f=>p.has(f.path)?!1:(p.add(f.path),!0));return{kind:"path",id:"destination",label:"Save to",default:o,presets:d,...i&&i!==o?{last:i}:{}}}var c=t=>typeof t=="string"&&t!==""?t:void 0;var pe=[2,1.5,1.25,.75,.5],gt=.25,ht=4,tt=-16;function nt(t){return{wav:"m4a",aiff:"m4a",flac:"m4a",avi:"mp4",ogg:"opus"}[t]??t}var et=t=>t.length===1&&t[0]?.kind==="media"?t[0]:void 0,bt=t=>t==="cut"||t==="mute"||t==="speed"||t==="resize"||t==="crop"||t==="rotate"||t==="loudness"||t==="extract"||t==="cleanup";function yt(t,e){let n=e.media??{},o=t.facts?.video,i=[];return e.extract&&i.push("audio"),n.cut&&i.push("trimmed"),n.mute&&i.push("muted"),n.cleanup?i.push("cleaned"):n.loudness!==void 0&&i.push("levelled"),n.speed!==void 0&&i.push(`${n.speed}x`),n.fps!==void 0&&i.push(`${n.fps}fps`),n.bitrate!==void 0&&i.push(`${n.bitrate}k`),e.crop&&i.push(z(e.crop.aspect)),e.resize&&i.push(o?y(g(o,e.resize)):"resized"),e.rotate&&i.push(T(e.rotate)),i.length===1?i[0]:"edited"}function St(t,e){return t.map(n=>{let o=e.target??n.format,i={background:"#ffffff",keepMetadata:!1};e.media&&Object.keys(e.media).length&&(i.media=e.media),e.resize&&(i.resize=e.resize),e.rotate&&(i.rotate=e.rotate);let r=n.facts?.video;e.crop&&r&&(i.crop={aspect:e.crop.aspect,box:e.crop.box??I(r,e.crop.aspect)});let a=e.roots?.get(n.path),p=u({sourcePath:n.path,target:o,suffix:yt(n,e),...e.output===void 0?{}:{output:e.output},...a===void 0?{}:{sourceRoot:a}});return{op:"convert",sources:[n],outputs:[O(p,c(e.destination),c(e.name))],target:o,options:i}})}function x(t){let e={},n=t.cut;return n&&typeof n.start=="number"&&(e.cut={start:n.start,...typeof n.end=="number"?{end:n.end}:{}}),t.mute===!0&&(e.mute=!0),typeof t.speed=="number"&&(e.speed=t.speed),typeof t.fps=="number"&&(e.fps=t.fps),typeof t.bitrate=="number"&&(e.bitrate=t.bitrate),typeof t.loudness=="number"&&(e.loudness=t.loudness),t.cleanup===!0&&(e.cleanup=!0),Object.keys(e).length?e:void 0}var de={id:"media-edit",label:"Edit",verb:"Editing",hint:"trim, mute, speed, resize, rotate, crop",appliesTo:t=>et(t)!==void 0,unavailable:()=>"one video or audio file",options:()=>[],plan(t,e){let n=et(t);if(!n||!bt(e.tool))return[];let o=e.tool,i={...typeof e.output=="string"?{output:e.output}:{},destination:e.destination,name:e.name};if(o==="cut"){let r=x(e)?.cut;if(!r)return[];i.media={cut:r}}if(o==="mute"&&(i.media={mute:!0}),o==="speed"){let r=e.speed;if(typeof r!="number"||r===1||r<gt||r>ht)return[];i.media={speed:r}}if(o==="loudness"&&(i.media={loudness:typeof e.loudness=="number"?e.loudness:tt}),o==="cleanup"){if(!n.facts?.audio)return[];i.media={cleanup:!0,loudness:tt}}if(o==="extract"){let r=n.facts?.audio;if(!r||!n.facts?.video)return[];i.extract=!0,i.target=G(r.codec)}if(o==="resize"){if(typeof e.resize!="object"||e.resize===null)return[];i.resize=e.resize}if(o==="rotate"){if(!n.facts?.video||!S(e.turn))return[];i.rotate=e.turn}if(o==="crop"){let r=e.crop;if(!r?.aspect||!n.facts?.video)return[];i.crop=r}return St([n],i)}};import{dirname as xt,join as kt}from"node:path";var It=t=>s[t.format].media==="video",zt=t=>t.length===1&&t[0]?.kind==="image"?t[0]:void 0,Ot=t=>t.length===1&&t[0]?.kind==="document"?t[0]:void 0,Mt="-small",m={min:30,max:100,step:35},Tt=t=>{let e=Math.ceil((t-m.min)/m.step);return Math.min(m.max,m.min+Math.max(0,e)*m.step)},ye={id:"compress",label:"Compress",verb:"Compressing",hint:"make it smaller",appliesTo:t=>{if(t.length===1&&t[0]?.kind==="media")return!0;let e=zt(t);if(e!==void 0){let o=s[e.format];return o.lossy||o.quantisable===!0}return(Ot(t)?.images?.compressible??0)>0},options(t,e,n){let o=t[0];if(!o)return[];let i=[{kind:"select",id:"mode",label:`Compress ${b(o.path)??"this file"}`,choices:[o.kind==="media"?{value:"quality",label:"By quality"}:{value:"quality",label:"By quality",hint:"pick a level, see the result"},{value:"size",label:"To a target size",hint:"smallest quality that fits"}],default:"quality"}];if(e.mode==="quality"&&o.kind==="media"&&!It(o))i.push({kind:"slider",id:"bitrate",label:"Quality",min:32,max:320,step:32,default:96});else if(e.mode==="quality"){let r=o.kind==="image"&&s[o.format].quantisable===!0;i.push(r?{kind:"slider",id:"quality",label:"Quality",...m,default:Tt(n.quality),points:!0}:{kind:"slider",id:"quality",label:"Quality",min:1,max:100,step:5,default:n.quality})}else if(e.mode==="size")i.push({kind:"text",id:"size",label:"Target size",placeholder:"e.g. 500kb or 2mb"});else return i;return i.push(A(o,n)),i},plan(t,e){let n=e.mode;if(n!=="quality"&&n!=="size")throw k(`compressAction.plan() needs a mode of "quality" or "size", got ${JSON.stringify(n)}.`,"This is a caller bug, not a user-facing condition: walk options() before calling plan().");let o=t[0];if(!o)return[];let i=(b(o.path)??"file").replace(/\.[^.]+$/,""),r=typeof e.destination=="string"?e.destination:xt(o.path),a=o.kind==="media"?nt(o.format):o.format,p=kt(r,B(i,`${Mt}${$(a)}`)),d=o.kind==="media"?x(e):void 0;return[{op:"convert",sources:[o],target:a,outputs:[p],options:{background:"#ffffff",keepMetadata:!1,...n==="quality"&&typeof e.quality=="number"?{quality:e.quality}:{},compress:{dither:e.dither===!0},...d?{media:d}:{}}}]}};function At(t){return{kind:"select",id:"pages",label:"Pages",default:"all",choices:[{value:"all",label:"All pages",hint:`${t.pages} pages`},{value:"first",label:"First page only"},{value:"choose",label:"Choose pages",hint:"pick which ones"}]}}function Ft(){return{kind:"select",id:"dpi",label:"Resolution",default:"150",choices:[{value:"72",label:"72 dpi",hint:"screen"},{value:"150",label:"150 dpi",badge:"default"},{value:"300",label:"300 dpi",hint:"print"}]}}function Rt(t,e){return Array.isArray(e)?P(e):e==="first"?[0]:typeof e=="string"&&e!=="all"&&e!==""?P(H(e,t.pages)):Array.from({length:t.pages},(n,o)=>o)}function wt(t,e){let n=s[t.format].lossy,o=s[e].lossy;if(n&&!o)return{hint:"likely bigger",tone:"warn"};if(!n&&o)return{hint:"likely smaller",tone:"ok"}}function Pt(t){let e=X(t).filter(o=>o.id!==t.format),n=e[0];return{kind:"select",id:"target",label:`Convert ${s[t.format].label} to`,choices:e.map(o=>{let i=wt(t,o.id);return{value:o.id,label:o.label,hint:i?.hint??o.hint,...i===void 0?{}:{tone:i.tone}}}),default:n?n.id:""}}function Et(t){return{kind:"slider",id:"bitrate",label:"Quality",min:64,max:320,step:32,default:t==="opus"?96:128}}var Ct=t=>typeof t=="object"&&t!==null&&("percent"in t||"width"in t||"height"in t);function jt(t){let e=t.target,n=typeof e=="string"?D(e):void 0;if(!n)throw k(`convertAction.plan() requires a valid target format, got ${JSON.stringify(e)}.`,"This is a caller bug, not a user-facing condition: call options() and pass one of the target select choices before calling plan().");return n}var Ae={id:"convert",label:"Convert",verb:"Converting",hint:"to another format",appliesTo:t=>t.length>=1,options(t,e,n){let o=t[0];if(!o)return[];let i=[Pt(o)],r=e.target;if(typeof r!="string")return i;o.kind==="document"&&w(r)&&i.push(At(o),Ft());let a=s[r];return o.kind==="media"?a?.media==="sound"&&a.lossy&&i.push(Et(r)):a?.lossy&&a.media===void 0&&i.push({kind:"slider",id:"quality",label:"Quality",min:1,max:100,step:5,default:n.quality}),i.push(A(o,n)),i},plan(t,e){let n=t[0];if(!n)return[];let o=jt(e),i=o.id,r={background:typeof e.background=="string"?e.background:"#ffffff",keepMetadata:e.keepMetadata===!0};if(o.lossy&&typeof e.quality=="number"&&(r.quality=e.quality),n.kind==="media"){let d=x(e);d&&(r.media=d),Ct(e.resize)&&(r.resize=e.resize)}let a=typeof e.destination=="string"?e.destination:void 0;if(n.kind==="document"&&w(i)){let d=Number(e.dpi);r.dpi=Number.isFinite(d)&&d>0?d:150;let f=Rt(n,e.pages);r.pages=f;let st=typeof e.sourceRoot=="string"?e.sourceRoot:void 0,pt=_(n.path,f,i,a,st);return[{op:"convert",sources:[n],outputs:pt,target:i,options:r}]}let p=L({sourcePath:n.path,target:i,...a===void 0?{}:{output:`${a}/`}});return J(p,n.path)&&(p=u({sourcePath:n.path,target:i,suffix:i,...a===void 0?{}:{output:`${a}/`}})),[{op:"convert",sources:[n],outputs:[p],target:i,options:r}]}};var Dt=[16,4,2],E=t=>typeof t=="number"&&Dt.includes(t),ot=t=>`dithered-${t}`,we=t=>`${t} colours`,it=t=>s[t.format].quantisable?t.format:"png",C=t=>!(t.frames>1)||t.format==="gif";function $t(t,e){if(e.dither)return ot(e.dither);if(e.deband)return U(e.deband);if(!e.rotate)return rt(t,e);let n=T(e.rotate);return e.trim||e.crop||e.resize?`${rt(t,e)}-${n}`:n}function rt(t,e){if(e.crop){let n=z(e.crop.aspect);if(!e.resize)return n;let o=e.crop.box??I(t,e.crop.aspect);return`${n}-${y(g(o,e.resize))}`}return e.trim&&e.resize?`trimmed-${K(e.resize)}`:e.resize?y(g(t,e.resize)):"trimmed"}function Nt(t,e){if(e.trim&&e.crop)throw new Error("planEdit cannot trim and crop the same image");return t.map(n=>{let o=e.target??(e.dither?it(n):W(n)),i={background:e.background,keepMetadata:e.keepMetadata,...e.quality===void 0?{}:{quality:e.quality},...e.trim?{trim:!0}:{},...e.resize?{resize:e.resize}:{},...e.crop?{crop:e.crop}:{},...e.rotate?{rotate:e.rotate}:{},...e.dither?{dither:e.dither}:{},...e.deband?{deband:e.deband}:{},...e.deband&&e.quality===void 0&&s[o].lossy?{quality:95}:{}},r=e.roots?.get(n.path),a=u({sourcePath:n.path,target:o,suffix:$t(n,e),...e.output===void 0?{}:{output:e.output},...r===void 0?{}:{sourceRoot:r}});return{op:"convert",sources:[n],outputs:[O(a,c(e.destination),c(e.name))],target:o,options:i}})}var j=t=>t.length>0&&t.every(e=>e.kind==="image")?t:void 0,Bt=t=>typeof t=="object"&&t!==null&&("percent"in t||"width"in t||"height"in t),at=t=>typeof t=="object"&&t!==null&&"aspect"in t&&typeof t.aspect=="object"&&t.aspect!==null&&"w"in t.aspect&&"h"in t.aspect;function l(t,e,n,o){return{id:t,label:e,verb:n,hint:o,appliesTo:i=>j(i)?.every(r=>t==="resize"?!0:t==="dither"?C(r):r.frames<=1)===!0,unavailable:i=>j(i)?"animated":"images only",options:()=>[],plan(i,r){let a=j(i);return a?t==="crop"&&!at(r.crop)?[]:t==="turn"&&!S(r.turn)?[]:t==="deband"&&(!F(r.deband)||a.some(p=>p.frames>1))?[]:t==="dither"&&(!E(r.dither)||!a.every(C))?[]:Nt(a,{trim:t==="trim"||r.trim===!0,...S(r.turn)?{rotate:r.turn}:{},...t==="dither"&&E(r.dither)?{dither:r.dither}:{},...t==="deband"&&F(r.deband)?{deband:r.deband}:{},...Bt(r.resize)?{resize:r.resize}:{},...at(r.crop)?{crop:r.crop}:{},...typeof r.target=="string"?{target:r.target}:{},...typeof r.output=="string"?{output:r.output}:{},...r.roots instanceof Map?{roots:r.roots}:{},destination:r.destination,name:r.name,background:typeof r.background=="string"?r.background:"#ffffff",keepMetadata:r.keepMetadata===!0,...typeof r.quality=="number"?{quality:r.quality}:{}}):[]}}}var Le=l("trim","Trim edges","Trimming edges","cut empty borders"),_e=l("resize","Resize","Resizing","smaller or larger"),Ue=l("crop","Crop to shape","Cropping","change the shape"),Qe=l("turn","Rotate","Rotating","turn it"),Xe=l("dither","Dither","Dithering","fewer colours, scattered"),Ge=l("deband","Remove banding","Removing banding","smooth out stripes");export{Gt as a,Ht as b,Wt as c,v as d,A as e,lt as f,c as g,ft as h,Vt as i,pe as j,St as k,de as l,ye as m,Ae as n,Dt as o,we as p,it as q,C as r,Nt as s,Le as t,_e as u,Ue as v,Qe as w,Xe as x,Ge as y};