forge-terminal 0.3.9 → 0.4.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 (93) hide show
  1. package/README.md +70 -10
  2. package/dist/chunks/{about-credits-NCKQZJMR.js → about-credits-6D6B2JTS.js} +1 -1
  3. package/dist/chunks/{available-QN6QAGCU.js → available-HYL2YE56.js} +1 -1
  4. package/dist/chunks/boot-IQ4NYHEG.js +3 -0
  5. package/dist/chunks/{catalog-O3V24DK7.js → catalog-U7IF2BH2.js} +1 -1
  6. package/dist/chunks/check-INHBJOBB.js +3 -0
  7. package/dist/chunks/{chunk-4QQEJ6YG.js → chunk-26NDEWOQ.js} +1 -1
  8. package/dist/chunks/chunk-2CK4RFPI.js +3 -0
  9. package/dist/chunks/chunk-3A43GEIR.js +4 -0
  10. package/dist/chunks/{chunk-SAWVMQAD.js → chunk-4LTI6JHW.js} +1 -1
  11. package/dist/chunks/chunk-5GJK5LP5.js +4 -0
  12. package/dist/chunks/chunk-6TERL22R.js +3 -0
  13. package/dist/chunks/chunk-6V6WEBUI.js +66 -0
  14. package/dist/chunks/chunk-6VOCIMXQ.js +3 -0
  15. package/dist/chunks/{chunk-32VJ2RDH.js → chunk-7ZI3PFFX.js} +1 -1
  16. package/dist/chunks/chunk-BLPVRO4J.js +19 -0
  17. package/dist/chunks/chunk-BXJ2HTKI.js +3 -0
  18. package/dist/chunks/{chunk-ZRP5CWIK.js → chunk-C2OZ5ERA.js} +1 -1
  19. package/dist/chunks/chunk-CBE73ZWA.js +3 -0
  20. package/dist/chunks/{chunk-TEO2EUS3.js → chunk-CLQHW4EF.js} +1 -1
  21. package/dist/chunks/chunk-D6JPP65L.js +3 -0
  22. package/dist/chunks/chunk-DW2EJIUX.js +3 -0
  23. package/dist/chunks/{chunk-3GVFOZ7M.js → chunk-EHARO6IS.js} +1 -1
  24. package/dist/chunks/{chunk-I6QBBRCE.js → chunk-FKPXXNKX.js} +1 -1
  25. package/dist/chunks/chunk-FWMFN36F.js +3 -0
  26. package/dist/chunks/chunk-HBDVKP3X.js +5 -0
  27. package/dist/chunks/chunk-HCN4BH2H.js +3 -0
  28. package/dist/chunks/chunk-ILWGG424.js +4 -0
  29. package/dist/chunks/chunk-IMC5NRDC.js +3 -0
  30. package/dist/chunks/chunk-JBSYGB3F.js +3 -0
  31. package/dist/chunks/chunk-MHW4OOQW.js +4 -0
  32. package/dist/chunks/chunk-OVILZLVA.js +3 -0
  33. package/dist/chunks/chunk-PGG2OTK6.js +3 -0
  34. package/dist/chunks/chunk-PSEIJXGT.js +3 -0
  35. package/dist/chunks/chunk-SS7HNRZ5.js +3 -0
  36. package/dist/chunks/chunk-SVDVVRVP.js +3 -0
  37. package/dist/chunks/chunk-XNNTF6FW.js +3 -0
  38. package/dist/chunks/{chunk-MBTGANIR.js → chunk-Z2LELLNV.js} +1 -1
  39. package/dist/chunks/chunk-ZONIA7SX.js +21 -0
  40. package/dist/chunks/clip-command-Q6SLD4U4.js +3 -0
  41. package/dist/chunks/colour-JPG24QYI.js +3 -0
  42. package/dist/chunks/config-command-R7QOBYF4.js +3 -0
  43. package/dist/chunks/execute-B7UL5RCU.js +3 -0
  44. package/dist/chunks/extensions-UR4GS47P.js +3 -0
  45. package/dist/chunks/{extensions-command-UGXZIFRI.js → extensions-command-AITZYSMM.js} +1 -1
  46. package/dist/chunks/image-KWRJIHQQ.js +3 -0
  47. package/dist/chunks/install-WBAFPZ2Q.js +3 -0
  48. package/dist/chunks/launch-RM5ZVXSU.js +4 -0
  49. package/dist/chunks/lock-GOOLFLSO.js +3 -0
  50. package/dist/chunks/manager-KZJ7WC34.js +4 -0
  51. package/dist/chunks/{paths-H2WS22BA.js → paths-KTXPDCDD.js} +1 -1
  52. package/dist/chunks/preferences-AUFJSKMJ.js +3 -0
  53. package/dist/chunks/preset-command-AXYFLVYA.js +3 -0
  54. package/dist/chunks/restart-TL76JEPU.js +3 -0
  55. package/dist/chunks/run-4Z6CRNHJ.js +4 -0
  56. package/dist/chunks/{server-XOMQGAIG.js → server-RM4YA6UL.js} +16 -15
  57. package/dist/chunks/{theme-ZSHECPGW.js → theme-LR72ACFF.js} +1 -1
  58. package/dist/chunks/transcribe-command-6YTLVSMW.js +3 -0
  59. package/dist/chunks/update-command-2SHKIIQD.js +3 -0
  60. package/dist/chunks/update-note-UH2TQPJ6.js +3 -0
  61. package/dist/chunks/watch-command-NU7QY6QU.js +3 -0
  62. package/dist/helpers/forge-transcribe +0 -0
  63. package/dist/index.js +42 -33
  64. package/package.json +29 -1
  65. package/skills/forge/SKILL.md +7 -0
  66. package/dist/chunks/boot-ZJLZZHA7.js +0 -3
  67. package/dist/chunks/check-BRP6EKSA.js +0 -3
  68. package/dist/chunks/chunk-3V4DKIWP.js +0 -66
  69. package/dist/chunks/chunk-C7YNQXXO.js +0 -3
  70. package/dist/chunks/chunk-DVJAGA5L.js +0 -19
  71. package/dist/chunks/chunk-F4ZPFXWD.js +0 -4
  72. package/dist/chunks/chunk-GGBNT4WI.js +0 -3
  73. package/dist/chunks/chunk-GNLE6JXL.js +0 -3
  74. package/dist/chunks/chunk-H2IUSPAK.js +0 -4
  75. package/dist/chunks/chunk-J3VS5AUZ.js +0 -4
  76. package/dist/chunks/chunk-LW2QEXDT.js +0 -3
  77. package/dist/chunks/chunk-MMRDELHW.js +0 -3
  78. package/dist/chunks/chunk-X54KIHCN.js +0 -4
  79. package/dist/chunks/chunk-YILLB45O.js +0 -3
  80. package/dist/chunks/colour-54Z3FBNN.js +0 -3
  81. package/dist/chunks/config-command-TXQUYFA6.js +0 -3
  82. package/dist/chunks/execute-4OBEIICQ.js +0 -3
  83. package/dist/chunks/extensions-7RTIGFIG.js +0 -3
  84. package/dist/chunks/image-F5D73JPQ.js +0 -3
  85. package/dist/chunks/install-YG43OJ7P.js +0 -3
  86. package/dist/chunks/launch-2I52TGLD.js +0 -4
  87. package/dist/chunks/lock-6KTGUFBY.js +0 -3
  88. package/dist/chunks/manager-XN7WNMEW.js +0 -4
  89. package/dist/chunks/preferences-YL6SRNZR.js +0 -3
  90. package/dist/chunks/restart-RO6DM5N3.js +0 -3
  91. package/dist/chunks/run-XQYPVWFI.js +0 -4
  92. package/dist/chunks/update-command-6VNVMAYO.js +0 -3
  93. package/dist/chunks/update-note-MJPR4GHH.js +0 -3
