forge-terminal 0.4.2 → 0.4.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 (24) hide show
  1. package/README.md +3 -3
  2. package/dist/chunks/{about-credits-PFW4OXPX.js → about-credits-BIOQB4LZ.js} +1 -1
  3. package/dist/chunks/{args-ZMSJ3NBZ.js → args-5XWINYYE.js} +1 -1
  4. package/dist/chunks/{boot-M6TQUYUF.js → boot-66CWEF4E.js} +1 -1
  5. package/dist/chunks/{chunk-MV7H3QQY.js → chunk-5BE5XZY5.js} +1 -1
  6. package/dist/chunks/{chunk-BCNMRALN.js → chunk-E55PYOCI.js} +2 -2
  7. package/dist/chunks/{chunk-P6NXFZZP.js → chunk-KAQ5LMYO.js} +1 -1
  8. package/dist/chunks/{chunk-DTX4OGMY.js → chunk-KCCI3WEN.js} +1 -1
  9. package/dist/chunks/{chunk-Y2A3HTKQ.js → chunk-WMPQ5T2K.js} +2 -2
  10. package/dist/chunks/{clip-command-LAVVAHHV.js → clip-command-ANGANJ3B.js} +1 -1
  11. package/dist/chunks/{colour-AJW2JR3S.js → colour-RMOFEV4G.js} +1 -1
  12. package/dist/chunks/{entry-UWADO4ND.js → entry-NFR27M33.js} +1 -1
  13. package/dist/chunks/{execute-MUM63CAA.js → execute-JY372YAC.js} +1 -1
  14. package/dist/chunks/{extensions-ZKAAFA4J.js → extensions-K27LB6ZO.js} +1 -1
  15. package/dist/chunks/{extensions-command-73UGWB6L.js → extensions-command-TBOTOP4R.js} +1 -1
  16. package/dist/chunks/launch-QNZWUCVQ.js +5 -0
  17. package/dist/chunks/{manager-743RM57Z.js → manager-DLXGO25L.js} +1 -1
  18. package/dist/chunks/{server-DPBVFUL7.js → server-PQEGX3HK.js} +3 -3
  19. package/dist/chunks/{theme-USWAYNEH.js → theme-BJRL3INU.js} +1 -1
  20. package/dist/chunks/{update-note-VYJKUIIX.js → update-note-NSHFIIX6.js} +1 -1
  21. package/dist/chunks/{watch-command-KULANTL2.js → watch-command-B5R6NDWW.js} +1 -1
  22. package/dist/index.js +6 -6
  23. package/package.json +5 -1
  24. package/dist/chunks/launch-S5BW2LZU.js +0 -5
@@ -1,4 +1,4 @@
1
1
  import { createRequire as __forgeCreateRequire } from 'node:module';
2
2
  const require = __forgeCreateRequire(import.meta.url);
