forge-terminal 0.2.1 → 0.3.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 -10
- package/dist/chunks/available-QN6QAGCU.js +3 -0
- package/dist/chunks/boot-ISMRSTLL.js +3 -0
- package/dist/chunks/catalog-O3V24DK7.js +3 -0
- package/dist/chunks/check-DN7SEN44.js +3 -0
- package/dist/chunks/chunk-4L6HNYSN.js +4 -0
- package/dist/chunks/{chunk-XFEHJ4C7.js → chunk-6ZEGAH36.js} +1 -1
- package/dist/chunks/chunk-775ILWZI.js +3 -0
- package/dist/chunks/chunk-CKWYIU2N.js +4 -0
- package/dist/chunks/{chunk-G2D6BKOS.js → chunk-CXVYIBCA.js} +2 -2
- package/dist/chunks/chunk-E5QDHFKQ.js +3 -0
- package/dist/chunks/{chunk-VH5RWPGZ.js → chunk-GDQQDHXJ.js} +2 -2
- package/dist/chunks/chunk-HON4OV7M.js +3 -0
- package/dist/chunks/chunk-IBPGC4N2.js +3 -0
- package/dist/chunks/chunk-LI2JPLF7.js +3 -0
- package/dist/chunks/{chunk-5B7WODWH.js → chunk-M6LD6DHO.js} +1 -1
- package/dist/chunks/chunk-NY6BX7QS.js +5 -0
- package/dist/chunks/chunk-OIZCRBLT.js +3 -0
- package/dist/chunks/chunk-Q45MSMTN.js +3 -0
- package/dist/chunks/chunk-RE7E6NA7.js +3 -0
- package/dist/chunks/{chunk-PN73WK2S.js → chunk-VNAIHACR.js} +1 -1
- package/dist/chunks/chunk-W42HVOBD.js +3 -0
- package/dist/chunks/chunk-XSOCV3F2.js +3 -0
- package/dist/chunks/chunk-YILLB45O.js +3 -0
- package/dist/chunks/chunk-YZG5A3GA.js +4 -0
- package/dist/chunks/chunk-ZRP5CWIK.js +3 -0
- package/dist/chunks/{catalog-NTACQH5V.js → clipboard-CPHPA4FH.js} +1 -1
- package/dist/chunks/colour-LZ7EJ6H4.js +3 -0
- package/dist/chunks/config-command-UW6BYQ2K.js +3 -0
- package/dist/chunks/execute-JRS6RQZA.js +3 -0
- package/dist/chunks/extensions-command-5QO6YX6O.js +3 -0
- package/dist/chunks/image-ESDL7GZU.js +3 -0
- package/dist/chunks/install-HCF5BIA6.js +3 -0
- package/dist/chunks/launch-BWYE27OQ.js +65 -0
- package/dist/chunks/lock-RZ6NVZFD.js +3 -0
- package/dist/chunks/manager-7HNOLCYH.js +4 -0
- package/dist/chunks/paths-H2WS22BA.js +3 -0
- package/dist/chunks/preferences-AKDCPHJ5.js +3 -0
- package/dist/chunks/restart-6ONEYN6T.js +3 -0
- package/dist/chunks/run-C475RRUL.js +4 -0
- package/dist/chunks/{server-DU7QWDAH.js → server-A327QWB6.js} +6 -6
- package/dist/chunks/theme-YG3CRJBG.js +3 -0
- package/dist/chunks/update-command-HT2RBFLR.js +3 -0
- package/dist/chunks/update-note-6GBF5AE4.js +3 -0
- package/dist/index.js +33 -29
- package/package.json +7 -4
- package/skills/forge/SKILL.md +3 -0
- package/dist/chunks/available-HEUREG6L.js +0 -3
- package/dist/chunks/boot-BUGERSEB.js +0 -3
- package/dist/chunks/chunk-2WYHI73Y.js +0 -3
- package/dist/chunks/chunk-4YCO7S4K.js +0 -3
- package/dist/chunks/chunk-C2WYXNRM.js +0 -4
- package/dist/chunks/chunk-C7OOWUMU.js +0 -3
- package/dist/chunks/chunk-EOYBXOCV.js +0 -4
- package/dist/chunks/chunk-HUAEVW2A.js +0 -3
- package/dist/chunks/chunk-L76Q54MB.js +0 -3
- package/dist/chunks/chunk-PD5DFBCU.js +0 -3
- package/dist/chunks/chunk-TEGB7JRM.js +0 -3
- package/dist/chunks/chunk-YXDEOLNA.js +0 -3
- package/dist/chunks/colour-DE6N6AZO.js +0 -3
- package/dist/chunks/config-command-SQXRTBRO.js +0 -3
- package/dist/chunks/execute-M3C3TTWB.js +0 -3
- package/dist/chunks/extensions-command-HJDBUBYO.js +0 -3
- package/dist/chunks/image-GYUUMS6H.js +0 -3
- package/dist/chunks/launch-WBUFRVQ7.js +0 -65
- package/dist/chunks/lock-XD4L3WFM.js +0 -3
- package/dist/chunks/manager-KBJTXZ27.js +0 -4
- package/dist/chunks/paths-JUM6GKQU.js +0 -3
- package/dist/chunks/run-RXVQD4DZ.js +0 -4
- package/dist/chunks/theme-DESCJOCE.js +0 -3
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{a as be,b as Se,e as Mt,j as Ae,l as xe,m as Re}from"./chunk-5B7WODWH.js";import{a as kt,b as ut,d as ye,h as It,i as Nt}from"./chunk-L76Q54MB.js";import{c as Ee}from"./chunk-EOYBXOCV.js";import{g as ge}from"./chunk-YXDEOLNA.js";import{A as pe,B as fe,C as de,D as he,H as me,I as it,Y as gt,d as Q,e as ue,f as mt,g as rt,h as Ht,s as ae,v as ce,w as le}from"./chunk-PD5DFBCU.js";import{c as st,e as Wn}from"./chunk-TMUK2DD3.js";var St=st((gu,dn)=>{"use strict";var cn="[^\\\\/]",Ro="(?=.)",ln="[^/]",Jt="(?:\\/|$)",pn="(?:^|\\/)",Xt=`\\.{1,2}${Jt}`,Eo="(?!\\.)",_o=`(?!${pn}${Xt})`,vo=`(?!\\.{0,1}${Jt})`,ko=`(?!${Xt})`,Io="[^.\\/]",wo=`${ln}*?`,Oo="/",fn={DOT_LITERAL:"\\.",PLUS_LITERAL:"\\+",QMARK_LITERAL:"\\?",SLASH_LITERAL:"\\/",ONE_CHAR:Ro,QMARK:ln,END_ANCHOR:Jt,DOTS_SLASH:Xt,NO_DOT:Eo,NO_DOTS:_o,NO_DOT_SLASH:vo,NO_DOTS_SLASH:ko,QMARK_NO_DOT:Io,STAR:wo,START_ANCHOR:pn,SEP:Oo},Co={...fn,SLASH_LITERAL:"[\\\\/]",QMARK:cn,STAR:`${cn}*?`,DOTS_SLASH:"\\.{1,2}(?:[\\\\/]|$)",NO_DOT:"(?!\\.)",NO_DOTS:"(?!(?:^|[\\\\/])\\.{1,2}(?:[\\\\/]|$))",NO_DOT_SLASH:"(?!\\.{0,1}(?:[\\\\/]|$))",NO_DOTS_SLASH:"(?!\\.{1,2}(?:[\\\\/]|$))",QMARK_NO_DOT:"[^.\\\\/]",START_ANCHOR:"(?:^|[\\\\/])",END_ANCHOR:"(?:[\\\\/]|$)",SEP:"\\"},$o={__proto__:null,alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"\\x21-\\x7E",lower:"a-z",print:"\\x20-\\x7E ",punct:"\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",space:" \\t\\r\\n\\v\\f",upper:"A-Z",word:"A-Za-z0-9_",xdigit:"A-Fa-f0-9"};dn.exports={DEFAULT_MAX_EXTGLOB_RECURSION:0,MAX_LENGTH:1024*64,POSIX_REGEX_SOURCE:$o,REGEX_BACKSLASH:/\\(?![*+?^${}(|)[\]])/g,REGEX_NON_SPECIAL_CHARS:/^[^@![\].,$*+?^{}()|\\/]+/,REGEX_SPECIAL_CHARS:/[-*+?.^${}(|)[\]]/,REGEX_SPECIAL_CHARS_BACKREF:/(\\?)((\W)(\3*))/g,REGEX_SPECIAL_CHARS_GLOBAL:/([-*+?.^${}(|)[\]])/g,REGEX_REMOVE_BACKSLASH:/(?:\[.*?[^\\]\]|\\(?=.))/g,REPLACEMENTS:{__proto__:null,"***":"*","**/**":"**","**/**/**":"**"},CHAR_0:48,CHAR_9:57,CHAR_UPPERCASE_A:65,CHAR_LOWERCASE_A:97,CHAR_UPPERCASE_Z:90,CHAR_LOWERCASE_Z:122,CHAR_LEFT_PARENTHESES:40,CHAR_RIGHT_PARENTHESES:41,CHAR_ASTERISK:42,CHAR_AMPERSAND:38,CHAR_AT:64,CHAR_BACKWARD_SLASH:92,CHAR_CARRIAGE_RETURN:13,CHAR_CIRCUMFLEX_ACCENT:94,CHAR_COLON:58,CHAR_COMMA:44,CHAR_DOT:46,CHAR_DOUBLE_QUOTE:34,CHAR_EQUAL:61,CHAR_EXCLAMATION_MARK:33,CHAR_FORM_FEED:12,CHAR_FORWARD_SLASH:47,CHAR_GRAVE_ACCENT:96,CHAR_HASH:35,CHAR_HYPHEN_MINUS:45,CHAR_LEFT_ANGLE_BRACKET:60,CHAR_LEFT_CURLY_BRACE:123,CHAR_LEFT_SQUARE_BRACKET:91,CHAR_LINE_FEED:10,CHAR_NO_BREAK_SPACE:160,CHAR_PERCENT:37,CHAR_PLUS:43,CHAR_QUESTION_MARK:63,CHAR_RIGHT_ANGLE_BRACKET:62,CHAR_RIGHT_CURLY_BRACE:125,CHAR_RIGHT_SQUARE_BRACKET:93,CHAR_SEMICOLON:59,CHAR_SINGLE_QUOTE:39,CHAR_SPACE:32,CHAR_TAB:9,CHAR_UNDERSCORE:95,CHAR_VERTICAL_LINE:124,CHAR_ZERO_WIDTH_NOBREAK_SPACE:65279,extglobChars(t){return{"!":{type:"negate",open:"(?:(?!(?:",close:`))${t.STAR})`},"?":{type:"qmark",open:"(?:",close:")?"},"+":{type:"plus",open:"(?:",close:")+"},"*":{type:"star",open:"(?:",close:")*"},"@":{type:"at",open:"(?:",close:")"}}},globChars(t){return t===!0?Co:fn}}});var At=st(W=>{"use strict";var{REGEX_BACKSLASH:To,REGEX_REMOVE_BACKSLASH:Po,REGEX_SPECIAL_CHARS:Lo,REGEX_SPECIAL_CHARS_GLOBAL:Fo}=St();W.isObject=t=>t!==null&&typeof t=="object"&&!Array.isArray(t);W.hasRegexChars=t=>Lo.test(t);W.isRegexChar=t=>t.length===1&&W.hasRegexChars(t);W.escapeRegex=t=>t.replace(Fo,"\\$1");W.toPosixSlashes=t=>t.replace(To,"/");W.isWindows=()=>{if(typeof navigator<"u"&&navigator.platform){let t=navigator.platform.toLowerCase();return t==="win32"||t==="windows"}return typeof process<"u"&&process.platform?process.platform==="win32":!1};W.removeBackslashes=t=>t.replace(Po,e=>e==="\\"?"":e);W.escapeLast=(t,e,n)=>{let r=t.lastIndexOf(e,n);return r===-1?t:t[r-1]==="\\"?W.escapeLast(t,e,r-1):`${t.slice(0,r)}\\${t.slice(r)}`};W.removePrefix=(t,e={})=>{let n=t;return n.startsWith("./")&&(n=n.slice(2),e.prefix="./"),n};W.wrapOutput=(t,e={},n={})=>{let r=n.contains?"":"^",o=n.contains?"":"$",s=`${r}(?:${t})${o}`;return e.negated===!0&&(s=`(?:^(?!${s}).*$)`),s};W.basename=(t,{windows:e}={})=>{let n=t.split(e?/[\\/]/:"/"),r=n[n.length-1];return r===""?n[n.length-2]:r}});var xn=st((bu,An)=>{"use strict";var hn=At(),{CHAR_ASTERISK:Kt,CHAR_AT:Do,CHAR_BACKWARD_SLASH:xt,CHAR_COMMA:Ho,CHAR_DOT:Qt,CHAR_EXCLAMATION_MARK:Yt,CHAR_FORWARD_SLASH:Sn,CHAR_LEFT_CURLY_BRACE:Zt,CHAR_LEFT_PARENTHESES:Vt,CHAR_LEFT_SQUARE_BRACKET:No,CHAR_PLUS:Mo,CHAR_QUESTION_MARK:mn,CHAR_RIGHT_CURLY_BRACE:Bo,CHAR_RIGHT_PARENTHESES:gn,CHAR_RIGHT_SQUARE_BRACKET:qo}=St(),yn=t=>t===Sn||t===xt,bn=t=>{t.isPrefix!==!0&&(t.depth=t.isGlobstar?1/0:1)},Go=(t,e)=>{let n=e||{},r=t.length-1,o=n.parts===!0||n.scanToEnd===!0,s=[],i=[],u=[],p=t,m=-1,g=0,y=0,f=!1,b=!1,S=!1,x=!1,R=!1,T=!1,A=!1,G=!1,K=!1,F=!1,C=0,w,E,k={value:"",depth:0,isGlob:!1},l=()=>m>=r,j=()=>p.charCodeAt(m+1),N=()=>(w=E,p.charCodeAt(++m));for(;m<r;){E=N();let I;if(E===xt){A=k.backslashes=!0,E=N(),E===Zt&&(T=!0);continue}if(T===!0||E===Zt){for(C++;l()!==!0&&(E=N());){if(E===xt){A=k.backslashes=!0,N();continue}if(E===Zt){C++;continue}if(T!==!0&&E===Qt&&(E=N())===Qt){if(f=k.isBrace=!0,S=k.isGlob=!0,F=!0,o===!0)continue;break}if(T!==!0&&E===Ho){if(f=k.isBrace=!0,S=k.isGlob=!0,F=!0,o===!0)continue;break}if(E===Bo&&(C--,C===0)){T=!1,f=k.isBrace=!0,F=!0;break}}if(o===!0)continue;break}if(E===Sn){if(s.push(m),i.push(k),k={value:"",depth:0,isGlob:!1},F===!0)continue;if(w===Qt&&m===g+1){g+=2;continue}y=m+1;continue}if(n.noext!==!0&&(E===Mo||E===Do||E===Kt||E===mn||E===Yt)===!0&&j()===Vt){if(S=k.isGlob=!0,x=k.isExtglob=!0,F=!0,E===Yt&&m===g&&(K=!0),o===!0){for(;l()!==!0&&(E=N());){if(E===xt){A=k.backslashes=!0,E=N();continue}if(E===gn){S=k.isGlob=!0,F=!0;break}}continue}break}if(E===Kt){if(w===Kt&&(R=k.isGlobstar=!0),S=k.isGlob=!0,F=!0,o===!0)continue;break}if(E===mn){if(S=k.isGlob=!0,F=!0,o===!0)continue;break}if(E===No){for(;l()!==!0&&(I=N());){if(I===xt){A=k.backslashes=!0,N();continue}if(I===qo){b=k.isBracket=!0,S=k.isGlob=!0,F=!0;break}}if(o===!0)continue;break}if(n.nonegate!==!0&&E===Yt&&m===g){G=k.negated=!0,g++;continue}if(n.noparen!==!0&&E===Vt){if(S=k.isGlob=!0,o===!0){for(;l()!==!0&&(E=N());){if(E===Vt){A=k.backslashes=!0,E=N();continue}if(E===gn){F=!0;break}}continue}break}if(S===!0){if(F=!0,o===!0)continue;break}}n.noext===!0&&(x=!1,S=!1);let D=p,c="",a="";g>0&&(c=p.slice(0,g),p=p.slice(g),y-=g),D&&S===!0&&y>0?(D=p.slice(0,y),a=p.slice(y)):S===!0?(D="",a=p):D=p,D&&D!==""&&D!=="/"&&D!==p&&yn(D.charCodeAt(D.length-1))&&(D=D.slice(0,-1)),n.unescape===!0&&(a&&(a=hn.removeBackslashes(a)),D&&A===!0&&(D=hn.removeBackslashes(D)));let U={prefix:c,input:t,start:g,base:D,glob:a,isBrace:f,isBracket:b,isGlob:S,isExtglob:x,isGlobstar:R,negated:G,negatedExtglob:K};if(n.tokens===!0&&(U.maxDepth=0,yn(E)||i.push(k),U.tokens=i),n.parts===!0||n.tokens===!0){let I;for(let L=0;L<s.length;L++){let V=I?I+1:g,J=s[L],tt=t.slice(V,J);n.tokens&&(L===0&&g!==0?(i[L].isPrefix=!0,i[L].value=c):i[L].value=tt,bn(i[L]),U.maxDepth+=i[L].depth),(L!==0||tt!=="")&&u.push(tt),I=J}if(I&&I+1<t.length){let L=t.slice(I+1);u.push(L),n.tokens&&(i[i.length-1].value=L,bn(i[i.length-1]),U.maxDepth+=i[i.length-1].depth)}U.slashes=s,U.parts=u}return U};An.exports=Go});var vn=st((Su,_n)=>{"use strict";var Rt=St(),z=At(),{MAX_LENGTH:Dt,POSIX_REGEX_SOURCE:jo,REGEX_NON_SPECIAL_CHARS:Wo,REGEX_SPECIAL_CHARS_BACKREF:zo,REPLACEMENTS:Rn}=Rt,Uo=(t,e)=>{if(typeof e.expandRange=="function")return e.expandRange(...t,e);t.sort();let n=`[${t.join("-")}]`;try{new RegExp(n)}catch{return t.map(o=>z.escapeRegex(o)).join("..")}return n},dt=(t,e)=>`Missing ${t}: "${e}" - use "\\\\${e}" to match literal characters`,En=t=>{let e=[],n=0,r=0,o=0,s="",i=!1;for(let u of t){if(i===!0){s+=u,i=!1;continue}if(u==="\\"){s+=u,i=!0;continue}if(u==='"'){o=o===1?0:1,s+=u;continue}if(o===0){if(u==="[")n++;else if(u==="]"&&n>0)n--;else if(n===0){if(u==="(")r++;else if(u===")"&&r>0)r--;else if(u==="|"&&r===0){e.push(s),s="";continue}}}s+=u}return e.push(s),e},Jo=t=>{let e=!1;for(let n of t){if(e===!0){e=!1;continue}if(n==="\\"){e=!0;continue}if(/[?*+@!()[\]{}]/.test(n))return!1}return!0},ee=t=>{let e=t.trim(),n=!0;for(;n===!0;)n=!1,/^@\([^\\()[\]{}|]+\)$/.test(e)&&(e=e.slice(2,-1),n=!0);if(Jo(e))return e.replace(/\\(.)/g,"$1")},Xo=t=>{let e=t.map(ee).filter(Boolean);for(let n=0;n<e.length;n++)for(let r=n+1;r<e.length;r++){let o=e[n],s=e[r],i=o[0];if(!(!i||o!==i.repeat(o.length)||s!==i.repeat(s.length))&&(o===s||o.startsWith(s)||s.startsWith(o)))return!0}return!1},te=(t,e=!0)=>{if(t[0]!=="+"&&t[0]!=="*"||t[1]!=="(")return;let n=0,r=0,o=0,s=!1;for(let i=1;i<t.length;i++){let u=t[i];if(s===!0){s=!1;continue}if(u==="\\"){s=!0;continue}if(u==='"'){o=o===1?0:1;continue}if(o!==1){if(u==="["){n++;continue}if(u==="]"&&n>0){n--;continue}if(!(n>0)){if(u==="("){r++;continue}if(u===")"&&(r--,r===0))return e===!0&&i!==t.length-1?void 0:{type:t[0],body:t.slice(2,i),end:i}}}}},Ko=t=>`${t.length===1?z.escapeRegex(t[0]):`[${t.map(n=>z.escapeRegex(n)).join("")}]`}*`,Qo=t=>{let e=0,n=[];for(;e<t.length;){let r=te(t.slice(e),!1);if(!r||r.type!=="*")return;let o=En(r.body).map(i=>i.trim());if(o.length!==1)return;let s=ee(o[0]);if(!s||s.length!==1)return;n.push(s),e+=r.end+1}if(!(n.length<1))return n},Yo=t=>{let e=0,n=t.trim(),r=te(n);for(;r;)e++,n=r.body.trim(),r=te(n);return e},Zo=(t,e)=>{if(e.maxExtglobRecursion===!1)return{risky:!1};let n=typeof e.maxExtglobRecursion=="number"?e.maxExtglobRecursion:Rt.DEFAULT_MAX_EXTGLOB_RECURSION,r=En(t).map(u=>u.trim());if(r.length>1&&(r.some(u=>u==="")||r.some(u=>/^[*?]+$/.test(u))||Xo(r)))return{risky:!0};let o=[],s=!1,i=!0;for(let u of r){let p=Qo(u);if(p){s=!0,o.push(...p);continue}let m=ee(u);if(m&&m.length===1){o.push(m);continue}if(i=!1,Yo(u)>n)return{risky:!0}}return s?i?{risky:!0,safeOutput:Ko([...new Set(o)])}:{risky:!0}:{risky:!1}},ne=(t,e)=>{if(typeof t!="string")throw new TypeError("Expected a string");t=Rn[t]||t;let n={...e},r=typeof n.maxLength=="number"?Math.min(Dt,n.maxLength):Dt,o=t.length;if(o>r)throw new SyntaxError(`Input length: ${o}, exceeds maximum allowed length: ${r}`);let s={type:"bos",value:"",output:n.prepend||""},i=[s],u=n.capture?"":"?:",p=Rt.globChars(n.windows),m=Rt.extglobChars(p),{DOT_LITERAL:g,PLUS_LITERAL:y,SLASH_LITERAL:f,ONE_CHAR:b,DOTS_SLASH:S,NO_DOT:x,NO_DOT_SLASH:R,NO_DOTS_SLASH:T,QMARK:A,QMARK_NO_DOT:G,STAR:K,START_ANCHOR:F}=p,C=h=>`(${u}(?:(?!${F}${h.dot?S:g}).)*?)`,w=n.dot?"":x,E=n.dot?A:G,k=n.bash===!0?C(n):K;n.capture&&(k=`(${k})`),typeof n.noext=="boolean"&&(n.noextglob=n.noext);let l={input:t,index:-1,start:0,dot:n.dot===!0,consumed:"",output:"",prefix:"",backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:i};t=z.removePrefix(t,l),o=t.length;let j=[],N=[],D=[],c=s,a,U=()=>l.index===o-1,I=l.peek=(h=1)=>t[l.index+h],L=l.advance=()=>t[++l.index]||"",V=()=>t.slice(l.index+1),J=(h="",P=0)=>{l.consumed+=h,l.index+=P},tt=h=>{l.output+=h.output!=null?h.output:h.value,J(h.value)},Gn=()=>{let h=1;for(;I()==="!"&&(I(2)!=="("||I(3)==="?");)L(),l.start++,h++;return h%2===0?!1:(l.negated=!0,l.start++,!0)},_t=h=>{l[h]++,D.push(h)},et=h=>{l[h]--,D.pop()},_=h=>{if(c.type==="globstar"){let P=l.braces>0&&(h.type==="comma"||h.type==="brace"),d=h.extglob===!0||j.length&&(h.type==="pipe"||h.type==="paren");h.type!=="slash"&&h.type!=="paren"&&!P&&!d&&(l.output=l.output.slice(0,-c.output.length),c.type="star",c.value="*",c.output=k,l.output+=c.output)}if(j.length&&h.type!=="paren"&&(j[j.length-1].inner+=h.value),(h.value||h.output)&&tt(h),c&&c.type==="text"&&h.type==="text"){c.output=(c.output||c.value)+h.value,c.value+=h.value;return}h.prev=c,i.push(h),c=h},vt=(h,P)=>{let d={...m[P],conditions:1,inner:""};d.prev=c,d.parens=l.parens,d.output=l.output,d.startIndex=l.index,d.tokensIndex=i.length;let v=(n.capture?"(":"")+d.open;_t("parens"),_({type:h,value:P,output:l.output?"":b}),_({type:"paren",extglob:!0,value:L(),output:v}),j.push(d)},jn=h=>{let P=t.slice(h.startIndex,l.index+1),d=t.slice(h.startIndex+2,l.index),v=Zo(d,n);if((h.type==="plus"||h.type==="star")&&v.risky){let O=v.safeOutput?(h.output?"":b)+(n.capture?`(${v.safeOutput})`:v.safeOutput):void 0,Y=i[h.tokensIndex];Y.type="text",Y.value=P,Y.output=O||z.escapeRegex(P);for(let Z=h.tokensIndex+1;Z<i.length;Z++)i[Z].value="",i[Z].output="",delete i[Z].suffix;l.output=h.output+Y.output,l.backtrack=!0,_({type:"paren",extglob:!0,value:a,output:""}),et("parens");return}let $=h.close+(n.capture?")":""),M;if(h.type==="negate"){let O=k;if(h.inner&&h.inner.length>1&&h.inner.includes("/")&&(O=C(n)),(O!==k||U()||/^\)+$/.test(V()))&&($=h.close=`)$))${O}`),h.inner.includes("*")&&(M=V())&&/^\.[^\\/.]+$/.test(M)){let Y=ne(M,{...e,fastpaths:!1}).output;$=h.close=`)${Y})${O})`}h.prev.type==="bos"&&(l.negatedExtglob=!0)}_({type:"paren",extglob:!0,value:a,output:$}),et("parens")};if(n.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(t)){let h=!1,P=t.replace(zo,(d,v,$,M,O,Y)=>M==="\\"?(h=!0,d):M==="?"?v?v+M+(O?A.repeat(O.length):""):Y===0?E+(O?A.repeat(O.length):""):A.repeat($.length):M==="."?g.repeat($.length):M==="*"?v?v+M+(O?k:""):k:v?d:`\\${d}`);return h===!0&&(n.unescape===!0?P=P.replace(/\\/g,""):P=P.replace(/\\+/g,d=>d.length%2===0?"\\\\":d?"\\":"")),P===t&&n.contains===!0?(l.output=t,l):(l.output=z.wrapOutput(P,l,e),l)}for(;!U();){if(a=L(),a==="\0")continue;if(a==="\\"){let d=I();if(d==="/"&&n.bash!==!0||d==="."||d===";")continue;if(!d){a+="\\",_({type:"text",value:a});continue}let v=/^\\+/.exec(V()),$=0;if(v&&v[0].length>2&&($=v[0].length,l.index+=$,$%2!==0&&(a+="\\")),n.unescape===!0?a=L():a+=L(),l.brackets===0){_({type:"text",value:a});continue}}if(l.brackets>0&&(a!=="]"||c.value==="["||c.value==="[^")){if(n.posix!==!1&&a===":"){let d=c.value.slice(1);if(d.includes("[")&&(c.posix=!0,d.includes(":"))){let v=c.value.lastIndexOf("["),$=c.value.slice(0,v),M=c.value.slice(v+2),O=jo[M];if(O){c.value=$+O,l.backtrack=!0,L(),!s.output&&i.indexOf(c)===1&&(s.output=b);continue}}}(a==="["&&I()!==":"||a==="-"&&I()==="]")&&(a=`\\${a}`),a==="]"&&(c.value==="["||c.value==="[^")&&(a=`\\${a}`),n.posix===!0&&a==="!"&&c.value==="["&&(a="^"),c.value+=a,tt({value:a});continue}if(l.quotes===1&&a!=='"'){a=z.escapeRegex(a),c.value+=a,tt({value:a});continue}if(a==='"'){l.quotes=l.quotes===1?0:1,n.keepQuotes===!0&&_({type:"text",value:a});continue}if(a==="("){_t("parens"),_({type:"paren",value:a});continue}if(a===")"){if(l.parens===0&&n.strictBrackets===!0)throw new SyntaxError(dt("opening","("));let d=j[j.length-1];if(d&&l.parens===d.parens+1){jn(j.pop());continue}_({type:"paren",value:a,output:l.parens?")":"\\)"}),et("parens");continue}if(a==="["){if(n.nobracket===!0||!V().includes("]")){if(n.nobracket!==!0&&n.strictBrackets===!0)throw new SyntaxError(dt("closing","]"));a=`\\${a}`}else _t("brackets");_({type:"bracket",value:a});continue}if(a==="]"){if(n.nobracket===!0||c&&c.type==="bracket"&&c.value.length===1){_({type:"text",value:a,output:`\\${a}`});continue}if(l.brackets===0){if(n.strictBrackets===!0)throw new SyntaxError(dt("opening","["));_({type:"text",value:a,output:`\\${a}`});continue}et("brackets");let d=c.value.slice(1);if(c.posix!==!0&&d[0]==="^"&&!d.includes("/")&&(a=`/${a}`),c.value+=a,tt({value:a}),n.literalBrackets===!1||z.hasRegexChars(d))continue;let v=z.escapeRegex(c.value);if(l.output=l.output.slice(0,-c.value.length),n.literalBrackets===!0){l.output+=v,c.value=v;continue}c.value=`(${u}${v}|${c.value})`,l.output+=c.value;continue}if(a==="{"&&n.nobrace!==!0){_t("braces");let d={type:"brace",value:a,output:"(",outputIndex:l.output.length,tokensIndex:l.tokens.length};N.push(d),_(d);continue}if(a==="}"){let d=N[N.length-1];if(n.nobrace===!0||!d){_({type:"text",value:a,output:a});continue}let v=")";if(d.dots===!0){let $=i.slice(),M=[];for(let O=$.length-1;O>=0&&(i.pop(),$[O].type!=="brace");O--)$[O].type!=="dots"&&M.unshift($[O].value);v=Uo(M,n),l.backtrack=!0}if(d.comma!==!0&&d.dots!==!0){let $=l.output.slice(0,d.outputIndex),M=l.tokens.slice(d.tokensIndex);d.value=d.output="\\{",a=v="\\}",l.output=$;for(let O of M)l.output+=O.output||O.value}_({type:"brace",value:a,output:v}),et("braces"),N.pop();continue}if(a==="|"){j.length>0&&j[j.length-1].conditions++,_({type:"text",value:a});continue}if(a===","){let d=a,v=N[N.length-1];v&&D[D.length-1]==="braces"&&(v.comma=!0,d="|"),_({type:"comma",value:a,output:d});continue}if(a==="/"){if(c.type==="dot"&&l.index===l.start+1){l.start=l.index+1,l.consumed="",l.output="",i.pop(),c=s;continue}_({type:"slash",value:a,output:f});continue}if(a==="."){if(l.braces>0&&c.type==="dot"){c.value==="."&&(c.output=g);let d=N[N.length-1];c.type="dots",c.output+=a,c.value+=a,d.dots=!0;continue}if(l.braces+l.parens===0&&c.type!=="bos"&&c.type!=="slash"){_({type:"text",value:a,output:g});continue}_({type:"dot",value:a,output:g});continue}if(a==="?"){if(!(c&&c.value==="(")&&n.noextglob!==!0&&I()==="("&&I(2)!=="?"){vt("qmark",a);continue}if(c&&c.type==="paren"){let v=I(),$=a;(c.value==="("&&!/[!=<:]/.test(v)||v==="<"&&!/<([!=]|\w+>)/.test(V()))&&($=`\\${a}`),_({type:"text",value:a,output:$});continue}if(n.dot!==!0&&(c.type==="slash"||c.type==="bos")){_({type:"qmark",value:a,output:G});continue}_({type:"qmark",value:a,output:A});continue}if(a==="!"){if(n.noextglob!==!0&&I()==="("&&(I(2)!=="?"||!/[!=<:]/.test(I(3)))){vt("negate",a);continue}if(n.nonegate!==!0&&l.index===0){Gn();continue}}if(a==="+"){if(n.noextglob!==!0&&I()==="("&&I(2)!=="?"){vt("plus",a);continue}if(c&&c.value==="("||n.regex===!1){_({type:"plus",value:a,output:y});continue}if(c&&(c.type==="bracket"||c.type==="paren"||c.type==="brace")||l.parens>0){_({type:"plus",value:a});continue}_({type:"plus",value:y});continue}if(a==="@"){if(n.noextglob!==!0&&I()==="("&&I(2)!=="?"){_({type:"at",extglob:!0,value:a,output:""});continue}_({type:"text",value:a});continue}if(a!=="*"){(a==="$"||a==="^")&&(a=`\\${a}`);let d=Wo.exec(V());d&&(a+=d[0],l.index+=d[0].length),_({type:"text",value:a});continue}if(c&&(c.type==="globstar"||c.star===!0)){c.type="star",c.star=!0,c.value+=a,c.output=k,l.backtrack=!0,l.globstar=!0,J(a);continue}let h=V();if(n.noextglob!==!0&&/^\([^?]/.test(h)){vt("star",a);continue}if(c.type==="star"){if(n.noglobstar===!0){J(a);continue}let d=c.prev,v=d.prev,$=d.type==="slash"||d.type==="bos",M=v&&(v.type==="star"||v.type==="globstar");if(n.bash===!0&&(!$||h[0]&&h[0]!=="/")){_({type:"star",value:a,output:""});continue}let O=l.braces>0&&(d.type==="comma"||d.type==="brace"),Y=j.length&&(d.type==="pipe"||d.type==="paren");if(!$&&d.type!=="paren"&&!O&&!Y){_({type:"star",value:a,output:""});continue}for(;h.slice(0,3)==="/**";){let Z=t[l.index+4];if(Z&&Z!=="/")break;h=h.slice(3),J("/**",3)}if(d.type==="bos"&&U()){c.type="globstar",c.value+=a,c.output=C(n),l.output=c.output,l.globstar=!0,J(a);continue}if(d.type==="slash"&&d.prev.type!=="bos"&&!M&&U()){l.output=l.output.slice(0,-(d.output+c.output).length),d.output=`(?:${d.output}`,c.type="globstar",c.output=C(n)+(n.strictSlashes?")":"|$)"),c.value+=a,l.globstar=!0,l.output+=d.output+c.output,J(a);continue}if(d.type==="slash"&&d.prev.type!=="bos"&&h[0]==="/"){let Z=h[1]!==void 0?"|$":"";l.output=l.output.slice(0,-(d.output+c.output).length),d.output=`(?:${d.output}`,c.type="globstar",c.output=`${C(n)}${f}|${f}${Z})`,c.value+=a,l.output+=d.output+c.output,l.globstar=!0,J(a+L()),_({type:"slash",value:"/",output:""});continue}if(d.type==="bos"&&h[0]==="/"){c.type="globstar",c.value+=a,c.output=`(?:^|${f}|${C(n)}${f})`,l.output=c.output,l.globstar=!0,J(a+L()),_({type:"slash",value:"/",output:""});continue}l.output=l.output.slice(0,-c.output.length),c.type="globstar",c.output=C(n),c.value+=a,l.output+=c.output,l.globstar=!0,J(a);continue}let P={type:"star",value:a,output:k};if(n.bash===!0){P.output=".*?",(c.type==="bos"||c.type==="slash")&&(P.output=w+P.output),_(P);continue}if(c&&(c.type==="bracket"||c.type==="paren")&&n.regex===!0){P.output=a,_(P);continue}(l.index===l.start||c.type==="slash"||c.type==="dot")&&(c.type==="dot"?(l.output+=R,c.output+=R):n.dot===!0?(l.output+=T,c.output+=T):(l.output+=w,c.output+=w),I()!=="*"&&(l.output+=b,c.output+=b)),_(P)}for(;l.brackets>0;){if(n.strictBrackets===!0)throw new SyntaxError(dt("closing","]"));l.output=z.escapeLast(l.output,"["),et("brackets")}for(;l.parens>0;){if(n.strictBrackets===!0)throw new SyntaxError(dt("closing",")"));l.output=z.escapeLast(l.output,"("),et("parens")}for(;l.braces>0;){if(n.strictBrackets===!0)throw new SyntaxError(dt("closing","}"));l.output=z.escapeLast(l.output,"{"),et("braces")}if(n.strictSlashes!==!0&&(c.type==="star"||c.type==="bracket")&&_({type:"maybe_slash",value:"",output:`${f}?`}),l.backtrack===!0){l.output="";for(let h of l.tokens)l.output+=h.output!=null?h.output:h.value,h.suffix&&(l.output+=h.suffix)}return l};ne.fastpaths=(t,e)=>{let n={...e},r=typeof n.maxLength=="number"?Math.min(Dt,n.maxLength):Dt,o=t.length;if(o>r)throw new SyntaxError(`Input length: ${o}, exceeds maximum allowed length: ${r}`);t=Rn[t]||t;let{DOT_LITERAL:s,SLASH_LITERAL:i,ONE_CHAR:u,DOTS_SLASH:p,NO_DOT:m,NO_DOTS:g,NO_DOTS_SLASH:y,STAR:f,START_ANCHOR:b}=Rt.globChars(n.windows),S=n.dot?g:m,x=n.dot?y:m,R=n.capture?"":"?:",T={negated:!1,prefix:""},A=n.bash===!0?".*?":f;n.capture&&(A=`(${A})`);let G=w=>w.noglobstar===!0?A:`(${R}(?:(?!${b}${w.dot?p:s}).)*?)`,K=w=>{switch(w){case"*":return`${S}${u}${A}`;case".*":return`${s}${u}${A}`;case"*.*":return`${S}${A}${s}${u}${A}`;case"*/*":return`${S}${A}${i}${u}${x}${A}`;case"**":return S+G(n);case"**/*":return`(?:${S}${G(n)}${i})?${x}${u}${A}`;case"**/*.*":return`(?:${S}${G(n)}${i})?${x}${A}${s}${u}${A}`;case"**/.*":return`(?:${S}${G(n)}${i})?${s}${u}${A}`;default:{let E=/^(.*?)\.(\w+)$/.exec(w);if(!E)return;let k=K(E[1]);return k?k+s+E[2]:void 0}}},F=z.removePrefix(t,T),C=K(F);return C&&n.strictSlashes!==!0&&(C+=`${i}?`),C};_n.exports=ne});var wn=st((Au,In)=>{"use strict";var Vo=xn(),re=vn(),kn=At(),ts=St(),es=t=>t&&typeof t=="object"&&!Array.isArray(t),H=(t,e,n=!1)=>{if(Array.isArray(t)){let g=t.map(f=>H(f,e,n));return f=>{for(let b of g){let S=b(f);if(S)return S}return!1}}let r=es(t)&&t.tokens&&t.input;if(t===""||typeof t!="string"&&!r)throw new TypeError("Expected pattern to be a non-empty string");let o=e||{},s=o.windows,i=r?H.compileRe(t,e):H.makeRe(t,e,!1,!0),u=i.state;delete i.state;let p=()=>!1;if(o.ignore){let g={...e,ignore:null,onMatch:null,onResult:null};p=H(o.ignore,g,n)}let m=(g,y=!1)=>{let{isMatch:f,match:b,output:S}=H.test(g,i,e,{glob:t,posix:s}),x={glob:t,state:u,regex:i,posix:s,input:g,output:S,match:b,isMatch:f};return typeof o.onResult=="function"&&o.onResult(x),f===!1?(x.isMatch=!1,y?x:!1):p(g)?(typeof o.onIgnore=="function"&&o.onIgnore(x),x.isMatch=!1,y?x:!1):(typeof o.onMatch=="function"&&o.onMatch(x),y?x:!0)};return n&&(m.state=u),m};H.test=(t,e,n,{glob:r,posix:o}={})=>{if(typeof t!="string")throw new TypeError("Expected input to be a string");if(t==="")return{isMatch:!1,output:""};let s=n||{},i=s.format||(o?kn.toPosixSlashes:null),u=t===r,p=u&&i?i(t):t;return u===!1&&(p=i?i(t):t,u=p===r),(u===!1||s.capture===!0)&&(s.matchBase===!0||s.basename===!0?u=H.matchBase(t,e,n,o):u=e.exec(p)),{isMatch:!!u,match:u,output:p}};H.matchBase=(t,e,n,r=n&&n.windows)=>(e instanceof RegExp?e:H.makeRe(e,n)).test(kn.basename(t,{windows:r}));H.isMatch=(t,e,n)=>H(e,n)(t);H.parse=(t,e)=>Array.isArray(t)?t.map(n=>H.parse(n,e)):re(t,{...e,fastpaths:!1});H.scan=(t,e)=>Vo(t,e);H.compileRe=(t,e,n=!1,r=!1)=>{if(n===!0)return t.output;let o=e||{},s=o.contains?"":"^",i=o.contains?"":"$",u=`${s}(?:${t.output})${i}`;t&&t.negated===!0&&(u=`^(?!${u}).*$`);let p=H.toRegex(u,e);return r===!0&&(p.state=t),p};H.makeRe=(t,e={},n=!1,r=!1)=>{if(!t||typeof t!="string")throw new TypeError("Expected a non-empty string");let o={negated:!1,fastpaths:!0};return e.fastpaths!==!1&&(t[0]==="."||t[0]==="*")&&(o.output=re.fastpaths(t,e)),o.output||(o=re(t,e)),H.compileRe(o,e,n,r)};H.toRegex=(t,e)=>{try{let n=e||{};return new RegExp(t,n.flags||(n.nocase?"i":""))}catch(n){if(e&&e.debug===!0)throw n;return/$^/}};H.constants=ts;In.exports=H});var Tn=st((xu,$n)=>{"use strict";var On=wn(),ns=At();function Cn(t,e,n=!1){return e&&(e.windows===null||e.windows===void 0)&&(e={...e,windows:ns.isWindows()}),On(t,e,n)}Object.assign(Cn,On);$n.exports=Cn});import{dirname as Jn}from"node:path";import{homedir as wt}from"node:os";import{dirname as zn,join as at}from"node:path";function Un(t,e){return t===e?"Same folder":t===at(wt(),"Desktop")?"Desktop":t===at(wt(),"Downloads")?"Downloads":t===at(e,"converted")?"New subfolder":t.split("/").pop()||t}function Ot(t,e,{subfolder:n=!1}={}){let r=zn(t.path),o=Ee(e.defaultOutput),s=[{label:Un(o,r),path:o},{label:"Desktop",path:at(wt(),"Desktop")},{label:"Same folder",path:r},{label:"Downloads",path:at(wt(),"Downloads")},...n?[{label:"New subfolder",path:at(r,"converted")}]:[]],i=new Set,u=s.filter(p=>i.has(p.path)?!1:(i.add(p.path),!0));return{kind:"path",id:"destination",label:"Save to",default:o,presets:u}}var q=t=>typeof t=="string"&&t!==""?t:void 0;var Xn=t=>t.length===1&&t[0]?.kind==="image"?t[0]:void 0,Kn=t=>t.length===1&&t[0]?.kind==="document"?t[0]:void 0,Qn="-small",_e={id:"compress",label:"Compress",verb:"Compressing",hint:"make it smaller",appliesTo:t=>{let e=Xn(t);return e!==void 0?Q[e.format].lossy:(Kn(t)?.images?.compressible??0)>0},options(t,e,n){let r=t[0];if(!r)return[];let o=[{kind:"select",id:"mode",label:`Compress ${r.path.split("/").pop()??"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")o.push({kind:"slider",id:"quality",label:"Quality",min:1,max:100,step:5,default:n.quality});else if(e.mode==="size")o.push({kind:"text",id:"size",label:"Target size",placeholder:"e.g. 500kb or 2mb"});else return o;return o.push(Ot(r,n)),o},plan(t,e){let n=e.mode;if(n!=="quality"&&n!=="size")throw it(`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 r=t[0];if(!r)return[];let o=(r.path.split("/").pop()??"file").replace(/\.[^.]+$/,""),i=`${typeof e.destination=="string"?e.destination:Jn(r.path)}/${o}${Qn}${mt(r.format)}`;return[{op:"convert",sources:[r],target:r.format,outputs:[i],options:{background:"#ffffff",keepMetadata:!1,...n==="quality"&&typeof e.quality=="number"?{quality:e.quality}:{}}}]}};import{existsSync as Bt,statSync as Yn}from"node:fs";import{basename as ct,dirname as Zn,extname as lt,isAbsolute as Vn,join as X,relative as tr,resolve as B,sep as er}from"node:path";function ve(t){return t.endsWith("/")||t.endsWith(er)||Bt(t)&&Yn(t).isDirectory()?!0:lt(t)===""}function nr(t,e){let n=ct(t),r=lt(n);return(r?n.slice(0,-r.length):n)+mt(e)}function ke(t,e,n){if(!n)return t;let r=tr(B(n),e);return!r||r.startsWith("..")?t:X(t,r)}function qt(t){let e=B(t.sourcePath),n=nr(e,t.target);if(!t.output)return X(B(e,".."),n);let r=Vn(t.output)?t.output:B(t.output);return ve(t.output)?X(ke(r,B(e,".."),t.sourceRoot),n):B(r)}function yt(t){let e=qt(t);if(t.output&&!ve(t.output))return e;let n=lt(e);return X(B(e,".."),`${ct(e,n)}-${t.suffix}${n}`)}function Ks(t){if(!Bt(t))return t;let e=B(t,".."),n=ct(t),r=lt(n),o=r?n.slice(0,-r.length):n;for(let s=1;s<1e4;s++){let i=X(e,`${o} (${s})${r}`);if(!Bt(i))return i}throw new Error(`no free name beside ${n}`)}function Ct(t){let e=B(t,".."),n=ct(t),r=lt(n);return{dir:e,stem:r?n.slice(0,-r.length):n,ext:r||".pdf"}}function pt(t,e){let{dir:n,stem:r,ext:o}=Ct(B(t));return X(n,`${r}-${e}${o}`)}function Ie(t,e){let{dir:n,stem:r,ext:o}=Ct(B(t)),s=String(e).length;return Array.from({length:e},(i,u)=>X(n,`${r}-${String(u+1).padStart(s,"0")}${o}`))}function we(t,e,n,r,o){let{stem:s}=Ct(B(t)),i=r?ke(B(r),B(t,".."),o):B(t,".."),u=mt(n),p=String(Math.max(1,...e.map(f=>f+1))).length,m=e.map(f=>X(i,`${s}-${String(f+1).padStart(p,"0")}${u}`)),[g,...y]=m;if(g===void 0)throw new Error("rasterOutputPaths requires at least one selected page");return[g,...y]}function Oe(t,e,n){if(!n)return[pt(t,"extract")];let{dir:r,stem:o,ext:s}=Ct(B(t));return e.map(i=>X(r,`${o}-p${i+1}${s}`))}function Ce(t){let e=B(t[0]??"merged.pdf");if(new Set(t.map(r=>B(r,".."))).size===1){let r=B(e,"..");return X(r,`${ct(r)}-merged.pdf`)}return pt(e,"merged")}function bt(t,e,n){let r=e?t.map(s=>X(e,ct(s))):t,[o]=r;return!n||r.length!==1||o===void 0?r:[X(Zn(o),`${n}${lt(o)}`)]}function nt(t,e,n){return bt([t],e,n)[0]??t}function rr(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 or(){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 sr(t,e){return Array.isArray(e)?ut(e):e==="first"?[0]:typeof e=="string"&&e!=="all"&&e!==""?ut(kt(e,t.pages)):Array.from({length:t.pages},(n,r)=>r)}function ir(t,e){let n=Q[t.format].lossy,r=Q[e].lossy;if(n&&!r)return{hint:"likely bigger",tone:"warn"};if(!n&&r)return{hint:"likely smaller",tone:"ok"}}function ur(t){let e=Se(t).filter(r=>r.id!==t.format),n=e[0];return{kind:"select",id:"target",label:`Convert ${Q[t.format].label} to`,choices:e.map(r=>{let o=ir(t,r.id);return{value:r.id,label:r.label,hint:o?.hint??r.hint,...o===void 0?{}:{tone:o.tone}}}),default:n?n.id:""}}function ar(t){let e=t.target,n=typeof e=="string"?ue(e):void 0;if(!n)throw it(`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 $e={id:"convert",label:"Convert",verb:"Converting",hint:"to another format",appliesTo:t=>t.length>=1,options(t,e,n){let r=t[0];if(!r)return[];let o=[ur(r)],s=e.target;return typeof s!="string"||(r.kind==="document"&&Mt(s)&&o.push(rr(r),or()),Q[s]?.lossy&&o.push({kind:"slider",id:"quality",label:"Quality",min:1,max:100,step:5,default:n.quality}),o.push(Ot(r,n,{subfolder:!0}))),o},plan(t,e){let n=t[0];if(!n)return[];let r=ar(e),o=r.id,s={background:typeof e.background=="string"?e.background:"#ffffff",keepMetadata:e.keepMetadata===!0};r.lossy&&typeof e.quality=="number"&&(s.quality=e.quality);let i=typeof e.destination=="string"?e.destination:void 0;if(n.kind==="document"&&Mt(o)){let p=Number(e.dpi);s.dpi=Number.isFinite(p)&&p>0?p:150;let m=sr(n,e.pages);s.pages=m;let g=typeof e.sourceRoot=="string"?e.sourceRoot:void 0,y=we(n.path,m,o,i,g);return[{op:"convert",sources:[n],outputs:y,target:o,options:s}]}let u=qt({sourcePath:n.path,target:o,...i===void 0?{}:{output:`${i}/`}});return[{op:"convert",sources:[n],outputs:[u],target:o,options:s}]}};var $t=t=>t.length>0&&t.every(e=>e.kind==="image")?t:void 0;function li(t,e){let n=be(t);return n.includes(e)?void 0:le(t,e,n)}function Te(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 Pe=()=>({kind:"select",id:"target",label:"Save as",default:"png",choices:[{value:"png",label:"PNG",hint:Q.png.hint}]}),cr=t=>t===1?"sharp":`${t}x`,lr=t=>t===1||t===3||t===4?t:2,Le={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=>$t(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"}]},Pe()],plan(t,e){let n=$t(t);if(!n)return[];let r=Te(e),o=lr(Number(e.scale??2));return n.map(s=>({op:"boost",sources:[s],outputs:[yt({sourcePath:s.path,target:r.target,suffix:cr(o),...r.output===void 0?{}:{output:r.output},...r.roots?.get(s.path)===void 0?{}:{sourceRoot:r.roots.get(s.path)}})],scale:o,target:r.target,options:{background:r.background,keepMetadata:r.keepMetadata,...r.quality===void 0?{}:{quality:r.quality}}}))}},Fe={id:"remove-background",label:"Remove background",verb:"Removing",hint:"cut out the subject",requires:"remove-background",appliesTo:t=>$t(t)!==void 0,unavailable:()=>"images only",options:()=>[Pe()],plan(t,e){let n=$t(t);if(!n)return[];let r=Te(e);return n.map(o=>({op:"remove-background",sources:[o],outputs:[yt({sourcePath:o.path,target:r.target,suffix:"cutout",...r.output===void 0?{}:{output:r.output},...r.roots?.get(o.path)===void 0?{}:{sourceRoot:r.roots.get(o.path)}})],target:r.target,options:{background:r.background,keepMetadata:r.keepMetadata,...r.quality===void 0?{}:{quality:r.quality}}}))}};function pr(t,e){return e.trim&&e.resize?`trimmed-${Re(e.resize)}`:e.resize?xe(ge(t,e.resize)):"trimmed"}function fr(t,e){return t.map(n=>{let r=e.target??Ae(n),o={background:e.background,keepMetadata:e.keepMetadata,...e.quality===void 0?{}:{quality:e.quality},...e.trim?{trim:!0}:{},...e.resize?{resize:e.resize}:{}},s=e.roots?.get(n.path),i=yt({sourcePath:n.path,target:r,suffix:pr(n,e),...e.output===void 0?{}:{output:e.output},...s===void 0?{}:{sourceRoot:s}});return{op:"convert",sources:[n],outputs:[nt(i,q(e.destination),q(e.name))],target:r,options:o}})}var Gt=t=>t.length>0&&t.every(e=>e.kind==="image")?t:void 0,dr=t=>typeof t=="object"&&t!==null&&("percent"in t||"width"in t||"height"in t);function De(t,e,n,r){return{id:t,label:e,verb:n,hint:r,appliesTo:o=>Gt(o)?.every(s=>t==="resize"||s.frames<=1)===!0,unavailable:o=>Gt(o)?"animated":"images only",options:()=>[],plan(o,s){let i=Gt(o);return i?fr(i,{trim:t==="trim"||s.trim===!0,...dr(s.resize)?{resize:s.resize}:{},...typeof s.target=="string"?{target:s.target}:{},...typeof s.output=="string"?{output:s.output}:{},...s.roots instanceof Map?{roots:s.roots}:{},destination:s.destination,name:s.name,background:typeof s.background=="string"?s.background:"#ffffff",keepMetadata:s.keepMetadata===!0,...typeof s.quality=="number"?{quality:s.quality}:{}}):[]}}}var He=De("trim","Trim edges","Trimming edges","cut empty borders"),Ne=De("resize","Resize","Resizing","smaller or larger");var Tt=t=>t.length===1&&t[0]?.kind==="document"&&t[0].format==="pdf"?t[0]:void 0,Me={id:"split",label:"Split",verb:"Splitting",hint:"into several files",appliesTo:t=>(Tt(t)?.pages??0)>1,unavailable:t=>Tt(t)===void 0?"one PDF at a time":"only one page",options(t){let e=Tt(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 n=Tt(t);if(!n)return[];let r=Array.isArray(e.cuts)?e.cuts:[],o=ye(r,n.pages).length,s=bt(Ie(n.path,o),q(e.destination),q(e.name));return[{op:"split",sources:[n],outputs:s,cuts:r}]}};function Ai(t){return Array.from({length:Math.max(0,t-1)},(e,n)=>n)}function xi(t,e){if(!Number.isInteger(e)||e<1)throw it("Splitting every N pages needs N to be a whole number, at least 1.");let n=[];for(let r=e;r<t;r+=e)n.push(r-1);return n}var ft=t=>t.length===1&&t[0]?.kind==="document"&&t[0].format==="pdf"?t[0]:void 0;function Be(t,e){return Array.isArray(e.pages)?ut(e.pages):typeof e.pages=="string"?ut(kt(e.pages,t.pages)):[]}var qe=t=>({kind:"text",id:"pages",label:"Pages",placeholder:`1-${t.pages}`}),Ge={id:"extract",label:"Extract",verb:"Extracting",hint:"keep only some pages",appliesTo:t=>ft(t)!==void 0,unavailable:()=>"one PDF at a time",options:t=>{let e=ft(t);return e?[qe(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 n=ft(t);if(!n)return[];let r=Be(n,e),o=e.separate==="many";return[{op:"extract",sources:[n],outputs:bt(Oe(n.path,r,o),q(e.destination),q(e.name)),pages:r,separate:o}]}},je={id:"delete",label:"Delete",verb:"Deleting",hint:"drop some pages",appliesTo:t=>ft(t)!==void 0,unavailable:()=>"one PDF at a time",options:t=>{let e=ft(t);return e?[qe(e)]:[]},plan(t,e){let n=ft(t);return n?[{op:"delete",sources:[n],outputs:[nt(pt(n.path,"trimmed"),q(e.destination),q(e.name))],pages:Be(n,e)}]:[]}};var jt=t=>t.filter(e=>e.kind==="document"&&e.format==="pdf"),We={id:"merge",label:"Merge",verb:"Merging",hint:"several files into one",appliesTo:t=>jt(t).length>=2&&jt(t).length===t.length,unavailable:t=>jt(t).length!==t.length?"PDFs only":"needs 2+ files",options:()=>[],plan(t,e){let n=nt(Ce(t.map(r=>r.path)),q(e.destination),q(e.name));return[{op:"merge",sources:t,outputs:[n]}]}};var ze=t=>t.length===1&&t[0]?.kind==="document"&&t[0].format==="pdf"?t[0]:void 0,Ue={id:"rotate",label:"Rotate",verb:"Rotating",hint:"turn pages",appliesTo:t=>ze(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 n=ze(t);if(!n)return[];let o=Number(e.degrees??90)/90%4||1;return[{op:"rotate",sources:[n],outputs:[nt(pt(n.path,"rotated"),q(e.destination),q(e.name))],turns:o}]}};var Je=[$e,_e,We,Me,Ge,je,Ue,He,Ne],qi=Je.filter(t=>!["convert","compress","trim","resize"].includes(t.id)),hr=[Le,Fe];function Gi(t,e=new Set){return[...Je,...hr.filter(n=>n.requires&&e.has(n.requires))].filter(n=>n.appliesTo(t))}function ji(t,e){return t.appliesTo(e)?void 0:t.unavailable?.(e)}function mr(t=1,e=100){let n=Math.max(1,e-t+1);return 1+Math.max(0,Math.ceil(Math.log2(n)))}async function Xe(t){let e=t.min??1,n=t.max??100,r=mr(e,n),o=0,s=async f=>(o+=1,t.onAttempt?.(o,r),t.encode(f)),i=()=>t.signal?.aborted===!0,u=await s(n);if(i())return{quality:n,bytes:u,missed:!1,cancelled:!0};if(u<=t.targetBytes)return{quality:n,bytes:u,missed:!1};let p=e,m=n,g;for(;p<=m;){let f=Math.floor((p+m)/2),b=await s(f);if(i())return{quality:f,bytes:b,missed:!1,cancelled:!0};b<=t.targetBytes?(g={quality:f,bytes:b,missed:!1},p=f+1):m=f-1}if(g)return g;let y=await t.encode(e);return{quality:e,bytes:y,missed:!0}}import{cpus as gr}from"node:os";function yr(){return Math.max(1,Math.min(gr().length,4))}function Pt(t){let e=t!==void 0&&Number.isFinite(t)?t:void 0;return Math.max(1,e??yr())}async function Wt(t,e,n){let r=0,o=async()=>{for(;r<t.length;){let i=r++;await n(t[i],i)}},s=Math.min(Pt(e),t.length);await Promise.all(Array.from({length:s},o))}async function Ke(t,e){let n=e.onEvent??(()=>{}),r=e.engineFor??It,o=Pt(e.concurrency),s=t.length,i=[],u=[],p=0;await Wt(t,o,async(f,b)=>{n({type:"job:start",job:f,index:b,total:s});let S=r(f);if(!S){p++;let x=f.sources[0].path,R={path:x,error:gt(x,new Error(`no engine runs ${f.op}`))};u[b]=R,n({type:"job:error",job:f,failure:R,completed:p,total:s});return}try{let x=await S.run(f,R=>n({type:"job:phase",job:f,progress:R}),e.signal);i[b]=x,p++,n({type:"job:done",job:f,result:x,completed:p,total:s})}catch(x){p++;let R=f.sources[0].path,T=rt(x)?x:gt(R,x),A={path:R,error:T};u[b]=A,n({type:"job:error",job:f,failure:A,completed:p,total:s})}});let m=i.filter(f=>f!==void 0),g=u.filter(f=>f!==void 0),y={results:m,failures:g,inputBytes:m.reduce((f,b)=>f+b.job.sources[0].bytes,0),outputBytes:m.reduce((f,b)=>f+b.outputBytes,0)};return n({type:"batch:done",summary:y}),y}import{existsSync as br}from"node:fs";import{resolve as Lt}from"node:path";function Sr(t){let e=t.sources[0]?.path??t.outputs[0]??"",n=new Set;for(let r of t.outputs){let o=Lt(r);if(n.has(o))return{output:r,error:de(e,r)};n.add(o)}}function Ar(t,e,n){let r=Sr(t);if(r)return r;let o=new Set(t.sources.map(i=>Lt(i.path))),s=t.sources[0]?.path??t.outputs[0]??"";for(let i of t.outputs){let u=Lt(i);if(o.has(u)&&!n)return{output:i,error:he(i,t.op)};let p=e.get(u);if(p){let m=p.sources[0]?.path??p.outputs[0]??"";return{output:i,error:fe([m,s],i)}}if(br(u)&&!n)return{output:i,error:pe(i,t.op)}}}function Qe(t,e){let n=[],r=[],o=new Map;for(let s of t){let i=Ar(s,o,e.force);if(i){let u=s.sources[0]?.path??i.output;r.push({path:u,error:i.error});continue}for(let u of s.outputs)o.set(Lt(u),s);n.push(s)}return{jobs:n,failures:r}}async function xr(t,e,n,r,o){let s=t.sources[0].path,i=f=>({kind:"failed",failure:{path:s,error:rt(f)?f:gt(s,f)}}),u;try{u=await n(t)?.measurer?.(t)}catch(f){return i(f)}if(!u||u.ladder.length===0)return{kind:"refused",failure:{path:s,error:ae(t.sources[0],t.target)}};let p=u;if(o?.aborted)return{kind:"cancelled"};let m=Number.POSITIVE_INFINITY,g;try{for(let f of p.ladder){let b=await Xe({encode:S=>p.measure({...t.options,...f,quality:S}),targetBytes:e,onAttempt:(S,x)=>r({type:"search:attempt",job:t,attempt:S,of:x,rung:f}),...o===void 0?{}:{signal:o}});if(b.cancelled)return{kind:"cancelled"};if(b.bytes<m&&(m=b.bytes,g={...f,quality:b.quality}),!b.missed)return t.options={...t.options,...f,quality:b.quality},{kind:"ready"}}}catch(f){return i(f)}return{kind:"unreachable",entry:{job:t,smallest:m,settings:g??{quality:1},error:ce(t.sources[0],e,m)}}}async function su(t,e){let n=e.onEvent??(()=>{}),r=e.engineFor??It,o=e.targetBytes,s=Qe(t,{force:e.force}),i=o===void 0?0:s.jobs.filter(R=>R.op==="convert").length,u=[],p=0;await Wt(s.jobs,Pt(e.concurrency),async(R,T)=>{if(o===void 0||R.op!=="convert"){u[T]={kind:"ready"};return}if(e.signal?.aborted){u[T]={kind:"cancelled"};return}let A=await xr(R,o,r,n,e.signal);u[T]=A,A.kind!=="cancelled"&&(p+=1,n({type:"search:settled",job:R,completed:p,total:i}))});let m=[...s.failures],g=[],y=[],f=[],b=!1;for(let[R,T]of s.jobs.entries()){let A=u[R]??{kind:"ready"};A.kind==="ready"?f.push(T):A.kind==="refused"?m.push(A.failure):A.kind==="failed"?y.push(A.failure):A.kind==="unreachable"?g.push(A.entry):b=!0}if(b)return{results:[],refusals:m,unreachable:[],failures:[],inputBytes:0,outputBytes:0,cancelled:!0};let S=new Set,x=await Ke(f,{...e.concurrency===void 0?{}:{concurrency:e.concurrency},...e.engineFor===void 0?{}:{engineFor:e.engineFor},...e.signal===void 0?{}:{signal:e.signal},onEvent:R=>{R.type==="job:error"&&!e.signal?.aborted&&S.add(R.failure),n(R)}});if(e.signal?.aborted&&x.failures.length>0){let R=x.failures.filter(T=>S.has(T));return{...x,refusals:m,unreachable:g,failures:[...y,...R],cancelled:!0}}return{results:x.results,refusals:m,unreachable:g,failures:[...y,...x.failures],inputBytes:x.inputBytes,outputBytes:x.outputBytes}}import{existsSync as Ps}from"node:fs";import{stat as Ls}from"node:fs/promises";import{resolve as ie}from"node:path";import{readdir as rs,readdirSync as os,realpath as ss,realpathSync as is,stat as us,statSync as as}from"fs";import{isAbsolute as cs,posix as ot,resolve as ls}from"path";import{fileURLToPath as ps}from"url";import{createRequire as Rr}from"module";import{basename as Er,dirname as Ut,normalize as _r,relative as vr,resolve as kr,sep as Ve}from"path";import*as Ir from"fs";var Ye=Rr(import.meta.url);function wr(t){let e=_r(t);return e.length>1&&e[e.length-1]===Ve&&(e=e.substring(0,e.length-1)),e}var Or=/[\\/]/g;function tn(t,e){return t.replace(Or,e)}var Cr=/^[a-z]:[\\/]$/i;function $r(t){return t==="/"||Cr.test(t)}function zt(t,e){let{resolvePaths:n,normalizePath:r,pathSeparator:o}=e,s=process.platform==="win32"&&t.includes("/")||t.startsWith(".");if(n&&(t=kr(t)),(r||s)&&(t=wr(t)),t===".")return"";let i=t[t.length-1]!==o;return tn(i?t+o:t,o)}function en(t,e){return e+t}function Tr(t,e){return function(n,r){return r.startsWith(t)?r.slice(t.length)+n:tn(vr(t,r),e.pathSeparator)+e.pathSeparator+n}}function Pr(t){return t}function Lr(t,e,n){return e+t+n}function Fr(t,e){let{relativePaths:n,includeBasePath:r}=e;return n&&t?Tr(t,e):r?en:Pr}function Dr(t){return function(e,n){n.push(e.substring(t.length)||".")}}function Hr(t){return function(e,n,r){let o=e.substring(t.length)||".";r.every(s=>s(o,!0))&&n.push(o)}}var Nr=(t,e)=>{e.push(t||".")},Mr=(t,e,n)=>{let r=t||".";n.every(o=>o(r,!0))&&e.push(r)},Br=()=>{};function qr(t,e){let{includeDirs:n,filters:r,relativePaths:o}=e;return n?o?r&&r.length?Hr(t):Dr(t):r&&r.length?Mr:Nr:Br}var Gr=(t,e,n,r)=>{r.every(o=>o(t,!1))&&n.files++},jr=(t,e,n,r)=>{r.every(o=>o(t,!1))&&e.push(t)},Wr=(t,e,n,r)=>{n.files++},zr=(t,e)=>{e.push(t)},Ur=()=>{};function Jr(t){let{excludeFiles:e,filters:n,onlyCounts:r}=t;return e?Ur:n&&n.length?r?Gr:jr:r?Wr:zr}var Xr=t=>t,Kr=()=>[""].slice(0,0);function Qr(t){return t.group?Kr:Xr}var Yr=(t,e,n)=>{t.push({directory:e,files:n,dir:e})},Zr=()=>{};function Vr(t){return t.group?Yr:Zr}var to=function(t,e,n){let{queue:r,fs:o,options:{suppressErrors:s}}=e;r.enqueue(),o.realpath(t,(i,u)=>{if(i)return r.dequeue(s?null:i,e);o.stat(u,(p,m)=>{if(p)return r.dequeue(s?null:p,e);if(m.isDirectory()&&nn(t,u,e))return r.dequeue(null,e);n(m,u),r.dequeue(null,e)})})},eo=function(t,e,n){let{queue:r,fs:o,options:{suppressErrors:s}}=e;r.enqueue();try{let i=o.realpathSync(t),u=o.statSync(i);if(u.isDirectory()&&nn(t,i,e))return;n(u,i)}catch(i){if(!s)throw i}};function no(t,e){return!t.resolveSymlinks||t.excludeSymlinks?null:e?eo:to}function nn(t,e,n){if(n.options.useRealPaths)return ro(e,n);let r=Ut(t),o=1;for(;r!==n.root&&o<2;){let s=n.symlinks.get(r);!!s&&(s===e||s.startsWith(e)||e.startsWith(s))?o++:r=Ut(r)}return n.symlinks.set(t,e),o>1}function ro(t,e){return e.visited.includes(t+e.options.pathSeparator)}var oo=t=>t.counts,so=t=>t.groups,io=t=>t.paths,uo=t=>t.paths.slice(0,t.options.maxFiles),ao=(t,e,n)=>(Ft(e,n,t.counts,t.options.suppressErrors),null),co=(t,e,n)=>(Ft(e,n,t.paths,t.options.suppressErrors),null),lo=(t,e,n)=>(Ft(e,n,t.paths.slice(0,t.options.maxFiles),t.options.suppressErrors),null),po=(t,e,n)=>(Ft(e,n,t.groups,t.options.suppressErrors),null);function Ft(t,e,n,r){e(t&&!r?t:null,n)}function fo(t,e){let{onlyCounts:n,group:r,maxFiles:o}=t;return n?e?oo:ao:r?e?so:po:o?e?uo:lo:e?io:co}var rn={withFileTypes:!0},ho=(t,e,n,r,o)=>{if(t.queue.enqueue(),r<0)return t.queue.dequeue(null,t);let{fs:s}=t;t.visited.push(e),t.counts.directories++,s.readdir(e||".",rn,(i,u=[])=>{o(u,n,r),t.queue.dequeue(t.options.suppressErrors?null:i,t)})},mo=(t,e,n,r,o)=>{let{fs:s}=t;if(r<0)return;t.visited.push(e),t.counts.directories++;let i=[];try{i=s.readdirSync(e||".",rn)}catch(u){if(!t.options.suppressErrors)throw u}o(i,n,r)};function go(t){return t?mo:ho}var yo=class{count=0;constructor(t){this.onQueueEmpty=t}enqueue(){return this.count++,this.count}dequeue(t,e){this.onQueueEmpty&&(--this.count<=0||t)&&(this.onQueueEmpty(t,e),t&&(e.controller.abort(),this.onQueueEmpty=void 0))}},bo=class{_files=0;_directories=0;set files(t){this._files=t}get files(){return this._files}set directories(t){this._directories=t}get directories(){return this._directories}get dirs(){return this._directories}},So=class{aborted=!1;abort(){this.aborted=!0}},on=class{root;isSynchronous;state;joinPath;pushDirectory;pushFile;getArray;groupFiles;resolveSymlink;walkDirectory;callbackInvoker;constructor(t,e,n){this.isSynchronous=!n,this.callbackInvoker=fo(e,this.isSynchronous),this.root=zt(t,e),this.state={root:$r(this.root)?this.root:this.root.slice(0,-1),paths:[""].slice(0,0),groups:[],counts:new bo,options:e,queue:new yo((r,o)=>this.callbackInvoker(o,r,n)),symlinks:new Map,visited:[""].slice(0,0),controller:new So,fs:e.fs||Ir},this.joinPath=Fr(this.root,e),this.pushDirectory=qr(this.root,e),this.pushFile=Jr(e),this.getArray=Qr(e),this.groupFiles=Vr(e),this.resolveSymlink=no(e,this.isSynchronous),this.walkDirectory=go(this.isSynchronous)}start(){return this.pushDirectory(this.root,this.state.paths,this.state.options.filters),this.walkDirectory(this.state,this.root,this.root,this.state.options.maxDepth,this.walk),this.isSynchronous?this.callbackInvoker(this.state,null):null}walk=(t,e,n)=>{let{paths:r,options:{filters:o,resolveSymlinks:s,excludeSymlinks:i,exclude:u,maxFiles:p,signal:m,useRealPaths:g,pathSeparator:y},controller:f}=this.state;if(f.aborted||m&&m.aborted||p&&r.length>p)return;let b=this.getArray(this.state.paths);for(let S=0;S<t.length;++S){let x=t[S];if(x.isFile()||x.isSymbolicLink()&&!s&&!i){let R=this.joinPath(x.name,e);this.pushFile(R,b,this.state.counts,o)}else if(x.isDirectory()){let R=Lr(x.name,e,this.state.options.pathSeparator);if(u&&u(x.name,R))continue;this.pushDirectory(R,r,o),this.walkDirectory(this.state,R,R,n-1,this.walk)}else if(this.resolveSymlink&&x.isSymbolicLink()){let R=en(x.name,e);this.resolveSymlink(R,this.state,(T,A)=>{if(T.isDirectory()){if(A=zt(A,this.state.options),u&&u(x.name,g?A:R+y))return;this.walkDirectory(this.state,A,g?A:R+y,n-1,this.walk)}else{A=g?A:R;let G=Er(A),K=zt(Ut(A),this.state.options);A=this.joinPath(G,K),this.pushFile(A,b,this.state.counts,o)}})}}this.groupFiles(this.state.groups,e,b)}};function Ao(t,e){return new Promise((n,r)=>{sn(t,e,(o,s)=>{if(o)return r(o);n(s)})})}function sn(t,e,n){new on(t,e,n).start()}function xo(t,e){return new on(t,e).start()}var Ze=class{constructor(t,e){this.root=t,this.options=e}withPromise(){return Ao(this.root,this.options)}withCallback(t){sn(this.root,this.options,t)}sync(){return xo(this.root,this.options)}},un=null;try{Ye.resolve("picomatch"),un=Ye("picomatch")}catch{}var an=class{globCache={};options={maxDepth:1/0,suppressErrors:!0,pathSeparator:Ve,filters:[]};globFunction;constructor(t){this.options={...this.options,...t},this.globFunction=this.options.globFunction}group(){return this.options.group=!0,this}withPathSeparator(t){return this.options.pathSeparator=t,this}withBasePath(){return this.options.includeBasePath=!0,this}withRelativePaths(){return this.options.relativePaths=!0,this}withDirs(){return this.options.includeDirs=!0,this}withMaxDepth(t){return this.options.maxDepth=t,this}withMaxFiles(t){return this.options.maxFiles=t,this}withFullPaths(){return this.options.resolvePaths=!0,this.options.includeBasePath=!0,this}withErrors(){return this.options.suppressErrors=!1,this}withSymlinks({resolvePaths:t=!0}={}){return this.options.resolveSymlinks=!0,this.options.useRealPaths=t,this.withFullPaths()}withAbortSignal(t){return this.options.signal=t,this}normalize(){return this.options.normalizePath=!0,this}filter(t){return this.options.filters.push(t),this}onlyDirs(){return this.options.excludeFiles=!0,this.options.includeDirs=!0,this}exclude(t){return this.options.exclude=t,this}onlyCounts(){return this.options.onlyCounts=!0,this}crawl(t){return new Ze(t||".",this.options)}withGlobFunction(t){return this.globFunction=t,this}crawlWithOptions(t,e){return this.options={...this.options,...e},new Ze(t||".",this.options)}glob(...t){return this.globFunction?this.globWithOptions(t):this.globWithOptions(t,{dot:!0})}globWithOptions(t,...e){let n=this.globFunction||un;if(!n)throw new Error("Please specify a glob function to use glob matching.");var r=this.globCache[t.join("\0")];return r||(r=n(t,...e),this.globCache[t.join("\0")]=r),this.options.filters.push(o=>r(o)),this}};var ht=Wn(Tn(),1),fs=Array.isArray,Dn=/\\/g,ds=/^[A-Za-z]:$/,Hn=process.platform==="win32",hs=/^(\/?\.\.)+$/;function ms(t,e={}){let n=t.length,r=Array(n),o=Array(n),s,i;for(s=0;s<n;s++){let u=Nn(t[s]);r[s]=u;let p=u.length,m=Array(p);for(i=0;i<p;i++)m[i]=(0,ht.default)(u[i],e);o[s]=m}return u=>{let p=u.split("/");if(p[0]===".."&&hs.test(u))return!0;for(s=0;s<n;s++){let m=r[s],g=o[s],y=p.length,f=Math.min(y,m.length);for(i=0;i<f;){let b=m[i];if(b.includes("/"))return!0;if(!g[i](p[i]))break;if(!e.noglobstar&&b==="**")return!0;i++}if(i===y)return!0}return!1}}var gs=/^[A-Z]:\/$/i,ys=Hn?t=>gs.test(t):t=>t==="/";function Pn(t,e,n){if(t===e||e.startsWith(`${t}/`)){if(n){let o=t.length+ +!ys(t);return(s,i)=>s.slice(o,i?-1:void 0)||"."}let r=e.slice(t.length+1);return r?(o,s)=>{if(o===".")return r;let i=`${r}/${o}`;return s?i.slice(0,-1):i}:(o,s)=>s&&o!=="."?o.slice(0,-1):o}return n?r=>ot.relative(t,r)||".":r=>ot.relative(t,`${e}/${r}`)||"."}function bs(t,e){if(e.startsWith(`${t}/`)){let n=e.slice(t.length+1);return r=>`${n}/${r}`}return n=>{let r=ot.relative(t,`${e}/${n}`);return n[n.length-1]==="/"&&r!==""?`${r}/`:r||"."}}function Ln(t){return t.replace(ds,e=>`${e}/`)}var Ss={parts:!0};function Nn(t){var e;let n=ht.default.scan(t,Ss);return!((e=n.parts)===null||e===void 0)&&e.length?n.parts:[t]}var As=/(?<!\\)([()[\]{}*?|]|^!|[!+@](?=\()|\\(?![()[\]{}!*+?@|]))/g,xs=/(?<!\\)([()[\]{}]|^!|[!+@](?=\())/g,Rs=t=>t.replace(As,"\\$&"),Es=t=>t.replace(xs,"\\$&"),_s=Hn?Es:Rs;function vs(t,e){if(e?.caseSensitiveMatch===!1)return!0;let n=ht.default.scan(t);return n.isGlob||n.negated}function Et(...t){console.log(`[tinyglobby ${new Date().toLocaleTimeString("es")}]`,...t)}function Mn(t){return typeof t=="string"?[t]:t??[]}var ks=/^(\/?\.\.)+/,Is=/\\(?=[()[\]{}!*+?@|])/g;function oe(t,e,n,r){var o;let s=e.cwd,i=t;t[t.length-1]==="/"&&(i=t.slice(0,-1)),i[i.length-1]!=="*"&&e.expandDirectories&&(i+="/**");let u=_s(s);i=cs(i.replace(Is,""))?ot.relative(u,i):ot.normalize(i);let p=(o=ks.exec(i))===null||o===void 0?void 0:o[0],m=Nn(i);if(p){let y=(p.length+1)/3,f=0,b=u.split("/");for(;f<y&&m[f+y]===b[b.length+f-y];)i=i.slice(0,(y-f-1)*3)+i.slice((y-f)*3+m[f+y].length+1)||".",f++;let S=ot.join(s,p.slice(f*3));S[0]!=="."&&n.root.length>S.length&&(n.root=Ln(S),n.depthOffset=-y+f)}if(!r&&n.depthOffset>=0){var g;(g=n.commonPath)!==null&&g!==void 0||(n.commonPath=m);let y=[],f=Math.min(n.commonPath.length,m.length);for(let b=0;b<f;b++){let S=m[b];if(S==="**"&&!m[b+1]){y.pop();break}if(b===m.length-1||S!==n.commonPath[b]||vs(S))break;y.push(S)}n.depthOffset=y.length,n.commonPath=y,n.root=Ln(y.length>0?ot.join(s,...y):s)}return i}function ws(t,e,n){let r=[],o=[];for(let s of t.ignore)s&&(s[0]!=="!"||s[1]==="(")&&o.push(oe(s,t,n,!0));for(let s of e)s&&(s[0]!=="!"||s[1]==="("?r.push(oe(s,t,n,!1)):(s[1]!=="!"||s[2]==="(")&&o.push(oe(s.slice(1),t,n,!0)));return{match:r,ignore:o}}function Os(t,e){let n=t.cwd,r={root:n,depthOffset:0},o=ws(t,e,r);t.debug&&Et("internal processing patterns:",o);let{absolute:s,caseSensitiveMatch:i,debug:u,dot:p,followSymbolicLinks:m,onlyDirectories:g}=t,y=r.root.replace(Dn,""),f={dot:p,nobrace:t.braceExpansion===!1,nocase:!i,noextglob:t.extglob===!1,noglobstar:t.globstar===!1,posix:!0},b=(0,ht.default)(o.match,f),S=(0,ht.default)(o.ignore,f),x=ms(o.match,f),R=Pn(n,y,s),T=s?R:Pn(n,y,!0),A=(F,C)=>{let w=T(C,!0);return w!=="."&&!x(w)||S(w)},G;t.deep!==void 0&&(G=Math.round(t.deep-r.depthOffset));let K=new an({filters:[u?(F,C)=>{let w=R(F,C),E=b(w)&&!S(w);return E&&Et(`matched ${w}`),E}:(F,C)=>{let w=R(F,C);return b(w)&&!S(w)}],exclude:u?(F,C)=>{let w=A(F,C);return Et(`${w?"skipped":"crawling"} ${C}`),w}:A,fs:t.fs,pathSeparator:"/",relativePaths:!s,resolvePaths:s,includeBasePath:s,resolveSymlinks:m,excludeSymlinks:!m,excludeFiles:g,includeDirs:g||!t.onlyFiles,maxDepth:G,signal:t.signal}).crawl(y);return t.debug&&Et("internal properties:",{...r,root:y}),[K,n!==y&&!s&&bs(n,y)]}function Cs(t,e){if(e)for(let n=t.length-1;n>=0;n--)t[n]=e(t[n]);return t}var Fn={caseSensitiveMatch:!0,debug:!!process.env.TINYGLOBBY_DEBUG,expandDirectories:!0,followSymbolicLinks:!0,onlyFiles:!0};function $s(t){let e=Object.assign({},t);for(let n in Fn)e[n]===void 0&&Object.assign(e,{[n]:Fn[n]});return e.cwd=(e.cwd instanceof URL?ps(e.cwd):ls(e.cwd||process.cwd())).replace(Dn,"/"),e.ignore=Mn(e.ignore),e.fs&&(e.fs={readdir:e.fs.readdir||rs,readdirSync:e.fs.readdirSync||os,realpath:e.fs.realpath||ss,realpathSync:e.fs.realpathSync||is,stat:e.fs.stat||us,statSync:e.fs.statSync||as}),e.debug&&Et("globbing with options:",e),e}function Ts(t,e={}){var n;if(t&&e?.patterns)throw new Error("Cannot pass patterns as both an argument and an option");let r=fs(t)||typeof t=="string",o=Mn((n=r?t:t.patterns)!==null&&n!==void 0?n:"**/*"),s=$s(r?e:t);return o.length>0?Os(s,o):[]}async function se(t,e){let[n,r]=Ts(t,e);return n?Cs(await n.withPromise(),r):[]}var Bn=Object.values(Q).flatMap(t=>t.extensions).map(t=>t.slice(1));function Fs(t){return/[*?[\]{}]/.test(t)}async function Ds(t,e){let n=e?`**/*.{${Bn.join(",")}}`:`*.{${Bn.join(",")}}`;return(await se([n],{cwd:t,absolute:!0,onlyFiles:!0,caseSensitiveMatch:!1})).sort()}async function qn(t,e,n,r){let o=await Ds(t,e);if(o.length===0){n.push({path:t,error:me(t)});return}for(let s of o)await r(s,t,!1)}async function Lu(t,e){let n=[],r=[],o=new Map,s=ie(t);return await qn(s,e.recursive,r,async(i,u)=>{try{n.push(await Nt(i)),o.set(i,u)}catch(p){rt(p)&&r.push({path:i,error:p})}}),{sources:n,failures:r,roots:o}}async function Fu(t,e){let n=[],r=[],o=new Map,s=new Set,i=async(u,p,m)=>{let g=ie(u);if(!s.has(g)){s.add(g);try{n.push(await Nt(g)),p&&o.set(g,p)}catch(y){if(rt(y))r.push({path:g,error:y});else if(m)throw y}}};for(let u of t){let p=ie(u);if(Fs(u)&&!Ps(p)){let g=await se([u],{absolute:!0,onlyFiles:!0});g.length===0&&r.push({path:p,error:Ht(p)});for(let y of g.sort())await i(y,void 0,!1);continue}let m;try{m=await Ls(p)}catch{r.push({path:p,error:Ht(p)});continue}if(m.isDirectory()){await qn(p,e.recursive,r,i);continue}await i(p,void 0,!0)}return{sources:n,failures:r,roots:o}}export{Ot as a,_e as b,ve as c,qt as d,Ks as e,$e as f,li as g,Le as h,Fe as i,fr as j,He as k,Ne as l,Ue as m,Me as n,Ai as o,xi as p,Je as q,qi as r,Gi as s,ji as t,Qe as u,su as v,Lu as w,Fu as x};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{mkdir as g,readFile as d,rename as p,unlink as h,writeFile as m}from"node:fs/promises";import{homedir as o}from"node:os";import{dirname as y,join as f}from"node:path";var u={defaultOutput:"~/Desktop",quality:80};function c(){let e=process.env.XDG_CONFIG_HOME,t=e!==void 0&&e.length>0?e:f(o(),".config");return f(t,"forge","config.json")}function E(e){return e==="~"?o():e.startsWith("~/")?f(o(),e.slice(2)):e}function l(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function O(e){let t={...u},r=[];if(e.theme!==void 0&&(e.theme==="dark"||e.theme==="light"?t.theme=e.theme:r.push("theme")),e.defaultOutput!==void 0&&(typeof e.defaultOutput=="string"&&e.defaultOutput.trim().length>0?t.defaultOutput=e.defaultOutput:r.push("defaultOutput")),e.quality!==void 0){let n=e.quality;typeof n=="number"&&Number.isInteger(n)&&n>=1&&n<=100?t.quality=n:r.push("quality")}return{prefs:t,rejected:r}}async function P(){let e;try{e=await d(c(),"utf8")}catch{return}try{let t=JSON.parse(e);return l(t)?t:void 0}catch{return}}async function N(){let e=c(),t;try{t=await d(e,"utf8")}catch(s){return s.code==="ENOENT"?{prefs:u}:{prefs:u,warning:`Could not read the config at ${e} \u2014 using defaults.`}}let r;try{r=JSON.parse(t)}catch{return{prefs:u,warning:`The config at ${e} is not valid JSON \u2014 using defaults.`}}if(!l(r))return{prefs:u,warning:`The config at ${e} is not an object \u2014 using defaults.`};let{prefs:n,rejected:i}=O(r);return i.length===0?{prefs:n}:{prefs:n,warning:`Ignored invalid config ${i.length===1?"setting":"settings"}: ${i.join(", ")}.`}}async function j(e){let t=c();await g(y(t),{recursive:!0});let n={...await P()??{}};for(let[s,a]of Object.entries(e))a!==void 0&&(n[s]=a);let i=`${t}.${process.pid}.tmp`;try{await m(i,`${JSON.stringify(n,null,2)}
|
|
4
|
-
`,"utf8"),await p(i,t)}catch(s){throw await h(i).catch(()=>{}),s}}export{u as a,c as b,E as c,N as d,j as e};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{b as n,d as f,e as u}from"./chunk-EOYBXOCV.js";import{I as o}from"./chunk-PD5DFBCU.js";var d=["output","theme","quality"];async function c(r){if(r.action==="path")return{stdout:[n()],exitCode:0,config:{path:n()},warnings:[]};if(r.action==="list"){let{prefs:t,warning:i}=await f(),s=[`output ${t.defaultOutput}`,`theme ${t.theme??"not set"}`,`quality ${t.quality}`,"",n()];return i!==void 0&&s.unshift(`\u26A0 ${i}`,""),{stdout:s,exitCode:0,config:{output:t.defaultOutput,theme:t.theme??null,quality:t.quality,path:n()},warnings:i===void 0?[]:[{code:"config-unreadable",message:i}]}}let{key:a,value:e}=r;if(a==="theme"){if(e!=="dark"&&e!=="light")throw o(`Theme must be dark or light, not ${e}.`);return await u({theme:e}),{stdout:[`theme is now ${e}`],exitCode:0,config:{theme:e},warnings:[]}}if(a==="quality"){let t=Number(e);if(!Number.isInteger(t)||t<1||t>100)throw o(`Quality must be a whole number between 1 and 100, not ${e}.`);return await u({quality:t}),{stdout:[`quality is now ${t}`],exitCode:0,config:{quality:t},warnings:[]}}if(e.trim().length===0)throw o("Output must be a folder path.");return await u({defaultOutput:e}),{stdout:[`output is now ${e}`],exitCode:0,config:{output:e},warnings:[]}}export{d as a,c as b};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{b as U,c as V,e as Y,f as g,l as Z,m as P,n as w,o as K,p as Q,q as X,r as j,s as tt,t as et,u as D,v as rt,w as ot,z as nt}from"./chunk-YXDEOLNA.js";import{J as F,K as k,M as q,U as H,Y as I,c as E,d as v,g as S,z as y}from"./chunk-PD5DFBCU.js";import{readFile as vt,rm as Ft}from"node:fs/promises";var St=new Set(["pdf"]),It=new Set(["jpeg","png"]),Dt=new Set(["convert"]),st;function Rt(){return st??=K().then(t=>t.PDFiumLibrary.init()),st}async function it(t,e){return await(await Rt()).loadDocument(t,e)}async function at(t){let e=await it(t);try{let r=[];for(let o=0;o<e.getPageCount();o++)r.push(e.getPage(o).getText());return r}finally{e.destroy()}}var ct={id:"pdfium",reads:St,writes:It,ops:Dt,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 y(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 P(),a=await it(await vt(r.path),t.options.password);try{let i=[],c=0;try{for(let[p,u]of s.entries()){let m=await a.getPage(u).render({scale:o/72,render:"bitmap",transparent:!0}),f=n(m.data,{raw:{width:m.width,height:m.height,channels:4}}).flatten({background:t.options.background}),d=await D(f,t.target,t.options.quality).toBuffer(),l=t.outputs[p];c+=await g(l,d),i.push(l),e({phase:"page",done:p+1,total:s.length})}}catch(p){throw await Promise.all(i.map(u=>Ft(u,{force:!0}))),p}return{job:t,outputBytes:c,warnings:[]}}finally{a.destroy()}}};function Ie(t,e){let r=t.split(",").map(n=>n.trim()).filter(n=>n!=="");if(r.length===0)throw F(t,"That selects no pages.",e);let o=new Set,s=(n,a)=>{if(!Number.isInteger(n)||n<1||n>e)throw F(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 F(n,`"${n}" ends before it starts.`,e);for(let p=i;p<=c;p++)o.add(p-1);continue}if(!/^\d+$/.test(n))throw F(n,`"${n}" is not a page number.`,e);o.add(s(Number(n),n)-1)}return[...o].sort((n,a)=>n-a)}function pt(t){return[...new Set(t)].sort((e,r)=>e-r)}function De(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 ut(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}import{mkdtemp as $t,rm as Tt}from"node:fs/promises";import{tmpdir as At}from"node:os";import{join as R}from"node:path";var ft=(t,e,r)=>Y(t,e,r)===void 0;function dt(t,e,r=Number.POSITIVE_INFINITY,o=[2,4]){return[...o].reverse().find(s=>s<r&&ft(t,e,s))??0}async function Bt(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,{installed:a,extensionsRoot:i}=await import("./paths-JUM6GKQU.js"),c=await a(n);if(!c)throw q(n);let p=U(c.version);if(t.op==="boost"){let{catalogEntry:d}=await import("./catalog-NTACQH5V.js"),l=V(t.scale,c.version,d(n)?.version);if(l)throw l}if(t.op==="boost"&&!ft(o.width,o.height,t.scale))throw H(o.path,dt(o.width,o.height,Number.POSITIVE_INFINITY,p),t.scale);let{runExtension:u}=await import("./run-RXVQD4DZ.js"),m=[];o.frames>1&&m.push({code:"animation-flattened",message:`${E(o.path)} has ${o.frames} frames. Only the first frame was used.`});let f=await $t(R(At(),"forge-ext-"));try{e({phase:"decoding"});let d=R(f,"in.png"),l=R(f,"out.png");await ot(o,d);let B=t.op==="boost"?["--in",d,"--out",l,"--scale",String(t.scale),"--cache",R(i(),"boost","cache")]:[d,l];await u(c,B,{subject:o.path,what:`${Jt(t)} is running on ${E(o.path)}`,onWait:()=>e({phase:"waiting"}),onStart:()=>e({phase:"encoding"}),...t.op==="boost"?{maxScale:dt(o.width,o.height,t.scale,p)}:{},...r===void 0?{}:{signal:r}});let J=(await P())(l);v[t.target].hasAlpha||(J=J.flatten({background:t.options.background}));let bt=await D(J,t.target,t.options.quality).toBuffer();e({phase:"writing"});let Et=await rt(bt,s);return{job:t,outputBytes:Et,warnings:m}}catch(d){throw S(d)?d:I(o.path,d)}finally{await Tt(f,{recursive:!0,force:!0}).catch(()=>{})}}function Jt(t){return t.op!=="boost"?"Remove background":t.scale===1?"Sharpen":`Boost resolution ${t.scale}\xD7`}var mt={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:Bt};import{readFile as $,rm as gt,stat as kt}from"node:fs/promises";var N=Z(()=>import("./pdf-compress-IMRFBLZF.js")),Lt=new Set(["pdf","jpeg","png","webp","avif","gif","tiff"]),Nt=new Set(["pdf"]);async function x(t){return(await w()).PDFDocument.load(await $(t),{ignoreEncryption:!0})}async function Ot(t){let{surveyDocument:e}=await N(),r=await x(t),{size:o}=await kt(t);return{kind:"document",path:t,format:"pdf",bytes:o,pages:r.getPageCount(),encrypted:r.isEncrypted,images:e(r)}}function b(t){for(let e of t)if(e.encrypted)throw y(e.path)}async function Wt(t,e,r){let o=await P(),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:v.jpeg.defaultQuality,mozjpeg:!0}).toBuffer();return t.embedJpg(a)}return t.embedPng(await o(r).rotate().png().toBuffer())}async function _t(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:`${E(r.path)} has ${r.frames} frames, and ${v.pdf.label} cannot animate. Only the first frame was converted.`}),e({phase:"reading"});let s=await $(r.path);e({phase:"encoding"});let a=await(await w()).PDFDocument.create(),i=await Wt(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 g(t.outputs[0],await a.save());return{job:t,outputBytes:p,warnings:o}}async function zt(t,e){b(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 x(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 g(t.outputs[0],s);return{job:t,outputBytes:n,warnings:[]}}async function Gt(t,e){let r=t.sources[0];b([r]);let o=await w();e({phase:"reading"});let s=await x(r.path),n=ut(t.cuts,s.getPageCount()),a=[],i=0;try{for(let[c,p]of n.entries()){let u=await o.PDFDocument.create(),m=Array.from({length:p.to-p.from+1},(l,B)=>p.from+B),f=await u.copyPages(s,m);for(let l of f)u.addPage(l);let d=t.outputs[c];if(d===void 0)throw new Error(`split produced ${n.length} parts but was given ${t.outputs.length} outputs`);i+=await g(d,await u.save()),a.push(d),e({phase:"page",done:c+1,total:n.length})}}catch(c){throw await Promise.all(a.map(p=>gt(p,{force:!0}))),c}return{job:t,outputBytes:i,warnings:[]}}async function L(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 Ct(t,e){let r=t.sources[0];if(b([r]),t.pages.length===0)throw k("That extract selects no pages.");e({phase:"reading"});let o=await x(r.path),s=pt(t.pages),n=[],a=0;try{if(t.separate)for(let[i,c]of s.entries()){let p=t.outputs[i];a+=await g(p,await L(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 g(i,await L(o,s)),n.push(i)}}catch(i){throw await Promise.all(n.map(c=>gt(c,{force:!0}))),i}return{job:t,outputBytes:a,warnings:[]}}async function Mt(t,e){let r=t.sources[0];b([r]),e({phase:"reading"});let o=await x(r.path),s=new Set(t.pages),n=o.getPageIndices().filter(i=>!s.has(i));if(n.length===0)throw k("That would delete every page.");e({phase:"writing"});let a=await g(t.outputs[0],await L(o,n));return{job:t,outputBytes:a,warnings:[]}}async function qt(t,e){let r=t.sources[0];b([r]);let o=await w();e({phase:"reading"});let s=await x(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 g(t.outputs[0],await s.save());return{job:t,outputBytes:n,warnings:[]}}async function Ht(t,e){let r=t.sources[0];b([r]);let{compressPdf:o}=await N();e({phase:"reading"});let s=await $(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});e({phase:"writing"});let u=await g(t.outputs[0],n),m=d=>d===1?"":"s",f=[];return a===0&&i===0?f.push({code:"pdf-no-images",message:"This PDF has no images to re-encode, so its size is almost unchanged."}):a===0?f.push({code:"pdf-no-images",message:`None of its ${i} image${m(i)} could be re-encoded \u2014 they are not JPEG data.`}):i>0&&f.push({code:"pdf-images-skipped",message:`${a} image${m(a)} recompressed, ${i} skipped (not JPEG).`}),c!==void 0&&p!==void 0&&f.push({code:"pdf-downsampled",message:`Images reduced from ${c} to ${p} dpi. Pass --dpi ${c} to keep them.`}),{job:t,outputBytes:u,warnings:f}}async function Ut(t){if(t.op!=="convert")return;let e=t.sources[0];if(e.kind!=="document")return;let{compressPdf:r}=await N(),o=await $(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 lt={id:"pdf",measurer:Ut,reads:Lt,writes:Nt,ops:new Set(["convert","merge","split","extract","delete","rotate"]),probe:Ot,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"?Ht(t,e):_t(t,e);case"merge":return zt(t,e);case"split":return Gt(t,e);case"extract":return Ct(t,e);case"delete":return Mt(t,e);case"rotate":return qt(t,e);default:throw new Error(`the pdf engine cannot ${t.op}`)}}};import{execFile as Vt}from"node:child_process";import{mkdtemp as Yt,readFile as G,rm as Zt}from"node:fs/promises";import{tmpdir as Kt}from"node:os";import{basename as Qt,extname as Xt,join as wt}from"node:path";import{promisify as jt}from"node:util";var z=jt(Vt),O=Buffer.from([208,207,17,224,161,177,26,225]);async function te(t){if(t.length<O.length||!t.subarray(0,O.length).equals(O))return!1;let e=await tt();try{return e.find(e.parse(t),"WordDocument")!==null}catch{return!1}}async function ee(t){let e=await j();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 re(t){let e=await G(t),r=await ee(e);if(r)return{kind:"document",path:t,format:"docx",bytes:e.byteLength,pages:r.pages,encrypted:!1};if(await te(e))return{kind:"document",path:t,format:"doc",bytes:e.byteLength,pages:0,encrypted:!1};throw new Error(`${t} is not a Word document`)}var ht="/Applications/LibreOffice.app/Contents/MacOS/soffice",oe=0;async function ne(){oe++;try{return await z("soffice",["--version"],{timeout:5e3}),"soffice"}catch{}try{return await z(ht,["--version"],{timeout:5e3}),ht}catch{return}}var yt,se=!1,ie;async function ae(){return se?ie:(yt??=ne(),yt)}var C="\f";function T(t){return t.split(/\r?\n/).map(e=>e.trim()).filter(e=>e.length>0)}async function ce(t){if(t.format==="docx"){let r=await Q(),{value:o}=await r.extractRawText({path:t.path});return T(o)}if(t.format==="doc"){let r=await X(),s=await new r().extract(t.path);return T(s.getBody())}return(await at(await G(t.path))).flatMap((r,o)=>o===0?T(r):[C,...T(r)])}var W=612,A=792,h=54,_=11,Pt=14;async function pe(t){let{PDFDocument:e,StandardFonts:r}=await w(),o=await e.create(),s=await o.embedFont(r.Helvetica),n=W-h*2,a=o.addPage([W,A]),i=A-h,c=()=>{a=o.addPage([W,A]),i=A-h};for(let p of t){if(p===C){c();continue}let u="";for(let m of p.split(/\s+/).filter(Boolean)){let f=u?`${u} ${m}`:m;u&&s.widthOfTextAtSize(f,_)>n?(i<h&&c(),a.drawText(u,{x:h,y:i,size:_,font:s}),i-=Pt,u=m):u=f}u&&(i<h&&c(),a.drawText(u,{x:h,y:i,size:_,font:s}),i-=Pt)}return o.save()}async function ue(t){let{Document:e,Packer:r,PageBreak:o,Paragraph:s}=await et(),n=t.map(i=>i===C?new s({children:[new o]}):new s(i)),a=new e({sections:[{children:n}]});return r.toBuffer(a)}var de=new Set(["docx","doc","pdf"]),fe=new Set(["docx","pdf"]),me=new Set(["convert"]),ge={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"};async function le(t,e,r){let o=await Yt(wt(Kt(),"forge-word-"));try{await z(t,[`-env:UserInstallation=file://${o}/profile`,"--headless","--convert-to",r,"--outdir",o,e],{timeout:12e4});let s=Qt(e,Xt(e));return await G(wt(o,`${s}.${r}`))}finally{await Zt(o,{recursive:!0,force:!0})}}async function we(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 y(r.path);e({phase:"reading"});let o=await ae();e({phase:"encoding"});let s=[],n;try{if(o!==void 0)n=await le(o,r.path,t.target);else{let i=await ce(r);n=t.target==="pdf"?await pe(i):await ue(i),s.push(ge)}}catch(i){throw I(r.path,i)}e({phase:"writing"});let a=await g(t.outputs[0],n);return{job:t,outputBytes:a,warnings:s}}var xt={id:"word",reads:de,writes:fe,ops:me,probe:re,run:we};var M=[nt,lt,xt,mt,ct];function pr(t){if(t.op==="convert"){let e=t.sources[0].format;return M.find(r=>r.reads.has(e)&&r.writes.has(t.target))}return M.find(e=>e.ops.has(t.op))}async function ur(t){let e;for(let r of M)try{return await r.probe(t)}catch(o){S(e)||(e=o)}throw e}function he(t){switch(t.op){case"convert":return t.options.trim&&t.options.resize?"trimmed and resized":t.options.resize?"resized":t.options.trim?"trimmed":t.target===t.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 t.scale===1?"sharpened":"boosted";case"remove-background":return"cut out";default:{let e=t;throw new Error(`describeResult has no verb for ${JSON.stringify(e)}`)}}}function fr(t){let{job:e}=t,r=e.sources.map(s=>({path:s.path,bytes:s.bytes})),o=r.length===1&&e.outputs.length===1?r[0]:void 0;return{verb:he(e),sources:r,outputs:[...e.outputs],outputBytes:t.outputBytes,...o?{size:{from:o.bytes,to:t.outputBytes}}:{},warnings:t.warnings}}export{Ie as a,pt as b,De as c,ut as d,it as e,ct as f,M as g,pr as h,ur as i,fr as j};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{a}from"./chunk-J7FLFHQJ.js";import{homedir as c}from"node:os";import{basename as h,isAbsolute as g,relative as f,sep as m}from"node:path";var p=/[\u0000-\u001f\u007f-\u009f--]/g;function l(e){return e.replace(p,"?")}function u(e,t){let r=f(t,e);if(r==="")return"";if(!(r===".."||r.startsWith(`..${m}`)||g(r)))return r}function C(e,t={}){return l(w(e,t))}function w(e,t){if(t.cwd!==void 0){let i=u(e,t.cwd);if(i!==void 0)return i===""?".":i}let r=u(e,t.home??c());return r!==void 0?r===""?"~":`~/${r}`:e}function n(e){return l(h(e))}var s={jpeg:{id:"jpeg",label:"JPEG",extensions:[".jpg",".jpeg"],hasAlpha:!1,animatable:!1,lossy:!0,hint:"universal",defaultQuality:82},png:{id:"png",label:"PNG",extensions:[".png"],hasAlpha:!0,animatable:!1,lossy:!1,hint:"lossless"},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"},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(s);function S(e){return s[e.toLowerCase()]}function H(e){let t=s[e].extensions[0];if(!t)throw new Error(`format ${e} declares no extensions`);return t}import{dirname as x}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 b(e){return e instanceof o}function O(e){return new o({code:"file-not-found",title:"File not found",detail:`${n(e)} could not be found.`,short:`${n(e)} could not be found.`,hint:"Check the filename and try again."})}function z(e){return new o({code:"not-a-file",title:"Not a file",detail:`${n(e)} is not a file.`,short:`${n(e)} is not a file.`,hint:"Point Forge at an image, or at a directory of images."})}function R(e){return new o({code:"permission-denied",title:"Permission denied",detail:`${n(e)} could not be read.`,short:`${n(e)} could not be read.`,hint:"Check the file permissions and try again."})}function U(e){return new o({code:"not-a-directory",title:"Invalid path",detail:`${n(e)} could not be found: part of its path is not a directory.`,short:`part of ${n(e)}'s path is not a folder.`,hint:"Check the path and try again."})}function M(e){return new o({code:"symlink-loop",title:"Too many symbolic links",detail:`${n(e)} could not be resolved: its path contains a symbolic-link loop.`,short:`${n(e)}'s path loops back on itself.`,hint:"Check for a circular symlink somewhere in the path."})}function L(e){return new o({code:"path-too-long",title:"Path too long",detail:`${n(e)}'s path is too long for the filesystem to resolve.`,short:`${n(e)}'s path is too long.`,hint:"Use a shorter path and try again."})}function W(e,t){return new o({code:"unreadable-path",title:"Could not read path",detail:`${n(e)} could not be checked.`,short:`${n(e)} could not be checked.`,hint:"Check the path and try again.",cause:t})}function J(e,t){return new o({code:"unsupported-source",title:"Unsupported file type",detail:`${n(e)} is ${t}, which Forge cannot read.`,short:`${n(e)} is ${t}, which Forge cannot read.`,hint:"Forge 0.1 handles images only."})}function B(e,t){return new o({code:"unsupported-source",title:"Not an image",detail:`${n(e)} is ${t}, not an image.`,hint:"A palette is taken from a photo, a screenshot or artwork."})}function _(e){return new o({code:"unsupported-source",title:"Nothing to take colours from",detail:`${n(e)} has no visible pixels.`})}function G(e){return new o({code:"heic-decoder-unavailable",title:"Cannot read HEIC here",detail:`${n(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 r=n(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 ${r} \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 ${r} 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?`${r}'s images are a kind Forge cannot re-encode, so there is nothing to make smaller.`:`${r} 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:`${r} is ${s[e.format].label}, which has no images Forge can re-encode.`,hint:`Use --to pdf to change it to PDF instead: forge ${r} --to pdf`,shellHint:"Use /convert to change it to PDF instead."}):new o({code:"unsupported-compress",title:"Nothing to compress",detail:`${r} 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 Q(e){let t=n(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 V(e,t,r){return new o({code:"unsupported-operation",title:`Cannot ${e} these files`,detail:`Not available for these files: ${t}.`,hint:r??"Page operations work on PDFs: --merge takes two or more, the others take one.",shellHint:r??"Use /pdf with a PDF staged \u2014 two or more for merge."})}function X(e,t,r){return new o({code:"target-unreachable",title:"Cannot get that small",detail:`${n(e.path)} is ${a(r)} even at the lowest quality, which is still over ${a(t)}.`,hint:"Try a larger --max-size, or --to a smaller format.",shellHint:"Try a larger target, or /convert to a smaller format."})}function Y(e,t,r){return new o({code:"unsupported-target",title:`Can't convert ${n(e.path)} to ${t}`,detail:`${n(e.path)} is a ${s[e.format].label} ${e.kind==="image"?"image":"document"}.`,hint:`Available: ${r.join(", ")}`})}function K(e,t){return new o({code:"corrupt-source",title:"Damaged file",detail:`${n(e)} could not be read. It may be damaged, or not a format Forge recognises.`,short:`${n(e)} could not be read.`,hint:"The file may be incomplete or corrupted.",cause:t})}function Z(e,t,r){return new o({code:"corrupt-source",title:`Damaged ${s[t].label}`,detail:`${n(e)} is a ${s[t].label} file, but its content could not be read.`,short:`${n(e)} could not be read.`,hint:"The file may be incomplete or corrupted.",cause:r})}function ee(e,t={}){let r=n(e);return new o({code:"encrypted-source",title:"This PDF is password-protected",detail:`${r} is password-protected.`,short:`${r} is password-protected.`,hint:t.attempted?"That password didn't open it. Check it and try again.":`Convert it to images instead: forge ${r} --to jpeg --password-stdin`})}var d=e=>e==="convert"||e==="boost"||e==="remove-background";function te(e,t="convert"){return new o({code:"output-exists",title:"File already exists",detail:`${n(e)} is already there.`,hint:d(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 oe(e,t){return new o({code:"output-collision",title:"Two files want the same output",detail:`${n(e[0])} and ${n(e[1])} would both become ${n(t)}.`,hint:"Convert them separately, or use --output to send them to different folders.",shellHint:"Convert them one at a time."})}function ne(e,t){return new o({code:"output-collision",title:"One output, written twice",detail:`${n(e)} would write ${n(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 re(e,t="convert"){return new o({code:"output-is-input",title:"Output would replace the original",detail:`${n(e)} is both the input and the output.`,hint:d(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:d(t)?"Choose a different folder to save it in.":"Move or rename that file first."})}function y(e,t){return new o({code:"permission-denied",title:"Permission denied",detail:`${n(x(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 $=new Set(["EACCES","EPERM","EROFS"]);function ie(e,t){if(b(t))return t;let r=t?.code;return r!==void 0&&$.has(r)?y(e,t):t}function se(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 ae(e){return new o({code:"empty-directory",title:"No images found",detail:`${n(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 le(e,t){return new o({code:"invalid-arguments",title:"Invalid arguments",detail:e,hint:t})}function de(e,t,r){return new o({code:"invalid-page-range",title:"Page range not understood",detail:t,hint:`This document has ${r} pages. Use numbers and spans, like "3-7, 12, 20-".`})}function ue(e){return new o({code:"empty-selection",title:"Nothing to write",detail:e,hint:"Select at least one page to keep."})}function pe(e){return new o({code:"invalid-dpi",title:"Invalid resolution",detail:`${String(e)} is not a resolution Forge can use.`,hint:"Give a number between 36 and 600. The default is 150."})}function ce(e){return new o({code:"extension-missing",title:"Extension not installed",detail:`${e} is an optional extension and is not installed.`,hint:`Install it with: forge extensions add ${e}`,shellHint:"Open /extensions to install it."})}function he(e,t,r,i){return new o({code:"extension-outdated",title:"Extension out of date",detail:`${e} ${r} cannot ${t}; that needs ${i} or later.`,hint:`Update it with: forge extensions add ${e}`,shellHint:"Open /extensions to update it."})}function ge(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 fe(e,t){return new o({code:"extension-unsupported",title:"Extension not available here",detail:`${e} cannot be installed on this Mac: ${t}`,hint:"See what is available with: forge extensions",shellHint:"See what is available in /extensions."})}function me(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 we(e,t){return new o({code:"extension-download-failed",title:"Not enough disk space",detail:`${e}: ${t}`,hint:`Free some disk space, then run: forge extensions add ${e}`,shellHint:"Free some disk space, then try again from /extensions."})}function xe(e,t,r){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:r==="remove"?`Wait for that job to finish, then run: forge extensions remove ${e}`:"Wait for that job to finish, then try again.",shellHint:r==="remove"?"It can be removed when that job finishes.":"Try again when that job finishes."})}function be(e){return new o({code:"no-subject",title:"No subject found",detail:`${n(e)} has no clear subject to cut out.`,hint:"Try a photo where the subject stands apart from the background."})}function ye(e,t,r){return r===1?new o({code:"boost-too-large",title:"Too large to sharpen",detail:`${n(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?`${n(e)} is too large to boost that far; ${t}x is the most it can take.`:`${n(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 $e(e,t){return new o({code:"resize-too-large",title:"Too large to resize to",detail:`${n(e)} would be ${t.width} \xD7 ${t.height}.`,hint:"Resize works up to 16,384 px a side and 100 megapixels."})}function Fe(e){return new o({code:"nothing-to-trim",title:"Nothing to trim",detail:`${n(e)} has no empty edges.`,short:"no empty edges"})}function Ee(e){return new o({code:"animated-trim",title:"Can't trim an animation",detail:`${n(e)} is animated; trimming works on still images.`})}function ve(e,t){return new o({code:"conversion-failed",title:"Conversion failed",detail:`${n(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 ke(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 Ce(e,t={}){let r=[`\u2715 ${e.title}`,"",` ${e.detail}`];return e.hint&&r.push("",` ${e.hint}`),t.debug&&e.cause instanceof Error&&r.push("",` ${e.cause.stack??e.cause.message}`),r}export{l as a,C as b,n as c,s as d,S as e,H as f,b as g,O as h,z as i,R as j,U as k,M as l,L as m,W as n,J as o,B as p,_ as q,G as r,q as s,Q as t,V as u,X as v,Y as w,K as x,Z as y,ee as z,te as A,oe as B,ne as C,re as D,y as E,ie as F,se as G,ae as H,le as I,de as J,ue as K,pe as L,ce as M,he as N,ge as O,fe as P,me as Q,we as R,xe as S,be as T,ye as U,$e as V,Fe as W,Ee as X,ve as Y,ke as Z,Ce as _};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
var e="https://github.com/AtharvaN16/forge-terminal/releases/download",a=[{id:"boost",title:"Boost resolution",summary:"Sharpen, or boost resolution 2x or 4x, with a local AI model",version:"1.0.0",minMacos:14,assets:{arm64:{url:`${e}/ext-boost-v1.0.0/forge-ext-boost-1.0.0-arm64.tar.gz`,bytes:14866325,sha256:"7af24c92f95b1cd34618adde4a90926c91a8db4347d640be4921f1dc706a9a2e"}},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",version:"1.0.0",minMacos:14,assets:{universal:{url:`${e}/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"}];function r(t){return a.find(o=>o.id===t)}export{a,r as b};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{E as G,F as b,G as Q,I as M,N as V,V as Z,W as Y,X as ee,Y as R,c as F,d as m,g as A,h as H,i as C,j as P,k as W,l as q,m as J,n as X,o as j,r as y,x as K,y as T}from"./chunk-PD5DFBCU.js";import{randomBytes as Me}from"node:crypto";import{constants as Re}from"node:fs";import{access as ke,readFile as se,rename as De,rm as Le,stat as Ne,writeFile as Ue}from"node:fs/promises";import{basename as $e,dirname as _e,join as He}from"node:path";import{randomBytes as me}from"node:crypto";import{constants as pe}from"node:fs";import{access as he,mkdir as ue,rename as le,rm as ge,writeFile as we}from"node:fs/promises";import{dirname as ye}from"node:path";async function I(e){let r=ye(e);try{await ue(r,{recursive:!0})}catch(t){let i=b(e,t);throw i===t?Q(e,t):i}try{await he(r,pe.W_OK)}catch(t){throw G(e,t)}}async function it(e,r){await I(e);let t=`${e}.${me(6).toString("hex")}.tmp`;try{return await we(t,r),await le(t,e),r.byteLength}catch(i){throw await ge(t,{force:!0}).catch(()=>{}),b(e,i)}}function st(e){if(m[e].hasAlpha)return;let r=Object.keys(m).filter(t=>m[t].hasAlpha&&t!=="heic").join(", ");return M(`${m[e].label} cannot hold transparency, so a cutout cannot be saved as one.`,`Choose a format that can: ${r}.`)}var te="1.1.0";function be(e,r){let t=e.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(t.length,i.length);n++){let a=(t[n]??0)-(i[n]??0);if(a!==0)return a>0}return!0}function k(e){return e!==void 0&&be(e,te)?[2,3,4]:[2,4]}function ct(e,r,t){if(e===1||k(r).some(n=>n===e))return;if(t!==void 0&&k(t).some(n=>n===e))return V("boost",`boost ${e}\xD7`,r,te);let i=k(r).map(n=>`--boost ${n}`);return M(`No released boost makes ${e}\xD7 yet.`,`Try ${i.slice(0,-1).join(", ")} or ${i.at(-1)}.`)}var xe=16384,Se=1e8;function re(e,r,t){let i=Math.max(e,r)*t;if(i>xe)return{side:i};let n=e*t*r*t;if(n>Se)return{megapixels:Math.round(n/1e6)}}var w=e=>Math.max(1,Math.round(e));function D(e,r){return"percent"in r?{width:w(e.width*r.percent/100),height:w(e.height*r.percent/100)}:"width"in r?{width:w(r.width),height:w(e.height*r.width/e.width)}:{width:w(e.width*r.height/e.height),height:w(r.height)}}function ie(e){return re(e.width,e.height,1)}import{execFile as Ie}from"node:child_process";import{randomBytes as ve}from"node:crypto";import{open as ne,rm as Ee}from"node:fs/promises";import{tmpdir as Oe}from"node:os";import{join as ze}from"node:path";import{promisify as Be}from"node:util";var L=Be(Ie),x;async function S(){if(x!==void 0)return x;try{await L("/usr/bin/sips",["--help"],{timeout:5e3}),x=!0}catch{x=!1}return x}async function E(e){let r=ze(Oe(),`forge-heic-${ve(8).toString("hex")}.png`),t=async()=>{await Ee(r,{force:!0}).catch(()=>{})};try{return await L("/usr/bin/sips",["-s","format","png",e,"--out",r],{timeout:12e4}),{path:r,cleanup:t}}catch(i){throw await t(),i}}var Fe=new Set(["heic","heix","hevc","hevx","heim","heis","mif1","msf1"]),Ae=new Set(["avif","avis"]);async function ae(e){let r;try{r=await ne(e,"r")}catch{return!1}try{let t=Buffer.alloc(64),{bytesRead:i}=await r.read(t,0,64,0);if(i<12||t.toString("latin1",4,8)!=="ftyp")return!1;let n=Math.min(t.readUInt32BE(0),i),a=[];for(let o=8;o+4<=n;o+=4)a.push(t.toString("latin1",o,o+4));return a.some(o=>Ae.has(o))?!1:a.some(o=>Fe.has(o))}catch{return!1}finally{await r.close().catch(()=>{})}}async function oe(e){let{stdout:r}=await L("/usr/bin/sips",["-g","pixelWidth","-g","pixelHeight","-g","hasAlpha",e],{timeout:3e4}),t=Number(/pixelWidth:\s*(\d+)/.exec(r)?.[1]??0),i=Number(/pixelHeight:\s*(\d+)/.exec(r)?.[1]??0),n=await Pe(e);return{width:n?i:t,height:n?t:i,hasAlpha:/hasAlpha:\s*yes/i.test(r)}}function*v(e,r,t){let i=r;for(;i+8<=t;){let n=e.readUInt32BE(i),a=8;if(n===1&&i+16<=t?(n=Number(e.readBigUInt64BE(i+8)),a=16):n===0&&(n=t-i),n<a)return;yield{type:e.toString("latin1",i+4,i+8),start:i+a,end:Math.min(i+n,t)},i+=n}}async function Pe(e){let r=await ne(e,"r");try{let t=Buffer.alloc(262144),{bytesRead:i}=await r.read(t,0,t.length,0),n=[...v(t,0,i)].find(c=>c.type==="meta");if(!n)return!1;let a=[...v(t,n.start+4,n.end)],o=a.find(c=>c.type==="pitm"),l=a.find(c=>c.type==="iprp");if(!o||!l)return!1;let g=t.readUInt8(o.start)===0?t.readUInt16BE(o.start+4):t.readUInt32BE(o.start+4),s=[...v(t,l.start,l.end)],h=s.find(c=>c.type==="ipco"),f=s.find(c=>c.type==="ipma");if(!h||!f)return!1;let p=new Map;if([...v(t,h.start,h.end)].forEach((c,B)=>{c.type==="irot"&&p.set(B+1,t.readUInt8(c.start)&3)}),p.size===0)return!1;let U=t.readUInt8(f.start),$=(t.readUInt8(f.start+3)&1)===1,d=f.start+4,ce=t.readUInt32BE(d);d+=4;for(let c=0;c<ce&&d<f.end;c++){let B=U<1?t.readUInt16BE(d):t.readUInt32BE(d);d+=U<1?2:4;let fe=t.readUInt8(d);d+=1;for(let _=0;_<fe;_++){let de=$?t.readUInt16BE(d)&32767:t.readUInt8(d)&127;if(d+=$?2:1,B===g&&(p.get(de)??0)%2===1)return!0}}return!1}catch{return!1}finally{await r.close().catch(()=>{})}}function u(e){let r;return()=>(r??=e(),r)}var O=u(async()=>(await import("sharp")).default),bt=u(()=>import("./es-T2U7NBLD.js")),xt=u(()=>import("@hyzyla/pdfium")),St=u(async()=>(await import("./lib-TPEJ5CJJ.js")).default),It=u(async()=>(await import("./word-OGQ2KZAJ.js")).default),vt=u(async()=>(await import("./adm-zip-SQKLKBDP.js")).default),Et=u(async()=>(await import("./cfb-V6M2PYOD.js")).default);async function Te(){let e=Object.getOwnPropertyDescriptor(globalThis,"localStorage");if(!e?.configurable)return import("./dist-J2V6ITHG.js");Object.defineProperty(globalThis,"localStorage",{value:void 0,configurable:!0,enumerable:e.enumerable??!1,writable:!0});try{return await import("./dist-J2V6ITHG.js")}finally{Object.defineProperty(globalThis,"localStorage",e)}}var Ot=u(Te);var Ce=new Set(["jpeg","png","webp","avif","heic","gif","tiff"]),We=new Set(["jpeg","png","webp","avif","gif","tiff"]),qe={jpeg:"jpeg",png:"png",webp:"webp",gif:"gif",tiff:"tiff"};function Je(e,r){if(r.format==="heif")return r.compression==="av1"?"avif":"heic";let t=qe[r.format??""];if(!t)throw j(e,r.format??"an unknown format");return t}async function Xe(e){let r;try{r=await Ne(e)}catch(n){let a=n.code;throw a==="ENOENT"?H(e):a==="EACCES"||a==="EPERM"?P(e):a==="ENOTDIR"?W(e):a==="ELOOP"?q(e):a==="ENAMETOOLONG"?J(e):X(e,n)}if(!r.isFile())throw C(e);try{await ke(e,Re.R_OK)}catch{throw P(e)}if(await ae(e)){if(!await S())throw y(e);let n;try{n=await oe(e)}catch(a){throw T(e,"heic",a)}if(n.width===0||n.height===0)throw T(e,"heic",void 0);return{kind:"image",path:e,format:"heic",width:n.width,height:n.height,bytes:r.size,hasAlpha:n.hasAlpha,frames:1}}let t=await O(),i;try{i=await t(e).metadata()}catch(n){throw K(e,n)}return{kind:"image",path:e,format:Je(e,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 N(e,r,t){let i=t??m[r].defaultQuality;switch(r){case"jpeg":return e.jpeg({quality:i,mozjpeg:!0});case"webp":return e.webp({quality:i});case"avif":return e.avif({quality:i});case"png":return e.png({compressionLevel:9});case"gif":return e.gif();case"tiff":return e.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")}}async function je(e,r){let t=_e(r);await I(r);let i=He(t,`.forge-tmp-${Me(6).toString("hex")}-${$e(r)}`);try{return await Ue(i,e),await De(i,r),e.length}catch(n){throw await Le(i,{force:!0}).catch(()=>{}),b(r,n)}}async function z(e,r,t,i,n,a){if(e.kind!=="image")throw new Error("pipelineFor received a non-image source");if(n===void 0&&e.format==="heic"&&!await S())throw y(e.path);let o=n===void 0&&e.format==="heic"?await E(e.path):void 0,l=async()=>{await o?.cleanup()},s=(await O())(n??o?.path??e.path,i?{animated:!0}:{});if(s=s.rotate(),t.trim&&(s=s.trim()),t.resize){if(!a&&t.trim)throw new Error("pipelineFor needs the resolved size to resize a trimmed image");let h=a??D(e,t.resize);s=s.resize(h.width,h.height,{fit:"fill"})}return e.hasAlpha&&!m[r].hasAlpha&&(s=s.flatten({background:t.background})),s=t.keepMetadata?s.keepMetadata():s.keepIccProfile(),{pipeline:s,cleanup:l}}async function Ut(e,r){let t={background:"#ffffff",keepMetadata:!1},{pipeline:i,cleanup:n}=await z(e,"png",t,!1);try{await i.png({compressionLevel:1}).toFile(r)}finally{await n()}}async function $t(e,r,t){let{pipeline:i,cleanup:n}=await z(e,r,t,!1);try{return await N(i,r,t.quality).toBuffer()}finally{await n()}}async function Ke(e){let r={width:e.width,height:e.height};if(e.frames>1)return{upright:r,trimmed:"animated"};if(e.format==="heic"&&!await S())throw y(e.path);let t=e.format==="heic"?await E(e.path):void 0;try{let i=await O(),{info:n}=await i(t?.path??e.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 A(i)?i:R(e.path,i)}finally{await t?.cleanup()}}async function Ge(e,r){if(e.op!=="convert")throw new Error(`image engine cannot ${e.op}`);let t=e.sources[0],i=e.outputs[0];if(t.kind!=="image")throw new Error("the image engine cannot convert a document source");let n=m[e.target],a=[];r({phase:"reading"});let o=t.frames>1,l=o&&n.animatable;o&&!n.animatable&&a.push({code:"animation-flattened",message:`${F(t.path)} has ${t.frames} frames, and ${n.label} cannot animate. Only the first frame was converted.`});let g;if(e.options.trim||e.options.resize){let f={width:t.width,height:t.height};if(e.options.trim){if(o)throw ee(t.path);let{trimmed:p}=await Ke(t);if(p==="nothing"){if(!e.options.resize)throw Y(t.path);a.push({code:"nothing-trimmed",message:`${F(t.path)} has no empty edges; resized only.`})}else p!=="animated"&&(f=p)}if(e.options.resize&&(g=D(f,e.options.resize),ie(g)))throw Z(t.path,g)}r({phase:"decoding"});let{pipeline:s,cleanup:h}=await z(t,e.target,e.options,l,void 0,g);try{await I(i),r({phase:"encoding"});let f=await N(s,e.target,e.options.quality).toBuffer();r({phase:"writing"});let p=await je(f,i);return{job:e,outputBytes:p,warnings:a}}catch(f){throw A(f)?f:R(t.path,f)}finally{await h()}}async function Qe(e){if(e.format!=="heic")return se(e.path);if(!await S())throw y(e.path);let r=await E(e.path);try{return await se(r.path)}finally{await r.cleanup()}}async function Ve(e){if(e.op!=="convert"||!m[e.target].lossy)return;let r=e.sources[0];if(r.kind!=="image")return;let t=await Qe(r);return{ladder:[{}],measure:async i=>{let{pipeline:n}=await z(r,e.target,i,!1,t);return(await N(n,e.target,i.quality).toBuffer()).length}}}var _t={id:"image",reads:Ce,writes:We,ops:new Set(["convert"]),probe:Xe,run:Ge,measurer:Ve};export{st as a,k as b,ct as c,xe as d,re as e,it as f,D as g,ie as h,S as i,E as j,ae as k,u as l,O as m,bt as n,xt as o,St as p,It as q,vt as r,Et as s,Ot as t,N as u,je as v,Ut as w,$t as x,Ke as y,_t as z};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{a as $,b as S,c as u,d as k,e as O,f as C}from"./chunk-VH5RWPGZ.js";import{c as w,d as I,f as y}from"./chunk-PBIS2ONZ.js";import{a as h,b as g}from"./chunk-PN73WK2S.js";import{b as m,c as d,h as f,i as p}from"./chunk-QVACE4IE.js";import"./chunk-L76Q54MB.js";import{a as l}from"./chunk-G2D6BKOS.js";import"./chunk-YXDEOLNA.js";import{c as b,q as x}from"./chunk-PD5DFBCU.js";import"./chunk-J7FLFHQJ.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=w(o);if(s.length===0)throw x(t.input);let e=t.inside?N(s,t.inside):void 0,r=e?I(o,e):s;if(t.svg)return{exitCode:0,stdout:[$(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=y(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=O(t.colour);if(t.svg)return{exitCode:0,stdout:[S(t.colour,o)],stderr:[]};let s=o.map(e=>({...e,...k(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};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{a,b}from"./chunk-HUAEVW2A.js";import"./chunk-EOYBXOCV.js";import"./chunk-PD5DFBCU.js";import"./chunk-J7FLFHQJ.js";import"./chunk-TMUK2DD3.js";export{a as CONFIG_KEYS,b as runConfig};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{b as a,c as b,d as c,e as d}from"./chunk-C2WYXNRM.js";import"./chunk-C7OOWUMU.js";import"./chunk-PN73WK2S.js";import"./chunk-5B7WODWH.js";import"./chunk-L76Q54MB.js";import"./chunk-G2D6BKOS.js";import"./chunk-EOYBXOCV.js";import"./chunk-YXDEOLNA.js";import"./chunk-PD5DFBCU.js";import"./chunk-J7FLFHQJ.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{a as u}from"./chunk-J7FLFHQJ.js";import"./chunk-TMUK2DD3.js";function m(e){return{id:e.entry.id,title:e.entry.title,summary:e.entry.summary,version:e.entry.version,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 f(e){return e.supported?e.installed===void 0?`not installed${e.downloadBytes?`, ${u(e.downloadBytes)} download`:""}`:e.updateAvailable?`installed ${e.installed}, update to ${e.entry.version} available`:`installed ${e.installed}`:`not available: ${e.reason??"unsupported here"}`}function x(e){let t=Math.max(...e.map(n=>n.entry.id.length));return e.flatMap((n,i)=>[...i>0?[""]:[],`${n.entry.id.padEnd(t)} ${n.entry.summary}`,`${" ".repeat(t)} ${f(n)}`,`${" ".repeat(t)} ${n.entry.licence}`])}async function E(e,t={}){let{installExtension:n,listExtensions:i,removeExtension:p}=await import("./manager-KBJTXZ27.js"),a,d;if(e.action==="add"&&e.id!==void 0){let o=(await i()).find(c=>c.entry.id===e.id),r=o?.installed!==void 0&&!o.updateAvailable,l=await n(e.id,{onProgress:t.onDownload});a={id:e.id,action:r?"unchanged":"added"},d=r?`${e.id} ${l.version} is already installed`:`Installed ${e.id} ${l.version}`}else if(e.action==="remove"&&e.id!==void 0){let o=await p(e.id);a={id:e.id,action:o?"removed":"unchanged"},d=o?`Removed ${e.id}`:`${e.id} was not installed`}let s=await i();return{stdout:d===void 0?x(s):[d],data:{extensions:s.map(m),...a?{changed:a}:{}}}}export{E as runExtensions,m as toExtensionJson};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{u as a,v as b,w as c,x as d,y as e,z as f}from"./chunk-YXDEOLNA.js";import"./chunk-PD5DFBCU.js";import"./chunk-J7FLFHQJ.js";import"./chunk-TMUK2DD3.js";export{c as decodeToPng,a as encode,d as encodeToBuffer,f as imageEngine,e as measureImage,b as writeAtomic};
|