gitpick 6.1.0-canary.1 ā 6.1.0-canary.10
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 +49 -4
- package/dist/index.mjs +47 -47
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
[](https://www.npmjs.com/package/gitpick)
|
|
10
10
|
[](https://github.com/nrjdalal/gitpick)
|
|
11
11
|
|
|
12
|
-
š¦ `Zero dependencies` / `Un/packed (~
|
|
12
|
+
š¦ `Zero dependencies` / `Un/packed (~72/26kb)` / `Faster and more features` yet drop-in replacement for `degit`
|
|
13
13
|
|
|
14
14
|
> #### Just `copy-and-paste` any GitHub, GitLab, Bitbucket or Codeberg URL - no editing required (shorthands work too) - to clone individual files, folders, branches, commits, raw content or even entire repositories without the `.git` directory.
|
|
15
15
|
|
|
16
|
-
Unlike other tools that force you to tweak URLs or follow strict formats to clone files, folders, branches or commits GitPick works seamlessly with any URL.
|
|
16
|
+
Unlike other tools that force you to tweak URLs or follow strict formats to clone files, folders, branches or commits, GitPick works seamlessly with any URL.
|
|
17
17
|
|
|
18
18
|
**You can also try [Interactive Mode](#-interactive-mode)**. Browse any repo right in your terminal. See every file, pick what you want, skip what you don't. Just `gitpick owner/repo -i` and you're in. No more guessing paths.
|
|
19
19
|
|
|
@@ -30,6 +30,7 @@ Unlike other tools that force you to tweak URLs or follow strict formats to clon
|
|
|
30
30
|
- [Interactive Mode](#-interactive-mode)
|
|
31
31
|
- [Private Repos](#-private-repos)
|
|
32
32
|
- [Config File](#-config-file)
|
|
33
|
+
- [.gitpickignore](#-gitpickignore)
|
|
33
34
|
- [Install Globally](#-install-globally-optional)
|
|
34
35
|
- [Used By](#-used-by)
|
|
35
36
|
- [Related Projects](#-related-projects)
|
|
@@ -39,7 +40,7 @@ Unlike other tools that force you to tweak URLs or follow strict formats to clon
|
|
|
39
40
|
|
|
40
41
|
## š Some Examples
|
|
41
42
|
|
|
42
|
-
|
|
43
|
+
See [Quick Usage](#-quick-usage) to learn more.
|
|
43
44
|
|
|
44
45
|
```sh
|
|
45
46
|
# interactive mode - browse and pick files/folders
|
|
@@ -174,7 +175,19 @@ npx gitpick https://codeberg.org/owner/repo -i
|
|
|
174
175
|
|
|
175
176
|
<img width="900" alt="gitpick interactive mode: browse and pick files/folders" src="https://raw.githubusercontent.com/nrjdalal/demo-kit/main/gitpick/demo-interactive.gif" />
|
|
176
177
|
|
|
177
|
-
Navigate with arrow keys,
|
|
178
|
+
Navigate with arrow keys, `space` to select, `enter` to expand a folder or preview a file, `.` to select all, `c` to confirm, `q` to quit. File previews come with syntax highlighting for 38 languages. Works with GitHub, GitLab, Bitbucket, Codeberg, public and private repos.
|
|
179
|
+
|
|
180
|
+
### Pick from a local folder
|
|
181
|
+
|
|
182
|
+
Interactive mode also works on any folder already on your machine, so you can use GitPick as a local file cherry-picker:
|
|
183
|
+
|
|
184
|
+
```sh
|
|
185
|
+
npx gitpick -i # browse the current directory
|
|
186
|
+
npx gitpick -i my-app # browse cwd, copy the selection into ./my-app
|
|
187
|
+
npx gitpick ./src -i my-app # browse ./src, copy the selection into ./my-app
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
Inside a git repo it respects your `.gitignore` (via `git ls-files`) and preserves symlinks when copying.
|
|
178
191
|
|
|
179
192
|
---
|
|
180
193
|
|
|
@@ -255,6 +268,36 @@ Each entry follows the same `<url> [target]` syntax as the CLI. All entries are
|
|
|
255
268
|
|
|
256
269
|
---
|
|
257
270
|
|
|
271
|
+
## š« .gitpickignore
|
|
272
|
+
|
|
273
|
+
Add a `.gitpickignore` file at the root of the path you are picking to keep matching files out of the copy. It uses gitignore-style patterns, so the syntax is already familiar:
|
|
274
|
+
|
|
275
|
+
```gitignore
|
|
276
|
+
# .gitpickignore lives at the root of the picked folder or repo
|
|
277
|
+
|
|
278
|
+
# any .log file, at any depth
|
|
279
|
+
*.log
|
|
280
|
+
|
|
281
|
+
# a directory named node_modules, anywhere (trailing slash means directory only)
|
|
282
|
+
node_modules/
|
|
283
|
+
|
|
284
|
+
# only the dist at the picked root (a leading slash anchors the pattern)
|
|
285
|
+
/dist
|
|
286
|
+
|
|
287
|
+
# every png under docs, at any depth
|
|
288
|
+
docs/**/*.png
|
|
289
|
+
|
|
290
|
+
# re-include a file an earlier rule excluded (! negates, last match wins)
|
|
291
|
+
!docs/logo.png
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
- The file must sit at the **root of what you pick** - the folder for a `tree` URL, or the repo root for a full clone.
|
|
295
|
+
- `*` matches within a path segment, `**` spans directories, `?` matches a single character, and a trailing `/` limits a rule to directories.
|
|
296
|
+
- A leading or embedded `/` anchors a pattern to the picked root; otherwise it matches by basename at any depth.
|
|
297
|
+
- Full-line `#` comments and blank lines are ignored, and the `.gitpickignore` file itself is never copied.
|
|
298
|
+
|
|
299
|
+
---
|
|
300
|
+
|
|
258
301
|
## š¦ Install Globally (Optional)
|
|
259
302
|
|
|
260
303
|
```sh
|
|
@@ -262,6 +305,8 @@ npm install -g gitpick
|
|
|
262
305
|
gitpick <url/shorthand> [target] [options]
|
|
263
306
|
```
|
|
264
307
|
|
|
308
|
+
This installs two commands, `gitpick` and `degit`, so existing `degit owner/repo` workflows keep working unchanged.
|
|
309
|
+
|
|
265
310
|
---
|
|
266
311
|
|
|
267
312
|
## š Used By
|
package/dist/index.mjs
CHANGED
|
@@ -1,56 +1,56 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import e from"node:fs";import t from"node:os";import n from"node:path";import{parseArgs as r,stripVTControlCharacters as i}from"node:util";import{spawn as a}from"node:child_process";import{once as o}from"node:events";import s from"node:fs/promises";import c from"node:process";import{fileURLToPath as l}from"node:url";import u from"node:tty";import d from"node:https";var
|
|
3
|
-
`?e.slice(0,e.at(-2)===`\r`?-2:-1):e;if(E.exitCode&&E.exitCode>0)throw Object.assign(new
|
|
4
|
-
`),r=0;for(let e of n)r+=Math.max(1,Math.ceil(e.length/t));return r},m=()=>{if(!o)return;let e=Date.now();(t===-1||e-l>=80)&&(t=++t%
|
|
5
|
-
`)){let t=e.trim();if(t.startsWith(`refs/heads/`))n.add(t.slice(11));else if(t.startsWith(`refs/remotes/origin/`)){let e=t.slice(20);e!==`HEAD`&&n.add(e)}else t.startsWith(`refs/tags/`)&&n.add(t.slice(10))}return n},
|
|
6
|
-
`)){let t=e.split(` `)[1]?.trim();t&&(t.startsWith(`refs/heads/`)?n.add(t.slice(11)):t.startsWith(`refs/tags/`)&&n.add(t.slice(10).replace(/\^\{\}$/,``)))}return n},
|
|
7
|
-
Skipping git init: won't initialize a repository in the current directory (clone into a sub-directory to init there).`));return}if(!e.existsSync(n.join(l,`.git`)))try{await
|
|
8
|
-
Skipping commit: nothing was cloned to commit.`));return}let u=i.commit||`chore: gitpick'ed`;try{if(c)await S(`git`,[`add`,`--force`,`--`,n.basename(r)],{cwd:l});else{let r=(a??[]).map(e=>e.split(n.sep).join(`/`)),i=n.join(t.tmpdir(),j(`gitpick-add-`));await e.promises.writeFile(i,r.join(`\0`));try{await S(`git`,[`add`,`--force`,`--pathspec-from-file=${i}`,`--pathspec-file-nul`],{cwd:l})}catch{await S(`git`,[`add`,`--force`,`--`,...r],{cwd:l})}finally{await e.promises.rm(i,{force:!0})}}await S(`git`,[`commit`,`-m`,u],{cwd:l})}catch(e){s||console.log(k(`\nSkipping commit ā git reported:\n${Ce(e)}`))}};var we=Object.defineProperty,Te=e=>t=>{var n=e[t];if(n)return n();throw Error(`Module not found in bundle: `+t)},F=(e,t)=>()=>(e&&(t=e(e=0)),t),I=(e,t)=>{for(var n in t)we(e,n,{get:t[n],enumerable:!0})},Ee={};I(Ee,{default:()=>De});var De,Oe=F(()=>{De=[{type:`cmnt`,match:/(;|#).*/gm},{expand:`str`},{expand:`num`},{type:`num`,match:/\$[\da-fA-F]*\b/g},{type:`kwd`,match:/^[a-z]+\s+[a-z.]+\b/gm,sub:[{type:`func`,match:/^[a-z]+/g}]},{type:`kwd`,match:/^\t*[a-z][a-z\d]*\b/gm},{match:/%|\$/g,type:`oper`}]}),ke={};I(ke,{default:()=>je});var Ae,je,Me=F(()=>{Ae={type:`var`,match:/\$\w+|\${[^}]*}|\$\([^)]*\)/g},je=[{sub:`todo`,match:/#.*/g},{type:`str`,match:/(["'])((?!\1)[^\r\n\\]|\\[^])*\1?/g,sub:[Ae]},{type:`oper`,match:/(?<=\s|^)\.*\/[a-z/_.-]+/gi},{type:`kwd`,match:/\s-[a-zA-Z]+|$<|[&|;]+|\b(unset|readonly|shift|export|if|fi|else|elif|while|do|done|for|until|case|esac|break|continue|exit|return|trap|wait|eval|exec|then|declare|enable|local|select|typeset|time|add|remove|install|update|delete)(?=\s|$)/g},{expand:`num`},{type:`func`,match:/(?<=(^|\||\&\&|\;)\s*)[a-z_.-]+(?=\s|$)/gim},{type:`bool`,match:/(?<=\s|^)(true|false)(?=\s|$)/g},{type:`oper`,match:/[=(){}<>!]+/g},{type:`var`,match:/(?<=\s|^)[\w_]+(?=\s*=)/g},Ae]}),Ne={};I(Ne,{default:()=>Pe});var Pe,Fe=F(()=>{Pe=[{match:/[^\[\->+.<\]\s].*/g,sub:`todo`},{type:`func`,match:/\.+/g},{type:`kwd`,match:/[<>]+/g},{type:`oper`,match:/[+-]+/g}]}),Ie={};I(Ie,{default:()=>Le});var Le,Re=F(()=>{Le=[{match:/\/\/.*\n?|\/\*((?!\*\/)[^])*(\*\/)?/g,sub:`todo`},{expand:`str`},{expand:`num`},{type:`kwd`,match:/#\s*include (<.*>|".*")/g,sub:[{type:`str`,match:/(<|").*/g}]},{match:/asm\s*{[^}]*}/g,sub:[{type:`kwd`,match:/^asm/g},{match:/[^{}]*(?=}$)/g,sub:`asm`}]},{type:`kwd`,match:/\*|&|#[a-z]+\b|\b(asm|auto|double|int|struct|break|else|long|switch|case|enum|register|typedef|char|extern|return|union|const|float|short|unsigned|continue|for|signed|void|default|goto|sizeof|volatile|do|if|static|while)\b/g},{type:`oper`,match:/[/*+:?&|%^~=!,<>.^-]+/g},{type:`func`,match:/[a-zA-Z_][\w_]*(?=\s*\()/g},{type:`class`,match:/\b[A-Z][\w_]*\b/g}]}),ze={};I(ze,{default:()=>Be});var Be,Ve=F(()=>{Be=[{match:/\/\*((?!\*\/)[^])*(\*\/)?/g,sub:`todo`},{expand:`str`},{type:`kwd`,match:/@\w+\b|\b(and|not|only|or)\b|\b[a-z-]+(?=[^{}]*{)/g},{type:`var`,match:/\b[\w-]+(?=\s*:)|(::?|\.)[\w-]+(?=[^{}]*{)/g},{type:`func`,match:/#[\w-]+(?=[^{}]*{)/g},{type:`num`,match:/#[\da-f]{3,8}/g},{type:`num`,match:/\d+(\.\d+)?(cm|mm|in|px|pt|pc|em|ex|ch|rem|vm|vh|vmin|vmax|%)?/g,sub:[{type:`var`,match:/[a-z]+|%/g}]},{match:/url\([^)]*\)/g,sub:[{type:`func`,match:/url(?=\()/g},{type:`str`,match:/[^()]+/g}]},{type:`func`,match:/\b[a-zA-Z]\w*(?=\s*\()/g},{type:`num`,match:/\b[a-z-]+\b/g}]}),He={};I(He,{default:()=>Ue});var Ue,We=F(()=>{Ue=[{expand:`strDouble`},{type:`oper`,match:/,/g}]}),Ge={};I(Ge,{default:()=>Ke});var Ke,qe=F(()=>{Ke=[{type:`deleted`,match:/^[-<].*/gm},{type:`insert`,match:/^[+>].*/gm},{type:`kwd`,match:/!.*/gm},{type:`section`,match:/^@@.*@@$|^\d.*|^([*-+])\1\1.*/gm}]}),Je={};I(Je,{default:()=>Ye});var Ye,Xe=F(()=>{Me(),Ye=[{type:`kwd`,match:/^(FROM|RUN|CMD|LABEL|MAINTAINER|EXPOSE|ENV|ADD|COPY|ENTRYPOINT|VOLUME|USER|WORKDIR|ARG|ONBUILD|STOPSIGNAL|HEALTHCHECK|SHELL)\b/gim},...je]}),Ze={};I(Ze,{default:()=>Qe});var Qe,$e=F(()=>{qe(),Qe=[{match:/^#.*/gm,sub:`todo`},{expand:`str`},...Ke,{type:`func`,match:/^(\$ )?git(\s.*)?$/gm},{type:`kwd`,match:/^commit \w+$/gm}]}),et={};I(et,{default:()=>tt});var tt,nt=F(()=>{tt=[{match:/\/\/.*\n?|\/\*((?!\*\/)[^])*(\*\/)?/g,sub:`todo`},{expand:`str`},{expand:`num`},{type:`kwd`,match:/\*|&|\b(break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go|goto|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/g},{type:`func`,match:/[a-zA-Z_][\w_]*(?=\s*\()/g},{type:`class`,match:/\b[A-Z][\w_]*\b/g},{type:`oper`,match:/[+\-*\/%&|^~=!<>.^-]+/g}]}),rt={};I(rt,{default:()=>B,name:()=>L,properties:()=>R,xmlElement:()=>z});var it,at,L,R,z,B,ot=F(()=>{it=`:A-Z_a-zĆ-ĆĆ-öø-˿Ͱ-ͽͿ-įææā-āā°-āā°-⿯ć-ķæļ¤-ļ·ļ·°-ļæ½`,at=it+`\\-\\.0-9Ā·Ģ-ĶÆāæ-ā`,L=`[${it}][${at}]*`,R=`\\s*(\\s+${L}\\s*(=\\s*([^"']\\S*|("|')(\\\\[^]|(?!\\4)[^])*\\4?)?)?\\s*)*`,z={match:RegExp(`<[/!?]?${L}${R}[/!?]?>`,`g`),sub:[{type:`var`,match:RegExp(`^<[/!?]?${L}`,`g`),sub:[{type:`oper`,match:/^<[\/!?]?/g}]},{type:`str`,match:/=\s*([^"']\S*|("|')(\\[^]|(?!\2)[^])*\2?)/g,sub:[{type:`oper`,match:/^=/g}]},{type:`oper`,match:/[\/!?]?>/g},{type:`class`,match:RegExp(L,`g`)}]},B=[{match:/<!--((?!-->)[^])*-->/g,sub:`todo`},{type:`class`,match:/<!\[CDATA\[[\s\S]*?\]\]>/gi},z,{type:`str`,match:RegExp(`<\\?${L}([^?]|\\?[^?>])*\\?+>`,`g`),sub:[{type:`var`,match:RegExp(`^<\\?${L}`,`g`),sub:[{type:`oper`,match:/^<\?/g}]},{type:`oper`,match:/\?+>$/g}]},{type:`var`,match:/&(#x?)?[\da-z]{1,8};/gi}]}),st={};I(st,{default:()=>ct});var ct,lt=F(()=>{ot(),ct=[{type:`class`,match:/<!DOCTYPE("[^"]*"|'[^']*'|[^"'>])*>/gi,sub:[{type:`str`,match:/"[^"]*"|'[^']*'/g},{type:`oper`,match:/^<!|>$/g},{type:`var`,match:/DOCTYPE/gi}]},{match:RegExp(`<style${R}>((?!</style>)[^])*</style\\s*>`,`g`),sub:[{match:RegExp(`^<style${R}>`,`g`),sub:z.sub},{match:RegExp(`${z.match}|[^]*(?=</style\\s*>$)`,`g`),sub:`css`},z]},{match:RegExp(`<script${R}>((?!<\/script>)[^])*<\/script\\s*>`,`g`),sub:[{match:RegExp(`^<script${R}>`,`g`),sub:z.sub},{match:RegExp(`${z.match}|[^]*(?=<\/script\\s*>$)`,`g`),sub:`js`},z]},...B]}),ut,V,dt=F(()=>{ut=[[`bash`,[/#!(\/usr)?\/bin\/bash/g,500],[/\b(if|elif|then|fi|echo)\b|\$/g,10]],[`html`,[/<\/?[a-z-]+[^\n>]*>/g,10],[/^\s+<!DOCTYPE\s+html/g,500]],[`http`,[/^(GET|HEAD|POST|PUT|DELETE|PATCH|HTTP)\b/g,500]],[`js`,[/\b(console|await|async|function|export|import|this|class|for|let|const|map|join|require|document|window)\b/g,10]],[`ts`,[/\b(console|await|async|function|export|import|this|class|for|let|const|map|join|require|document|window|implements|interface|namespace)\b/g,10]],[`py`,[/\b(def|print|await|async|class|and|or|lambda|import|from|self|asyncio|pass|True|False|None|__init__)\b/g,10]],[`sql`,[/\b(SELECT|INSERT|FROM)\b/g,50]],[`pl`,[/#!(\/usr)?\/bin\/perl/g,500],[/\b(use|print)\b|\$/g,10]],[`lua`,[/#!(\/usr)?\/bin\/lua/g,500]],[`make`,[/\b(ifneq|endif|if|elif|then|fi|echo|.PHONY|^[a-z]+ ?:$)\b|\$/gm,10]],[`uri`,[/https?:|mailto:|tel:|ftp:/g,30]],[`css`,[/^(@import|@page|@media|(\.|#)[a-z]+)/gm,20]],[`diff`,[/^[+><-]/gm,10],[/^@@ ?[-+,0-9 ]+ ?@@/gm,25]],[`md`,[/^(>|\t\*|\t\d+.)/gm,10],[/\[.*\](.*)/g,10]],[`docker`,[/^(FROM|ENTRYPOINT|RUN)/gm,500]],[`xml`,[/<\/?[a-z-]+[^\n>]*>/g,10],[/^<\?xml/g,500]],[`c`,[/#include\b|\bprintf\s+\(/g,100]],[`rs`,[/^\s+(use|fn|mut|match)\b/gm,100]],[`go`,[/\b(func|fmt|package)\b/g,100]],[`java`,[/^import\s+java/gm,500]],[`asm`,[/^(section|global main|extern|\t(call|mov|ret))/gm,100]],[`css`,[/^(@import|@page|@media|(\.|#)[a-z]+)/gm,20]],[`json`,[/\b(true|false|null|\{})\b|\"[^"]+\":/g,10]],[`yaml`,[/^(\s+)?[a-z][a-z0-9]*:/gim,10]]],V=e=>ut.map(([t,...n])=>[t,n.reduce((t,[n,r])=>t+[...e.matchAll(n)].length*r,0)]).filter(([e,t])=>t>20).sort((e,t)=>t[1]-e[1])[0]?.[0]||`plain`}),ft={};I(ft,{default:()=>pt});var pt,mt=F(()=>{dt(),pt=[{type:`kwd`,match:/^(GET|HEAD|POST|PUT|DELETE|CONNECT|OPTIONS|TRACE|PATCH|PRI|SEARCH)\b/gm},{expand:`str`},{type:`section`,match:/\bHTTP\/[\d.]+\b/g},{expand:`num`},{type:`oper`,match:/[,;:=]/g},{type:`var`,match:/[a-zA-Z][\w-]*(?=:)/g},{match:/\n\n[^]*/g,sub:V}]}),ht={};I(ht,{default:()=>gt});var gt,_t=F(()=>{gt=[{match:/(^[ \f\t\v]*)[#;].*/gm,sub:`todo`},{type:`var`,match:/.*(?==)/g},{type:`section`,match:/^\s*\[.+\]\s*$/gm},{type:`oper`,match:/=/g},{type:`str`,match:/.*/g}]}),vt={};I(vt,{default:()=>yt});var yt,bt=F(()=>{yt=[{match:/\/\/.*\n?|\/\*((?!\*\/)[^])*(\*\/)?/g,sub:`todo`},{expand:`str`},{expand:`num`},{type:`kwd`,match:/\b(abstract|assert|boolean|break|byte|case|catch|char|class|continue|const|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|package|private|protected|public|requires|return|short|static|strictfp|super|switch|synchronized|this|throw|throws|transient|try|var|void|volatile|while)\b/g},{type:`oper`,match:/[/*+:?&|%^~=!,<>.^-]+/g},{type:`func`,match:/[a-zA-Z_][\w_]*(?=\s*\()/g},{type:`class`,match:/\b[A-Z][\w_]*\b/g}]}),xt={};I(xt,{default:()=>St});var St,Ct=F(()=>{St=[{match:/\/\*\*((?!\*\/)[^])*(\*\/)?/g,sub:`jsdoc`},{match:/\/\/.*\n?|\/\*((?!\*\/)[^])*(\*\/)?/g,sub:`todo`},{expand:`str`},{match:/`((?!`)[^]|\\[^])*`?/g,sub:`js_template_literals`},{type:`kwd`,match:/=>|\b(this|set|get|as|async|await|break|case|catch|class|const|constructor|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|if|implements|import|in|instanceof|interface|let|var|of|new|package|private|protected|public|return|static|super|switch|throw|throws|try|typeof|void|while|with|yield)\b/g},{match:/\/((?!\/)[^\r\n\\]|\\.)+\/[dgimsuy]*/g,sub:`regex`},{expand:`num`},{type:`num`,match:/\b(NaN|null|undefined|[A-Z][A-Z_]*)\b/g},{type:`bool`,match:/\b(true|false)\b/g},{type:`oper`,match:/[/*+:?&|%^~=!,<>.^-]+/g},{type:`class`,match:/\b[A-Z][\w_]*\b/g},{type:`func`,match:/[a-zA-Z$_][\w$_]*(?=\s*((\?\.)?\s*\(|=\s*(\(?[\w,{}\[\])]+\)? =>|function\b)))/g}]}),wt={};I(wt,{default:()=>Tt,type:()=>Et});var Tt,Et,Dt=F(()=>{Tt=[{match:new class{exec(e){let t=this.lastIndex,n,r=n=>{for(;++t<e.length-2;)if(e[t]==`{`)r();else if(e[t]==`}`)return};for(;t<e.length;++t)if(e[t-1]!=`\\`&&e[t]==`$`&&e[t+1]==`{`)return n=t++,r(t),this.lastIndex=t+1,{index:n,0:e.slice(n,t+1)};return null}},sub:[{type:`kwd`,match:/^\${|}$/g},{match:/(?!^\$|{)[^]+(?=}$)/g,sub:`js`}]}],Et=`str`}),Ot={};I(Ot,{default:()=>kt,type:()=>At});var kt,At,jt=F(()=>{kt=[{type:`err`,match:/\b(TODO|FIXME|DEBUG|OPTIMIZE|WARNING|XXX|BUG)\b/g},{type:`class`,match:/\bIDEA\b/g},{type:`insert`,match:/\b(CHANGED|FIX|CHANGE)\b/g},{type:`oper`,match:/\bQUESTION\b/g}],At=`cmnt`}),Mt={};I(Mt,{default:()=>Nt,type:()=>Pt});var Nt,Pt,Ft=F(()=>{jt(),Nt=[{type:`kwd`,match:/@\w+/g},{type:`class`,match:/{[\w\s|<>,.@\[\]]+}/g},{type:`var`,match:/\[[\w\s="']+\]/g},...kt],Pt=`cmnt`}),It={};I(It,{default:()=>Lt});var Lt,Rt=F(()=>{Lt=[{type:`var`,match:/(("|')((?!\2)[^\r\n\\]|\\[^])*\2|[a-zA-Z]\w*)(?=\s*:)/g},{expand:`str`},{expand:`num`},{type:`num`,match:/\bnull\b/g},{type:`bool`,match:/\b(true|false)\b/g}]}),zt={};I(zt,{default:()=>Bt});var Bt,Vt=F(()=>{dt(),Bt=[{type:`cmnt`,match:/^>.*|(=|-)\1+/gm},{type:`class`,match:/\*\*((?!\*\*).)*\*\*/g},{match:/```((?!```)[^])*\n```/g,sub:e=>({type:`kwd`,sub:[{match:/\n[^]*(?=```)/g,sub:e.split(`
|
|
9
|
-
`)[0].slice(3)||V(e)}]})},{type:`str`,match:/`[^`]*`/g},{type:`var`,match:/~~((?!~~).)*~~/g},{type:`kwd`,match:/\b_\S([^\n]*?\S)?_\b|\*\S([^\n]*?\S)?\*/g},{type:`kwd`,match:/^\s*(\*|\d+\.)\s/gm},{type:`func`,match:/\[[^\]]*]\([^)]*\)|<[^>]*>/g,sub:[{type:`oper`,match:/^\[[^\]]*]/g}]}]}),Ht={};I(Ht,{default:()=>Ut});var Ut,Wt=F(()=>{Vt(),dt(),Ut=[{type:`insert`,match:/(leanpub-start-insert)((?!leanpub-end-insert)[^])*(leanpub-end-insert)?/g,sub:[{type:`insert`,match:/leanpub-(start|end)-insert/g},{match:/(?!leanpub-start-insert)((?!leanpub-end-insert)[^])*/g,sub:V}]},{type:`deleted`,match:/(leanpub-start-delete)((?!leanpub-end-delete)[^])*(leanpub-end-delete)?/g,sub:[{type:`deleted`,match:/leanpub-(start|end)-delete/g},{match:/(?!leanpub-start-delete)((?!leanpub-end-delete)[^])*/g,sub:V}]},...Bt]}),Gt={};I(Gt,{default:()=>Kt});var Kt,qt=F(()=>{Kt=[{type:`cmnt`,match:/^#.*/gm},{expand:`strDouble`},{expand:`num`},{type:`err`,match:/\b(err(or)?|[a-z_-]*exception|warn|warning|failed|ko|invalid|not ?found|alert|fatal)\b/gi},{type:`num`,match:/\b(null|undefined)\b/gi},{type:`bool`,match:/\b(false|true|yes|no)\b/gi},{type:`oper`,match:/\.|,/g}]}),Jt={};I(Jt,{default:()=>Yt});var Yt,Xt=F(()=>{Yt=[{match:/^#!.*|--(\[(=*)\[((?!--\]\2\])[^])*--\]\2\]|.*)/g,sub:`todo`},{expand:`str`},{type:`kwd`,match:/\b(and|break|do|else|elseif|end|for|function|if|in|local|not|or|repeat|return|then|until|while)\b/g},{type:`bool`,match:/\b(true|false|nil)\b/g},{type:`oper`,match:/[+*/%^#=~<>:,.-]+/g},{expand:`num`},{type:`func`,match:/[a-z_]+(?=\s*[({])/g}]}),Zt={};I(Zt,{default:()=>Qt});var Qt,$t=F(()=>{Qt=[{match:/^\s*#.*/gm,sub:`todo`},{expand:`str`},{type:`oper`,match:/[${}()]+/g},{type:`class`,match:/.PHONY:/gm},{type:`section`,match:/^[\w.]+:/gm},{type:`kwd`,match:/\b(ifneq|endif)\b/g},{expand:`num`},{type:`var`,match:/[A-Z_]+(?=\s*=)/g},{match:/^.*$/gm,sub:`bash`}]}),en={};I(en,{default:()=>tn});var tn,nn=F(()=>{tn=[{match:/#.*/g,sub:`todo`},{type:`str`,match:/(["'])(\\[^]|(?!\1)[^])*\1?/g},{expand:`num`},{type:`kwd`,match:/\b(any|break|continue|default|delete|die|do|else|elsif|eval|for|foreach|given|goto|if|last|local|my|next|our|package|print|redo|require|return|say|state|sub|switch|undef|unless|until|use|when|while|not|and|or|xor)\b/g},{type:`oper`,match:/[-+*/%~!&<>|=?,]+/g},{type:`func`,match:/[a-z_]+(?=\s*\()/g}]}),rn={};I(rn,{default:()=>an});var an,on=F(()=>{an=[{expand:`strDouble`}]}),sn={};I(sn,{default:()=>cn});var cn,ln=F(()=>{cn=[{match:/#.*/g,sub:`todo`},{type:`str`,match:/f("""|''')(\\[^]|(?!\1)[^])*\1?|f("|')(\\[^]|(?!\3).)*\3?/gi,sub:[{type:`var`,match:/{[^{}]*}/g,sub:[{match:/(?!^{)[^]*(?=}$)/g,sub:`py`}]}]},{match:/("""|''')(\\[^]|(?!\1)[^])*\1?/g,sub:`todo`},{expand:`str`},{type:`kwd`,match:/\b(and|as|assert|break|class|continue|def|del|elif|else|except|finally|for|from|global|if|import|in|is|lambda|nonlocal|not|or|pass|raise|return|try|while|with|yield)\b/g},{type:`bool`,match:/\b(False|True|None)\b/g},{expand:`num`},{type:`func`,match:/[a-z_]\w*(?=\s*\()/gi},{type:`oper`,match:/[-/*+<>,=!&|^%]+/g},{type:`class`,match:/\b[A-Z][\w_]*\b/g}]}),un={};I(un,{default:()=>dn,type:()=>fn});var dn,fn,pn=F(()=>{dn=[{match:/^(?!\/).*/gm,sub:`todo`},{type:`num`,match:/\[((?!\])[^\\]|\\.)*\]/g},{type:`kwd`,match:/\||\^|\$|\\.|\w+($|\r|\n)/g},{type:`var`,match:/\*|\+|\{\d+,\d+\}/g}],fn=`oper`}),mn={};I(mn,{default:()=>hn});var hn,gn=F(()=>{hn=[{match:/\/\/.*\n?|\/\*((?!\*\/)[^])*(\*\/)?/g,sub:`todo`},{expand:`str`},{expand:`num`},{type:`kwd`,match:/\b(as|break|const|continue|crate|else|enum|extern|false|fn|for|if|impl|in|let|loop|match|mod|move|mut|pub|ref|return|self|Self|static|struct|super|trait|true|type|unsafe|use|where|while|async|await|dyn|abstract|become|box|do|final|macro|override|priv|typeof|unsized|virtual|yield|try)\b/g},{type:`oper`,match:/[/*+:?&|%^~=!,<>.^-]+/g},{type:`class`,match:/\b[A-Z][\w_]*\b/g},{type:`func`,match:/[a-zA-Z_][\w_]*(?=\s*!?\s*\()/g}]}),_n={};I(_n,{default:()=>vn});var vn,yn=F(()=>{vn=[{match:/--.*\n?|\/\*((?!\*\/)[^])*(\*\/)?/g,sub:`todo`},{expand:`str`},{type:`func`,match:/\b(AVG|COUNT|FIRST|FORMAT|LAST|LCASE|LEN|MAX|MID|MIN|MOD|NOW|ROUND|SUM|UCASE)(?=\s*\()/g},{type:`kwd`,match:/\b(ACTION|ADD|AFTER|ALGORITHM|ALL|ALTER|ANALYZE|ANY|APPLY|AS|ASC|AUTHORIZATION|AUTO_INCREMENT|BACKUP|BDB|BEGIN|BERKELEYDB|BIGINT|BINARY|BIT|BLOB|BOOL|BOOLEAN|BREAK|BROWSE|BTREE|BULK|BY|CALL|CASCADED?|CASE|CHAIN|CHAR(?:ACTER|SET)?|CHECK(?:POINT)?|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMNS?|COMMENT|COMMIT(?:TED)?|COMPUTE|CONNECT|CONSISTENT|CONSTRAINT|CONTAINS(?:TABLE)?|CONTINUE|CONVERT|CREATE|CROSS|CURRENT(?:_DATE|_TIME|_TIMESTAMP|_USER)?|CURSOR|CYCLE|DATA(?:BASES?)?|DATE(?:TIME)?|DAY|DBCC|DEALLOCATE|DEC|DECIMAL|DECLARE|DEFAULT|DEFINER|DELAYED|DELETE|DELIMITERS?|DENY|DESC|DESCRIBE|DETERMINISTIC|DISABLE|DISCARD|DISK|DISTINCT|DISTINCTROW|DISTRIBUTED|DO|DOUBLE|DROP|DUMMY|DUMP(?:FILE)?|DUPLICATE|ELSE(?:IF)?|ENABLE|ENCLOSED|END|ENGINE|ENUM|ERRLVL|ERRORS|ESCAPED?|EXCEPT|EXEC(?:UTE)?|EXISTS|EXIT|EXPLAIN|EXTENDED|FETCH|FIELDS|FILE|FILLFACTOR|FIRST|FIXED|FLOAT|FOLLOWING|FOR(?: EACH ROW)?|FORCE|FOREIGN|FREETEXT(?:TABLE)?|FROM|FULL|FUNCTION|GEOMETRY(?:COLLECTION)?|GLOBAL|GOTO|GRANT|GROUP|HANDLER|HASH|HAVING|HOLDLOCK|HOUR|IDENTITY(?:_INSERT|COL)?|IF|IGNORE|IMPORT|INDEX|INFILE|INNER|INNODB|INOUT|INSERT|INT|INTEGER|INTERSECT|INTERVAL|INTO|INVOKER|ISOLATION|ITERATE|JOIN|kwdS?|KILL|LANGUAGE|LAST|LEAVE|LEFT|LEVEL|LIMIT|LINENO|LINES|LINESTRING|LOAD|LOCAL|LOCK|LONG(?:BLOB|TEXT)|LOOP|MATCH(?:ED)?|MEDIUM(?:BLOB|INT|TEXT)|MERGE|MIDDLEINT|MINUTE|MODE|MODIFIES|MODIFY|MONTH|MULTI(?:LINESTRING|POINT|POLYGON)|NATIONAL|NATURAL|NCHAR|NEXT|NO|NONCLUSTERED|NULLIF|NUMERIC|OFF?|OFFSETS?|ON|OPEN(?:DATASOURCE|QUERY|ROWSET)?|OPTIMIZE|OPTION(?:ALLY)?|ORDER|OUT(?:ER|FILE)?|OVER|PARTIAL|PARTITION|PERCENT|PIVOT|PLAN|POINT|POLYGON|PRECEDING|PRECISION|PREPARE|PREV|PRIMARY|PRINT|PRIVILEGES|PROC(?:EDURE)?|PUBLIC|PURGE|QUICK|RAISERROR|READS?|REAL|RECONFIGURE|REFERENCES|RELEASE|RENAME|REPEAT(?:ABLE)?|REPLACE|REPLICATION|REQUIRE|RESIGNAL|RESTORE|RESTRICT|RETURN(?:S|ING)?|REVOKE|RIGHT|ROLLBACK|ROUTINE|ROW(?:COUNT|GUIDCOL|S)?|RTREE|RULE|SAVE(?:POINT)?|SCHEMA|SECOND|SELECT|SERIAL(?:IZABLE)?|SESSION(?:_USER)?|SET(?:USER)?|SHARE|SHOW|SHUTDOWN|SIMPLE|SMALLINT|SNAPSHOT|SOME|SONAME|SQL|START(?:ING)?|STATISTICS|STATUS|STRIPED|SYSTEM_USER|TABLES?|TABLESPACE|TEMP(?:ORARY|TABLE)?|TERMINATED|TEXT(?:SIZE)?|THEN|TIME(?:STAMP)?|TINY(?:BLOB|INT|TEXT)|TOP?|TRAN(?:SACTIONS?)?|TRIGGER|TRUNCATE|TSEQUAL|TYPES?|UNBOUNDED|UNCOMMITTED|UNDEFINED|UNION|UNIQUE|UNLOCK|UNPIVOT|UNSIGNED|UPDATE(?:TEXT)?|USAGE|USE|USER|USING|VALUES?|VAR(?:BINARY|CHAR|CHARACTER|YING)|VIEW|WAITFOR|WARNINGS|WHEN|WHERE|WHILE|WITH(?: ROLLUP|IN)?|WORK|WRITE(?:TEXT)?|YEAR)\b/g},{type:`num`,match:/\.?\d[\d.oxa-fA-F-]*|\bNULL\b/g},{type:`bool`,match:/\b(TRUE|FALSE)\b/g},{type:`oper`,match:/[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|DIV|IN|ILIKE|IS|LIKE|NOT|OR|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/g},{type:`var`,match:/@\S+/g}]}),bn={};I(bn,{default:()=>xn});var xn,Sn=F(()=>{xn=[{match:/#.*/g,sub:`todo`},{type:`str`,match:/("""|''')((?!\1)[^]|\\[^])*\1?/g},{expand:`str`},{type:`section`,match:/^\[.+\]\s*$/gm},{type:`num`,match:/\b(inf|nan)\b|\d[\d:ZT.-]*/g},{expand:`num`},{type:`bool`,match:/\b(true|false)\b/g},{type:`oper`,match:/[+,.=-]/g},{type:`var`,match:/\w+(?= \=)/g}]}),Cn={};I(Cn,{default:()=>wn});var wn,Tn=F(()=>{Ct(),wn=[{type:`type`,match:/:\s*(any|void|number|boolean|string|object|never|enum)\b/g},{type:`kwd`,match:/\b(type|namespace|typedef|interface|public|private|protected|implements|declare|abstract|readonly)\b/g},...St]}),En={};I(En,{default:()=>Dn});var Dn,On=F(()=>{Dn=[{match:/^#.*/gm,sub:`todo`},{type:`class`,match:/^\w+(?=:?)/gm},{type:`num`,match:/:\d+/g},{type:`oper`,match:/[:/&?]|\w+=/g},{type:`func`,match:/[.\w]+@|#[\w]+$/gm},{type:`var`,match:/\w+\.\w+(\.\w+)*/g}]}),kn={};I(kn,{default:()=>An});var An,jn=F(()=>{An=[{match:/#.*/g,sub:`todo`},{expand:`str`},{type:`str`,match:/(>|\|)\r?\n((\s[^\n]*)?(\r?\n|$))*/g},{type:`type`,match:/!![a-z]+/g},{type:`bool`,match:/\b(Yes|No)\b/g},{type:`oper`,match:/[+:-]/g},{expand:`num`},{type:`var`,match:/[a-zA-Z]\w*(?=:)/g}]});I({},{default:()=>H});var H,Mn=F(()=>{H={black:`\x1B[30m`,red:`\x1B[31m`,green:`\x1B[32m`,gray:`\x1B[90m`,yellow:`\x1B[33m`,blue:`\x1B[34m`,magenta:`\x1B[35m`,cyan:`\x1B[36m`,white:`\x1B[37m`}});I({},{default:()=>Nn});var Nn,Pn={};I(Pn,{default:()=>Fn});var Fn,In=F(()=>{Mn(),Fn={deleted:H.red,var:H.red,err:H.red,kwd:H.red,num:H.yellow,class:H.yellow,cmnt:H.gray,insert:H.green,str:H.green,bool:H.cyan,type:H.blue,oper:H.blue,section:H.magenta,func:H.magenta}}),Ln={num:{type:`num`,match:/(\.e?|\b)\d(e-|[\d.oxa-fA-F_])*(\.|\b)/g},str:{type:`str`,match:/(["'])(\\[^]|(?!\1)[^\r\n\\])*\1?/g},strDouble:{type:`str`,match:/"((?!")[^\r\n\\]|\\[^])*"?/g}},Rn=Te({"./languages/asm.js":()=>Promise.resolve().then(()=>(Oe(),Ee)),"./languages/bash.js":()=>Promise.resolve().then(()=>(Me(),ke)),"./languages/bf.js":()=>Promise.resolve().then(()=>(Fe(),Ne)),"./languages/c.js":()=>Promise.resolve().then(()=>(Re(),Ie)),"./languages/css.js":()=>Promise.resolve().then(()=>(Ve(),ze)),"./languages/csv.js":()=>Promise.resolve().then(()=>(We(),He)),"./languages/diff.js":()=>Promise.resolve().then(()=>(qe(),Ge)),"./languages/docker.js":()=>Promise.resolve().then(()=>(Xe(),Je)),"./languages/git.js":()=>Promise.resolve().then(()=>($e(),Ze)),"./languages/go.js":()=>Promise.resolve().then(()=>(nt(),et)),"./languages/html.js":()=>Promise.resolve().then(()=>(lt(),st)),"./languages/http.js":()=>Promise.resolve().then(()=>(mt(),ft)),"./languages/ini.js":()=>Promise.resolve().then(()=>(_t(),ht)),"./languages/java.js":()=>Promise.resolve().then(()=>(bt(),vt)),"./languages/js.js":()=>Promise.resolve().then(()=>(Ct(),xt)),"./languages/js_template_literals.js":()=>Promise.resolve().then(()=>(Dt(),wt)),"./languages/jsdoc.js":()=>Promise.resolve().then(()=>(Ft(),Mt)),"./languages/json.js":()=>Promise.resolve().then(()=>(Rt(),It)),"./languages/leanpub-md.js":()=>Promise.resolve().then(()=>(Wt(),Ht)),"./languages/log.js":()=>Promise.resolve().then(()=>(qt(),Gt)),"./languages/lua.js":()=>Promise.resolve().then(()=>(Xt(),Jt)),"./languages/make.js":()=>Promise.resolve().then(()=>($t(),Zt)),"./languages/md.js":()=>Promise.resolve().then(()=>(Vt(),zt)),"./languages/pl.js":()=>Promise.resolve().then(()=>(nn(),en)),"./languages/plain.js":()=>Promise.resolve().then(()=>(on(),rn)),"./languages/py.js":()=>Promise.resolve().then(()=>(ln(),sn)),"./languages/regex.js":()=>Promise.resolve().then(()=>(pn(),un)),"./languages/rs.js":()=>Promise.resolve().then(()=>(gn(),mn)),"./languages/sql.js":()=>Promise.resolve().then(()=>(yn(),_n)),"./languages/todo.js":()=>Promise.resolve().then(()=>(jt(),Ot)),"./languages/toml.js":()=>Promise.resolve().then(()=>(Sn(),bn)),"./languages/ts.js":()=>Promise.resolve().then(()=>(Tn(),Cn)),"./languages/uri.js":()=>Promise.resolve().then(()=>(On(),En)),"./languages/xml.js":()=>Promise.resolve().then(()=>(ot(),rt)),"./languages/yaml.js":()=>Promise.resolve().then(()=>(jn(),kn))}),zn={};async function Bn(e,t,n){try{let r,i,a={},o,s=[],c=0,l=typeof t==`string`?await(zn[t]??(zn[t]=Rn(`./languages/${t}.js`))):t,u=[...typeof t==`string`?l.default:t.sub];for(;c<e.length;){for(a.index=null,r=u.length;r-- >0;){if(i=u[r].expand?Ln[u[r].expand]:u[r],s[r]===void 0||s[r].match.index<c){if(i.match.lastIndex=c,o=i.match.exec(e),o===null){u.splice(r,1),s.splice(r,1);continue}s[r]={match:o,lastIndex:i.match.lastIndex}}s[r].match[0]&&(s[r].match.index<=a.index||a.index===null)&&(a={part:i,index:s[r].match.index,match:s[r].match[0],end:s[r].lastIndex})}if(a.index===null)break;n(e.slice(c,a.index),l.type),c=a.end,a.part.sub?await Bn(a.match,typeof a.part.sub==`string`?a.part.sub:typeof a.part.sub==`function`?a.part.sub(a.match):a.part,n):n(a.match,a.part.type)}n(e.slice(c,e.length),l.type)}catch{n(e)}}var Vn=Promise.resolve().then(()=>(In(),Pn)),Hn=async(e,t)=>{let n=``,r=(await Vn).default;return await Bn(e,t,(e,t)=>n+=t?`${r[t]??``}${e}\x1B[0m`:e),n};const Un={".js":`js`,".mjs":`js`,".cjs":`js`,".jsx":`js`,".ts":`ts`,".mts":`ts`,".cts":`ts`,".tsx":`ts`,".json":`json`,".jsonc":`json`,".md":`md`,".mdx":`md`,".css":`css`,".scss":`css`,".html":`html`,".htm":`html`,".svelte":`html`,".vue":`html`,".xml":`xml`,".svg":`xml`,".yaml":`yaml`,".yml":`yaml`,".toml":`toml`,".py":`py`,".rs":`rs`,".go":`go`,".c":`c`,".h":`c`,".cpp":`c`,".hpp":`c`,".java":`java`,".sql":`sql`,".sh":`bash`,".bash":`bash`,".zsh":`bash`,".lua":`lua`,".pl":`pl`,".pm":`pl`,".rb":`py`,".diff":`diff`,".patch":`diff`,".ini":`ini`,".cfg":`ini`,".env":`ini`,".dockerfile":`docker`,".makefile":`make`,".csv":`csv`,".log":`log`};function Wn(e){let t=n.extname(e).toLowerCase();if(t)return Un[t]||`plain`;let r=n.basename(e).toLowerCase();return r===`dockerfile`?`docker`:r===`makefile`?`make`:r===`.gitignore`||r===`.env`?`ini`:`plain`}const U=e=>e.replace(/\x1B\[\d+(?:;\d+)*m/g,``);function Gn(e,t){let n=0,r=0;for(;r<e.length&&n<t;){if(e[r]===`\x1B`&&e[r+1]===`[`){let t=e.indexOf(`m`,r);if(t!==-1){r=t+1;continue}}n++,r++}return e.slice(0,r)+`\x1B[0m`}function Kn(e){let t=[],n=new Map,r=[...e].sort((e,t)=>e.type===t.type?e.path.localeCompare(t.path,void 0,{sensitivity:`base`}):e.type===`tree`?-1:1);for(let e of r){let r=e.path.split(`/`),i={name:r[r.length-1],path:e.path,type:e.type,size:e.size||0,linkTarget:e.linkTarget||``,children:[],expanded:!1,selected:!1,depth:r.length-1};if(e.type===`tree`&&n.set(e.path,i),r.length===1)t.push(i);else{let e=r.slice(0,-1).join(`/`),a=n.get(e);if(a)a.children.push(i);else{let e=``,a=t;for(let t=0;t<r.length-1;t++){e=e?e+`/`+r[t]:r[t];let i=n.get(e);i||(i={name:r[t],path:e,type:`tree`,size:0,linkTarget:``,children:[],expanded:!1,selected:!1,depth:t},n.set(e,i),a.push(i)),a=i.children}a.push(i)}}}function i(e){e.sort((e,t)=>e.type===t.type?e.name.localeCompare(t.name,void 0,{sensitivity:`base`}):e.type===`tree`?-1:1);for(let t of e)t.children.length&&i(t.children)}i(t);function a(e){let t=0;for(let n of e)n.children.length&&(n.size=a(n.children)),t+=n.size;return t}return a(t),t}function qn(e){let t=[];function n(e,r){for(let i=0;i<e.length;i++){let a=e[i],o=i===e.length-1,s=o?`āāā `:`āāā `;t.push({node:a,prefix:r,connector:s}),a.type===`tree`&&a.expanded&&n(a.children,r+(o?` `:`ā `))}}return n(e,``),t}function W(e,t){e.selected=t;for(let n of e.children)W(n,t)}function Jn(e,t){let n=e.includes(`/`)?e.split(`/`).slice(0,-1).join(`/`):``,r=t.replace(/\/$/,``),i=(n?`${n}/${r}`:r).split(`/`),a=[];for(let e of i)e===`..`?a.pop():e!==`.`&&a.push(e);return a.join(`/`)}function G(e,t){for(let n of e){if(n.path===t)return n;if(n.children.length){let e=G(n.children,t);if(e)return e}}return null}function Yn(e){function t(e){for(let n of e)n.children.length&&(t(n.children),n.selected=n.children.every(e=>e.selected))}t(e)}function Xn(e){let t=[];function n(e){for(let r of e)r.selected?r.type===`tree`?r.children.length>0&&r.children.every(e=>e.selected)||r.children.length===0?t.push(r.path):n(r.children):t.push(r.path):r.type===`tree`&&n(r.children)}return n(e),t}function Zn(e){let t=0,n=0,r=0,i=0;function a(e){for(let o of e)o.selected&&(o.type===`tree`?n++:o.type===`symlink`?r++:(t++,i+=o.size)),o.children.length&&a(o.children)}return a(e),{files:t,folders:n,symlinks:r,size:i}}const K=e=>e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`;function Qn(t,r,i){return new Promise(a=>{let o=Kn(t);if(!o.length){a([]);return}function s(e,t,n=0){for(let r of e)r.type===`tree`&&n<=t&&(r.expanded=!0,s(r.children,t,n+1))}t.length<=30?s(o,1/0):s(o,1);let c=0,l=0,u=process.stdout,d=process.stdin,f=d.isRaw;d.setRawMode(!0),d.resume(),u.write(`\x1B[?1049h\x1B[?25l`);function p(){d.setRawMode(f??!1),d.pause(),d.removeListener(`data`,x),u.removeListener(`resize`,v),u.write(`\x1B[?25h\x1B[?1049l`)}let m=()=>{u.write(`\x1B[?25h\x1B[?1049l`)},h=()=>{p(),process.removeListener(`exit`,m),process.removeListener(`SIGINT`,h),a([]),process.exit(0)},g=!1,_=null,v=()=>{g&&_?_():y()};process.on(`exit`,m),process.on(`SIGINT`,h),u.on(`resize`,v);function y(){let e=u.rows||24,t=u.columns||80,n=Math.max(1,e-3-1-5),a=qn(o),s=c-1;s>=0?(s<l&&(l=s),s>=l+n&&(l=s-n+1)):l=0,l<0&&(l=0);let d=a.slice(l,l+n),{files:f,folders:p,symlinks:m,size:h}=Zn(o),g=`\x1B[H\x1B[2J`;g+=`\n ${r}\n\n`;let _=o.every(e=>e.selected),v=c===0,y=_?O(`ā`):E(`ā`),b=`${v?k(`>`):` `} ${y} ${E(`.`)}`;if(v){let e=Math.max(0,t-U(b).length);b=`\x1B[48;5;236m${b}${` `.repeat(e)}\x1B[49m`}g+=b+`
|
|
10
|
-
`;for(let e=0;e<d.length;e++){let n=d[e],r=l+e+1===c,i=n.node.selected?
|
|
2
|
+
import e from"node:fs";import t from"node:os";import n from"node:path";import{parseArgs as r,stripVTControlCharacters as i}from"node:util";import{spawn as a}from"node:child_process";import{once as o}from"node:events";import s from"node:fs/promises";import c from"node:process";import{fileURLToPath as l}from"node:url";import u from"node:tty";import{Readable as d}from"node:stream";import{pipeline as f}from"node:stream/promises";import p from"node:https";var m=class extends Error{constructor(...e){super(...e),this.name=`SubprocessError`,this.stdout=``,this.stderr=``}};const h=[`.exe`,`.com`],g={},_=e=>(...t)=>g[t.join(`\0`)]??=e(...t),v=_(async(...e)=>{try{return await s.access(e[0]),!0}catch{return!1}}),y=_(async(e,t,r)=>{let i=r.split(n.delimiter).filter(Boolean).map(e=>e.replace(/^"(.*)"$/,`$1`));try{await Promise.any([t,...i].flatMap(t=>h.map(r=>v(`${n.resolve(t,e)}${r}`))))}catch{return!1}return!0}),b=async(e,t)=>c.platform===`win32`&&!t.shell&&!h.some(t=>e.toLowerCase().endsWith(t))&&!await y(e,t.cwd??`.`,(c.env.PATH||c.env.Path)??``),x=e=>e.replaceAll(/([()\][%!^"`<>&|;, *?])/g,`^$1`),S=e=>x(x(`"${e.replaceAll(/(\\*)"/g,`$1$1\\"`).replace(/(\\*)$/,`$1$1`)}"`)),C=e=>/[^\w./-]/.test(e)?`'${e.replaceAll(`'`,`'\\''`)}'`:e,ee=new Set;async function w(e,t=[],r={}){let{stdin:s,stdout:u,stderr:d,stdio:f,cwd:p=`.`,env:h,...g}=r,_=p instanceof URL?l(p):n.resolve(p),v=h?{...c.env,...h}:void 0,y=f??[s,u,d],w=[e,...t].map(e=>C(i(e))).join(` `);[`node`,`node.exe`].includes(e.toLowerCase())&&(e=c.execPath,t=[...c.execArgv.filter(e=>!e.startsWith(`--inspect`)),...t]);let T={...g,stdio:y,env:v,cwd:_};await b(e,T)&&(t=t.map(e=>S(e)),e=x(e),T={...T,shell:!0}),T.shell&&t.length>0&&(e=[e,...t].join(` `),t=[]);let E=a(e,t,T);ee.add(E);let D=()=>ee.delete(E);E.once(`close`,D),E.once(`exit`,D);let O=``,k=``;E.stdout&&(E.stdout.setEncoding(`utf8`),E.stdout.on(`data`,e=>O+=e)),E.stderr&&(E.stderr.setEncoding(`utf8`),E.stderr.on(`data`,e=>k+=e)),E.once(`error`,()=>{});try{await o(E,`spawn`)}catch(e){throw Object.assign(new m(`Command failed: ${w}`,{cause:e}),{stdout:O,stderr:k})}await o(E,`close`);let A=e=>e.at(-1)===`
|
|
3
|
+
`?e.slice(0,e.at(-2)===`\r`?-2:-1):e;if(E.exitCode&&E.exitCode>0)throw Object.assign(new m(`Command failed with exit code ${E.exitCode}: ${w}`),{stdout:A(O),stderr:A(k),exitCode:E.exitCode});if(E.signalCode)throw Object.assign(new m(`Command was terminated with ${E.signalCode}: ${w}`),{stdout:A(O),stderr:A(k)});return{stdout:A(O),stderr:A(k)}}const T=u?.WriteStream?.prototype?.hasColors?.()??!1,E=(e,t)=>{if(!T)return e=>e;let n=`\u001B[${e}m`,r=`\u001B[${t}m`;return e=>{let i=e+``,a=i.indexOf(r);if(a===-1)return n+i+r;let o=n,s=0,c=(t===22?r:``)+n;for(;a!==-1;)o+=i.slice(s,a)+c,s=a+r.length,a=i.indexOf(r,s);return o+=i.slice(s)+r,o}},D=E(1,22),O=E(2,22),k=E(31,39),A=E(32,39),j=E(33,39),M=E(36,39),te=c.platform!==`win32`||!!c.env.WT_SESSION||c.env.TERM_PROGRAM===`vscode`,ne=e=>!!(e.isTTY&&c.env.TERM!==`dumb`&&!(`CI`in c.env)),re=A(te?`ā`:`ā`),ie=te?[`ā `,`ā `,`ā ¹`,`ā ø`,`ā ¼`,`ā “`,`ā ¦`,`ā §`,`ā `,`ā `]:[`-`,`\\`,`|`,`/`],ae=(e={})=>{let t=-1,n,r=e.text??``,a=e.stream??c.stderr,o=ne(a),s=0,l=0,u=!1,d=e=>a.write(e),f=()=>{if(!(!o||s===0)){a.cursorTo(0);for(let e=0;e<s;e++)e>0&&a.moveCursor(0,-1),a.clearLine(1);s=0}},p=e=>{let t=a.columns??80,n=i(e).split(`
|
|
4
|
+
`),r=0;for(let e of n)r+=Math.max(1,Math.ceil(e.length/t));return r},m=()=>{if(!o)return;let e=Date.now();(t===-1||e-l>=80)&&(t=++t%ie.length,l=e);let n=ie[t],i=`${M(n)} ${r}`;f(),d(i),s=p(i)};return{start(e){return r=e,u=!0,o&&d(`\x1B[?25l`),m(),o&&(n=setInterval(m,80)),this},success(e){return u?(u=!1,n&&=(clearInterval(n),void 0),f(),o&&d(`\x1B[?25h`),d(`${re} ${e??r}\n`),this):this}}},N=new Set;function oe(){for(let e of ee)try{e.kill(`SIGKILL`)}catch{}for(let t of N)try{e.rmSync(t,{recursive:!0,force:!0})}catch{}process.exit(1)}process.on(`SIGINT`,oe),process.on(`SIGTERM`,oe);const se=e=>/[.+^${}()|[\]\\]/.test(e)?`\\${e}`:e,ce=e=>{let t=``,n=0;for(;n<e.length;){let r=e[n];if(r===`*`)if(e[n+1]===`*`){let r=n===0||e[n-1]===`/`;n+=2;let i=e[n]===`/`;r&&i?(t+=`(?:.*/)?`,n+=1):t+=`.*`}else t+=`[^/]*`,n+=1;else r===`?`?(t+=`[^/]`,n+=1):r===`/`?(t+=`/`,n+=1):(t+=se(r),n+=1)}return t},le=e=>{let t=e.trim();if(!t||t.startsWith(`#`))return null;let n=!1;t.startsWith(`!`)&&(n=!0,t=t.slice(1));let r=!1;t.endsWith(`/`)&&(r=!0,t=t.replace(/\/+$/,``));let i=!1;if(t.startsWith(`/`)?(i=!0,t=t.replace(/^\/+/,``)):t.includes(`/`)&&(i=!0),!t)return null;let a=ce(t),o=i?`^${a}$`:`^(?:.*/)?${a}$`;return{negated:n,dirOnly:r,regex:new RegExp(o)}},ue=e=>{let t=[];for(let n of e.split(/\r?\n/)){let e=le(n);e&&t.push(e)}return{ignores(e,r){let i=e.split(n.sep).join(`/`);if(!i||i===`.`)return!1;let a=!1;for(let e of t)e.dirOnly&&!r||e.regex.test(i)&&(a=!e.negated);return a}}},de=t=>{let r;try{r=e.readFileSync(n.join(t,`.gitpickignore`),`utf8`)}catch{return null}return ue(r)},fe=e=>({matcher:de(e),srcRoot:e}),pe=async(t,r,i,a)=>{let o=i??r,s=a??fe(t),c=await e.promises.readdir(t,{withFileTypes:!0});await e.promises.mkdir(r,{recursive:!0});let l=[];for(let i of c){if(i.name===`.git`)continue;let a=n.join(t,i.name),c=n.join(r,i.name),u=n.relative(s.srcRoot,a);if(u!==`.gitpickignore`&&!s.matcher?.ignores(u,i.isDirectory()))if(i.isDirectory())l.push(...await pe(a,c,o,s));else if(i.isSymbolicLink()){let t=await e.promises.readlink(a);await e.promises.rm(c,{force:!0,recursive:!0}),await e.promises.symlink(t,c),l.push(n.relative(o,c))}else await e.promises.copyFile(a,c),l.push(n.relative(o,c))}return l},P=e=>Number(((performance.now()-e)/1e3).toFixed(2)),F=e=>`${e}${Date.now()}${Math.random().toString(16).slice(2,6)}`,me=e=>e.split(`/`).map(encodeURIComponent).join(`/`),he=e=>{let{host:t,owner:n,repository:r,branch:i,path:a}=e;if(!a)return null;let o=`${encodeURIComponent(n)}/${encodeURIComponent(r)}`,s=me(i),c=me(a);switch(t){case`github.com`:return`https://raw.githubusercontent.com/${o}/${s}/${c}`;case`gitlab.com`:return`https://gitlab.com/${o}/-/raw/${s}/${c}`;case`codeberg.org`:return`https://codeberg.org/${o}/raw/${s}/${c}`;default:return null}},ge=async(t,r)=>{let i=he(t);if(!i)return null;let a=performance.now(),o;try{o=await fetch(i)}catch{return null}if(!o.ok||!o.body)return null;let s=P(a),c=performance.now(),l=`${r}.${F(`gitpick-`)}.part`;N.add(l);try{await e.promises.mkdir(n.dirname(r),{recursive:!0}),await f(d.fromWeb(o.body),e.createWriteStream(l)),await e.promises.rename(l,r)}catch{return await e.promises.rm(l,{force:!0}),null}finally{N.delete(l)}let u=P(c),{size:p}=await e.promises.stat(r);return{size:p,networkTime:s,copyTime:u}},_e=(e,t)=>{for(let n=t.length;n>=1;n--){let r=t.slice(0,n).join(`/`);if(e.has(r))return{branch:r,path:t.slice(n).join(`/`)}}return null},ve=async e=>{let{stdout:t}=await w(`git`,[`for-each-ref`,`--format=%(refname)`,`refs/heads`,`refs/remotes/origin`,`refs/tags`],{cwd:e}),n=new Set;for(let e of t.split(`
|
|
5
|
+
`)){let t=e.trim();if(t.startsWith(`refs/heads/`))n.add(t.slice(11));else if(t.startsWith(`refs/remotes/origin/`)){let e=t.slice(20);e!==`HEAD`&&n.add(e)}else t.startsWith(`refs/tags/`)&&n.add(t.slice(10))}return n},ye=async e=>{let{stdout:t}=await w(`git`,[`ls-remote`,`--heads`,`--tags`,e]),n=new Set;for(let e of t.split(`
|
|
6
|
+
`)){let t=e.split(` `)[1]?.trim();t&&(t.startsWith(`refs/heads/`)?n.add(t.slice(11)):t.startsWith(`refs/tags/`)&&n.add(t.slice(10).replace(/\^\{\}$/,``)))}return n},be=async(e,t)=>t.length?_e(await ve(e),t):null,xe=async(e,t)=>t.length?_e(await ye(e),t):null,Se=async e=>{try{return await w(`git`,[`symbolic-ref`,`-q`,`HEAD`],{cwd:e}),!1}catch{return!0}},Ce=async(e,t)=>{if(t.refSegments?.length){let n=await be(e,t.refSegments);n&&(t.branch=n.branch,t.path=n.path)}await w(`git`,[`checkout`,t.branch],{cwd:e})},we=async(e,t,n,r)=>{let i=r?[`--recursive`]:[];try{return await w(`git`,[`clone`,e,t,`--branch`,n.branch,`--depth`,`1`,`--single-branch`,...i]),`shallow`}catch{return await w(`git`,[`clone`,e,t,...i]),await Ce(t,n),`full`}},Te=async(t,r,i,a,o)=>{if(o===`full`||!i.refSegments||i.refSegments.length<=1||e.existsSync(n.join(r,i.path))||!await Se(r))return null;let s=await xe(t,i.refSegments);return!s||s.branch===i.branch?null:(i.branch=s.branch,i.path=s.path,await e.promises.rm(r,{recursive:!0,force:!0}),we(t,r,i,a))},Ee=e=>e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`,De={raw:`raw (single GET)`,shallow:`shallow (depth=1)`,full:`full (depth=full)`},I=async(r,i,a)=>{let o=i.tree||i.quiet,s=i.verbose&&!o;process.platform===`win32`&&await w(`git`,[`config`,`--global`,`core.longpaths`,`true`]);let c=`https://${r.host}/${r.owner}/${r.repository}.git`,l=ae(),u=performance.now();!i.watch&&!o&&l.start(`Picking ${r.type}${r.type===`repository`?` without .git`:` from repository`}...`);let d=(e,t,n,d,f)=>{let p=P(u);return o||(i.watch?console.log(`- Synced at `+new Date().toLocaleTimeString()):l.success(`Picked ${r.type}${r.type===`repository`?` without .git`:` from repository`} in ${p} seconds.`)),s&&(console.log(O(` clone: ${De[f]??f}`)),console.log(O(` from: ${c} @ ${M(r.branch)}`)),console.log(O(` to: ${a}`)),console.log(O(` files: ${e.length} (${Ee(t)})`)),console.log(O(` network: ${n}s`)),console.log(O(` copy: ${d}s`)),console.log(O(` total: ${p}s`))),{files:e,duration:p,networkTime:n,copyTime:d,totalSize:t,cloneStrategy:f}};if(r.type===`blob`||r.type===`raw`){let e=await ge(r,a);if(e)return d([n.basename(a)],e.size,e.networkTime,e.copyTime,`raw`)}let f=`https://${r.token?r.token+`@`:r.token}${r.host}/${r.owner}/${r.repository}.git`,p=n.resolve(t.tmpdir(),F(`${r.repository}-`));N.add(p);let m=performance.now(),h=await we(f,p,r,i.recursive),g=await Te(f,p,r,i.recursive,h);g&&(h=g);let _=P(m),v=n.resolve(p,r.path),y=await e.promises.stat(v),b=[],x=performance.now();y.isDirectory()?(await e.promises.mkdir(a,{recursive:!0}),b=await pe(v,a)):(await e.promises.mkdir(n.dirname(a),{recursive:!0}),await e.promises.copyFile(v,a),b=[n.basename(a)]);let S=P(x),C=0;for(let t of b)try{let r=await e.promises.stat(n.join(a,t));C+=r.size}catch{let t=await e.promises.stat(a);C+=t.size;break}return await e.promises.rm(p,{recursive:!0,force:!0}),N.delete(p),d(b,C,_,S,h)},Oe=e=>e?.stderr?.trim()||e?.stdout?.trim()||e?.message||`git failed`,ke=async(r,i,a)=>{let o=!!i.autoCommit||i.commit!==void 0;if(!i.init&&!o)return;let s=i.quiet,c=e.existsSync(r)&&e.statSync(r).isFile(),l=c?n.dirname(r):r;if(n.resolve(l)===process.cwd()){s||console.log(j(`
|
|
7
|
+
Skipping git init: won't initialize a repository in the current directory (clone into a sub-directory to init there).`));return}if(!e.existsSync(n.join(l,`.git`)))try{await w(`git`,[`init`],{cwd:l})}catch(e){s||console.log(j(`\nSkipping git init ā git reported:\n${Oe(e)}`));return}if(!o)return;if(!c&&!a?.length){s||console.log(j(`
|
|
8
|
+
Skipping commit: nothing was cloned to commit.`));return}let u=i.commit||`chore: gitpick'ed`;try{if(c)await w(`git`,[`add`,`--force`,`--`,n.basename(r)],{cwd:l});else{let r=(a??[]).map(e=>e.split(n.sep).join(`/`)),i=n.join(t.tmpdir(),F(`gitpick-add-`));await e.promises.writeFile(i,r.join(`\0`));try{await w(`git`,[`add`,`--force`,`--pathspec-from-file=${i}`,`--pathspec-file-nul`],{cwd:l})}catch{await w(`git`,[`add`,`--force`,`--`,...r],{cwd:l})}finally{await e.promises.rm(i,{force:!0})}}await w(`git`,[`commit`,`-m`,u],{cwd:l})}catch(e){s||console.log(j(`\nSkipping commit ā git reported:\n${Oe(e)}`))}};var Ae=Object.defineProperty,je=e=>t=>{var n=e[t];if(n)return n();throw Error(`Module not found in bundle: `+t)},L=(e,t)=>()=>(e&&(t=e(e=0)),t),R=(e,t)=>{for(var n in t)Ae(e,n,{get:t[n],enumerable:!0})},Me={};R(Me,{default:()=>Ne});var Ne,Pe=L(()=>{Ne=[{type:`cmnt`,match:/(;|#).*/gm},{expand:`str`},{expand:`num`},{type:`num`,match:/\$[\da-fA-F]*\b/g},{type:`kwd`,match:/^[a-z]+\s+[a-z.]+\b/gm,sub:[{type:`func`,match:/^[a-z]+/g}]},{type:`kwd`,match:/^\t*[a-z][a-z\d]*\b/gm},{match:/%|\$/g,type:`oper`}]}),Fe={};R(Fe,{default:()=>Le});var Ie,Le,Re=L(()=>{Ie={type:`var`,match:/\$\w+|\${[^}]*}|\$\([^)]*\)/g},Le=[{sub:`todo`,match:/#.*/g},{type:`str`,match:/(["'])((?!\1)[^\r\n\\]|\\[^])*\1?/g,sub:[Ie]},{type:`oper`,match:/(?<=\s|^)\.*\/[a-z/_.-]+/gi},{type:`kwd`,match:/\s-[a-zA-Z]+|$<|[&|;]+|\b(unset|readonly|shift|export|if|fi|else|elif|while|do|done|for|until|case|esac|break|continue|exit|return|trap|wait|eval|exec|then|declare|enable|local|select|typeset|time|add|remove|install|update|delete)(?=\s|$)/g},{expand:`num`},{type:`func`,match:/(?<=(^|\||\&\&|\;)\s*)[a-z_.-]+(?=\s|$)/gim},{type:`bool`,match:/(?<=\s|^)(true|false)(?=\s|$)/g},{type:`oper`,match:/[=(){}<>!]+/g},{type:`var`,match:/(?<=\s|^)[\w_]+(?=\s*=)/g},Ie]}),ze={};R(ze,{default:()=>Be});var Be,Ve=L(()=>{Be=[{match:/[^\[\->+.<\]\s].*/g,sub:`todo`},{type:`func`,match:/\.+/g},{type:`kwd`,match:/[<>]+/g},{type:`oper`,match:/[+-]+/g}]}),He={};R(He,{default:()=>Ue});var Ue,We=L(()=>{Ue=[{match:/\/\/.*\n?|\/\*((?!\*\/)[^])*(\*\/)?/g,sub:`todo`},{expand:`str`},{expand:`num`},{type:`kwd`,match:/#\s*include (<.*>|".*")/g,sub:[{type:`str`,match:/(<|").*/g}]},{match:/asm\s*{[^}]*}/g,sub:[{type:`kwd`,match:/^asm/g},{match:/[^{}]*(?=}$)/g,sub:`asm`}]},{type:`kwd`,match:/\*|&|#[a-z]+\b|\b(asm|auto|double|int|struct|break|else|long|switch|case|enum|register|typedef|char|extern|return|union|const|float|short|unsigned|continue|for|signed|void|default|goto|sizeof|volatile|do|if|static|while)\b/g},{type:`oper`,match:/[/*+:?&|%^~=!,<>.^-]+/g},{type:`func`,match:/[a-zA-Z_][\w_]*(?=\s*\()/g},{type:`class`,match:/\b[A-Z][\w_]*\b/g}]}),Ge={};R(Ge,{default:()=>Ke});var Ke,qe=L(()=>{Ke=[{match:/\/\*((?!\*\/)[^])*(\*\/)?/g,sub:`todo`},{expand:`str`},{type:`kwd`,match:/@\w+\b|\b(and|not|only|or)\b|\b[a-z-]+(?=[^{}]*{)/g},{type:`var`,match:/\b[\w-]+(?=\s*:)|(::?|\.)[\w-]+(?=[^{}]*{)/g},{type:`func`,match:/#[\w-]+(?=[^{}]*{)/g},{type:`num`,match:/#[\da-f]{3,8}/g},{type:`num`,match:/\d+(\.\d+)?(cm|mm|in|px|pt|pc|em|ex|ch|rem|vm|vh|vmin|vmax|%)?/g,sub:[{type:`var`,match:/[a-z]+|%/g}]},{match:/url\([^)]*\)/g,sub:[{type:`func`,match:/url(?=\()/g},{type:`str`,match:/[^()]+/g}]},{type:`func`,match:/\b[a-zA-Z]\w*(?=\s*\()/g},{type:`num`,match:/\b[a-z-]+\b/g}]}),Je={};R(Je,{default:()=>Ye});var Ye,Xe=L(()=>{Ye=[{expand:`strDouble`},{type:`oper`,match:/,/g}]}),Ze={};R(Ze,{default:()=>Qe});var Qe,$e=L(()=>{Qe=[{type:`deleted`,match:/^[-<].*/gm},{type:`insert`,match:/^[+>].*/gm},{type:`kwd`,match:/!.*/gm},{type:`section`,match:/^@@.*@@$|^\d.*|^([*-+])\1\1.*/gm}]}),et={};R(et,{default:()=>tt});var tt,nt=L(()=>{Re(),tt=[{type:`kwd`,match:/^(FROM|RUN|CMD|LABEL|MAINTAINER|EXPOSE|ENV|ADD|COPY|ENTRYPOINT|VOLUME|USER|WORKDIR|ARG|ONBUILD|STOPSIGNAL|HEALTHCHECK|SHELL)\b/gim},...Le]}),rt={};R(rt,{default:()=>it});var it,at=L(()=>{$e(),it=[{match:/^#.*/gm,sub:`todo`},{expand:`str`},...Qe,{type:`func`,match:/^(\$ )?git(\s.*)?$/gm},{type:`kwd`,match:/^commit \w+$/gm}]}),ot={};R(ot,{default:()=>st});var st,ct=L(()=>{st=[{match:/\/\/.*\n?|\/\*((?!\*\/)[^])*(\*\/)?/g,sub:`todo`},{expand:`str`},{expand:`num`},{type:`kwd`,match:/\*|&|\b(break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go|goto|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/g},{type:`func`,match:/[a-zA-Z_][\w_]*(?=\s*\()/g},{type:`class`,match:/\b[A-Z][\w_]*\b/g},{type:`oper`,match:/[+\-*\/%&|^~=!<>.^-]+/g}]}),lt={};R(lt,{default:()=>ft,name:()=>z,properties:()=>B,xmlElement:()=>V});var ut,dt,z,B,V,ft,pt=L(()=>{ut=`:A-Z_a-zĆ-ĆĆ-öø-˿Ͱ-ͽͿ-įææā-āā°-āā°-⿯ć-ķæļ¤-ļ·ļ·°-ļæ½`,dt=ut+`\\-\\.0-9Ā·Ģ-ĶÆāæ-ā`,z=`[${ut}][${dt}]*`,B=`\\s*(\\s+${z}\\s*(=\\s*([^"']\\S*|("|')(\\\\[^]|(?!\\4)[^])*\\4?)?)?\\s*)*`,V={match:RegExp(`<[/!?]?${z}${B}[/!?]?>`,`g`),sub:[{type:`var`,match:RegExp(`^<[/!?]?${z}`,`g`),sub:[{type:`oper`,match:/^<[\/!?]?/g}]},{type:`str`,match:/=\s*([^"']\S*|("|')(\\[^]|(?!\2)[^])*\2?)/g,sub:[{type:`oper`,match:/^=/g}]},{type:`oper`,match:/[\/!?]?>/g},{type:`class`,match:RegExp(z,`g`)}]},ft=[{match:/<!--((?!-->)[^])*-->/g,sub:`todo`},{type:`class`,match:/<!\[CDATA\[[\s\S]*?\]\]>/gi},V,{type:`str`,match:RegExp(`<\\?${z}([^?]|\\?[^?>])*\\?+>`,`g`),sub:[{type:`var`,match:RegExp(`^<\\?${z}`,`g`),sub:[{type:`oper`,match:/^<\?/g}]},{type:`oper`,match:/\?+>$/g}]},{type:`var`,match:/&(#x?)?[\da-z]{1,8};/gi}]}),mt={};R(mt,{default:()=>ht});var ht,gt=L(()=>{pt(),ht=[{type:`class`,match:/<!DOCTYPE("[^"]*"|'[^']*'|[^"'>])*>/gi,sub:[{type:`str`,match:/"[^"]*"|'[^']*'/g},{type:`oper`,match:/^<!|>$/g},{type:`var`,match:/DOCTYPE/gi}]},{match:RegExp(`<style${B}>((?!</style>)[^])*</style\\s*>`,`g`),sub:[{match:RegExp(`^<style${B}>`,`g`),sub:V.sub},{match:RegExp(`${V.match}|[^]*(?=</style\\s*>$)`,`g`),sub:`css`},V]},{match:RegExp(`<script${B}>((?!<\/script>)[^])*<\/script\\s*>`,`g`),sub:[{match:RegExp(`^<script${B}>`,`g`),sub:V.sub},{match:RegExp(`${V.match}|[^]*(?=<\/script\\s*>$)`,`g`),sub:`js`},V]},...ft]}),_t,H,vt=L(()=>{_t=[[`bash`,[/#!(\/usr)?\/bin\/bash/g,500],[/\b(if|elif|then|fi|echo)\b|\$/g,10]],[`html`,[/<\/?[a-z-]+[^\n>]*>/g,10],[/^\s+<!DOCTYPE\s+html/g,500]],[`http`,[/^(GET|HEAD|POST|PUT|DELETE|PATCH|HTTP)\b/g,500]],[`js`,[/\b(console|await|async|function|export|import|this|class|for|let|const|map|join|require|document|window)\b/g,10]],[`ts`,[/\b(console|await|async|function|export|import|this|class|for|let|const|map|join|require|document|window|implements|interface|namespace)\b/g,10]],[`py`,[/\b(def|print|await|async|class|and|or|lambda|import|from|self|asyncio|pass|True|False|None|__init__)\b/g,10]],[`sql`,[/\b(SELECT|INSERT|FROM)\b/g,50]],[`pl`,[/#!(\/usr)?\/bin\/perl/g,500],[/\b(use|print)\b|\$/g,10]],[`lua`,[/#!(\/usr)?\/bin\/lua/g,500]],[`make`,[/\b(ifneq|endif|if|elif|then|fi|echo|.PHONY|^[a-z]+ ?:$)\b|\$/gm,10]],[`uri`,[/https?:|mailto:|tel:|ftp:/g,30]],[`css`,[/^(@import|@page|@media|(\.|#)[a-z]+)/gm,20]],[`diff`,[/^[+><-]/gm,10],[/^@@ ?[-+,0-9 ]+ ?@@/gm,25]],[`md`,[/^(>|\t\*|\t\d+.)/gm,10],[/\[.*\](.*)/g,10]],[`docker`,[/^(FROM|ENTRYPOINT|RUN)/gm,500]],[`xml`,[/<\/?[a-z-]+[^\n>]*>/g,10],[/^<\?xml/g,500]],[`c`,[/#include\b|\bprintf\s+\(/g,100]],[`rs`,[/^\s+(use|fn|mut|match)\b/gm,100]],[`go`,[/\b(func|fmt|package)\b/g,100]],[`java`,[/^import\s+java/gm,500]],[`asm`,[/^(section|global main|extern|\t(call|mov|ret))/gm,100]],[`css`,[/^(@import|@page|@media|(\.|#)[a-z]+)/gm,20]],[`json`,[/\b(true|false|null|\{})\b|\"[^"]+\":/g,10]],[`yaml`,[/^(\s+)?[a-z][a-z0-9]*:/gim,10]]],H=e=>_t.map(([t,...n])=>[t,n.reduce((t,[n,r])=>t+[...e.matchAll(n)].length*r,0)]).filter(([e,t])=>t>20).sort((e,t)=>t[1]-e[1])[0]?.[0]||`plain`}),yt={};R(yt,{default:()=>bt});var bt,xt=L(()=>{vt(),bt=[{type:`kwd`,match:/^(GET|HEAD|POST|PUT|DELETE|CONNECT|OPTIONS|TRACE|PATCH|PRI|SEARCH)\b/gm},{expand:`str`},{type:`section`,match:/\bHTTP\/[\d.]+\b/g},{expand:`num`},{type:`oper`,match:/[,;:=]/g},{type:`var`,match:/[a-zA-Z][\w-]*(?=:)/g},{match:/\n\n[^]*/g,sub:H}]}),St={};R(St,{default:()=>Ct});var Ct,wt=L(()=>{Ct=[{match:/(^[ \f\t\v]*)[#;].*/gm,sub:`todo`},{type:`var`,match:/.*(?==)/g},{type:`section`,match:/^\s*\[.+\]\s*$/gm},{type:`oper`,match:/=/g},{type:`str`,match:/.*/g}]}),Tt={};R(Tt,{default:()=>Et});var Et,Dt=L(()=>{Et=[{match:/\/\/.*\n?|\/\*((?!\*\/)[^])*(\*\/)?/g,sub:`todo`},{expand:`str`},{expand:`num`},{type:`kwd`,match:/\b(abstract|assert|boolean|break|byte|case|catch|char|class|continue|const|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|package|private|protected|public|requires|return|short|static|strictfp|super|switch|synchronized|this|throw|throws|transient|try|var|void|volatile|while)\b/g},{type:`oper`,match:/[/*+:?&|%^~=!,<>.^-]+/g},{type:`func`,match:/[a-zA-Z_][\w_]*(?=\s*\()/g},{type:`class`,match:/\b[A-Z][\w_]*\b/g}]}),Ot={};R(Ot,{default:()=>kt});var kt,At=L(()=>{kt=[{match:/\/\*\*((?!\*\/)[^])*(\*\/)?/g,sub:`jsdoc`},{match:/\/\/.*\n?|\/\*((?!\*\/)[^])*(\*\/)?/g,sub:`todo`},{expand:`str`},{match:/`((?!`)[^]|\\[^])*`?/g,sub:`js_template_literals`},{type:`kwd`,match:/=>|\b(this|set|get|as|async|await|break|case|catch|class|const|constructor|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|if|implements|import|in|instanceof|interface|let|var|of|new|package|private|protected|public|return|static|super|switch|throw|throws|try|typeof|void|while|with|yield)\b/g},{match:/\/((?!\/)[^\r\n\\]|\\.)+\/[dgimsuy]*/g,sub:`regex`},{expand:`num`},{type:`num`,match:/\b(NaN|null|undefined|[A-Z][A-Z_]*)\b/g},{type:`bool`,match:/\b(true|false)\b/g},{type:`oper`,match:/[/*+:?&|%^~=!,<>.^-]+/g},{type:`class`,match:/\b[A-Z][\w_]*\b/g},{type:`func`,match:/[a-zA-Z$_][\w$_]*(?=\s*((\?\.)?\s*\(|=\s*(\(?[\w,{}\[\])]+\)? =>|function\b)))/g}]}),jt={};R(jt,{default:()=>Mt,type:()=>Nt});var Mt,Nt,Pt=L(()=>{Mt=[{match:new class{exec(e){let t=this.lastIndex,n,r=n=>{for(;++t<e.length-2;)if(e[t]==`{`)r();else if(e[t]==`}`)return};for(;t<e.length;++t)if(e[t-1]!=`\\`&&e[t]==`$`&&e[t+1]==`{`)return n=t++,r(t),this.lastIndex=t+1,{index:n,0:e.slice(n,t+1)};return null}},sub:[{type:`kwd`,match:/^\${|}$/g},{match:/(?!^\$|{)[^]+(?=}$)/g,sub:`js`}]}],Nt=`str`}),Ft={};R(Ft,{default:()=>It,type:()=>Lt});var It,Lt,Rt=L(()=>{It=[{type:`err`,match:/\b(TODO|FIXME|DEBUG|OPTIMIZE|WARNING|XXX|BUG)\b/g},{type:`class`,match:/\bIDEA\b/g},{type:`insert`,match:/\b(CHANGED|FIX|CHANGE)\b/g},{type:`oper`,match:/\bQUESTION\b/g}],Lt=`cmnt`}),zt={};R(zt,{default:()=>Bt,type:()=>Vt});var Bt,Vt,Ht=L(()=>{Rt(),Bt=[{type:`kwd`,match:/@\w+/g},{type:`class`,match:/{[\w\s|<>,.@\[\]]+}/g},{type:`var`,match:/\[[\w\s="']+\]/g},...It],Vt=`cmnt`}),Ut={};R(Ut,{default:()=>Wt});var Wt,Gt=L(()=>{Wt=[{type:`var`,match:/(("|')((?!\2)[^\r\n\\]|\\[^])*\2|[a-zA-Z]\w*)(?=\s*:)/g},{expand:`str`},{expand:`num`},{type:`num`,match:/\bnull\b/g},{type:`bool`,match:/\b(true|false)\b/g}]}),Kt={};R(Kt,{default:()=>qt});var qt,Jt=L(()=>{vt(),qt=[{type:`cmnt`,match:/^>.*|(=|-)\1+/gm},{type:`class`,match:/\*\*((?!\*\*).)*\*\*/g},{match:/```((?!```)[^])*\n```/g,sub:e=>({type:`kwd`,sub:[{match:/\n[^]*(?=```)/g,sub:e.split(`
|
|
9
|
+
`)[0].slice(3)||H(e)}]})},{type:`str`,match:/`[^`]*`/g},{type:`var`,match:/~~((?!~~).)*~~/g},{type:`kwd`,match:/\b_\S([^\n]*?\S)?_\b|\*\S([^\n]*?\S)?\*/g},{type:`kwd`,match:/^\s*(\*|\d+\.)\s/gm},{type:`func`,match:/\[[^\]]*]\([^)]*\)|<[^>]*>/g,sub:[{type:`oper`,match:/^\[[^\]]*]/g}]}]}),Yt={};R(Yt,{default:()=>Xt});var Xt,Zt=L(()=>{Jt(),vt(),Xt=[{type:`insert`,match:/(leanpub-start-insert)((?!leanpub-end-insert)[^])*(leanpub-end-insert)?/g,sub:[{type:`insert`,match:/leanpub-(start|end)-insert/g},{match:/(?!leanpub-start-insert)((?!leanpub-end-insert)[^])*/g,sub:H}]},{type:`deleted`,match:/(leanpub-start-delete)((?!leanpub-end-delete)[^])*(leanpub-end-delete)?/g,sub:[{type:`deleted`,match:/leanpub-(start|end)-delete/g},{match:/(?!leanpub-start-delete)((?!leanpub-end-delete)[^])*/g,sub:H}]},...qt]}),Qt={};R(Qt,{default:()=>$t});var $t,en=L(()=>{$t=[{type:`cmnt`,match:/^#.*/gm},{expand:`strDouble`},{expand:`num`},{type:`err`,match:/\b(err(or)?|[a-z_-]*exception|warn|warning|failed|ko|invalid|not ?found|alert|fatal)\b/gi},{type:`num`,match:/\b(null|undefined)\b/gi},{type:`bool`,match:/\b(false|true|yes|no)\b/gi},{type:`oper`,match:/\.|,/g}]}),tn={};R(tn,{default:()=>nn});var nn,rn=L(()=>{nn=[{match:/^#!.*|--(\[(=*)\[((?!--\]\2\])[^])*--\]\2\]|.*)/g,sub:`todo`},{expand:`str`},{type:`kwd`,match:/\b(and|break|do|else|elseif|end|for|function|if|in|local|not|or|repeat|return|then|until|while)\b/g},{type:`bool`,match:/\b(true|false|nil)\b/g},{type:`oper`,match:/[+*/%^#=~<>:,.-]+/g},{expand:`num`},{type:`func`,match:/[a-z_]+(?=\s*[({])/g}]}),an={};R(an,{default:()=>on});var on,sn=L(()=>{on=[{match:/^\s*#.*/gm,sub:`todo`},{expand:`str`},{type:`oper`,match:/[${}()]+/g},{type:`class`,match:/.PHONY:/gm},{type:`section`,match:/^[\w.]+:/gm},{type:`kwd`,match:/\b(ifneq|endif)\b/g},{expand:`num`},{type:`var`,match:/[A-Z_]+(?=\s*=)/g},{match:/^.*$/gm,sub:`bash`}]}),cn={};R(cn,{default:()=>ln});var ln,un=L(()=>{ln=[{match:/#.*/g,sub:`todo`},{type:`str`,match:/(["'])(\\[^]|(?!\1)[^])*\1?/g},{expand:`num`},{type:`kwd`,match:/\b(any|break|continue|default|delete|die|do|else|elsif|eval|for|foreach|given|goto|if|last|local|my|next|our|package|print|redo|require|return|say|state|sub|switch|undef|unless|until|use|when|while|not|and|or|xor)\b/g},{type:`oper`,match:/[-+*/%~!&<>|=?,]+/g},{type:`func`,match:/[a-z_]+(?=\s*\()/g}]}),dn={};R(dn,{default:()=>fn});var fn,pn=L(()=>{fn=[{expand:`strDouble`}]}),mn={};R(mn,{default:()=>hn});var hn,gn=L(()=>{hn=[{match:/#.*/g,sub:`todo`},{type:`str`,match:/f("""|''')(\\[^]|(?!\1)[^])*\1?|f("|')(\\[^]|(?!\3).)*\3?/gi,sub:[{type:`var`,match:/{[^{}]*}/g,sub:[{match:/(?!^{)[^]*(?=}$)/g,sub:`py`}]}]},{match:/("""|''')(\\[^]|(?!\1)[^])*\1?/g,sub:`todo`},{expand:`str`},{type:`kwd`,match:/\b(and|as|assert|break|class|continue|def|del|elif|else|except|finally|for|from|global|if|import|in|is|lambda|nonlocal|not|or|pass|raise|return|try|while|with|yield)\b/g},{type:`bool`,match:/\b(False|True|None)\b/g},{expand:`num`},{type:`func`,match:/[a-z_]\w*(?=\s*\()/gi},{type:`oper`,match:/[-/*+<>,=!&|^%]+/g},{type:`class`,match:/\b[A-Z][\w_]*\b/g}]}),_n={};R(_n,{default:()=>vn,type:()=>yn});var vn,yn,bn=L(()=>{vn=[{match:/^(?!\/).*/gm,sub:`todo`},{type:`num`,match:/\[((?!\])[^\\]|\\.)*\]/g},{type:`kwd`,match:/\||\^|\$|\\.|\w+($|\r|\n)/g},{type:`var`,match:/\*|\+|\{\d+,\d+\}/g}],yn=`oper`}),xn={};R(xn,{default:()=>Sn});var Sn,Cn=L(()=>{Sn=[{match:/\/\/.*\n?|\/\*((?!\*\/)[^])*(\*\/)?/g,sub:`todo`},{expand:`str`},{expand:`num`},{type:`kwd`,match:/\b(as|break|const|continue|crate|else|enum|extern|false|fn|for|if|impl|in|let|loop|match|mod|move|mut|pub|ref|return|self|Self|static|struct|super|trait|true|type|unsafe|use|where|while|async|await|dyn|abstract|become|box|do|final|macro|override|priv|typeof|unsized|virtual|yield|try)\b/g},{type:`oper`,match:/[/*+:?&|%^~=!,<>.^-]+/g},{type:`class`,match:/\b[A-Z][\w_]*\b/g},{type:`func`,match:/[a-zA-Z_][\w_]*(?=\s*!?\s*\()/g}]}),wn={};R(wn,{default:()=>Tn});var Tn,En=L(()=>{Tn=[{match:/--.*\n?|\/\*((?!\*\/)[^])*(\*\/)?/g,sub:`todo`},{expand:`str`},{type:`func`,match:/\b(AVG|COUNT|FIRST|FORMAT|LAST|LCASE|LEN|MAX|MID|MIN|MOD|NOW|ROUND|SUM|UCASE)(?=\s*\()/g},{type:`kwd`,match:/\b(ACTION|ADD|AFTER|ALGORITHM|ALL|ALTER|ANALYZE|ANY|APPLY|AS|ASC|AUTHORIZATION|AUTO_INCREMENT|BACKUP|BDB|BEGIN|BERKELEYDB|BIGINT|BINARY|BIT|BLOB|BOOL|BOOLEAN|BREAK|BROWSE|BTREE|BULK|BY|CALL|CASCADED?|CASE|CHAIN|CHAR(?:ACTER|SET)?|CHECK(?:POINT)?|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMNS?|COMMENT|COMMIT(?:TED)?|COMPUTE|CONNECT|CONSISTENT|CONSTRAINT|CONTAINS(?:TABLE)?|CONTINUE|CONVERT|CREATE|CROSS|CURRENT(?:_DATE|_TIME|_TIMESTAMP|_USER)?|CURSOR|CYCLE|DATA(?:BASES?)?|DATE(?:TIME)?|DAY|DBCC|DEALLOCATE|DEC|DECIMAL|DECLARE|DEFAULT|DEFINER|DELAYED|DELETE|DELIMITERS?|DENY|DESC|DESCRIBE|DETERMINISTIC|DISABLE|DISCARD|DISK|DISTINCT|DISTINCTROW|DISTRIBUTED|DO|DOUBLE|DROP|DUMMY|DUMP(?:FILE)?|DUPLICATE|ELSE(?:IF)?|ENABLE|ENCLOSED|END|ENGINE|ENUM|ERRLVL|ERRORS|ESCAPED?|EXCEPT|EXEC(?:UTE)?|EXISTS|EXIT|EXPLAIN|EXTENDED|FETCH|FIELDS|FILE|FILLFACTOR|FIRST|FIXED|FLOAT|FOLLOWING|FOR(?: EACH ROW)?|FORCE|FOREIGN|FREETEXT(?:TABLE)?|FROM|FULL|FUNCTION|GEOMETRY(?:COLLECTION)?|GLOBAL|GOTO|GRANT|GROUP|HANDLER|HASH|HAVING|HOLDLOCK|HOUR|IDENTITY(?:_INSERT|COL)?|IF|IGNORE|IMPORT|INDEX|INFILE|INNER|INNODB|INOUT|INSERT|INT|INTEGER|INTERSECT|INTERVAL|INTO|INVOKER|ISOLATION|ITERATE|JOIN|kwdS?|KILL|LANGUAGE|LAST|LEAVE|LEFT|LEVEL|LIMIT|LINENO|LINES|LINESTRING|LOAD|LOCAL|LOCK|LONG(?:BLOB|TEXT)|LOOP|MATCH(?:ED)?|MEDIUM(?:BLOB|INT|TEXT)|MERGE|MIDDLEINT|MINUTE|MODE|MODIFIES|MODIFY|MONTH|MULTI(?:LINESTRING|POINT|POLYGON)|NATIONAL|NATURAL|NCHAR|NEXT|NO|NONCLUSTERED|NULLIF|NUMERIC|OFF?|OFFSETS?|ON|OPEN(?:DATASOURCE|QUERY|ROWSET)?|OPTIMIZE|OPTION(?:ALLY)?|ORDER|OUT(?:ER|FILE)?|OVER|PARTIAL|PARTITION|PERCENT|PIVOT|PLAN|POINT|POLYGON|PRECEDING|PRECISION|PREPARE|PREV|PRIMARY|PRINT|PRIVILEGES|PROC(?:EDURE)?|PUBLIC|PURGE|QUICK|RAISERROR|READS?|REAL|RECONFIGURE|REFERENCES|RELEASE|RENAME|REPEAT(?:ABLE)?|REPLACE|REPLICATION|REQUIRE|RESIGNAL|RESTORE|RESTRICT|RETURN(?:S|ING)?|REVOKE|RIGHT|ROLLBACK|ROUTINE|ROW(?:COUNT|GUIDCOL|S)?|RTREE|RULE|SAVE(?:POINT)?|SCHEMA|SECOND|SELECT|SERIAL(?:IZABLE)?|SESSION(?:_USER)?|SET(?:USER)?|SHARE|SHOW|SHUTDOWN|SIMPLE|SMALLINT|SNAPSHOT|SOME|SONAME|SQL|START(?:ING)?|STATISTICS|STATUS|STRIPED|SYSTEM_USER|TABLES?|TABLESPACE|TEMP(?:ORARY|TABLE)?|TERMINATED|TEXT(?:SIZE)?|THEN|TIME(?:STAMP)?|TINY(?:BLOB|INT|TEXT)|TOP?|TRAN(?:SACTIONS?)?|TRIGGER|TRUNCATE|TSEQUAL|TYPES?|UNBOUNDED|UNCOMMITTED|UNDEFINED|UNION|UNIQUE|UNLOCK|UNPIVOT|UNSIGNED|UPDATE(?:TEXT)?|USAGE|USE|USER|USING|VALUES?|VAR(?:BINARY|CHAR|CHARACTER|YING)|VIEW|WAITFOR|WARNINGS|WHEN|WHERE|WHILE|WITH(?: ROLLUP|IN)?|WORK|WRITE(?:TEXT)?|YEAR)\b/g},{type:`num`,match:/\.?\d[\d.oxa-fA-F-]*|\bNULL\b/g},{type:`bool`,match:/\b(TRUE|FALSE)\b/g},{type:`oper`,match:/[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|DIV|IN|ILIKE|IS|LIKE|NOT|OR|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/g},{type:`var`,match:/@\S+/g}]}),Dn={};R(Dn,{default:()=>On});var On,kn=L(()=>{On=[{match:/#.*/g,sub:`todo`},{type:`str`,match:/("""|''')((?!\1)[^]|\\[^])*\1?/g},{expand:`str`},{type:`section`,match:/^\[.+\]\s*$/gm},{type:`num`,match:/\b(inf|nan)\b|\d[\d:ZT.-]*/g},{expand:`num`},{type:`bool`,match:/\b(true|false)\b/g},{type:`oper`,match:/[+,.=-]/g},{type:`var`,match:/\w+(?= \=)/g}]}),An={};R(An,{default:()=>jn});var jn,Mn=L(()=>{At(),jn=[{type:`type`,match:/:\s*(any|void|number|boolean|string|object|never|enum)\b/g},{type:`kwd`,match:/\b(type|namespace|typedef|interface|public|private|protected|implements|declare|abstract|readonly)\b/g},...kt]}),Nn={};R(Nn,{default:()=>Pn});var Pn,Fn=L(()=>{Pn=[{match:/^#.*/gm,sub:`todo`},{type:`class`,match:/^\w+(?=:?)/gm},{type:`num`,match:/:\d+/g},{type:`oper`,match:/[:/&?]|\w+=/g},{type:`func`,match:/[.\w]+@|#[\w]+$/gm},{type:`var`,match:/\w+\.\w+(\.\w+)*/g}]}),In={};R(In,{default:()=>Ln});var Ln,Rn=L(()=>{Ln=[{match:/#.*/g,sub:`todo`},{expand:`str`},{type:`str`,match:/(>|\|)\r?\n((\s[^\n]*)?(\r?\n|$))*/g},{type:`type`,match:/!![a-z]+/g},{type:`bool`,match:/\b(Yes|No)\b/g},{type:`oper`,match:/[+:-]/g},{expand:`num`},{type:`var`,match:/[a-zA-Z]\w*(?=:)/g}]});R({},{default:()=>U});var U,zn=L(()=>{U={black:`\x1B[30m`,red:`\x1B[31m`,green:`\x1B[32m`,gray:`\x1B[90m`,yellow:`\x1B[33m`,blue:`\x1B[34m`,magenta:`\x1B[35m`,cyan:`\x1B[36m`,white:`\x1B[37m`}});R({},{default:()=>Bn});var Bn,Vn={};R(Vn,{default:()=>Hn});var Hn,Un=L(()=>{zn(),Hn={deleted:U.red,var:U.red,err:U.red,kwd:U.red,num:U.yellow,class:U.yellow,cmnt:U.gray,insert:U.green,str:U.green,bool:U.cyan,type:U.blue,oper:U.blue,section:U.magenta,func:U.magenta}}),Wn={num:{type:`num`,match:/(\.e?|\b)\d(e-|[\d.oxa-fA-F_])*(\.|\b)/g},str:{type:`str`,match:/(["'])(\\[^]|(?!\1)[^\r\n\\])*\1?/g},strDouble:{type:`str`,match:/"((?!")[^\r\n\\]|\\[^])*"?/g}},Gn=je({"./languages/asm.js":()=>Promise.resolve().then(()=>(Pe(),Me)),"./languages/bash.js":()=>Promise.resolve().then(()=>(Re(),Fe)),"./languages/bf.js":()=>Promise.resolve().then(()=>(Ve(),ze)),"./languages/c.js":()=>Promise.resolve().then(()=>(We(),He)),"./languages/css.js":()=>Promise.resolve().then(()=>(qe(),Ge)),"./languages/csv.js":()=>Promise.resolve().then(()=>(Xe(),Je)),"./languages/diff.js":()=>Promise.resolve().then(()=>($e(),Ze)),"./languages/docker.js":()=>Promise.resolve().then(()=>(nt(),et)),"./languages/git.js":()=>Promise.resolve().then(()=>(at(),rt)),"./languages/go.js":()=>Promise.resolve().then(()=>(ct(),ot)),"./languages/html.js":()=>Promise.resolve().then(()=>(gt(),mt)),"./languages/http.js":()=>Promise.resolve().then(()=>(xt(),yt)),"./languages/ini.js":()=>Promise.resolve().then(()=>(wt(),St)),"./languages/java.js":()=>Promise.resolve().then(()=>(Dt(),Tt)),"./languages/js.js":()=>Promise.resolve().then(()=>(At(),Ot)),"./languages/js_template_literals.js":()=>Promise.resolve().then(()=>(Pt(),jt)),"./languages/jsdoc.js":()=>Promise.resolve().then(()=>(Ht(),zt)),"./languages/json.js":()=>Promise.resolve().then(()=>(Gt(),Ut)),"./languages/leanpub-md.js":()=>Promise.resolve().then(()=>(Zt(),Yt)),"./languages/log.js":()=>Promise.resolve().then(()=>(en(),Qt)),"./languages/lua.js":()=>Promise.resolve().then(()=>(rn(),tn)),"./languages/make.js":()=>Promise.resolve().then(()=>(sn(),an)),"./languages/md.js":()=>Promise.resolve().then(()=>(Jt(),Kt)),"./languages/pl.js":()=>Promise.resolve().then(()=>(un(),cn)),"./languages/plain.js":()=>Promise.resolve().then(()=>(pn(),dn)),"./languages/py.js":()=>Promise.resolve().then(()=>(gn(),mn)),"./languages/regex.js":()=>Promise.resolve().then(()=>(bn(),_n)),"./languages/rs.js":()=>Promise.resolve().then(()=>(Cn(),xn)),"./languages/sql.js":()=>Promise.resolve().then(()=>(En(),wn)),"./languages/todo.js":()=>Promise.resolve().then(()=>(Rt(),Ft)),"./languages/toml.js":()=>Promise.resolve().then(()=>(kn(),Dn)),"./languages/ts.js":()=>Promise.resolve().then(()=>(Mn(),An)),"./languages/uri.js":()=>Promise.resolve().then(()=>(Fn(),Nn)),"./languages/xml.js":()=>Promise.resolve().then(()=>(pt(),lt)),"./languages/yaml.js":()=>Promise.resolve().then(()=>(Rn(),In))}),Kn={};async function qn(e,t,n){try{let r,i,a={},o,s=[],c=0,l=typeof t==`string`?await(Kn[t]??(Kn[t]=Gn(`./languages/${t}.js`))):t,u=[...typeof t==`string`?l.default:t.sub];for(;c<e.length;){for(a.index=null,r=u.length;r-- >0;){if(i=u[r].expand?Wn[u[r].expand]:u[r],s[r]===void 0||s[r].match.index<c){if(i.match.lastIndex=c,o=i.match.exec(e),o===null){u.splice(r,1),s.splice(r,1);continue}s[r]={match:o,lastIndex:i.match.lastIndex}}s[r].match[0]&&(s[r].match.index<=a.index||a.index===null)&&(a={part:i,index:s[r].match.index,match:s[r].match[0],end:s[r].lastIndex})}if(a.index===null)break;n(e.slice(c,a.index),l.type),c=a.end,a.part.sub?await qn(a.match,typeof a.part.sub==`string`?a.part.sub:typeof a.part.sub==`function`?a.part.sub(a.match):a.part,n):n(a.match,a.part.type)}n(e.slice(c,e.length),l.type)}catch{n(e)}}var Jn=Promise.resolve().then(()=>(Un(),Vn)),Yn=async(e,t)=>{let n=``,r=(await Jn).default;return await qn(e,t,(e,t)=>n+=t?`${r[t]??``}${e}\x1B[0m`:e),n};const Xn={".js":`js`,".mjs":`js`,".cjs":`js`,".jsx":`js`,".ts":`ts`,".mts":`ts`,".cts":`ts`,".tsx":`ts`,".json":`json`,".jsonc":`json`,".md":`md`,".mdx":`md`,".css":`css`,".scss":`css`,".html":`html`,".htm":`html`,".svelte":`html`,".vue":`html`,".xml":`xml`,".svg":`xml`,".yaml":`yaml`,".yml":`yaml`,".toml":`toml`,".py":`py`,".rs":`rs`,".go":`go`,".c":`c`,".h":`c`,".cpp":`c`,".hpp":`c`,".java":`java`,".sql":`sql`,".sh":`bash`,".bash":`bash`,".zsh":`bash`,".lua":`lua`,".pl":`pl`,".pm":`pl`,".rb":`py`,".diff":`diff`,".patch":`diff`,".ini":`ini`,".cfg":`ini`,".env":`ini`,".dockerfile":`docker`,".makefile":`make`,".csv":`csv`,".log":`log`};function Zn(e){let t=n.extname(e).toLowerCase();if(t)return Xn[t]||`plain`;let r=n.basename(e).toLowerCase();return r===`dockerfile`?`docker`:r===`makefile`?`make`:r===`.gitignore`||r===`.env`?`ini`:`plain`}const W=e=>e.replace(/\x1B\[\d+(?:;\d+)*m/g,``);function Qn(e,t){let n=0,r=0;for(;r<e.length&&n<t;){if(e[r]===`\x1B`&&e[r+1]===`[`){let t=e.indexOf(`m`,r);if(t!==-1){r=t+1;continue}}n++,r++}return e.slice(0,r)+`\x1B[0m`}function $n(e){let t=[],n=new Map,r=[...e].sort((e,t)=>e.type===t.type?e.path.localeCompare(t.path,void 0,{sensitivity:`base`}):e.type===`tree`?-1:1);for(let e of r){let r=e.path.split(`/`),i={name:r[r.length-1],path:e.path,type:e.type,size:e.size||0,linkTarget:e.linkTarget||``,children:[],expanded:!1,selected:!1,depth:r.length-1};if(e.type===`tree`&&n.set(e.path,i),r.length===1)t.push(i);else{let e=r.slice(0,-1).join(`/`),a=n.get(e);if(a)a.children.push(i);else{let e=``,a=t;for(let t=0;t<r.length-1;t++){e=e?e+`/`+r[t]:r[t];let i=n.get(e);i||(i={name:r[t],path:e,type:`tree`,size:0,linkTarget:``,children:[],expanded:!1,selected:!1,depth:t},n.set(e,i),a.push(i)),a=i.children}a.push(i)}}}function i(e){e.sort((e,t)=>e.type===t.type?e.name.localeCompare(t.name,void 0,{sensitivity:`base`}):e.type===`tree`?-1:1);for(let t of e)t.children.length&&i(t.children)}i(t);function a(e){let t=0;for(let n of e)n.children.length&&(n.size=a(n.children)),t+=n.size;return t}return a(t),t}function er(e){let t=[];function n(e,r){for(let i=0;i<e.length;i++){let a=e[i],o=i===e.length-1,s=o?`āāā `:`āāā `;t.push({node:a,prefix:r,connector:s}),a.type===`tree`&&a.expanded&&n(a.children,r+(o?` `:`ā `))}}return n(e,``),t}function G(e,t){e.selected=t;for(let n of e.children)G(n,t)}function tr(e,t){let n=e.includes(`/`)?e.split(`/`).slice(0,-1).join(`/`):``,r=t.replace(/\/$/,``),i=(n?`${n}/${r}`:r).split(`/`),a=[];for(let e of i)e===`..`?a.pop():e!==`.`&&a.push(e);return a.join(`/`)}function K(e,t){for(let n of e){if(n.path===t)return n;if(n.children.length){let e=K(n.children,t);if(e)return e}}return null}function nr(e){function t(e){for(let n of e)n.children.length&&(t(n.children),n.selected=n.children.every(e=>e.selected))}t(e)}function rr(e){let t=[];function n(e){for(let r of e)r.selected?r.type===`tree`?r.children.length>0&&r.children.every(e=>e.selected)||r.children.length===0?t.push(r.path):n(r.children):t.push(r.path):r.type===`tree`&&n(r.children)}return n(e),t}function ir(e){let t=0,n=0,r=0,i=0;function a(e){for(let o of e)o.selected&&(o.type===`tree`?n++:o.type===`symlink`?r++:(t++,i+=o.size)),o.children.length&&a(o.children)}return a(e),{files:t,folders:n,symlinks:r,size:i}}const q=e=>e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`;function ar(t,r,i){return new Promise(a=>{let o=$n(t);if(!o.length){a([]);return}function s(e,t,n=0){for(let r of e)r.type===`tree`&&n<=t&&(r.expanded=!0,s(r.children,t,n+1))}t.length<=30?s(o,1/0):s(o,1);let c=0,l=0,u=process.stdout,d=process.stdin,f=d.isRaw;d.setRawMode(!0),d.resume(),u.write(`\x1B[?1049h\x1B[?25l`);function p(){d.setRawMode(f??!1),d.pause(),d.removeListener(`data`,x),u.removeListener(`resize`,v),u.write(`\x1B[?25h\x1B[?1049l`)}let m=()=>{u.write(`\x1B[?25h\x1B[?1049l`)},h=()=>{p(),process.removeListener(`exit`,m),process.removeListener(`SIGINT`,h),a([]),process.exit(0)},g=!1,_=null,v=()=>{g&&_?_():y()};process.on(`exit`,m),process.on(`SIGINT`,h),u.on(`resize`,v);function y(){let e=u.rows||24,t=u.columns||80,n=Math.max(1,e-3-1-5),a=er(o),s=c-1;s>=0?(s<l&&(l=s),s>=l+n&&(l=s-n+1)):l=0,l<0&&(l=0);let d=a.slice(l,l+n),{files:f,folders:p,symlinks:m,size:h}=ir(o),g=`\x1B[H\x1B[2J`;g+=`\n ${r}\n\n`;let _=o.every(e=>e.selected),v=c===0,y=_?A(`ā`):O(`ā`),b=`${v?j(`>`):` `} ${y} ${O(`.`)}`;if(v){let e=Math.max(0,t-W(b).length);b=`\x1B[48;5;236m${b}${` `.repeat(e)}\x1B[49m`}g+=b+`
|
|
10
|
+
`;for(let e=0;e<d.length;e++){let n=d[e],r=l+e+1===c,i=n.node.selected?A(`ā`):O(`ā`),a=n.node.type===`tree`?M(n.node.name+`/`):n.node.type===`symlink`?j(n.node.name)+O(` -> `)+(n.node.linkTarget.endsWith(`/`)?M(n.node.linkTarget):n.node.linkTarget):n.node.name,o=n.node.type===`tree`?n.node.expanded?O(`ā¾ `):O(`āø `):` `,s=`${r?j(`>`):` `} ${i} ${O(n.prefix)}${O(n.connector)}${o}${a}`,u=n.node.size>0&&n.node.type!==`symlink`?O(q(n.node.size)):``,f=W(s).length,p=W(u).length,m=Math.max(1,t-f-p-1),h=u?`${s}${` `.repeat(m)}${u} `:s;if(r){let e=Math.max(0,t-W(h).length);h=`\x1B[48;5;236m${h}${` `.repeat(e)}\x1B[49m`}g+=h+`
|
|
11
11
|
`}for(let e=d.length;e<n;e++)g+=`
|
|
12
12
|
`;g+=`
|
|
13
|
-
`;let x=a.length>n?
|
|
13
|
+
`;let x=a.length>n?O(` ⢠${l+1}-${Math.min(l+n,a.length)}/${a.length}`):``,S;if(_)S=` all selected ${O(`ā¢`)} ${O(q(h))}${x}`;else if(f+p+m>0){let e=[];p>0&&e.push(M(`${p} folder${p===1?``:`s`}`)),f>0&&e.push(`${f} file${f===1?``:`s`}`),m>0&&e.push(j(`${m} symlink${m===1?``:`s`}`)),S=` ${[e.join(` `),O(q(h))].join(O(` ⢠`))}${x}`}else S=O(` press . to select all`)+x;g+=S+`
|
|
14
14
|
`,g+=`
|
|
15
|
-
`;let C=
|
|
16
|
-
`),v=String(f.length).length;function b(){let e=u.rows||24,n=u.columns||80,r=Math.max(1,e-3-3);c<l&&(l=c),c>=l+r&&(l=c-r+1),l<0&&(l=0);let i=`\x1B[H\x1B[2J`,a=t.type===`symlink`?
|
|
15
|
+
`;let C=O(i?`āā:navigate enter:expand/preview space:select c:confirm q:quit`:`āā:navigate enter:expand space:select c:confirm q:quit`);g+=` ${C}\n`,u.write(g)}async function b(t){d.removeListener(`data`,x);let r=t.type===`symlink`?tr(t.path,t.linkTarget):t.path,o=n.join(i,r),s;try{let n=e.statSync(o);if(n.isDirectory())s=O(`(directory)`);else if(n.size>512*1024)s=O(`(file too large: ${q(n.size)})`);else{let r=e.readFileSync(o);if(r.includes(0))s=O(`(binary file: ${q(n.size)})`);else{let e=r.toString(`utf-8`),n=Zn(t.name);if(n!==`plain`)try{s=await Yn(e,n)}catch{s=e}else s=e}}}catch{s=O(`(unable to read file)`)}let c=0,l=0,f=s.split(`
|
|
16
|
+
`),v=String(f.length).length;function b(){let e=u.rows||24,n=u.columns||80,r=Math.max(1,e-3-3);c<l&&(l=c),c>=l+r&&(l=c-r+1),l<0&&(l=0);let i=`\x1B[H\x1B[2J`,a=t.type===`symlink`?j(t.path)+O(` -> `)+t.linkTarget:t.path;i+=`\n ${D(a)} ${O(`ā¢`)} ${O(q(t.size))}\n\n`;let o=Math.min(r,f.length-l);for(let e=0;e<o;e++){let t=l+e,r=t===c,a=`${O(` ${String(t+1).padStart(v)} `)}${Qn(f[t],n-v-5)}`;if(r){let e=a.replace(/\x1B\[0m/g,``),t=Math.max(0,n-W(e).length);a=`\x1B[48;5;236m${e}${` `.repeat(t)}\x1B[0m`}i+=a+`
|
|
17
17
|
`}for(let e=o;e<r;e++)i+=`
|
|
18
18
|
`;i+=`
|
|
19
|
-
`;let s=f.length>r?
|
|
20
|
-
`){s++,n=!1,i+=
|
|
21
|
-
`)n=!1,i+=
|
|
22
|
-
`&&(i+=e.slice(r,s),r=s,o=-1))}let s=n===
|
|
23
|
-
With ${
|
|
19
|
+
`;let s=f.length>r?O(`${l+1}-${Math.min(l+r,f.length)}/${f.length}`)+O(` ⢠`):``,d=O(`āā:navigate esc/q:back`);i+=` ${s}${d}\n`,u.write(i)}function S(e){let t=e.toString();if(t===``){g=!1,_=null,d.removeListener(`data`,S),p(),process.removeListener(`exit`,m),process.removeListener(`SIGINT`,h),a([]);return}if(t===`\x1B`||t===`q`||t===`Q`||t===`\r`){g=!1,_=null,d.removeListener(`data`,S),d.on(`data`,x),y();return}(t===`\x1B[A`||t===`k`)&&c>0&&c--,(t===`\x1B[B`||t===`j`)&&c<f.length-1&&c++,b()}g=!0,_=b,d.on(`data`,S),b()}function x(e){let t=er(o),n=t.length+1,r=e.toString();if(r===``||r===`q`||r===`Q`){p(),process.removeListener(`exit`,m),process.removeListener(`SIGINT`,h),a([]);return}if(r===`c`||r===`C`){p(),process.removeListener(`exit`,m),process.removeListener(`SIGINT`,h),a(rr(o));return}if((r===`\x1B[A`||r===`k`)&&c>0&&c--,(r===`\x1B[B`||r===`j`)&&c<n-1&&c++,c===0&&(r===` `||r===`\r`)||r===`.`){let e=o.every(e=>e.selected);for(let t of o)G(t,!e)}if(r===` `&&c>0){let e=t[c-1];if(e){let t=!e.node.selected;if(G(e.node,t),t&&e.node.type===`symlink`&&e.node.linkTarget){let t=K(o,tr(e.node.path,e.node.linkTarget));t&&G(t,!0)}nr(o)}}if(r===`\r`&&c>0){let e=t[c-1];if(e&&e.node.type===`tree`)e.node.expanded=!e.node.expanded;else if(e&&e.node.type===`symlink`&&e.node.linkTarget.endsWith(`/`)){let t=tr(e.node.path,e.node.linkTarget),n=t.split(`/`);for(let e=1;e<=n.length;e++){let t=K(o,n.slice(0,e).join(`/`));t&&t.type===`tree`&&(t.expanded=!0)}let r=K(o,t);if(r){r.type===`tree`&&(r.expanded=!0);let e=er(o).findIndex(e=>e.node===r);e>=0&&(c=e+1)}}else if(e&&i&&(e.node.type===`blob`||e.node.type===`symlink`)){b(e.node);return}}if((r===`\x1B[C`||r===`l`)&&c>0){let e=t[c-1];e&&e.node.type===`tree`&&(e.node.expanded=!0)}if((r===`\x1B[D`||r===`h`)&&c>0){let e=t[c-1];e&&e.node.type===`tree`&&(e.node.expanded=!1)}y()}d.on(`data`,x),y()})}function or(e){if(typeof e==`number`||/^\d+$/.test(e))return typeof e==`number`?e:parseInt(e,10);let t=/(\d+)([hms])/g,n=0,r;for(;(r=t.exec(e))!==null;){let e=parseInt(r[1],10);switch(r[2]){case`h`:n+=e*36e5;break;case`m`:n+=e*6e4;break;case`s`:n+=e*1e3;break}}return n}const J=async e=>{let t=(await w(`git`,[`ls-remote`,e])).stdout,n=t.match(/(.+)\s+HEAD/)?.[1],r=t.match(RegExp(`${n}\\s+refs/heads/(.+)`))?.[1];if(!r)throw Error(`Could not determine default branch!`);return r},sr=[{prefix:`git@github.com:`,host:`github.com`},{prefix:`https://github.com/`,host:`github.com`},{prefix:`https://raw.githubusercontent.com/`,host:`github.com`},{prefix:`git@gitlab.com:`,host:`gitlab.com`},{prefix:`https://gitlab.com/`,host:`gitlab.com`},{prefix:`git@bitbucket.org:`,host:`bitbucket.org`},{prefix:`https://bitbucket.org/`,host:`bitbucket.org`},{prefix:`git@codeberg.org:`,host:`codeberg.org`},{prefix:`https://codeberg.org/`,host:`codeberg.org`}];async function cr(e,{branch:t,target:n}){let r=e.match(/^https:\/\/([^@]+)@(github\.com|gitlab\.com|bitbucket\.org|codeberg\.org)/),i=``;if(r)i=r[1],e=e.replace(`${r[1]}@`,``);else{let t={"github.com":process.env.GITHUB_TOKEN||process.env.GH_TOKEN||``,"gitlab.com":process.env.GITLAB_TOKEN||``,"bitbucket.org":process.env.BITBUCKET_TOKEN||``,"codeberg.org":process.env.CODEBERG_TOKEN||``};for(let{prefix:n,host:r}of sr)if(e.startsWith(n)){i=t[r];break}!i&&!e.startsWith(`https://`)&&!e.startsWith(`git@`)&&(i=t[`github.com`])}let a=`github.com`;for(let{prefix:t,host:n}of sr)if(e.startsWith(t)){a=n,e=e.replace(t,``);break}let o=e.split(`/`),s=o[0],c=o[1]?.endsWith(`.git`)?o[1].slice(0,-4):o[1],l=`https://${i&&i+`@`}${a}/${s}/${c}`,u,d,f;if(a===`github.com`)o[2]===`refs`&&[`heads`,`tags`].includes(o[3])?(u=`raw`,d=t||o[4],f=o.slice(5).join(`/`)):o[2]===`refs`&&o[3]===`remotes`?(u=`raw`,d=t||`${o[4]}/${o[5]}`,f=o.slice(6).join(`/`)):o[2]===`blob`?(u=`blob`,d=t||o[3],f=o.slice(4).join(`/`)):o[2]===`tree`?(u=`tree`,d=t||o[3],f=o.slice(4).join(`/`)):o[2]===`commit`?(u=`repository`,d=t||o[3],f=``):(u=`repository`,d=t||await J(l),f=``);else if(a===`gitlab.com`)o[2]===`-`&&o[3]===`blob`?(u=`blob`,d=t||o[4],f=o.slice(5).join(`/`)):o[2]===`-`&&o[3]===`tree`?(u=`tree`,d=t||o[4],f=o.slice(5).join(`/`)):(u=`repository`,d=t||await J(l),f=``);else if(a===`bitbucket.org`)o[2]===`src`?(u=`tree`,d=t||o[3],f=o.slice(4).join(`/`)):(u=`repository`,d=t||await J(l),f=``);else if(a===`codeberg.org`)[`src`,`raw`,`media`].includes(o[2])&&[`branch`,`tag`,`commit`].includes(o[3])?(u=o[2]===`src`?`tree`:`blob`,d=t||o[4],f=o.slice(5).join(`/`)):(u=`repository`,d=t||await J(l),f=``);else{let e=a;throw Error(`Unsupported host: ${e}`)}let p=n||(u===`blob`?`.`:f.split(`/`).pop()||c),m=!t&&(u===`tree`||u===`blob`)?[d,...f?f.split(`/`):[]]:void 0;return{token:i,host:a,owner:s,repository:c,type:u,branch:d,path:f,target:p,refSegments:m}}const lr=n.join(t.homedir(),`.cache`,`gitpick`),ur=n.join(lr,`update-check.json`);function dr(){try{return JSON.parse(e.readFileSync(ur,`utf-8`))}catch{return null}}function fr(t){try{e.mkdirSync(lr,{recursive:!0}),e.writeFileSync(ur,JSON.stringify(t))}catch{}}function pr(){return new Promise(e=>{let t=p.get(`https://registry.npmjs.org/gitpick/latest`,{headers:{Accept:`application/json`},timeout:3e3},t=>{if(t.statusCode!==200)return t.resume(),e(null);let n=``;t.on(`data`,e=>n+=e),t.on(`end`,()=>{try{e(JSON.parse(n).version||null)}catch{e(null)}})});t.on(`error`,()=>e(null)),t.on(`timeout`,()=>{t.destroy(),e(null)})})}function mr(e,t){let n=e.split(`.`).map(Number),r=t.split(`.`).map(Number);for(let e=0;e<3;e++){if((n[e]||0)>(r[e]||0))return!0;if((n[e]||0)<(r[e]||0))return!1}return!1}function Y(e,t){if(t)return;let n=dr();n&&mr(n.latestVersion,e)&&console.log(O(`\n Update available: ${j(e)} ā ${M(D(n.latestVersion))}\n Run ${M(`npm i -g gitpick`)} to update\n`))}function hr(){let e=dr();e&&Date.now()-e.lastCheck<864e5||setTimeout(async()=>{let e=await pr();e&&fr({lastCheck:Date.now(),latestVersion:e})},0)}const X=Symbol(`singleComment`),gr=Symbol(`multiComment`),Z=(e,t,n)=>e.slice(t,n).replace(/[^ \t\r\n]/g,` `),_r=(e,t)=>{let n=t-1,r=0;for(;e[n]===`\\`;)--n,r+=1;return!!(r%2)};function vr(e){if(typeof e!=`string`)throw TypeError(`Expected argument \`jsonString\` to be a \`string\`, got \`${typeof e}\``);let t=!1,n=!1,r=0,i=``,a=``,o=-1;for(let s=0;s<e.length;s++){let c=e[s],l=e[s+1];if(!n&&c===`"`&&(_r(e,s)||(t=!t)),!t)if(!n&&c+l===`//`)i+=e.slice(r,s),r=s,n=X,s++;else if(n===X&&c+l===`\r
|
|
20
|
+
`){s++,n=!1,i+=Z(e,r,s),r=s;continue}else if(n===X&&c===`
|
|
21
|
+
`)n=!1,i+=Z(e,r,s),r=s;else if(!n&&c+l===`/*`){i+=e.slice(r,s),r=s,n=gr,s++;continue}else if(n===gr&&c+l===`*/`){s++,n=!1,i+=Z(e,r,s+1),r=s+1;continue}else n||(o===-1?c===`,`&&(a+=i+e.slice(r,s),i=``,r=s,o=s):c===`}`||c===`]`?(i+=e.slice(r,s),a+=Z(i,0,1)+i.slice(1),i=``,r=s,o=-1):c!==` `&&c!==` `&&c!==`\r`&&c!==`
|
|
22
|
+
`&&(i+=e.slice(r,s),r=s,o=-1))}let s=n===X?Z(e,r):e.slice(r);return a+i+s}const yr=[`.gitpick.json`,`.gitpick.jsonc`],br=async()=>{let t;for(let r of yr){let i=n.resolve(r);if(e.existsSync(i)){t=i;break}}if(!t)return!1;let r=await e.promises.readFile(t,`utf-8`),i=JSON.parse(vr(r));if(!Array.isArray(i)||!i.every(e=>typeof e==`string`))throw Error(`${n.basename(t)} must be an array of strings`);for(let e of i)await w(process.argv[0],[...process.argv.slice(1),...e.split(/\s+/),`-o`],{stdio:`inherit`});return!0};var xr=`gitpick`,Q=`6.1.0-canary.10`;const Sr=(e,t)=>`\x1b]8;;${t}\x07${e}\x1b]8;;\x07`,Cr=`
|
|
23
|
+
With ${D(`${Sr(`GitPick`,`https://github.com/nrjdalal/gitpick`)}`)} clone specific directories or files from GitHub, GitLab, Bitbucket and Codeberg!
|
|
24
24
|
|
|
25
|
-
$ gitpick ${
|
|
25
|
+
$ gitpick ${j(`<url>`)} ${A(`[target]`)} ${M(`[options]`)}
|
|
26
26
|
|
|
27
|
-
${
|
|
27
|
+
${D(`Hint:`)}
|
|
28
28
|
[target] and [options] are optional and if not specified,
|
|
29
29
|
GitPick fallbacks to the default behavior of \`git clone\`
|
|
30
30
|
A \`.gitpickignore\` at the root of the picked path excludes matching paths from the copy
|
|
31
31
|
|
|
32
|
-
${
|
|
33
|
-
${
|
|
34
|
-
${
|
|
32
|
+
${D(`Arguments:`)}
|
|
33
|
+
${j(`url`)} GitHub/GitLab/Bitbucket/Codeberg URL with path to file/folder/repository
|
|
34
|
+
${A(`target`)} Directory to clone into (optional)
|
|
35
35
|
|
|
36
|
-
${
|
|
37
|
-
${
|
|
38
|
-
${
|
|
39
|
-
${
|
|
40
|
-
${
|
|
41
|
-
${
|
|
42
|
-
${
|
|
43
|
-
${
|
|
36
|
+
${D(`Options:`)}
|
|
37
|
+
${M(`-i, --interactive`)} Browse and pick files/folders interactively
|
|
38
|
+
${M(`-b, --branch`)} Branch/SHA to clone
|
|
39
|
+
${M(`-o, --overwrite`)} Skip overwrite prompt
|
|
40
|
+
${M(`-r, --recursive`)} Clone submodules
|
|
41
|
+
${M(`-q, --quiet`)} Suppress all output except errors
|
|
42
|
+
${M(`-n, --dry-run`)} Show what would be cloned without cloning
|
|
43
|
+
${M(`-w, --watch [time]`)} Watch the repository and sync every [time]
|
|
44
44
|
(e.g. 1h, 30m, 15s)
|
|
45
|
-
${
|
|
46
|
-
${
|
|
47
|
-
${
|
|
48
|
-
${
|
|
49
|
-
${
|
|
50
|
-
${
|
|
51
|
-
${
|
|
45
|
+
${M(` --init`)} Initialize the cloned output as a new git repository
|
|
46
|
+
${M(` --auto-commit`)} Commit with message "chore: gitpick'ed" (implies --init)
|
|
47
|
+
${M(` --commit <msg>`)} Commit with <msg> (implies --init)
|
|
48
|
+
${M(` --tree`)} List copied files as a tree
|
|
49
|
+
${M(` --verbose`)} Show detailed clone information
|
|
50
|
+
${M(`-h, --help`)} display help for command
|
|
51
|
+
${M(`-v, --version`)} display the version number
|
|
52
52
|
|
|
53
|
-
${
|
|
53
|
+
${D(`Examples:`)}
|
|
54
54
|
$ gitpick <url>
|
|
55
55
|
$ gitpick <url> [target]
|
|
56
56
|
$ gitpick <url> [target] -b [branch/SHA]
|
|
@@ -61,13 +61,13 @@ ${T(`Examples:`)}
|
|
|
61
61
|
$ gitpick https://bitbucket.org/owner/repo
|
|
62
62
|
$ gitpick https://codeberg.org/owner/repo
|
|
63
63
|
|
|
64
|
-
š More awesome tools at ${
|
|
65
|
-
`).filter(Boolean);for(let i of t){let t=i.split(`/`);for(let e=1;e<t.length;e++){let n=t.slice(0,e).join(`/`);c.some(e=>e.path===n)||c.push({path:n,type:`tree`})}let a=n.join(r,i);try{let t=await e.promises.lstat(a);if(t.isSymbolicLink()){let t=await e.promises.readlink(a),n=!1;try{n=(await e.promises.stat(a)).isDirectory()}catch{}c.push({path:i,type:`symlink`,linkTarget:n?t+`/`:t})}else c.push({path:i,type:`blob`,size:t.size})}catch{}}l=!0}catch{}if(!l){async function t(r,i){let a;try{a=await e.promises.readdir(r,{withFileTypes:!0})}catch{return}for(let o of a){if(o.name===`.git`)continue;let a=i?`${i}/${o.name}`:o.name,s=n.join(r,o.name);if(o.isSymbolicLink()){let t=await e.promises.readlink(s),n=!1;try{n=(await e.promises.stat(s)).isDirectory()}catch{}c.push({path:a,type:`symlink`,linkTarget:n?t+`/`:t})}else if(o.isDirectory())c.push({path:a,type:`tree`}),await t(s,a);else try{let t=await e.promises.stat(s);c.push({path:a,type:`blob`,size:t.size})}catch{}}}await t(r,``)}c.length||(console.log(
|
|
66
|
-
Directory is empty.`)),process.exit(0));let u=await
|
|
67
|
-
No files selected.`),process.exit(0)),s.dryRun){console.log(`\n${
|
|
68
|
-
`)),process.exit(0)}let c=s.tree||s.quiet;c||console.log(`\nWith ${
|
|
69
|
-
Repository has no files.`)),process.exit(0));let p=await
|
|
70
|
-
No files selected.`),process.exit(0)),s.dryRun){console.log(`\n${
|
|
71
|
-
`)),
|
|
72
|
-
`)};if(s.dryRun){if(s.tree){let r=n.resolve(t.tmpdir(),
|
|
64
|
+
š More awesome tools at ${M(`https://github.com/nrjdalal`)}`,$=e=>{let r=process.cwd(),i=t.homedir(),a=n.sep;return e===r?`.`:e.startsWith(r+a)?`./`+n.relative(r,e).replaceAll(a,`/`):e.startsWith(i+a)?`~/`+n.relative(i,e).replaceAll(a,`/`):e},wr=async(t,r=``)=>{let i=(await e.promises.readdir(t,{withFileTypes:!0})).filter(e=>e.name!==`.git`).sort((e,t)=>e.name.localeCompare(t.name,void 0,{sensitivity:`base`}));for(let a=0;a<i.length;a++){let o=i[a],s=a===i.length-1,c=s?`āāā `:`āāā `,l=n.join(t,o.name);if(o.isSymbolicLink()){let t=await e.promises.readlink(l),n=!1;try{n=e.statSync(l).isDirectory()}catch{}process.stdout.write(`${r}${c}${j(o.name)} -> ${n?M(t):t}\n`)}else o.isDirectory()?(process.stdout.write(`${r}${c}${M(o.name)}\n`),await wr(l,`${r}${s?` `:`ā `}`)):process.stdout.write(`${r}${c}${o.name}\n`)}},Tr=e=>{try{return r(e)}catch(e){throw Error(`Error parsing arguments: ${e.message}`)}},Er=async(t,r,i,a,o)=>{let s=0,c=[];for(let l of t){let t=n.join(r,l),u=n.join(i,l),d=await(o?e.promises.lstat:e.promises.stat)(t).catch(()=>null);if(!d)continue;let f=n.relative(a.srcRoot,t);if(f!==`.gitpickignore`&&!a.matcher?.ignores(f,d.isDirectory()))if(await e.promises.mkdir(n.dirname(u),{recursive:!0}),o&&d.isSymbolicLink()){let n=await e.promises.readlink(t);try{await e.promises.rm(u,{force:!0}),await e.promises.symlink(n,u),s++,c.push(l)}catch(e){console.log(j(` Warning: failed to copy symlink ${l}: ${e.message}`))}}else if(d.isDirectory()){await e.promises.mkdir(u,{recursive:!0});let r=await pe(t,u,void 0,a);s+=r.length;for(let e of r)c.push(n.join(l,e))}else await e.promises.copyFile(t,u),s++,c.push(l)}return{copiedFiles:s,copied:c}};(async()=>{hr();try{let{positionals:r,values:i}=Tr({allowPositionals:!0,options:{branch:{type:`string`,short:`b`},commit:{type:`string`},"auto-commit":{type:`boolean`},"dry-run":{type:`boolean`,short:`n`},force:{type:`boolean`,short:`f`},help:{type:`boolean`,short:`h`},init:{type:`boolean`},interactive:{type:`boolean`,short:`i`},quiet:{type:`boolean`,short:`q`},tree:{type:`boolean`},verbose:{type:`boolean`},overwrite:{type:`boolean`,short:`o`},recursive:{type:`boolean`,short:`r`},version:{type:`boolean`,short:`v`},watch:{type:`string`,short:`w`}}});r.length||(i.version&&(console.log(`\n${xr}@${Q}`),process.exit(0)),i.interactive?r.push(`.`):(await br()&&process.exit(0),console.log(Cr),process.exit(0))),r[0]===`clone`&&r.shift();let[a,o]=r,s={branch:i.branch,commit:i.commit,autoCommit:i[`auto-commit`],dryRun:i[`dry-run`],force:i.force,init:i.init,interactive:i.interactive,quiet:i.quiet,tree:i.tree,verbose:i.verbose,overwrite:i.overwrite,recursive:i.recursive,watch:i.watch};if((a===`.`||a.startsWith(`./`)||a.startsWith(`../`)||a.startsWith(`/`)||a.startsWith(`~/`)||s.interactive&&!a.includes(`/`)&&!a.startsWith(`http`)&&!a.startsWith(`git@`))&&s.interactive){if(!e.existsSync(n.resolve(a.startsWith(`~/`)?a.replace(`~`,t.homedir()):a))){if(o)throw Error(`Directory not found: ${a}`);o=a,a=`.`}if(!process.stdout.isTTY)throw Error(`Interactive mode requires a TTY`);let r=n.resolve(a.startsWith(`~/`)?a.replace(`~`,t.homedir()):a);if(!e.existsSync(r))throw Error(`Directory not found: ${a}`);if(!e.statSync(r).isDirectory())throw Error(`Not a directory: ${a}`);let i=o?n.resolve(o):null,c=[],l=!1;try{let t=(await w(`git`,[`ls-files`,`--cached`,`--others`,`--exclude-standard`],{cwd:r})).stdout.trim().split(`
|
|
65
|
+
`).filter(Boolean);for(let i of t){let t=i.split(`/`);for(let e=1;e<t.length;e++){let n=t.slice(0,e).join(`/`);c.some(e=>e.path===n)||c.push({path:n,type:`tree`})}let a=n.join(r,i);try{let t=await e.promises.lstat(a);if(t.isSymbolicLink()){let t=await e.promises.readlink(a),n=!1;try{n=(await e.promises.stat(a)).isDirectory()}catch{}c.push({path:i,type:`symlink`,linkTarget:n?t+`/`:t})}else c.push({path:i,type:`blob`,size:t.size})}catch{}}l=!0}catch{}if(!l){async function t(r,i){let a;try{a=await e.promises.readdir(r,{withFileTypes:!0})}catch{return}for(let o of a){if(o.name===`.git`)continue;let a=i?`${i}/${o.name}`:o.name,s=n.join(r,o.name);if(o.isSymbolicLink()){let t=await e.promises.readlink(s),n=!1;try{n=(await e.promises.stat(s)).isDirectory()}catch{}c.push({path:a,type:`symlink`,linkTarget:n?t+`/`:t})}else if(o.isDirectory())c.push({path:a,type:`tree`}),await t(s,a);else try{let t=await e.promises.stat(s);c.push({path:a,type:`blob`,size:t.size})}catch{}}}await t(r,``)}c.length||(console.log(j(`
|
|
66
|
+
Directory is empty.`)),process.exit(0));let u=await ar(c,`${$(r)}`,r);if(u.length||(console.log(`
|
|
67
|
+
No files selected.`),process.exit(0)),s.dryRun){console.log(`\n${A(`ā`)} Would pick ${u.length} path${u.length===1?``:`s`}:`);for(let e of u)console.log(` ${e}`);console.log(),process.exit(0)}if(!i){console.log(`\n${A(`ā`)} Selected ${u.length} path${u.length===1?``:`s`}:`);for(let e of u)console.log(` ${e}`);console.log(),process.exit(0)}let d=n.resolve(i);if(r===d)throw Error(`Source and target directories are the same`);if(d.startsWith(r+n.sep))throw Error(`Target directory is inside the source directory`);console.log(`\n${A(`ā`)} Picking ${u.length} selected path${u.length===1?``:`s`}...`),s.overwrite=s.overwrite||s.force,e.existsSync(i)&&!s.overwrite&&(await e.promises.readdir(i)).length&&(console.log(`${j(`\nWarning: The target directory exists at ${A(o)} and is not empty. Use ${M(`-f`)} or ${M(`-o`)} to overwrite.`)}`),process.exit(1)),await e.promises.mkdir(i,{recursive:!0});let{copiedFiles:f,copied:p}=await Er(u,r,i,fe(r),!0);console.log(A(`ā Copied ${f} file${f===1?``:`s`} to ${$(i)}`)),await ke(i,s,p),s.tree&&(process.stdout.write(`\n${D(M($(i)))}\n`),await wr(i),process.stdout.write(`
|
|
68
|
+
`)),process.exit(0)}let c=s.tree||s.quiet;c||console.log(`\nWith ${D(`${Sr(`GitPick`,`https://github.com/nrjdalal/gitpick`)}`)} clone specific files, folders, branches,\ncommits and much more from GitHub, GitLab, Bitbucket and Codeberg!`);let l=await cr(a,{branch:s.branch,target:o});if(l.type===`blob`){let e=l.target.startsWith(`/`),t=l.target.split(/[/\\]/).filter(e=>e!==``),n=t[t.length-1];n!==`.`&&n!==`..`&&n?.includes(`.`)?t.pop():n=l.path.split(`/`).pop()||n,l.target=(e?`/`:``)+[...t,n].join(`/`)}c||console.info(`\n${A(`ā`)} ${l.owner}/${l.repository} ${M(l.type+`:`+l.branch)} ${l.type===`repository`?`> ${A(l.target)}`:`${l.path.length?j(l.path)+` >`:`>`} ${A(l.target)}`}`);let u=n.resolve(l.target);if(s.interactive){if(!process.stdout.isTTY)throw Error(`Interactive mode requires a TTY`);let r=n.resolve(t.tmpdir(),F(`gitpick-interactive-`)),i=`https://${l.token?l.token+`@`:``}${l.host}/${l.owner}/${l.repository}.git`,a=ae();a.start(`Fetching ${l.owner}/${l.repository}...`);let o=await we(i,r,l,s.recursive);await Te(i,r,l,s.recursive,o);let c=l.path?n.join(r,l.path):r,d=[];async function f(t,r){let i=await e.promises.readdir(t,{withFileTypes:!0});for(let a of i){if(a.name===`.git`)continue;let i=r?`${r}/${a.name}`:a.name,o=n.join(t,a.name);if(a.isSymbolicLink()){let t=await e.promises.readlink(o),n=!1;try{n=(await e.promises.stat(o)).isDirectory()}catch{}d.push({path:i,type:`symlink`,linkTarget:n?t+`/`:t})}else if(a.isDirectory())d.push({path:i,type:`tree`}),await f(o,i);else{let t=await e.promises.stat(o);d.push({path:i,type:`blob`,size:t.size})}}}await f(c,``),a.success(`Fetched ${l.owner}/${l.repository} (${d.length} entries)`),d.length||(await e.promises.rm(r,{recursive:!0,force:!0}),console.log(j(`
|
|
69
|
+
Repository has no files.`)),process.exit(0));let p=await ar(d,`${l.owner}/${l.repository} ${M(`repository:`+l.branch)} > ${A(l.target)}`,c);if(p.length||(await e.promises.rm(r,{recursive:!0,force:!0}),console.log(`
|
|
70
|
+
No files selected.`),process.exit(0)),s.dryRun){console.log(`\n${A(`ā`)} Would pick ${p.length} path${p.length===1?``:`s`}:`);for(let e of p)console.log(` ${e}`);await e.promises.rm(r,{recursive:!0,force:!0}),console.log(),Y(Q,!1),process.exit(0)}console.log(`\n${A(`ā`)} Picking ${p.length} selected path${p.length===1?``:`s`}...`),e.existsSync(u)&&!s.overwrite&&(await e.promises.readdir(u)).length&&(await e.promises.rm(r,{recursive:!0,force:!0}),console.log(`${j(`\nWarning: The target directory exists at ${A(l.target)} and is not empty. Use ${M(`-f`)} or ${M(`-o`)} to overwrite.`)}`),process.exit(1)),await e.promises.mkdir(u,{recursive:!0});let{copiedFiles:m,copied:h}=await Er(p,c,u,fe(c),!1);await e.promises.rm(r,{recursive:!0,force:!0}),console.log(A(`ā Copied ${m} file${m===1?``:`s`} to ${$(u)}`)),await ke(u,s,h),s.tree&&(process.stdout.write(`\n${D(M($(u)))}\n`),await wr(u),process.stdout.write(`
|
|
71
|
+
`)),Y(Q,!1),process.exit(0)}let d=async t=>{e.statSync(t).isDirectory()?(process.stdout.write(`${D(M($(u)))}\n`),await wr(t)):(process.stdout.write(`${D(M($(n.dirname(u))))}\n`),process.stdout.write(`āāā ${n.basename(u)}\n`)),process.stdout.write(`
|
|
72
|
+
`)};if(s.dryRun){if(s.tree){let r=n.resolve(t.tmpdir(),F(`gitpick-dry-`));try{await I(l,s,r),await d(r)}finally{await e.promises.rm(r,{recursive:!0,force:!0})}}c||console.log(),Y(Q,c),process.exit(0)}if(s.overwrite=s.overwrite||s.force,s.watch&&(s.overwrite=!0),e.existsSync(u)&&!s.overwrite&&(l.type===`blob`&&(console.log(`${j(`\nWarning: The target file exists at ${A(l.target)}. Use ${M(`-f`)} or ${M(`-o`)} to overwrite.`)}`),process.exit(1)),(await e.promises.readdir(u)).length&&(console.log(`${j(`\nWarning: The target directory exists at ${A(l.target)} and is not empty. Use ${M(`-f`)} or ${M(`-o`)} to overwrite.`)}`),process.exit(1))),s.watch){c||console.log(`\nš Watching every ${or(s.watch)/1e3+`s`}\n`);let{files:e}=await I(l,s,u);await ke(u,s,e),s.tree&&await d(u);let t=or(s.watch);setInterval(async()=>{await I(l,s,u),s.tree&&await d(u)},t)}else{let{files:e}=await I(l,s,u);await ke(u,s,e),s.tree&&await d(u),Y(Q,c),process.exit(0)}}catch(e){e instanceof Error?console.log(D(`\n${k(`Error: `)}`)+e.message):console.log(D(`${k(`
|
|
73
73
|
Unexpected Error: `)}`)+JSON.stringify(e,null,2)),process.exit(1)}})();export{};
|