3
- import{a as ie,b as ue,c as pe,d as N,e as de,k as fe,l as le,m as me,o as ge,p as he}from"./chunk-I63TO22X.js";import{a as y}from"./chunk-DERIWZAT.js";import{c as I}from"./chunk-YWKMG5WO.js";import{f as ce,i as j}from"./chunk-LNB5D67B.js";import{e as te,f as re,g as oe,h as se,i as ne,j as ae}from"./chunk-EHARO6IS.js";import{a as F,c as X,d as Z,e as C,f as _,k as ee}from"./chunk-QR6QHTC3.js";import{e as Q}from"./chunk-6L6C3GJU.js";import{d as $}from"./chunk-EEQSUBBL.js";import{n as H,p as L}from"./chunk-KAHWYWNT.js";import{a as U,c as Y,d as E,e as K}from"./chunk-EXLXSKRH.js";import{F as M,G as q,J as G,b as P,c as w,d as v,na as V,p as z,r as k,t as D,w as J}from"./chunk-3UEQ2OX6.js";import{a as h,b as W}from"./chunk-J7FLFHQJ.js";import{a as m}from"./chunk-MV7H3QQY.js";import{a as R}from"./chunk-M66BUNYO.js";import{readFile as Je}from"node:fs/promises";import{dirname as Fe,resolve as Me}from"node:path";async function ye(e){let r=[],t=[...e.resolved.failures];for(let o of e.resolved.sources){let s=F(o);if(!s.includes(e.target)){t.push({path:o.path,error:D(o,e.target,s)});continue}let n={sourcePath:o.path,target:e.target,output:e.output,sourceRoot:e.resolved.roots.get(o.path)},a=E(n);Y(a,o.path)&&e.target!==o.format&&(a=K({...n,suffix:e.target})),r.push({op:"convert",sources:[o],outputs:[a],target:e.target,options:e.options})}return{jobs:r,failures:t}}import{resolve as Ce}from"node:path";function je(e,r=new Set){let t={path:Ce(e.path),kind:e.kind,format:e.format,bytes:e.bytes},o=e.kind==="document"&&e.encrypted===!0,s={targets:F(e).filter(n=>!o||C(n)),actions:ge([e],r).filter(n=>!o||n.id===j.id).map(n=>n.id)};if(e.kind==="image")return{...t,width:e.width,height:e.height,...s};if(e.kind==="media"){let n=e.facts;return{...t,...n?{duration:n.duration}:{},...n?.video?{width:n.video.width,height:n.video.height,fps:n.video.fps}:{},...s}}return{...t,pages:e.pages,encrypted:e.encrypted,...s}}async function be(e){let r=await y(e,{recursive:!1}),{installedExtensionIds:t}=await import("./available-GYIHVSRX.js"),o=await t();return{probes:r.sources.map(s=>je(s,o)),failures:r.failures}}import{dirname as Be}from"node:path";var B=e=>({cwd:e.cwd??process.cwd(),...e.home===void 0?{}:{home:e.home}});function we(e,r){let t=P(Be(e),B(r));return t==="."?"":` in ${t.endsWith("/")?t:`${t}/`}`}function Ie(e,r){let{pct:t,direction:o}=W(e,r);return o==="same"?"same size":`${t}% ${o}`}function xe(e,r={}){let t=e.results[0];if(!t)return[];let o=t.job.sources[0],s=t.job.outputs;if(s.length>1){let a=[`\u2713 ${w(o.path)} \u2192 ${s.length} files${we(s[0],r)}`,` ${s.map(i=>w(i)).join(", ")}`,` ${h(o.bytes)} \u2192 ${h(t.outputBytes)} total`];for(let i of t.warnings)a.push("",`\u26A0 ${i.message}`);return a}let n=[`\u2713 ${w(o.path)} \u2192 ${P(s[0],B(r))}`,` ${h(o.bytes)} \u2192 ${h(t.outputBytes)} \xB7 ${Ie(o.bytes,t.outputBytes)}`];for(let a of t.warnings)n.push("",`\u26A0 ${a.message}`);return n}function Pe(e,r={}){let t=[`\u2713 ${e.results.length} converted`,` ${h(e.inputBytes)} \u2192 ${h(e.outputBytes)} \xB7 ${Ie(e.inputBytes,e.outputBytes)}`];for(let s of e.results)for(let n of s.job.outputs)t.push(` ${P(n,B(r))}`);let o=e.results.flatMap(s=>s.warnings);if(o.length>0){t.push("");for(let s of o)t.push(`\u26A0 ${s.message}`)}return t}function ve(e,r={}){let t=e.results.flatMap(u=>u.job.outputs),o=t.map(u=>w(u)).join(", "),s=t.length===1?"file":"files",n=t[0]===void 0?"":we(t[0],r),a=[`\u2713 ${t.length} ${s} \xB7 ${o}${n}`],i=e.results.flatMap(u=>u.warnings);for(let u of i)a.push("",`\u26A0 ${u.message}`);return a}function O(e,r){if(e.length===0)return[];let t=[];for(let o of e)t.push(...V(o.error,{debug:r.debug}),"");return t}function ke(){let e=new Set(X()),r=new Set(Z()),t=["Formats",""];for(let s of e){let n=R[s],a=r.has(s)?"read and write":"read only";t.push(` ${n.label.padEnd(6)} ${n.extensions.join(" ").padEnd(12)} ${a}`)}let o=[...e].filter(s=>!r.has(s)).map(s=>R[s].label);if(o.length>0){let s=o.join(", "),[n,a]=o.length===1?["is","it"]:["are","them"];t.push("",`${s} ${n} read only because Forge cannot yet write ${a}.`)}return t}function $e(e,r={}){let t=[R[e.format].label,h(e.bytes)];return e.duration!==void 0&&t.push($(e.duration)),e.width!==void 0&&e.height!==void 0&&t.push(`${e.width}\xD7${e.height}`),e.fps!==void 0&&t.push(`${e.fps} fps`),e.pages!==void 0&&t.push(`${e.pages} ${e.pages===1?"page":"pages"}`),e.encrypted&&t.push("password-protected"),[`${P(e.path,B(r))} \xB7 ${t.join(" \xB7 ")}`,` converts to ${e.targets.join(", ")}`,` actions ${e.actions.join(", ")}`]}import{createInterface as Re}from"node:readline";import{PassThrough as Oe}from"node:stream";function Se(e){return new Promise(r=>{let t=Re({input:e,terminal:!1}),o=!1,s=n=>{if(o)return;o=!0,t.close(),e.pause(),e.unref?.(),r(n.replace(/\r$/,""))};t.once("line",s),t.once("close",()=>s(""))})}async function Ee(e){if(e.stdin)return Se(process.stdin);if(!process.stdin.isTTY)return;let r=new Oe,t=Re({input:process.stdin,output:r,terminal:!0});try{return process.stderr.write("Password: "),await new Promise(o=>t.question("",o))}finally{process.stderr.write(`
4
- `),t.close()}}function T(e){return e.length===0?0:e.some(r=>r.error.code==="invalid-arguments")?2:1}function Ne(e,r){if(e.action==="merge")return{};if(e.action==="rotate")return{degrees:e.rotate};if(e.action==="extract")return{pages:e.pages,separate:e.separate?"many":"one"};if(e.action==="delete")return{pages:e.pages};let t=r.find(a=>a.kind==="document"),o=t?.pages??0,s=e.split;if(!s)throw M("--split needs a mode: every-page, every=N or at=N,N.");if(s.mode==="every-page")return{cuts:fe(o)};if(s.mode==="every-n")return{cuts:le(o,s.n)};let n=Math.max(o-1,0);for(let a of s.after)if(!Number.isInteger(a)||a<1||a>n)throw q(String(a),`"${a}" is outside 1 and ${n} \u2014 ${t?w(t.path):"the document"} has ${o} pages.`,o);return{cuts:s.after.map(a=>a-1)}}function Te(e,r){let t;return()=>r?(t??=Ee({stdin:e}).then(o=>e&&o===""?void 0:o),t):Promise.resolve(void 0)}async function Ae(e,r,t,o){let s;if(e.encrypted){if(s=r.password??await t(),s===void 0)return{failure:{path:e.path,error:J(e.path)}};let i;try{i=await Q(await Je(e.path),s)}catch{return{failure:{path:e.path,error:J(e.path,{attempted:!0})}}}i.destroy()}let n;try{n=j.plan([e],{target:r.target,background:r.options.background,keepMetadata:r.options.keepMetadata,dpi:String(r.dpi??150),...r.options.quality===void 0?{}:{quality:r.options.quality},...r.pages===void 0?{}:{pages:r.pages},...r.output===void 0?{}:{destination:r.output},...o===void 0?{}:{sourceRoot:o}})}catch(i){if(!v(i))throw i;return{failure:{path:e.path,error:i}}}let a=n[0];if(a?.op!=="convert")throw new Error(`convertAction.plan() did not return a convert job for ${e.path}`);return s!==void 0&&(a.options.password=s),{job:a}}function S(e,r){return t=>{if(t.type==="search:attempt"){r||e.onSearch?.(t.rung.dpi===void 0?`attempt ${t.attempt} of ${t.of}`:`${t.rung.dpi} dpi \xB7 attempt ${t.attempt} of ${t.of}`);return}if(t.type==="search:settled"){r&&e.onSearch?.(`${t.completed} of ${t.total} searched`);return}if(!r&&t.type==="job:phase"&&t.progress.phase==="time"){let o=t.progress,s=`${$(o.done)} of ${$(o.total)}`;e.onEncode?.(o.pass?`pass ${o.pass.at} of 2 \xB7 ${s}`:s);return}r&&(t.type==="job:done"||t.type==="job:error")&&e.onProgress?.({completed:t.completed,total:t.total})}}var b=(e,r)=>({kind:e,results:[],failures:r,inputBytes:0,outputBytes:0});async function We(e){let r=await y(e.inputs,{recursive:!1});if(r.sources.length===0)return b("pageop",r.failures);let t=me.find(a=>a.id===e.action);if(!t)throw new Error(`no action registered for "${e.action}"`);let o=r.sources[0]?.path??"";if(!t.appliesTo(r.sources)){let a=he(t,r.sources)??"not available for these files";return b("pageop",[...r.failures,{path:o,error:k(e.action,a)}])}let s;try{s=t.plan(r.sources,Ne(e,r.sources))}catch(a){if(!v(a))throw a;return b("pageop",[...r.failures,{path:o,error:a}])}let n=await I(s,{force:e.force});return{kind:"pageop",results:n.results,failures:[...r.failures,...n.refusals,...n.failures],inputBytes:n.inputBytes,outputBytes:n.outputBytes}}async function ze(e,r){let t=await y(e.inputs,{recursive:e.recursive}),o=[],s=[];for(let i of t.sources){if(!N.appliesTo([i])){s.push({path:i.path,error:z(i)});continue}let u=e.output!==void 0&&!U(e.output)?Me(e.output):void 0,g=e.output===void 0||u!==void 0?Fe(i.path):Fe(E({sourcePath:i.path,target:i.format,output:e.output,sourceRoot:t.roots.get(i.path)})),[d]=N.plan([i],{mode:e.maxBytes===void 0?"quality":"size",...e.quality===void 0?{}:{quality:e.quality},...e.options.media??{},destination:g});d?.op==="convert"&&(u!==void 0&&(d.outputs=[u]),e.dpi!==void 0&&(d.options.dpi=e.dpi),o.push(d))}let n=o.length>1;n&&r.onProgress?.({completed:0,total:o.length});let a=await I(o,{force:e.force,...e.concurrency===void 0?{}:{concurrency:e.concurrency},...e.maxBytes===void 0?{}:{targetBytes:e.maxBytes},onEvent:S(r,n)});return{kind:"compress",results:a.results,failures:[...t.failures,...s,...a.refusals,...a.unreachable.map(i=>({path:i.job.sources[0].path,error:i.error})),...a.failures],inputBytes:a.inputBytes,outputBytes:a.outputBytes}}async function De(e,r){let t=e.kind,o=e.op==="remove-background"?H(e.target):void 0;if(o)return b(t,[{path:"",error:o}]);let{installed:s}=await import("./paths-5XI5L4KW.js"),n=await s(e.op);if(!n)return b(t,[{path:"",error:G(e.op)}]);if(e.op==="boost"&&e.scale!==void 0){let{assetFor:c,catalogEntry:p}=await import("./catalog-YSMT3PXT.js"),f=p("boost"),x=f&&c(f)?.version,A=L(e.scale,n.version,x);if(A)return b(t,[{path:"",error:A}])}let a=await y(e.inputs,{recursive:e.recursive}),i=e.op==="boost"?ue:pe,u=[],g=[];for(let c of a.sources){if(!i.appliesTo([c])){g.push({path:c.path,error:k(e.op,"it works on images, not documents","Try an image such as a JPEG, PNG, WebP or HEIC file.")});continue}let p=ie(c,e.target);if(p){g.push({path:c.path,error:p});continue}u.push(...i.plan([c],{target:e.target,background:e.options.background,keepMetadata:e.options.keepMetadata,...e.scale===void 0?{}:{scale:e.scale},...e.options.quality===void 0?{}:{quality:e.options.quality},...e.output===void 0?{}:{output:e.output},roots:a.roots}))}let d=u.length>1;d&&r.onProgress?.({completed:0,total:u.length});let l=await I(u,{force:e.force,concurrency:1,...r.signal===void 0?{}:{signal:r.signal},onEvent:S(r,d)});return{kind:t,results:l.results,failures:[...a.failures,...g,...l.refusals,...l.failures],inputBytes:l.inputBytes,outputBytes:l.outputBytes}}async function qe(e,r){let t=e.crop!==void 0?"crop":e.resize!==void 0?"resize":"trim",o=e.target===void 0?void 0:ee(e.target,t);if(o)return b(e.kind,[{path:"",error:o}]);let s=await y(e.inputs,{recursive:e.recursive}),n=[],a=[],i=[];for(let p of s.sources)p.kind==="image"&&e.media===void 0?n.push(p):p.kind==="media"&&!e.trim?a.push(p):p.kind==="image"?i.push({path:p.path,error:k("cut","it works on video and sound, not images","Try a video or sound file, such as a MOV, MP4 or WAV.")}):i.push({path:p.path,error:k(t,"it works on images, not documents","Try an image such as a JPEG, PNG, WebP or HEIC file.")});let u=ce(a,{...e.media===void 0?{}:{media:e.media},...e.crop===void 0?{}:{crop:e.crop},...e.resize===void 0?{}:{resize:e.resize},...e.target===void 0?{}:{target:e.target},...e.output===void 0?{}:{output:e.output},roots:s.roots}),d=[...de(n,{trim:e.trim,...e.crop===void 0?{}:{crop:e.crop},...e.resize===void 0?{}:{resize:e.resize},...e.target===void 0?{}:{target:e.target},...e.output===void 0?{}:{output:e.output},roots:s.roots,background:e.options.background,keepMetadata:e.options.keepMetadata,...e.options.quality===void 0?{}:{quality:e.options.quality}}),...u],l=d.length>1;l&&r.onProgress?.({completed:0,total:d.length});let c=await I(d,{force:e.force,...e.concurrency===void 0?{}:{concurrency:e.concurrency},onEvent:S(r,l)});return{kind:e.kind,results:c.results,failures:[...s.failures,...i,...c.refusals,...c.failures],inputBytes:c.inputBytes,outputBytes:c.outputBytes}}async function Ge(e,r){let t=await y(e.inputs,{recursive:e.recursive}),o=f=>f.kind==="document"&&f.format==="pdf",s=C(e.target),n=s?t.sources.filter(o):[],a=s?t.sources.filter(f=>!o(f)):t.sources,i=[],u=[],g=Te(e.passwordStdin??!1,r.interactive??!0);for(let f of n){let x=await Ae(f,e,g,t.roots.get(f.path));"failure"in x?u.push(x.failure):i.push(x.job)}let d=await ye({resolved:{sources:a,failures:[],roots:t.roots},target:e.target,options:e.options,force:e.force,...e.output===void 0?{}:{output:e.output}}),l=[...d.jobs,...i],c=l.length>1;c&&r.onProgress?.({completed:0,total:l.length});let p=await I(l,{force:e.force,...e.concurrency===void 0?{}:{concurrency:e.concurrency},...e.maxBytes===void 0?{}:{targetBytes:e.maxBytes},onEvent:S(r,c)});return{kind:"convert",results:p.results,failures:[...t.failures,...u,...d.failures,...p.refusals,...p.unreachable.map(f=>({path:f.job.sources[0].path,error:f.error})),...p.failures],inputBytes:p.inputBytes,outputBytes:p.outputBytes}}async function Ve(e,r={}){try{if(e.kind==="pageop")return await We(e);if(e.kind==="extension-op")return await De(e,r);if(e.kind==="edit")return await qe(e,r);if(e.kind==="preset"){let{runPresetCommand:t}=await import("./preset-command-HORY7KZQ.js");return await t(e)}return e.kind==="compress"?await ze(e,r):await Ge(e,r)}catch(t){if(!v(t))throw t;return b(e.kind,[{path:"",error:t}])}}function He(e,r){let t=T(e.failures);if(r.json)return{exitCode:t,stdout:[JSON.stringify(te(m,e))],stderr:[]};let o=e.results.length===0?[]:e.kind==="pageop"?ve(e):e.results.length===1?xe(e):Pe(e);return{exitCode:t,stdout:o,stderr:O(e.failures,{debug:r.debug})}}function Le(e,r){let t=[{path:"",error:e}],o=T(t);return r.json?{exitCode:o,stdout:[JSON.stringify(re(m,e))],stderr:[]}:{exitCode:o,stdout:[],stderr:O(t,{debug:r.debug})}}async function Ue(e,r){let{runConfig:t}=await import("./config-command-TYNYVUMP.js"),o=await t(e);return r?{exitCode:0,stdout:[JSON.stringify(ne(m,o.config,o.warnings))],stderr:[]}:{exitCode:0,stdout:o.stdout,stderr:[]}}async function Tt(e,r={}){let t=r.json??!1,o="debug"in e?e.debug:!1;try{if(e.kind==="config")return await Ue(e,t);if(e.kind==="clip"){let{runClipCommand:s}=await import("./clip-command-LAVVAHHV.js");return await s(e,{...r,json:t,debug:o})}if(e.kind==="update"){let{runUpdate:s}=await import("./update-command-GMBG7BK6.js"),n=await s(m,{...r.onInstalling?{onInstalling:r.onInstalling}:{}});return{exitCode:0,stdout:t?[JSON.stringify({forge:m,ok:!0,...n.data})]:n.stdout,stderr:[]}}if(e.kind==="uninstall"){let{runUninstall:s}=await import("./entry-UWADO4ND.js"),n=[];return{exitCode:await s(m,i=>n.push(i)),stdout:n,stderr:[]}}if(e.kind==="extensions"){let{runExtensions:s}=await import("./extensions-command-73UGWB6L.js"),n=await s(e,{onDownload:r.onDownload});return{exitCode:0,stdout:t?[JSON.stringify(ae(m,n.data))]:n.stdout,stderr:[]}}if(e.kind==="formats")return t?{exitCode:0,stdout:[JSON.stringify(oe(m,_()))],stderr:[]}:{exitCode:0,stdout:ke(),stderr:[]};if(e.kind==="probe"){let{probes:s,failures:n}=await be(e.inputs),a=T(n);return t?{exitCode:a,stdout:[JSON.stringify(se(m,{probes:s,failures:n}))],stderr:[]}:{exitCode:a,stdout:s.flatMap((i,u)=>[...u>0?[""]:[],...$e(i)]),stderr:O(n,{debug:o})}}if(e.kind==="palette"||e.kind==="scale"){let{runPalette:s,runScale:n}=await import("./colour-AJW2JR3S.js"),a={json:t,colour:r.colour??!1};return e.kind==="palette"?await s(e,a):await n(e,a)}if(e.kind==="transcribe"){let{runTranscribeCommand:s}=await import("./transcribe-command-YUSBCQEQ.js"),n=[],a=[];return{exitCode:await s(e,{out:u=>n.push(u),err:u=>a.push(u)}),stdout:n,stderr:a}}if(e.kind==="shell")return{exitCode:0,stdout:[],stderr:[]};if(e.kind==="watch")throw M("forge watch runs in a terminal until ctrl-c.","Try: forge watch ./images --to webp");return He(await Ve(e,r),{json:t,debug:o})}catch(s){if(!v(s))throw s;return Le(s,{json:t,debug:o})}}export{be as a,Ie as b,T as c,Ve as d,He as e,Tt as f};
3
+ import{a as ie,b as ue,c as pe,d as N,e as de,k as fe,l as le,m as me,o as ge,p as he}from"./chunk-I63TO22X.js";import{a as y}from"./chunk-DERIWZAT.js";import{c as I}from"./chunk-YWKMG5WO.js";import{f as ce,i as j}from"./chunk-LNB5D67B.js";import{e as te,f as re,g as oe,h as se,i as ne,j as ae}from"./chunk-EHARO6IS.js";import{a as F,c as X,d as Z,e as C,f as _,k as ee}from"./chunk-QR6QHTC3.js";import{e as Q}from"./chunk-6L6C3GJU.js";import{d as $}from"./chunk-EEQSUBBL.js";import{n as H,p as L}from"./chunk-KAHWYWNT.js";import{a as U,c as Y,d as E,e as K}from"./chunk-EXLXSKRH.js";import{F as M,G as q,J as G,b as P,c as w,d as v,na as V,p as z,r as k,t as D,w as J}from"./chunk-3UEQ2OX6.js";import{a as h,b as W}from"./chunk-J7FLFHQJ.js";import{a as m}from"./chunk-5BE5XZY5.js";import{a as R}from"./chunk-M66BUNYO.js";import{readFile as Je}from"node:fs/promises";import{dirname as Fe,resolve as Me}from"node:path";async function ye(e){let r=[],t=[...e.resolved.failures];for(let o of e.resolved.sources){let s=F(o);if(!s.includes(e.target)){t.push({path:o.path,error:D(o,e.target,s)});continue}let n={sourcePath:o.path,target:e.target,output:e.output,sourceRoot:e.resolved.roots.get(o.path)},a=E(n);Y(a,o.path)&&e.target!==o.format&&(a=K({...n,suffix:e.target})),r.push({op:"convert",sources:[o],outputs:[a],target:e.target,options:e.options})}return{jobs:r,failures:t}}import{resolve as Ce}from"node:path";function je(e,r=new Set){let t={path:Ce(e.path),kind:e.kind,format:e.format,bytes:e.bytes},o=e.kind==="document"&&e.encrypted===!0,s={targets:F(e).filter(n=>!o||C(n)),actions:ge([e],r).filter(n=>!o||n.id===j.id).map(n=>n.id)};if(e.kind==="image")return{...t,width:e.width,height:e.height,...s};if(e.kind==="media"){let n=e.facts;return{...t,...n?{duration:n.duration}:{},...n?.video?{width:n.video.width,height:n.video.height,fps:n.video.fps}:{},...s}}return{...t,pages:e.pages,encrypted:e.encrypted,...s}}async function be(e){let r=await y(e,{recursive:!1}),{installedExtensionIds:t}=await import("./available-GYIHVSRX.js"),o=await t();return{probes:r.sources.map(s=>je(s,o)),failures:r.failures}}import{dirname as Be}from"node:path";var B=e=>({cwd:e.cwd??process.cwd(),...e.home===void 0?{}:{home:e.home}});function we(e,r){let t=P(Be(e),B(r));return t==="."?"":` in ${t.endsWith("/")?t:`${t}/`}`}function Ie(e,r){let{pct:t,direction:o}=W(e,r);return o==="same"?"same size":`${t}% ${o}`}function xe(e,r={}){let t=e.results[0];if(!t)return[];let o=t.job.sources[0],s=t.job.outputs;if(s.length>1){let a=[`\u2713 ${w(o.path)} \u2192 ${s.length} files${we(s[0],r)}`,` ${s.map(i=>w(i)).join(", ")}`,` ${h(o.bytes)} \u2192 ${h(t.outputBytes)} total`];for(let i of t.warnings)a.push("",`\u26A0 ${i.message}`);return a}let n=[`\u2713 ${w(o.path)} \u2192 ${P(s[0],B(r))}`,` ${h(o.bytes)} \u2192 ${h(t.outputBytes)} \xB7 ${Ie(o.bytes,t.outputBytes)}`];for(let a of t.warnings)n.push("",`\u26A0 ${a.message}`);return n}function Pe(e,r={}){let t=[`\u2713 ${e.results.length} converted`,` ${h(e.inputBytes)} \u2192 ${h(e.outputBytes)} \xB7 ${Ie(e.inputBytes,e.outputBytes)}`];for(let s of e.results)for(let n of s.job.outputs)t.push(` ${P(n,B(r))}`);let o=e.results.flatMap(s=>s.warnings);if(o.length>0){t.push("");for(let s of o)t.push(`\u26A0 ${s.message}`)}return t}function ve(e,r={}){let t=e.results.flatMap(u=>u.job.outputs),o=t.map(u=>w(u)).join(", "),s=t.length===1?"file":"files",n=t[0]===void 0?"":we(t[0],r),a=[`\u2713 ${t.length} ${s} \xB7 ${o}${n}`],i=e.results.flatMap(u=>u.warnings);for(let u of i)a.push("",`\u26A0 ${u.message}`);return a}function O(e,r){if(e.length===0)return[];let t=[];for(let o of e)t.push(...V(o.error,{debug:r.debug}),"");return t}function ke(){let e=new Set(X()),r=new Set(Z()),t=["Formats",""];for(let s of e){let n=R[s],a=r.has(s)?"read and write":"read only";t.push(` ${n.label.padEnd(6)} ${n.extensions.join(" ").padEnd(12)} ${a}`)}let o=[...e].filter(s=>!r.has(s)).map(s=>R[s].label);if(o.length>0){let s=o.join(", "),[n,a]=o.length===1?["is","it"]:["are","them"];t.push("",`${s} ${n} read only because Forge cannot yet write ${a}.`)}return t}function $e(e,r={}){let t=[R[e.format].label,h(e.bytes)];return e.duration!==void 0&&t.push($(e.duration)),e.width!==void 0&&e.height!==void 0&&t.push(`${e.width}\xD7${e.height}`),e.fps!==void 0&&t.push(`${e.fps} fps`),e.pages!==void 0&&t.push(`${e.pages} ${e.pages===1?"page":"pages"}`),e.encrypted&&t.push("password-protected"),[`${P(e.path,B(r))} \xB7 ${t.join(" \xB7 ")}`,` converts to ${e.targets.join(", ")}`,` actions ${e.actions.join(", ")}`]}import{createInterface as Re}from"node:readline";import{PassThrough as Oe}from"node:stream";function Se(e){return new Promise(r=>{let t=Re({input:e,terminal:!1}),o=!1,s=n=>{if(o)return;o=!0,t.close(),e.pause(),e.unref?.(),r(n.replace(/\r$/,""))};t.once("line",s),t.once("close",()=>s(""))})}async function Ee(e){if(e.stdin)return Se(process.stdin);if(!process.stdin.isTTY)return;let r=new Oe,t=Re({input:process.stdin,output:r,terminal:!0});try{return process.stderr.write("Password: "),await new Promise(o=>t.question("",o))}finally{process.stderr.write(`
4
+ `),t.close()}}function T(e){return e.length===0?0:e.some(r=>r.error.code==="invalid-arguments")?2:1}function Ne(e,r){if(e.action==="merge")return{};if(e.action==="rotate")return{degrees:e.rotate};if(e.action==="extract")return{pages:e.pages,separate:e.separate?"many":"one"};if(e.action==="delete")return{pages:e.pages};let t=r.find(a=>a.kind==="document"),o=t?.pages??0,s=e.split;if(!s)throw M("--split needs a mode: every-page, every=N or at=N,N.");if(s.mode==="every-page")return{cuts:fe(o)};if(s.mode==="every-n")return{cuts:le(o,s.n)};let n=Math.max(o-1,0);for(let a of s.after)if(!Number.isInteger(a)||a<1||a>n)throw q(String(a),`"${a}" is outside 1 and ${n} \u2014 ${t?w(t.path):"the document"} has ${o} pages.`,o);return{cuts:s.after.map(a=>a-1)}}function Te(e,r){let t;return()=>r?(t??=Ee({stdin:e}).then(o=>e&&o===""?void 0:o),t):Promise.resolve(void 0)}async function Ae(e,r,t,o){let s;if(e.encrypted){if(s=r.password??await t(),s===void 0)return{failure:{path:e.path,error:J(e.path)}};let i;try{i=await Q(await Je(e.path),s)}catch{return{failure:{path:e.path,error:J(e.path,{attempted:!0})}}}i.destroy()}let n;try{n=j.plan([e],{target:r.target,background:r.options.background,keepMetadata:r.options.keepMetadata,dpi:String(r.dpi??150),...r.options.quality===void 0?{}:{quality:r.options.quality},...r.pages===void 0?{}:{pages:r.pages},...r.output===void 0?{}:{destination:r.output},...o===void 0?{}:{sourceRoot:o}})}catch(i){if(!v(i))throw i;return{failure:{path:e.path,error:i}}}let a=n[0];if(a?.op!=="convert")throw new Error(`convertAction.plan() did not return a convert job for ${e.path}`);return s!==void 0&&(a.options.password=s),{job:a}}function S(e,r){return t=>{if(t.type==="search:attempt"){r||e.onSearch?.(t.rung.dpi===void 0?`attempt ${t.attempt} of ${t.of}`:`${t.rung.dpi} dpi \xB7 attempt ${t.attempt} of ${t.of}`);return}if(t.type==="search:settled"){r&&e.onSearch?.(`${t.completed} of ${t.total} searched`);return}if(!r&&t.type==="job:phase"&&t.progress.phase==="time"){let o=t.progress,s=`${$(o.done)} of ${$(o.total)}`;e.onEncode?.(o.pass?`pass ${o.pass.at} of 2 \xB7 ${s}`:s);return}r&&(t.type==="job:done"||t.type==="job:error")&&e.onProgress?.({completed:t.completed,total:t.total})}}var b=(e,r)=>({kind:e,results:[],failures:r,inputBytes:0,outputBytes:0});async function We(e){let r=await y(e.inputs,{recursive:!1});if(r.sources.length===0)return b("pageop",r.failures);let t=me.find(a=>a.id===e.action);if(!t)throw new Error(`no action registered for "${e.action}"`);let o=r.sources[0]?.path??"";if(!t.appliesTo(r.sources)){let a=he(t,r.sources)??"not available for these files";return b("pageop",[...r.failures,{path:o,error:k(e.action,a)}])}let s;try{s=t.plan(r.sources,Ne(e,r.sources))}catch(a){if(!v(a))throw a;return b("pageop",[...r.failures,{path:o,error:a}])}let n=await I(s,{force:e.force});return{kind:"pageop",results:n.results,failures:[...r.failures,...n.refusals,...n.failures],inputBytes:n.inputBytes,outputBytes:n.outputBytes}}async function ze(e,r){let t=await y(e.inputs,{recursive:e.recursive}),o=[],s=[];for(let i of t.sources){if(!N.appliesTo([i])){s.push({path:i.path,error:z(i)});continue}let u=e.output!==void 0&&!U(e.output)?Me(e.output):void 0,g=e.output===void 0||u!==void 0?Fe(i.path):Fe(E({sourcePath:i.path,target:i.format,output:e.output,sourceRoot:t.roots.get(i.path)})),[d]=N.plan([i],{mode:e.maxBytes===void 0?"quality":"size",...e.quality===void 0?{}:{quality:e.quality},...e.options.media??{},destination:g});d?.op==="convert"&&(u!==void 0&&(d.outputs=[u]),e.dpi!==void 0&&(d.options.dpi=e.dpi),o.push(d))}let n=o.length>1;n&&r.onProgress?.({completed:0,total:o.length});let a=await I(o,{force:e.force,...e.concurrency===void 0?{}:{concurrency:e.concurrency},...e.maxBytes===void 0?{}:{targetBytes:e.maxBytes},onEvent:S(r,n)});return{kind:"compress",results:a.results,failures:[...t.failures,...s,...a.refusals,...a.unreachable.map(i=>({path:i.job.sources[0].path,error:i.error})),...a.failures],inputBytes:a.inputBytes,outputBytes:a.outputBytes}}async function De(e,r){let t=e.kind,o=e.op==="remove-background"?H(e.target):void 0;if(o)return b(t,[{path:"",error:o}]);let{installed:s}=await import("./paths-5XI5L4KW.js"),n=await s(e.op);if(!n)return b(t,[{path:"",error:G(e.op)}]);if(e.op==="boost"&&e.scale!==void 0){let{assetFor:c,catalogEntry:p}=await import("./catalog-YSMT3PXT.js"),f=p("boost"),x=f&&c(f)?.version,A=L(e.scale,n.version,x);if(A)return b(t,[{path:"",error:A}])}let a=await y(e.inputs,{recursive:e.recursive}),i=e.op==="boost"?ue:pe,u=[],g=[];for(let c of a.sources){if(!i.appliesTo([c])){g.push({path:c.path,error:k(e.op,"it works on images, not documents","Try an image such as a JPEG, PNG, WebP or HEIC file.")});continue}let p=ie(c,e.target);if(p){g.push({path:c.path,error:p});continue}u.push(...i.plan([c],{target:e.target,background:e.options.background,keepMetadata:e.options.keepMetadata,...e.scale===void 0?{}:{scale:e.scale},...e.options.quality===void 0?{}:{quality:e.options.quality},...e.output===void 0?{}:{output:e.output},roots:a.roots}))}let d=u.length>1;d&&r.onProgress?.({completed:0,total:u.length});let l=await I(u,{force:e.force,concurrency:1,...r.signal===void 0?{}:{signal:r.signal},onEvent:S(r,d)});return{kind:t,results:l.results,failures:[...a.failures,...g,...l.refusals,...l.failures],inputBytes:l.inputBytes,outputBytes:l.outputBytes}}async function qe(e,r){let t=e.crop!==void 0?"crop":e.resize!==void 0?"resize":"trim",o=e.target===void 0?void 0:ee(e.target,t);if(o)return b(e.kind,[{path:"",error:o}]);let s=await y(e.inputs,{recursive:e.recursive}),n=[],a=[],i=[];for(let p of s.sources)p.kind==="image"&&e.media===void 0?n.push(p):p.kind==="media"&&!e.trim?a.push(p):p.kind==="image"?i.push({path:p.path,error:k("cut","it works on video and sound, not images","Try a video or sound file, such as a MOV, MP4 or WAV.")}):i.push({path:p.path,error:k(t,"it works on images, not documents","Try an image such as a JPEG, PNG, WebP or HEIC file.")});let u=ce(a,{...e.media===void 0?{}:{media:e.media},...e.crop===void 0?{}:{crop:e.crop},...e.resize===void 0?{}:{resize:e.resize},...e.target===void 0?{}:{target:e.target},...e.output===void 0?{}:{output:e.output},roots:s.roots}),d=[...de(n,{trim:e.trim,...e.crop===void 0?{}:{crop:e.crop},...e.resize===void 0?{}:{resize:e.resize},...e.target===void 0?{}:{target:e.target},...e.output===void 0?{}:{output:e.output},roots:s.roots,background:e.options.background,keepMetadata:e.options.keepMetadata,...e.options.quality===void 0?{}:{quality:e.options.quality}}),...u],l=d.length>1;l&&r.onProgress?.({completed:0,total:d.length});let c=await I(d,{force:e.force,...e.concurrency===void 0?{}:{concurrency:e.concurrency},onEvent:S(r,l)});return{kind:e.kind,results:c.results,failures:[...s.failures,...i,...c.refusals,...c.failures],inputBytes:c.inputBytes,outputBytes:c.outputBytes}}async function Ge(e,r){let t=await y(e.inputs,{recursive:e.recursive}),o=f=>f.kind==="document"&&f.format==="pdf",s=C(e.target),n=s?t.sources.filter(o):[],a=s?t.sources.filter(f=>!o(f)):t.sources,i=[],u=[],g=Te(e.passwordStdin??!1,r.interactive??!0);for(let f of n){let x=await Ae(f,e,g,t.roots.get(f.path));"failure"in x?u.push(x.failure):i.push(x.job)}let d=await ye({resolved:{sources:a,failures:[],roots:t.roots},target:e.target,options:e.options,force:e.force,...e.output===void 0?{}:{output:e.output}}),l=[...d.jobs,...i],c=l.length>1;c&&r.onProgress?.({completed:0,total:l.length});let p=await I(l,{force:e.force,...e.concurrency===void 0?{}:{concurrency:e.concurrency},...e.maxBytes===void 0?{}:{targetBytes:e.maxBytes},onEvent:S(r,c)});return{kind:"convert",results:p.results,failures:[...t.failures,...u,...d.failures,...p.refusals,...p.unreachable.map(f=>({path:f.job.sources[0].path,error:f.error})),...p.failures],inputBytes:p.inputBytes,outputBytes:p.outputBytes}}async function Ve(e,r={}){try{if(e.kind==="pageop")return await We(e);if(e.kind==="extension-op")return await De(e,r);if(e.kind==="edit")return await qe(e,r);if(e.kind==="preset"){let{runPresetCommand:t}=await import("./preset-command-HORY7KZQ.js");return await t(e)}return e.kind==="compress"?await ze(e,r):await Ge(e,r)}catch(t){if(!v(t))throw t;return b(e.kind,[{path:"",error:t}])}}function He(e,r){let t=T(e.failures);if(r.json)return{exitCode:t,stdout:[JSON.stringify(te(m,e))],stderr:[]};let o=e.results.length===0?[]:e.kind==="pageop"?ve(e):e.results.length===1?xe(e):Pe(e);return{exitCode:t,stdout:o,stderr:O(e.failures,{debug:r.debug})}}function Le(e,r){let t=[{path:"",error:e}],o=T(t);return r.json?{exitCode:o,stdout:[JSON.stringify(re(m,e))],stderr:[]}:{exitCode:o,stdout:[],stderr:O(t,{debug:r.debug})}}async function Ue(e,r){let{runConfig:t}=await import("./config-command-TYNYVUMP.js"),o=await t(e);return r?{exitCode:0,stdout:[JSON.stringify(ne(m,o.config,o.warnings))],stderr:[]}:{exitCode:0,stdout:o.stdout,stderr:[]}}async function Tt(e,r={}){let t=r.json??!1,o="debug"in e?e.debug:!1;try{if(e.kind==="config")return await Ue(e,t);if(e.kind==="clip"){let{runClipCommand:s}=await import("./clip-command-ANGANJ3B.js");return await s(e,{...r,json:t,debug:o})}if(e.kind==="update"){let{runUpdate:s}=await import("./update-command-GMBG7BK6.js"),n=await s(m,{...r.onInstalling?{onInstalling:r.onInstalling}:{}});return{exitCode:0,stdout:t?[JSON.stringify({forge:m,ok:!0,...n.data})]:n.stdout,stderr:[]}}if(e.kind==="uninstall"){let{runUninstall:s}=await import("./entry-NFR27M33.js"),n=[];return{exitCode:await s(m,i=>n.push(i)),stdout:n,stderr:[]}}if(e.kind==="extensions"){let{runExtensions:s}=await import("./extensions-command-TBOTOP4R.js"),n=await s(e,{onDownload:r.onDownload});return{exitCode:0,stdout:t?[JSON.stringify(ae(m,n.data))]:n.stdout,stderr:[]}}if(e.kind==="formats")return t?{exitCode:0,stdout:[JSON.stringify(oe(m,_()))],stderr:[]}:{exitCode:0,stdout:ke(),stderr:[]};if(e.kind==="probe"){let{probes:s,failures:n}=await be(e.inputs),a=T(n);return t?{exitCode:a,stdout:[JSON.stringify(se(m,{probes:s,failures:n}))],stderr:[]}:{exitCode:a,stdout:s.flatMap((i,u)=>[...u>0?[""]:[],...$e(i)]),stderr:O(n,{debug:o})}}if(e.kind==="palette"||e.kind==="scale"){let{runPalette:s,runScale:n}=await import("./colour-RMOFEV4G.js"),a={json:t,colour:r.colour??!1};return e.kind==="palette"?await s(e,a):await n(e,a)}if(e.kind==="transcribe"){let{runTranscribeCommand:s}=await import("./transcribe-command-YUSBCQEQ.js"),n=[],a=[];return{exitCode:await s(e,{out:u=>n.push(u),err:u=>a.push(u)}),stdout:n,stderr:a}}if(e.kind==="shell")return{exitCode:0,stdout:[],stderr:[]};if(e.kind==="watch")throw M("forge watch runs in a terminal until ctrl-c.","Try: forge watch ./images --to webp");return He(await Ve(e,r),{json:t,debug:o})}catch(s){if(!v(s))throw s;return Le(s,{json:t,debug:o})}}export{be as a,Ie as b,T as c,Ve as d,He as e,Tt as f};
@@ -1,3 +1,3 @@
1
1
  import { createRequire as __forgeCreateRequire } from 'node:module';
