forge-terminal 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -7
- package/dist/chunks/{about-credits-XL2AIGQ7.js → about-credits-PWTKZG3Y.js} +1 -1
- package/dist/chunks/args-RHIBM3R3.js +3 -0
- package/dist/chunks/{available-TNMISSBA.js → available-FPBRQ3LS.js} +1 -1
- package/dist/chunks/{boot-QRKC4QBA.js → boot-PHDTJAFT.js} +1 -1
- package/dist/chunks/{catalog-FMHWWMUX.js → catalog-G44MXIAF.js} +1 -1
- package/dist/chunks/{check-HOITNMJX.js → check-BFHBPCGW.js} +1 -1
- package/dist/chunks/{chunk-EIPMQFIF.js → chunk-2YU4EI24.js} +1 -1
- package/dist/chunks/chunk-3IAJTXYM.js +3 -0
- package/dist/chunks/{chunk-ECA4PW5T.js → chunk-3OCPO5V6.js} +1 -1
- package/dist/chunks/chunk-42IEPG2K.js +3 -0
- package/dist/chunks/{chunk-BYUOU2Q2.js → chunk-4AL5QJLM.js} +1 -1
- package/dist/chunks/{chunk-UUTBDIFR.js → chunk-56B3VZCM.js} +1 -1
- package/dist/chunks/{chunk-QIMSNTKL.js → chunk-56QHX7QR.js} +1 -1
- package/dist/chunks/{chunk-HXKLYK3M.js → chunk-6NCN7OJ5.js} +1 -1
- package/dist/chunks/{chunk-YBA6DJQ4.js → chunk-6PUV4HSU.js} +1 -1
- package/dist/chunks/{chunk-2OSM4W4D.js → chunk-72UR37EG.js} +1 -1
- package/dist/chunks/{chunk-3IX3QA76.js → chunk-7NP76V4U.js} +1 -1
- package/dist/chunks/{chunk-5FJT4BNY.js → chunk-AETM2PCZ.js} +1 -1
- package/dist/chunks/{chunk-GIG4I2IC.js → chunk-BQV3DSUZ.js} +2 -2
- package/dist/chunks/chunk-DC2DHMXO.js +3 -0
- package/dist/chunks/{chunk-6HUYBVQA.js → chunk-DKHBJ52G.js} +1 -1
- package/dist/chunks/chunk-E5VPEBUQ.js +3 -0
- package/dist/chunks/chunk-F4TUCI6D.js +3 -0
- package/dist/chunks/{chunk-MF3KKEFB.js → chunk-FEJSM3E4.js} +1 -1
- package/dist/chunks/{chunk-JUA63KQK.js → chunk-G2V33TMN.js} +1 -1
- package/dist/chunks/{chunk-FXA45V4B.js → chunk-G4M2XYFJ.js} +1 -1
- package/dist/chunks/{chunk-WID72ZII.js → chunk-H332YFSO.js} +1 -1
- package/dist/chunks/chunk-HAOKWLD3.js +4 -0
- package/dist/chunks/{chunk-S7BZPV5T.js → chunk-I3C3SRF2.js} +1 -1
- package/dist/chunks/{chunk-NUTTDNTG.js → chunk-ID4GJZJ6.js} +1 -1
- package/dist/chunks/{chunk-X4QI2EYV.js → chunk-ID75X37Z.js} +1 -1
- package/dist/chunks/{chunk-FWVE3GNA.js → chunk-JPASVE56.js} +1 -1
- package/dist/chunks/{chunk-UN5DSJE2.js → chunk-JZM37DG2.js} +1 -1
- package/dist/chunks/{chunk-G6L5NIJ5.js → chunk-KPUKMAYK.js} +1 -1
- package/dist/chunks/{chunk-UEAZTRTL.js → chunk-M7HB4L6L.js} +1 -1
- package/dist/chunks/{chunk-NLM2SP3F.js → chunk-OK56WDPA.js} +1 -1
- package/dist/chunks/{chunk-I25E2XDH.js → chunk-OLKPV4WO.js} +1 -1
- package/dist/chunks/chunk-OPDC577C.js +3 -0
- package/dist/chunks/chunk-OQ6DTE56.js +3 -0
- package/dist/chunks/chunk-PNPAHKJR.js +3 -0
- package/dist/chunks/{chunk-3HG7RXC2.js → chunk-PXCEMDOY.js} +2 -2
- package/dist/chunks/{chunk-YJZEHJ6U.js → chunk-QMNERJL2.js} +1 -1
- package/dist/chunks/{chunk-TNIPRV6K.js → chunk-R6QVLPGC.js} +1 -1
- package/dist/chunks/{chunk-65Y7YCZZ.js → chunk-S44LAUHZ.js} +1 -1
- package/dist/chunks/{chunk-YYZYZWF5.js → chunk-SCJ2QXZF.js} +22 -22
- package/dist/chunks/{chunk-QO4JUY6B.js → chunk-SJIDFYPT.js} +1 -1
- package/dist/chunks/{chunk-PISCJKIG.js → chunk-TQEGSODD.js} +1 -1
- package/dist/chunks/chunk-ULX4ZD2Y.js +3 -0
- package/dist/chunks/{chunk-BWJNZT75.js → chunk-W6QOV4RP.js} +1 -1
- package/dist/chunks/chunk-WWWWXOM4.js +3 -0
- package/dist/chunks/{chunk-2JU3YZQU.js → chunk-XIR3VWQY.js} +1 -1
- package/dist/chunks/chunk-XUJLUOGD.js +6 -0
- package/dist/chunks/chunk-Y3DMALHT.js +66 -0
- package/dist/chunks/chunk-YXV3PYVI.js +3 -0
- package/dist/chunks/{chunk-QPUKPSPZ.js → chunk-Z3PQ5TMU.js} +1 -1
- package/dist/chunks/chunk-ZL7E7PZN.js +4 -0
- package/dist/chunks/clip-command-6Q7BTXR5.js +3 -0
- package/dist/chunks/{clipboard-W67Q22JG.js → clipboard-QWNPA3GM.js} +1 -1
- package/dist/chunks/colour-7HPH6KTY.js +3 -0
- package/dist/chunks/{command-ZX3L5VFO.js → command-JTK4IOS7.js} +1 -1
- package/dist/chunks/{config-command-VEGQPXVB.js → config-command-DIQTU7DM.js} +1 -1
- package/dist/chunks/{continue-editing-LTMIEFRD.js → continue-editing-FTUY6UFG.js} +1 -1
- package/dist/chunks/{decoded-SK6W44WW.js → decoded-IXLPWTGZ.js} +1 -1
- package/dist/chunks/{entry-3R2GK3IW.js → entry-ZF7D32ZI.js} +2 -2
- package/dist/chunks/execute-RP7ZMWLZ.js +3 -0
- package/dist/chunks/extensions-YOZ4IF4E.js +3 -0
- package/dist/chunks/{extensions-command-RNAPQYWV.js → extensions-command-O7UHUJ3Y.js} +1 -1
- package/dist/chunks/{ffmpeg-G4TRWUTV.js → ffmpeg-2ZP3GXJX.js} +1 -1
- package/dist/chunks/{image-67XO45NW.js → image-6A7FXKIR.js} +1 -1
- package/dist/chunks/{install-X7EEH5CQ.js → install-4L7JGP3X.js} +1 -1
- package/dist/chunks/{install-UN3YGSJW.js → install-XJAPLIH2.js} +1 -1
- package/dist/chunks/launch-2KSJ4GGN.js +18 -0
- package/dist/chunks/link-inputs-GTEW6ZH4.js +3 -0
- package/dist/chunks/{lock-5ZO5PCZP.js → lock-KNR7XS7Q.js} +1 -1
- package/dist/chunks/manager-YH5XAMZA.js +4 -0
- package/dist/chunks/{needed-7IUPDEJB.js → needed-TB3OC76N.js} +1 -1
- package/dist/chunks/{own-5BD5BVE7.js → own-KUGTZ3BV.js} +1 -1
- package/dist/chunks/{paths-6OENILJ4.js → paths-BBUKTDDP.js} +1 -1
- package/dist/chunks/pdfium-MJ65YOXW.js +3 -0
- package/dist/chunks/{preferences-E2CH2YSG.js → preferences-7S7YZOFK.js} +1 -1
- package/dist/chunks/preset-command-KMKR6KMG.js +3 -0
- package/dist/chunks/registry-657JRJR5.js +3 -0
- package/dist/chunks/{run-3DX3SROY.js → run-VJDF5WRF.js} +1 -1
- package/dist/chunks/{server-TF32DQEO.js → server-6PH2DSFW.js} +20 -20
- package/dist/chunks/{signals-QSXY3F2A.js → signals-VY2XE3LV.js} +1 -1
- package/dist/chunks/{theme-4Y66DDAO.js → theme-FVQOSLPB.js} +1 -1
- package/dist/chunks/{transcribe-HH5P3PV4.js → transcribe-FUN2SKRN.js} +1 -1
- package/dist/chunks/transcribe-command-KNSUHROE.js +3 -0
- package/dist/chunks/{update-command-6VVDG75Y.js → update-command-X4OSYETA.js} +1 -1
- package/dist/chunks/{update-note-XV2T2NNG.js → update-note-LV7G4CHE.js} +1 -1
- package/dist/chunks/video-link-CF7GUA6V.js +3 -0
- package/dist/chunks/watch-command-3C4AWM7A.js +3 -0
- package/dist/index.js +7 -7
- package/package.json +9 -13
- package/skills/forge/SKILL.md +7 -3
- package/dist/chunks/args-PS5SVBZY.js +0 -3
- package/dist/chunks/chunk-2L66A2X6.js +0 -3
- package/dist/chunks/chunk-3SVHRKQH.js +0 -6
- package/dist/chunks/chunk-4MZV4SRU.js +0 -4
- package/dist/chunks/chunk-4NDZTK22.js +0 -3
- package/dist/chunks/chunk-5XJCMMCM.js +0 -3
- package/dist/chunks/chunk-CCNRNCRU.js +0 -3
- package/dist/chunks/chunk-EEQSUBBL.js +0 -3
- package/dist/chunks/chunk-EJWTYDBJ.js +0 -3
- package/dist/chunks/chunk-JD3RB6IV.js +0 -66
- package/dist/chunks/chunk-NMGQGYVM.js +0 -3
- package/dist/chunks/chunk-SFN3LBB6.js +0 -3
- package/dist/chunks/chunk-UI4EUC3S.js +0 -3
- package/dist/chunks/chunk-X2YUHPOU.js +0 -4
- package/dist/chunks/clip-command-4ON3Q57W.js +0 -3
- package/dist/chunks/colour-2BGK2BFR.js +0 -3
- package/dist/chunks/execute-TC3QZ6GL.js +0 -3
- package/dist/chunks/extensions-3SG2LW7R.js +0 -3
- package/dist/chunks/launch-EGFNGHLN.js +0 -18
- package/dist/chunks/manager-272REVNF.js +0 -4
- package/dist/chunks/pdfium-MHPBLZY5.js +0 -3
- package/dist/chunks/preset-command-5I3NZ2OP.js +0 -3
- package/dist/chunks/registry-DWFV4GBG.js +0 -3
- package/dist/chunks/transcribe-command-VY5HYNXV.js +0 -3
- package/dist/chunks/watch-command-BMSMGIHK.js +0 -3
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{c as re,g as ft,h as pt}from"./chunk-EEQSUBBL.js";import{c as dt,d as ut}from"./chunk-BSFBZBAI.js";import{c as me,d as mt,f as le,g as lt,l as gt}from"./chunk-BWJNZT75.js";import{c as at,e as ct}from"./chunk-3IX3QA76.js";import{b as Ce,c as ze,d as Ue,f as qe,m as C,n as ot,o as nt,p as rt,q as st,v as it}from"./chunk-FWVE3GNA.js";import{n as Ve,o as He,p as ue,s as Ge,u as Ke,w as M}from"./chunk-UN5DSJE2.js";import{g as tt}from"./chunk-6HUYBVQA.js";import{a as Ye,b as ne,c as T,e as Qe,f as Ze,g as Xe,h as je,i as et}from"./chunk-KXKQDFHX.js";import{a as We}from"./chunk-I2LPGKUU.js";import{$ as Ae,B as ee,Ba as Le,Ca as Je,D as te,M as ke,T as Y,U as de,X as De,a as I,f as A,ia as Te,pa as oe,wa as Ne,xa as Be,z as Oe,za as W}from"./chunk-CCNRNCRU.js";import{a as _e}from"./chunk-FGR6QCG5.js";import{c as J}from"./chunk-VLVNA4T3.js";import{mkdtemp as Vt,rm as Ht}from"node:fs/promises";import{tmpdir as Gt}from"node:os";import{join as se}from"node:path";var wt=(e,t,o)=>qe(e,t,o)===void 0;function ht(e,t,o=Number.POSITIVE_INFINITY,n=[2,4]){return[...n].reverse().find(s=>s<o&&wt(e,t,s))??0}async function Kt(e,t,o){if(e.op!=="boost"&&e.op!=="remove-background")throw new Error(`the extension engine cannot ${e.op}`);if(o?.aborted)throw o.reason??new Error("aborted");let n=e.sources[0],s=e.outputs[0],r=e.op,{assetFor:i,catalogEntry:a,offeredHere:f}=await import("./catalog-FMHWWMUX.js");if(!f(r,process.platform,process.arch))throw Ae(a(r)?.title??r);let{installed:m,extensionsRoot:p}=await import("./paths-6OENILJ4.js"),w=await m(r);if(!w)throw De(r);let h=ze(w.version);if(e.op==="boost"){let l=a(r),y=Ue(e.scale,w.version,l&&i(l)?.version);if(y)throw y}if(e.op==="boost"&&!wt(n.width,n.height,e.scale))throw Te(n.path,ht(n.width,n.height,Number.POSITIVE_INFINITY,h),e.scale);let{runExtension:x}=await import("./run-3DX3SROY.js"),S=[];n.frames>1&&S.push({code:"animation-flattened",message:`${J(n.path)} has ${n.frames} frames. Only the first frame was used.`});let v=await Vt(se(Gt(),"forge-ext-"));try{t({phase:"decoding"});let l=se(v,"in.png"),y=se(v,"out.png");await st(n,l);let F=e.op==="boost"?["--in",l,"--out",y,"--scale",String(e.scale),"--cache",se(p(),"boost","cache")]:[l,y],$=e.op==="boost"&&Ce(w.version);await x({...w,serve:$},F,{subject:n.path,what:`${Yt(e)} is running on ${J(n.path)}`,onWait:()=>t({phase:"waiting"}),onStart:()=>t({phase:"encoding"}),onProgress:(R,b)=>t({phase:"tiles",done:R,total:b}),...e.op==="boost"?{maxScale:ht(n.width,n.height,e.scale,h)}:{},...o===void 0?{}:{signal:o}});let P=(await ne())(y);I[e.target].hasAlpha||(P=P.flatten({background:e.options.background}));let d=await nt(P,e.target,e.options.quality).toBuffer();t({phase:"writing"});let g=await rt(d,s);return{job:e,outputBytes:g,warnings:S}}catch(l){throw A(l)?l:W(n.path,l)}finally{await Ht(v,{recursive:!0,force:!0}).catch(()=>{})}}function Yt(e){return e.op!=="boost"?"Remove background":e.scale===1?"Sharpen":`Boost resolution ${e.scale}\xD7`}var bt={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:Kt};import{randomBytes as wo}from"node:crypto";import{rm as bo,stat as z}from"node:fs/promises";import{dirname as vo,join as yo}from"node:path";var ge="%NOISE_FLOOR%",Qt=["highpass=f=80",`afftdn=nr=12:nf=${ge}`],Zt="highpass=f=80,astats=measure_perchannel=none:measure_overall=RMS_trough";function Et(e){let t=/RMS trough dB:\s*(-?[\d.]+|-?inf)/i.exec(e)?.[1],o=t===void 0?Number.NaN:Number(t);return Number.isFinite(o)?Math.min(-30,Math.max(-70,Math.round(o+8))):-50}var he="%LOUDNORM_MEASURED%",Xt={mp4:"mp4",hevc:"mp4",mov:"mov",webm:"webm",mkv:"matroska",avi:"avi",gif:"gif",mp3:"mp3",m4a:"ipod",opus:"opus",flac:"flac",wav:"wav",aiff:"aiff",ogg:"ogg"},jt={mp4:["h264","hevc","mpeg4","av1"],mov:["h264","hevc","mpeg4","prores","av1"],mkv:["h264","hevc","mpeg4","vp8","vp9","av1"],hevc:["hevc"],webm:["vp8","vp9","av1"],avi:["mpeg4","h264","mjpeg","msmpeg4v3"]},eo={mp4:["aac","alac","mp3"],hevc:["aac","alac","mp3"],mov:["aac","alac","mp3","pcm_s16le","pcm_s16be","pcm_s24le"],m4a:["aac","alac"],mkv:["aac","mp3","opus","vorbis","flac","ac3","eac3"],webm:["opus","vorbis"],opus:["opus"],mp3:["mp3"],flac:["flac"],wav:["pcm_s16le","pcm_s24le"],aiff:["pcm_s16be","pcm_s24be"],ogg:["vorbis","opus","flac"],avi:["mp3","ac3","aac","pcm_s16le"]},vt=[48e3,24e3,16e3,12e3,8e3],to=[48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3];function oo(e,t){if(e.includes(t))return t;let o=Math.max(...e);return t>o?o:Math.min(...e.filter(n=>n>t))}function no(e,t,o,n=16){let s=n>16,r={encoder:"opus",kbps:96,args:["-strict","-2"],rates:[48e3]};switch(e){case"webm":return o("libopus")?{encoder:"libopus",kbps:96,rates:vt}:o("libvorbis")?{encoder:"libvorbis",kbps:128}:o("opus")?r:{codec:"Opus or Vorbis",encoders:["libopus","libvorbis","opus"],sound:!0};case"opus":return o("libopus")?{encoder:"libopus",kbps:96,rates:vt}:o("opus")?r:{codec:"Opus",encoders:["libopus","opus"]};case"mp3":return o("libmp3lame")?{encoder:"libmp3lame",kbps:128}:{codec:"MP3",encoders:["libmp3lame"]};case"flac":return{encoder:"flac"};case"wav":return{encoder:s?"pcm_s24le":"pcm_s16le"};case"aiff":return{encoder:s?"pcm_s24be":"pcm_s16be"};case"ogg":return o("libvorbis")?{encoder:"libvorbis",kbps:128}:{encoder:"vorbis",kbps:128,args:["-strict","-2","-ac","2"]};default:return{encoder:t==="darwin"&&o("aac_at")?"aac_at":"aac",kbps:128,rates:to}}}var Q=e=>Math.max(2,Math.floor(e/2)*2),ro=e=>String(Math.round(e*1e3)/1e3),so=e=>String(Math.ceil(e*1e3)/1e3),io=e=>Math.round(38-(e-1)*20/99),ao=e=>Math.round(50-(e-1)*30/99),co=e=>Math.round(40-(e-1)*18/99),yt=e=>Math.round(20+e*60/100),fo=e=>Math.round(31-(e-1)*29/99);function po(e,t){let o=.15*2**((18-e)/6);return Math.max(64,Math.round(t*o/1e3))}function uo(e,t,o,n,s){let r=e.width,i=e.height;if(o)r=o.width,i=o.height;else{t.crop?.box&&(r=t.crop.box.width,i=t.crop.box.height);let a=t.resize;if(a&&"width"in a){let f=Math.min(a.width,r)/r;r*=f,i*=f}else if(a&&"height"in a){let f=Math.min(a.height,i)/i;r*=f,i*=f}else a&&(r*=a.percent/100,i*=a.percent/100)}return r*i*(n??e.fps*s)}var mo="zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,format=yuv420p";function xt(e){let t=[],o=e;for(;o>2;)t.push("atempo=2"),o/=2;for(;o<.5;)t.push("atempo=0.5"),o/=.5;return t.push(`atempo=${Math.round(o*1e3)/1e3}`),t}var lo=800,go=15,Pt=32;function we(e){let{facts:t,options:o,target:n,platform:s}=e,r=o.media??{},i=t.video,a=t.audio,f=I[n].media==="sound",m=n==="gif",p=o.compress!==void 0,w=s==="darwin",h=c=>e.has===void 0||e.has.has(c),x=c=>Be(n,c,e.os??s),S=r.cut?.start??0,v=Math.min(r.cut?.end??t.duration,t.duration),l=Math.max(0,v-S),y=r.speed??1,F=l/y,$=i!==void 0&&!f,_=a!==void 0&&!r.mute&&!m,P,d,g,R;if(r.targetBytes!==void 0&&F>0){if($&&i){let c=ft({duration:F,width:i.width,height:i.height,fps:i.fps,hasAudio:_,targetBytes:r.targetBytes});"videoKbps"in c&&(P={width:c.width,height:c.height,fps:c.fps},g=c.videoKbps,d=c.audioKbps)}else if(_){let c=Math.floor(r.targetBytes*8/F/1e3*.98);R=Math.max(Pt,Math.min(320,c))}}let b=[];if($&&i){if(i.hdr&&n!=="hevc"&&h("zscale")&&b.push(mo),o.crop?.box){let c=o.crop.box;b.push(`crop=${Q(c.width)}:${Q(c.height)}:${c.left}:${c.top}`)}if(P)b.push(`scale=${P.width}:${P.height}`);else if(o.resize){let c=o.resize;"width"in c?b.push(`scale=trunc(min(${Q(c.width)}\\,iw)/2)*2:-2`):"height"in c?b.push(`scale=-2:trunc(min(${Q(c.height)}\\,ih)/2)*2`):b.push(`scale=trunc(iw*${c.percent/100}/2)*2:-2`)}if(o.rotate&&b.push(o.rotate===90?"transpose=1":o.rotate===270?"transpose=2":"hflip,vflip"),y!==1&&b.push(`setpts=PTS/${y}`),m){let c=Math.min(lo,Q(i.width));b.push(`fps=${Math.min(go,i.fps)},scale=${c}:-2:flags=lanczos,split[s0][s1];[s0]palettegen=stats_mode=diff[p];[s1][p]paletteuse=dither=bayer:bayer_scale=4`)}}let E=P?.fps??r.fps,N=$&&i!==void 0&&b.length===0&&E===void 0&&!p&&r.targetBytes===void 0&&(jt[n]??[]).includes(i.codec),u=[],D=!1;if(!$)u.push("-vn");else if(N)u.push("-c:v","copy");else{if(b.length&&u.push("-vf",b.join(",")),m)u.push("-c:v","gif","-loop","0");else if(n==="webm"){if(!h("libvpx-vp9"))throw x({codec:"VP9",encoders:["libvpx-vp9"]});if(D=g!==void 0,u.push("-c:v","libvpx-vp9","-row-mt","1","-deadline","good","-cpu-used","4"),i?.codec==="gif"&&u.push("-pix_fmt","yuva420p"),g!==void 0)u.push("-b:v",`${g}k`);else{let c=p?ao(o.quality??60):33;u.push("-crf",String(c),"-b:v","0")}}else if(n==="hevc"){let c=h("libx265"),k=w&&h("hevc_videotoolbox");if(!c&&!k)throw x({codec:"HEVC",encoders:["libx265",...w?["hevc_videotoolbox"]:[]]});if(g!==void 0)c?u.push("-c:v","libx265","-preset","fast","-b:v",`${g}k`):u.push("-c:v","hevc_videotoolbox","-b:v",`${g}k`);else if(k&&(!p||!c)){let K=p?yt(o.quality??60):60;u.push("-c:v","hevc_videotoolbox","-q:v",String(K))}else{let K=p?co(o.quality??60):26;u.push("-c:v","libx265","-crf",String(K),"-preset","fast")}u.push("-tag:v","hvc1","-pix_fmt",i?.hdr?"p010le":"yuv420p")}else{let c=p?io(o.quality??60):21,k=()=>`${g??po(c,i?uo(i,o,P,E,y):0)}k`;if(g===void 0&&!p&&w&&h("h264_videotoolbox"))u.push("-c:v","h264_videotoolbox","-q:v","65");else if(h("libx264"))D=g!==void 0,g!==void 0?u.push("-c:v","libx264","-preset","medium","-b:v",`${g}k`):p?u.push("-c:v","libx264","-preset","medium","-crf",String(c)):u.push("-c:v","libx264","-preset","veryfast","-crf","21");else if(w&&h("h264_videotoolbox"))g!==void 0?u.push("-c:v","h264_videotoolbox","-b:v",k()):u.push("-c:v","h264_videotoolbox","-q:v",String(yt(o.quality??60)));else if(h("libopenh264"))u.push("-c:v","libopenh264","-b:v",k());else if(s==="win32"&&h("h264_mf"))u.push("-c:v","h264_mf","-b:v",k());else if(n==="avi")if(g!==void 0)u.push("-c:v","mpeg4","-b:v",`${g}k`);else{let K=p?fo(o.quality??60):3;u.push("-c:v","mpeg4","-q:v",String(K))}else throw x({codec:"H.264",encoders:["libx264",...w?["h264_videotoolbox"]:[],"libopenh264",...s==="win32"?["h264_mf"]:[]]});u.push("-pix_fmt","yuv420p")}E!==void 0?u.push("-r",String(E)):n==="avi"?u.push("-fps_mode","cfr"):m||u.push("-fps_mode","passthrough")}let Se=r.cleanup?[...Qt]:[],j=[...Se,...y!==1?xt(y):[]],B=r.loudness;B!==void 0&&j.push(`loudnorm=I=${B}:TP=-1.5:LRA=11:${he}:linear=true`);let Fe=r.bitrate??d??R,Ie=_&&a!==void 0&&j.length===0&&Fe===void 0&&!(p&&f)&&(eo[n]??[]).includes(a.codec),O=[];if(!_)O.push("-an");else if(Ie)O.push("-c:a","copy");else{j.length&&O.push("-af",j.join(","));let c=no(n,s,h,a?.bits);if("codec"in c)throw x(c);O.push("-c:a",c.encoder);let k=Fe??c.kbps;k!==void 0&&c.kbps!==void 0&&O.push("-b:a",`${k}k`),c.args&&O.push(...c.args),!c.args?.includes("-ac")&&d!==void 0&&d<=Pt&&O.push("-ac","1"),a&&(B!==void 0||c.rates&&!c.rates.includes(a.sampleRate))&&O.push("-ar",String(c.rates?oo(c.rates,a.sampleRate):a.sampleRate))}let ce=[];S>0&&ce.push("-ss",so(S)),r.cut&&ce.push("-t",ro(l));let H=[...ce,"-i",e.input],G=[],fe=[...$?["-map","0:v:0"]:[],..._?["-map","0:a:0"]:[]],$e=o.keepMetadata?[]:["-map_metadata","-1"],qt=Xt[n]??n,Re=["mp4","hevc","mov","m4a"].includes(n)?["-movflags","+faststart"]:[],Me=["-f",qt,"-y",e.output],pe=s==="win32"?"NUL":"/dev/null",L=[];return r.cleanup&&L.push({args:[...H,...G,"-vn","-af",Zt,"-f","null",pe],measures:"noise"}),B!==void 0&&L.push({args:[...H,...G,"-vn","-af",`${[...Se,...y!==1?xt(y):[]].map(c=>`${c},`).join("")}loudnorm=I=${B}:TP=-1.5:LRA=11:print_format=json`,"-f","null",pe],measures:"loudness",pass:{at:1,of:2}}),D?(L.push({args:[...H,...G,...fe.slice(0,2),...u,"-pass","1","-passlogfile",e.passlog,"-an","-f","null",pe],pass:{at:1,of:2}}),L.push({args:[...H,...G,...fe,...u,"-pass","2","-passlogfile",e.passlog,...O,...$e,...Re,...Me],pass:{at:2,of:2}})):L.push({args:[...H,...G,...fe,...u,...O,...$e,...Re,...Me],...B!==void 0?{pass:{at:2,of:2}}:{}}),{steps:L,duration:F,copies:{video:N,audio:Ie},...P?{fitted:P}:{}}}var xo=["mp4","mov","webm","mkv","avi","gif"],Ft=["mp4","mov","hevc","webm","mkv","avi","gif","mp3","m4a","wav"],Po=["mp3","m4a","wav","aiff","flac","opus","ogg"],Eo=["mp3","m4a","opus","flac","aiff","wav"];function So(e){return C(e,64)}function Fo(e,t){return t&&!t.video&&(e==="mp4"||e==="mov")?"m4a":e}async function It(e,t){let o=ot(await So(e));if(!o)throw new Error("not video or sound");if(o!=="mp4"&&o!=="mov"&&I[o].media!==t)throw new Error(`not ${t}`);let n=(await z(e)).size,s=await me(),r;if(s){try{r=await le(e,s)}catch(a){throw ee(e,a)}if(r.duration<=0||!r.video&&!r.audio)throw ee(e,r)}let i=Fo(o,r);if(I[i].media!==t)throw new Error(`not ${t}`);return{kind:"media",path:e,format:i,bytes:n,...r?{facts:r}:{}}}async function Io(){let{assetFor:e,catalogEntry:t}=await import("./catalog-FMHWWMUX.js"),o=t("video");return o!==void 0&&e(o)!==void 0}async function $o(e,t){if(e.kind==="media"&&e.facts)return e.facts;try{return await le(e.path,t)}catch(o){throw ee(e.path,o)}}function Ro(e,t){let o=e.options.media??{},n=o.cut?.start??0,s=Math.min(o.cut?.end??t,t);return Math.max(0,s-n)/(o.speed??1)}function $t(e,t){if(e.op!=="convert")return;let o=e.sources[0],n=o.kind==="media"?o.facts:void 0;if(!n)return;let s=e.options.media??{},r=pt({...n,duration:Ro(e,n.duration)},{soundOnly:I[e.target].media==="sound",mute:s.mute===!0||e.target==="gif"});return t<r?{floor:r}:void 0}function Mo(e){let t=e.slice(e.lastIndexOf("{"),e.lastIndexOf("}")+1),o=JSON.parse(t);return[`measured_I=${o.input_i}`,`measured_TP=${o.input_tp}`,`measured_LRA=${o.input_lra}`,`measured_thresh=${o.input_thresh}`,`offset=${o.target_offset}`].join(":")}async function St(e){await Promise.all(e.map(t=>bo(t,{force:!0}).catch(()=>{})));for(let t of e)ue(t)}async function Rt(e,t,o){if(e.op!=="convert")throw new Error(`media engines only convert, not ${e.op}`);if(o?.aborted)throw o.reason??new Error("aborted");let n=e.sources[0],s=e.outputs[0],r=await me();if(!r)throw Ne(n.path,process.platform,await Io());let i=await $o(n,r),a=e.options.media;if((a?.cleanup||a?.loudness!==void 0)&&!i.audio)throw Le(n.path);let f=await z(n.path).catch(()=>{}),m=wo(6).toString("hex"),p=Ve(s,m),w=yo(vo(s),`.forge-pass-${m}`),h=[p,`${w}-0.log`,`${w}-0.log.temp`,`${w}-0.log.mbtree`,`${w}-0.log.mbtree.temp`],x=[],S=(d,g=e.options)=>we({input:n.path,output:p,target:e.target,facts:i,options:g,platform:d,os:process.platform,passlog:w,...r.has?{has:r.has}:{}}),v=e.options,l=S(process.platform);if(l.duration<=0)throw ke(n.path,re(i.duration));await Ge(s);let y=process.platform,F=v.media?.cut;if(l.copies.video&&F&&F.start>0){let d=await lt(n.path,F.start,r);d!==void 0&&F.start-d>.05&&(v={...v,media:{...v.media,cut:{...F,start:d}}},l=S(process.platform,v),x.push({code:"media-cut-keyframe",message:`It starts at ${re(d)}, the keyframe just before ${re(F.start)}.`}))}let $=0,_=async d=>{let g=$,R="",b="";for(let E of d.steps){let N=E.args.map(D=>D.replace(he,R).replace(ge,b)),u=await gt(N,{tools:r,signal:o,report:E.measures!==void 0,onTime:D=>t({phase:"time",done:Math.min(D,d.duration),total:d.duration,...E.pass?{pass:{at:g+E.pass.at,of:g+E.pass.of}}:{}})});E.measures==="loudness"&&(R=Mo(u)),E.measures==="noise"&&(b=String(Et(u)))}$=g+Math.max(0,...d.steps.map(E=>E.pass?.of??0))};for(let d of h)He(d);try{try{await _(l)}catch(b){if(o?.aborted||!l.steps.some(E=>E.args.some(N=>N.endsWith("_videotoolbox"))))throw b;y="linux",l=S(y,v),$=0,await _(l)}let d=v.media?.targetBytes;for(let b of[.95,.9]){if(d===void 0||(await z(p)).size<=d)break;v={...v,media:{...v.media,targetBytes:Math.floor(d*b)}},l=S(y,v),await _(l)}let g=(await z(p)).size;if(d!==void 0&&g>d)throw Oe(n,e.options.media?.targetBytes??d,g);if(e.options.compress!==void 0&&g>=n.bytes)throw oe(n.path,n.bytes,g);let R=await z(n.path).catch(()=>{});if(f&&R&&(R.size!==f.size||R.mtimeMs!==f.mtimeMs))throw Je(n.path);await Ke(p,s),ue(p)}catch(d){throw await St(h),o?.aborted||A(d)?d:W(n.path,d,n.format)}await St(h.slice(1));let P=i.video;if(l.fitted&&P&&(l.fitted.width<P.width-2||l.fitted.fps<P.fps)){let d=_e(e.options.media?.targetBytes??0);x.push({code:"media-fitted",message:`To fit ${d} it is now ${l.fitted.width}\xD7${l.fitted.height} at ${l.fitted.fps} fps.`})}return{job:e,outputBytes:(await z(s)).size,warnings:x}}function Kn(e,t){if(e.kind!=="media"||!e.facts)return;let o=mt()?.has;if(o)try{we({input:e.path,output:e.path,target:t,facts:e.facts,options:{background:"#ffffff",keepMetadata:!1},platform:process.platform,passlog:"",has:o});return}catch(n){return A(n)&&n.code==="encoder-missing"?n:void 0}}var Z=e=>new Set(e);function _o(e){let t=e.kind==="media"?e.facts:void 0,o=e.kind==="image"||t!==void 0&&t.audio===void 0;return Z(Ft.filter(n=>!(o&&I[n].media==="sound"||n==="hevc"&&t?.video?.codec==="hevc")))}var Mt={id:"video",reads:Z(xo),writes:Z(Ft),ops:new Set(["convert"]),probe:e=>It(e,"video"),alone:!0,run:Rt,sizeTo:$t,writesFor:_o},_t={id:"sound",reads:Z(Po),writes:Z(Eo),ops:new Set(["convert"]),probe:e=>It(e,"sound"),alone:!0,run:Rt,sizeTo:$t};import{readFile as ie,rm as At,stat as Oo}from"node:fs/promises";function Zn(e,t){let o=e.split(",").map(r=>r.trim()).filter(r=>r!=="");if(o.length===0)throw Y(e,"That selects no pages.",t);let n=new Set,s=(r,i)=>{if(!Number.isInteger(r)||r<1||r>t)throw Y(i,`'${i}' is outside 1 and ${t}.`,t);return r};for(let r of o){let i=r.match(/^(\d+)\s*-\s*(\d*)$/);if(i?.[1]!==void 0){let a=s(Number(i[1]),r),f=i[2]===""?t:s(Number(i[2]),r);if(f<a)throw Y(r,`'${r}' ends before it starts.`,t);for(let m=a;m<=f;m++)n.add(m-1);continue}if(!/^\d+$/.test(r))throw Y(r,`'${r}' is not a page number.`,t);n.add(s(Number(r),r)-1)}return[...n].sort((r,i)=>r-i)}function Ot(e){return[...new Set(e)].sort((t,o)=>t-o)}function Xn(e){if(e.length===0)return"";let t=[...new Set(e)].sort((r,i)=>r-i),o=[],n=t[0],s=n;for(let r of t.slice(1)){if(r===s+1){s=r;continue}o.push(n===s?`${n+1}`:`${n+1}-${s+1}`),n=r,s=r}return o.push(n===s?`${n+1}`:`${n+1}-${s+1}`),o.join(", ")}function kt(e,t){let o=[...new Set(e)].sort((r,i)=>r-i).filter(r=>r>=0&&r<t-1),n=[],s=0;for(let r of o)n.push({from:s,to:r}),s=r+1;return n.push({from:s,to:t-1}),n}var ve=Ye(()=>import("./pdf-compress-U2E3CNXG.js")),ko=new Set(["pdf","jpeg","png","webp","avif","gif","tiff","heic","raw"]),Do=new Set(["pdf"]);async function U(e){return(await T()).PDFDocument.load(await ie(e),{ignoreEncryption:!0})}var Ao=1024,Dt=Buffer.from("%PDF-","latin1");async function To(e){return(await C(e,Ao+Dt.length)).indexOf(Dt)!==-1}async function No(e){if(!await To(e))throw new Error(`${e} is not a PDF`);let{surveyDocument:t}=await ve(),o=await U(e),{size:n}=await Oo(e);return{kind:"document",path:e,format:"pdf",bytes:n,pages:o.getPageCount(),encrypted:o.isEncrypted,images:t(o)}}function q(e){for(let t of e)if(t.encrypted)throw te(t.path)}async function Tt(e,t,o){let n=await ne(),s=t.format==="jpeg"||t.format==="png",r=s?(await n(o).metadata()).orientation:void 0;if(s&&(r===void 0||r===1))return t.format==="jpeg"?e.embedJpg(o):e.embedPng(o);if(t.format==="jpeg"){let i=await n(o).rotate().jpeg({quality:I.jpeg.defaultQuality,mozjpeg:!0}).toBuffer();return e.embedJpg(i)}return e.embedPng(await n(o).rotate().png().toBuffer())}async function Nt(e){let t=await tt(e.path,e.format);return typeof t=="string"?ie(t):t}async function Bo(e,t){let o=e.sources[0];if(o.kind!=="image")throw new Error("the pdf engine cannot embed a document source");let n=[];o.frames>1&&n.push({code:"animation-flattened",message:`${J(o.path)} has ${o.frames} frames, and ${I.pdf.label} cannot animate. Only the first frame was converted.`}),t({phase:"reading"});let s=await Nt(o);t({phase:"encoding"});let i=await(await T()).PDFDocument.create(),a=await Tt(i,o,s);i.addPage([a.width,a.height]).drawImage(a,{x:0,y:0,width:a.width,height:a.height}),t({phase:"writing"});let m=await M(e.outputs[0],await i.save());return{job:e,outputBytes:m,warnings:n}}async function Lo(e,t){q(e.sources.filter(a=>a.kind==="document"));let n=await(await T()).PDFDocument.create(),s=[];for(let a of e.sources){if(t({phase:"reading"}),a.kind==="image"){a.frames>1&&s.push({code:"animation-flattened",message:`${J(a.path)} has ${a.frames} frames, and ${I.pdf.label} cannot animate. Only the first frame was merged.`});let p=await Tt(n,a,await Nt(a));n.addPage([p.width,p.height]).drawImage(p,{x:0,y:0,width:p.width,height:p.height});continue}let f=await U(a.path),m=await n.copyPages(f,f.getPageIndices());for(let p of m)n.addPage(p)}t({phase:"writing"});let r=await n.save(),i=await M(e.outputs[0],r);return{job:e,outputBytes:i,warnings:s}}async function Jo(e,t){let o=e.sources[0];q([o]);let n=await T();t({phase:"reading"});let s=await U(o.path),r=kt(e.cuts,s.getPageCount()),i=[],a=0;try{for(let[f,m]of r.entries()){let p=await n.PDFDocument.create(),w=Array.from({length:m.to-m.from+1},(S,v)=>m.from+v),h=await p.copyPages(s,w);for(let S of h)p.addPage(S);let x=e.outputs[f];if(x===void 0)throw new Error(`split produced ${r.length} parts but was given ${e.outputs.length} outputs`);a+=await M(x,await p.save()),i.push(x),t({phase:"page",done:f+1,total:r.length})}}catch(f){throw await Promise.all(i.map(m=>At(m,{force:!0}))),f}return{job:e,outputBytes:a,warnings:[]}}async function be(e,t){let n=await(await T()).PDFDocument.create(),s=await n.copyPages(e,t);for(let r of s)n.addPage(r);return n.save()}async function Wo(e,t){let o=e.sources[0];if(q([o]),e.pages.length===0)throw de("That extract selects no pages.");t({phase:"reading"});let n=await U(o.path),s=Ot(e.pages),r=[],i=0;try{if(e.separate)for(let[a,f]of s.entries()){let m=e.outputs[a];i+=await M(m,await be(n,[f])),r.push(m),t({phase:"page",done:a+1,total:s.length})}else{t({phase:"writing"});let a=e.outputs[0];i=await M(a,await be(n,s)),r.push(a)}}catch(a){throw await Promise.all(r.map(f=>At(f,{force:!0}))),a}return{job:e,outputBytes:i,warnings:[]}}async function Co(e,t){let o=e.sources[0];q([o]),t({phase:"reading"});let n=await U(o.path),s=new Set(e.pages),r=n.getPageIndices().filter(a=>!s.has(a));if(r.length===0)throw de("That would delete every page.");t({phase:"writing"});let i=await M(e.outputs[0],await be(n,r));return{job:e,outputBytes:i,warnings:[]}}async function zo(e,t){let o=e.sources[0];q([o]);let n=await T();t({phase:"reading"});let s=await U(o.path);for(let i of s.getPages()){let f=((i.getRotation().angle+e.turns*90)%360+360)%360;i.setRotation(n.degrees(f))}t({phase:"writing"});let r=await M(e.outputs[0],await s.save());return{job:e,outputBytes:r,warnings:[]}}async function Uo(e,t){let o=e.sources[0];q([o]);let{compressPdf:n}=await ve();t({phase:"reading"});let s=await ie(o.path);t({phase:"encoding"});let{bytes:r,recompressed:i,skipped:a,fromDpi:f,toDpi:m}=await n(s,{quality:e.options.quality??60,dpi:e.options.dpi??150});if(e.options.compress&&r.length>=o.bytes)throw oe(o.path,o.bytes,r.length);t({phase:"writing"});let p=await M(e.outputs[0],r),w=x=>x===1?"":"s",h=[];return i===0&&a===0?h.push({code:"pdf-no-images",message:"This PDF has no images to re-encode, so its size is almost unchanged."}):i===0?h.push({code:"pdf-no-images",message:`None of its ${a} image${w(a)} could be re-encoded \u2014 they are not JPEG data.`}):a>0&&h.push({code:"pdf-images-skipped",message:`${i} image${w(i)} recompressed, ${a} skipped (not JPEG).`}),f!==void 0&&m!==void 0&&h.push({code:"pdf-downsampled",message:`Images reduced from ${f} to ${m} dpi. Pass --dpi ${f} to keep them.`}),{job:e,outputBytes:p,warnings:h}}async function qo(e){if(e.op!=="convert")return;let t=e.sources[0];if(t.kind!=="document")return;let{compressPdf:o}=await ve(),n=await ie(t.path);return{ladder:[e.options.dpi??150,120,96,72].map(s=>({dpi:s})),measure:async s=>(await o(n,{quality:s.quality??60,...s.dpi===void 0?{}:{dpi:s.dpi}})).bytes.byteLength}}var Bt={id:"pdf",measurer:qo,reads:ko,writes:Do,ops:new Set(["convert","merge","split","extract","delete","rotate"]),probe:No,async run(e,t){switch(e.op){case"convert":if(e.target!=="pdf")throw new Error("the pdf engine only converts to pdf");return e.sources[0].kind==="document"?Uo(e,t):Bo(e,t);case"merge":return Lo(e,t);case"split":return Jo(e,t);case"extract":return Wo(e,t);case"delete":return Co(e,t);case"rotate":return zo(e,t);default:throw new Error(`the pdf engine cannot ${e.op}`)}}};import{execFile as Vo}from"node:child_process";import{mkdtemp as Ho,readFile as Pe,rm as Go}from"node:fs/promises";import{tmpdir as Ko}from"node:os";import{basename as Ct,extname as zt,join as Lt,win32 as ye}from"node:path";import{pathToFileURL as Yo}from"node:url";import{promisify as Qo}from"node:util";var xe=Qo(Vo),V=Buffer.from([208,207,17,224,161,177,26,225]);async function Zo(e){if(e.length<V.length||!e.subarray(0,V.length).equals(V))return!1;let t=await je();try{return t.find(t.parse(e),"WordDocument")!==null}catch{return!1}}async function Xo(e){let t=await Xe();try{let o=new t(e);if(!o.getEntry("word/document.xml"))return;let n=0,s=o.getEntry("docProps/app.xml");if(s){let r=/<Pages>(\d+)<\/Pages>/.exec(o.readAsText(s));r?.[1]&&(n=Number(r[1]))}return{pages:n}}catch{return}}var Jt=Buffer.from([80,75,3,4]);async function jo(e){let t=await C(e,V.length);return t.subarray(0,Jt.length).equals(Jt)||t.subarray(0,V.length).equals(V)}async function en(e){if(!await jo(e))throw new Error(`${e} is not a Word document`);let t=await Pe(e),o=await Xo(t);if(o)return{kind:"document",path:e,format:"docx",bytes:t.byteLength,pages:o.pages,encrypted:!1};if(await Zo(t))return{kind:"document",path:e,format:"doc",bytes:t.byteLength,pages:0,encrypted:!1};throw new Error(`${e} is not a Word document`)}function tn(e,t){return e==="win32"?[ye.join(t.ProgramFiles??"C:\\Program Files","LibreOffice","program","soffice.exe"),ye.join(t["ProgramFiles(x86)"]??"C:\\Program Files (x86)","LibreOffice","program","soffice.exe")]:["/Applications/LibreOffice.app/Contents/MacOS/soffice"]}var on=0;async function nn(){on++;try{return await xe("soffice",["--version"],{timeout:5e3}),"soffice"}catch{}for(let e of tn(process.platform,process.env))try{return await xe(e,["--version"],{timeout:5e3}),e}catch{}}var Wt,rn=!1,sn;async function an(){return rn?sn:(Wt??=nn(),Wt)}var Ee="\f";function ae(e){return e.split(/\r?\n/).map(t=>t.trim()).filter(t=>t.length>0)}async function cn(e){if(e.format==="docx"){let o=await Qe(),{value:n}=await o.extractRawText({path:e.path});return ae(n)}if(e.format==="doc"){let o=await Ze(),s=await new o().extract(e.path);return ae(s.getBody())}return(await at(await Pe(e.path))).flatMap((o,n)=>n===0?ae(o):[Ee,...ae(o)])}var fn={width:612,height:792,margin:54};async function pn(e,t={}){let o=[[]];for(let n of e)n===Ee?o.push([]):o.at(-1)?.push({kind:"paragraph",text:n});return ut(o,{title:t.title??"",paper:fn,...t.fonts?{fonts:t.fonts}:{},...t.onMissing?{onMissing:t.onMissing}:{}})}async function dn(e){let{Document:t,Packer:o,PageBreak:n,Paragraph:s}=await et(),r=e.map(a=>a===Ee?new s({children:[new n]}):new s(We(a))),i=new t({sections:[{children:r}]});return o.toBuffer(i)}var un=new Set(["docx","doc","pdf"]),mn=new Set(["docx","pdf"]),ln=new Set(["convert"]),gn={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 hn(e=process.platform){return e==="linux"?{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: sudo apt install libreoffice"}:e!=="win32"?gn:{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 wn(e,t,o,n=process.platform){return[`-env:UserInstallation=${n==="win32"?Yo(ye.join(e,"profile"),{windows:!0}).href:`file://${e}/profile`}`,"--headless","--convert-to",o,"--outdir",e,t]}async function bn(e,t,o){let n=await Ho(Lt(Ko(),"forge-word-"));try{await xe(e,wn(n,t,o),{timeout:12e4});let s=Ct(t,zt(t));return await Pe(Lt(n,`${s}.${o}`))}finally{await Go(n,{recursive:!0,force:!0})}}async function vn(e,t){if(e.op!=="convert")throw new Error(`the word engine cannot ${e.op}`);let o=e.sources[0];if(o.kind!=="document")throw new Error("the word engine can only convert a document source");if(o.encrypted)throw te(o.path);t({phase:"reading"});let n=await an();t({phase:"encoding"});let s=[],r;try{if(n!==void 0)r=await bn(n,o.path,e.target);else{let a=await cn(o);r=e.target==="pdf"?await pn(a,{title:Ct(o.path,zt(o.path)),onMissing:f=>s.push(dt(f))}):await dn(a),s.push(hn())}}catch(a){throw W(o.path,a)}t({phase:"writing"});let i=await M(e.outputs[0],r);return{job:e,outputBytes:i,warnings:s}}var Ut={id:"word",reads:un,writes:mn,ops:ln,probe:en,run:vn};var X=[it,Mt,_t,Bt,Ut,bt,ct];function Or(e){return X.find(t=>t.reads.has(e))}function kr(e){return X.find(t=>t.writes.has(e))}function Dr(e){if(e.op==="convert"){let t=e.sources[0].format;return X.find(o=>o.reads.has(t)&&o.writes.has(e.target))}return X.find(t=>t.ops.has(e.op))}async function Ar(e){let t;for(let o of X)try{return await o.probe(e)}catch(n){A(t)||(t=n)}throw t}export{Zn as a,Ot as b,Xn as c,kt as d,Kn as e,X as f,Or as g,kr as h,Dr as i,Ar as j};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{Fa as s}from"./chunk-CCNRNCRU.js";var a=new Set(["youtube.com","www.youtube.com","m.youtube.com","music.youtube.com"]),l=/^[A-Za-z0-9_-]{11}$/,r=e=>e&&l.test(e)?{kind:"video",id:e,url:`https://www.youtube.com/watch?v=${e}`}:void 0;function k(e){let n=e.trim();if(n==="")return;let u=/^https?:\/\//i.test(n),t;try{t=new URL(/^[a-z]+:\/\//i.test(n)?n:`https://${n}`)}catch{return u?{kind:"other"}:void 0}let o=t.hostname.toLowerCase();if(!(o==="youtu.be"||a.has(o)))return u?{kind:"other"}:void 0;let[i,d]=t.pathname.split("/").filter(Boolean);return(o==="youtu.be"?r(i):i==="watch"?r(t.searchParams.get("v")):i==="shorts"||i==="live"?r(d):i==="playlist"&&t.searchParams.get("list")?{kind:"playlist"}:void 0)??{kind:"other"}}function p(e){if(e?.kind==="playlist")return s("This is a playlist.",void 0,{hint:"Pass one video's link.",shellHint:"Paste one video's link."});if(e?.kind==="other")return s("This is not a YouTube video.",void 0,{hint:"Pass a media file or a YouTube link.",shellHint:"Drop a media file or paste a YouTube link."})}export{k as a,p as b};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{a as y,c as H}from"./chunk-2L66A2X6.js";import{d as K,f as S,g as V}from"./chunk-QPUKPSPZ.js";import{a as X,b as G,e as T}from"./chunk-PISCJKIG.js";import{a as W,b as E}from"./chunk-NMGQGYVM.js";import{i as P,j as U,k as b}from"./chunk-FWVE3GNA.js";import{d as z,l as O}from"./chunk-QO4JUY6B.js";import{b as J,c as L,d as Q,e as u,i as _,m as M}from"./chunk-UN5DSJE2.js";import{a as h,d as w}from"./chunk-4MZV4SRU.js";import{A as B,P as I,a as s,b as $,d as N,e as g}from"./chunk-CCNRNCRU.js";var F=t=>t.length>0&&t.every(e=>e.kind==="image")?t:void 0;function Ht(t,e){let n=X(t);return n.includes(e)?void 0:B(t,e,n)}function Y(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 Z=()=>({kind:"select",id:"target",label:"Save as",default:"png",choices:[{value:"png",label:"PNG",hint:s.png.hint}]}),ut=t=>t===1?"sharp":`${t}x`,ft=t=>t===1||t===3||t===4?t:2,Wt={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=>F(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"}]},Z()],plan(t,e){let n=F(t);if(!n)return[];let o=Y(e),i=ft(Number(e.scale??2));return n.map(r=>({op:"boost",sources:[r],outputs:[u({sourcePath:r.path,target:o.target,suffix:ut(i),...o.output===void 0?{}:{output:o.output},...o.roots?.get(r.path)===void 0?{}:{sourceRoot:o.roots.get(r.path)}})],scale:i,target:o.target,options:{background:o.background,keepMetadata:o.keepMetadata,...o.quality===void 0?{}:{quality:o.quality}}}))}},Kt={id:"remove-background",label:"Remove background",verb:"Removing",hint:"cut out the subject",requires:"remove-background",appliesTo:t=>F(t)!==void 0,unavailable:()=>"images only",options:()=>[Z()],plan(t,e){let n=F(t);if(!n)return[];let o=Y(e);return n.map(i=>({op:"remove-background",sources:[i],outputs:[u({sourcePath:i.path,target:o.target,suffix:"cutout",...o.output===void 0?{}:{output:o.output},...o.roots?.get(i.path)===void 0?{}:{sourceRoot:o.roots.get(i.path)}})],target:o.target,options:{background:o.background,keepMetadata:o.keepMetadata,...o.quality===void 0?{}:{quality:o.quality}}}))}};var ct=[{degrees:90,label:"90\xB0 right",suffix:"rotated-right"},{degrees:180,label:"180\xB0",suffix:"rotated-180"},{degrees:270,label:"90\xB0 left",suffix:"rotated-left"}],x=t=>t===90||t===180||t===270,Yt=(t,e)=>e===180?{...t}:{width:t.height,height:t.width},A=t=>ct.find(e=>e.degrees===t).suffix;import{dirname as mt,join as q}from"node:path";var v="Same location",tt="New subfolder";function lt(t,e,n){return t===e?v:t===h("Desktop")?"Desktop":t===h("Downloads")?"Downloads":e!==void 0&&n!==void 0&&t===q(e,n)?tt:y(t)||t}function R(t,e,n={}){return gt(mt(t.path),e,n)}function gt(t,e,{subfolder:n}={}){let o=w(e.defaultOutput),i=e.lastOutput?w(e.lastOutput):void 0,r=f=>({label:lt(f,t,n),path:f}),a=[r(o),...i?[r(i)]:[],r(h("Desktop")),...t===void 0?[]:[{label:v,path:t}],r(h("Downloads")),...n!==void 0&&t!==void 0?[{label:tt,path:q(t,n)}]:[]],p=new Set,d=a.filter(f=>p.has(f.path)?!1:(p.add(f.path),!0));return{kind:"path",id:"destination",label:"Save to",default:o,presets:d,...i&&i!==o?{last:i}:{}}}var c=t=>typeof t=="string"&&t!==""?t:void 0;var de=[2,1.5,1.25,.75,.5],ht=.25,bt=4,et=-16;function ot(t){return{wav:"m4a",aiff:"m4a",flac:"m4a",avi:"mp4",ogg:"opus"}[t]??t}var nt=t=>t.length===1&&t[0]?.kind==="media"?t[0]:void 0,yt=t=>t==="cut"||t==="mute"||t==="speed"||t==="resize"||t==="crop"||t==="rotate"||t==="loudness"||t==="extract"||t==="cleanup";function St(t,e){let n=e.media??{},o=t.facts?.video,i=[];return e.extract&&i.push("audio"),n.cut&&i.push("trimmed"),n.mute&&i.push("muted"),n.cleanup?i.push("cleaned"):n.loudness!==void 0&&i.push("levelled"),n.speed!==void 0&&i.push(`${n.speed}x`),n.fps!==void 0&&i.push(`${n.fps}fps`),n.bitrate!==void 0&&i.push(`${n.bitrate}k`),e.crop&&i.push(O(e.crop.aspect)),e.resize&&i.push(o?S(b(o,e.resize)):"resized"),e.rotate&&i.push(A(e.rotate)),i.length===1?i[0]:"edited"}function xt(t,e){return t.map(n=>{let o=e.target??n.format,i={background:"#ffffff",keepMetadata:!1};e.media&&Object.keys(e.media).length&&(i.media=e.media),e.resize&&(i.resize=e.resize),e.rotate&&(i.rotate=e.rotate);let r=n.facts?.video;e.crop&&r&&(i.crop={aspect:e.crop.aspect,box:e.crop.box??z(r,e.crop.aspect)});let a=e.roots?.get(n.path),p=u({sourcePath:n.path,target:o,suffix:St(n,e),...e.output===void 0?{}:{output:e.output},...a===void 0?{}:{sourceRoot:a}});return{op:"convert",sources:[n],outputs:[M(p,c(e.destination),c(e.name))],target:o,options:i}})}function k(t){let e={},n=t.cut;return n&&typeof n.start=="number"&&(e.cut={start:n.start,...typeof n.end=="number"?{end:n.end}:{}}),t.mute===!0&&(e.mute=!0),typeof t.speed=="number"&&(e.speed=t.speed),typeof t.fps=="number"&&(e.fps=t.fps),typeof t.bitrate=="number"&&(e.bitrate=t.bitrate),typeof t.loudness=="number"&&(e.loudness=t.loudness),t.cleanup===!0&&(e.cleanup=!0),Object.keys(e).length?e:void 0}var ue={id:"media-edit",label:"Edit",verb:"Editing",hint:"trim, mute, speed, resize, rotate, crop",appliesTo:t=>nt(t)!==void 0,unavailable:()=>"one video or audio file",options:()=>[],plan(t,e){let n=nt(t);if(!n||!yt(e.tool))return[];let o=e.tool,i={...typeof e.output=="string"?{output:e.output}:{},destination:e.destination,name:e.name};if(o==="cut"){let r=k(e)?.cut;if(!r)return[];i.media={cut:r}}if(o==="mute"&&(i.media={mute:!0}),o==="speed"){let r=e.speed;if(typeof r!="number"||r===1||r<ht||r>bt)return[];i.media={speed:r}}if(o==="loudness"&&(i.media={loudness:typeof e.loudness=="number"?e.loudness:et}),o==="cleanup"){if(!n.facts?.audio)return[];i.media={cleanup:!0,loudness:et}}if(o==="extract"){let r=n.facts?.audio;if(!r||!n.facts?.video)return[];i.extract=!0,i.target=H(r.codec)}if(o==="resize"){if(typeof e.resize!="object"||e.resize===null)return[];i.resize=e.resize}if(o==="rotate"){if(!n.facts?.video||!x(e.turn))return[];i.rotate=e.turn}if(o==="crop"){let r=e.crop;if(!r?.aspect||!n.facts?.video)return[];i.crop=r}return xt([n],i)}};import{dirname as kt,join as It}from"node:path";var zt=t=>s[t.format].media==="video",Ot=t=>t.length===1&&t[0]?.kind==="image"?t[0]:void 0,Mt=t=>t.length===1&&t[0]?.kind==="document"?t[0]:void 0,Tt="-small",m={min:30,max:100,step:35},Ft=t=>{let e=Math.ceil((t-m.min)/m.step);return Math.min(m.max,m.min+Math.max(0,e)*m.step)},Se={id:"compress",label:"Compress",verb:"Compressing",hint:"make it smaller",appliesTo:t=>{if(t.length===1&&t[0]?.kind==="media")return!0;let e=Ot(t);if(e!==void 0){let o=s[e.format];return o.lossy||o.quantisable===!0}return(Mt(t)?.images?.compressible??0)>0},options(t,e,n){let o=t[0];if(!o)return[];let i=[{kind:"select",id:"mode",label:`Compress ${y(o.path)??"this file"}`,choices:[o.kind==="media"?{value:"quality",label:"By quality"}:{value:"quality",label:"By quality",hint:"pick a level, see the result"},{value:"size",label:"To a target size",hint:"smallest quality that fits"}],default:"quality"}];if(e.mode==="quality"&&o.kind==="media"&&!zt(o))i.push({kind:"slider",id:"bitrate",label:"Quality",min:32,max:320,step:32,default:96});else if(e.mode==="quality"){let r=o.kind==="image"&&s[o.format].quantisable===!0;i.push(r?{kind:"slider",id:"quality",label:"Quality",...m,default:Ft(g(o.format,n.quality)),points:!0}:{kind:"slider",id:"quality",label:"Quality",min:1,max:100,step:5,default:g(o.format,n.quality)})}else if(e.mode==="size")i.push({kind:"text",id:"size",label:"Target size",placeholder:"e.g. 500kb or 2mb"});else return i;return i.push(R(o,n)),i},plan(t,e){let n=e.mode;if(n!=="quality"&&n!=="size")throw I(`compressAction.plan() needs a mode of "quality" or "size", got ${JSON.stringify(n)}.`,"This is a caller bug, not a user-facing condition: walk options() before calling plan().");let o=t[0];if(!o)return[];let i=(y(o.path)??"file").replace(/\.[^.]+$/,""),r=typeof e.destination=="string"?e.destination:kt(o.path),a=o.kind==="media"?ot(o.format):o.format,p=It(r,J(i,`${Tt}${N(a)}`)),d=o.kind==="media"?k(e):void 0;return[{op:"convert",sources:[o],target:a,outputs:[p],options:{background:"#ffffff",keepMetadata:!1,...n==="quality"&&typeof e.quality=="number"?{quality:e.quality}:{},compress:{dither:e.dither===!0},...d?{media:d}:{}}}]}};function At(t){return{kind:"select",id:"pages",label:"Pages",default:"all",choices:[{value:"all",label:"All pages",hint:`${t.pages} pages`},{value:"first",label:"First page only"},{value:"choose",label:"Choose pages",hint:"pick which ones"}]}}function Rt(){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 wt(t,e){return Array.isArray(e)?E(e):e==="first"?[0]:typeof e=="string"&&e!=="all"&&e!==""?E(W(e,t.pages)):Array.from({length:t.pages},(n,o)=>o)}function Pt(t,e){let n=s[t.format].lossy,o=s[e].lossy;if(n&&!o)return{hint:"likely bigger",tone:"warn"};if(!n&&o)return{hint:"likely smaller",tone:"ok"}}function Et(t){let e=t.kind==="document"&&t.encrypted,n=G(t).filter(i=>i.id!==t.format&&(!e||T(i.id))),o=n[0];return{kind:"select",id:"target",label:`Convert ${s[t.format].label} to`,choices:n.map(i=>{let r=Pt(t,i.id);return{value:i.id,label:i.label,hint:r?.hint??i.hint,...r===void 0?{}:{tone:r.tone}}}),default:o?o.id:""}}function Ct(t){return{kind:"slider",id:"bitrate",label:"Quality",min:64,max:320,step:32,default:t==="opus"?96:128}}var jt=t=>typeof t=="object"&&t!==null&&("percent"in t||"width"in t||"height"in t);function Dt(t){let e=t.target,n=typeof e=="string"?$(e):void 0;if(!n)throw I(`convertAction.plan() requires a valid target format, got ${JSON.stringify(e)}.`,"This is a caller bug, not a user-facing condition: call options() and pass one of the target select choices before calling plan().");return n}var Ae={id:"convert",label:"Convert",verb:"Converting",hint:"to another format",appliesTo:t=>t.length>=1,options(t,e,n){let o=t[0];if(!o)return[];let i=[Et(o)],r=e.target;if(typeof r!="string")return i;o.kind==="document"&&T(r)&&i.push(At(o),Rt());let a=s[r];return o.kind==="media"?a?.media==="sound"&&a.lossy&&i.push(Ct(r)):a?.lossy&&a.media===void 0&&i.push({kind:"slider",id:"quality",label:"Quality",min:1,max:100,step:5,default:g(r,n.quality)}),i.push(R(o,n)),i},plan(t,e){let n=t[0];if(!n)return[];let o=Dt(e),i=o.id,r={background:typeof e.background=="string"?e.background:"#ffffff",keepMetadata:e.keepMetadata===!0};if(o.lossy&&typeof e.quality=="number"&&(r.quality=e.quality),n.kind==="media"){let d=k(e);d&&(r.media=d),jt(e.resize)&&(r.resize=e.resize)}let a=typeof e.destination=="string"?e.destination:void 0;if(n.kind==="document"&&T(i)){let d=Number(e.dpi);r.dpi=Number.isFinite(d)&&d>0?d:150;let f=wt(n,e.pages);r.pages=f;let pt=typeof e.sourceRoot=="string"?e.sourceRoot:void 0,dt=_(n.path,f,i,a,pt);return[{op:"convert",sources:[n],outputs:dt,target:i,options:r}]}let p=Q({sourcePath:n.path,target:i,...a===void 0?{}:{output:`${a}/`}});return L(p,n.path)&&(p=u({sourcePath:n.path,target:i,suffix:i,...a===void 0?{}:{output:`${a}/`}})),[{op:"convert",sources:[n],outputs:[p],target:i,options:r}]}};var $t=[16,4,2],C=t=>typeof t=="number"&&$t.includes(t),it=t=>`dithered-${t}`,Pe=t=>`${t} colours`,rt=t=>s[t.format].quantisable?t.format:"png",j=t=>!(t.frames>1)||t.format==="gif";function Nt(t,e){if(e.dither)return it(e.dither);if(e.deband)return U(e.deband);if(!e.rotate)return at(t,e);let n=A(e.rotate);return e.trim||e.crop||e.resize?`${at(t,e)}-${n}`:n}function at(t,e){if(e.crop){let n=O(e.crop.aspect);if(!e.resize)return n;let o=e.crop.box??z(t,e.crop.aspect);return`${n}-${S(b(o,e.resize))}`}return e.trim&&e.resize?`trimmed-${V(e.resize)}`:e.resize?S(b(t,e.resize)):"trimmed"}function Bt(t,e){if(e.trim&&e.crop)throw new Error("planEdit cannot trim and crop the same image");return t.map(n=>{let o=e.target??(e.dither?rt(n):K(n)),i={background:e.background,keepMetadata:e.keepMetadata,...e.quality===void 0?{}:{quality:e.quality},...e.trim?{trim:!0}:{},...e.resize?{resize:e.resize}:{},...e.crop?{crop:e.crop}:{},...e.rotate?{rotate:e.rotate}:{},...e.dither?{dither:e.dither}:{},...e.deband?{deband:e.deband}:{},...e.deband&&e.quality===void 0&&s[o].lossy?{quality:95}:{}},r=e.roots?.get(n.path),a=u({sourcePath:n.path,target:o,suffix:Nt(n,e),...e.output===void 0?{}:{output:e.output},...r===void 0?{}:{sourceRoot:r}});return{op:"convert",sources:[n],outputs:[M(a,c(e.destination),c(e.name))],target:o,options:i}})}var D=t=>t.length>0&&t.every(e=>e.kind==="image")?t:void 0,Jt=t=>typeof t=="object"&&t!==null&&("percent"in t||"width"in t||"height"in t),st=t=>typeof t=="object"&&t!==null&&"aspect"in t&&typeof t.aspect=="object"&&t.aspect!==null&&"w"in t.aspect&&"h"in t.aspect;function l(t,e,n,o){return{id:t,label:e,verb:n,hint:o,appliesTo:i=>D(i)?.every(r=>t==="resize"?!0:t==="dither"?j(r):r.frames<=1)===!0,unavailable:i=>D(i)?"animated":"images only",options:()=>[],plan(i,r){let a=D(i);return a?t==="crop"&&!st(r.crop)?[]:t==="turn"&&!x(r.turn)?[]:t==="deband"&&(!P(r.deband)||a.some(p=>p.frames>1))?[]:t==="dither"&&(!C(r.dither)||!a.every(j))?[]:Bt(a,{trim:t==="trim"||r.trim===!0,...x(r.turn)?{rotate:r.turn}:{},...t==="dither"&&C(r.dither)?{dither:r.dither}:{},...t==="deband"&&P(r.deband)?{deband:r.deband}:{},...Jt(r.resize)?{resize:r.resize}:{},...st(r.crop)?{crop:r.crop}:{},...typeof r.target=="string"?{target:r.target}:{},...typeof r.output=="string"?{output:r.output}:{},...r.roots instanceof Map?{roots:r.roots}:{},destination:r.destination,name:r.name,background:typeof r.background=="string"?r.background:"#ffffff",keepMetadata:r.keepMetadata===!0,...typeof r.quality=="number"?{quality:r.quality}:{}}):[]}}}var Qe=l("trim","Trim edges","Trimming edges","cut empty borders"),_e=l("resize","Resize","Resizing","smaller or larger"),Ue=l("crop","Crop to shape","Cropping","change the shape"),Xe=l("turn","Rotate","Rotating","turn it"),Ge=l("dither","Dither","Dithering","fewer colours, scattered"),He=l("deband","Remove banding","Removing banding","smooth out stripes");export{Ht as a,Wt as b,Kt as c,tt as d,R as e,gt as f,c as g,ct as h,Yt as i,de as j,xt as k,ue as l,Se as m,Ae as n,$t as o,Pe as p,rt as q,j as r,Bt as s,Qe as t,_e as u,Ue as v,Xe as w,Ge as x,He as y};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{b as fe,e as me,f as ge,g as he,i as ye,j as be}from"./chunk-EJWTYDBJ.js";import{a as ue,b as de,c as pe,k as ce,m as z,n as J,s as le}from"./chunk-UI4EUC3S.js";import{b as se,c as W}from"./chunk-6RMRWBMB.js";import{a as x}from"./chunk-X4QI2EYV.js";import{b as I}from"./chunk-QIMSNTKL.js";import{d as Re,e as q}from"./chunk-QPUKPSPZ.js";import{a as B,c as ae,d as ie,e as S,f as j}from"./chunk-PISCJKIG.js";import{f as we,g as xe,h as ve,i as ke,j as Ie,k as Pe}from"./chunk-YJ6XLDRA.js";import{a as y}from"./chunk-WID72ZII.js";import{d as F}from"./chunk-EEQSUBBL.js";import{b as ne}from"./chunk-3IX3QA76.js";import{a as _,d as ee}from"./chunk-FWVE3GNA.js";import{a as k,c as re,d as C,e as oe,i as te}from"./chunk-UN5DSJE2.js";import{A as Y,D,La as Z,P as O,S as K,V as Q,X,a as R,c as A,d as L,f as $,w as U,y as E}from"./chunk-CCNRNCRU.js";import{a as w,b as H}from"./chunk-FGR6QCG5.js";import{b as P,c as v}from"./chunk-VLVNA4T3.js";import{basename as Ne,dirname as Ae,extname as De,resolve as V}from"node:path";async function $e(e){let o=[],r=[...e.resolved.failures];for(let t of e.resolved.sources){let n=B(t);if(!n.includes(e.target)){r.push({path:t.path,error:Y(t,e.target,n)});continue}let a={sourcePath:t.path,target:e.target,output:e.output,sourceRoot:e.resolved.roots.get(t.path)},s=C(a);re(s,t.path)&&e.target!==t.format&&(s=oe({...a,suffix:e.target})),o.push({op:"convert",sources:[t],outputs:[s],target:e.target,options:e.options})}return{jobs:o,failures:r}}import{resolve as ze}from"node:path";function qe(e,o=new Set){let r={path:ze(e.path),kind:e.kind,format:e.format,bytes:e.bytes},t=e.kind==="document"&&e.encrypted===!0,n={targets:B(e).filter(a=>!t||S(a)),actions:ye([e],o).filter(a=>!t||a.id===J.id).map(a=>a.id)};if(e.kind==="image")return{...r,width:e.width,height:e.height,...n};if(e.kind==="media"){let a=e.facts;return{...r,...a?{duration:a.duration}:{},...a?.video?{width:a.video.width,height:a.video.height,fps:a.video.fps}:{},...n}}return{...r,...e.pages>0?{pages:e.pages}:{},encrypted:e.encrypted,...n}}async function Ee(e){let o=await x(e,{recursive:!1}),{installedExtensionIds:r}=await import("./available-TNMISSBA.js"),t=await r();return{probes:o.sources.map(n=>qe(n,t)),failures:o.failures}}import{dirname as Ve}from"node:path";var T=e=>({cwd:e.cwd??process.cwd(),...e.home===void 0?{}:{home:e.home}});function Fe(e,o){let r=P(Ve(e),T(o));return r==="."?"":` in ${r.endsWith("/")?r:`${r}/`}`}function Oe(e,o){let{pct:r,direction:t}=H(e,o);return t==="same"?"same size":`${r}% ${t}`}function Ce(e,o={}){let r=e.results[0];if(!r)return[];let t=r.job.sources[0],n=r.job.outputs;if(n.length>1){let s=[`\u2713 ${v(t.path)} \u2192 ${n.length} files${Fe(n[0],o)}`,` ${n.map(i=>v(i)).join(", ")}`,` ${w(t.bytes)} \u2192 ${w(r.outputBytes)} total`];for(let i of r.warnings)s.push("",`\u26A0 ${i.message}`);return s}let a=[`\u2713 ${v(t.path)} \u2192 ${P(n[0],T(o))}`,` ${w(t.bytes)} \u2192 ${w(r.outputBytes)} \xB7 ${Oe(t.bytes,r.outputBytes)}`];for(let s of r.warnings)a.push("",`\u26A0 ${s.message}`);return a}function Be(e,o={}){let r=[`\u2713 ${e.results.length} converted`,` ${w(e.inputBytes)} \u2192 ${w(e.outputBytes)} \xB7 ${Oe(e.inputBytes,e.outputBytes)}`];for(let n of e.results)for(let a of n.job.outputs)r.push(` ${P(a,T(o))}`);let t=e.results.flatMap(n=>n.warnings);if(t.length>0){r.push("");for(let n of t)r.push(`\u26A0 ${n.message}`)}return r}function Se(e,o={}){let r=e.results.flatMap(u=>u.job.outputs),t=r.map(u=>v(u)).join(", "),n=r.length===1?"file":"files",a=r[0]===void 0?"":Fe(r[0],o),s=[`\u2713 ${r.length} ${n} \xB7 ${t}${a}`],i=e.results.flatMap(u=>u.warnings);for(let u of i)s.push("",`\u26A0 ${u.message}`);return s}function M(e,o){if(e.length===0)return[];let r=[];for(let t of e)r.push(...Z(t.error,{debug:o.debug}),"");return r}function je(){let e=new Set(ae()),o=new Set(ie()),r=["Formats",""],t=j(),n=Math.max(...t.map(s=>s.label.length));for(let s of t){let i=s.read&&s.write?"read and write":s.read?"read only":"write only";r.push(` ${s.label.padEnd(n)} ${i.padEnd(14)} ${s.extensions.join(" ")}`)}let a=[...e].filter(s=>!o.has(s)).map(s=>R[s].label);if(a.length>0){let s=a.join(", "),[i,u]=a.length===1?["is","it"]:["are","them"];r.push("",`${s} ${i} read only because Forge cannot yet write ${u}.`)}return r}function Je(e,o={}){let r=[R[e.format].label,w(e.bytes)];return e.duration!==void 0&&r.push(F(e.duration)),e.width!==void 0&&e.height!==void 0&&r.push(`${e.width}\xD7${e.height}`),e.fps!==void 0&&r.push(`${e.fps} fps`),e.pages!==void 0&&r.push(`${e.pages} ${e.pages===1?"page":"pages"}`),e.encrypted&&r.push("password-protected"),[`${P(e.path,T(o))} \xB7 ${r.join(" \xB7 ")}`,` converts to ${e.targets.join(", ")}`,` actions ${e.actions.join(", ")}`]}import{createInterface as Te}from"node:readline";import{PassThrough as Ge}from"node:stream";function Le(e){return new Promise(o=>{let r=Te({input:e,terminal:!1}),t=!1,n=a=>{if(t)return;t=!0,r.close(),e.pause(),e.unref?.(),o(a.replace(/\r$/,""))};r.once("line",n),r.once("close",()=>n(""))})}async function Me(e){if(e.stdin)return Le(process.stdin);if(!process.stdin.isTTY)return;let o=new Ge,r=Te({input:process.stdin,output:o,terminal:!0});try{return process.stderr.write("Password: "),await new Promise(t=>r.question("",t))}finally{process.stderr.write(`
|
|
4
|
-
`),r.close()}}function He(e){return e.kind==="preset"?e.name:e.kind==="pageop"?"PDF":e.kind==="compress"?"Compress":e.kind==="convert"?"Convert":"Edit"}function G(e){return e.length===0?0:e.some(o=>o.error.code==="invalid-arguments")?2:1}function Ue(e,o){if(e.action==="merge")return{};if(e.action==="rotate")return{degrees:e.rotate};if(e.action==="extract")return{pages:e.pages,separate:e.separate?"many":"one"};if(e.action==="delete")return{pages:e.pages};let r=o.find(s=>s.kind==="document"),t=r?.pages??0,n=e.split;if(!n)throw O("--split needs a mode: every-page, every=N or at=N,N.");if(n.mode==="every-page")return{cuts:me(t)};if(n.mode==="every-n"){let s=ge(t,n.n);if(s.length===0&&r)throw Q(r.path,t,n.n);return{cuts:s}}let a=Math.max(t-1,0);for(let s of n.after)if(!Number.isInteger(s)||s<1||s>a)throw K(s,r?v(r.path):"The document",t);return{cuts:n.after.map(s=>s-1)}}function Ye(e,o){let r;return()=>o?(r??=Me({stdin:e}).then(t=>e&&t===""?void 0:t),r):Promise.resolve(void 0)}async function Ke(e,o,r,t){let n;if(e.encrypted){if(n=o.password??await r(),n===void 0)return{failure:{path:e.path,error:D(e.path)}};if(!await ne(e.path,n))return{failure:{path:e.path,error:D(e.path,{attempted:!0})}}}let a;try{a=J.plan([e],{target:o.target,background:o.options.background,keepMetadata:o.options.keepMetadata,dpi:String(o.dpi??150),...o.options.quality===void 0?{}:{quality:o.options.quality},...o.pages===void 0?{}:{pages:o.pages},...o.output===void 0||!k(o.output)?{}:{destination:o.output},...t===void 0?{}:{sourceRoot:t}})}catch(i){if(!$(i))throw i;return{failure:{path:e.path,error:i}}}let s=a[0];if(s?.op!=="convert")throw new Error(`convertAction.plan() did not return a convert job for ${e.path}`);return n!==void 0&&(s.options.password=n),o.output!==void 0&&!k(o.output)&&(s.outputs=s.outputs.length===1?[V(o.output)]:te(V(o.output),s.options.pages??[],o.target)),{job:s}}function N(e,o){return r=>{if(r.type==="search:attempt"){o||e.onSearch?.(r.rung.dpi===void 0?`attempt ${r.attempt} of ${r.of}`:`${r.rung.dpi} dpi \xB7 attempt ${r.attempt} of ${r.of}`);return}if(r.type==="search:settled"){o&&e.onSearch?.(`${r.completed} of ${r.total} searched`);return}if(!o&&r.type==="job:phase"&&r.progress.phase==="time"){let t=r.progress,n=`${F(t.done)} of ${F(t.total)}`;e.onEncode?.(t.pass?`pass ${t.pass.at} of ${t.pass.of} \xB7 ${n}`:n);return}o&&(r.type==="job:done"||r.type==="job:error")&&e.onProgress?.({completed:r.completed,total:r.total})}}var b=(e,o)=>({kind:e,results:[],failures:o,inputBytes:0,outputBytes:0});async function Qe(e,o){let r=await x(e.inputs,{recursive:!1});if(r.sources.length===0)return b("pageop",r.failures);let t=he.find(u=>u.id===e.action);if(!t)throw new Error(`no action registered for "${e.action}"`);let n=r.sources[0]?.path??"",a=e.action==="merge";if(a?!fe(r.sources):!t.appliesTo(r.sources)){let u=a?r.sources.length<2?"needs 2+ files":"PDFs and images only":be(t,r.sources)??"not available for these files";return b("pageop",[...r.failures,{path:n,error:E(e.action,u)}])}let s;try{s=t.plan(r.sources,Ue(e,r.sources))}catch(u){if(!$(u))throw u;return b("pageop",[...r.failures,{path:n,error:u}])}let i=await I(s,{force:e.force,...o.signal===void 0?{}:{signal:o.signal}});return{kind:"pageop",results:i.results,failures:[...r.failures,...i.refusals,...i.failures],inputBytes:i.inputBytes,outputBytes:i.outputBytes}}async function Xe(e,o){let r=await x(e.inputs,{recursive:e.recursive}),t=e.output===void 0||k(e.output)?[]:A(De(e.output)),n=t[0];if(n!==void 0&&r.sources.some(d=>!t.some(c=>c.id===d.format)))return We({kind:"convert",inputs:e.inputs,target:n.id,options:{...e.options,...e.quality===void 0?{}:{quality:e.quality}},force:e.force,recursive:e.recursive,debug:e.debug,dpi:e.dpi??150,...e.output===void 0?{}:{output:e.output},...e.maxBytes===void 0?{}:{maxBytes:e.maxBytes},...e.concurrency===void 0?{}:{concurrency:e.concurrency}},o);let a=[],s=[];for(let d of r.sources){if(!z.appliesTo([d])){s.push({path:d.path,error:U(d)});continue}let c=e.output!==void 0&&!k(e.output)?V(e.output):void 0,l=e.output===void 0||c!==void 0?Ae(d.path):Ae(C({sourcePath:d.path,target:d.format,output:e.output,sourceRoot:r.roots.get(d.path)})),[f]=z.plan([d],{mode:e.maxBytes===void 0?"quality":"size",...e.quality===void 0?{}:{quality:e.quality},...e.options.media??{},destination:l});f?.op==="convert"&&(c!==void 0&&(f.outputs=[c]),e.dpi!==void 0&&(f.options.dpi=e.dpi),a.push(f))}let i=a.length>1;i&&o.onProgress?.({completed:0,total:a.length});let u=await I(a,{force:e.force,...e.concurrency===void 0?{}:{concurrency:e.concurrency},...e.maxBytes===void 0?{}:{targetBytes:e.maxBytes},...o.signal===void 0?{}:{signal:o.signal},onEvent:N(o,i)});return{kind:"compress",results:u.results,failures:[...r.failures,...s,...u.refusals,...u.unreachable.map(d=>({path:d.job.sources[0].path,error:d.error})),...u.failures],inputBytes:u.inputBytes,outputBytes:u.outputBytes}}async function Ze(e,o){let r=e.kind,t=e.op==="remove-background"&&e.target!==void 0?_(e.target):void 0;if(t)return b(r,[{path:"",error:t}]);let{installed:n}=await import("./paths-6OENILJ4.js"),a=await n(e.op);if(!a)return b(r,[{path:"",error:X(e.op)}]);if(e.op==="boost"&&e.scale!==void 0){let{assetFor:f,catalogEntry:m}=await import("./catalog-FMHWWMUX.js"),p=m("boost"),g=p&&f(p)?.version,h=ee(e.scale,a.version,g);if(h)return b(r,[{path:"",error:h}])}let s=await x(e.inputs,{recursive:e.recursive}),i=e.op==="boost"?de:pe,u=[],d=[];for(let f of s.sources){if(!i.appliesTo([f])){d.push({path:f.path,error:E(e.op==="remove-background"?"remove the background of":e.scale===1?"sharpen":"boost","it works on images, not documents","Try an image such as a JPEG, PNG, WebP or HEIC file.")});continue}let m=e.target??(e.op==="boost"&&f.kind==="image"?Re(f):"png"),p=ue(f,m);if(p){d.push({path:f.path,error:p});continue}u.push(...i.plan([f],{target:m,background:e.options.background,keepMetadata:e.options.keepMetadata,...e.scale===void 0?{}:{scale:e.scale},...e.options.quality===void 0?{}:{quality:e.options.quality},...e.output===void 0?{}:{output:e.output},roots:s.roots}))}let c=u.length>1;c&&o.onProgress?.({completed:0,total:u.length});let l=await I(u,{force:e.force,concurrency:1,...o.signal===void 0?{}:{signal:o.signal},onEvent:N(o,c)});return{kind:r,results:l.results,failures:[...s.failures,...d,...l.refusals,...l.failures],inputBytes:l.inputBytes,outputBytes:l.outputBytes}}function _e(e){let o=Object.keys(e??{});return o.length===1&&(o[0]==="cut"||o[0]==="mute")?o[0]:"edit"}async function er(e,o){let r=e.crop!==void 0?"crop":e.resize!==void 0?"resize":"trim",t=e.target===void 0?void 0:q(e.target,r);if(t)return b(e.kind,[{path:"",error:t}]);let n=await x(e.inputs,{recursive:e.recursive}),a=[],s=[],i=[];for(let h of n.sources)h.kind==="image"&&e.media===void 0?a.push(h):h.kind==="media"&&!e.trim?s.push(h):h.kind==="image"?i.push({path:h.path,error:E(_e(e.media),"it works on video and sound, not images","Try a video or sound file, such as a MOV, MP4 or WAV.")}):i.push({path:h.path,error:E(r,"it works on images, not documents","Try an image such as a JPEG, PNG, WebP or HEIC file.")});let u=e.target===void 0?e.named:void 0,d=u===void 0||a.length===0?void 0:q(u,r);if(d)return b(e.kind,[{path:"",error:d}]);let c=e.target??u,l=ce(s,{...e.media===void 0?{}:{media:e.media},...e.crop===void 0?{}:{crop:e.crop},...e.resize===void 0?{}:{resize:e.resize},...c===void 0?{}:{target:c},...e.output===void 0?{}:{output:e.output},roots:n.roots}),m=[...le(a,{trim:e.trim,...e.crop===void 0?{}:{crop:e.crop},...e.resize===void 0?{}:{resize:e.resize},...c===void 0?{}:{target:c},...e.output===void 0?{}:{output:e.output},roots:n.roots,background:e.options.background,keepMetadata:e.options.keepMetadata,...e.options.quality===void 0?{}:{quality:e.options.quality}}),...l],p=m.length>1;p&&o.onProgress?.({completed:0,total:m.length});let g=await I(m,{force:e.force,...e.concurrency===void 0?{}:{concurrency:e.concurrency},...o.signal===void 0?{}:{signal:o.signal},onEvent:N(o,p)});return{kind:e.kind,results:g.results,failures:[...n.failures,...i,...g.refusals,...g.failures],inputBytes:g.inputBytes,outputBytes:g.outputBytes}}async function We(e,o){let r=await x(e.inputs,{recursive:e.recursive}),t=p=>p.kind==="document"&&p.format==="pdf",n=S(e.target),a=n?r.sources.filter(t):[],s=n?r.sources.filter(p=>!t(p)):r.sources,i=[],u=[],d=Ye(e.passwordStdin??!1,o.interactive??!0);for(let p of a){let g=await Ke(p,e,d,r.roots.get(p.path));"failure"in g?u.push(g.failure):i.push(g.job)}let c=await $e({resolved:{sources:s,failures:[],roots:r.roots},target:e.target,options:e.options,force:e.force,...e.output===void 0?{}:{output:e.output}}),l=[...c.jobs,...i],f=l.length>1;f&&o.onProgress?.({completed:0,total:l.length});let m=await I(l,{force:e.force,...e.concurrency===void 0?{}:{concurrency:e.concurrency},...e.maxBytes===void 0?{}:{targetBytes:e.maxBytes},...o.signal===void 0?{}:{signal:o.signal},onEvent:N(o,f)});return{kind:"convert",results:m.results,failures:[...r.failures,...u,...c.failures,...m.refusals,...m.unreachable.map(p=>({path:p.job.sources[0].path,error:p.error})),...m.failures],inputBytes:m.inputBytes,outputBytes:m.outputBytes}}function rr(e){if(e.kind!=="convert"&&e.kind!=="edit"&&e.kind!=="extension-op"||e.output===void 0||k(e.output))return e;let o=De(e.output),t=A(o)[0];if(t===void 0)return e;if(e.target===void 0)return e.kind==="edit"?{...e,named:t.id}:{...e,target:t.id};if(R[e.target].extensions.includes(o.toLowerCase()))return e;let n=Ne(e.output);throw O(`-o ${n} conflicts with --to ${e.target}.`,`Name it ${Ne(n,o)}${L(e.target)}, or use --to ${t.id}.`)}async function or(e,o={}){try{if(e.kind==="pageop")return await Qe(e,o);if(e.kind==="extension-op")return await Ze(e,o);if(e.kind==="edit")return await er(e,o);if(e.kind==="preset"){let{runPresetCommand:r}=await import("./preset-command-5I3NZ2OP.js");return await r(e,o.signal)}return e.kind==="compress"?await Xe(e,o):await We(e,o)}catch(r){if(!$(r))throw r;return b(e.kind,[{path:"",error:r}])}}function tr(e,o){let r=G(e.failures);if(o.json)return{exitCode:r,stdout:[JSON.stringify(we(y,e))],stderr:[]};let t=e.results.length===0?[]:e.kind==="pageop"?Se(e):e.results.length===1?Ce(e):Be(e);return{exitCode:r,stdout:t,stderr:M(e.failures,{debug:o.debug})}}function sr(e,o){let r=[{path:"",error:e}],t=G(r);return o.json?{exitCode:t,stdout:[JSON.stringify(xe(y,e))],stderr:[]}:{exitCode:t,stdout:[],stderr:M(r,{debug:o.debug})}}async function nr(e,o){let{runConfig:r}=await import("./config-command-VEGQPXVB.js"),t=await r(e);return o?{exitCode:0,stdout:[JSON.stringify(Ie(y,t.config,t.warnings))],stderr:[]}:{exitCode:0,stdout:t.stdout,stderr:[]}}async function Xr(e,o={}){let r=o.json??!1,t="debug"in e?e.debug:!1;try{if(e.kind==="config")return await nr(e,r);if(e.kind==="clip"){let{runClipCommand:s}=await import("./clip-command-4ON3Q57W.js");return await s(e,{...o,json:r,debug:t})}if(e.kind==="update"){let{runUpdate:s}=await import("./update-command-6VVDG75Y.js"),i=await s(y,{...o.onInstalling?{onInstalling:o.onInstalling}:{}});return{exitCode:0,stdout:r?[JSON.stringify({forge:y,ok:!0,...i.data})]:i.stdout,stderr:[]}}if(e.kind==="uninstall"){let{runUninstall:s}=await import("./entry-3R2GK3IW.js"),i=[];return{exitCode:await s(y,d=>i.push(d)),stdout:i,stderr:[]}}if(e.kind==="extensions"){let{runExtensions:s}=await import("./extensions-command-RNAPQYWV.js"),i=await s(e,{onDownload:o.onDownload});return{exitCode:0,stdout:r?[JSON.stringify(Pe(y,i.data))]:i.stdout,stderr:[]}}if(e.kind==="formats")return r?{exitCode:0,stdout:[JSON.stringify(ve(y,j()))],stderr:[]}:{exitCode:0,stdout:je(),stderr:[]};if(e.kind==="probe"){let{probes:s,failures:i}=await Ee(e.inputs),u=G(i);return r?{exitCode:u,stdout:[JSON.stringify(ke(y,{probes:s,failures:i}))],stderr:[]}:{exitCode:u,stdout:s.flatMap((d,c)=>[...c>0?[""]:[],...Je(d)]),stderr:M(i,{debug:t})}}if(e.kind==="palette"||e.kind==="scale"||e.kind==="card"){let{runCard:s,runPalette:i,runScale:u}=await import("./colour-2BGK2BFR.js"),d={json:r,colour:o.colour??!1};return e.kind==="card"?await s(e,d):e.kind==="palette"?await i(e,d):await u(e,d)}if(e.kind==="transcribe"){let{runTranscribeCommand:s,transcribeFact:i}=await import("./transcribe-command-VY5HYNXV.js"),u=[],d=[],c,{onTranscribe:l}=o,f="";return{exitCode:await s(e,{out:p=>u.push(p),err:p=>d.push(p),...l?{onStart:p=>{f=p==="read"?"reading text":"transcribing",l(f,"")},onProgress:p=>l(f,i(p))}:{},finished:p=>{c=W("Transcribe",p)}}),stdout:u,stderr:d,...c?{notice:c}:{}}}if(e.kind==="shell")return{exitCode:0,stdout:[],stderr:[]};if(e.kind==="watch")throw O("forge watch runs in a terminal until ctrl-c.","Try: forge watch ./images --to webp");let n=await or(rr(e),o),a=W(He(e),se(n.results,n.failures));return{...tr(n,{json:r,debug:t}),...a?{notice:a}:{}}}catch(n){if(!$(n))throw n;return sr(n,{json:r,debug:t})}}export{Ee as a,Oe as b,G as c,or as d,tr as e,Xr as f};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{a,b,c,d}from"./chunk-YJZEHJ6U.js";import"./chunk-JUA63KQK.js";import"./chunk-NUTTDNTG.js";import"./chunk-X2YUHPOU.js";import"./chunk-EJWTYDBJ.js";import"./chunk-UI4EUC3S.js";import"./chunk-2L66A2X6.js";import"./chunk-6RMRWBMB.js";import"./chunk-X4QI2EYV.js";import"./chunk-QIMSNTKL.js";import"./chunk-ECA4PW5T.js";import"./chunk-QPUKPSPZ.js";import"./chunk-PISCJKIG.js";import"./chunk-YJ6XLDRA.js";import"./chunk-63XCSYHM.js";import"./chunk-WID72ZII.js";import"./chunk-O7DK3GJT.js";import"./chunk-65Y7YCZZ.js";import"./chunk-NMGQGYVM.js";import"./chunk-EEQSUBBL.js";import"./chunk-BSFBZBAI.js";import"./chunk-BWJNZT75.js";import"./chunk-3IX3QA76.js";import"./chunk-PON65UTS.js";import"./chunk-FWVE3GNA.js";import"./chunk-QO4JUY6B.js";import"./chunk-UN5DSJE2.js";import"./chunk-6HUYBVQA.js";import"./chunk-KXKQDFHX.js";import"./chunk-4MZV4SRU.js";import"./chunk-BYUOU2Q2.js";import"./chunk-NUCGWLOY.js";import"./chunk-I2LPGKUU.js";import"./chunk-HON4OV7M.js";import"./chunk-CCNRNCRU.js";import"./chunk-FGR6QCG5.js";import"./chunk-VLVNA4T3.js";import"./chunk-TMUK2DD3.js";export{b as clipLines,a as runClip,d as runClipCommand,c as runUndo};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{a as K}from"./chunk-4NDZTK22.js";import{g as V,h as _,i as M}from"./chunk-G6L5NIJ5.js";import{b as v,c as U}from"./chunk-POM7FXIV.js";import{i as B,l as Y,m as q,o as z}from"./chunk-5FJT4BNY.js";import{b as $,c as W,h as D,i as O,j as x}from"./chunk-EYOO35US.js";import{a as F,b as G,c as H}from"./chunk-YJ6XLDRA.js";import"./chunk-63XCSYHM.js";import{a as w}from"./chunk-WID72ZII.js";import"./chunk-NMGQGYVM.js";import"./chunk-EEQSUBBL.js";import"./chunk-BSFBZBAI.js";import"./chunk-BWJNZT75.js";import"./chunk-3IX3QA76.js";import"./chunk-PON65UTS.js";import"./chunk-FWVE3GNA.js";import"./chunk-QO4JUY6B.js";import"./chunk-UN5DSJE2.js";import"./chunk-6HUYBVQA.js";import"./chunk-KXKQDFHX.js";import"./chunk-I2LPGKUU.js";import{g as N,h as P,i as I,m as L,q as A,r as J,s as T}from"./chunk-CCNRNCRU.js";import"./chunk-FGR6QCG5.js";import{c as k}from"./chunk-VLVNA4T3.js";import"./chunk-TMUK2DD3.js";import{readFile as at}from"node:fs/promises";import{basename as lt,resolve as tt}from"node:path";function h(t,e){let o=x(e);if(!o)return;let r=o.alpha!==void 0&&o.alpha<1?o.alpha:void 0;return{name:t,hex:$(o.rgb),...r===void 0?{}:{alpha:r}}}function S(t){return/^\s*(#|(rgba?|hsla?|hwb|lab|lch|oklab|oklch|color)\s*\()/i.test(t)}function Q(t){let e=t.replace(/^/,"").trim();if(e==="")return{colours:[],bad:[]};if(e.startsWith("{")||e.startsWith("["))try{return ot(JSON.parse(e))}catch{}return ut(e.split(/\r?\n/))}var g=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),et=["hex","colour","color","value","$value"];function ot(t){let e={colours:[],bad:[]};if(Array.isArray(t)){for(let c of t){if(!g(c))continue;let p=typeof c.name=="string"?c.name:void 0,f=et.find(d=>typeof c[d]=="string");if(!p||!f)continue;let l=c[f],m=h(p,l);m?e.colours.push(m):e.bad.push(`${p}: ${l}`)}return e}if(!g(t))return e;let o=Object.keys(t).filter(c=>!c.startsWith("$")),r=o.length===1?t[o[0]]:void 0,n=c=>"$value"in c?c.$value:c.value,s=c=>"$value"in c||typeof c.value=="string",u=g(r)&&!s(r)?r:t,a=(c,p=0)=>{let f=/^\{(.+)\}$/.exec(c.trim());if(!f||p>8)return c;let l=t;for(let d of f[1].split("."))l=g(l)?l[d]:void 0;let m=g(l)&&s(l)?n(l):void 0;return typeof m=="string"?a(m,p+1):typeof l=="string"?a(l,p+1):c},i=(c,p,f)=>{let l=c.$type??f;for(let[m,d]of Object.entries(c)){if(m.startsWith("$"))continue;let y=[...p,m].join("/");if(g(d)&&s(d)){let C=d.$type??d.type??l,b=n(d);if(typeof b!="string")continue;let E=a(b),R=h(y,E);R?e.colours.push(R):(C==="color"||S(E))&&e.bad.push(`${y}: ${b}`)}else if(g(d))i(d,[...p,m],l);else if(typeof d=="string"){let C=a(d),b=h(y,C);b?e.colours.push(b):S(C)&&e.bad.push(`${y}: ${d}`)}}};return i(u,[]),e}function X(t){let e=[],o="",r=!1;for(let n=0;n<t.length;n++){let s=t[n];r?s==='"'&&t[n+1]==='"'?(o+='"',n++):s==='"'?r=!1:o+=s:s==='"'?r=!0:s===","?(e.push(o.trim()),o=""):o+=s}return e.push(o.trim()),e}var rt=["name","token","label"],nt=["hex","colour","color","value","rgb"];function st(t,e,o){let r={colours:[],bad:[]};for(let n of t){if(n.trim()==="")continue;let s=X(n),u=s[e]??"",a=s[o]??"",i=u?h(u,a):void 0;i?r.colours.push(i):r.bad.push(n.trim())}return r}function it(t){let e=t.replace(/^[-*•]\s+/,"").replace(/[;,]$/,"").trim();for(let n of[" ",":","=",","]){let s=e.indexOf(n);if(s<=0)continue;let u=h(e.slice(0,s).trim(),e.slice(s+1).trim());if(u?.name)return u}let o=h("",e);if(o)return{...o,name:o.hex};let r=e.split(/\s+/);for(let n=1;n<r.length;n++){let s=h(r.slice(0,n).join(" "),r.slice(n).join(" "));if(s)return s}for(let n=r.length-1;n>=1;n--){let s=h(r.slice(n).join(" "),r.slice(0,n).join(" "));if(s)return s}}function ct(t){let e=t.split(/\s+/)[0];if(x(e))return!0;let o=/^#([0-9a-z]{1,8})$/i.exec(e);if(!o)return!1;let r=o[1];return/^[0-9a-f]+$/i.test(r)||[3,4,6,8].includes(r.length)||/\d/.test(r)}function ut(t){let e=X(t[0]??"").map(a=>a.toLowerCase()),o=e.findIndex(a=>rt.includes(a)),r=e.findIndex(a=>nt.includes(a));if(e.length>1&&o!==-1&&r!==-1)return st(t.slice(1),o,r);let n=t.some(a=>/^\s*--[\w-]+\s*:/.test(a)),s={colours:[],bad:[]},u=!1;for(let a of t){let i=a.replace(/\/\*.*?\*\//g,"");if(u){let f=i.indexOf("*/");if(f===-1)continue;i=i.slice(f+2),u=!1}let c=i.indexOf("/*");if(c!==-1&&(i=i.slice(0,c),u=!0),i=i.trim(),i===""||i.startsWith("//"))continue;if(n){let f=/^--([\w-]+)\s*:\s*(.+?)\s*;?$/.exec(i);if(!f)continue;let l=h(f[1],f[2]);l?s.colours.push(l):S(f[2])&&s.bad.push(`--${f[1]}: ${f[2]}`);continue}if(i.startsWith("#")&&!ct(i))continue;let p=it(i);p?s.colours.push(p):s.bad.push(i)}return s}var j=({r:t,g:e,b:o},r)=>r?`\x1B[38;2;${t};${e};${o}m\u2588\u2588\x1B[39m `:"";function ft(t,e){let o=W(e),r,n=Number.POSITIVE_INFINITY;for(let s of t){let u=(s.centre.L-o.L)**2+(s.centre.a-o.a)**2+(s.centre.b-o.b)**2;u<n&&(n=u,r=s)}return r}async function pt(t){let{pixels:e}=await K(t.input),o=Y(e);if(o.length===0)throw A(t.input);let r=t.inside?ft(o,t.inside):void 0,n=r?q(e,r):o,s=G(w,{source:tt(t.input),...r?{inside:r.hex}:{},colours:n.map(a=>({hex:a.hex,rgb:D(a.rgb),oklch:O(a.rgb),share:a.share}))});return{groups:n,...r?{parent:r}:{},doc:s,svg:()=>_(k(t.input),n,"light",r?.hex)}}async function It(t,e){let{groups:o,doc:r,svg:n}=await pt(t);if(t.svg)return{exitCode:0,stdout:[n()],stderr:[]};if(e.json)return{exitCode:0,stdout:[JSON.stringify(r)],stderr:[]};let s=z(o.map(u=>u.share));return{exitCode:0,stdout:o.map((u,a)=>`${j(u.rgb,e.colour)}${u.hex} ${String(s[a]).padStart(3)}%`),stderr:[]}}async function Lt(t,e){let o=B(t.colour);if(t.svg)return{exitCode:0,stdout:[M(t.colour,o)],stderr:[]};let r=o.map(n=>({...n,...U(n.rgb)}));if(e.json){let n=H(w,{reference:$(t.colour),steps:r.map(s=>({step:s.step,hex:s.hex,oklch:O(s.rgb),white:s.white,black:s.black}))});return{exitCode:0,stdout:[JSON.stringify(n)],stderr:[]}}return{exitCode:0,stdout:r.map(n=>`${String(n.step).padStart(4)} ${j(n.rgb,e.colour)}${n.hex} white ${n.white.toFixed(1)} ${v(n.white)} \xB7 black ${n.black.toFixed(1)} ${v(n.black)}`),stderr:[]}}async function dt(){let t=[];for await(let e of process.stdin)t.push(Buffer.from(e));return Buffer.concat(t).toString("utf8")}async function mt(t){try{return await at(t,"utf8")}catch(e){let o=e.code;throw o==="ENOENT"||o==="ENOTDIR"?N(t):o==="EISDIR"?P(t):o==="EACCES"||o==="EPERM"?I(t):L(t,e)}}var Z=t=>t.alpha===void 0?t.hex:`${t.hex} ${Math.round(t.alpha*100)}%`;async function At(t,e,o=dt){let r=t.input==="-",n=r?await o():await mt(t.input),s=r?"the text from stdin":k(t.input),{colours:u,bad:a}=Q(n);if(a.length>0)throw T(s,a);if(u.length===0)throw J(s);if(t.svg){let i=t.title??(r?"Colours":lt(t.input).replace(/\..*$/,"")||"Colours"),c=u.length,p=u.map(l=>({id:l.name,name:l.name,value:Z(l),hex:l.hex,...l.alpha===void 0?{}:{alpha:l.alpha}}));return{exitCode:0,stdout:[V(i,`${c} colour${c===1?"":"s"}`,p,"light",{perRow:8})],stderr:[]}}if(e.json){let i=F(w,{source:r?"-":tt(t.input),colours:u});return{exitCode:0,stdout:[JSON.stringify(i)],stderr:[]}}return{exitCode:0,stdout:u.map(i=>{let c=x(i.hex)?.rgb??{r:0,g:0,b:0};return`${j(c,e.colour)}${Z(i)} ${i.name}`}),stderr:[]}}export{pt as readPalette,At as runCard,It as runPalette,Lt as runScale};
|
|
@@ -1,3 +0,0 @@
|
|
|
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-X2YUHPOU.js";import"./chunk-EJWTYDBJ.js";import"./chunk-UI4EUC3S.js";import"./chunk-2L66A2X6.js";import"./chunk-6RMRWBMB.js";import"./chunk-X4QI2EYV.js";import"./chunk-QIMSNTKL.js";import"./chunk-ECA4PW5T.js";import"./chunk-QPUKPSPZ.js";import"./chunk-PISCJKIG.js";import"./chunk-YJ6XLDRA.js";import"./chunk-63XCSYHM.js";import"./chunk-WID72ZII.js";import"./chunk-O7DK3GJT.js";import"./chunk-65Y7YCZZ.js";import"./chunk-NMGQGYVM.js";import"./chunk-EEQSUBBL.js";import"./chunk-BSFBZBAI.js";import"./chunk-BWJNZT75.js";import"./chunk-3IX3QA76.js";import"./chunk-PON65UTS.js";import"./chunk-FWVE3GNA.js";import"./chunk-QO4JUY6B.js";import"./chunk-UN5DSJE2.js";import"./chunk-6HUYBVQA.js";import"./chunk-KXKQDFHX.js";import"./chunk-4MZV4SRU.js";import"./chunk-BYUOU2Q2.js";import"./chunk-NUCGWLOY.js";import"./chunk-I2LPGKUU.js";import"./chunk-HON4OV7M.js";import"./chunk-CCNRNCRU.js";import"./chunk-FGR6QCG5.js";import"./chunk-VLVNA4T3.js";import"./chunk-TMUK2DD3.js";export{d as execute,a as exitCodeFor,c as renderRun,b as runIntent};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{Tb as a,Ub as b,Vb as c,Wb as d,Xb as e}from"./chunk-JD3RB6IV.js";import"./chunk-2L66A2X6.js";import"./chunk-POM7FXIV.js";import"./chunk-5FJT4BNY.js";import"./chunk-I25E2XDH.js";import"./chunk-IBPGC4N2.js";import"./chunk-EYOO35US.js";import"./chunk-WID72ZII.js";import"./chunk-EEQSUBBL.js";import"./chunk-4MZV4SRU.js";import"./chunk-BYUOU2Q2.js";import"./chunk-NUCGWLOY.js";import"./chunk-I2LPGKUU.js";import"./chunk-HON4OV7M.js";import"./chunk-CCNRNCRU.js";import"./chunk-FGR6QCG5.js";import"./chunk-VLVNA4T3.js";import"./chunk-TMUK2DD3.js";export{e as ExtensionsFlow,c as byteCount,b as extensionCredits,d as extensionsChip,a as realManager};
|