@@ -0,0 +1,3 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ import{A as nt,B as st,C as it,G as T,H as at,I as ct,N as pt,o as Q,p as X,r as j,u as tt,v as b,w,x as et,y as rt,z as ot}from"./chunk-D6JPP65L.js";import{d as m}from"./chunk-7ZI3PFFX.js";import{$ as K,G as D,H as N,J as V,N as Y,W as Z,c as S,d as R,ea as $,w as x}from"./chunk-DW2EJIUX.js";import{a as I}from"./chunk-BXJ2HTKI.js";import{readFile as Rt,rm as $t}from"node:fs/promises";var Tt=new Set(["pdf"]),At=new Set(["jpeg","png"]),Lt=new Set(["convert"]),ft;function Jt(){return ft??=et().then(t=>t.PDFiumLibrary.init()),ft}async function dt(t,e){return await(await Jt()).loadDocument(t,e)}async function ut(t){let e=await dt(t);try{let r=[];for(let o=0;o<e.getPageCount();o++)r.push(e.getPage(o).getText());return r}finally{e.destroy()}}var mt={id:"pdfium",reads:Tt,writes:At,ops:Lt,probe(){throw new Error("pdfium does not probe; engines/pdf.ts classifies PDFs")},async run(t,e){if(t.op!=="convert")throw new Error(`pdfium cannot ${t.op}`);let r=t.sources[0];if(r.kind!=="document")throw new Error("the pdfium engine can only rasterise a document source");if(r.encrypted&&t.options.password===void 0)throw x(r.path);let o=t.options.dpi??150,s=t.options.pages??Array.from({length:r.pages},(i,c)=>c);if(s.length!==t.outputs.length)throw new Error(`pdfium was given ${s.length} pages but ${t.outputs.length} outputs`);for(let i of s)if(i<0||i>=r.pages)throw new Error(`pdfium was asked for page ${i}, but ${r.path} has ${r.pages} pages`);let n=await b(),a=await dt(await Rt(r.path),t.options.password);try{let i=[],c=0;try{for(let[p,f]of s.entries()){let d=await a.getPage(f).render({scale:o/72,render:"bitmap",transparent:!0}),u=n(d.data,{raw:{width:d.width,height:d.height,channels:4}}).flatten({background:t.options.background}),l=await T(u,t.target,t.options.quality).toBuffer(),h=t.outputs[p];c+=await m(h,l),i.push(h),e({phase:"page",done:p+1,total:s.length})}}catch(p){throw await Promise.all(i.map(f=>$t(f,{force:!0}))),p}return{job:t,outputBytes:c,warnings:[]}}finally{a.destroy()}}};import{mkdtemp as kt,rm as Bt}from"node:fs/promises";import{tmpdir as Nt}from"node:os";import{join as A}from"node:path";var lt=(t,e,r)=>j(t,e,r)===void 0;function gt(t,e,r=Number.POSITIVE_INFINITY,o=[2,4]){return[...o].reverse().find(s=>s<r&&lt(t,e,s))??0}async function Ot(t,e,r){if(t.op!=="boost"&&t.op!=="remove-background")throw new Error(`the extension engine cannot ${t.op}`);if(r?.aborted)throw r.reason??new Error("aborted");let o=t.sources[0],s=t.outputs[0],n=t.op,{assetFor:a,catalogEntry:i,offeredHere:c}=await import("./catalog-U7IF2BH2.js");if(!c(n))throw Y(i(n)?.title??n);let{installed:p,extensionsRoot:f}=await import("./paths-KTXPDCDD.js"),d=await p(n);if(!d)throw V(n);let u=Q(d.version);if(t.op==="boost"){let g=i(n),P=X(t.scale,d.version,g&&a(g)?.version);if(P)throw P}if(t.op==="boost"&&!lt(o.width,o.height,t.scale))throw Z(o.path,gt(o.width,o.height,Number.POSITIVE_INFINITY,u),t.scale);let{runExtension:l}=await import("./run-4Z6CRNHJ.js"),h=[];o.frames>1&&h.push({code:"animation-flattened",message:`${S(o.path)} has ${o.frames} frames. Only the first frame was used.`});let v=await kt(A(Nt(),"forge-ext-"));try{e({phase:"decoding"});let g=A(v,"in.png"),P=A(v,"out.png");await ct(o,g);let St=t.op==="boost"?["--in",g,"--out",P,"--scale",String(t.scale),"--cache",A(f(),"boost","cache")]:[g,P];await l(d,St,{subject:o.path,what:`${Wt(t)} is running on ${S(o.path)}`,onWait:()=>e({phase:"waiting"}),onStart:()=>e({phase:"encoding"}),...t.op==="boost"?{maxScale:gt(o.width,o.height,t.scale,u)}:{},...r===void 0?{}:{signal:r}});let B=(await b())(P);I[t.target].hasAlpha||(B=B.flatten({background:t.options.background}));let It=await T(B,t.target,t.options.quality).toBuffer();e({phase:"writing"});let Dt=await at(It,s);return{job:t,outputBytes:Dt,warnings:h}}catch(g){throw R(g)?g:$(o.path,g)}finally{await Bt(v,{recursive:!0,force:!0}).catch(()=>{})}}function Wt(t){return t.op!=="boost"?"Remove background":t.scale===1?"Sharpen":`Boost resolution ${t.scale}\xD7`}var wt={id:"extension",reads:new Set,writes:new Set,ops:new Set(["boost","remove-background"]),probe:()=>Promise.reject(new Error("the extension engine reads no files")),run:Ot};import{readFile as L,rm as Pt,stat as _t}from"node:fs/promises";function qe(t,e){let r=t.split(",").map(n=>n.trim()).filter(n=>n!=="");if(r.length===0)throw D(t,"That selects no pages.",e);let o=new Set,s=(n,a)=>{if(!Number.isInteger(n)||n<1||n>e)throw D(a,`"${a}" is outside 1 and ${e}.`,e);return n};for(let n of r){let a=n.match(/^(\d+)\s*-\s*(\d*)$/);if(a?.[1]!==void 0){let i=s(Number(a[1]),n),c=a[2]===""?e:s(Number(a[2]),n);if(c<i)throw D(n,`"${n}" ends before it starts.`,e);for(let p=i;p<=c;p++)o.add(p-1);continue}if(!/^\d+$/.test(n))throw D(n,`"${n}" is not a page number.`,e);o.add(s(Number(n),n)-1)}return[...o].sort((n,a)=>n-a)}function ht(t){return[...new Set(t)].sort((e,r)=>e-r)}function Ue(t){if(t.length===0)return"";let e=[...new Set(t)].sort((n,a)=>n-a),r=[],o=e[0],s=o;for(let n of e.slice(1)){if(n===s+1){s=n;continue}r.push(o===s?`${o+1}`:`${o+1}-${s+1}`),o=n,s=n}return r.push(o===s?`${o+1}`:`${o+1}-${s+1}`),r.join(", ")}function yt(t,e){let r=[...new Set(t)].sort((n,a)=>n-a).filter(n=>n>=0&&n<e-1),o=[],s=0;for(let n of r)o.push({from:s,to:n}),s=n+1;return o.push({from:s,to:e-1}),o}var W=tt(()=>import("./pdf-compress-IMRFBLZF.js")),Ct=new Set(["pdf","jpeg","png","webp","avif","gif","tiff"]),Gt=new Set(["pdf"]);async function E(t){return(await w()).PDFDocument.load(await L(t),{ignoreEncryption:!0})}async function Mt(t){let{surveyDocument:e}=await W(),r=await E(t),{size:o}=await _t(t);return{kind:"document",path:t,format:"pdf",bytes:o,pages:r.getPageCount(),encrypted:r.isEncrypted,images:e(r)}}function F(t){for(let e of t)if(e.encrypted)throw x(e.path)}async function zt(t,e,r){let o=await b(),s=e.format==="jpeg"||e.format==="png",n=s?(await o(r).metadata()).orientation:void 0;if(s&&(n===void 0||n===1))return e.format==="jpeg"?t.embedJpg(r):t.embedPng(r);if(e.format==="jpeg"){let a=await o(r).rotate().jpeg({quality:I.jpeg.defaultQuality,mozjpeg:!0}).toBuffer();return t.embedJpg(a)}return t.embedPng(await o(r).rotate().png().toBuffer())}async function qt(t,e){let r=t.sources[0];if(r.kind!=="image")throw new Error("the pdf engine cannot embed a document source");let o=[];r.frames>1&&o.push({code:"animation-flattened",message:`${S(r.path)} has ${r.frames} frames, and ${I.pdf.label} cannot animate. Only the first frame was converted.`}),e({phase:"reading"});let s=await L(r.path);e({phase:"encoding"});let a=await(await w()).PDFDocument.create(),i=await zt(a,r,s);a.addPage([i.width,i.height]).drawImage(i,{x:0,y:0,width:i.width,height:i.height}),e({phase:"writing"});let p=await m(t.outputs[0],await a.save());return{job:t,outputBytes:p,warnings:o}}async function Ut(t,e){F(t.sources.filter(a=>a.kind==="document"));let o=await(await w()).PDFDocument.create();for(let a of t.sources){e({phase:"reading"});let i=await E(a.path),c=await o.copyPages(i,i.getPageIndices());for(let p of c)o.addPage(p)}e({phase:"writing"});let s=await o.save(),n=await m(t.outputs[0],s);return{job:t,outputBytes:n,warnings:[]}}async function Ht(t,e){let r=t.sources[0];F([r]);let o=await w();e({phase:"reading"});let s=await E(r.path),n=yt(t.cuts,s.getPageCount()),a=[],i=0;try{for(let[c,p]of n.entries()){let f=await o.PDFDocument.create(),d=Array.from({length:p.to-p.from+1},(h,v)=>p.from+v),u=await f.copyPages(s,d);for(let h of u)f.addPage(h);let l=t.outputs[c];if(l===void 0)throw new Error(`split produced ${n.length} parts but was given ${t.outputs.length} outputs`);i+=await m(l,await f.save()),a.push(l),e({phase:"page",done:c+1,total:n.length})}}catch(c){throw await Promise.all(a.map(p=>Pt(p,{force:!0}))),c}return{job:t,outputBytes:i,warnings:[]}}async function O(t,e){let o=await(await w()).PDFDocument.create(),s=await o.copyPages(t,e);for(let n of s)o.addPage(n);return o.save()}async function Vt(t,e){let r=t.sources[0];if(F([r]),t.pages.length===0)throw N("That extract selects no pages.");e({phase:"reading"});let o=await E(r.path),s=ht(t.pages),n=[],a=0;try{if(t.separate)for(let[i,c]of s.entries()){let p=t.outputs[i];a+=await m(p,await O(o,[c])),n.push(p),e({phase:"page",done:i+1,total:s.length})}else{e({phase:"writing"});let i=t.outputs[0];a=await m(i,await O(o,s)),n.push(i)}}catch(i){throw await Promise.all(n.map(c=>Pt(c,{force:!0}))),i}return{job:t,outputBytes:a,warnings:[]}}async function Yt(t,e){let r=t.sources[0];F([r]),e({phase:"reading"});let o=await E(r.path),s=new Set(t.pages),n=o.getPageIndices().filter(i=>!s.has(i));if(n.length===0)throw N("That would delete every page.");e({phase:"writing"});let a=await m(t.outputs[0],await O(o,n));return{job:t,outputBytes:a,warnings:[]}}async function Zt(t,e){let r=t.sources[0];F([r]);let o=await w();e({phase:"reading"});let s=await E(r.path);for(let a of s.getPages()){let c=((a.getRotation().angle+t.turns*90)%360+360)%360;a.setRotation(o.degrees(c))}e({phase:"writing"});let n=await m(t.outputs[0],await s.save());return{job:t,outputBytes:n,warnings:[]}}async function Kt(t,e){let r=t.sources[0];F([r]);let{compressPdf:o}=await W();e({phase:"reading"});let s=await L(r.path);e({phase:"encoding"});let{bytes:n,recompressed:a,skipped:i,fromDpi:c,toDpi:p}=await o(s,{quality:t.options.quality??60,dpi:t.options.dpi??150});if(t.options.compress&&n.length>=r.bytes)throw K(r.path,r.bytes,n.length);e({phase:"writing"});let f=await m(t.outputs[0],n),d=l=>l===1?"":"s",u=[];return a===0&&i===0?u.push({code:"pdf-no-images",message:"This PDF has no images to re-encode, so its size is almost unchanged."}):a===0?u.push({code:"pdf-no-images",message:`None of its ${i} image${d(i)} could be re-encoded \u2014 they are not JPEG data.`}):i>0&&u.push({code:"pdf-images-skipped",message:`${a} image${d(a)} recompressed, ${i} skipped (not JPEG).`}),c!==void 0&&p!==void 0&&u.push({code:"pdf-downsampled",message:`Images reduced from ${c} to ${p} dpi. Pass --dpi ${c} to keep them.`}),{job:t,outputBytes:f,warnings:u}}async function Qt(t){if(t.op!=="convert")return;let e=t.sources[0];if(e.kind!=="document")return;let{compressPdf:r}=await W(),o=await L(e.path);return{ladder:[t.options.dpi??150,120,96,72].map(s=>({dpi:s})),measure:async s=>(await r(o,{quality:s.quality??60,...s.dpi===void 0?{}:{dpi:s.dpi}})).bytes.byteLength}}var xt={id:"pdf",measurer:Qt,reads:Ct,writes:Gt,ops:new Set(["convert","merge","split","extract","delete","rotate"]),probe:Mt,async run(t,e){switch(t.op){case"convert":if(t.target!=="pdf")throw new Error("the pdf engine only converts to pdf");return t.sources[0].kind==="document"?Kt(t,e):qt(t,e);case"merge":return Ut(t,e);case"split":return Ht(t,e);case"extract":return Vt(t,e);case"delete":return Yt(t,e);case"rotate":return Zt(t,e);default:throw new Error(`the pdf engine cannot ${t.op}`)}}};import{execFile as Xt}from"node:child_process";import{mkdtemp as jt,readFile as q,rm as te}from"node:fs/promises";import{tmpdir as ee}from"node:os";import{basename as re,extname as oe,join as bt,win32 as M}from"node:path";import{pathToFileURL as ne}from"node:url";import{promisify as se}from"node:util";var z=se(Xt),_=Buffer.from([208,207,17,224,161,177,26,225]);async function ie(t){if(t.length<_.length||!t.subarray(0,_.length).equals(_))return!1;let e=await st();try{return e.find(e.parse(t),"WordDocument")!==null}catch{return!1}}async function ae(t){let e=await nt();try{let r=new e(t);if(!r.getEntry("word/document.xml"))return;let o=0,s=r.getEntry("docProps/app.xml");if(s){let n=/<Pages>(\d+)<\/Pages>/.exec(r.readAsText(s));n?.[1]&&(o=Number(n[1]))}return{pages:o}}catch{return}}async function ce(t){let e=await q(t),r=await ae(e);if(r)return{kind:"document",path:t,format:"docx",bytes:e.byteLength,pages:r.pages,encrypted:!1};if(await ie(e))return{kind:"document",path:t,format:"doc",bytes:e.byteLength,pages:0,encrypted:!1};throw new Error(`${t} is not a Word document`)}function pe(t,e){return t==="win32"?[M.join(e.ProgramFiles??"C:\\Program Files","LibreOffice","program","soffice.exe"),M.join(e["ProgramFiles(x86)"]??"C:\\Program Files (x86)","LibreOffice","program","soffice.exe")]:["/Applications/LibreOffice.app/Contents/MacOS/soffice"]}var fe=0;async function de(){fe++;try{return await z("soffice",["--version"],{timeout:5e3}),"soffice"}catch{}for(let t of pe(process.platform,process.env))try{return await z(t,["--version"],{timeout:5e3}),t}catch{}}var Et,ue=!1,me;async function ge(){return ue?me:(Et??=de(),Et)}var U="\f";function J(t){return t.split(/\r?\n/).map(e=>e.trim()).filter(e=>e.length>0)}async function le(t){if(t.format==="docx"){let r=await rt(),{value:o}=await r.extractRawText({path:t.path});return J(o)}if(t.format==="doc"){let r=await ot(),s=await new r().extract(t.path);return J(s.getBody())}return(await ut(await q(t.path))).flatMap((r,o)=>o===0?J(r):[U,...J(r)])}var C=612,k=792,y=54,G=11,Ft=14;async function we(t){let{PDFDocument:e,StandardFonts:r}=await w(),o=await e.create(),s=await o.embedFont(r.Helvetica),n=C-y*2,a=o.addPage([C,k]),i=k-y,c=()=>{a=o.addPage([C,k]),i=k-y};for(let p of t){if(p===U){c();continue}let f="";for(let d of p.split(/\s+/).filter(Boolean)){let u=f?`${f} ${d}`:d;f&&s.widthOfTextAtSize(u,G)>n?(i<y&&c(),a.drawText(f,{x:y,y:i,size:G,font:s}),i-=Ft,f=d):f=u}f&&(i<y&&c(),a.drawText(f,{x:y,y:i,size:G,font:s}),i-=Ft)}return o.save()}async function he(t){let{Document:e,Packer:r,PageBreak:o,Paragraph:s}=await it(),n=t.map(i=>i===U?new s({children:[new o]}):new s(i)),a=new e({sections:[{children:n}]});return r.toBuffer(a)}var ye=new Set(["docx","doc","pdf"]),Pe=new Set(["docx","pdf"]),xe=new Set(["convert"]),be={code:"word-basic-fidelity",message:"Converted with basic formatting only \u2014 tables, images, and complex layouts weren't preserved. Install LibreOffice for full-fidelity conversion: brew install --cask libreoffice"};function Ee(t=process.platform){return t!=="win32"?be:{code:"word-basic-fidelity",message:"Converted with basic formatting only \u2014 tables, images, and complex layouts weren't preserved. Install LibreOffice from libreoffice.org for full-fidelity conversion."}}function Fe(t,e,r,o=process.platform){return[`-env:UserInstallation=${o==="win32"?ne(M.join(t,"profile"),{windows:!0}).href:`file://${t}/profile`}`,"--headless","--convert-to",r,"--outdir",t,e]}async function ve(t,e,r){let o=await jt(bt(ee(),"forge-word-"));try{await z(t,Fe(o,e,r),{timeout:12e4});let s=re(e,oe(e));return await q(bt(o,`${s}.${r}`))}finally{await te(o,{recursive:!0,force:!0})}}async function Se(t,e){if(t.op!=="convert")throw new Error(`the word engine cannot ${t.op}`);let r=t.sources[0];if(r.kind!=="document")throw new Error("the word engine can only convert a document source");if(r.encrypted)throw x(r.path);e({phase:"reading"});let o=await ge();e({phase:"encoding"});let s=[],n;try{if(o!==void 0)n=await ve(o,r.path,t.target);else{let i=await le(r);n=t.target==="pdf"?await we(i):await he(i),s.push(Ee())}}catch(i){throw $(r.path,i)}e({phase:"writing"});let a=await m(t.outputs[0],n);return{job:t,outputBytes:a,warnings:s}}var vt={id:"word",reads:ye,writes:Pe,ops:xe,probe:ce,run:Se};var H=[pt,xt,vt,wt,mt];function yr(t){if(t.op==="convert"){let e=t.sources[0].format;return H.find(r=>r.reads.has(e)&&r.writes.has(t.target))}return H.find(e=>e.ops.has(t.op))}async function Pr(t){let e;for(let r of H)try{return await r.probe(t)}catch(o){R(e)||(e=o)}throw e}export{qe as a,ht as b,Ue as c,yt as d,dt as e,mt as f,H as g,yr as h,Pr as i};
@@ -1,3 +1,3 @@
1
1
  import { createRequire as __forgeCreateRequire } from 'node:module';
2
2
  const require = __forgeCreateRequire(import.meta.url);
3
- import{E as s,F as a,G as m}from"./chunk-MMRDELHW.js";import{randomBytes as f}from"node:crypto";import{constants as u}from"node:fs";import{access as d,mkdir as p,rename as w,rm as S,writeFile as h}from"node:fs/promises";import{dirname as y}from"node:path";async function P(t){let e=y(t);try{await p(e,{recursive:!0})}catch(r){let i=a(t,r);throw i===r?m(t,r):i}try{await d(e,u.W_OK)}catch(r){throw s(t,r)}}var A=new Set(["EPERM","EBUSY","EACCES"]),N=5,M=9;async function T(t,e,r=process.platform,i=o=>new Promise(n=>setTimeout(n,o)),E=N){if(r!=="win32"){await w(t,e);return}for(let o=1;;o++)try{await w(t,e);return}catch(n){let c=n.code;if(o>=E||!c||!A.has(c))throw n;await i(Math.min(50*2**(o-1),1e3))}}async function O(t,e){await P(t);let r=`${t}.${f(6).toString("hex")}.tmp`;try{return await h(r,e),await T(r,t),e.byteLength}catch(i){throw await S(r,{force:!0}).catch(()=>{}),a(t,i)}}export{P as a,M as b,T as c,O as d};
3
+ import{B as s,C as a,D as m}from"./chunk-DW2EJIUX.js";import{randomBytes as f}from"node:crypto";import{constants as u}from"node:fs";import{access as d,mkdir as p,rename as w,rm as S,writeFile as h}from"node:fs/promises";import{dirname as y}from"node:path";async function P(t){let e=y(t);try{await p(e,{recursive:!0})}catch(r){let i=a(t,r);throw i===r?m(t,r):i}try{await d(e,u.W_OK)}catch(r){throw s(t,r)}}var A=new Set(["EPERM","EBUSY","EACCES"]),N=5,M=9;async function T(t,e,r=process.platform,i=o=>new Promise(n=>setTimeout(n,o)),E=N){if(r!=="win32"){await w(t,e);return}for(let o=1;;o++)try{await w(t,e);return}catch(n){let c=n.code;if(o>=E||!c||!A.has(c))throw n;await i(Math.min(50*2**(o-1),1e3))}}async function O(t,e){await P(t);let r=`${t}.${f(6).toString("hex")}.tmp`;try{return await h(r,e),await T(r,t),e.byteLength}catch(i){throw await S(r,{force:!0}).catch(()=>{}),a(t,i)}}export{P as a,M as b,T as c,O as d};
@@ -0,0 +1,19 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ import{a as $,h as lt,i as D}from"./chunk-Z2LELLNV.js";import{b as x,c as R,d as H,f as v,g as P,h as X}from"./chunk-QVACE4IE.js";import{i as it}from"./chunk-6VOCIMXQ.js";import{D as at,E as st,v as ot}from"./chunk-D6JPP65L.js";import{d as tt,m as et,o as nt,u as rt}from"./chunk-DW2EJIUX.js";import{a as Z}from"./chunk-BXJ2HTKI.js";var xt=[[15,"rose"],[45,"red"],[70,"orange"],[95,"amber"],[120,"yellow"],[140,"lime"],[165,"green"],[185,"teal"],[215,"cyan"],[250,"sky"],[280,"blue"],[295,"indigo"],[315,"violet"],[340,"purple"],[355,"pink"],[360,"rose"]];function w(t){let{C:e,h:n}=v(R(t));return e<.03?"grey":_(n)}function _(t){let e=(t%360+360)%360;return(xt.find(([n])=>e<n)??[360,"rose"])[1]}var Tt=["full","mono","analogous","opposite","split","triad","pastel"],ct={full:"Full set",mono:"Monochromatic",analogous:"Analogous",opposite:"Complementary",split:"Split complementary",triad:"Triadic",pastel:"Pastel"},B={brightness:0,saturation:0,hue:0,contrast:0},At=t=>!!(t.brightness||t.saturation||t.hue||t.contrast),G=[{name:"red",hex:{r:251,g:44,b:54},role:"danger"},{name:"orange",hex:{r:255,g:105,b:0}},{name:"yellow",hex:{r:239,g:177,b:0},role:"warning"},{name:"green",hex:{r:0,g:201,b:80},role:"success"},{name:"teal",hex:{r:0,g:187,b:167}},{name:"blue",hex:{r:43,g:127,b:255},role:"info"},{name:"purple",hex:{r:173,g:70,b:255}},{name:"pink",hex:{r:246,g:51,b:154}}],$t={analogous:[-30,0,30],opposite:[0,180],split:[0,150,210],triad:[0,120,240]},wt=.553,yt=.024,b=t=>v(R(t)),C=(t,e,n)=>H(P({L:t,C:Math.max(0,e),h:(n+360)%360})),K=(t,e)=>(t-e+540)%360-180;function ht(t,e,n){let r=P({L:t,C:e,h:n}),a=R(H(r));return Math.hypot(a.L-r.L,a.a-r.a,a.b-r.b)<.003}function L(t,e){let n=0,r=.4;for(let a=0;a<30;a++){let o=(n+r)/2;ht(t,o,e)?n=o:r=o}return n}function W({L:t,C:e,h:n}){let r=L(t,n);return r>0?Math.min(1,e/r):0}var A=(t,e)=>e>=0?t+(.98-t)*(e/100):t+(t-.05)*(e/100),q=(t,e,n)=>n>=0?t+(Math.max(t,e)-t)*(n/100):t*(1+n/100);function T(t,e){if(!(e.brightness||e.saturation||e.hue))return t;let{L:n,C:r,h:a}=b(t),o=A(n,e.brightness),i=(a+e.hue+360)%360,l=q(r,L(o,i),e.saturation);for(let s=0;s<40&&l>0&&!ht(o,l,i);s++)l-=.005;return C(o,l,i)}function k(t,e,n,r){let a=A(t,r.brightness),o=(n+r.hue+360)%360,i=L(a,o);return C(a,Math.min(i,q(e,i,r.saturation)),o)}function Y(t,e,n){if(!e)return t;let r=b(t[n].rgb).L;return t.map((a,o)=>{if(o===n)return a;let i=b(a.rgb),l=Math.max(.02,Math.min(.995,r+(i.L-r)*(1+e/100))),s=C(l,Math.min(i.C,L(l,i.h)),i.h);return{...a,rgb:s,hex:x(s)}})}function Et(t,e,n,r){return Y(t(T(e,n)),n.contrast,r)}function ut(t,e){let n=b(t),r=G.map(s=>b(s.hex)),a=0;r.forEach((s,c)=>{Math.abs(K(n.h,s.h))<Math.abs(K(n.h,r[a].h))&&(a=c)});let o=r[a],i=Math.max(-10,Math.min(10,K(n.h,o.h)/2)),l=W(n);return G.map((s,c)=>{if(c===a)return{name:s.name,role:s.role,rgb:T(t,e),yours:!0};let h=r[c],p=n.L>=o.L?h.L+(n.L-o.L)*(1-h.L)/(1-o.L):h.L*n.L/o.L,f=A(p,e.brightness),g=(h.h+i+e.hue+360)%360,d=L(f,g),u=Math.min(1,W(h)),S=Math.min(d,q(l*u*d,d,e.saturation));return{name:s.name,role:s.role,rgb:C(f,S,g),yours:!1}})}function St(t,e,n){let r=b(t),a=w(t);if(e==="mono")return[{name:a,rgb:T(t,n),yours:!0},{name:`${a} soft`,rgb:k(r.L,r.C*.5,r.h,n),yours:!1},{name:`${a} dusty`,rgb:k(r.L,r.C*.22,r.h,n),yours:!1}];if(e==="pastel")return ut(t,B).map((l,s)=>{let c=b(l.rgb),h=c.C<.01?b(G[s].hex).h:c.h;return{...l,rgb:k(.86,Math.min(.1,L(.86,h))*.85,h,n)}});let o=W(r);return($t[e]??[0]).map(l=>{if(l===0)return{name:a,rgb:T(t,n),yours:!0};let s=(r.h+l+360)%360,c=o*L(r.L,s);return{name:o>0?_(s):w(k(r.L,c,s,B)),rgb:k(r.L,c,s,n),yours:!1}}).sort((l,s)=>Number(s.yours)-Number(l.yours))}function Lt(t,e,n){let r=b(t).h+e.hue,a=Math.max(0,yt*(1+e.saturation/100));return D(C(A(wt,e.brightness),a,r),n)}function Ot(t,e,n=B,r=$){let a=lt(r);return{rows:(e==="full"?ut(t,n):St(t,e,n)).map(({name:l,role:s,rgb:c,yours:h})=>({name:l,...s?{role:s}:{},steps:Y(D(c,r),n.contrast,a),yours:h})),neutral:Y(Lt(t,n,r),n.contrast,a)}}var M=t=>t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),E=t=>t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"colour",y='font-family="Inter"',O=t=>`${t[0]?.toUpperCase()??""}${t.slice(1)}`;function mt(t){let e=t==="dark";return{ink:e?"#FAFAFA":"#111111",grey:e?"#A1A1AA":"#71717A",edge:e?"#FFFFFF":"#000000",paper:e?"#18181B":"#FFFFFF"}}var Mt=`<defs><pattern id="checker" width="16" height="16" patternUnits="userSpaceOnUse"><rect width="16" height="16" fill="#FFFFFF"/><rect width="8" height="8" fill="#E5E5E5"/><rect x="8" y="8" width="8" height="8" fill="#E5E5E5"/></pattern></defs>
4
+ `;function I(t,e,n,r="light"){let{ink:a,grey:o,edge:i,paper:l}=mt(r),s=n.length>8?64:104,c=10,h=48+n.length*s+Math.max(0,n.length-1)*c,p=84+s+56,f=s>80?12:10,g=`<text id="title" x="24" y="38" ${y} font-size="15" font-weight="600" fill="${a}">${M(t)}</text><text id="subtitle" x="24" y="58" ${y} font-size="12" fill="${o}">${M(e)}</text>`,d=n.map((u,S)=>`<g id="${E(u.id)}" transform="translate(${24+S*(s+c)} 80)">`+(u.alpha===void 0?"":`<rect id="checker" width="${s}" height="${s}" rx="${f}" fill="url(#checker)"/>`)+`<rect id="swatch" width="${s}" height="${s}" rx="${f}" fill="${u.hex}"`+(u.alpha===void 0?"":` fill-opacity="${u.alpha.toFixed(3)}"`)+` stroke="${i}" stroke-opacity="0.08"/><text id="name" x="1" y="${s+22}" ${y} font-size="13" font-weight="600" fill="${a}">${M(u.name)}</text><text id="value" x="1" y="${s+40}" ${y} font-size="11" fill="${o}">${M(u.value)}</text></g>`).join(`
5
+ `);return`<svg xmlns="http://www.w3.org/2000/svg" width="${h}" height="${p}" viewBox="0 0 ${h} ${p}">
6
+ `+(n.some(u=>u.alpha!==void 0)?Mt:"")+`<g id="${E(t)}">
7
+ <rect id="card" width="${h}" height="${p}" rx="0" fill="${l}"/>
8
+ ${g}
9
+ ${d}
10
+ </g>
11
+ </svg>`}function Ht(t,e,n="light",r){let a=t.replace(/\.[^.]+$/,""),o=e.length;return I(t,r?`${o} shade${o===1?"":"s"} of ${r}`:`${o} colour${o===1?"":"s"}, most of the image first`,e.map((i,l)=>({id:`${a}-${l+1}`,name:i.hex,value:X(i.rgb),hex:i.hex})),n)}function N(t){if(t.set==="radix")return"Radix 1\u201312";if(t.set==="even")return`${t.start}\u2013${t.end}, ${t.count} even steps`;let e=$;return t.start===e.start&&t.end===e.end?"50\u2013950":`Tailwind ${t.start}\u2013${t.end}`}function Pt(t,e,n="light",r=$){let a=w(t);return I(O(a),`from ${x(t)} \xB7 ${N(r)} in OKLCH`,e.map(o=>({id:`${a}-${o.step}`,name:String(o.step),value:o.hex,hex:o.hex})),n)}function Dt(t,e,n,r=$,a="light"){let{ink:o,grey:i,edge:l,paper:s}=mt(a),c=`${O(w(t))} palette`,h=`from ${x(t)} \xB7 ${ct[n]} \xB7 ${N(r)} in OKLCH`,p=[...e.rows.map(m=>({name:m.name,steps:m.steps})),{name:"neutral",steps:e.neutral}],f=p[0]?.steps.map(m=>m.step)??[],g=44,d=6,u=g+10,S=92,z=24+Math.max(92,...p.map(m=>m.name.length*8+12)),gt=z+f.length*g+Math.max(0,f.length-1)*d+24,U=Math.max(gt,48+Math.ceil(h.length*6.5)),j=S+p.length*u+24+10,pt=`<text id="title" x="24" y="38" ${y} font-size="15" font-weight="600" fill="${o}">${M(c)}</text><text id="subtitle" x="24" y="58" ${y} font-size="12" fill="${i}">${M(h)}</text>`,ft=f.map((m,F)=>`<text id="step-${m}" x="${z+F*(g+d)+1}" y="${S-10}" ${y} font-size="11" font-weight="600" fill="${i}">${m}</text>`).join(""),dt=p.map((m,F)=>{let J=S+F*u+(F===p.length-1?10:0),Q=E(m.name);return`<g id="${Q}"><text id="name" x="24" y="${J+g/2+4}" ${y} font-size="13" font-weight="600" fill="${o}">${M(m.name)}</text>`+m.steps.map((V,bt)=>`<g id="${Q}-${V.step}"><rect id="swatch" x="${z+bt*(g+d)}" y="${J}" width="${g}" height="${g}" rx="8" fill="${V.hex}" stroke="${l}" stroke-opacity="0.08"/></g>`).join("")+"</g>"}).join(`
12
+ `);return`<svg xmlns="http://www.w3.org/2000/svg" width="${U}" height="${j}" viewBox="0 0 ${U} ${j}">
13
+ <g id="${E(c)}">
14
+ <rect id="card" width="${U}" height="${j}" rx="0" fill="${s}"/>
15
+ ${pt}
16
+ <g id="steps">${ft}</g>
17
+ ${dt}
18
+ </g>
19
+ </svg>`}function _t(t,e,n,r="light",a=$){return I(`${O(w(t))} neutral`,`from ${x(t)} \xB7 ${n} tint \xB7 ${N(a)} in OKLCH`,e.map(o=>({id:`neutral-${o.step}`,name:String(o.step),value:o.hex,hex:o.hex})),r)}function Kt(t,e,n,r="light",a=$){let o=w(t);return I(`${O(o)} alpha`,`from ${x(t)} \xB7 over ${n} \xB7 ${N(a)}`,e.map(i=>({id:`${o}-alpha-${i.step}`,name:String(i.step),value:i.hex8,hex:x(i.rgb),alpha:i.a})),r)}async function Qt(t,e=192){let n=await it(t);if(n.kind!=="image")throw et(t,`a ${Z[n.format].label}`);let r=n.format==="heic";if(r&&!await at())throw nt(t);let a=r?await st(t):void 0;try{let i=(await ot())(a?.path??t,{animated:!1}),{data:l,info:s}=await(r?i:i.rotate()).resize(e,e,{fit:"inside",withoutEnlargement:!0}).ensureAlpha().raw().toBuffer({resolveWithObject:!0});return{source:n,pixels:{width:s.width,height:s.height,rgba:new Uint8Array(l.buffer,l.byteOffset,l.length)}}}catch(o){throw tt(o)?o:rt(t,o)}finally{await a?.cleanup()}}export{Tt as a,ct as b,B as c,At as d,Et as e,Ot as f,I as g,Ht as h,Pt as i,Dt as j,_t as k,Kt as l,Qt as m};
@@ -0,0 +1,3 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ var a={jpeg:{id:"jpeg",label:"JPEG",extensions:[".jpg",".jpeg"],hasAlpha:!1,animatable:!1,lossy:!0,hint:"universal",defaultQuality:82},png:{id:"png",label:"PNG",extensions:[".png"],hasAlpha:!0,animatable:!1,lossy:!1,hint:"lossless",quantisable:!0},webp:{id:"webp",label:"WebP",extensions:[".webp"],hasAlpha:!0,animatable:!0,lossy:!0,hint:"smaller, modern",defaultQuality:80},avif:{id:"avif",label:"AVIF",extensions:[".avif"],hasAlpha:!0,animatable:!0,lossy:!0,hint:"smallest",defaultQuality:50},heic:{id:"heic",label:"HEIC",extensions:[".heic",".heif"],hasAlpha:!0,animatable:!1,lossy:!0,hint:"Apple photos"},gif:{id:"gif",label:"GIF",extensions:[".gif"],hasAlpha:!0,animatable:!0,lossy:!1,hint:"animation",quantisable:!0},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"}},t=Object.keys(a);function l(e){return a[e.toLowerCase()]}function i(e){let s=a[e].extensions[0];if(!s)throw new Error(`format ${e} declares no extensions`);return s}export{a,l as b,i as c};
@@ -1,3 +1,3 @@
1
1
  import { createRequire as __forgeCreateRequire } from 'node:module';
2
2
  const require = __forgeCreateRequire(import.meta.url);
3
- import{a}from"./chunk-HON4OV7M.js";import{b as c}from"./chunk-YILLB45O.js";import{access as x,readFile as p}from"node:fs/promises";import{join as n,sep as y}from"node:path";function g(){return n(a(),"forge","extensions")}var E=/^[A-Za-z0-9][A-Za-z0-9._-]*$/;async function v(e){if(c(e)!==void 0)try{let u=n(g(),e),t=(await p(n(u,"current"),"utf8")).trim();if(!E.test(t))return;let r=n(u,t),i=JSON.parse(await p(n(r,"manifest.json"),"utf8"));if(typeof i!="object"||i===null)return;let{id:m,version:l,entry:o,kind:s,files:d}=i;if(m!==e||l!==t||s!=="node"&&s!=="exec"||typeof o!="string"||typeof d!="object"||d===null||!(o in d))return;let f=n(r,o);return f.startsWith(`${r}${y}`)?(await x(f),{id:e,version:t,dir:r,entry:f,kind:s}):void 0}catch{return}}export{g as a,E as b,v as c};
3
+ import{a}from"./chunk-HON4OV7M.js";import{b as c}from"./chunk-SS7HNRZ5.js";import{access as x,readFile as p}from"node:fs/promises";import{join as n,sep as y}from"node:path";function g(){return n(a(),"forge","extensions")}var E=/^[A-Za-z0-9][A-Za-z0-9._-]*$/;async function v(e){if(c(e)!==void 0)try{let u=n(g(),e),t=(await p(n(u,"current"),"utf8")).trim();if(!E.test(t))return;let r=n(u,t),i=JSON.parse(await p(n(r,"manifest.json"),"utf8"));if(typeof i!="object"||i===null)return;let{id:m,version:l,entry:o,kind:s,files:d}=i;if(m!==e||l!==t||s!=="node"&&s!=="exec"||typeof o!="string"||typeof d!="object"||d===null||!(o in d))return;let f=n(r,o);return f.startsWith(`${r}${y}`)?(await x(f),{id:e,version:t,dir:r,entry:f,kind:s}):void 0}catch{return}}export{g as a,E as b,v as c};
@@ -0,0 +1,3 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ import{a as n}from"./chunk-IMC5NRDC.js";import{g as o}from"./chunk-6VOCIMXQ.js";import{F as i}from"./chunk-DW2EJIUX.js";import{a as r}from"./chunk-BXJ2HTKI.js";var I=5,h=200,c=5;function x(t){return t.format==="heic"?"jpeg":n(t).includes(t.format)?t.format:"png"}function z(t,m){let e=o.find(f=>f.id==="image")?.writes;if(!e?.has(t))return i(`Cannot ${m} into ${r[t].label}; only an image format can take the edit.`,`Choose one of: ${[...e??[]].join(", ")}.`)}var E=t=>`${t.width}x${t.height}`,u=t=>"percent"in t?`${t.percent}pct`:"width"in t?`${t.width}w`:`${t.height}h`;export{I as a,h as b,c,x as d,z as e,E as f,u as g};
@@ -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 m}from"./chunk-ZRP5CWIK.js";import{X as l}from"./chunk-MMRDELHW.js";import{randomBytes as h}from"node:crypto";import{link as y,mkdir as p,readdir as x,readFile as P,rename as E,rm as c,stat as L,writeFile as S}from"node:fs/promises";import{join as u}from"node:path";var b=720*60*1e3,k=600*1e3,M=200,F=600*1e3;function a(){return u(m(),".locks")}function f(t){return u(a(),`${t}.lock`)}function v(t){if(!Number.isInteger(t)||t<=0)return!1;try{return process.kill(t,0),!0}catch(n){return n.code==="EPERM"}}async function s(t){try{let n=JSON.parse(await P(t,"utf8"));return typeof n.pid!="number"||typeof n.token!="string"?void 0:n}catch{return}}async function d(t,n){if(n===void 0||!v(n.pid))return!0;let e=await L(t).catch(()=>{});return e!==void 0&&Date.now()-e.mtimeMs>b}async function D(t){let n=`${t}.stale-${h(4).toString("hex")}`;try{await E(t,n)}catch{return}let e=await s(n);e!==void 0&&!await d(n,e)&&await y(n,t).catch(()=>{}),await c(n,{force:!0})}async function A(){let t=await x(a()).catch(()=>[]);for(let n of t){if(!/\.lock\.(stale-)?[0-9a-f]+$/.test(n))continue;let e=u(a(),n),i=await L(e).catch(()=>{});i&&Date.now()-i.mtimeMs>F&&await c(e,{force:!0})}}async function g(t,n){await p(a(),{recursive:!0});let e=f(t),i={pid:process.pid,token:h(8).toString("hex"),at:Date.now(),...n!==void 0?{what:n}:{}},r=`${e}.${i.token}`;await S(r,JSON.stringify(i),{flag:"wx"});try{for(let o=0;o<2;o++){try{return await y(r,e),i}catch(w){if(w.code!=="EEXIST")throw w}if(!await d(e,await s(e)))return;await D(e)}return}finally{await c(r,{force:!0})}}async function T(t,n){let e=f(t);(await s(e))?.token===n.token&&await c(e,{force:!0})}async function _(t){let n=f(t),e=await s(n);if(!(e===void 0||await d(n,e)))return{pid:e.pid,...e.what!==void 0?{what:e.what}:{}}}async function H(t,n,e={}){let i=Date.now()+(e.waitMs??k);await p(a(),{recursive:!0}),await A();let r=await g(t,e.what);for(r===void 0&&(e.waitMs??k)>0&&e.onWait?.();r===void 0;){if(e.signal?.aborted)throw e.signal.reason??new Error("aborted");if(Date.now()>=i)throw l(t,await _(t),e.action??"run");await new Promise(o=>setTimeout(o,M)),r=await g(t,e.what)}try{return await n()}finally{await T(t,r)}}export{k as a,_ as b,H as c};
3
+ import{a as m}from"./chunk-C2OZ5ERA.js";import{U as l}from"./chunk-DW2EJIUX.js";import{randomBytes as h}from"node:crypto";import{link as y,mkdir as p,readdir as x,readFile as P,rename as E,rm as c,stat as L,writeFile as S}from"node:fs/promises";import{join as u}from"node:path";var b=720*60*1e3,k=600*1e3,M=200,F=600*1e3;function a(){return u(m(),".locks")}function f(t){return u(a(),`${t}.lock`)}function v(t){if(!Number.isInteger(t)||t<=0)return!1;try{return process.kill(t,0),!0}catch(n){return n.code==="EPERM"}}async function s(t){try{let n=JSON.parse(await P(t,"utf8"));return typeof n.pid!="number"||typeof n.token!="string"?void 0:n}catch{return}}async function d(t,n){if(n===void 0||!v(n.pid))return!0;let e=await L(t).catch(()=>{});return e!==void 0&&Date.now()-e.mtimeMs>b}async function D(t){let n=`${t}.stale-${h(4).toString("hex")}`;try{await E(t,n)}catch{return}let e=await s(n);e!==void 0&&!await d(n,e)&&await y(n,t).catch(()=>{}),await c(n,{force:!0})}async function A(){let t=await x(a()).catch(()=>[]);for(let n of t){if(!/\.lock\.(stale-)?[0-9a-f]+$/.test(n))continue;let e=u(a(),n),i=await L(e).catch(()=>{});i&&Date.now()-i.mtimeMs>F&&await c(e,{force:!0})}}async function g(t,n){await p(a(),{recursive:!0});let e=f(t),i={pid:process.pid,token:h(8).toString("hex"),at:Date.now(),...n!==void 0?{what:n}:{}},r=`${e}.${i.token}`;await S(r,JSON.stringify(i),{flag:"wx"});try{for(let o=0;o<2;o++){try{return await y(r,e),i}catch(w){if(w.code!=="EEXIST")throw w}if(!await d(e,await s(e)))return;await D(e)}return}finally{await c(r,{force:!0})}}async function T(t,n){let e=f(t);(await s(e))?.token===n.token&&await c(e,{force:!0})}async function _(t){let n=f(t),e=await s(n);if(!(e===void 0||await d(n,e)))return{pid:e.pid,...e.what!==void 0?{what:e.what}:{}}}async function H(t,n,e={}){let i=Date.now()+(e.waitMs??k);await p(a(),{recursive:!0}),await A();let r=await g(t,e.what);for(r===void 0&&(e.waitMs??k)>0&&e.onWait?.();r===void 0;){if(e.signal?.aborted)throw e.signal.reason??new Error("aborted");if(Date.now()>=i)throw l(t,await _(t),e.action??"run");await new Promise(o=>setTimeout(o,M)),r=await g(t,e.what)}try{return await n()}finally{await T(t,r)}}export{k as a,_ as b,H as c};
@@ -0,0 +1,3 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ import{a as q,c as gt}from"./chunk-7ZI3PFFX.js";import{$ as pt,C as ct,F as B,K as ft,X as dt,aa as ut,ba as mt,c as k,ca as lt,d as C,da as wt,e as et,ea as U,f as rt,g as W,h as it,i as nt,j as ot,k as at,l as st,o as I,u as ht,v as j}from"./chunk-DW2EJIUX.js";import{a as w}from"./chunk-BXJ2HTKI.js";import{randomBytes as qt}from"node:crypto";import{constants as Jt}from"node:fs";import{access as Vt,readFile as Ot,rm as Xt,stat as Zt,writeFile as Gt}from"node:fs/promises";import{basename as Kt,dirname as Qt,join as Yt}from"node:path";var Pt=[{w:1,h:1,label:"1:1"},{w:4,h:5,label:"4:5"},{w:16,h:9,label:"16:9"},{w:9,h:16,label:"9:16"}],le=20,we=10,E=t=>Math.max(1,Math.round(t)),N=(t,r,e)=>Math.min(Math.max(t,r),e);function A(t,r){let e=E(t.width*r.h/r.w),[i,n]=e<=t.height?[t.width,e]:[Math.min(t.width,E(t.height*r.w/r.h)),t.height];return{left:Math.floor((t.width-i)/2),top:Math.floor((t.height-n)/2),width:i,height:n}}var Ft=(t,r)=>r.width===t.width&&r.height===t.height;function ge(t){return Pt.filter(r=>!Ft(t,A(t,r)))}function ye(t,r,e,i){let n=A(t,r),o,a;return r.w>=r.h?(o=E(n.width*i/100),a=Math.min(t.height,E(o*r.h/r.w))):(a=E(n.height*i/100),o=Math.min(t.width,E(a*r.w/r.h))),{left:N(Math.round(e.x-o/2),0,t.width-o),top:N(Math.round(e.y-a/2),0,t.height-a),width:o,height:a}}function xe(t,r,e,i){return{...r,left:N(r.left+e,0,t.width-r.width),top:N(r.top+i,0,t.height-r.height)}}function be(t,r){return{x:r.width<t.width,y:r.height<t.height}}function Se(t){return{x:t.left+t.width/2,y:t.top+t.height/2}}function Ie(t,r){return Math.round(r.width*r.height*100/(t.width*t.height))}var J=t=>`${t.w}:${t.h}`,Me=t=>`cropped-${t.w}x${t.h}`;function Ee(t){let r=/^(\d{1,3}):(\d{1,3})$/.exec(t.trim()),e=Number(r?.[1]),i=Number(r?.[2]);if(!r||e<1||e>100||i<1||i>100)throw B(`"${t}" is not a shape; it takes two whole numbers from 1 to 100, as W:H.`,"Try --crop 1:1 or --crop 16:9.");return{w:e,h:i}}function Ae(t,r,e){let i=e*2,n=new Uint8Array(r*i*3),o=t.alpha?new Uint8Array(r*i):void 0,a=t.width/r,d=t.height/i;for(let s=0;s<i;s++){let h=s*d,l=h+d;for(let p=0;p<r;p++){let f=p*a,u=f+a,x=0,m=0,g=0,c=0,y=0;for(let b=Math.floor(h);b<Math.min(Math.ceil(l),t.height);b++){let L=Math.min(b+1,l)-Math.max(b,h);for(let O=Math.floor(f);O<Math.min(Math.ceil(u),t.width);O++){let Y=b*t.width+O,tt=(Math.min(O+1,u)-Math.max(O,f))*L,R=tt*(t.alpha?(t.alpha[Y]??0)/255:1),H=Y*3;x+=(t.rgb[H]??0)*R,m+=(t.rgb[H+1]??0)*R,g+=(t.rgb[H+2]??0)*R,c+=R,y+=tt}}let z=s*r+p;c>0&&n.set([x/c,m/c,g/c].map(Math.round),z*3),o&&y>0&&(o[z]=Math.round(c*255/y))}}return{cols:r,dotRows:i,rgb:n,...o?{alpha:o}:{}}}function Te(t){if(w[t].hasAlpha)return;let r=Object.keys(w).filter(e=>w[e].hasAlpha&&e!=="heic").join(", ");return B(`${w[t].label} cannot hold transparency, so a cutout cannot be saved as one.`,`Choose a format that can: ${r}.`)}var yt="1.1.0";function zt(t,r){let e=t.split(".").map(n=>Number.parseInt(n,10)||0),i=r.split(".").map(n=>Number.parseInt(n,10)||0);for(let n=0;n<Math.max(e.length,i.length);n++){let o=(e[n]??0)-(i[n]??0);if(o!==0)return o>0}return!0}function V(t){return t!==void 0&&zt(t,yt)?[2,3,4]:[2,4]}function Pe(t,r,e){if(t===1||V(r).some(n=>n===t))return;if(e!==void 0&&V(e).some(n=>n===t))return ft("boost",`boost ${t}\xD7`,r,yt);let i=V(r).map(n=>`--boost ${n}`);return B(`No released boost makes ${t}\xD7 yet.`,`Try ${i.slice(0,-1).join(", ")} or ${i.at(-1)}.`)}var Rt=16384,kt=1e8;function xt(t,r,e){let i=Math.max(t,r)*e;if(i>Rt)return{side:i};let n=t*e*r*e;if(n>kt)return{megapixels:Math.round(n/1e6)}}var v=t=>Math.max(1,Math.round(t));function X(t,r){return"percent"in r?{width:v(t.width*r.percent/100),height:v(t.height*r.percent/100)}:"width"in r?{width:v(r.width),height:v(t.height*r.width/t.width)}:{width:v(t.width*r.height/t.height),height:v(r.height)}}function bt(t){return xt(t.width,t.height,1)}import{execFile as Ut}from"node:child_process";import{randomBytes as Nt}from"node:crypto";import{mkdtemp as Dt,open as St,readFile as _t,rm as Z}from"node:fs/promises";import{tmpdir as It}from"node:os";import{join as _}from"node:path";import{promisify as $t}from"node:util";function S(t){let r;return()=>(r??=t(),r)}var M=S(async()=>(await import("sharp")).default),ke=S(()=>import("./es-T2U7NBLD.js")),Ce=S(()=>import("@hyzyla/pdfium")),Ue=S(async()=>(await import("./lib-TPEJ5CJJ.js")).default),Ne=S(async()=>(await import("./word-OGQ2KZAJ.js")).default),De=S(async()=>(await import("./adm-zip-SQKLKBDP.js")).default),_e=S(async()=>(await import("./cfb-V6M2PYOD.js")).default);async function Ct(){let t=Object.getOwnPropertyDescriptor(globalThis,"localStorage");if(!t?.configurable)return import("./dist-J2V6ITHG.js");Object.defineProperty(globalThis,"localStorage",{value:void 0,configurable:!0,enumerable:t.enumerable??!1,writable:!0});try{return await import("./dist-J2V6ITHG.js")}finally{Object.defineProperty(globalThis,"localStorage",t)}}var $e=S(Ct);var G=$t(Ut),Mt=async()=>({...await import("./paths-KTXPDCDD.js"),...await import("./run-4Z6CRNHJ.js")}),T;async function P(t=process.platform){if(t==="win32")return await(await Mt()).installed("heic")!==void 0;if(T!==void 0)return T;try{await G("/usr/bin/sips",["--help"],{timeout:5e3}),T=!0}catch{T=!1}return T}async function $(t,r=process.platform){if(r==="win32")return Lt(t);let e=_(It(),`forge-heic-${Nt(8).toString("hex")}.png`),i=async()=>{await Z(e,{force:!0}).catch(()=>{})};try{return await G("/usr/bin/sips",["-s","format","png",t,"--out",e],{timeout:12e4}),{path:e,cleanup:i}}catch(n){throw await i(),n}}async function Et(t){let{installed:r,runExtension:e}=await Mt(),i=await r("heic");if(i===void 0)throw I(t,"win32");return{ext:i,runExtension:e}}async function Lt(t){let r=await Dt(_(It(),"forge-heic-")),e=async()=>{await Z(r,{recursive:!0,force:!0}).catch(()=>{})};try{let{ext:i,runExtension:n}=await Et(t),o=_(r,"decoded.rgba"),a=_(r,"decoded.png"),{width:d,height:s}=await n(i,["--in",t,"--out",o],{subject:t});return await(await M())(await _t(o),{raw:{width:d,height:s,channels:4}}).png().toFile(a),await Z(o,{force:!0}),{path:a,cleanup:e}}catch(i){throw await e(),i}}var Ht=new Set(["heic","heix","hevc","hevx","heim","heis","mif1","msf1"]),Wt=new Set(["avif","avis"]);async function At(t){let r;try{r=await St(t,"r")}catch{return!1}try{let e=Buffer.alloc(64),{bytesRead:i}=await r.read(e,0,64,0);if(i<12||e.toString("latin1",4,8)!=="ftyp")return!1;let n=Math.min(e.readUInt32BE(0),i),o=[];for(let a=8;a+4<=n;a+=4)o.push(e.toString("latin1",a,a+4));return o.some(a=>Wt.has(a))?!1:o.some(a=>Ht.has(a))}catch{return!1}finally{await r.close().catch(()=>{})}}async function vt(t,r=process.platform){if(r==="win32"){let{ext:a,runExtension:d}=await Et(t),s=await d(a,["--info","--in",t],{subject:t});return{width:s.width,height:s.height,hasAlpha:s.hasAlpha??!0}}let{stdout:e}=await G("/usr/bin/sips",["-g","pixelWidth","-g","pixelHeight","-g","hasAlpha",t],{timeout:3e4}),i=Number(/pixelWidth:\s*(\d+)/.exec(e)?.[1]??0),n=Number(/pixelHeight:\s*(\d+)/.exec(e)?.[1]??0),o=await jt(t);return{width:o?n:i,height:o?i:n,hasAlpha:/hasAlpha:\s*yes/i.test(e)}}function*D(t,r,e){let i=r;for(;i+8<=e;){let n=t.readUInt32BE(i),o=8;if(n===1&&i+16<=e?(n=Number(t.readBigUInt64BE(i+8)),o=16):n===0&&(n=e-i),n<o)return;yield{type:t.toString("latin1",i+4,i+8),start:i+o,end:Math.min(i+n,e)},i+=n}}async function jt(t){let r=await St(t,"r");try{let e=Buffer.alloc(262144),{bytesRead:i}=await r.read(e,0,e.length,0),n=[...D(e,0,i)].find(c=>c.type==="meta");if(!n)return!1;let o=[...D(e,n.start+4,n.end)],a=o.find(c=>c.type==="pitm"),d=o.find(c=>c.type==="iprp");if(!a||!d)return!1;let s=e.readUInt8(a.start)===0?e.readUInt16BE(a.start+4):e.readUInt32BE(a.start+4),h=[...D(e,d.start,d.end)],l=h.find(c=>c.type==="ipco"),p=h.find(c=>c.type==="ipma");if(!l||!p)return!1;let f=new Map;if([...D(e,l.start,l.end)].forEach((c,y)=>{c.type==="irot"&&f.set(y+1,e.readUInt8(c.start)&3)}),f.size===0)return!1;let u=e.readUInt8(p.start),x=(e.readUInt8(p.start+3)&1)===1,m=p.start+4,g=e.readUInt32BE(m);m+=4;for(let c=0;c<g&&m<p.end;c++){let y=u<1?e.readUInt16BE(m):e.readUInt32BE(m);m+=u<1?2:4;let z=e.readUInt8(m);m+=1;for(let b=0;b<z;b++){let L=x?e.readUInt16BE(m)&32767:e.readUInt8(m)&127;if(m+=x?2:1,y===s&&(f.get(L)??0)%2===1)return!0}}return!1}catch{return!1}finally{await r.close().catch(()=>{})}}var te=new Set(["jpeg","png","webp","avif","heic","gif","tiff"]),ee=new Set(["jpeg","png","webp","avif","gif","tiff"]),re={jpeg:"jpeg",png:"png",webp:"webp",gif:"gif",tiff:"tiff"};function ie(t,r){if(r.format==="heif")return r.compression==="av1"?"avif":"heic";let e=re[r.format??""];if(!e)throw st(t,r.format??"an unknown format");return e}async function ne(t){let r;try{r=await Zt(t)}catch(n){let o=n.code;throw o==="ENOENT"?et(t):o==="EACCES"||o==="EPERM"?W(t):o==="ENOTDIR"?it(t):o==="ELOOP"?nt(t):o==="ENAMETOOLONG"?ot(t):at(t,n)}if(!r.isFile())throw rt(t);try{await Vt(t,Jt.R_OK)}catch{throw W(t)}if(await At(t)){if(!await P())throw I(t);let n;try{n=await vt(t)}catch(o){throw j(t,"heic",o)}if(n.width===0||n.height===0)throw j(t,"heic",void 0);return{kind:"image",path:t,format:"heic",width:n.width,height:n.height,bytes:r.size,hasAlpha:n.hasAlpha,frames:1}}let e=await M(),i;try{i=await e(t).metadata()}catch(n){throw ht(t,n)}return{kind:"image",path:t,format:ie(t,i),width:i.autoOrient?.width??i.width??0,height:i.autoOrient?.height??i.height??0,bytes:r.size,hasAlpha:i.hasAlpha??!1,frames:i.pages??1}}function K(t,r,e,i){let n=e??w[r].defaultQuality;if(i&&w[r].quantisable)return oe(t,r,e,i);switch(r){case"jpeg":return t.jpeg({quality:n,mozjpeg:!0});case"webp":return t.webp({quality:n});case"avif":return t.avif({quality:n});case"png":return t.png({compressionLevel:9});case"gif":return t.gif();case"tiff":return t.tiff({compression:"deflate"});case"heic":throw new Error("heic is not writable; the capability graph should have prevented this");case"pdf":throw new Error("pdf is not an image target; the capability graph should have prevented this");case"docx":throw new Error("docx is not an image target; the capability graph should have prevented this");case"doc":throw new Error("doc is not an image target; the capability graph should have prevented this")}}function oe(t,r,e,{dither:i}){let n=e??100,o=i?1:0;return r==="gif"?t.gif({interFrameMaxError:Math.round(32*(100-n)/100),dither:o}):t.png({palette:!0,quality:n,dither:o,compressionLevel:9,effort:10})}var Q=(t,r)=>t.kind==="image"&&t.frames>1&&w[r].animatable;async function ae(t,r){let e=Qt(r);await q(r);let i=Yt(e,`.forge-tmp-${qt(6).toString("hex")}-${Kt(r)}`);try{return await Gt(i,t),await gt(i,r),t.length}catch(n){throw await Xt(i,{force:!0}).catch(()=>{}),ct(r,n)}}async function F(t,r,e,i,n,o){if(t.kind!=="image")throw new Error("pipelineFor received a non-image source");if(n===void 0&&t.format==="heic"&&!await P())throw I(t.path);let a=n===void 0&&t.format==="heic"?await $(t.path):void 0,d=async()=>{await a?.cleanup()},h=(await M())(n??a?.path??t.path,i?{animated:!0}:{});if(h=h.rotate(),e.trim&&(h=h.trim()),e.crop){if(!e.crop.box)throw new Error("pipelineFor needs the crop placed (run does it)");h=h.extract(e.crop.box)}if(e.resize){if(!o&&(e.trim||e.crop))throw new Error("pipelineFor needs the resolved size to resize a cut image");let l=o??X(t,e.resize);h=h.resize(l.width,l.height,{fit:"fill"})}return t.hasAlpha&&!w[r].hasAlpha&&(h=h.flatten({background:e.background})),h=e.keepMetadata?h.keepMetadata():h.keepIccProfile(),{pipeline:h,cleanup:d}}async function cr(t,r){let e={background:"#ffffff",keepMetadata:!1},{pipeline:i,cleanup:n}=await F(t,"png",e,!1);try{await i.png({compressionLevel:1}).toFile(r)}finally{await n()}}async function fr(t,r,e){let{pipeline:i,cleanup:n}=await F(t,r,e,Q(t,r));try{return await K(i,r,e.quality,e.compress).toBuffer()}finally{await n()}}async function se(t){let r={width:t.width,height:t.height};if(t.frames>1)return{upright:r,trimmed:"animated"};if(t.format==="heic"&&!await P())throw I(t.path);let e=t.format==="heic"?await $(t.path):void 0;try{let i=await M(),{info:n}=await i(e?.path??t.path).rotate().trim().jpeg({quality:1}).toBuffer({resolveWithObject:!0});return n.width===r.width&&n.height===r.height?{upright:r,trimmed:"nothing"}:{upright:r,trimmed:{width:n.width,height:n.height}}}catch(i){throw C(i)?i:U(t.path,i)}finally{await e?.cleanup()}}var Bt=1024;async function he(t){let r={background:"#ffffff",keepMetadata:!1},{pipeline:e,cleanup:i}=await F(t,"png",r,!1);try{let{data:n,info:o}=await e.resize(Bt,Bt,{fit:"inside",withoutEnlargement:!0}).ensureAlpha().raw().toBuffer({resolveWithObject:!0}),a=o.width*o.height,d=o.channels,s=new Uint8Array(a*3),h=new Uint8Array(a),l=!1;for(let p=0;p<a;p++){for(let f=0;f<3;f++)s[p*3+f]=n[p*d+(d>=4?f:0)]??0;h[p]=n[p*d+d-1]??255,h[p]!==255&&(l=!0)}return{size:{width:t.width,height:t.height},thumb:{width:o.width,height:o.height,rgb:s,...l?{alpha:h}:{}}}}catch(n){throw C(n)?n:U(t.path,n)}finally{await i()}}var Tt=128;async function ce(t,r){let{thumb:e,size:i}=t,n=A(e,r),o=await M(),{info:a}=await o(fe(e),{raw:{width:e.width,height:e.height,channels:3}}).resize(n.width,n.height,{fit:"cover",position:o.strategy.attention}).raw().toBuffer({resolveWithObject:!0}),d=A(i,r),s=Math.round(-(a.cropOffsetLeft??0)*i.width/e.width),h=Math.round(-(a.cropOffsetTop??0)*i.height/e.height);return{...d,left:Math.min(Math.max(s,0),i.width-d.width),top:Math.min(Math.max(h,0),i.height-d.height)}}function fe(t){let{alpha:r}=t;if(!r)return t.rgb;let e=new Uint8Array(t.rgb.length);for(let i=0;i<e.length;i++){let n=(r[Math.floor(i/3)]??255)/255;e[i]=Math.round(Tt+((t.rgb[i]??0)-Tt)*n)}return e}async function de(t,r){if(t.op!=="convert")throw new Error(`image engine cannot ${t.op}`);let e=t.sources[0],i=t.outputs[0];if(e.kind!=="image")throw new Error("the image engine cannot convert a document source");let n=w[t.target],o=[];r({phase:"reading"});let a=e.frames>1,d=Q(e,t.target);a&&!n.animatable&&o.push({code:"animation-flattened",message:`${k(e.path)} has ${e.frames} frames, and ${n.label} cannot animate. Only the first frame was converted.`});let s=t.options,h;if(s.trim||s.crop||s.resize){let f={width:e.width,height:e.height};if(s.trim&&s.crop)throw new Error("a job cannot both trim and crop");if(s.crop){if(a)throw wt(e.path);let{aspect:u}=s.crop,x=c=>c.width===e.width&&c.height===e.height,m=A(f,u),g=s.crop.box??(x(m)?m:await ce(await he(e),u));if(x(g)){if(!s.resize)throw lt(e.path,J(u));o.push({code:"nothing-cropped",message:`${k(e.path)} is already ${J(u)}; resized only.`});let{crop:c,...y}=s;s=y}else s={...s,crop:{aspect:u,box:g}},f={width:g.width,height:g.height}}if(s.trim){if(a)throw mt(e.path);let{trimmed:u}=await se(e);if(u==="nothing"){if(!s.resize)throw ut(e.path);o.push({code:"nothing-trimmed",message:`${k(e.path)} has no empty edges; resized only.`})}else u!=="animated"&&(f=u)}if(s.resize&&(h=X(f,s.resize),bt(h)))throw dt(e.path,h)}r({phase:"decoding"});let{pipeline:l,cleanup:p}=await F(e,t.target,s,d,void 0,h);try{await q(i),r({phase:"encoding"});let f=await K(l,t.target,s.quality,s.compress).toBuffer();if(s.compress&&f.length>=e.bytes)throw pt(e.path,e.bytes,f.length);r({phase:"writing"});let u=await ae(f,i);return{job:t,outputBytes:u,warnings:o}}catch(f){throw C(f)?f:U(e.path,f)}finally{await p()}}async function pe(t){if(t.format!=="heic")return Ot(t.path);if(!await P())throw I(t.path);let r=await $(t.path);try{return await Ot(r.path)}finally{await r.cleanup()}}async function ue(t){if(t.op!=="convert")return;let r=w[t.target];if(!r.lossy&&!(r.quantisable&&t.options.compress))return;let e=t.sources[0];if(e.kind!=="image")return;let i=await pe(e);return{ladder:[{}],measure:async n=>{let{pipeline:o}=await F(e,t.target,n,Q(e,t.target),i);return(await K(o,t.target,n.quality,n.compress).toBuffer()).length}}}var dr={id:"image",reads:te,writes:ee,ops:new Set(["convert"]),probe:ne,run:de,measurer:ue};export{Pt as a,le as b,we as c,A as d,ge as e,ye as f,xe as g,be as h,Se as i,Ie as j,Me as k,Ee as l,Ae as m,Te as n,V as o,Pe as p,Rt as q,xt as r,X as s,bt as t,S as u,M as v,ke as w,Ce as x,Ue as y,Ne as z,De as A,_e as B,$e as C,P as D,$ as E,At as F,K as G,ae as H,cr as I,fr as J,se as K,he as L,ce as M,dr as N};
@@ -0,0 +1,3 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ import{a as l}from"./chunk-J7FLFHQJ.js";import{a as s}from"./chunk-BXJ2HTKI.js";import{homedir as m}from"node:os";import{posix as p,win32 as h}from"node:path";var f=/[\u0000-\u001f\u007f-\u009f‪-‮⁦-⁩]/g;function d(e){return e.replace(f,"?")}function c(e,t,n){let i=n.relative(t,e);if(i==="")return"";if(!(i===".."||i.startsWith(`..${n.sep}`)||n.isAbsolute(i)))return i}function C(e,t={}){return d(w(e,t))}function w(e,t){let n=(t.platform??process.platform)==="win32"?h:p;if(t.cwd!==void 0){let a=c(e,t.cwd,n);if(a!==void 0)return a===""?".":a}let i=c(e,t.home??m(),n);return i!==void 0?i===""?"~":`~${n.sep}${i}`:e}function r(e,t=process.platform){return d((t==="win32"?h:p).basename(e))}import{dirname as b}from"node:path";var o=class extends Error{code;title;detail;short;hint;shellHint;constructor(t){super(`${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 x(e){return e instanceof o}function N(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 U(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 D(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 O(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 j(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 z(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 A(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})}function M(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.`,hint:"Forge 0.1 handles images only."})}function J(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 R(e){return new o({code:"unsupported-source",title:"Nothing to take colours from",detail:`${r(e)} has no visible pixels.`})}function W(e,t=process.platform){return t==="win32"?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 Windows.`,short:"HEIC needs the heic extension.",hint:"Install it with: forge extensions add heic",shellHint:"Open /extensions to install it."}):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 q(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 L(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 B(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 _(e,t,n){return new o({code:"target-unreachable",title:"Cannot get that small",detail:`${r(e.path)} is ${l(n)} even at the lowest quality, which is still over ${l(t)}.`,hint:"Try a larger --max-size, or --to a smaller format.",shellHint:"Try a larger target, or /convert to a smaller format."})}function V(e,t,n){return new o({code:"unsupported-target",title:`Can't convert ${r(e.path)} to ${t}`,detail:`${r(e.path)} is a ${s[e.format].label} ${e.kind==="image"?"image":"document"}.`,hint:`Available: ${n.join(", ")}`})}function X(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 Y(e,t,n){return new o({code:"corrupt-source",title:`Damaged ${s[t].label}`,detail:`${r(e)} is a ${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 G(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 u=e=>e==="convert"||e==="boost"||e==="remove-background";function K(e,t="convert"){return new o({code:"output-exists",title:"File already exists",detail:`${r(e)} is already there.`,hint:u(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 Q(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 Z(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 ee(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:u(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:u(t)?"Choose a different folder to save it in.":"Move or rename that file first."})}function $(e,t){return new o({code:"permission-denied",title:"Permission denied",detail:`${r(b(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 y=new Set(["EACCES","EPERM","EROFS"]);function te(e,t){if(x(t))return t;let n=t?.code;return n!==void 0&&y.has(n)?$(e,t):t}function oe(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 ne(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 re(e,t){return new o({code:"invalid-arguments",title:"Invalid arguments",detail:e,hint:t})}function ie(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 se(e){return new o({code:"empty-selection",title:"Nothing to write",detail:e,hint:"Select at least one page to keep."})}function ae(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 le(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 de(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 ue(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 ce(e,t,n=process.platform){let i=n==="win32"?"PC":"Mac";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 pe(e,t=process.platform){let n=t==="win32"?"Windows":t==="darwin"?"macOS":"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 he(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 ge(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 fe(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 me(){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 (and HTTPS_PROXY if you use a proxy), then run: forge update",shellHint:"Check your connection, then try again."})}function we(e,t){return new o({code:"extension-download-failed",title:"Download failed",detail:`${e}: ${t}`,hint:`Check your connection (and HTTPS_PROXY if you use a proxy), then run: forge extensions add ${e}`,shellHint:"Check your connection, then try again from /extensions."})}function be(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 xe(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 $e(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 ye(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 Fe(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."})}function Ee(e){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:"Copy a picture, or take a screenshot with \u2303\u21E7\u23184, then run forge clip again."})}function ve(){return new o({code:"clipboard-unavailable",title:"No clipboard",detail:"Forge reads the clipboard on a Mac, and not over SSH."})}function ke(){return new o({code:"nothing-to-undo",title:"Nothing to undo",detail:"No copied image has been changed yet."})}function Ce(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 g=n>t?`would grow from ${l(t)} to ${l(n)}`:`would stay at ${l(t)}`;return new o({code:"cannot-compress-more",title:"Cannot compress more",detail:`${a} ${g}, so nothing was written.`,short:"nothing written",hint:"Try a lower --quality.",shellHint:"Try a lower quality."})}function Te(e){return new o({code:"nothing-to-trim",title:"Nothing to trim",detail:`${r(e)} has no empty edges.`,short:"no empty edges"})}function Se(e){return new o({code:"animated-trim",title:"Can't trim an animation",detail:`${r(e)} is animated; trimming works on still images.`})}function He(e,t){return new o({code:"nothing-to-crop",title:"Nothing to crop",detail:`${r(e)} is already ${t}.`,short:`already ${t}`})}function Pe(e){return new o({code:"animated-crop",title:"Can't crop an animation",detail:`${r(e)} is animated; cropping works on still images.`})}function Ie(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})}function Ne(e){return new o({code:"no-sound",title:"Nothing to transcribe",detail:`${r(e)} has no sound.`})}function Ue(e){return 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 files can be transcribed."})}function De(e){return new o({code:"language-unsupported",title:"Language not supported",detail:`Apple's speech recogniser does not support ${e}.`,hint:"Pass another with --language, for example --language en-US."})}function Oe(e,t,n={}){return new o({code:"link-unavailable",title:"Cannot transcribe this link",detail:e,...n,...t===void 0?{}:{cause:t}})}function je(e){return new o({code:"transcribe-unavailable",title:"Transcribe is not available",detail:e})}function ze(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 Ae(e,t={}){let n=[`\u2715 ${e.title}`,"",` ${e.detail}`];return e.hint&&n.push("",` ${e.hint}`),t.debug&&e.cause instanceof Error&&n.push("",` ${e.cause.stack??e.cause.message}`),n}export{d as a,C as b,r as c,x as d,N as e,U as f,D as g,O as h,j as i,z as j,A as k,M as l,J as m,R as n,W as o,q as p,L as q,B as r,_ as s,V as t,X as u,Y as v,G as w,K as x,Q as y,Z as z,ee as A,$ as B,te as C,oe as D,ne as E,re as F,ie as G,se as H,ae as I,le as J,de as K,ue as L,ce as M,pe as N,he as O,ge as P,fe as Q,me as R,we as S,be as T,xe as U,$e as V,ye as W,Fe as X,Ee as Y,ve as Z,ke as _,Ce as $,Te as aa,Se as ba,He as ca,Pe as da,Ie as ea,Ne as fa,Ue as ga,De as ha,Oe as ia,je as ja,ze as ka,Ae as la};
@@ -1,3 +1,3 @@
1
1
  import { createRequire as __forgeCreateRequire } from 'node:module';
2
2
  const require = __forgeCreateRequire(import.meta.url);
3
- import{j as t}from"./chunk-GGBNT4WI.js";import{resolve as s}from"node:path";function c(r,e){return{forge:r,ok:!0,palette:e,failures:[]}}function f(r,e){return{forge:r,ok:!0,scale:e,failures:[]}}function a(r){let e=t(r),n=e.sources.map(o=>s(o.path));return{op:r.job.op,source:n[0]??"",sources:n,outputs:e.outputs.map(o=>s(o)),inputBytes:e.sources.reduce((o,u)=>o+u.bytes,0),outputBytes:e.outputBytes,warnings:e.warnings.map(o=>({code:o.code,message:o.message}))}}function i(r){let{error:e}=r;return{...r.path?{path:s(r.path)}:{},code:e.code,title:e.title,detail:e.detail,...e.hint===void 0?{}:{hint:e.hint}}}function l(r,e){return{forge:r,ok:e.failures.length===0,results:e.results.map(a),failures:e.failures.map(i)}}function J(r,e){return l(r,{results:[],failures:[{error:e}]})}function m(r,e){return{forge:r,ok:!0,formats:e,failures:[]}}function b(r,e){return{forge:r,ok:e.failures.length===0,probes:e.probes,failures:e.failures.map(i)}}function x(r,e,n){return{forge:r,ok:!0,config:e,warnings:n.map(o=>({code:o.code,message:o.message})),failures:[]}}function d(r,e){return{forge:r,ok:!0,extensions:e.extensions,...e.changed?{changed:e.changed}:{},failures:[]}}export{c as a,f as b,l as c,J as d,m as e,b as f,x as g,d as h};
3
+ import{a as t}from"./chunk-PSEIJXGT.js";import{resolve as s}from"node:path";function c(r,e){return{forge:r,ok:!0,palette:e,failures:[]}}function f(r,e){return{forge:r,ok:!0,scale:e,failures:[]}}function a(r){let e=t(r),n=e.sources.map(o=>s(o.path));return{op:r.job.op,source:n[0]??"",sources:n,outputs:e.outputs.map(o=>s(o)),inputBytes:e.sources.reduce((o,u)=>o+u.bytes,0),outputBytes:e.outputBytes,warnings:e.warnings.map(o=>({code:o.code,message:o.message}))}}function i(r){let{error:e}=r;return{...r.path?{path:s(r.path)}:{},code:e.code,title:e.title,detail:e.detail,...e.hint===void 0?{}:{hint:e.hint}}}function l(r,e){return{forge:r,ok:e.failures.length===0,results:e.results.map(a),failures:e.failures.map(i)}}function J(r,e){return l(r,{results:[],failures:[{error:e}]})}function m(r,e){return{forge:r,ok:!0,formats:e,failures:[]}}function b(r,e){return{forge:r,ok:e.failures.length===0,probes:e.probes,failures:e.failures.map(i)}}function x(r,e,n){return{forge:r,ok:!0,config:e,warnings:n.map(o=>({code:o.code,message:o.message})),failures:[]}}function d(r,e){return{forge:r,ok:!0,extensions:e.extensions,...e.changed?{changed:e.changed}:{},failures:[]}}export{c as a,f as b,a as c,i as d,l as e,J as f,m as g,b as h,x as i,d as j};
@@ -1,3 +1,3 @@
1
1
  import { createRequire as __forgeCreateRequire } from 'node:module';
2
2
  const require = __forgeCreateRequire(import.meta.url);
3
- import{I as n}from"./chunk-MMRDELHW.js";import{c as i,e as s,f as o}from"./chunk-H2IUSPAK.js";var g=["output","theme","quality","update-check"];async function p(a){if(a.action==="path")return{stdout:[i()],exitCode:0,config:{path:i()},warnings:[]};if(a.action==="list"){let{prefs:e,warning:u}=await s(),f=[`output ${e.defaultOutput}`,`theme ${e.theme??"not set"}`,`quality ${e.quality}`,`update-check ${e.updateCheck===!1?"off":"on"}`,"",i()];return u!==void 0&&f.unshift(`\u26A0 ${u}`,""),{stdout:f,exitCode:0,config:{output:e.defaultOutput,theme:e.theme??null,quality:e.quality,"update-check":e.updateCheck===!1?"off":"on",path:i()},warnings:u===void 0?[]:[{code:"config-unreadable",message:u}]}}let{key:r,value:t}=a;if(r==="theme"){if(t!=="dark"&&t!=="light")throw n(`Theme must be dark or light, not ${t}.`);return await o({theme:t}),{stdout:[`theme is now ${t}`],exitCode:0,config:{theme:t},warnings:[]}}if(r==="quality"){let e=Number(t);if(!Number.isInteger(e)||e<1||e>100)throw n(`Quality must be a whole number between 1 and 100, not ${t}.`);return await o({quality:e}),{stdout:[`quality is now ${e}`],exitCode:0,config:{quality:e},warnings:[]}}if(r==="update-check"){if(t!=="on"&&t!=="off")throw n(`update-check must be on or off, not ${t}.`);return await o({updateCheck:t==="on"}),{stdout:[`update-check is now ${t}`],exitCode:0,config:{"update-check":t},warnings:[]}}if(t.trim().length===0)throw n("Output must be a folder path.");return await o({defaultOutput:t}),{stdout:[`output is now ${t}`],exitCode:0,config:{output:t},warnings:[]}}export{g as a,p as b};
3
+ import{F as n}from"./chunk-DW2EJIUX.js";import{d as i,f as s,g as o}from"./chunk-5GJK5LP5.js";var g=["output","theme","quality","update-check"];async function p(a){if(a.action==="path")return{stdout:[i()],exitCode:0,config:{path:i()},warnings:[]};if(a.action==="list"){let{prefs:e,warning:u}=await s(),f=[`output ${e.defaultOutput}`,`theme ${e.theme??"not set"}`,`quality ${e.quality}`,`update-check ${e.updateCheck===!1?"off":"on"}`,"",i()];return u!==void 0&&f.unshift(`\u26A0 ${u}`,""),{stdout:f,exitCode:0,config:{output:e.defaultOutput,theme:e.theme??null,quality:e.quality,"update-check":e.updateCheck===!1?"off":"on",path:i()},warnings:u===void 0?[]:[{code:"config-unreadable",message:u}]}}let{key:r,value:t}=a;if(r==="theme"){if(t!=="dark"&&t!=="light")throw n(`Theme must be dark or light, not ${t}.`);return await o({theme:t}),{stdout:[`theme is now ${t}`],exitCode:0,config:{theme:t},warnings:[]}}if(r==="quality"){let e=Number(t);if(!Number.isInteger(e)||e<1||e>100)throw n(`Quality must be a whole number between 1 and 100, not ${t}.`);return await o({quality:e}),{stdout:[`quality is now ${e}`],exitCode:0,config:{quality:e},warnings:[]}}if(r==="update-check"){if(t!=="on"&&t!=="off")throw n(`update-check must be on or off, not ${t}.`);return await o({updateCheck:t==="on"}),{stdout:[`update-check is now ${t}`],exitCode:0,config:{"update-check":t},warnings:[]}}if(t.trim().length===0)throw n("Output must be a folder path.");return await o({defaultOutput:t}),{stdout:[`output is now ${t}`],exitCode:0,config:{output:t},warnings:[]}}export{g as a,p as b};
@@ -0,0 +1,3 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ import{a as k}from"./chunk-BZXDNDPG.js";import{b as S,g as O}from"./chunk-HCN4BH2H.js";import{b as y,e as f}from"./chunk-IMC5NRDC.js";import{a as h,b as d}from"./chunk-6VOCIMXQ.js";import{F as b}from"./chunk-DW2EJIUX.js";import{b as c,e as m}from"./chunk-5GJK5LP5.js";import{a as u,b as g}from"./chunk-BXJ2HTKI.js";import{dirname as w,join as P}from"node:path";var x="Same location",I="New subfolder";function D(e,t){return e===t?x:e===c("Desktop")?"Desktop":e===c("Downloads")?"Downloads":t!==void 0&&e===P(t,"converted")?I:k(e)||e}function A(e,t,n={}){return R(w(e.path),t,n)}function R(e,t,{subfolder:n=!1}={}){let o=m(t.defaultOutput),r=t.lastOutput?m(t.lastOutput):void 0,i=s=>({label:D(s,e),path:s}),a=[i(o),...r?[i(r)]:[],i(c("Desktop")),...e===void 0?[]:[{label:x,path:e}],i(c("Downloads")),...n&&e!==void 0?[{label:I,path:P(e,"converted")}]:[]],l=new Set,p=a.filter(s=>l.has(s.path)?!1:(l.add(s.path),!0));return{kind:"path",id:"destination",label:"Save to",default:o,presets:p,...r&&r!==o?{last:r}:{}}}var L=e=>typeof e=="string"&&e!==""?e:void 0;function q(e){return{kind:"select",id:"pages",label:"Pages",default:"all",choices:[{value:"all",label:"All pages",hint:`${e.pages} pages`},{value:"first",label:"First page only"},{value:"choose",label:"Choose pages",hint:"pick which ones"}]}}function C(){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 E(e,t){return Array.isArray(t)?d(t):t==="first"?[0]:typeof t=="string"&&t!=="all"&&t!==""?d(h(t,e.pages)):Array.from({length:e.pages},(n,o)=>o)}function N(e,t){let n=u[e.format].lossy,o=u[t].lossy;if(n&&!o)return{hint:"likely bigger",tone:"warn"};if(!n&&o)return{hint:"likely smaller",tone:"ok"}}function T(e){let t=y(e).filter(o=>o.id!==e.format),n=t[0];return{kind:"select",id:"target",label:`Convert ${u[e.format].label} to`,choices:t.map(o=>{let r=N(e,o.id);return{value:o.id,label:o.label,hint:r?.hint??o.hint,...r===void 0?{}:{tone:r.tone}}}),default:n?n.id:""}}function j(e){let t=e.target,n=typeof t=="string"?g(t):void 0;if(!n)throw b(`convertAction.plan() requires a valid target format, got ${JSON.stringify(t)}.`,"This is a caller bug, not a user-facing condition: call options() and pass one of the target select choices before calling plan().");return n}var K={id:"convert",label:"Convert",verb:"Converting",hint:"to another format",appliesTo:e=>e.length>=1,options(e,t,n){let o=e[0];if(!o)return[];let r=[T(o)],i=t.target;return typeof i!="string"||(o.kind==="document"&&f(i)&&r.push(q(o),C()),u[i]?.lossy&&r.push({kind:"slider",id:"quality",label:"Quality",min:1,max:100,step:5,default:n.quality}),r.push(A(o,n,{subfolder:!0}))),r},plan(e,t){let n=e[0];if(!n)return[];let o=j(t),r=o.id,i={background:typeof t.background=="string"?t.background:"#ffffff",keepMetadata:t.keepMetadata===!0};o.lossy&&typeof t.quality=="number"&&(i.quality=t.quality);let a=typeof t.destination=="string"?t.destination:void 0;if(n.kind==="document"&&f(r)){let p=Number(t.dpi);i.dpi=Number.isFinite(p)&&p>0?p:150;let s=E(n,t.pages);i.pages=s;let F=typeof t.sourceRoot=="string"?t.sourceRoot:void 0,v=O(n.path,s,r,a,F);return[{op:"convert",sources:[n],outputs:v,target:r,options:i}]}let l=S({sourcePath:n.path,target:r,...a===void 0?{}:{output:`${a}/`}});return[{op:"convert",sources:[n],outputs:[l],target:r,options:i}]}};export{I as a,A as b,R as c,L as d,K as e};
@@ -0,0 +1,5 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ import{c as A}from"./chunk-C2OZ5ERA.js";import{J as N,ea as v,fa as P,ga as $,ha as I,ia as w,ja as x}from"./chunk-DW2EJIUX.js";var j=new Set(["youtube.com","www.youtube.com","m.youtube.com","music.youtube.com"]),W=/^[A-Za-z0-9_-]{11}$/,S=t=>t&&W.test(t)?{kind:"video",id:t,url:`https://www.youtube.com/watch?v=${t}`}:void 0;function ie(t){let n=t.trim();if(n==="")return;let e;try{e=new URL(/^[a-z]+:\/\//i.test(n)?n:`https://${n}`)}catch{return}let r=e.hostname.toLowerCase();if(r==="youtu.be")return S(e.pathname.slice(1).split("/")[0]);if(!j.has(r))return;let[o,i]=e.pathname.split("/").filter(Boolean);if(o==="watch")return S(e.searchParams.get("v"));if(o==="shorts"||o==="live")return S(i);if(o==="playlist"&&e.searchParams.get("list"))return{kind:"playlist"}}var B="Summary and notes by Apple Intelligence. They may contain mistakes.";function E(t){let n=Math.floor(t),e=i=>String(i).padStart(2,"0"),r=Math.floor(n/3600),o=Math.floor(n/60)%60;return r>0?`${r}:${e(o)}:${e(n%60)}`:`${o}:${e(n%60)}`}var _=t=>t.split(/\s+/).filter(Boolean).length,C=60,G=140,K=1,Y=10;function H(t){let n=[],e;for(let r of t){if(e){let o=r.start-e.end;if(!(o>Y||o>K&&e.words>=C||e.words>=G)){e.text+=` ${r.text}`,e.end=r.end,e.words+=_(r.text);continue}n.push({start:e.start,text:e.text})}e={start:r.start,end:r.end,text:r.text,words:_(r.text)}}return e&&n.push({start:e.start,text:e.text}),n}var O=t=>H(t).flatMap(n=>[`**${E(n.start)}** ${n.text}`,""]);function ce(t,n){let e=[`# ${n.title}`,"",`${n.from} \xB7 ${E(t.seconds)}`,""],r=t.notes;if(!r)return[...e,...O(t.segments)].join(`
4
+ `);let o=r.parts,i=a=>{let s=o[a];return s?`### ${s.refused?`Part ${a+1}`:s.heading} \xB7 ${E(s.start)}`:""};return e.push(r.summary,"",`_${B}_`,"","## Notes",""),o.forEach((a,s)=>{e.push(i(s),""),a.points.length>0&&e.push(...a.points.map(c=>`- ${c}`),"")}),e.push("## Transcript",""),o.forEach((a,s)=>{let c=o[s+1]?.start??Number.POSITIVE_INFINITY,f=t.segments.filter(u=>u.start>=a.start&&u.start<c);e.push(i(s),"",...O(f))}),e.join(`
5
+ `)}function de(t){let n=[...t].map(e=>(e.codePointAt(0)??0)<32?" ":e).join("").replace(/[/\\:*?"<>|]/g,"-").replace(/\s+/g," ").trim().slice(0,120).replace(/^\.+/,"");return n===""?"transcript":n}import{spawn as z}from"node:child_process";import{existsSync as R}from"node:fs";import{dirname as J,join as L}from"node:path";import{createInterface as X}from"node:readline";import{fileURLToPath as Z}from"node:url";var y="forge-transcribe";function F(){let t=process.env.FORGE_TRANSCRIBE_HELPER;if(t!==void 0)return R(t)?t:void 0;if(process.platform!=="darwin")return;let n=J(Z(import.meta.url));return[L(n,"helpers",y),L(n,"..","helpers",y),L(n,"..","..","dist","helpers",y)].find(e=>R(e))}function k(t,n,e={}){let r=F();if(r===void 0)return Promise.reject(x("Transcribe needs macOS 26 or later on Apple silicon."));let{signal:o}=e;return o?.aborted?Promise.reject(o.reason??new Error("aborted")):new Promise((i,a)=>{let s=z(r,t,{stdio:["ignore","pipe","ignore"]}),c,f=!1,u=p=>{f||(f=!0,o?.removeEventListener("abort",h),p())},h=()=>{s.kill("SIGKILL"),u(()=>a(o?.reason??new Error("aborted")))};o?.addEventListener("abort",h,{once:!0}),X({input:s.stdout}).on("line",p=>{let m;try{m=JSON.parse(p)}catch{return}"ok"in m?c=m:e.onLine?.(m)}),s.on("error",p=>u(()=>a(v(n,p)))),s.on("close",()=>u(()=>{if(c===void 0)return a(v(n,new Error(`${y} gave no result`)));if(c.ok===!0)return i(c);a(q(String(c.code??""),String(c.message??""),n,t))}))})}function q(t,n,e,r){if(t==="no-sound")return P(e);if(t==="unreadable")return $(e);if(t==="locale"){let o=r.indexOf("--locale");return I(o>=0?r[o+1]??"this language":"this Mac's language")}return t==="unsupported"?x(n):v(e,new Error(`${t}: ${n}`))}async function he(t={}){if(F()===void 0)return;let n=["status",...t.locale?["--locale",t.locale]:[]],e=await k(n,"");return{speech:e.speech===!0,locale:typeof e.locale=="string"?e.locale:null,notes:e.notes==="available"||e.notes==="off"?e.notes:"unsupported"}}async function ve(t){let n=await k(["probe",t],t);return{seconds:Number(n.seconds)}}async function we(t,n){let e=["run",t,...n.locale?["--locale",n.locale]:[],...n.notes?["--notes"]:[]],r=await k(e,t,{signal:n.signal,onLine:o=>{let i=Q(o);i&&n.onEvent?.(i)}});return{locale:String(r.locale),seconds:Number(r.seconds),segments:r.segments,...r.notes?{notes:r.notes}:{}}}function Q(t){if(t.event==="model")return{kind:"model",fraction:Number(t.fraction)};if(t.event==="heard")return{kind:"heard",seconds:Number(t.seconds),of:Number(t.of)};if(t.event==="notes")return{kind:"notes",part:Number(t.part),of:Number(t.of)}}import{spawn as D}from"node:child_process";import{mkdtemp as ee,rm as te}from"node:fs/promises";import{tmpdir as ne}from"node:os";import{join as V}from"node:path";import{createInterface as re}from"node:readline";var oe=[[/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."]],b=class extends Error{};async function Pe(t,n={}){let e=await A("yt-dlp");if(e===void 0)throw N("yt-dlp");let r=await ee(V(ne(),"forge-yt-"));n.onDir?.(r);let o=()=>te(r,{recursive:!0,force:!0});try{let i;try{i=await M(e.entry,t,r,n)}catch(a){if(!(a instanceof b))throw a;await se(e.entry,n.signal);try{i=await M(e.entry,t,r,n)}catch(s){throw s instanceof b?w(`yt-dlp could not fetch this video: ${s.message}`,s):s}}return{...i,dispose:o}}catch(i){throw await o(),i}}function M(t,n,e,r){let{signal:o}=r;if(o?.aborted)return Promise.reject(o.reason??new Error("aborted"));let i=["--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",V(e,"sound.%(ext)s"),n];return new Promise((a,s)=>{let c=D(t,i,{stdio:["ignore","pipe","pipe"]}),f,u,h="",p=!1,m=d=>{p||(p=!0,o?.removeEventListener("abort",T),d())},T=()=>{c.kill("SIGKILL"),m(()=>s(o?.reason??new Error("aborted")))};o?.addEventListener("abort",T,{once:!0}),re({input:c.stdout}).on("line",d=>{if(d.startsWith("forge-facts ")){let l=JSON.parse(d.slice(12));if(l.is_live===!0){c.kill("SIGKILL"),m(()=>s(w("Live streams cannot be transcribed.")));return}f={title:String(l.title??""),uploader:String(l.uploader??""),seconds:Number(l.duration??0)},r.onEvent?.({kind:"facts",facts:f})}else if(d.startsWith("forge-bytes ")){let[l,g]=d.slice(12).split(" ").map(Number);Number.isFinite(l)&&Number.isFinite(g)&&(g??0)>0&&r.onEvent?.({kind:"bytes",done:l,total:g})}else d.startsWith("forge-file ")&&(u=d.slice(11))}),c.stderr.on("data",d=>{h+=d.toString()}),c.on("error",d=>m(()=>s(new b(d.message)))),c.on("close",d=>m(()=>{if(d===0&&f!==void 0&&u!==void 0)return a({path:u,facts:f});let l=h.match(/ERROR: (?:\[[^\]]*\] )?(?:[\w-]+: )?(.*)/)?.[1]?.trim()??"",g=oe.find(([U])=>U.test(l));s(g?w(g[1]):new b(l||`yt-dlp exited ${d}`))}))})}function se(t,n){return new Promise((e,r)=>{let o=D(t,["--update"],{stdio:"ignore"}),i=()=>o.kill("SIGKILL");n?.addEventListener("abort",i,{once:!0}),o.on("error",()=>e()),o.on("close",()=>{n?.removeEventListener("abort",i),n?.aborted?r(n.reason??new Error("aborted")):e()})})}export{ie as a,E as b,ce as c,de as d,he as e,ve as f,we as g,Pe as h};
@@ -0,0 +1,3 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ import{c as d}from"./chunk-BXJ2HTKI.js";import{existsSync as x,statSync as w}from"node:fs";import{basename as g,dirname as P,extname as f,isAbsolute as E,join as o,relative as I,resolve as s,sep as R}from"node:path";function $(t){return t.endsWith("/")||t.endsWith(R)||x(t)&&w(t).isDirectory()?!0:f(t)===""}function v(t,e){let r=g(t),n=f(r);return(n?r.slice(0,-n.length):r)+d(e)}function h(t,e,r){if(!r)return t;let n=I(s(r),e);return!n||n.startsWith("..")?t:o(t,n)}function F(t){let e=s(t.sourcePath),r=v(e,t.target);if(!t.output)return o(s(e,".."),r);let n=E(t.output)?t.output:s(t.output);return $(t.output)?o(h(n,s(e,".."),t.sourceRoot),r):s(n)}function D(t){let e=F(t);if(t.output&&!$(t.output))return e;let r=f(e);return o(s(e,".."),`${g(e,r)}-${t.suffix}${r}`)}function _(t){if(!x(t))return t;let e=s(t,".."),r=g(t),n=f(r),i=n?r.slice(0,-n.length):r;for(let u=1;u<1e4;u++){let c=o(e,`${i} (${u})${n}`);if(!x(c))return c}throw new Error(`no free name beside ${r}`)}function a(t){let e=s(t,".."),r=g(t),n=f(r);return{dir:e,stem:n?r.slice(0,-n.length):r,ext:n||".pdf"}}function O(t,e){let{dir:r,stem:n,ext:i}=a(s(t));return o(r,`${n}-${e}${i}`)}function z(t,e){let{dir:r,stem:n,ext:i}=a(s(t)),u=String(e).length;return Array.from({length:e},(c,p)=>o(r,`${n}-${String(p+1).padStart(u,"0")}${i}`))}function L(t,e,r,n,i){let{stem:u}=a(s(t)),c=n?h(s(n),s(t,".."),i):s(t,".."),p=d(r),b=String(Math.max(1,...e.map(m=>m+1))).length,y=e.map(m=>o(c,`${u}-${String(m+1).padStart(b,"0")}${p}`)),[l,...S]=y;if(l===void 0)throw new Error("rasterOutputPaths requires at least one selected page");return[l,...S]}function M(t,e,r){if(!r)return[O(t,"extract")];let{dir:n,stem:i,ext:u}=a(s(t));return e.map(c=>o(n,`${i}-p${c+1}${u}`))}function T(t){let e=s(t[0]??"merged.pdf");if(new Set(t.map(n=>s(n,".."))).size===1){let n=s(e,"..");return o(n,`${g(n)}-merged.pdf`)}return O(e,"merged")}function A(t,e,r){let n=e?t.map(u=>o(e,g(u))):t,[i]=n;return!r||n.length!==1||i===void 0?n:[o(P(i),`${r}${f(i)}`)]}function B(t,e,r){return A([t],e,r)[0]??t}export{$ as a,F as b,D as c,_ as d,O as e,z as f,L as g,M as h,T as i,A as j,B as k};
@@ -0,0 +1,4 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ import{d as f}from"./chunk-5GJK5LP5.js";import{randomBytes as g}from"node:crypto";import{mkdir as N,readFile as b,rename as x,rm as y,writeFile as k}from"node:fs/promises";import{dirname as l,join as E}from"node:path";var A="https://registry.npmjs.org/forge-terminal/latest",C=1440*60*1e3,R=3e3,O=/^(\d+)\.(\d+)\.(\d+)$/;function a(t){let e=O.exec(t);return e?[Number(e[1]),Number(e[2]),Number(e[3])]:void 0}function P(t,e){let n=a(t),o=a(e);if(!n||!o)return!1;for(let r=0;r<3;r++)if(n[r]!==o[r])return n[r]>o[r];return!1}function D(t,e=process.env){return!(t.updateCheck===!1||e.CI!==void 0&&e.CI!==""&&e.CI!=="false"||e.FORGE_NO_UPDATE_CHECK!==void 0&&e.FORGE_NO_UPDATE_CHECK!=="")}var S=20,_=22,T=200;function U(t){let e=t.codePointAt(0)??0;return e>=32&&(e<127||e>159)}var d=(t,e)=>typeof t=="string"?[...t].filter(U).join("").trim().slice(0,e):"";function p(t){if(!Array.isArray(t))return;let e=t.map(n=>{let{title:o,text:r}=typeof n=="object"&&n!==null?n:{};return{title:d(o,_),text:d(r,T)}}).filter(n=>n.title!==""&&n.text!=="").slice(0,S);return e.length>0?e:void 0}function h(){return E(l(f()),"update-check.json")}async function c(){try{let t=JSON.parse(await b(h(),"utf8"));if(typeof t!="object"||t===null)return;let{checkedAt:e,latest:n,notifiedAt:o,whatsNew:r}=t;if(typeof e!="number")return;let s=typeof n=="string"&&a(n)!==void 0,i=s?p(r):void 0;return{checkedAt:e,...s?{latest:n}:{},...typeof o=="number"?{notifiedAt:o}:{},...i?{whatsNew:i}:{}}}catch{return}}async function F(t){let e=h();await N(l(e),{recursive:!0});let n=`${e}.${g(4).toString("hex")}.tmp`;try{await k(n,`${JSON.stringify(t)}
4
+ `),await x(n,e)}catch(o){throw await y(n,{force:!0}).catch(()=>{}),o}}function L(t,e=Date.now()){return t===void 0?!0:t.checkedAt>e||e-t.checkedAt>C}async function $(t={}){return(await w(t))?.version}async function w(t){let e=t.fetchImpl??fetch,n=AbortSignal.timeout(t.timeoutMs??R),o=t.signal?AbortSignal.any([t.signal,n]):n;try{let r=await e(A,{signal:o,headers:{accept:"application/json"}});if(!r.ok)return;let s=await r.json(),{version:i,whatsNew:m}=s??{};if(typeof i!="string"||!a(i))return;let u=p(m);return u?{version:i,whatsNew:u}:{version:i}}catch{return}}async function G(t={}){let e=await w(t),n=await c(),o=e??(n?.latest!==void 0?n:void 0),r=e?.version??n?.latest,s={checkedAt:t.now??Date.now(),...r!==void 0?{latest:r}:{},...n?.notifiedAt!==void 0?{notifiedAt:n.notifiedAt}:{},...o?.whatsNew!==void 0?{whatsNew:o.whatsNew}:{}};return await F(s).catch(()=>{}),e?.version}async function H(t){let e=await c();return e?.latest===t?e.whatsNew??[]:[]}async function J(t){let e=(await c())?.latest;return e!==void 0&&P(e,t)?e:void 0}export{A as a,C as b,P as c,D as d,S as e,_ as f,T as g,h,c as i,F as j,L as k,$ as l,G as m,H as n,J as o};
@@ -0,0 +1,3 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ import{f as i,g as n}from"./chunk-6VOCIMXQ.js";import{a as e}from"./chunk-BXJ2HTKI.js";function a(t){let o=Object.keys(e);return[...t].sort((r,s)=>o.indexOf(r)-o.indexOf(s))}function f(t){let o=new Set;for(let r of n)if(r.reads.has(t.format))for(let s of r.writes)o.add(s);return a([...o])}function F(t){return f(t).map(o=>({id:o,label:e[o].label,hint:e[o].hint,lossy:e[o].lossy}))}function d(){let t=new Set;for(let o of n)for(let r of o.reads)t.add(r);return a([...t])}function l(){let t=new Set;for(let o of n)for(let r of o.writes)t.add(r);return a([...t])}function p(t){return i.writes.has(t)}function I(){let t=new Set(d()),o=new Set(l());return a([...new Set([...t,...o])]).map(r=>({id:r,label:e[r].label,extensions:[...e[r].extensions],read:t.has(r),write:o.has(r),lossy:e[r].lossy}))}export{f as a,F as b,d as c,l as d,p as e,I as f};
@@ -0,0 +1,3 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ import{h as E}from"./chunk-6VOCIMXQ.js";import{$ as A,A as M,d as v,ea as F,p as I,s as S,x as R,y as P,z as w}from"./chunk-DW2EJIUX.js";function U(e=1,t=100){let n=Math.max(1,t-e+1);return 1+Math.max(0,Math.ceil(Math.log2(n)))}async function B(e){let t=e.min??1,n=e.max??100,l=U(t,n),c=0,s=async r=>(c+=1,e.onAttempt?.(c,l),e.encode(r)),a=()=>e.signal?.aborted===!0,i=await s(n);if(a())return{quality:n,bytes:i,missed:!1,cancelled:!0};if(i<=e.targetBytes)return{quality:n,bytes:i,missed:!1};let f=t,p=n,b;for(;f<=p;){let r=Math.floor((f+p)/2),d=await s(r);if(a())return{quality:r,bytes:d,missed:!1,cancelled:!0};d<=e.targetBytes?(b={quality:r,bytes:d,missed:!1},f=r+1):p=r-1}if(b)return b;let h=await e.encode(t);return{quality:t,bytes:h,missed:!0}}import{cpus as O}from"node:os";function q(){return Math.max(1,Math.min(O().length,4))}function J(e){let t=e!==void 0&&Number.isFinite(e)?e:void 0;return Math.max(1,t??q())}async function x(e,t,n){let l=0,c=async()=>{for(;l<e.length;){let a=l++;await n(e[a],a)}},s=Math.min(J(t),e.length);await Promise.all(Array.from({length:s},c))}async function T(e,t){let n=t.onEvent??(()=>{}),l=t.engineFor??E,c=J(t.concurrency),s=e.length,a=[],i=[],f=0;await x(e,c,async(r,d)=>{n({type:"job:start",job:r,index:d,total:s});let g=l(r);if(!g){f++;let o=r.sources[0].path,u={path:o,error:F(o,new Error(`no engine runs ${r.op}`))};i[d]=u,n({type:"job:error",job:r,failure:u,completed:f,total:s});return}try{let o=await g.run(r,u=>n({type:"job:phase",job:r,progress:u}),t.signal);a[d]=o,f++,n({type:"job:done",job:r,result:o,completed:f,total:s})}catch(o){f++;let u=r.sources[0].path,y=v(o)?o:F(u,o),m={path:u,error:y};i[d]=m,n({type:"job:error",job:r,failure:m,completed:f,total:s})}});let p=a.filter(r=>r!==void 0),b=i.filter(r=>r!==void 0),h={results:p,failures:b,inputBytes:p.reduce((r,d)=>r+d.job.sources[0].bytes,0),outputBytes:p.reduce((r,d)=>r+d.outputBytes,0)};return n({type:"batch:done",summary:h}),h}import{existsSync as N}from"node:fs";import{resolve as k}from"node:path";function _(e){let t=e.sources[0]?.path??e.outputs[0]??"",n=new Set;for(let l of e.outputs){let c=k(l);if(n.has(c))return{output:l,error:w(t,l)};n.add(c)}}function D(e,t,n){let l=_(e);if(l)return l;let c=new Set(e.sources.map(a=>k(a.path))),s=e.sources[0]?.path??e.outputs[0]??"";for(let a of e.outputs){let i=k(a);if(c.has(i)&&!n)return{output:a,error:M(a,e.op)};let f=t.get(i);if(f){let p=f.sources[0]?.path??f.outputs[0]??"";return{output:a,error:P([p,s],a)}}if(N(i)&&!n)return{output:a,error:R(a,e.op)}}}function C(e,t){let n=[],l=[],c=new Map;for(let s of e){let a=D(s,c,t.force);if(a){let i=s.sources[0]?.path??a.output;l.push({path:i,error:a.error});continue}for(let i of s.outputs)c.set(k(i),s);n.push(s)}return{jobs:n,failures:l}}async function L(e,t,n,l,c){let s=e.sources[0].path,a=o=>({kind:"failed",failure:{path:s,error:v(o)?o:F(s,o)}}),i;try{i=await n(e)?.measurer?.(e)}catch(o){return a(o)}if(!i||i.ladder.length===0)return{kind:"refused",failure:{path:s,error:I(e.sources[0],e.target)}};let f=i,p=e.sources[0],b=e.options.compress!==void 0&&p.bytes<=t,h=b?p.bytes-1:t;if(c?.aborted)return{kind:"cancelled"};let r=Number.POSITIVE_INFINITY,d;try{for(let o of f.ladder){let u=await B({encode:y=>f.measure({...e.options,...o,quality:y}),targetBytes:h,onAttempt:(y,m)=>l({type:"search:attempt",job:e,attempt:y,of:m,rung:o}),...c===void 0?{}:{signal:c}});if(u.cancelled)return{kind:"cancelled"};if(u.bytes<r&&(r=u.bytes,d={...o,quality:u.quality}),!u.missed)return e.options={...e.options,...o,quality:u.quality},{kind:"ready"}}}catch(o){return a(o)}return b?{kind:"failed",failure:{path:s,error:A(s,p.bytes,r,!0)}}:{kind:"unreachable",entry:{job:e,smallest:r,settings:d??{quality:1},error:S(e.sources[0],t,r)}}}async function re(e,t){let n=t.onEvent??(()=>{}),l=t.engineFor??E,c=t.targetBytes,s=C(e,{force:t.force}),a=c===void 0?0:s.jobs.filter(u=>u.op==="convert").length,i=[],f=0;await x(s.jobs,J(t.concurrency),async(u,y)=>{if(c===void 0||u.op!=="convert"){i[y]={kind:"ready"};return}if(t.signal?.aborted){i[y]={kind:"cancelled"};return}let m=await L(u,c,l,n,t.signal);i[y]=m,m.kind!=="cancelled"&&(f+=1,n({type:"search:settled",job:u,completed:f,total:a}))});let p=[...s.failures],b=[],h=[],r=[],d=!1;for(let[u,y]of s.jobs.entries()){let m=i[u]??{kind:"ready"};m.kind==="ready"?r.push(y):m.kind==="refused"?p.push(m.failure):m.kind==="failed"?h.push(m.failure):m.kind==="unreachable"?b.push(m.entry):d=!0}if(d)return{results:[],refusals:p,unreachable:[],failures:[],inputBytes:0,outputBytes:0,cancelled:!0};let g=new Set,o=await T(r,{...t.concurrency===void 0?{}:{concurrency:t.concurrency},...t.engineFor===void 0?{}:{engineFor:t.engineFor},...t.signal===void 0?{}:{signal:t.signal},onEvent:u=>{u.type==="job:error"&&!t.signal?.aborted&&g.add(u.failure),n(u)}});if(t.signal?.aborted&&o.failures.length>0){let u=o.failures.filter(y=>g.has(y));return{...o,refusals:p,unreachable:b,failures:[...h,...u],cancelled:!0}}return{results:o.results,refusals:p,unreachable:b,failures:[...h,...o.failures],inputBytes:o.inputBytes,outputBytes:o.outputBytes}}export{J as a,C as b,re as c};
@@ -0,0 +1,4 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ var v="0.4.0",x={ok:"\u2713",fail:"\u2715",warn:"\u26A0",cursor:"\u276F",strip:"\u258C",star:"\u2605",arrow:"\u2192",tip:"\u2727",longArrow:"\u2500\u2500\u2192",longArrowDown:`\u2502
4
+ \u25BC`,dotFilled:"\u25CF",dotEmpty:"\u25CB"},f={name:"dark",fg:"#e7e7e7",dim:"#b0b0b0",accent:"#e5a23c",ok:"#6fcf7f",warn:"#e5c07b",fail:"#e8796d",failTint:"#2e2020",failTintDim:"#b0b0b0",larger:"#f2994a",shedHatch:"#47774f",grownFill:"#403225",tag:"#63c1d8",label:"#a68ce0",modeConvert:"#55c7d9",modeConvertBg:"#122c33",modeCompress:"#79c98b",modeCompressBg:"#182c1e",modePdf:"#ff6b4a",modePdfBg:"#361c16",modeColour:"#f27ba8",modeColourBg:"#3a1e2b",modeEdit:"#b39ae8",modeEditBg:"#2a2238",modeTranscribe:"#e63946",modeTranscribeBg:"#3a1a1d",border:"#808080",selectionBg:"#2c2c2c",band:"#2c2c2c",canvas:"#1e1e1e",textSelectionBg:"#3f5c86",brand:"#e5a23c",keycapBg:"#333333",violet:"#a68ce0",faint:"#4d4d4d",listBand:"#323232",shelf:"#242424",tabChip:"#262626",panelBand:"#404040",ink:"#0c1d22",track:"#2e2e2e",trackFill:"#515151",thumb:"#e7e7e7",folderChip:"#414141",pill:"#e7e7e7",fieldBand:"#3d3d3d",defaultTagBg:"#33261a",defaultTag:"#c98a4b",newTagBg:"#2a3448",newTag:"#4f77c5"},o={name:"light",fg:"#262626",dim:"#4f4f4f",accent:"#915a01",ok:"#0e702c",warn:"#8a6100",fail:"#a43c32",failTint:"#f9e3df",failTintDim:"#4a4a4a",larger:"#8b4d01",shedHatch:"#87b896",grownFill:"#ece3d6",tag:"#0a6b86",label:"#5e4b99",modeConvert:"#036b7b",modeConvertBg:"#e6f7fa",modeCompress:"#24733a",modeCompressBg:"#eaf5ec",modePdf:"#b82a06",modePdfBg:"#fceee9",modeColour:"#b0306a",modeColourBg:"#f7e3ec",modeEdit:"#64569f",modeEditBg:"#f0ebfa",modeTranscribe:"#c0102c",modeTranscribeBg:"#fef0ef",border:"#767676",selectionBg:"#e4e4e4",band:"#e4e4e4",canvas:"#ffffff",textSelectionBg:"#b9cfe8",brand:"#915a01",keycapBg:"#e1e1e1",violet:"#5e4b99",faint:"#b2b2b2",listBand:"#dcdcdc",shelf:"#f3f3f3",tabChip:"#f0f0f0",panelBand:"#d5d5d5",ink:"#ffffff",track:"#e4e4e4",trackFill:"#afafaf",thumb:"#262626",folderChip:"#d0d0d0",pill:"#262626",fieldBand:"#d7d7d7",defaultTagBg:"#f5e2cc",defaultTag:"#8f5000",newTagBg:"#e1e7f4",newTag:"#3358a3"},i={name:"neutral",fg:"",dim:"gray",accent:"yellow",ok:"green",warn:"yellow",fail:"red",failTint:"",failTintDim:"gray",larger:"yellow",shedHatch:"green",grownFill:"",tag:"cyan",label:"magenta",modeConvert:"cyan",modeConvertBg:"",modeCompress:"green",modeCompressBg:"",modePdf:"red",modePdfBg:"",modeColour:"magenta",modeColourBg:"",modeEdit:"magenta",modeEditBg:"",modeTranscribe:"redBright",modeTranscribeBg:"",border:"gray",selectionBg:"",band:"",canvas:"",textSelectionBg:"",brand:"yellow",keycapBg:"",violet:"magenta",faint:"gray",listBand:"",shelf:"",tabChip:"",panelBand:"",ink:"",track:"",trackFill:"",thumb:"",folderChip:"",pill:"",fieldBand:"",defaultTagBg:"",defaultTag:"",newTagBg:"",newTag:""},d=["convert","compress","pdf","edit","colour","transcribe"],k=`1\u2013${d.length}`;function E(e,t){let r=d,n=e==="menu"?r.length:r.indexOf(e),a=Math.max(0,Math.min(r.length-1,n+t));return r[a]}function P(e){return/^[1-9]$/.test(e)?d[Number(e)-1]:void 0}var S={convert:"\u2194",compress:"\u2193",pdf:"\u25A3",colour:"\u25D0",edit:"\u2726",transcribe:"\xB6"},c="#7d6ad0",l="#cc8ae2";function s(e,t){return t==="compress"?{fg:e.modeCompress,bg:e.modeCompressBg}:t==="pdf"?{fg:e.modePdf,bg:e.modePdfBg}:t==="colour"?{fg:e.modeColour,bg:e.modeColourBg}:t==="edit"?{fg:e.modeEdit,bg:e.modeEditBg}:t==="transcribe"?{fg:e.modeTranscribe,bg:e.modeTranscribeBg}:{fg:e.modeConvert,bg:e.modeConvertBg}}var g=["#f26e69","#e5a23c","#ace02c","#55c7d9","#6579fd","#ad95e9"],b=["#e5a23c","#f2cf6b"],m={convert:["#1e96a7","#1e94b3","#1e92c0","#1d8ed2","#1b86ef","#4a7df8","#6974f8","#816af8","#995cf8"],compress:["#24b459","#22ab6d","#21a479","#209f81","#1f9c89","#1f9a91","#1e9998","#1e97a0","#1e96a7"],pdf:["#eb4319","#e3541a","#de601b","#db6a1c","#d9731d","#d87c1e","#d8841f","#d98c20","#d99522"],edit:["#9b5af8","#985cf8","#965ef8","#945ff8","#9161f8","#8f62f8","#8d64f8","#8a65f8","#8867f8"],transcribe:["#f3233e","#f12259","#ee2270","#ea2186","#e6219b","#e121b0","#da22c6","#d122dc","#c723f2"],colour:["#f42335","#e05b1a","#d87d1e","#da9b23","#d2b427","#b4c027","#5bbf23","#20a27c","#1e989b","#1e94b6","#1c8cd9","#577af8","#7371f8","#8568f8","#965df8"]},u=["#d99522","#da9822","#da9b23","#da9f24","#d9a224","#d9a525","#d8a825","#d7ab26","#d6ad26"],B={convert:["#d6f7fd","#ddf5fe","#e1f4fe","#e4f2fe","#e7f1fe","#eaf0fe","#eceffe","#efeefe","#f1edfe"],compress:["#e0f7e4","#def8e7","#dcf8ea","#daf8ed","#d8f8f1","#d7f8f4","#d6f8f7","#d6f8fa","#d6f7fd"],pdf:["#feece7","#feece6","#feece5","#feece3","#feece2","#feede0","#feedde","#feeddc","#feeed9"],edit:["#f2edfe","#f1edfe","#f1edfe","#f1eefe","#f0eefe","#f0eefe","#f0eefe","#f0eefe","#efeefe"],transcribe:["#feebea","#feebec","#feebee","#feeaf0","#feeaf2","#feeaf5","#fee9f9","#fde9fd","#f9eafe"],colour:["#feebe9","#feece5","#feede0","#feeed7","#f7f1d6","#eff3d9","#e5f6df","#dbf8eb","#d6f8f8","#def5fe","#e5f2fe","#ebf0fe","#edeffe","#efeefe","#f1edfe"]},p=["#feeed9","#feeed8","#feeed7","#fdeed6","#fcefd6","#fbefd6","#fbefd6","#faefd6","#f9f0d6"],T={convert:["#138291","#8467bd"],compress:["#2b8748","#138291"],pdf:["#d54322","#a06c10"],edit:["#8567bc","#7b67cd"],transcribe:["#df3140","#9c5cb1"],colour:["#cb4b49","#a06c10","#618110","#138291","#5869ec","#8268bd"]};function C(e,t){return e.name==="light"?t==="menu"?u:m[t]:t==="menu"?e.name==="dark"?b:[e.brand]:t==="compress"?[e.modeCompress,e.modeConvert]:t==="pdf"?[e.modePdf,e.brand]:t==="colour"?e.name==="dark"?g:[e.modeColour,e.violet]:t==="edit"?[e.modeEdit,e.name==="dark"?c:e.violet]:t==="transcribe"?[e.modeTranscribe,e.name==="dark"?l:e.violet]:[e.modeConvert,e.violet]}function y(e,t){if(e.name==="light")return t==="menu"?p:B[t]}function w(e,t){return e.name==="light"?T[t]:C(e,t)}function M(e){return{...e,accent:e.brand,tag:e.brand,label:e.brand}}function R(e,t){let{fg:r,bg:n}=s(e,t);return{...e,accent:r,tag:r,label:r,band:n===""?e.band:n}}function H(e){return e.canvas!==""}function O(e){return e==="dark"?f:e==="light"?o:i}function D(e){return e===""?void 0:e}var _={filled:"\u2501",empty:"\u2501",knob:"\u25CF"};function h(){return process.env.NO_COLOR!==void 0&&process.env.NO_COLOR!==""?!1:process.stdout.isTTY===!0}function F(){h()||(process.env.FORCE_COLOR="0")}export{v as a,x as b,f as c,o as d,i as e,d as f,k as g,E as h,P as i,S as j,s as k,C as l,y as m,w as n,M as o,R as p,H as q,O as r,D as s,_ as t,h as u,F as v};
@@ -0,0 +1,3 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ import{c as h}from"./chunk-JBSYGB3F.js";import{i as P}from"./chunk-6VOCIMXQ.js";import{d as y,ea as s}from"./chunk-DW2EJIUX.js";import{mkdtemp as F,rm as x}from"node:fs/promises";import{tmpdir as z}from"node:os";import{join as v}from"node:path";var f={background:"#ffffff",keepMetadata:!1};function w(e,r,o){switch(e.kind){case"cut":return{op:"convert",sources:[r],outputs:[o],target:"png",options:{...f,...e.trim?{trim:!0}:{},...e.crop?{crop:{aspect:e.crop}}:{},...e.resize?{resize:e.resize}:{}}};case"cutout":return{op:"remove-background",sources:[r],outputs:[o],target:"png",options:f};case"boost":return{op:"boost",sources:[r],outputs:[o],scale:e.scale,target:"png",options:f};case"encode":return{op:"convert",sources:[r],outputs:[o],target:e.target,options:{...f,...e.background?{background:e.background}:{},...e.quality!==void 0?{quality:e.quality}:{},...e.trim?{trim:!0}:{},...e.crop?{crop:{aspect:e.crop}}:{},...e.resize?{resize:e.resize}:{}}}}}async function C(e,r,o,n){let E=n.probe??P,l=await F(v(z(),"forge-preset-")),I={force:n.force,...n.signal?{signal:n.signal}:{},...n.onEvent?{onEvent:n.onEvent}:{}};try{let i=e;for(let[d,t]of r.entries()){let u=d===r.length-1,g=u?o:v(l,`${d}.png`),a=await h([w(t,i,g)],{...I,...u?{}:{force:!0},...u&&t.kind==="encode"&&t.maxBytes?{targetBytes:t.maxBytes}:{}});if(a.cancelled)return{kind:"cancelled"};let m=a.refusals[0];if(m)return{kind:"refused",error:m.error};let p=a.unreachable[0];if(p)return{kind:"unreachable",entry:p};let b=a.failures[0];if(b)return{kind:"failed",pass:t,error:b.error};let c=a.results[0];if(!c)return{kind:"failed",pass:t,error:s(e.path,"no result")};if(u){let j=c.job.op==="convert"?{...c.job,sources:[e]}:c.job;return{kind:"done",result:{...c,job:j}}}let k=await E(g);if(k.kind!=="image")return{kind:"failed",pass:t,error:s(e.path,"not an image")};i=k}return{kind:"failed",pass:{kind:"encode",target:e.format},error:s(e.path,"nothing to run")}}catch(i){return{kind:"failed",pass:r[r.length-1]??{kind:"encode",target:e.format},error:y(i)?i:s(e.path,i)}}finally{await x(l,{recursive:!0,force:!0})}}export{C as a};
@@ -0,0 +1,3 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ import{b as C,d as a,e as N}from"./chunk-FWMFN36F.js";import{a as k}from"./chunk-BZXDNDPG.js";import{c as l,e as f,f as J,h as q,i as E,j as g,k as s}from"./chunk-HCN4BH2H.js";import{d as j,f as I,g as D}from"./chunk-CBE73ZWA.js";import{a as F}from"./chunk-IMC5NRDC.js";import{a as M,b as S,d as R}from"./chunk-6VOCIMXQ.js";import{d as P,k as T,s as y}from"./chunk-D6JPP65L.js";import{F as d,t as w}from"./chunk-DW2EJIUX.js";import{a as m,c as z}from"./chunk-BXJ2HTKI.js";import{dirname as nt}from"node:path";var it=t=>t.length===1&&t[0]?.kind==="image"?t[0]:void 0,rt=t=>t.length===1&&t[0]?.kind==="document"?t[0]:void 0,at="-small",c={min:30,max:100,step:35},st=t=>{let e=Math.ceil((t-c.min)/c.step);return Math.min(c.max,c.min+Math.max(0,e)*c.step)},v={id:"compress",label:"Compress",verb:"Compressing",hint:"make it smaller",appliesTo:t=>{let e=it(t);if(e!==void 0){let n=m[e.format];return n.lossy||n.quantisable===!0}return(rt(t)?.images?.compressible??0)>0},options(t,e,o){let n=t[0];if(!n)return[];let r=[{kind:"select",id:"mode",label:`Compress ${k(n.path)??"this file"}`,choices:[{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"){let i=n.kind==="image"&&m[n.format].quantisable===!0;r.push(i?{kind:"slider",id:"quality",label:"Quality",...c,default:st(o.quality),points:!0}:{kind:"slider",id:"quality",label:"Quality",min:1,max:100,step:5,default:o.quality})}else if(e.mode==="size")r.push({kind:"text",id:"size",label:"Target size",placeholder:"e.g. 500kb or 2mb"});else return r;return r.push(C(n,o)),r},plan(t,e){let o=e.mode;if(o!=="quality"&&o!=="size")throw d(`compressAction.plan() needs a mode of "quality" or "size", got ${JSON.stringify(o)}.`,"This is a caller bug, not a user-facing condition: walk options() before calling plan().");let n=t[0];if(!n)return[];let r=(k(n.path)??"file").replace(/\.[^.]+$/,""),p=`${typeof e.destination=="string"?e.destination:nt(n.path)}/${r}${at}${z(n.format)}`;return[{op:"convert",sources:[n],target:n.format,outputs:[p],options:{background:"#ffffff",keepMetadata:!1,...o==="quality"&&typeof e.quality=="number"?{quality:e.quality}:{},compress:{dither:e.dither===!0}}}]}};var b=t=>t.length>0&&t.every(e=>e.kind==="image")?t:void 0;function wt(t,e){let o=F(t);return o.includes(e)?void 0:w(t,e,o)}function $(t){return{target:t.target??"png",background:typeof t.background=="string"?t.background:"#ffffff",keepMetadata:t.keepMetadata===!0,...typeof t.output=="string"?{output:t.output}:{},...t.roots instanceof Map?{roots:t.roots}:{},...typeof t.quality=="number"?{quality:t.quality}:{}}}var B=()=>({kind:"select",id:"target",label:"Save as",default:"png",choices:[{value:"png",label:"PNG",hint:m.png.hint}]}),pt=t=>t===1?"sharp":`${t}x`,ct=t=>t===1||t===3||t===4?t:2,_={id:"boost",label:"Boost resolution",verb:"Boosting",hint:"sharper, at its size or at 2\xD7, 3\xD7 or 4\xD7",requires:"boost",appliesTo:t=>b(t)!==void 0,unavailable:()=>"images only",options:()=>[{kind:"select",id:"scale",label:"Scale",default:"2",choices:[{value:"1",label:"Sharpen",hint:"the same size, sharper"},{value:"2",label:"2\xD7",hint:"twice the width and height"},{value:"3",label:"3\xD7",hint:"three times the width and height"},{value:"4",label:"4\xD7",hint:"four times the width and height"}]},B()],plan(t,e){let o=b(t);if(!o)return[];let n=$(e),r=ct(Number(e.scale??2));return o.map(i=>({op:"boost",sources:[i],outputs:[l({sourcePath:i.path,target:n.target,suffix:pt(r),...n.output===void 0?{}:{output:n.output},...n.roots?.get(i.path)===void 0?{}:{sourceRoot:n.roots.get(i.path)}})],scale:r,target:n.target,options:{background:n.background,keepMetadata:n.keepMetadata,...n.quality===void 0?{}:{quality:n.quality}}}))}},G={id:"remove-background",label:"Remove background",verb:"Removing",hint:"cut out the subject",requires:"remove-background",appliesTo:t=>b(t)!==void 0,unavailable:()=>"images only",options:()=>[B()],plan(t,e){let o=b(t);if(!o)return[];let n=$(e);return o.map(r=>({op:"remove-background",sources:[r],outputs:[l({sourcePath:r.path,target:n.target,suffix:"cutout",...n.output===void 0?{}:{output:n.output},...n.roots?.get(r.path)===void 0?{}:{sourceRoot:n.roots.get(r.path)}})],target:n.target,options:{background:n.background,keepMetadata:n.keepMetadata,...n.quality===void 0?{}:{quality:n.quality}}}))}};function ut(t,e){if(e.crop){let o=T(e.crop.aspect);if(!e.resize)return o;let n=e.crop.box??P(t,e.crop.aspect);return`${o}-${I(y(n,e.resize))}`}return e.trim&&e.resize?`trimmed-${D(e.resize)}`:e.resize?I(y(t,e.resize)):"trimmed"}function mt(t,e){if(e.trim&&e.crop)throw new Error("planEdit cannot trim and crop the same image");return t.map(o=>{let n=e.target??j(o),r={background:e.background,keepMetadata:e.keepMetadata,...e.quality===void 0?{}:{quality:e.quality},...e.trim?{trim:!0}:{},...e.resize?{resize:e.resize}:{},...e.crop?{crop:e.crop}:{}},i=e.roots?.get(o.path),p=l({sourcePath:o.path,target:n,suffix:ut(o,e),...e.output===void 0?{}:{output:e.output},...i===void 0?{}:{sourceRoot:i}});return{op:"convert",sources:[o],outputs:[s(p,a(e.destination),a(e.name))],target:n,options:r}})}var x=t=>t.length>0&&t.every(e=>e.kind==="image")?t:void 0,lt=t=>typeof t=="object"&&t!==null&&("percent"in t||"width"in t||"height"in t),Q=t=>typeof t=="object"&&t!==null&&"aspect"in t&&typeof t.aspect=="object"&&t.aspect!==null&&"w"in t.aspect&&"h"in t.aspect;function A(t,e,o,n){return{id:t,label:e,verb:o,hint:n,appliesTo:r=>x(r)?.every(i=>t==="resize"||i.frames<=1)===!0,unavailable:r=>x(r)?"animated":"images only",options:()=>[],plan(r,i){let p=x(r);return p?t==="crop"&&!Q(i.crop)?[]:mt(p,{trim:t==="trim"||i.trim===!0,...lt(i.resize)?{resize:i.resize}:{},...Q(i.crop)?{crop:i.crop}:{},...typeof i.target=="string"?{target:i.target}:{},...typeof i.output=="string"?{output:i.output}:{},...i.roots instanceof Map?{roots:i.roots}:{},destination:i.destination,name:i.name,background:typeof i.background=="string"?i.background:"#ffffff",keepMetadata:i.keepMetadata===!0,...typeof i.quality=="number"?{quality:i.quality}:{}}):[]}}}var X=A("trim","Trim edges","Trimming edges","cut empty borders"),H=A("resize","Resize","Resizing","smaller or larger"),U=A("crop","Crop to shape","Cropping","change the shape");var h=t=>t.length===1&&t[0]?.kind==="document"&&t[0].format==="pdf"?t[0]:void 0,K={id:"split",label:"Split",verb:"Splitting",hint:"into several files",appliesTo:t=>(h(t)?.pages??0)>1,unavailable:t=>h(t)===void 0?"one PDF at a time":"only one page",options(t){let e=h(t);return e?[{kind:"select",id:"mode",label:"How",default:"every-page",choices:[{value:"every-page",label:"Every page",hint:`${e.pages} files`},{value:"every-n",label:"Every N pages",hint:"ask how many"},{value:"points",label:"At points I choose",hint:"grid"}]}]:[]},plan(t,e){let o=h(t);if(!o)return[];let n=Array.isArray(e.cuts)?e.cuts:[],r=R(n,o.pages).length,i=g(J(o.path,r),a(e.destination),a(e.name));return[{op:"split",sources:[o],outputs:i,cuts:n}]}};function Et(t){return Array.from({length:Math.max(0,t-1)},(e,o)=>o)}function Nt(t,e){if(!Number.isInteger(e)||e<1)throw d("Splitting every N pages needs N to be a whole number, at least 1.");let o=[];for(let n=e;n<t;n+=e)o.push(n-1);return o}var u=t=>t.length===1&&t[0]?.kind==="document"&&t[0].format==="pdf"?t[0]:void 0;function L(t,e){return Array.isArray(e.pages)?S(e.pages):typeof e.pages=="string"?S(M(e.pages,t.pages)):[]}var V=t=>({kind:"text",id:"pages",label:"Pages",placeholder:`1-${t.pages}`}),W={id:"extract",label:"Extract",verb:"Extracting",hint:"keep only some pages",appliesTo:t=>u(t)!==void 0,unavailable:()=>"one PDF at a time",options:t=>{let e=u(t);return e?[V(e),{kind:"select",id:"separate",label:"Output",default:"one",choices:[{value:"one",label:"One file",hint:"all selected pages together"},{value:"many",label:"Separate files",hint:"one per page"}]}]:[]},plan(t,e){let o=u(t);if(!o)return[];let n=L(o,e),r=e.separate==="many";return[{op:"extract",sources:[o],outputs:g(q(o.path,n,r),a(e.destination),a(e.name)),pages:n,separate:r}]}},Y={id:"delete",label:"Delete",verb:"Deleting",hint:"drop some pages",appliesTo:t=>u(t)!==void 0,unavailable:()=>"one PDF at a time",options:t=>{let e=u(t);return e?[V(e)]:[]},plan(t,e){let o=u(t);return o?[{op:"delete",sources:[o],outputs:[s(f(o.path,"trimmed"),a(e.destination),a(e.name))],pages:L(o,e)}]:[]}};var O=t=>t.filter(e=>e.kind==="document"&&e.format==="pdf"),Z={id:"merge",label:"Merge",verb:"Merging",hint:"several files into one",appliesTo:t=>O(t).length>=2&&O(t).length===t.length,unavailable:t=>O(t).length!==t.length?"PDFs only":"needs 2+ files",options:()=>[],plan(t,e){let o=s(E(t.map(n=>n.path)),a(e.destination),a(e.name));return[{op:"merge",sources:t,outputs:[o]}]}};var tt=t=>t.length===1&&t[0]?.kind==="document"&&t[0].format==="pdf"?t[0]:void 0,et={id:"rotate",label:"Rotate",verb:"Rotating",hint:"turn pages",appliesTo:t=>tt(t)!==void 0,unavailable:()=>"one PDF at a time",options:()=>[{kind:"select",id:"degrees",label:"Turn",default:"90",choices:[{value:"90",label:"90\xB0 right",hint:"a quarter turn"},{value:"180",label:"180\xB0",hint:"upside down"},{value:"270",label:"90\xB0 left",hint:"a quarter turn back"}]}],plan(t,e){let o=tt(t);if(!o)return[];let r=Number(e.degrees??90)/90%4||1;return[{op:"rotate",sources:[o],outputs:[s(f(o.path,"rotated"),a(e.destination),a(e.name))],turns:r}]}};var ot=[N,v,Z,K,W,Y,et,X,H,U],ie=ot.filter(t=>!["convert","compress","trim","resize","crop"].includes(t.id)),dt=[_,G];function re(t,e=new Set){return[...ot,...dt.filter(o=>o.requires&&e.has(o.requires))].filter(o=>o.appliesTo(t))}function ae(t,e){return t.appliesTo(e)?void 0:t.unavailable?.(e)}export{v as a,wt as b,_ as c,G as d,mt as e,X as f,H as g,U as h,et as i,K as j,Et as k,Nt as l,ot as m,ie as n,re as o,ae as p};
@@ -0,0 +1,3 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ function o(e){switch(e.op){case"convert":return e.options.crop&&e.options.resize?"cropped and resized":e.options.crop?"cropped":e.options.trim&&e.options.resize?"trimmed and resized":e.options.resize?"resized":e.options.trim?"trimmed":e.target===e.sources[0].format?"compressed":"converted";case"merge":return"merged";case"split":return"split";case"extract":return"extracted";case"delete":return"deleted from";case"rotate":return"rotated";case"boost":return e.scale===1?"sharpened":"boosted";case"remove-background":return"cut out";default:{let t=e;throw new Error(`describeResult has no verb for ${JSON.stringify(t)}`)}}}function i(e){let{job:t}=e,r=t.sources.map(n=>({path:n.path,bytes:n.bytes})),s=r.length===1&&t.outputs.length===1?r[0]:void 0;return{verb:o(t),sources:r,outputs:[...t.outputs],outputBytes:e.outputBytes,...s?{size:{from:s.bytes,to:e.outputBytes}}:{},warnings:e.warnings}}export{i as a};
@@ -0,0 +1,3 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ var s="https://github.com/AtharvaN16/forge-terminal/releases/download",r=[{id:"boost",title:"Boost resolution",summary:"Sharpen, or boost resolution 2x or 4x, with a local AI model",minMacos:14,assets:{"darwin-arm64":{version:"1.0.0",url:`${s}/ext-boost-v1.0.0/forge-ext-boost-1.0.0-arm64.tar.gz`,bytes:14866325,sha256:"7af24c92f95b1cd34618adde4a90926c91a8db4347d640be4921f1dc706a9a2e"},"win32-x64":{version:"1.1.0",url:`${s}/ext-boost-v1.1.0/forge-ext-boost-1.1.0-win32-x64.tar.gz`,bytes:22993151,sha256:"abac81a9efe616f33b3bce98db2c0ff0b5597b43a7e3d5ea98968761a2b7a0ce"},"win32-arm64":{version:"1.1.0",url:`${s}/ext-boost-v1.1.0/forge-ext-boost-1.1.0-win32-arm64.tar.gz`,bytes:22936985,sha256:"7d39d93cae52f298423db0b185b0ae3a3bac65464abeb23561d9bcb2ebb3f026"}},licence:"Real-ESRGAN general-x4v3 (BSD-3-Clause), ONNX Runtime (MIT)"},{id:"remove-background",title:"Remove background",summary:"Cut the subject out of a photo, on this Mac",minMacos:14,assets:{"darwin-universal":{version:"1.0.0",url:`${s}/ext-remove-background-v1.0.0/forge-ext-remove-background-1.0.0-universal.tar.gz`,bytes:32489,sha256:"9f6e055c0ce25f7504e10c7871e506a813bc75d6536396a675a8c075c4eb4686"}},licence:"Uses Apple Vision on-device; helper is MIT"},{id:"heic",title:"HEIC photos",summary:"Open iPhone photos (HEIC) on Windows",assets:{"win32-universal":{version:"1.0.0",url:`${s}/ext-heic-v1.0.0/forge-ext-heic-1.0.0-win32-universal.tar.gz`,bytes:532364,sha256:"6c5f86c1a896d84264fb19371117e6ca6ec9b8726afec03f8c30aa5125a3ad97"}},licence:"libheif and libde265 (LGPL-3.0), via libheif-js"},{id:"yt-dlp",title:"YouTube links",summary:"Transcribe YouTube videos: yt-dlp fetches their sound",minMacos:26,assets:{"darwin-universal":{version:"2026.08.19",url:"https://github.com/yt-dlp/yt-dlp/releases/download/2026.08.19/yt-dlp_macos",bytes:37146048,sha256:"0f192b7ec147ab6288885d6351d9ab67367640029b4377576ef46dd79cf7b202",binary:"yt-dlp"}},licence:"yt-dlp (Unlicense); its bundled Python and libraries under their own licences"}];function n(t){return r.find(e=>e.id===t)}function c(t,e=process.platform,a=process.arch){let o=t.assets;return o[`${e}-${a}`]??o[`${e}-universal`]}function i(t,e=process.platform){return Object.keys(t.assets).some(a=>a.startsWith(`${e}-`))}function l(t,e=process.platform){let a=n(t);return a!==void 0&&i(a,e)}export{r as a,n as b,c,i as d,l as e};
@@ -0,0 +1,3 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ import{a as w,b as I,c as k,d as m,e as $,f as O}from"./chunk-ZONIA7SX.js";import{b as P,d as R,e as B}from"./chunk-3A43GEIR.js";import{e as h}from"./chunk-EHARO6IS.js";import{i as x}from"./chunk-6VOCIMXQ.js";import{a as l}from"./chunk-MHW4OOQW.js";import{Y as y,Z as C,_ as v,b as p}from"./chunk-DW2EJIUX.js";import{a as f}from"./chunk-J7FLFHQJ.js";import{a as c}from"./chunk-BXJ2HTKI.js";import{dirname as S,join as q}from"node:path";async function T(t){if(t.fallback!==void 0)return t.fallback;let{loadPreferences:r,expandTilde:e}=await import("./preferences-AUFJSKMJ.js");return e((await r()).prefs.defaultOutput)}function F(t){if(t.pasteboard)return t.pasteboard;if(!$())throw C();return O()}function E(t,r,e,o){let a=q(r.outDir,`Copied image${c[o].extensions[0]}`),s={inputs:[r.source],output:a,force:!1,recursive:!1,debug:t.debug},n={background:"#ffffff",keepMetadata:!1,...t.quality===void 0?{}:{quality:t.quality}};return o===e?{kind:"compress",...s,options:n,...t.quality===void 0?{}:{quality:t.quality},...t.maxBytes===void 0?{}:{maxBytes:t.maxBytes}}:{kind:"convert",...s,target:o,options:n,...t.maxBytes===void 0?{}:{maxBytes:t.maxBytes}}}async function J(t,r={}){let e=r.clip??{},o=F(e),a=await w(o,e.root);if(!a)throw y((await o.peek()).text?"text":"nothing");let s=await x(a.source),n=t.target??s.format,b=E(t,a,s.format,n),i=await R(b,r),g=i.results[0];if(!g||i.failures.length>0)return{report:i,status:"failed"};let u=g.job.outputs[0],d={report:i,output:u,source:{format:s.format,bytes:s.bytes},target:n};if(await I(o,a,u,n)==="changed")return{...d,status:"changed",saved:await m(u,await T(e))};if(t.save===void 0)return{...d,status:"placed"};let j=t.save===!0?await T(e):t.save,{expandTilde:D}=await import("./preferences-AUFJSKMJ.js");return{...d,status:"placed",saved:await m(u,D(j))}}function N(t){let r=t.target===t.source.format?"":` as ${c[t.target].label}`,e=` ${f(t.source.bytes)} \u2192 ${f(t.report.outputBytes)} \xB7 ${P(t.source.bytes,t.report.outputBytes)}`;if(t.status==="changed"){let a=t.target===t.source.format?"compressed":"converted";return[`\u2713 Copied image \u2192 ${p(t.saved)}${r}`,e,"","\u26A0 Clipboard changed"," The file you uploaded is no longer in the clipboard.",` The ${a} image is saved to ${p(S(t.saved))}.`]}let o=t.saved===void 0?"":` + ${p(t.saved)}`;return[`\u2713 Copied image \u2192 clipboard${r}${o}`,e]}async function U(t){if(!await k(F(t),t.root))throw v()}async function Z(t,r){if(t.undo)return await U(r.clip??{}),{exitCode:0,stdout:r.json?[JSON.stringify({forge:l,ok:!0,clipboard:"restored"})]:["\u2713 The original is back on the clipboard"],stderr:[]};let e=await J(t,r);if(e.status==="failed")return B(e.report,r);if(r.json){let o={...h(l,e.report),clipboard:e.status,...e.saved===void 0?{}:{saved:e.saved}};return{exitCode:0,stdout:[JSON.stringify(o)],stderr:[]}}return{exitCode:0,stdout:N(e),stderr:[]}}export{J as a,N as b,U as c,Z as d};
@@ -0,0 +1,3 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ import{e as h}from"./chunk-FWMFN36F.js";import{a as y}from"./chunk-IMC5NRDC.js";import{i as g}from"./chunk-6VOCIMXQ.js";import{d as b}from"./chunk-DW2EJIUX.js";import{a}from"./chunk-BXJ2HTKI.js";import{existsSync as x}from"node:fs";import{open as S,readdir as w,stat as k}from"node:fs/promises";import{extname as I,join as v,resolve as K}from"node:path";function A(e){return e.startsWith(".")||/\.(crdownload|part|download|tmp)$/i.test(e)}function j(e){return e.kind==="image"?"images":e.format==="pdf"?"pdfs":"documents"}var R=new Set(Object.values(a).flatMap(e=>e.extensions));async function M(e){let n=await S(e,"r"),o=Buffer.alloc(4096),i=0;try{i=(await n.read(o,0,o.length,0)).bytesRead}finally{await n.close()}let t=o.subarray(0,i),r=(c,u)=>t.subarray(c,c+u).toString("latin1");return r(4,4)==="ftyp"?/^(M4A |M4B |M4P )$/.test(r(8,4))?"audio":"video":t[0]===26&&t[1]===69&&t[2]===223&&t[3]===163?"video":r(0,4)==="RIFF"?r(8,4)==="WAVE"?"audio":r(8,3)==="AVI"?"video":"other":t[0]===0&&t[1]===0&&t[2]===1&&(t[3]===186||t[3]===179)?"video":r(0,3)==="ID3"||r(0,4)==="fLaC"||r(0,4)==="OggS"||r(0,4)==="FORM"&&/^AIF[FC]$/.test(r(8,4))||t[0]===255&&t[1]!==void 0&&(t[1]&224)===224?"audio":i>0&&!t.includes(0)&&O(t)?"text":"other"}function O(e){try{return new TextDecoder("utf-8",{fatal:!0}).decode(e,{stream:!0}),!0}catch{return!1}}var F=["images","pdfs","documents","videos","audio","other"];function $(e,n){if(e==="videos"||e==="audio")return"not yet supported";if(e==="other")return n.every(o=>o==="text")?n.length===1?"a text file":"text files":"not supported"}async function _(e){let n=K(e),o=await w(n,{withFileTypes:!0}),i=[],t=[],r=new Map,c=[],u=0;for(let f of o.sort((d,s)=>d.name.localeCompare(s.name))){if(!f.isFile()||A(f.name))continue;let d=v(n,f.name);c.push(d);let s=await E(d);if(s.kind==="source")i.push(s.source),u+=s.source.bytes;else if(s.kind==="failed")t.push(s.failure),u+=s.bytes;else{let p=s.kind,m=r.get(p)??{bytes:0,sniffed:[]};m.bytes+=s.bytes,m.sniffed.push(s.sniffed),r.set(p,m),u+=s.bytes}}let l=[];for(let f of F){let d=i.filter(s=>j(s)===f);d.length>0&&l.push({id:f,count:d.length,bytes:d.reduce((s,p)=>s+p.bytes,0),sources:d})}l.sort((f,d)=>d.count-f.count);for(let f of F){let d=r.get(f);if(!d)continue;let s=$(f,d.sniffed);l.push({id:f,count:d.sniffed.length,bytes:d.bytes,sources:[],...s===void 0?{}:{why:s}})}return{dir:n,sources:i,failures:t,kinds:l,bytes:u,paths:c}}async function E(e){try{return{kind:"source",source:await g(e)}}catch(n){let o=await k(e).then(r=>r.size,()=>0);if(R.has(I(e).toLowerCase())){let r=b(n)?n:void 0;if(r)return{kind:"failed",failure:{path:e,error:r},bytes:o}}let i=await M(e).catch(()=>"other");return{kind:i==="video"?"videos":i==="audio"?"audio":"other",sniffed:i,bytes:o}}}function q(e){let n=new Set(e.flatMap(o=>y(o).filter(i=>i!==o.format)));return Object.keys(a).filter(o=>n.has(o))}function z(e,n){let o=q(e),i=e[0],t=i?.kind==="image"?"webp":i?.format==="pdf"?"png":void 0,r=t&&o.includes(t)?t:o[0];if(r)return D(e,r,n)}function D(e,n,o){let i={target:n};return a[n].lossy&&(i.quality=o),e.some(t=>t.kind==="document"&&t.format==="pdf")&&(n==="png"||n==="jpeg")&&(i.dpi=150),i}function U(e,n,o,i){if(e.format===n.target)return{left:`already ${a[n.target].label}`};if(!y(e).includes(n.target))return{left:`can\u2019t become ${a[n.target].label}`};let[t]=h.plan([e],{target:n.target,...n.quality===void 0?{}:{quality:n.quality},...n.dpi===void 0?{}:{dpi:String(n.dpi)},pages:"all",...i===void 0?{}:{destination:i}});if(t?.op!=="convert")return{left:"not supported"};if(t.outputs.some(r=>x(r)&&!o.has(r)))return{left:"already converted"};t.outputs=t.outputs.map(r=>N(r,o));for(let r of t.outputs)o.add(r);return{job:t}}function N(e,n){if(!n.has(e))return e;let o=I(e),i=e.slice(0,e.length-o.length);for(let t=1;;t++){let r=`${i} (${t})${o}`;if(!n.has(r)&&!x(r))return r}}export{A as a,j as b,M as c,_ as d,E as e,q as f,z as g,D as h,U as i};
@@ -1,3 +1,3 @@
1
1
  import { createRequire as __forgeCreateRequire } from 'node:module';
2
2
  const require = __forgeCreateRequire(import.meta.url);
3
- import{b as h,c as S,d as A,e as R,f as T,g}from"./chunk-QVACE4IE.js";import{I as E}from"./chunk-MMRDELHW.js";var y={set:"tailwind",start:50,end:950,count:11},O=["tailwind","even","radix"],v=[0,50,100,150,200,250,300,350,400,450],D=[550,600,650,700,750,800,850,900,950,1e3],I=Array.from({length:19},(e,n)=>n+3),$=[20,50,100,150,200,260,330,420,500,560,750,920],N=8;function P({set:e,start:n,end:r,count:o}){if(!O.includes(e))return`The set must be tailwind, even or radix; got ${e}.`;if(e!=="radix"){if(!v.includes(n))return n%50===0?`The start must be from 0 to 450, so the colour (500) stays in the scale; got ${n}.`:`The start must be a multiple of 50; got ${n}.`;if(!D.includes(r))return r%50===0?`The end must be from 550 to 1000, so the colour (500) stays in the scale; got ${r}.`:`The end must be a multiple of 50; got ${r}.`;if(e==="even"&&!I.includes(o))return`An even set has 3 to 21 steps; got ${o}.`}}function d(e){let{set:n,start:r,end:o,count:a}=e;if(n==="radix")return $.map((t,s)=>({step:s+1,at:t}));if(n==="tailwind"){let t=new Set([r,o,500]);for(let s=Math.ceil((r+1)/100)*100;s<o;s+=100)t.add(s);return[...t].sort((s,u)=>s-u).map(s=>({step:s,at:s}))}let i=a-1,f=Math.round(i*(500-r)/(o-r)),c=Math.max(1,Math.min(i-1,f)),p=i-c,b=[];for(let t=0;t<=c;t++)b.push(r+(500-r)*t/c);for(let t=1;t<=p;t++)b.push(500+(o-500)*t/p);for(let t of[10,5,1]){let s=b.map(u=>Math.round(u/t)*t);if(new Set(s).size===s.length)return b.map((u,l)=>({step:s[l],at:u}))}return b.map(t=>({step:t,at:t}))}function _(e){return d(e).map(n=>n.step)}var z=_(y);function K(e){return e.set==="radix"?N:d(e).findIndex(n=>n.at===500)}var W=[[50,1],[100,.86],[200,.68],[300,.46],[400,.22],[500,0]],F=[[500,0],[600,.2],[700,.4],[800,.6],[900,.8],[950,1]];function w(e,n){for(let r=1;r<e.length;r++){let[o,a]=e[r-1],[i,f]=e[r];if(n<=i)return a+(f-a)*(n-o)/(i-o)}return e[e.length-1][1]}var H=.995,U=.35,j=5e-4;function Y(e,n=y){let r=P(n);if(r)throw E(r,"Try: Tailwind, from 50 to 950.");let{L:o,C:a,h:i}=T(S(e)),f=a<j,c=Math.max(.975,o),p=o<.16?.42*o:Math.max(.16,.42*o);return d(n).map(({step:b,at:t})=>{if(t===500)return{step:b,at:t,rgb:{...e},hex:h(e),reference:!0};let s,u;if(t>=50&&t<500){let m=w(W,t);s=o+(c-o)*m,u=a*(1-.88*m)}else if(t<50){let m=(50-t)/50;s=c+(Math.max(H,c)-c)*m,u=a*.12*(1-m)}else if(t<=950){let m=w(F,t);s=o-(o-p)*m,u=a*(1-.45*m)}else{let m=(t-950)/50;s=p*(1-U*m),u=a*.55*(1-.4*m)}for(f&&(u=0);u>0&&!R(g({L:s,C:u,h:i}));)u-=.002;let l=A(g({L:s,C:Math.max(0,u),h:i}));return{step:b,at:t,rgb:l,hex:h(l),reference:!1}})}var x=e=>{let n=e/255;return n<=.04045?n/12.92:((n+.055)/1.055)**2.4},M=({r:e,g:n,b:r})=>.2126*x(e)+.7152*x(n)+.0722*x(r);function L(e,n){let[r,o]=[M(e),M(n)].sort((a,i)=>i-a);return(r+.05)/(o+.05)}function J(e){return e>=7?"AAA":e>=4.5?"AA":e>=3?"large":"fails"}var k={r:255,g:255,b:255},B={r:0,g:0,b:0},C=e=>Math.floor(e*10)/10;function Q(e){return{white:C(L(e,k)),black:C(L(e,B))}}export{y as a,O as b,v as c,D as d,I as e,d as f,_ as g,K as h,Y as i,L as j,J as k,Q as l};
3
+ import{b as h,c as S,d as A,e as R,f as T,g}from"./chunk-QVACE4IE.js";import{F as E}from"./chunk-DW2EJIUX.js";var y={set:"tailwind",start:50,end:950,count:11},O=["tailwind","even","radix"],v=[0,50,100,150,200,250,300,350,400,450],D=[550,600,650,700,750,800,850,900,950,1e3],I=Array.from({length:19},(e,n)=>n+3),$=[20,50,100,150,200,260,330,420,500,560,750,920],N=8;function P({set:e,start:n,end:r,count:o}){if(!O.includes(e))return`The set must be tailwind, even or radix; got ${e}.`;if(e!=="radix"){if(!v.includes(n))return n%50===0?`The start must be from 0 to 450, so the colour (500) stays in the scale; got ${n}.`:`The start must be a multiple of 50; got ${n}.`;if(!D.includes(r))return r%50===0?`The end must be from 550 to 1000, so the colour (500) stays in the scale; got ${r}.`:`The end must be a multiple of 50; got ${r}.`;if(e==="even"&&!I.includes(o))return`An even set has 3 to 21 steps; got ${o}.`}}function d(e){let{set:n,start:r,end:o,count:a}=e;if(n==="radix")return $.map((t,s)=>({step:s+1,at:t}));if(n==="tailwind"){let t=new Set([r,o,500]);for(let s=Math.ceil((r+1)/100)*100;s<o;s+=100)t.add(s);return[...t].sort((s,u)=>s-u).map(s=>({step:s,at:s}))}let i=a-1,f=Math.round(i*(500-r)/(o-r)),c=Math.max(1,Math.min(i-1,f)),p=i-c,b=[];for(let t=0;t<=c;t++)b.push(r+(500-r)*t/c);for(let t=1;t<=p;t++)b.push(500+(o-500)*t/p);for(let t of[10,5,1]){let s=b.map(u=>Math.round(u/t)*t);if(new Set(s).size===s.length)return b.map((u,l)=>({step:s[l],at:u}))}return b.map(t=>({step:t,at:t}))}function _(e){return d(e).map(n=>n.step)}var z=_(y);function K(e){return e.set==="radix"?N:d(e).findIndex(n=>n.at===500)}var W=[[50,1],[100,.86],[200,.68],[300,.46],[400,.22],[500,0]],F=[[500,0],[600,.2],[700,.4],[800,.6],[900,.8],[950,1]];function w(e,n){for(let r=1;r<e.length;r++){let[o,a]=e[r-1],[i,f]=e[r];if(n<=i)return a+(f-a)*(n-o)/(i-o)}return e[e.length-1][1]}var H=.995,U=.35,j=5e-4;function Y(e,n=y){let r=P(n);if(r)throw E(r,"Try: Tailwind, from 50 to 950.");let{L:o,C:a,h:i}=T(S(e)),f=a<j,c=Math.max(.975,o),p=o<.16?.42*o:Math.max(.16,.42*o);return d(n).map(({step:b,at:t})=>{if(t===500)return{step:b,at:t,rgb:{...e},hex:h(e),reference:!0};let s,u;if(t>=50&&t<500){let m=w(W,t);s=o+(c-o)*m,u=a*(1-.88*m)}else if(t<50){let m=(50-t)/50;s=c+(Math.max(H,c)-c)*m,u=a*.12*(1-m)}else if(t<=950){let m=w(F,t);s=o-(o-p)*m,u=a*(1-.45*m)}else{let m=(t-950)/50;s=p*(1-U*m),u=a*.55*(1-.4*m)}for(f&&(u=0);u>0&&!R(g({L:s,C:u,h:i}));)u-=.002;let l=A(g({L:s,C:Math.max(0,u),h:i}));return{step:b,at:t,rgb:l,hex:h(l),reference:!1}})}var x=e=>{let n=e/255;return n<=.04045?n/12.92:((n+.055)/1.055)**2.4},M=({r:e,g:n,b:r})=>.2126*x(e)+.7152*x(n)+.0722*x(r);function L(e,n){let[r,o]=[M(e),M(n)].sort((a,i)=>i-a);return(r+.05)/(o+.05)}function J(e){return e>=7?"AAA":e>=4.5?"AA":e>=3?"large":"fails"}var k={r:255,g:255,b:255},B={r:0,g:0,b:0},C=e=>Math.floor(e*10)/10;function Q(e){return{white:C(L(e,k)),black:C(L(e,B))}}export{y as a,O as b,v as c,D as d,I as e,d as f,_ as g,K as h,Y as i,L as j,J as k,Q as l};
@@ -0,0 +1,21 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ import{d as f}from"./chunk-HCN4BH2H.js";import{c as g,d as l}from"./chunk-7ZI3PFFX.js";import{randomBytes as b}from"node:crypto";import{copyFile as S,mkdir as w,readdir as h,readFile as v,rename as N,rm as p,stat as O}from"node:fs/promises";import{tmpdir as k}from"node:os";import{extname as u,join as o}from"node:path";function m(){return o(k(),"forge-clip")}var F=5,d={".png":"png",".jpg":"jpeg",".jpeg":"jpeg",".webp":"webp",".heic":"heic",".avif":"avif",".gif":"gif",".tiff":"tiff"};async function Q(e,r=m()){let t=`${Date.now().toString(36)}-${b(3).toString("hex")}`,n=o(r,t),a=await e.read(o(n,"in"));if(!a)return await p(n,{recursive:!0,force:!0}),null;let i=o(n,"out");await w(i,{recursive:!0}),await j(r,a.path);let s=o(n,"in","Copied image");return await N(a.path,s),await I(r,t),{source:s,outDir:i,changeCount:a.changeCount}}async function j(e,r){let t=o(e,"last"),n=`Copied image${u(r)}`,a=o(e,`.last-${b(4).toString("hex")}`);await w(a,{recursive:!0}),await S(r,o(a,n)),await p(t,{recursive:!0,force:!0}),await g(a,t)}async function I(e,r){let t=await h(e,{withFileTypes:!0}).catch(()=>[]),a=(await Promise.all(t.filter(i=>i.isDirectory()&&i.name!=="last"&&!i.name.startsWith(".")).map(async i=>({name:i.name,at:(await O(o(e,i.name)).catch(()=>null))?.mtimeMs??0})))).filter(i=>i.name!==r).sort((i,s)=>s.at-i.at).slice(F-1);await Promise.all(a.map(i=>p(o(e,i.name),{recursive:!0,force:!0})))}async function T(e=m()){let r=o(e,"last"),t=(await h(r).catch(()=>[])).find(n=>d[u(n).toLowerCase()]!==void 0);return t===void 0?null:{path:o(r,t),format:d[u(t).toLowerCase()]}}async function V(e,r,t,n){let{changeCount:a}=await e.peek();return a!==r.changeCount?"changed":(await e.write(t,n),"placed")}async function Z(e,r=m()){let t=await T(r);return t?(await e.write(t.path,t.format),!0):!1}async function tt(e,r){let t=f(o(r,`Copied image${u(e)}`));return await l(t,await v(e)),t}import{execFile as $}from"node:child_process";import{mkdir as A,rename as E,rm as J}from"node:fs/promises";import{join as y}from"node:path";import{promisify as R}from"node:util";var D=R($),_=async(e,r)=>{let{stdout:t}=await D("osascript",["-l","JavaScript","-e",e,...r],{timeout:5e3});return t.trim()},P=[{uti:"public.png",ext:"png"},{uti:"public.jpeg",ext:"jpg"},{uti:"org.webmproject.webp",ext:"webp"},{uti:"public.heic",ext:"heic"},{uti:"public.avif",ext:"avif"},{uti:"com.compuserve.gif",ext:"gif"},{uti:"public.tiff",ext:"tiff"}];function K(e){let r=e.includes("public.file-url");return P.find(t=>e.includes(t.uti)&&!(r&&t.uti==="public.tiff"))?.uti??null}function ot(e=process.platform,r=process.env){return e==="darwin"&&!r.SSH_CONNECTION&&!r.SSH_TTY}var U={png:"public.png",jpeg:"public.jpeg",webp:"org.webmproject.webp",heic:"public.heic",avif:"public.avif",gif:"com.compuserve.gif",tiff:"public.tiff"};function W(e){return U[e]??"public.data"}var L=`ObjC.import('AppKit')
4
+ const pb = $.NSPasteboard.generalPasteboard
5
+ JSON.stringify({ types: ObjC.deepUnwrap(pb.types) || [], count: Number(pb.changeCount) })`,B=`function run(argv) {
6
+ ObjC.import('AppKit')
7
+ const pb = $.NSPasteboard.generalPasteboard
8
+ const data = pb.dataForType(argv[0])
9
+ if (data.isNil()) return JSON.stringify({ ok: false })
10
+ const ok = data.writeToFileAtomically(argv[1], true)
11
+ return JSON.stringify({ ok: ok, count: Number(pb.changeCount) })
12
+ }`,M=`function run(argv) {
13
+ ObjC.import('AppKit')
14
+ const pb = $.NSPasteboard.generalPasteboard
15
+ const item = $.NSPasteboardItem.alloc.init
16
+ item.setDataForType($.NSData.dataWithContentsOfFile(argv[0]), argv[1])
17
+ item.setStringForType($.NSURL.fileURLWithPath(argv[0]).absoluteString, 'public.file-url')
18
+ pb.clearContents
19
+ pb.writeObjects($.NSArray.arrayWithObject(item))
20
+ return JSON.stringify({ count: Number(pb.changeCount) })
21
+ }`;function st(e=_){let r=async()=>{try{let{types:t,count:n}=JSON.parse(await e(L,[]));return{changeCount:n,image:K(t),text:t.includes("public.utf8-plain-text")}}catch{return{changeCount:-1,image:null,text:!1}}};return{peek:r,async read(t){let{image:n}=await r(),a=P.find(C=>C.uti===n);if(!a)return null;await A(t,{recursive:!0});let i=y(t,`Copied image.${a.ext}`),s=JSON.parse(await e(B,[a.uti,i]));if(!s.ok||s.count===void 0)return null;if(a.uti!=="public.tiff")return{path:i,changeCount:s.count};let{default:x}=await import("sharp"),c=y(t,"Copied image.png");return await x(i).keepIccProfile().png().toFile(`${c}.part`),await E(`${c}.part`,c),await J(i,{force:!0}),{path:c,changeCount:s.count}},async write(t,n){let{count:a}=JSON.parse(await e(M,[t,W(n)]));return a}}}export{Q as a,V as b,Z as c,tt as d,ot as e,st as f};
@@ -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}from"./chunk-SVDVVRVP.js";import"./chunk-ZONIA7SX.js";import"./chunk-3A43GEIR.js";import"./chunk-PGG2OTK6.js";import"./chunk-FWMFN36F.js";import"./chunk-BZXDNDPG.js";import"./chunk-6TERL22R.js";import"./chunk-JBSYGB3F.js";import"./chunk-HCN4BH2H.js";import"./chunk-CBE73ZWA.js";import"./chunk-IMC5NRDC.js";import"./chunk-EHARO6IS.js";import"./chunk-PSEIJXGT.js";import"./chunk-6VOCIMXQ.js";import"./chunk-D6JPP65L.js";import"./chunk-7ZI3PFFX.js";import"./chunk-MHW4OOQW.js";import"./chunk-DW2EJIUX.js";import"./chunk-J7FLFHQJ.js";import"./chunk-5GJK5LP5.js";import"./chunk-HON4OV7M.js";import"./chunk-BXJ2HTKI.js";import"./chunk-TMUK2DD3.js";export{b as clipLines,a as runClip,d as runClipCommand,c as runUndo};
@@ -0,0 +1,3 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ import{h as S,i as k,m as C}from"./chunk-BLPVRO4J.js";import{i as $,k as u,l as w}from"./chunk-Z2LELLNV.js";import{c as I,d as y,f as O}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-6VOCIMXQ.js";import"./chunk-D6JPP65L.js";import"./chunk-7ZI3PFFX.js";import{a as l}from"./chunk-MHW4OOQW.js";import{c as b,n as x}from"./chunk-DW2EJIUX.js";import"./chunk-J7FLFHQJ.js";import"./chunk-BXJ2HTKI.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=I(o);if(s.length===0)throw x(t.input);let e=t.inside?N(s,t.inside):void 0,r=e?y(o,e):s;if(t.svg)return{exitCode:0,stdout:[S(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=O(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:[k(t.colour,o)],stderr:[]};let s=o.map(e=>({...e,...w(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};
@@ -0,0 +1,3 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ import{a,b}from"./chunk-FKPXXNKX.js";import"./chunk-DW2EJIUX.js";import"./chunk-J7FLFHQJ.js";import"./chunk-5GJK5LP5.js";import"./chunk-HON4OV7M.js";import"./chunk-BXJ2HTKI.js";import"./chunk-TMUK2DD3.js";export{a as CONFIG_KEYS,b as runConfig};
@@ -0,0 +1,3 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ import{c as a,d as b,e as c,f as d}from"./chunk-3A43GEIR.js";import"./chunk-PGG2OTK6.js";import"./chunk-FWMFN36F.js";import"./chunk-BZXDNDPG.js";import"./chunk-6TERL22R.js";import"./chunk-JBSYGB3F.js";import"./chunk-HCN4BH2H.js";import"./chunk-CBE73ZWA.js";import"./chunk-IMC5NRDC.js";import"./chunk-EHARO6IS.js";import"./chunk-PSEIJXGT.js";import"./chunk-6VOCIMXQ.js";import"./chunk-D6JPP65L.js";import"./chunk-7ZI3PFFX.js";import"./chunk-MHW4OOQW.js";import"./chunk-DW2EJIUX.js";import"./chunk-J7FLFHQJ.js";import"./chunk-5GJK5LP5.js";import"./chunk-HON4OV7M.js";import"./chunk-BXJ2HTKI.js";import"./chunk-TMUK2DD3.js";export{d as execute,a as exitCodeFor,c as renderRun,b as runIntent};
@@ -0,0 +1,3 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ import{$a as a,ab as b,bb as c,cb as d,db as e}from"./chunk-6V6WEBUI.js";import"./chunk-BZXDNDPG.js";import"./chunk-Z2LELLNV.js";import"./chunk-PBIS2ONZ.js";import"./chunk-IBPGC4N2.js";import"./chunk-QVACE4IE.js";import"./chunk-MHW4OOQW.js";import"./chunk-DW2EJIUX.js";import"./chunk-J7FLFHQJ.js";import"./chunk-BXJ2HTKI.js";import"./chunk-SS7HNRZ5.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-YILLB45O.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-XN7WNMEW.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-SS7HNRZ5.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-KZJ7WC34.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};