2
2
  const require = __forgeCreateRequire(import.meta.url);
3
- import{a,b,c,d}from"./chunk-P6NXFZZP.js";import"./chunk-Y2A3HTKQ.js";import"./chunk-TMQDQLY7.js";import"./chunk-I63TO22X.js";import"./chunk-DERIWZAT.js";import"./chunk-YWKMG5WO.js";import"./chunk-LNB5D67B.js";import"./chunk-BZXDNDPG.js";import"./chunk-EHARO6IS.js";import"./chunk-PSEIJXGT.js";import"./chunk-QR6QHTC3.js";import"./chunk-6L6C3GJU.js";import"./chunk-EEQSUBBL.js";import"./chunk-KAHWYWNT.js";import"./chunk-SMBK6BTC.js";import"./chunk-EXLXSKRH.js";import"./chunk-3UEQ2OX6.js";import"./chunk-J7FLFHQJ.js";import"./chunk-LDKF7KIZ.js";import"./chunk-MV7H3QQY.js";import"./chunk-AAXBN572.js";import"./chunk-HON4OV7M.js";import"./chunk-M66BUNYO.js";import"./chunk-TMUK2DD3.js";export{b as clipLines,a as runClip,d as runClipCommand,c as runUndo};
3
+ import{a,b,c,d}from"./chunk-KAQ5LMYO.js";import"./chunk-WMPQ5T2K.js";import"./chunk-TMQDQLY7.js";import"./chunk-I63TO22X.js";import"./chunk-DERIWZAT.js";import"./chunk-YWKMG5WO.js";import"./chunk-LNB5D67B.js";import"./chunk-BZXDNDPG.js";import"./chunk-EHARO6IS.js";import"./chunk-PSEIJXGT.js";import"./chunk-QR6QHTC3.js";import"./chunk-6L6C3GJU.js";import"./chunk-EEQSUBBL.js";import"./chunk-KAHWYWNT.js";import"./chunk-SMBK6BTC.js";import"./chunk-EXLXSKRH.js";import"./chunk-3UEQ2OX6.js";import"./chunk-J7FLFHQJ.js";import"./chunk-LDKF7KIZ.js";import"./chunk-5BE5XZY5.js";import"./chunk-AAXBN572.js";import"./chunk-HON4OV7M.js";import"./chunk-M66BUNYO.js";import"./chunk-TMUK2DD3.js";export{b as clipLines,a as runClip,d as runClipCommand,c as runUndo};
@@ -1,3 +1,3 @@
1
1
  import { createRequire as __forgeCreateRequire } from 'node:module';
2
2
  const require = __forgeCreateRequire(import.meta.url);
3
- import{h as y,i as O,m as C}from"./chunk-FH3R2YYD.js";import{i as $,k as u,l as S}from"./chunk-IWFVEMDN.js";import{c as k,d as w,f as I}from"./chunk-PBIS2ONZ.js";import{a as h,b as g}from"./chunk-EHARO6IS.js";import"./chunk-PSEIJXGT.js";import{b as m,c as d,h as f,i as p}from"./chunk-QVACE4IE.js";import"./chunk-6L6C3GJU.js";import"./chunk-EEQSUBBL.js";import"./chunk-KAHWYWNT.js";import"./chunk-SMBK6BTC.js";import"./chunk-EXLXSKRH.js";import{c as b,n as x}from"./chunk-3UEQ2OX6.js";import"./chunk-J7FLFHQJ.js";import"./chunk-LDKF7KIZ.js";import{a as l}from"./chunk-MV7H3QQY.js";import"./chunk-M66BUNYO.js";import"./chunk-TMUK2DD3.js";import{resolve as R}from"node:path";var P=({r:t,g:n,b:o},s)=>s?`\x1B[38;2;${t};${n};${o}m\u2588\u2588\x1B[39m `:"";function N(t,n){let o=d(n),s,e=Number.POSITIVE_INFINITY;for(let r of t){let a=(r.centre.L-o.L)**2+(r.centre.a-o.a)**2+(r.centre.b-o.b)**2;a<e&&(e=a,s=r)}return s}async function D(t,n){let{pixels:o}=await C(t.input),s=k(o);if(s.length===0)throw x(t.input);let e=t.inside?N(s,t.inside):void 0,r=e?w(o,e):s;if(t.svg)return{exitCode:0,stdout:[y(b(t.input),r,"light",e?.hex)],stderr:[]};if(n.json){let i=h(l,{source:R(t.input),...e?{inside:e.hex}:{},colours:r.map(c=>({hex:c.hex,rgb:f(c.rgb),oklch:p(c.rgb),share:c.share}))});return{exitCode:0,stdout:[JSON.stringify(i)],stderr:[]}}let a=I(r.map(i=>i.share));return{exitCode:0,stdout:r.map((i,c)=>`${P(i.rgb,n.colour)}${i.hex} ${String(a[c]).padStart(3)}%`),stderr:[]}}async function H(t,n){let o=$(t.colour);if(t.svg)return{exitCode:0,stdout:[O(t.colour,o)],stderr:[]};let s=o.map(e=>({...e,...S(e.rgb)}));if(n.json){let e=g(l,{reference:m(t.colour),steps:s.map(r=>({step:r.step,hex:r.hex,oklch:p(r.rgb),white:r.white,black:r.black}))});return{exitCode:0,stdout:[JSON.stringify(e)],stderr:[]}}return{exitCode:0,stdout:s.map(e=>`${String(e.step).padStart(4)} ${P(e.rgb,n.colour)}${e.hex} white ${e.white.toFixed(1)} ${u(e.white)} \xB7 black ${e.black.toFixed(1)} ${u(e.black)}`),stderr:[]}}export{D as runPalette,H as runScale};
3
+ import{h as y,i as O,m as C}from"./chunk-FH3R2YYD.js";import{i as $,k as u,l as S}from"./chunk-IWFVEMDN.js";import{c as k,d as w,f as I}from"./chunk-PBIS2ONZ.js";import{a as h,b as g}from"./chunk-EHARO6IS.js";import"./chunk-PSEIJXGT.js";import{b as m,c as d,h as f,i as p}from"./chunk-QVACE4IE.js";import"./chunk-6L6C3GJU.js";import"./chunk-EEQSUBBL.js";import"./chunk-KAHWYWNT.js";import"./chunk-SMBK6BTC.js";import"./chunk-EXLXSKRH.js";import{c as b,n as x}from"./chunk-3UEQ2OX6.js";import"./chunk-J7FLFHQJ.js";import"./chunk-LDKF7KIZ.js";import{a as l}from"./chunk-5BE5XZY5.js";import"./chunk-M66BUNYO.js";import"./chunk-TMUK2DD3.js";import{resolve as R}from"node:path";var P=({r:t,g:n,b:o},s)=>s?`\x1B[38;2;${t};${n};${o}m\u2588\u2588\x1B[39m `:"";function N(t,n){let o=d(n),s,e=Number.POSITIVE_INFINITY;for(let r of t){let a=(r.centre.L-o.L)**2+(r.centre.a-o.a)**2+(r.centre.b-o.b)**2;a<e&&(e=a,s=r)}return s}async function D(t,n){let{pixels:o}=await C(t.input),s=k(o);if(s.length===0)throw x(t.input);let e=t.inside?N(s,t.inside):void 0,r=e?w(o,e):s;if(t.svg)return{exitCode:0,stdout:[y(b(t.input),r,"light",e?.hex)],stderr:[]};if(n.json){let i=h(l,{source:R(t.input),...e?{inside:e.hex}:{},colours:r.map(c=>({hex:c.hex,rgb:f(c.rgb),oklch:p(c.rgb),share:c.share}))});return{exitCode:0,stdout:[JSON.stringify(i)],stderr:[]}}let a=I(r.map(i=>i.share));return{exitCode:0,stdout:r.map((i,c)=>`${P(i.rgb,n.colour)}${i.hex} ${String(a[c]).padStart(3)}%`),stderr:[]}}async function H(t,n){let o=$(t.colour);if(t.svg)return{exitCode:0,stdout:[O(t.colour,o)],stderr:[]};let s=o.map(e=>({...e,...S(e.rgb)}));if(n.json){let e=g(l,{reference:m(t.colour),steps:s.map(r=>({step:r.step,hex:r.hex,oklch:p(r.rgb),white:r.white,black:r.black}))});return{exitCode:0,stdout:[JSON.stringify(e)],stderr:[]}}return{exitCode:0,stdout:s.map(e=>`${String(e.step).padStart(4)} ${P(e.rgb,n.colour)}${e.hex} white ${e.white.toFixed(1)} ${u(e.white)} \xB7 black ${e.black.toFixed(1)} ${u(e.black)}`),stderr:[]}}export{D as runPalette,H as runScale};
@@ -2,5 +2,5 @@ import { createRequire as __forgeCreateRequire } from 'node:module';
2
2
  const require = __forgeCreateRequire(import.meta.url);
3
3
  import{a as N,b as $,c as k,d as h,f,g as p,h as _}from"./chunk-6FUVEO3A.js";import{c as E}from"./chunk-QXTXBMTM.js";import{a as D,b as T,c as A,d as F,e as R}from"./chunk-JFJ3ZJQL.js";import{c as x}from"./chunk-EX7KZBI6.js";import{f as P}from"./chunk-EXLXSKRH.js";import{d as b}from"./chunk-3UEQ2OX6.js";import"./chunk-J7FLFHQJ.js";import{a as w}from"./chunk-HON4OV7M.js";import"./chunk-M66BUNYO.js";import"./chunk-5B5XXH22.js";import"./chunk-TMUK2DD3.js";import{spawn as X}from"node:child_process";import{homedir as ge}from"node:os";import{join as M}from"node:path";import{appendFileSync as V,mkdirSync as O,readFileSync as K,renameSync as Y,rmSync as y,statSync as G}from"node:fs";import{join as C}from"node:path";var Z={quiet:500,cap:3e3,poll:50},ee=15e3,I=e=>new Promise(t=>setTimeout(t,e));async function j(e,t,n,r=Z){O(e,{recursive:!0});let i=C(e,`${t}.spool`),o=C(e,`${t}.lock`),s=m=>{try{return K(m,"utf8").split(`
4
4
  `).filter(Boolean)}catch{return[]}},u=()=>{try{return G(i).size}catch{return 0}};for(V(i,`${n}
5
- `);;){try{O(o)}catch{try{Date.now()-G(o).mtimeMs>ee&&y(o,{recursive:!0,force:!0})}catch{}if(await I(r.poll),!s(i).includes(n))return null;continue}try{let m=Date.now(),c=u(),l=Date.now();for(;Date.now()-l<r.quiet&&Date.now()-m<r.cap;){await I(r.poll);let S=u();S!==c&&(c=S,l=Date.now())}let a=`${i}.${process.pid}.${Date.now()}`;try{Y(i,a)}catch{return[n]}let g=[...new Set(s(a))];return y(a,{force:!0}),g}finally{y(o,{recursive:!0,force:!0})}}}import{realpathSync as ne}from"node:fs";import{delimiter as te,join as re}from"node:path";function q(e,t,n=process.platform){let r=s=>{try{return ne(s)}catch{return}},i=r(e)??e,o=n==="win32"?"node.exe":"node";for(let s of(t??"").split(te)){if(s==="")continue;let u=re(s,o);if(u!==e&&r(u)===i)return u}return e}import{basename as v,dirname as ie,extname as oe,join as se}from"node:path";function ae(e,t,n){if(n==="win32")return e==="wt"?["wt.exe",["-w","new",...t]]:["conhost.exe",t];if(e==="ghostty")return["/usr/bin/open",["-na","Ghostty","--args","-e",...t]];let r=`exec ${t.map(N).join(" ")}`;return["/usr/bin/osascript",[...["on run argv",...e==="iTerm.app"?['tell application "iTerm"',"create window with default profile","tell current session of current window to write text (item 1 of argv)","activate","end tell"]:['if application "Terminal" is running then','tell application "Terminal" to do script (item 1 of argv)',"else",'tell application "Terminal" to do script (item 1 of argv) in window 1',"end if",'tell application "Terminal" to activate'],"end run"].flatMap(o=>["-e",o]),r]]}function H(e){let t=v(e,oe(e));return P(se(ie(e),`${t}-sharp.png`))}function ue(e){let t=e.flatMap(o=>"output"in o?[o.output]:[]),n=e.flatMap(o=>"error"in o?[o]:[]),[r]=n;if(r===void 0)return{title:t.length===1?v(t[0]):`${t.length} files`,body:"Sharpened"};let i=r.input?v(r.input):"file";return e.length===1?{title:`${i} not sharpened`,body:r.error}:{title:`${t.length} of ${e.length} files sharpened`,body:`${i}: ${r.error}`}}async function U(e,t,n){if(e==="sharpen"){let s=[];for(let a of t){let g=await n.sharpen(a);s.push("error"in g?{input:a,...g}:g)}let{title:u,body:m}=ue(s);await n.notify(u,m);let l=s.flatMap(a=>"output"in a?[a.output]:[]).at(-1);l!==void 0&&await n.reveal(l);return}let r=e==="open"?[]:t,[i,o]=ae(n.terminal,[...n.self,"menu","open",e,...r],n.platform);await n.launch(i,o)}import{mkdirSync as le,readFileSync as ce,writeFileSync as me}from"node:fs";import{join as pe}from"node:path";async function B(e,t){if(!t.global||e.platform!=="darwin"&&e.platform!=="win32")return;let n=h(e);if(t.enabled===!1){n!==void 0&&await p(e);return}if(!(n!==void 0&&k(n,e))&&(await f(e),n===void 0))return e.platform==="darwin"?"Added Forge to Finder\u2019s Quick Actions":"Added Forge to the right-click menu"}async function J(e){let t=h(e);if(t===void 0)return;let{xdgConfigHome:n,...r}=e;await f({...r,...t})}var L=e=>pe(e.menuDir,"terminal"),fe=new Set(["Apple_Terminal","iTerm.app","ghostty"]);function z(e,t){let n=e.platform==="win32"?t.WT_SESSION?"wt":"console":fe.has(t.TERM_PROGRAM??"")?t.TERM_PROGRAM:void 0;if(n)try{le(e.menuDir,{recursive:!0}),me(L(e),n)}catch{}}function Q(e){try{return ce(L(e),"utf8").trim()||void 0}catch{return}}import{rmSync as de}from"node:fs";async function W(e,t){await p(e),t.out("\u2713 Removed Forge from the right-click menu");let{code:n,output:r}=await t.npm(["uninstall","--global","forge-terminal"]);return n!==0?(t.out(`\u2715 npm could not uninstall forge-terminal: ${R(r)}`),1):(t.out("\u2713 Uninstalled forge-terminal"),de(t.forgeDir,{recursive:!0,force:!0}),t.out("\u2713 Deleted Forge\u2019s settings"),0)}var we=()=>M(w(),"forge","menu");async function d(e){return{platform:process.platform,home:ge(),menuDir:we(),node:q(process.execPath,process.env.PATH),execArgv:process.execArgv,forge:T(process.argv[1])??"",...process.env.XDG_CONFIG_HOME?{xdgConfigHome:process.env.XDG_CONFIG_HOME}:{},version:e,sharpen:await x("boost")!==void 0,run:_}}async function Ye(e){if(process.env.FORGE_NO_MENU)return;let t=await d(e);z(t,process.env);let{loadPreferences:n}=await import("./preferences-4VETUGMN.js"),{prefs:r}=await n();return B(t,{global:D(t.forge,t.platform),enabled:r.rightClickMenu!==!1})}async function Ze(){let{isInstalled:e}=await import("./install-2A5BGKQU.js");return e(await d(""))}async function en(e){let{VERSION:t}=await import("./theme-USWAYNEH.js"),{savePreferences:n}=await import("./preferences-4VETUGMN.js"),r=await d(t);e?await f(r):await p(r),await n({rightClickMenu:e})}async function nn(){if(!process.env.FORGE_NO_MENU)try{await J(await d(""))}catch{}}async function he(e){let{parseArgs:t}=await import("./args-ZMSJ3NBZ.js"),{runIntent:n}=await import("./execute-MUM63CAA.js"),r=t([e,"--sharpen","--output",H(e)]),i=await n(r),o=i.results[0]?.job.outputs[0];if(o!==void 0)return{output:o};let s=i.failures[0]?.error;return{error:b(s)?s.detail:"It could not be sharpened."}}var ye=(e,t)=>new Promise(n=>{let r=X(e,t,{detached:!0,stdio:"ignore"});r.on("error",()=>n()),r.unref(),n()});async function tn(e,t){let n=await d(t);if(e.kind==="install")return await f(n),0;if(e.kind==="remove")return await p(n),0;if(e.kind!=="run")return 2;let r=e.paths;if(n.platform==="win32"&&r.length===1){let i=await j(M(n.menuDir,"spool"),e.action,r[0]);if(i===null)return 0;r=i}return await U(e.action,r,{platform:n.platform,self:[n.node,...n.execArgv,n.forge],terminal:Q(n),launch:ye,sharpen:he,notify:(i,o)=>$(i,o,n.platform),reveal:async i=>{await E(i,n.platform)}}),0}async function rn(e,t){let n=await d(e),r=i=>new Promise(o=>{let s=n.platform==="win32"?F(n.node):void 0,[u,m]=s!==void 0?[n.node,[s,...i]]:[A(n.node),i],c="",l=X(u,m,{stdio:["ignore","pipe","pipe"]});l.stdout.setEncoding("utf8").on("data",a=>{c+=a}),l.stderr.setEncoding("utf8").on("data",a=>{c+=a}),l.on("error",a=>o({code:null,output:`${c}
5
+ `);;){try{O(o)}catch{try{Date.now()-G(o).mtimeMs>ee&&y(o,{recursive:!0,force:!0})}catch{}if(await I(r.poll),!s(i).includes(n))return null;continue}try{let m=Date.now(),c=u(),l=Date.now();for(;Date.now()-l<r.quiet&&Date.now()-m<r.cap;){await I(r.poll);let S=u();S!==c&&(c=S,l=Date.now())}let a=`${i}.${process.pid}.${Date.now()}`;try{Y(i,a)}catch{return[n]}let g=[...new Set(s(a))];return y(a,{force:!0}),g}finally{y(o,{recursive:!0,force:!0})}}}import{realpathSync as ne}from"node:fs";import{delimiter as te,join as re}from"node:path";function q(e,t,n=process.platform){let r=s=>{try{return ne(s)}catch{return}},i=r(e)??e,o=n==="win32"?"node.exe":"node";for(let s of(t??"").split(te)){if(s==="")continue;let u=re(s,o);if(u!==e&&r(u)===i)return u}return e}import{basename as v,dirname as ie,extname as oe,join as se}from"node:path";function ae(e,t,n){if(n==="win32")return e==="wt"?["wt.exe",["-w","new",...t]]:["conhost.exe",t];if(e==="ghostty")return["/usr/bin/open",["-na","Ghostty","--args","-e",...t]];let r=`exec ${t.map(N).join(" ")}`;return["/usr/bin/osascript",[...["on run argv",...e==="iTerm.app"?['tell application "iTerm"',"create window with default profile","tell current session of current window to write text (item 1 of argv)","activate","end tell"]:['if application "Terminal" is running then','tell application "Terminal" to do script (item 1 of argv)',"else",'tell application "Terminal" to do script (item 1 of argv) in window 1',"end if",'tell application "Terminal" to activate'],"end run"].flatMap(o=>["-e",o]),r]]}function H(e){let t=v(e,oe(e));return P(se(ie(e),`${t}-sharp.png`))}function ue(e){let t=e.flatMap(o=>"output"in o?[o.output]:[]),n=e.flatMap(o=>"error"in o?[o]:[]),[r]=n;if(r===void 0)return{title:t.length===1?v(t[0]):`${t.length} files`,body:"Sharpened"};let i=r.input?v(r.input):"file";return e.length===1?{title:`${i} not sharpened`,body:r.error}:{title:`${t.length} of ${e.length} files sharpened`,body:`${i}: ${r.error}`}}async function U(e,t,n){if(e==="sharpen"){let s=[];for(let a of t){let g=await n.sharpen(a);s.push("error"in g?{input:a,...g}:g)}let{title:u,body:m}=ue(s);await n.notify(u,m);let l=s.flatMap(a=>"output"in a?[a.output]:[]).at(-1);l!==void 0&&await n.reveal(l);return}let r=e==="open"?[]:t,[i,o]=ae(n.terminal,[...n.self,"menu","open",e,...r],n.platform);await n.launch(i,o)}import{mkdirSync as le,readFileSync as ce,writeFileSync as me}from"node:fs";import{join as pe}from"node:path";async function B(e,t){if(!t.global||e.platform!=="darwin"&&e.platform!=="win32")return;let n=h(e);if(t.enabled===!1){n!==void 0&&await p(e);return}if(!(n!==void 0&&k(n,e))&&(await f(e),n===void 0))return e.platform==="darwin"?"Added Forge to Finder\u2019s Quick Actions":"Added Forge to the right-click menu"}async function J(e){let t=h(e);if(t===void 0)return;let{xdgConfigHome:n,...r}=e;await f({...r,...t})}var L=e=>pe(e.menuDir,"terminal"),fe=new Set(["Apple_Terminal","iTerm.app","ghostty"]);function z(e,t){let n=e.platform==="win32"?t.WT_SESSION?"wt":"console":fe.has(t.TERM_PROGRAM??"")?t.TERM_PROGRAM:void 0;if(n)try{le(e.menuDir,{recursive:!0}),me(L(e),n)}catch{}}function Q(e){try{return ce(L(e),"utf8").trim()||void 0}catch{return}}import{rmSync as de}from"node:fs";async function W(e,t){await p(e),t.out("\u2713 Removed Forge from the right-click menu");let{code:n,output:r}=await t.npm(["uninstall","--global","forge-terminal"]);return n!==0?(t.out(`\u2715 npm could not uninstall forge-terminal: ${R(r)}`),1):(t.out("\u2713 Uninstalled forge-terminal"),de(t.forgeDir,{recursive:!0,force:!0}),t.out("\u2713 Deleted Forge\u2019s settings"),0)}var we=()=>M(w(),"forge","menu");async function d(e){return{platform:process.platform,home:ge(),menuDir:we(),node:q(process.execPath,process.env.PATH),execArgv:process.execArgv,forge:T(process.argv[1])??"",...process.env.XDG_CONFIG_HOME?{xdgConfigHome:process.env.XDG_CONFIG_HOME}:{},version:e,sharpen:await x("boost")!==void 0,run:_}}async function Ye(e){if(process.env.FORGE_NO_MENU)return;let t=await d(e);z(t,process.env);let{loadPreferences:n}=await import("./preferences-4VETUGMN.js"),{prefs:r}=await n();return B(t,{global:D(t.forge,t.platform),enabled:r.rightClickMenu!==!1})}async function Ze(){let{isInstalled:e}=await import("./install-2A5BGKQU.js");return e(await d(""))}async function en(e){let{VERSION:t}=await import("./theme-BJRL3INU.js"),{savePreferences:n}=await import("./preferences-4VETUGMN.js"),r=await d(t);e?await f(r):await p(r),await n({rightClickMenu:e})}async function nn(){if(!process.env.FORGE_NO_MENU)try{await J(await d(""))}catch{}}async function he(e){let{parseArgs:t}=await import("./args-5XWINYYE.js"),{runIntent:n}=await import("./execute-JY372YAC.js"),r=t([e,"--sharpen","--output",H(e)]),i=await n(r),o=i.results[0]?.job.outputs[0];if(o!==void 0)return{output:o};let s=i.failures[0]?.error;return{error:b(s)?s.detail:"It could not be sharpened."}}var ye=(e,t)=>new Promise(n=>{let r=X(e,t,{detached:!0,stdio:"ignore"});r.on("error",()=>n()),r.unref(),n()});async function tn(e,t){let n=await d(t);if(e.kind==="install")return await f(n),0;if(e.kind==="remove")return await p(n),0;if(e.kind!=="run")return 2;let r=e.paths;if(n.platform==="win32"&&r.length===1){let i=await j(M(n.menuDir,"spool"),e.action,r[0]);if(i===null)return 0;r=i}return await U(e.action,r,{platform:n.platform,self:[n.node,...n.execArgv,n.forge],terminal:Q(n),launch:ye,sharpen:he,notify:(i,o)=>$(i,o,n.platform),reveal:async i=>{await E(i,n.platform)}}),0}async function rn(e,t){let n=await d(e),r=i=>new Promise(o=>{let s=n.platform==="win32"?F(n.node):void 0,[u,m]=s!==void 0?[n.node,[s,...i]]:[A(n.node),i],c="",l=X(u,m,{stdio:["ignore","pipe","pipe"]});l.stdout.setEncoding("utf8").on("data",a=>{c+=a}),l.stderr.setEncoding("utf8").on("data",a=>{c+=a}),l.on("error",a=>o({code:null,output:`${c}
6
6
  ${a.message}`})),l.on("close",a=>o({code:a,output:c}))});return W(n,{forgeDir:M(w(),"forge"),npm:r,out:t})}export{Ye as menuAtStart,Ze as menuIsOn,d as realMenuEnv,nn as resyncMenu,tn as runMenuCommand,rn as runUninstall,en as switchMenu};
@@ -1,3 +1,3 @@
1
1
  import { createRequire as __forgeCreateRequire } from 'node:module';
2
2
  const require = __forgeCreateRequire(import.meta.url);
3
- import{c as a,d as b,e as c,f as d}from"./chunk-Y2A3HTKQ.js";import"./chunk-I63TO22X.js";import"./chunk-DERIWZAT.js";import"./chunk-YWKMG5WO.js";import"./chunk-LNB5D67B.js";import"./chunk-BZXDNDPG.js";import"./chunk-EHARO6IS.js";import"./chunk-PSEIJXGT.js";import"./chunk-QR6QHTC3.js";import"./chunk-6L6C3GJU.js";import"./chunk-EEQSUBBL.js";import"./chunk-KAHWYWNT.js";import"./chunk-SMBK6BTC.js";import"./chunk-EXLXSKRH.js";import"./chunk-3UEQ2OX6.js";import"./chunk-J7FLFHQJ.js";import"./chunk-LDKF7KIZ.js";import"./chunk-MV7H3QQY.js";import"./chunk-AAXBN572.js";import"./chunk-HON4OV7M.js";import"./chunk-M66BUNYO.js";import"./chunk-TMUK2DD3.js";export{d as execute,a as exitCodeFor,c as renderRun,b as runIntent};
3
+ import{c as a,d as b,e as c,f as d}from"./chunk-WMPQ5T2K.js";import"./chunk-I63TO22X.js";import"./chunk-DERIWZAT.js";import"./chunk-YWKMG5WO.js";import"./chunk-LNB5D67B.js";import"./chunk-BZXDNDPG.js";import"./chunk-EHARO6IS.js";import"./chunk-PSEIJXGT.js";import"./chunk-QR6QHTC3.js";import"./chunk-6L6C3GJU.js";import"./chunk-EEQSUBBL.js";import"./chunk-KAHWYWNT.js";import"./chunk-SMBK6BTC.js";import"./chunk-EXLXSKRH.js";import"./chunk-3UEQ2OX6.js";import"./chunk-J7FLFHQJ.js";import"./chunk-LDKF7KIZ.js";import"./chunk-5BE5XZY5.js";import"./chunk-AAXBN572.js";import"./chunk-HON4OV7M.js";import"./chunk-M66BUNYO.js";import"./chunk-TMUK2DD3.js";export{d as execute,a as exitCodeFor,c as renderRun,b as runIntent};
@@ -1,3 +1,3 @@
1
1
  import { createRequire as __forgeCreateRequire } from 'node:module';
2
2
  const require = __forgeCreateRequire(import.meta.url);
3
- import{jb as a,kb as b,lb as c,mb as d,nb as e}from"./chunk-BCNMRALN.js";import"./chunk-IWFVEMDN.js";import"./chunk-PBIS2ONZ.js";import"./chunk-BZXDNDPG.js";import"./chunk-IBPGC4N2.js";import"./chunk-QVACE4IE.js";import"./chunk-EEQSUBBL.js";import"./chunk-3UEQ2OX6.js";import"./chunk-J7FLFHQJ.js";import"./chunk-MV7H3QQY.js";import"./chunk-M66BUNYO.js";import"./chunk-5B5XXH22.js";import"./chunk-TMUK2DD3.js";export{e as ExtensionsFlow,c as byteCount,b as extensionCredits,d as extensionsChip,a as realManager};
3
+ import{jb as a,kb as b,lb as c,mb as d,nb as e}from"./chunk-E55PYOCI.js";import"./chunk-IWFVEMDN.js";import"./chunk-PBIS2ONZ.js";import"./chunk-BZXDNDPG.js";import"./chunk-IBPGC4N2.js";import"./chunk-QVACE4IE.js";import"./chunk-EEQSUBBL.js";import"./chunk-3UEQ2OX6.js";import"./chunk-J7FLFHQJ.js";import"./chunk-5BE5XZY5.js";import"./chunk-M66BUNYO.js";import"./chunk-5B5XXH22.js";import"./chunk-TMUK2DD3.js";export{e as ExtensionsFlow,c as byteCount,b as extensionCredits,d as extensionsChip,a as realManager};
@@ -1,3 +1,3 @@
1
1
  import { createRequire as __forgeCreateRequire } from 'node:module';
2
2
  const require = __forgeCreateRequire(import.meta.url);
3
- import{a as c}from"./chunk-J7FLFHQJ.js";import{c as d}from"./chunk-5B5XXH22.js";import"./chunk-TMUK2DD3.js";function f(e){let t=Object.entries(e.assets).find(([n])=>n.startsWith(`${process.platform}-`));return d(e)?.version??t?.[1]?.version??""}function y(e){return{id:e.entry.id,title:e.entry.title,summary:e.entry.summary,version:f(e.entry),licence:e.entry.licence,installed:e.installed??null,updateAvailable:e.updateAvailable,supported:e.supported,...e.reason!==void 0?{reason:e.reason}:{},...e.downloadBytes!==void 0?{downloadBytes:e.downloadBytes}:{}}}function x(e){return e.supported?e.installed===void 0?`not installed${e.downloadBytes?`, ${c(e.downloadBytes)} download`:""}`:e.updateAvailable?`installed ${e.installed}, update to ${d(e.entry)?.version} available`:`installed ${e.installed}`:`not available: ${e.reason??"unsupported here"}`}function E(e){let t=Math.max(...e.map(n=>n.entry.id.length));return e.flatMap((n,a)=>[...a>0?[""]:[],`${n.entry.id.padEnd(t)} ${n.entry.summary}`,`${" ".repeat(t)} ${x(n)}`,`${" ".repeat(t)} ${n.entry.licence}`])}async function g(e,t={}){let{installExtension:n,listExtensions:a,removeExtension:p}=await import("./manager-743RM57Z.js"),i,s;if(e.action==="add"&&e.id!==void 0){let o=(await a()).find(m=>m.entry.id===e.id),l=o?.installed!==void 0&&!o.updateAvailable,u=await n(e.id,{onProgress:t.onDownload});i={id:e.id,action:l?"unchanged":"added"},s=l?`${e.id} ${u.version} is already installed`:`Installed ${e.id} ${u.version}`}else if(e.action==="remove"&&e.id!==void 0){let o=await p(e.id);i={id:e.id,action:o?"removed":"unchanged"},s=o?`Removed ${e.id}`:`${e.id} was not installed`}let r=await a();return{stdout:s===void 0?E(r):[s],data:{extensions:r.map(y),...i?{changed:i}:{}}}}export{g as runExtensions,y as toExtensionJson};
3
+ import{a as c}from"./chunk-J7FLFHQJ.js";import{c as d}from"./chunk-5B5XXH22.js";import"./chunk-TMUK2DD3.js";function f(e){let t=Object.entries(e.assets).find(([n])=>n.startsWith(`${process.platform}-`));return d(e)?.version??t?.[1]?.version??""}function y(e){return{id:e.entry.id,title:e.entry.title,summary:e.entry.summary,version:f(e.entry),licence:e.entry.licence,installed:e.installed??null,updateAvailable:e.updateAvailable,supported:e.supported,...e.reason!==void 0?{reason:e.reason}:{},...e.downloadBytes!==void 0?{downloadBytes:e.downloadBytes}:{}}}function x(e){return e.supported?e.installed===void 0?`not installed${e.downloadBytes?`, ${c(e.downloadBytes)} download`:""}`:e.updateAvailable?`installed ${e.installed}, update to ${d(e.entry)?.version} available`:`installed ${e.installed}`:`not available: ${e.reason??"unsupported here"}`}function E(e){let t=Math.max(...e.map(n=>n.entry.id.length));return e.flatMap((n,a)=>[...a>0?[""]:[],`${n.entry.id.padEnd(t)} ${n.entry.summary}`,`${" ".repeat(t)} ${x(n)}`,`${" ".repeat(t)} ${n.entry.licence}`])}async function g(e,t={}){let{installExtension:n,listExtensions:a,removeExtension:p}=await import("./manager-DLXGO25L.js"),i,s;if(e.action==="add"&&e.id!==void 0){let o=(await a()).find(m=>m.entry.id===e.id),l=o?.installed!==void 0&&!o.updateAvailable,u=await n(e.id,{onProgress:t.onDownload});i={id:e.id,action:l?"unchanged":"added"},s=l?`${e.id} ${u.version} is already installed`:`Installed ${e.id} ${u.version}`}else if(e.action==="remove"&&e.id!==void 0){let o=await p(e.id);i={id:e.id,action:o?"removed":"unchanged"},s=o?`Removed ${e.id}`:`${e.id} was not installed`}let r=await a();return{stdout:s===void 0?E(r):[s],data:{extensions:r.map(y),...i?{changed:i}:{}}}}export{g as runExtensions,y as toExtensionJson};